[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp DAGISelEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Sep 8 18:15:13 PDT 2005
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.8 -> 1.9
DAGISelEmitter.h updated: 1.6 -> 1.7
---
Log message:
add an accessor to provide more checking
---
Diffs of the changes: (+9 -5)
DAGISelEmitter.cpp | 10 +++++-----
DAGISelEmitter.h | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.8 llvm/utils/TableGen/DAGISelEmitter.cpp:1.9
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.8 Thu Sep 8 20:11:44 2005
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 8 20:15:01 2005
@@ -277,7 +277,7 @@
TP.error("'" + Op->getName() + "' fragment requires " +
utostr(Frag->getNumArgs()) + " operands!");
- TreePatternNode *FragTree = Frag->getTree(0)->clone();
+ TreePatternNode *FragTree = Frag->getOnlyTree()->clone();
// Resolve formal arguments to their actual value.
if (Frag->getNumArgs()) {
@@ -400,7 +400,7 @@
if (R->isSubClassOf("RegisterClass"))
return getValueType(R->getValueAsDef("RegType"));
else if (R->isSubClassOf("PatFrag")) {
- //return ISE.ReadNonterminal(R)->getTree()->getType();
+ // Pattern fragment types will be resolved when they are inlined.
return MVT::LAST_VALUETYPE;
} else if (R->isSubClassOf("Register")) {
assert(0 && "Explicit registers not handled here yet!\n");
@@ -574,9 +574,9 @@
CodeInit *CI =
dynamic_cast<CodeInit*>(Fragments[i]->getValueInit("Predicate"));
if (!CI->getValue().empty()) {
- assert(!P->getTree(0)->isLeaf() && "Can't be a leaf!");
+ assert(!P->getOnlyTree()->isLeaf() && "Can't be a leaf!");
std::string ClassName =
- getSDNodeInfo(P->getTree(0)->getOperator()).getSDClassName();
+ getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName();
const char *C2 = ClassName == "SDNode" ? "N" : "inN";
OS << "static inline bool Predicate_" << Fragments[i]->getName()
@@ -584,7 +584,7 @@
if (ClassName != "SDNode")
OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n";
OS << CI->getValue() << "\n}\n";
- P->getTree(0)->setPredicateFn("Predicate_"+Fragments[i]->getName());
+ P->getOnlyTree()->setPredicateFn("Predicate_"+Fragments[i]->getName());
}
}
Index: llvm/utils/TableGen/DAGISelEmitter.h
diff -u llvm/utils/TableGen/DAGISelEmitter.h:1.6 llvm/utils/TableGen/DAGISelEmitter.h:1.7
--- llvm/utils/TableGen/DAGISelEmitter.h:1.6 Thu Sep 8 20:11:17 2005
+++ llvm/utils/TableGen/DAGISelEmitter.h Thu Sep 8 20:15:01 2005
@@ -235,6 +235,10 @@
const std::vector<TreePatternNode*> &getTrees() const { return Trees; }
unsigned getNumTrees() const { return Trees.size(); }
TreePatternNode *getTree(unsigned i) const { return Trees[i]; }
+ TreePatternNode *getOnlyTree() const {
+ assert(Trees.size() == 1 && "Doesn't have exactly one pattern!");
+ return Trees[0];
+ }
/// getRecord - Return the actual TableGen record corresponding to this
/// pattern.
More information about the llvm-commits
mailing list