aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-01-19 21:57:10 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-01-19 21:57:10 +0000
commit823b752d75dd395c69d297ee17f1cda9e4b3cd43 (patch)
tree17d3f28b6587f978e46e4c538fb9d70a93c037e4
parent394244717af79d561079181549c8f1aceccce375 (diff)
Bug fix. Flag operand number may be calculated incorrectly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25465 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 03ec9951dc..f9f5504f76 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -2119,12 +2119,22 @@ public:
NodeHasProperty(Pattern, SDNodeInfo::SDNPInFlag, ISE);
bool HasOutFlag = HasImpResults ||
(isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPOutFlag, ISE));
+ bool NodeHasChain =
+ NodeHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE);
bool HasChain = II.hasCtrlDep ||
(isRoot && PatternHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE));
if (HasOutFlag || HasInFlag || HasOptInFlag || HasImpInputs)
OS << " SDOperand InFlag = SDOperand(0, 0);\n";
+ // How many results is this pattern expected to produce?
+ unsigned NumExpectedResults = 0;
+ for (unsigned i = 0, e = Pattern->getExtTypes().size(); i != e; i++) {
+ MVT::ValueType VT = Pattern->getTypeNum(i);
+ if (VT != MVT::isVoid && VT != MVT::Flag)
+ NumExpectedResults++;
+ }
+
// Determine operand emission order. Complex pattern first.
std::vector<std::pair<unsigned, TreePatternNode*> > EmitOrder;
std::vector<std::pair<unsigned, TreePatternNode*> >::iterator OI;
@@ -2163,7 +2173,7 @@ public:
if (HasImpInputs)
EmitCopyToRegs(Pattern, "N", ChainEmitted, true);
if (HasInFlag || HasOptInFlag) {
- unsigned FlagNo = (unsigned) HasChain + Pattern->getNumChildren();
+ unsigned FlagNo = (unsigned) NodeHasChain + Pattern->getNumChildren();
if (HasOptInFlag)
OS << " if (N.getNumOperands() == " << FlagNo+1 << ") ";
else
@@ -2237,8 +2247,6 @@ public:
}
// User does not expect that the instruction produces a chain!
- bool NodeHasChain =
- NodeHasProperty(Pattern, SDNodeInfo::SDNPHasChain, ISE);
bool AddedChain = HasChain && !NodeHasChain;
if (NodeHasChain)
OS << " CodeGenMap[N.getValue(" << ValNo++ << ")] = Chain;\n";
@@ -2255,13 +2263,10 @@ public:
OS << " CodeGenMap[N.getValue(" << ValNo << ")] = InFlag;\n";
if (AddedChain && HasOutFlag) {
- // Is this pattern expected to produce a result?
- if (Pattern->getTypeNum(0) == MVT::isVoid ||
- Pattern->getTypeNum(0) == MVT::Flag) {
+ if (NumExpectedResults == 0) {
OS << " return Result.getValue(N.ResNo+1);\n";
} else {
- OS << " if (N.ResNo < "
- << ((NumResults > 1) ? NumResults : 1) << ")\n";
+ OS << " if (N.ResNo < " << NumExpectedResults << ")\n";
OS << " return Result.getValue(N.ResNo);\n";
OS << " else\n";
OS << " return Result.getValue(N.ResNo+1);\n";