mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[TableGen] Don't leak Expanders and Operators in SetTheory.
llvm-svn: 235697
This commit is contained in:
parent
450d5f5eed
commit
60d2b0d189
@ -95,17 +95,17 @@ private:
|
||||
ExpandMap Expansions;
|
||||
|
||||
// Known DAG operators by name.
|
||||
StringMap<Operator*> Operators;
|
||||
StringMap<std::unique_ptr<Operator>> Operators;
|
||||
|
||||
// Typed expanders by class name.
|
||||
StringMap<Expander*> Expanders;
|
||||
StringMap<std::unique_ptr<Expander>> Expanders;
|
||||
|
||||
public:
|
||||
/// Create a SetTheory instance with only the standard operators.
|
||||
SetTheory();
|
||||
|
||||
/// addExpander - Add an expander for Records with the named super class.
|
||||
void addExpander(StringRef ClassName, Expander*);
|
||||
void addExpander(StringRef ClassName, std::unique_ptr<Expander>);
|
||||
|
||||
/// addFieldExpander - Add an expander for ClassName that simply evaluates
|
||||
/// FieldName in the Record to get the set elements. That is all that is
|
||||
@ -118,7 +118,7 @@ public:
|
||||
void addFieldExpander(StringRef ClassName, StringRef FieldName);
|
||||
|
||||
/// addOperator - Add a DAG operator.
|
||||
void addOperator(StringRef Name, Operator*);
|
||||
void addOperator(StringRef Name, std::unique_ptr<Operator>);
|
||||
|
||||
/// evaluate - Evaluate Expr and append the resulting set to Elts.
|
||||
void evaluate(Init *Expr, RecSet &Elts, ArrayRef<SMLoc> Loc);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ CodeGenRegBank::CodeGenRegBank(RecordKeeper &Records) {
|
||||
// Configure register Sets to understand register classes and tuples.
|
||||
Sets.addFieldExpander("RegisterClass", "MemberList");
|
||||
Sets.addFieldExpander("CalleeSavedRegs", "SaveList");
|
||||
Sets.addExpander("RegisterTuples", new TupleExpander());
|
||||
Sets.addExpander("RegisterTuples", llvm::make_unique<TupleExpander>());
|
||||
|
||||
// Read in the user-defined (named) sub-register indices.
|
||||
// More indices will be synthesized later.
|
||||
|
@ -93,8 +93,8 @@ CodeGenSchedModels::CodeGenSchedModels(RecordKeeper &RK,
|
||||
|
||||
// Allow Set evaluation to recognize the dags used in InstRW records:
|
||||
// (instrs Op1, Op1...)
|
||||
Sets.addOperator("instrs", new InstrsOp);
|
||||
Sets.addOperator("instregex", new InstRegexOp(Target));
|
||||
Sets.addOperator("instrs", llvm::make_unique<InstrsOp>());
|
||||
Sets.addOperator("instregex", llvm::make_unique<InstRegexOp>(Target));
|
||||
|
||||
// Instantiate a CodeGenProcModel for each SchedMachineModel with the values
|
||||
// that are explicitly referenced in tablegen records. Resources associated
|
||||
|
Loading…
x
Reference in New Issue
Block a user