diff options
author | Chris Lattner <sabre@nondot.org> | 2006-11-14 18:41:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-11-14 18:41:38 +0000 |
commit | 7c3a96b81a66eadffe54366b1b0952f11f7876f6 (patch) | |
tree | 8bdb9c9feb0645308f39c80900be2ca1d6b79516 | |
parent | 20ddd4a7ae3798fa65a2bc6e7258e3d4500ecbe9 (diff) |
Fix a bug handling nodes with variable arguments. The code was fixed to assume
that there were two input operands before the variable operand portion. This
*happened* to be true for all call instructions, which took a chain and a
destination, but was not true for the PPC BCTRL instruction, whose destination
is implicit.
Making this code more general allows elimination of the custom selection logic
for BCTRL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31732 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index ed261bc687..80cb5cdf87 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -2852,6 +2852,11 @@ public: if (NodeHasOutFlag) Code += ", MVT::Flag"; + // Figure out how many fixed inputs the node has. This is important to + // know which inputs are the variable ones if present. + unsigned NumInputs = AllOps.size(); + NumInputs += NodeHasChain; + // Inputs. if (HasVarOps) { for (unsigned i = 0, e = AllOps.size(); i != e; ++i) @@ -2860,15 +2865,17 @@ public: } if (HasVarOps) { + // Figure out whether any operands at the end of the op list are not + // part of the variable section. + std::string EndAdjust; if (NodeHasInFlag || HasImpInputs) - emitCode("for (unsigned i = 2, e = N.getNumOperands()-1; " - "i != e; ++i) {"); - else if (NodeHasOptInFlag) - emitCode("for (unsigned i = 2, e = N.getNumOperands()-" - "(HasInFlag?1:0); i != e; ++i) {"); - else - emitCode("for (unsigned i = 2, e = N.getNumOperands(); " - "i != e; ++i) {"); + EndAdjust = "-1"; // Always has one flag. + else if (NodeHasOptInFlag) + EndAdjust = "-(HasInFlag?1:0)"; // May have a flag. + + emitCode("for (unsigned i = " + utostr(NumInputs) + + ", e = N.getNumOperands()" + EndAdjust + "; i != e; ++i) {"); + emitCode(" AddToISelQueue(N.getOperand(i));"); emitCode(" Ops" + utostr(OpsNo) + ".push_back(N.getOperand(i));"); emitCode("}"); |