diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2006-01-19 21:57:10 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2006-01-19 21:57:10 +0000 |
| commit | 9e7fb7b2fc9251b584063930f7dcea0b9df7755e (patch) | |
| tree | 5d19734914573a6b00e1d6270dd250daa50964b3 | |
| parent | 5df67bcd50d02d8bfd1ec272fa3c9e1899bd70ca (diff) | |
| download | bcm5719-llvm-9e7fb7b2fc9251b584063930f7dcea0b9df7755e.tar.gz bcm5719-llvm-9e7fb7b2fc9251b584063930f7dcea0b9df7755e.zip | |
Bug fix. Flag operand number may be calculated incorrectly.
llvm-svn: 25465
| -rw-r--r-- | llvm/utils/TableGen/DAGISelEmitter.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp index 03ec9951dcb..f9f5504f76c 100644 --- a/llvm/utils/TableGen/DAGISelEmitter.cpp +++ b/llvm/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"; |

