diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:23 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:23 +0000 |
commit | 08f71e3e7437359f94fed3207bc64d8cc54ef3f3 (patch) | |
tree | e6b5637aeda8016c19322530cec193b4ad9830dc /utils | |
parent | aa839b8fa3e4500551f23b20491c1c55e89567b5 (diff) | |
download | external_llvm-08f71e3e7437359f94fed3207bc64d8cc54ef3f3.zip external_llvm-08f71e3e7437359f94fed3207bc64d8cc54ef3f3.tar.gz external_llvm-08f71e3e7437359f94fed3207bc64d8cc54ef3f3.tar.bz2 |
[AVX] Make VarListElementInit Unique
Make sure VarListElementInits are unique and created only once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136499 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 3a022fc..89de3ed 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1414,7 +1414,16 @@ const Init *VarBitInit::resolveReferences(Record &R, const VarListElementInit *VarListElementInit::get(const TypedInit *T, unsigned E) { - return new VarListElementInit(T, E); + typedef std::pair<const TypedInit *, unsigned> Key; + typedef DenseMap<Key, VarListElementInit *> Pool; + + static Pool ThePool; + + Key TheKey(std::make_pair(T, E)); + + VarListElementInit *&I = ThePool[TheKey]; + if (!I) I = new VarListElementInit(T, E); + return I; } std::string VarListElementInit::getAsString() const { |