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