diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:22 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:22 +0000 |
commit | aa839b8fa3e4500551f23b20491c1c55e89567b5 (patch) | |
tree | ed50515995b4aacce35c3e62e84d9c49dd8d9c09 /utils | |
parent | e0be0e361a8306a7106ccab27dcf0140a748bfbc (diff) | |
download | external_llvm-aa839b8fa3e4500551f23b20491c1c55e89567b5.zip external_llvm-aa839b8fa3e4500551f23b20491c1c55e89567b5.tar.gz external_llvm-aa839b8fa3e4500551f23b20491c1c55e89567b5.tar.bz2 |
[AVX] Make VarBitInit Unique
Make sure VarBitInits are unique and created only once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/Record.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 68f9f2a..3a022fc 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1389,7 +1389,16 @@ const Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) const { } const VarBitInit *VarBitInit::get(const TypedInit *T, unsigned B) { - return new VarBitInit(T, B); + typedef std::pair<const TypedInit *, unsigned> Key; + typedef DenseMap<Key, VarBitInit *> Pool; + + static Pool ThePool; + + Key TheKey(std::make_pair(T, B)); + + VarBitInit *&I = ThePool[TheKey]; + if (!I) I = new VarBitInit(T, B); + return I; } std::string VarBitInit::getAsString() const { |