summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-09 01:15:01 +0000
committerChris Lattner <sabre@nondot.org>2005-09-09 01:15:01 +0000
commit3793709e89bba99c1c3d0aaaaa46a389cbf365af (patch)
treee0cd9711ec8a3fad24adf807903d59b5db8badcf
parentf2a17a70f4be4677450ec03abf6840dd97bcd672 (diff)
downloadexternal_llvm-3793709e89bba99c1c3d0aaaaa46a389cbf365af.zip
external_llvm-3793709e89bba99c1c3d0aaaaa46a389cbf365af.tar.gz
external_llvm-3793709e89bba99c1c3d0aaaaa46a389cbf365af.tar.bz2
add an accessor to provide more checking
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23289 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp10
-rw-r--r--utils/TableGen/DAGISelEmitter.h4
2 files changed, 9 insertions, 5 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 37e9fa3..9b10a4a 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -277,7 +277,7 @@ TreePatternNode *TreePatternNode::InlinePatternFragments(TreePattern &TP) {
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 @@ MVT::ValueType TreePattern::getIntrinsicType(Record *R) const {
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 @@ void DAGISelEmitter::ParseAndResolvePatternFragments(std::ostream &OS) {
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 @@ void DAGISelEmitter::ParseAndResolvePatternFragments(std::ostream &OS) {
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());
}
}
diff --git a/utils/TableGen/DAGISelEmitter.h b/utils/TableGen/DAGISelEmitter.h
index 65c7e70..9c84843 100644
--- a/utils/TableGen/DAGISelEmitter.h
+++ b/utils/TableGen/DAGISelEmitter.h
@@ -235,6 +235,10 @@ namespace llvm {
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.