aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-29 19:07:21 +0000
committerDavid Greene <greened@obbligato.org>2011-07-29 19:07:21 +0000
commite0be0e361a8306a7106ccab27dcf0140a748bfbc (patch)
tree10391d7f532a55705296215398c587b2b8899da4 /utils/TableGen/Record.cpp
parentb76a1e6993fa4020a6c1ef552fdf4f564b706fac (diff)
[AVX] Make VarInit Unique
Make sure VarInits are unique and created only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index a6b5c4b884..68f9f2a247 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -1294,7 +1294,15 @@ 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 *, TableGenStringKey> Key;
+ typedef DenseMap<Key, VarInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(T, VN));
+
+ VarInit *&I = ThePool[TheKey];
+ if (!I) I = new VarInit(VN, T);
+ return I;
}
const Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,