summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-29 19:07:24 +0000
committerDavid Greene <greened@obbligato.org>2011-07-29 19:07:24 +0000
commit65bf3ca9aa474db6c5c2a0d3ea0f4a22af514184 (patch)
treef242cef704491c6dff76528d3d171d628d096b8e
parent08f71e3e7437359f94fed3207bc64d8cc54ef3f3 (diff)
downloadllvm-65bf3ca9aa474db6c5c2a0d3ea0f4a22af514184.tar.gz
llvm-65bf3ca9aa474db6c5c2a0d3ea0f4a22af514184.tar.bz2
llvm-65bf3ca9aa474db6c5c2a0d3ea0f4a22af514184.tar.xz
[AVX] Make FieldInit Unique
Make sure FieldInits are unique and created only once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136500 91177308-0d34-0410-b5e6-96231b3b80d8
-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 89de3edfd1..d4e6083975 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -1475,7 +1475,15 @@ std::string DefInit::getAsString() const {
}
const FieldInit *FieldInit::get(const Init *R, const std::string &FN) {
- return new FieldInit(R, FN);
+ typedef std::pair<const Init *, TableGenStringKey> Key;
+ typedef DenseMap<Key, FieldInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(R, FN));
+
+ FieldInit *&I = ThePool[TheKey];
+ if (!I) I = new FieldInit(R, FN);
+ return I;
}
const Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV,