[llvm-commits] CVS: llvm/utils/TableGen/InstrSelectorEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Aug 7 15:00:01 PDT 2003
Changes in directory llvm/utils/TableGen:
InstrSelectorEmitter.cpp updated: 1.9 -> 1.10
---
Log message:
Add support for "cast" nodes, which are required when there is not enough information
to infer type type of all nodes, e.g. (ret imm)
---
Diffs of the changes:
Index: llvm/utils/TableGen/InstrSelectorEmitter.cpp
diff -u llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.9 llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.10
--- llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.9 Thu Aug 7 14:42:14 2003
+++ llvm/utils/TableGen/InstrSelectorEmitter.cpp Thu Aug 7 14:59:42 2003
@@ -52,6 +52,7 @@
}
return OS << ")";
}
+
void TreePatternNode::dump() const { std::cerr << *this; }
//===----------------------------------------------------------------------===//
@@ -126,11 +127,33 @@
TreePatternNode *Pattern::ParseTreePattern(DagInit *DI) {
Record *Operator = DI->getNodeType();
+ const std::vector<Init*> &Args = DI->getArgs();
+
+ if (Operator->isSubClassOf("ValueType")) {
+ // If the operator is a ValueType, then this must be "type cast" of a leaf
+ // node.
+ if (Args.size() != 1)
+ error("Type cast only valid for a leaf node!");
+
+ Init *Arg = Args[0];
+ TreePatternNode *New;
+ if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
+ New = new TreePatternNode(DI);
+ // If it's a regclass or something else known, set the type.
+ New->setType(getIntrinsicType(DI->getDef()));
+ } else {
+ Arg->dump();
+ error("Unknown leaf value for tree pattern!");
+ }
+
+ // Apply the type cast...
+ New->updateNodeType(getValueType(Operator), TheRecord->getName());
+ return New;
+ }
if (!ISE.getNodeTypes().count(Operator))
error("Unrecognized node '" + Operator->getName() + "'!");
- const std::vector<Init*> &Args = DI->getArgs();
std::vector<TreePatternNode*> Children;
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
More information about the llvm-commits
mailing list