[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Evan Cheng
evan.cheng at apple.com
Tue Sep 19 12:08:19 PDT 2006
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.260 -> 1.261
---
Log message:
Allow PatFrag to be a leaf node.
---
Diffs of the changes: (+18 -10)
DAGISelEmitter.cpp | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.260 llvm/utils/TableGen/DAGISelEmitter.cpp:1.261
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.260 Tue Sep 19 13:40:15 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Sep 19 14:08:04 2006
@@ -1158,15 +1158,19 @@
// keep track of the fact that this fragment uses it.
std::string Code = Fragments[i]->getValueAsCode("Predicate");
if (!Code.empty()) {
- assert(!P->getOnlyTree()->isLeaf() && "Can't be a leaf!");
- std::string ClassName =
- getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName();
- const char *C2 = ClassName == "SDNode" ? "N" : "inN";
-
- OS << "inline bool Predicate_" << Fragments[i]->getName()
- << "(SDNode *" << C2 << ") {\n";
- if (ClassName != "SDNode")
- OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n";
+ if (P->getOnlyTree()->isLeaf())
+ OS << "inline bool Predicate_" << Fragments[i]->getName()
+ << "(SDNode *N) {\n";
+ else {
+ std::string ClassName =
+ getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName();
+ const char *C2 = ClassName == "SDNode" ? "N" : "inN";
+
+ OS << "inline bool Predicate_" << Fragments[i]->getName()
+ << "(SDNode *" << C2 << ") {\n";
+ if (ClassName != "SDNode")
+ OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n";
+ }
OS << Code << "\n}\n";
P->getOnlyTree()->setPredicateFn("Predicate_"+Fragments[i]->getName());
}
@@ -2371,6 +2375,11 @@
#endif
assert(0 && "Unknown leaf type!");
}
+
+ // If there is a node predicate for this, emit the call.
+ if (!Child->getPredicateFn().empty())
+ emitCheck(Child->getPredicateFn() + "(" + RootName + utostr(OpNo) +
+ ".Val)");
} else if (IntInit *II =
dynamic_cast<IntInit*>(Child->getLeafValue())) {
emitCheck("isa<ConstantSDNode>(" + RootName + utostr(OpNo) + ")");
@@ -2827,7 +2836,6 @@
emitCode("SDOperand Tmp" + utostr(ResNo) + " = Transform_" + Op->getName()
+ "(" + Ops.back() + ".Val);");
NodeOps.push_back("Tmp" + utostr(ResNo));
- emitCode("AddToISelQueue(Tmp" + utostr(ResNo) + ");");
if (isRoot)
emitCode("return Tmp" + utostr(ResNo) + ".Val;");
return NodeOps;
More information about the llvm-commits
mailing list