aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/TableGen/Record.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 8fc0c18cd4..56a46e195b 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -860,7 +860,20 @@ std::string UnOpInit::getAsString() const {
const BinOpInit *BinOpInit::get(BinaryOp opc, const Init *lhs,
const Init *rhs, RecTy *Type) {
- return new BinOpInit(opc, lhs, rhs, Type);
+ typedef std::pair<
+ std::pair<std::pair<unsigned, const Init *>, const Init *>,
+ RecTy *
+ > Key;
+
+ typedef DenseMap<Key, BinOpInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(std::make_pair(std::make_pair(opc, lhs), rhs),
+ Type));
+
+ BinOpInit *&I = ThePool[TheKey];
+ if (!I) I = new BinOpInit(opc, lhs, rhs, Type);
+ return I;
}
const Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {