Fixes for a number of bugs: save flag results in CodeGenMap, folded chains

may not all have ResNo == 0.

llvm-svn: 24858
This commit is contained in:
Evan Cheng 2005-12-19 07:18:51 +00:00
parent 631c9df853
commit 9bd85c2f19
1 changed files with 33 additions and 23 deletions

View File

@ -1761,7 +1761,7 @@ private:
// Node to name mapping // Node to name mapping
std::map<std::string,std::string> VariableMap; std::map<std::string,std::string> VariableMap;
// Names of all the folded nodes which produce chains. // Names of all the folded nodes which produce chains.
std::vector<std::string> FoldedChains; std::vector<std::pair<std::string, unsigned> > FoldedChains;
bool FoundChain; bool FoundChain;
bool InFlag; bool InFlag;
unsigned TmpNo; unsigned TmpNo;
@ -1856,8 +1856,10 @@ public:
OS << " if (" << RootName << OpNo << ".getOpcode() != " OS << " if (" << RootName << OpNo << ".getOpcode() != "
<< CInfo.getEnumName() << ") goto P" << PatternNo << "Fail;\n"; << CInfo.getEnumName() << ") goto P" << PatternNo << "Fail;\n";
EmitMatchCode(Child, RootName + utostr(OpNo)); EmitMatchCode(Child, RootName + utostr(OpNo));
if (NodeHasChain(Child, ISE)) if (NodeHasChain(Child, ISE)) {
FoldedChains.push_back(RootName + utostr(OpNo)); FoldedChains.push_back(std::make_pair(RootName + utostr(OpNo),
CInfo.getNumResults()));
}
} else { } else {
// If this child has a name associated with it, capture it in VarMap. If // If this child has a name associated with it, capture it in VarMap. If
// we already saw this in the pattern, emit code to verify dagness. // we already saw this in the pattern, emit code to verify dagness.
@ -2078,41 +2080,49 @@ public:
OS << " Chain = Tmp" << LastOp << ".getValue(" OS << " Chain = Tmp" << LastOp << ".getValue("
<< NumResults << ");\n"; << NumResults << ");\n";
} }
} else if (II.hasCtrlDep) { } else if (II.hasCtrlDep || NumImpResults > 0) {
OS << " SDOperand Result = "; OS << " SDOperand Result = CurDAG->getTargetNode("
OS << "CurDAG->getTargetNode("
<< II.Namespace << "::" << II.TheDef->getName(); << II.Namespace << "::" << II.TheDef->getName();
// Output order: results, chain, flags
// Result types.
if (NumResults > 0) { if (NumResults > 0) {
// TODO: multiple results? // TODO: multiple results?
if (N->getType() != MVT::isVoid) if (N->getType() != MVT::isVoid)
OS << ", MVT::" << getEnumName(N->getType()); OS << ", MVT::" << getEnumName(N->getType());
} }
if (II.hasCtrlDep)
OS << ", MVT::Other"; OS << ", MVT::Other";
for (unsigned i = 0; i < NumImpResults; i++) { for (unsigned i = 0; i < NumImpResults; i++) {
Record *ImpResult = Inst.getImpResult(i); Record *ImpResult = Inst.getImpResult(i);
MVT::ValueType RVT = getRegisterValueType(ImpResult, CGT); MVT::ValueType RVT = getRegisterValueType(ImpResult, CGT);
OS << ", MVT::" << getEnumName(RVT); OS << ", MVT::" << getEnumName(RVT);
} }
// Inputs.
for (unsigned i = 0, e = Ops.size(); i != e; ++i) for (unsigned i = 0, e = Ops.size(); i != e; ++i)
OS << ", Tmp" << Ops[i]; OS << ", Tmp" << Ops[i];
OS << ", Chain"; if (II.hasCtrlDep) OS << ", Chain";
if (InFlag) if (InFlag) OS << ", InFlag";
OS << ", InFlag";
OS << ");\n"; OS << ");\n";
if (NumResults != 0) {
OS << " CodeGenMap[N.getValue(0)] = Result;\n"; unsigned ValNo = 0;
} for (unsigned i = 0; i < NumResults; i++)
OS << " CodeGenMap[N.getValue(" << ValNo++ << ")] = Result;\n";
if (II.hasCtrlDep) {
OS << " Chain "; OS << " Chain ";
if (NodeHasChain(Pattern, ISE)) if (NodeHasChain(Pattern, ISE))
OS << "= CodeGenMap[N.getValue(" << NumResults << ")] "; OS << "= CodeGenMap[N.getValue(" << ValNo << ")] ";
for (unsigned j = 0, e = FoldedChains.size(); j < e; j++) for (unsigned j = 0, e = FoldedChains.size(); j < e; j++)
OS << "= CodeGenMap[" << FoldedChains[j] << ".getValue(" OS << "= CodeGenMap[" << FoldedChains[j].first << ".getValue("
<< NumResults << ")] "; << FoldedChains[j].second << ")] ";
OS << "= Result.getValue(" << NumResults << ");\n"; OS << "= Result.getValue(" << ValNo++ << ");\n";
if (NumResults == 0 && NumImpResults == 0) }
OS << " return Chain;\n"; for (unsigned i = 0; i < NumImpResults; i++) {
else OS << " CodeGenMap[N.getValue(" << ValNo << ")] = Result";
OS << " return (N.ResNo) ? Chain : Result.getValue(0);\n"; OS << ".getValue(" << ValNo++ << ");\n";
}
OS << " return Result.getValue(N.ResNo);\n";
} else { } else {
// If this instruction is the root, and if there is only one use of it, // If this instruction is the root, and if there is only one use of it,
// use SelectNodeTo instead of getTargetNode to avoid an allocation. // use SelectNodeTo instead of getTargetNode to avoid an allocation.