forked from OSchip/llvm-project
Make tblgen emit:
tblgen: In ZAPNOTi: Cannot use 'IZAPX' in an input pattern! for a bad pattern, instead of an ugly assertion. llvm-svn: 23854
This commit is contained in:
parent
4dd383120f
commit
8bda5afd91
|
@ -573,19 +573,22 @@ bool TreePatternNode::canPatternMatch(std::string &Reason, DAGISelEmitter &ISE){
|
||||||
// TreePattern implementation
|
// TreePattern implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
TreePattern::TreePattern(Record *TheRec, ListInit *RawPat,
|
TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
|
||||||
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
||||||
|
isInputPattern = isInput;
|
||||||
for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i)
|
for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i)
|
||||||
Trees.push_back(ParseTreePattern((DagInit*)RawPat->getElement(i)));
|
Trees.push_back(ParseTreePattern((DagInit*)RawPat->getElement(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TreePattern::TreePattern(Record *TheRec, DagInit *Pat,
|
TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
|
||||||
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
||||||
|
isInputPattern = isInput;
|
||||||
Trees.push_back(ParseTreePattern(Pat));
|
Trees.push_back(ParseTreePattern(Pat));
|
||||||
}
|
}
|
||||||
|
|
||||||
TreePattern::TreePattern(Record *TheRec, TreePatternNode *Pat,
|
TreePattern::TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput,
|
||||||
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
|
||||||
|
isInputPattern = isInput;
|
||||||
Trees.push_back(Pat);
|
Trees.push_back(Pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +641,11 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||||
Operator->getName() != "set")
|
Operator->getName() != "set")
|
||||||
error("Unrecognized node '" + Operator->getName() + "'!");
|
error("Unrecognized node '" + Operator->getName() + "'!");
|
||||||
|
|
||||||
|
// Check to see if this is something that is illegal in an input pattern.
|
||||||
|
if (isInputPattern && (Operator->isSubClassOf("Instruction") ||
|
||||||
|
Operator->isSubClassOf("SDNodeXForm")))
|
||||||
|
error("Cannot use '" + Operator->getName() + "' in an input pattern!");
|
||||||
|
|
||||||
std::vector<TreePatternNode*> Children;
|
std::vector<TreePatternNode*> Children;
|
||||||
|
|
||||||
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
|
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
|
||||||
|
@ -780,7 +788,7 @@ void DAGISelEmitter::ParsePatternFragments(std::ostream &OS) {
|
||||||
OS << "\n// Predicate functions.\n";
|
OS << "\n// Predicate functions.\n";
|
||||||
for (unsigned i = 0, e = Fragments.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Fragments.size(); i != e; ++i) {
|
||||||
DagInit *Tree = Fragments[i]->getValueAsDag("Fragment");
|
DagInit *Tree = Fragments[i]->getValueAsDag("Fragment");
|
||||||
TreePattern *P = new TreePattern(Fragments[i], Tree, *this);
|
TreePattern *P = new TreePattern(Fragments[i], Tree, true, *this);
|
||||||
PatternFragments[Fragments[i]] = P;
|
PatternFragments[Fragments[i]] = P;
|
||||||
|
|
||||||
// Validate the argument list, converting it to map, to discard duplicates.
|
// Validate the argument list, converting it to map, to discard duplicates.
|
||||||
|
@ -1016,7 +1024,7 @@ void DAGISelEmitter::ParseInstructions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the instruction.
|
// Parse the instruction.
|
||||||
TreePattern *I = new TreePattern(Instrs[i], LI, *this);
|
TreePattern *I = new TreePattern(Instrs[i], LI, true, *this);
|
||||||
// Inline pattern fragments into it.
|
// Inline pattern fragments into it.
|
||||||
I->InlinePatternFragments();
|
I->InlinePatternFragments();
|
||||||
|
|
||||||
|
@ -1133,7 +1141,7 @@ void DAGISelEmitter::ParseInstructions() {
|
||||||
// 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 Instructions map.
|
// being inserted into the Instructions map.
|
||||||
TreePattern Temp(I->getRecord(), ResultPattern, *this);
|
TreePattern Temp(I->getRecord(), ResultPattern, false, *this);
|
||||||
Temp.InferAllTypes();
|
Temp.InferAllTypes();
|
||||||
|
|
||||||
DAGInstruction &TheInsertedInst = Instructions.find(I->getRecord())->second;
|
DAGInstruction &TheInsertedInst = Instructions.find(I->getRecord())->second;
|
||||||
|
@ -1175,7 +1183,7 @@ void DAGISelEmitter::ParsePatterns() {
|
||||||
|
|
||||||
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
||||||
DagInit *Tree = Patterns[i]->getValueAsDag("PatternToMatch");
|
DagInit *Tree = Patterns[i]->getValueAsDag("PatternToMatch");
|
||||||
TreePattern *Pattern = new TreePattern(Patterns[i], Tree, *this);
|
TreePattern *Pattern = new TreePattern(Patterns[i], Tree, true, *this);
|
||||||
|
|
||||||
// Inline pattern fragments into it.
|
// Inline pattern fragments into it.
|
||||||
Pattern->InlinePatternFragments();
|
Pattern->InlinePatternFragments();
|
||||||
|
@ -1189,7 +1197,7 @@ void DAGISelEmitter::ParsePatterns() {
|
||||||
if (LI->getSize() == 0) continue; // no pattern.
|
if (LI->getSize() == 0) continue; // no pattern.
|
||||||
|
|
||||||
// Parse the instruction.
|
// Parse the instruction.
|
||||||
TreePattern *Result = new TreePattern(Patterns[i], LI, *this);
|
TreePattern *Result = new TreePattern(Patterns[i], LI, false, *this);
|
||||||
|
|
||||||
// Inline pattern fragments into it.
|
// Inline pattern fragments into it.
|
||||||
Result->InlinePatternFragments();
|
Result->InlinePatternFragments();
|
||||||
|
|
|
@ -258,13 +258,20 @@ namespace llvm {
|
||||||
/// ISE - the DAG isel emitter coordinating this madness.
|
/// ISE - the DAG isel emitter coordinating this madness.
|
||||||
///
|
///
|
||||||
DAGISelEmitter &ISE;
|
DAGISelEmitter &ISE;
|
||||||
|
|
||||||
|
/// isInputPattern - True if this is an input pattern, something to match.
|
||||||
|
/// False if this is an output pattern, something to emit.
|
||||||
|
bool isInputPattern;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// TreePattern constructor - Parse the specified DagInits into the
|
/// TreePattern constructor - Parse the specified DagInits into the
|
||||||
/// current record.
|
/// current record.
|
||||||
TreePattern(Record *TheRec, ListInit *RawPat, DAGISelEmitter &ise);
|
TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
|
||||||
TreePattern(Record *TheRec, DagInit *Pat, DAGISelEmitter &ise);
|
DAGISelEmitter &ise);
|
||||||
TreePattern(Record *TheRec, TreePatternNode *Pat, DAGISelEmitter &ise);
|
TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
|
||||||
|
DAGISelEmitter &ise);
|
||||||
|
TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput,
|
||||||
|
DAGISelEmitter &ise);
|
||||||
|
|
||||||
/// getTrees - Return the tree patterns which corresponds to this pattern.
|
/// getTrees - Return the tree patterns which corresponds to this pattern.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue