Fix a fixme by passing around SDOperand's instead of SDNode*'s

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2005-09-23 21:53:45 +00:00
parent d1ff35a49d
commit 547394ca38

View File

@@ -994,13 +994,13 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
assert(!N->isLeaf() && "Cannot match against a leaf!"); assert(!N->isLeaf() && "Cannot match against a leaf!");
// Emit code to load the child nodes and match their contents recursively. // Emit code to load the child nodes and match their contents recursively.
for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) {
OS << " SDNode *" << RootName << i <<" = " << RootName OS << " SDOperand " << RootName << i <<" = " << RootName
<< "->getOperand(" << i << ").Val;\n"; << ".getOperand(" << i << ");\n";
TreePatternNode *Child = N->getChild(i); TreePatternNode *Child = N->getChild(i);
if (!Child->isLeaf()) { if (!Child->isLeaf()) {
// If it's not a leaf, recursively match. // If it's not a leaf, recursively match.
const SDNodeInfo &CInfo = getSDNodeInfo(Child->getOperator()); const SDNodeInfo &CInfo = getSDNodeInfo(Child->getOperator());
OS << " if (" << RootName << i << "->getOpcode() != " OS << " if (" << RootName << i << ".getOpcode() != "
<< CInfo.getEnumName() << ") goto P" << PatternNo << "Fail;\n"; << CInfo.getEnumName() << ") goto P" << PatternNo << "Fail;\n";
EmitMatchForPattern(Child, RootName + utostr(i), PatternNo, OS); EmitMatchForPattern(Child, RootName + utostr(i), PatternNo, OS);
} else { } else {
@@ -1022,14 +1022,14 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
// If this child has a name associated with it, capture it as a variable. // If this child has a name associated with it, capture it as a variable.
if (!Child->getName().empty()) if (!Child->getName().empty())
OS << " SDOperand op" << Child->getName() << "(" << RootName OS << " SDOperand op" << Child->getName() << " = " << RootName
<< i << ", 0 /*FIXME*/);\n"; << i << ";\n";
} }
// If there is a node predicate for this, emit the call. // If there is a node predicate for this, emit the call.
if (!N->getPredicateFn().empty()) if (!N->getPredicateFn().empty())
OS << " if (!" << N->getPredicateFn() << "(" << RootName OS << " if (!" << N->getPredicateFn() << "(" << RootName
<< ")) goto P" << PatternNo << "Fail;\n"; << ".Val)) goto P" << PatternNo << "Fail;\n";
} }
/// EmitCodeForPattern - Given a pattern to match, emit code to the specified /// EmitCodeForPattern - Given a pattern to match, emit code to the specified
@@ -1090,18 +1090,17 @@ struct PatternSortingPredicate {
void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) { void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
// Emit boilerplate. // Emit boilerplate.
OS << "// The main instruction selector code.\n" OS << "// The main instruction selector code.\n"
<< "SDOperand SelectCode(SDOperand Op) {\n" << "SDOperand SelectCode(SDOperand N) {\n"
<< " SDNode *N = Op.Val;\n" << " if (N.getOpcode() >= ISD::BUILTIN_OP_END &&\n"
<< " if (N->getOpcode() >= ISD::BUILTIN_OP_END &&\n" << " N.getOpcode() < PPCISD::FIRST_NUMBER)\n"
<< " N->getOpcode() < PPCISD::FIRST_NUMBER)\n" << " return N; // Already selected.\n\n"
<< " return Op; // Already selected.\n\n" << " switch (N.getOpcode()) {\n"
<< " switch (N->getOpcode()) {\n"
<< " default: break;\n" << " default: break;\n"
<< " case ISD::EntryToken: // These leaves remain the same.\n" << " case ISD::EntryToken: // These leaves remain the same.\n"
<< " return Op;\n" << " return N;\n"
<< " case ISD::AssertSext:\n" << " case ISD::AssertSext:\n"
<< " case ISD::AssertZext:\n" << " case ISD::AssertZext:\n"
<< " return Select(N->getOperand(0));\n"; << " return Select(N.getOperand(0));\n";
// Group the patterns by their top-level opcodes. // Group the patterns by their top-level opcodes.
std::map<Record*, std::vector<PatternToMatch*> > PatternsByOpcode; std::map<Record*, std::vector<PatternToMatch*> > PatternsByOpcode;
@@ -1132,7 +1131,7 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
OS << " } // end of big switch.\n\n" OS << " } // end of big switch.\n\n"
<< " std::cerr << \"Cannot yet select: \";\n" << " std::cerr << \"Cannot yet select: \";\n"
<< " N->dump();\n" << " N.Val->dump();\n"
<< " std::cerr << '\\n';\n" << " std::cerr << '\\n';\n"
<< " abort();\n" << " abort();\n"
<< "}\n"; << "}\n";