[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Oct 20 18:20:11 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.64 -> 1.65
DAGISelEmitter.h updated: 1.34 -> 1.35
---
Log message:
Make tblgen emit:
tblgen: In ZAPNOTi: Cannot use 'IZAPX' in an input pattern!
for a bad pattern, instead of an ugly assertion.
---
Diffs of the changes: (+26 -11)
DAGISelEmitter.cpp | 24 ++++++++++++++++--------
DAGISelEmitter.h | 13 ++++++++++---
2 files changed, 26 insertions(+), 11 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.64 llvm/utils/TableGen/DAGISelEmitter.cpp:1.65
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.64 Tue Oct 18 23:41:05 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Oct 20 20:19:59 2005
@@ -573,19 +573,22 @@
// TreePattern implementation
//
-TreePattern::TreePattern(Record *TheRec, ListInit *RawPat,
+TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
DAGISelEmitter &ise) : TheRecord(TheRec), ISE(ise) {
+ isInputPattern = isInput;
for (unsigned i = 0, e = RawPat->getSize(); i != e; ++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) {
+ isInputPattern = isInput;
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) {
+ isInputPattern = isInput;
Trees.push_back(Pat);
}
@@ -638,6 +641,11 @@
Operator->getName() != "set")
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;
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
@@ -780,7 +788,7 @@
OS << "\n// Predicate functions.\n";
for (unsigned i = 0, e = Fragments.size(); i != e; ++i) {
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;
// Validate the argument list, converting it to map, to discard duplicates.
@@ -1016,7 +1024,7 @@
}
// 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.
I->InlinePatternFragments();
@@ -1133,7 +1141,7 @@
// Use a temporary tree pattern to infer all types and make sure that the
// constructed result is correct. This depends on the instruction already
// being inserted into the Instructions map.
- TreePattern Temp(I->getRecord(), ResultPattern, *this);
+ TreePattern Temp(I->getRecord(), ResultPattern, false, *this);
Temp.InferAllTypes();
DAGInstruction &TheInsertedInst = Instructions.find(I->getRecord())->second;
@@ -1175,7 +1183,7 @@
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
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.
Pattern->InlinePatternFragments();
@@ -1189,7 +1197,7 @@
if (LI->getSize() == 0) continue; // no pattern.
// 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.
Result->InlinePatternFragments();
Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.34 llvm/utils/TableGen/DAGISelEmitter.h:1.35
--- llvm/utils/TableGen/DAGISelEmitter.h:1.34 Tue Oct 18 23:12:14 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h Thu Oct 20 20:19:59 2005
@@ -258,13 +258,20 @@
/// ISE - the DAG isel emitter coordinating this madness.
///
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:
/// TreePattern constructor - Parse the specified DagInits into the
/// current record.
- TreePattern(Record *TheRec, ListInit *RawPat, DAGISelEmitter &ise);
- TreePattern(Record *TheRec, DagInit *Pat, DAGISelEmitter &ise);
- TreePattern(Record *TheRec, TreePatternNode *Pat, DAGISelEmitter &ise);
+ TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
+ 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.
///
More information about the llvm-commits
mailing list