diff options
author | David Greene <greened@obbligato.org> | 2011-07-29 19:07:11 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-29 19:07:11 +0000 |
commit | 726bbde3c4ac5a279c86d1632b7b94498b01854a (patch) | |
tree | 517f942a50e616422893671b5c3915db1ab9ffe3 /utils/TableGen/Record.cpp | |
parent | 0ffd167a01cc44e1c3bddf4d71d772a38834a30b (diff) | |
download | llvm-726bbde3c4ac5a279c86d1632b7b94498b01854a.tar.gz llvm-726bbde3c4ac5a279c86d1632b7b94498b01854a.tar.bz2 llvm-726bbde3c4ac5a279c86d1632b7b94498b01854a.tar.xz |
[AVX] Make BitsInit Unique
Make BitsInit a FoldingSetNode so we can unique it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r-- | utils/TableGen/Record.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 3e0038c9e6..77c0d1a491 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -16,6 +16,8 @@ #include "Error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Format.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" @@ -455,8 +457,36 @@ const BitInit *BitInit::get(bool V) { return V ? &True : &False; } +static void +ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef<const Init *> Range) { + ID.AddInteger(Range.size()); + + for (ArrayRef<const Init *>::iterator i = Range.begin(), + iend = Range.end(); + i != iend; + ++i) + ID.AddPointer(*i); +} + const BitsInit *BitsInit::get(ArrayRef<const Init *> Range) { - return new BitsInit(Range); + typedef FoldingSet<BitsInit> Pool; + static Pool ThePool; + + FoldingSetNodeID ID; + ProfileBitsInit(ID, Range); + + void *IP = 0; + if (const BitsInit *I = ThePool.FindNodeOrInsertPos(ID, IP)) + return I; + + BitsInit *I = new BitsInit(Range); + ThePool.InsertNode(I, IP); + + return I; +} + +void BitsInit::Profile(FoldingSetNodeID &ID) const { + ProfileBitsInit(ID, Bits); } const Init * |