[llvm-commits] [llvm] r136494 - /llvm/trunk/utils/TableGen/Record.cpp

David Greene greened at obbligato.org
Fri Jul 29 12:07:18 PDT 2011


Author: greened
Date: Fri Jul 29 14:07:18 2011
New Revision: 136494

URL: http://llvm.org/viewvc/llvm-project?rev=136494&view=rev
Log:
[AVX] Make UnOpInit Unique

Make sure UnOpInits are unique and created only once.  This will be
important for AVX/SIMD as many operators will be used to generate
patterns and other relevant data.

Modified:
    llvm/trunk/utils/TableGen/Record.cpp

Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=136494&r1=136493&r2=136494&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Fri Jul 29 14:07:18 2011
@@ -714,7 +714,16 @@
 }
 
 const UnOpInit *UnOpInit::get(UnaryOp opc, const Init *lhs, RecTy *Type) {
-  return new UnOpInit(opc, lhs, Type);
+  typedef std::pair<std::pair<unsigned, const Init *>, RecTy *> Key;
+
+  typedef DenseMap<Key, UnOpInit *> Pool;
+  static Pool ThePool;  
+
+  Key TheKey(std::make_pair(std::make_pair(opc, lhs), Type));
+
+  UnOpInit *&I = ThePool[TheKey];
+  if (!I) I = new UnOpInit(opc, lhs, Type);
+  return I;
 }
 
 const Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {





More information about the llvm-commits mailing list