summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/TableGen/SetTheory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/TableGen/SetTheory.cpp')
-rw-r--r--contrib/llvm/lib/TableGen/SetTheory.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/contrib/llvm/lib/TableGen/SetTheory.cpp b/contrib/llvm/lib/TableGen/SetTheory.cpp
index c99c2ba..92f5b2d 100644
--- a/contrib/llvm/lib/TableGen/SetTheory.cpp
+++ b/contrib/llvm/lib/TableGen/SetTheory.cpp
@@ -12,10 +12,10 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/TableGen/SetTheory.h"
#include "llvm/Support/Format.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
-#include "llvm/TableGen/SetTheory.h"
using namespace llvm;
@@ -245,28 +245,28 @@ void SetTheory::Expander::anchor() {}
SetTheory::SetTheory() {
- addOperator("add", new AddOp);
- addOperator("sub", new SubOp);
- addOperator("and", new AndOp);
- addOperator("shl", new ShlOp);
- addOperator("trunc", new TruncOp);
- addOperator("rotl", new RotOp(false));
- addOperator("rotr", new RotOp(true));
- addOperator("decimate", new DecimateOp);
- addOperator("interleave", new InterleaveOp);
- addOperator("sequence", new SequenceOp);
+ addOperator("add", llvm::make_unique<AddOp>());
+ addOperator("sub", llvm::make_unique<SubOp>());
+ addOperator("and", llvm::make_unique<AndOp>());
+ addOperator("shl", llvm::make_unique<ShlOp>());
+ addOperator("trunc", llvm::make_unique<TruncOp>());
+ addOperator("rotl", llvm::make_unique<RotOp>(false));
+ addOperator("rotr", llvm::make_unique<RotOp>(true));
+ addOperator("decimate", llvm::make_unique<DecimateOp>());
+ addOperator("interleave", llvm::make_unique<InterleaveOp>());
+ addOperator("sequence", llvm::make_unique<SequenceOp>());
}
-void SetTheory::addOperator(StringRef Name, Operator *Op) {
- Operators[Name] = Op;
+void SetTheory::addOperator(StringRef Name, std::unique_ptr<Operator> Op) {
+ Operators[Name] = std::move(Op);
}
-void SetTheory::addExpander(StringRef ClassName, Expander *E) {
- Expanders[ClassName] = E;
+void SetTheory::addExpander(StringRef ClassName, std::unique_ptr<Expander> E) {
+ Expanders[ClassName] = std::move(E);
}
void SetTheory::addFieldExpander(StringRef ClassName, StringRef FieldName) {
- addExpander(ClassName, new FieldExpander(FieldName));
+ addExpander(ClassName, llvm::make_unique<FieldExpander>(FieldName));
}
void SetTheory::evaluate(Init *Expr, RecSet &Elts, ArrayRef<SMLoc> Loc) {
@@ -289,10 +289,10 @@ void SetTheory::evaluate(Init *Expr, RecSet &Elts, ArrayRef<SMLoc> Loc) {
DefInit *OpInit = dyn_cast<DefInit>(DagExpr->getOperator());
if (!OpInit)
PrintFatalError(Loc, "Bad set expression: " + Expr->getAsString());
- Operator *Op = Operators.lookup(OpInit->getDef()->getName());
- if (!Op)
+ auto I = Operators.find(OpInit->getDef()->getName());
+ if (I == Operators.end())
PrintFatalError(Loc, "Unknown set operator: " + Expr->getAsString());
- Op->apply(*this, DagExpr, Elts, Loc);
+ I->second->apply(*this, DagExpr, Elts, Loc);
}
const RecVec *SetTheory::expand(Record *Set) {
@@ -307,11 +307,12 @@ const RecVec *SetTheory::expand(Record *Set) {
// Skip unnamed superclasses.
if (!dyn_cast<StringInit>(SC[i]->getNameInit()))
continue;
- if (Expander *Exp = Expanders.lookup(SC[i]->getName())) {
+ auto I = Expanders.find(SC[i]->getName());
+ if (I != Expanders.end()) {
// This breaks recursive definitions.
RecVec &EltVec = Expansions[Set];
RecSet Elts;
- Exp->expand(*this, Set, Elts);
+ I->second->expand(*this, Set, Elts);
EltVec.assign(Elts.begin(), Elts.end());
return &EltVec;
}
OpenPOWER on IntegriCloud