diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-02-05 22:50:29 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-02-05 22:50:29 +0000 |
commit | a58891ff1e6b5cc61cbb3cfe46be7f2eeddbfe98 (patch) | |
tree | bde597ab334f6b85410379f63fde4d78d89573f0 /utils | |
parent | ebaaa91094ae54d16ca4f6fc247d47739a761d63 (diff) | |
download | llvm-a58891ff1e6b5cc61cbb3cfe46be7f2eeddbfe98.tar.gz llvm-a58891ff1e6b5cc61cbb3cfe46be7f2eeddbfe98.tar.bz2 llvm-a58891ff1e6b5cc61cbb3cfe46be7f2eeddbfe98.tar.xz |
Fix PR1975: dag isel emitter produces patterns that isel wrong flag result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index dda56c0942..7a1920ceac 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -305,6 +305,8 @@ private: std::map<std::string, std::string> VariableMap; // Node to operator mapping std::map<std::string, Record*> OperatorMap; + // Name of the folded node which produces a flag. + std::pair<std::string, unsigned> FoldedFlag; // Names of all the folded nodes which produce chains. std::vector<std::pair<std::string, unsigned> > FoldedChains; // Original input chain(s). @@ -587,8 +589,17 @@ public: emitCheck(RootName + ".getOpcode() == " + CInfo.getEnumName()); EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain); - if (NodeHasProperty(Child, SDNPHasChain, CGP)) + bool HasChain = false; + if (NodeHasProperty(Child, SDNPHasChain, CGP)) { + HasChain = true; FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults())); + } + if (NodeHasProperty(Child, SDNPOutFlag, CGP)) { + assert(FoldedFlag.first == "" && FoldedFlag.second == 0 && + "Pattern folded multiple nodes which produce flags?"); + FoldedFlag = std::make_pair(RootName, + CInfo.getNumResults() + (unsigned)HasChain); + } } else { // 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. @@ -1105,9 +1116,15 @@ public: } if (NodeHasOutFlag) { - emitCode("ReplaceUses(SDOperand(N.Val, " + - utostr(NumPatResults + (unsigned)InputHasChain) - +"), InFlag);"); + if (FoldedFlag.first != "") { + emitCode("ReplaceUses(SDOperand(" + FoldedFlag.first + ".Val, " + + utostr(FoldedFlag.second) + "), InFlag);"); + } else { + assert(NodeHasProperty(Pattern, SDNPOutFlag, CGP)); + emitCode("ReplaceUses(SDOperand(N.Val, " + + utostr(NumPatResults + (unsigned)InputHasChain) + +"), InFlag);"); + } NeedReplace = true; } |