diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:19 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:19 +0000 |
commit | 65a5b8cb3b32db7681afca62d3e9d92941dbf979 (patch) | |
tree | 33fb30d8e3079f9ca15922e97d326d1df510f2a0 /utils/TableGen/Record.cpp | |
parent | 6f03b636d26bebad3cfcaaa02a2bbc1b3a6c81b8 (diff) | |
download | llvm-65a5b8cb3b32db7681afca62d3e9d92941dbf979.tar.gz llvm-65a5b8cb3b32db7681afca62d3e9d92941dbf979.tar.bz2 llvm-65a5b8cb3b32db7681afca62d3e9d92941dbf979.tar.xz |
[AVX] Make BinOpInit Unique
Make sure BinOpInits are unique and created only once. This will be
important for AVX/SIMD as many operators will be used to generate
patterns and other relevant data.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r-- | utils/TableGen/Record.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 8fc0c18cd4..56a46e195b 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -860,7 +860,20 @@ std::string UnOpInit::getAsString() const { const BinOpInit *BinOpInit::get(BinaryOp opc, const Init *lhs, const Init *rhs, RecTy *Type) { - return new BinOpInit(opc, lhs, rhs, Type); + typedef std::pair< + std::pair<std::pair<unsigned, const Init *>, const Init *>, + RecTy * + > Key; + + typedef DenseMap<Key, BinOpInit *> Pool; + static Pool ThePool; + + Key TheKey(std::make_pair(std::make_pair(std::make_pair(opc, lhs), rhs), + Type)); + + BinOpInit *&I = ThePool[TheKey]; + if (!I) I = new BinOpInit(opc, lhs, rhs, Type); + return I; } const Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { |