diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:15 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:15 +0000 |
commit | 637b4ffa01f42a6df598d4fc367d645a600128e1 (patch) | |
tree | db067f5833a212e230e6dc2cc0b822629a2eff7e /utils/TableGen | |
parent | d0e9d04ab04d862392cbc84543ad9d77c58eb966 (diff) | |
download | external_llvm-637b4ffa01f42a6df598d4fc367d645a600128e1.zip external_llvm-637b4ffa01f42a6df598d4fc367d645a600128e1.tar.gz external_llvm-637b4ffa01f42a6df598d4fc367d645a600128e1.tar.bz2 |
[AVX] Make CodeInit Unique
Use a StringMap to ensure CodeInits are unique and created only
once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136492 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/Record.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index ee5db47..133a158 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -575,7 +575,12 @@ const StringInit *StringInit::get(const std::string &V) { } const CodeInit *CodeInit::get(const std::string &V) { - return new CodeInit(V); + typedef StringMap<CodeInit *> Pool; + static Pool ThePool; + + CodeInit *&I = ThePool[V]; + if (!I) I = new CodeInit(V); + return I; } const ListInit *ListInit::get(ArrayRef<const Init *> Range, RecTy *EltTy) { |