mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
[TableGen] Make DAGInstruction own Pattern to avoid leaking it.
Reviewers: dsanders, craig.topper, stoklund, nhaehnle Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D47525 llvm-svn: 334275
This commit is contained in:
parent
b9397a046f
commit
cc1e276c98
@ -3423,7 +3423,7 @@ const DAGInstruction &CodeGenDAGPatterns::parseInstructionPattern(
|
|||||||
assert(!DAGInsts.count(CGI.TheDef) && "Instruction already parsed!");
|
assert(!DAGInsts.count(CGI.TheDef) && "Instruction already parsed!");
|
||||||
|
|
||||||
// Parse the instruction.
|
// Parse the instruction.
|
||||||
TreePattern *I = new TreePattern(CGI.TheDef, Pat, true, *this);
|
auto I = llvm::make_unique<TreePattern>(CGI.TheDef, Pat, true, *this);
|
||||||
// Inline pattern fragments into it.
|
// Inline pattern fragments into it.
|
||||||
I->InlinePatternFragments();
|
I->InlinePatternFragments();
|
||||||
|
|
||||||
@ -3461,7 +3461,7 @@ const DAGInstruction &CodeGenDAGPatterns::parseInstructionPattern(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find inputs and outputs, and verify the structure of the uses/defs.
|
// Find inputs and outputs, and verify the structure of the uses/defs.
|
||||||
FindPatternInputsAndOutputs(I, Pat, InstInputs, InstResults,
|
FindPatternInputsAndOutputs(I.get(), Pat, InstInputs, InstResults,
|
||||||
InstImpResults);
|
InstImpResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3572,16 +3572,18 @@ const DAGInstruction &CodeGenDAGPatterns::parseInstructionPattern(
|
|||||||
|
|
||||||
// Create and insert the instruction.
|
// Create and insert the instruction.
|
||||||
// FIXME: InstImpResults should not be part of DAGInstruction.
|
// FIXME: InstImpResults should not be part of DAGInstruction.
|
||||||
DAGInstruction TheInst(I, Results, Operands, InstImpResults);
|
TreePattern *InstPattern = I.get();
|
||||||
DAGInsts.insert(std::make_pair(I->getRecord(), TheInst));
|
DAGInstruction TheInst(std::move(I), Results, Operands, InstImpResults);
|
||||||
|
DAGInsts.emplace(InstPattern->getRecord(), std::move(TheInst));
|
||||||
|
|
||||||
// Use a temporary tree pattern to infer all types and make sure that the
|
// Use a temporary tree pattern to infer all types and make sure that the
|
||||||
// constructed result is correct. This depends on the instruction already
|
// constructed result is correct. This depends on the instruction already
|
||||||
// being inserted into the DAGInsts map.
|
// being inserted into the DAGInsts map.
|
||||||
TreePattern Temp(I->getRecord(), ResultPattern, false, *this);
|
TreePattern Temp(InstPattern->getRecord(), ResultPattern, false, *this);
|
||||||
Temp.InferAllTypes(&I->getNamedNodesMap());
|
Temp.InferAllTypes(&InstPattern->getNamedNodesMap());
|
||||||
|
|
||||||
DAGInstruction &TheInsertedInst = DAGInsts.find(I->getRecord())->second;
|
DAGInstruction &TheInsertedInst =
|
||||||
|
DAGInsts.find(InstPattern->getRecord())->second;
|
||||||
TheInsertedInst.setResultPattern(Temp.getOnlyTree());
|
TheInsertedInst.setResultPattern(Temp.getOnlyTree());
|
||||||
|
|
||||||
return TheInsertedInst;
|
return TheInsertedInst;
|
||||||
|
@ -907,21 +907,21 @@ struct DAGDefaultOperand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class DAGInstruction {
|
class DAGInstruction {
|
||||||
TreePattern *Pattern;
|
std::unique_ptr<TreePattern> Pattern;
|
||||||
std::vector<Record*> Results;
|
std::vector<Record*> Results;
|
||||||
std::vector<Record*> Operands;
|
std::vector<Record*> Operands;
|
||||||
std::vector<Record*> ImpResults;
|
std::vector<Record*> ImpResults;
|
||||||
TreePatternNodePtr ResultPattern;
|
TreePatternNodePtr ResultPattern;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DAGInstruction(TreePattern *TP,
|
DAGInstruction(std::unique_ptr<TreePattern> &&TP,
|
||||||
const std::vector<Record*> &results,
|
const std::vector<Record*> &results,
|
||||||
const std::vector<Record*> &operands,
|
const std::vector<Record*> &operands,
|
||||||
const std::vector<Record*> &impresults)
|
const std::vector<Record*> &impresults)
|
||||||
: Pattern(TP), Results(results), Operands(operands),
|
: Pattern(std::move(TP)), Results(results), Operands(operands),
|
||||||
ImpResults(impresults), ResultPattern(nullptr) {}
|
ImpResults(impresults), ResultPattern(nullptr) {}
|
||||||
|
|
||||||
TreePattern *getPattern() const { return Pattern; }
|
TreePattern *getPattern() const { return Pattern.get(); }
|
||||||
unsigned getNumResults() const { return Results.size(); }
|
unsigned getNumResults() const { return Results.size(); }
|
||||||
unsigned getNumOperands() const { return Operands.size(); }
|
unsigned getNumOperands() const { return Operands.size(); }
|
||||||
unsigned getNumImpResults() const { return ImpResults.size(); }
|
unsigned getNumImpResults() const { return ImpResults.size(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user