diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:20 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:20 +0000 |
commit | b76a1e6993fa4020a6c1ef552fdf4f564b706fac (patch) | |
tree | cac8bdbf41230143c2bf74dc820f363cb213af60 | |
parent | 65a5b8cb3b32db7681afca62d3e9d92941dbf979 (diff) |
[AVX] Make TernOpInit Unique
Make sure TernOpInits 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@136496 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/Record.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 56a46e195b..a6b5c4b884 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -975,7 +975,26 @@ std::string BinOpInit::getAsString() const { const TernOpInit *TernOpInit::get(TernaryOp opc, const Init *lhs, const Init *mhs, const Init *rhs, RecTy *Type) { - return new TernOpInit(opc, lhs, mhs, rhs, Type); + typedef std::pair< + std::pair< + std::pair<std::pair<unsigned, RecTy *>, const Init *>, + const Init * + >, + const Init * + > Key; + + typedef DenseMap<Key, TernOpInit *> Pool; + static Pool ThePool; + + Key TheKey(std::make_pair(std::make_pair(std::make_pair(std::make_pair(opc, + Type), + lhs), + mhs), + rhs)); + + TernOpInit *&I = ThePool[TheKey]; + if (!I) I = new TernOpInit(opc, lhs, mhs, rhs, Type); + return I; } static const Init *ForeachHelper(const Init *LHS, const Init *MHS, |