summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-29 19:07:20 +0000
committerDavid Greene <greened@obbligato.org>2011-07-29 19:07:20 +0000
commitdaba48800fa94e3c712fcf300c31bf4f5a27d550 (patch)
tree5d043c3cfc50c59afe671805cf1d3a1728bb7848
parent3acab9c5fe1f6b4818217820d65b4067ec51ad73 (diff)
downloadbcm5719-llvm-daba48800fa94e3c712fcf300c31bf4f5a27d550.tar.gz
bcm5719-llvm-daba48800fa94e3c712fcf300c31bf4f5a27d550.zip
[AVX] Make TernOpInit Unique
Make sure TernOpInits 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. llvm-svn: 136496
-rw-r--r--llvm/utils/TableGen/Record.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp
index 56a46e195b4..a6b5c4b884d 100644
--- a/llvm/utils/TableGen/Record.cpp
+++ b/llvm/utils/TableGen/Record.cpp
@@ -975,7 +975,26 @@ std::string BinOpInit::getAsString() const {
const TernOpInit *TernOpInit::get(TernaryOp opc, const Init *lhs,
const Init *mhs, const Init *rhs,
RecTy *Type) {
- return new TernOpInit(opc, lhs, mhs, rhs, Type);
+ typedef std::pair<
+ std::pair<
+ std::pair<std::pair<unsigned, RecTy *>, const Init *>,
+ const Init *
+ >,
+ const Init *
+ > Key;
+
+ typedef DenseMap<Key, TernOpInit *> Pool;
+ static Pool ThePool;
+
+ Key TheKey(std::make_pair(std::make_pair(std::make_pair(std::make_pair(opc,
+ Type),
+ lhs),
+ mhs),
+ rhs));
+
+ TernOpInit *&I = ThePool[TheKey];
+ if (!I) I = new TernOpInit(opc, lhs, mhs, rhs, Type);
+ return I;
}
static const Init *ForeachHelper(const Init *LHS, const Init *MHS,
OpenPOWER on IntegriCloud