[llvm-commits] [PATCH 16/20] [AVX] Make VarInit Unique
David Greene
dag at cray.com
Tue Jul 19 13:11:51 PDT 2011
Make sure VarInits are unique and created only once.
---
utils/TableGen/Record.cpp | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git oldutils/TableGen/Record.cpp newutils/TableGen/Record.cpp
index 64ddced..6b37898 100644
--- oldutils/TableGen/Record.cpp
+++ newutils/TableGen/Record.cpp
@@ -1299,7 +1299,21 @@ TypedInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
const VarInit *VarInit::get(const std::string &VN, RecTy *T) {
- return new VarInit(VN, T);
+ typedef std::pair<RecTy *, std::string> Key;
+ typedef DenseMap<Key, VarInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(T, VN));
+ Pool::iterator Result = ThePool.find(TheKey);
+
+ if (Result == ThePool.end()) {
+ VarInit *New = new VarInit(VN, T);
+ 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 *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,
--
1.7.6
More information about the llvm-commits
mailing list