[AVX] Make ListInits Unique
[oota-llvm.git] / utils / TableGen / Record.h
index c3ce2dd6046187fb18248df99e56de18c12b6ede..cbde0e9bdbc783c70f3facd7e24c169e98ad2e70 100644 (file)
@@ -1,3 +1,4 @@
+
 //===- Record.h - Classes to represent Table Records ------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
@@ -16,6 +17,7 @@
 #define RECORD_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/DataTypes.h"
@@ -648,11 +650,9 @@ public:
 /// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
 /// It contains a vector of bits, whose size is determined by the type.
 ///
-class BitsInit : public Init {
+class BitsInit : public Init, public FoldingSetNode {
   std::vector<const Init*> Bits;
 
-  BitsInit(unsigned Size) : Bits(Size) {}
-
   BitsInit(ArrayRef<const Init *> Range) : Bits(Range.begin(), Range.end()) {}
 
   BitsInit(const BitsInit &Other);  // Do not define.
@@ -661,6 +661,8 @@ class BitsInit : public Init {
 public:
   static const BitsInit *get(ArrayRef<const Init *> Range);
 
+  void Profile(FoldingSetNodeID &ID) const;
+
   unsigned getNumBits() const { return Bits.size(); }
 
   const Init *getBit(unsigned Bit) const {
@@ -800,15 +802,12 @@ public:
 
 /// ListInit - [AL, AH, CL] - Represent a list of defs
 ///
-class ListInit : public TypedInit {
+class ListInit : public TypedInit, public FoldingSetNode {
   std::vector<const Init*> Values;
 public:
   typedef std::vector<const Init*>::const_iterator const_iterator;
 
-  explicit ListInit(std::vector<const Init*> &Vs, RecTy *EltTy)
-    : TypedInit(ListRecTy::get(EltTy)) {
-    Values.swap(Vs);
-  }
+private:
   explicit ListInit(ArrayRef<const Init *> Range, RecTy *EltTy)
       : TypedInit(ListRecTy::get(EltTy)), Values(Range.begin(), Range.end()) {}
 
@@ -818,6 +817,8 @@ public:
 public:
   static const ListInit *get(ArrayRef<const Init *> Range, RecTy *EltTy);
 
+  void Profile(FoldingSetNodeID &ID) const;
+
   unsigned getSize() const { return Values.size(); }
   const Init *getElement(unsigned i) const {
     assert(i < Values.size() && "List element index out of range!");