[llvm-commits] [llvm] r136496 - /llvm/trunk/utils/TableGen/Record.cpp
David Greene
greened at obbligato.org
Fri Jul 29 12:07:20 PDT 2011
Author: greened
Date: Fri Jul 29 14:07:20 2011
New Revision: 136496
URL: http://llvm.org/viewvc/llvm-project?rev=136496&view=rev
Log:
[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.
Modified:
llvm/trunk/utils/TableGen/Record.cpp
Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=136496&r1=136495&r2=136496&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:20 2011
@@ -975,7 +975,26 @@
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,
More information about the llvm-commits
mailing list