[llvm-commits] [PATCH 13/20] [AVX] Make UnOpInit Unique
David Greene
dag at cray.com
Tue Jul 19 13:11:48 PDT 2011
Make sure UnOpInits 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.
---
utils/TableGen/Record.cpp | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git oldutils/TableGen/Record.cpp newutils/TableGen/Record.cpp
index 5d1ec3a..7adee3b 100644
--- oldutils/TableGen/Record.cpp
+++ newutils/TableGen/Record.cpp
@@ -697,7 +697,22 @@ const Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV,
}
const UnOpInit *UnOpInit::get(UnaryOp opc, const Init *lhs, RecTy *Type) {
- return new UnOpInit(opc, lhs, Type);
+ typedef std::pair<std::pair<unsigned, const Init *>, RecTy *> Key;
+
+ typedef DenseMap<Key, UnOpInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(std::make_pair(opc, lhs), Type));
+ Pool::iterator Result = ThePool.find(TheKey);
+
+ if (Result == ThePool.end()) {
+ UnOpInit *New = new UnOpInit(opc, lhs, Type);
+ bool Inserted = false;
+ tie(Result, Inserted) = ThePool.insert(std::make_pair(TheKey, New));
+ assert(Inserted && "Did not insert new Init into pool!");
+ }
+
+ return Result->second;
}
const Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
--
1.7.6
More information about the llvm-commits
mailing list