[AVX] Make IntInit Unique
[oota-llvm.git] / utils / TableGen / Record.cpp
index 77c0d1a491dda2b472bdee30d2f3dcce6fae5870..54edfe5ea8fabff40c79cfb46c5a083619127212 100644 (file)
@@ -539,7 +539,12 @@ const Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) const {
 }
 
 const IntInit *IntInit::get(int64_t V) {
-  return new IntInit(V);
+  typedef DenseMap<int64_t, IntInit *> Pool;
+  static Pool ThePool;
+
+  IntInit *&I = ThePool[V];
+  if (!I) I = new IntInit(V);
+  return I;
 }
 
 std::string IntInit::getAsString() const {