From 9789aaad632f5a75fc8b8e70fd27aaa92199f3bb Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 24 Jan 2006 20:46:50 +0000 Subject: [PATCH] Fix an optional in flag bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25590 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 81 ++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 5e63042c90f..e76dd8fd554 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -2206,26 +2206,71 @@ public: << NumResults << ");\n"; } } else if (HasChain || HasOutFlag) { - OS << " SDOperand Result = CurDAG->getTargetNode(" - << II.Namespace << "::" << II.TheDef->getName(); + if (HasOptInFlag) { + OS << " SDOperand Result = SDOperand(0, 0);\n"; + unsigned FlagNo = (unsigned) NodeHasChain + Pattern->getNumChildren(); + OS << " if (N.getNumOperands() == " << FlagNo+1 << ")\n"; + OS << " Result = CurDAG->getTargetNode(" + << II.Namespace << "::" << II.TheDef->getName(); - // Output order: results, chain, flags - // Result types. - if (NumResults > 0) { - if (N->getTypeNum(0) != MVT::isVoid) - OS << ", MVT::" << getEnumName(N->getTypeNum(0)); + // Output order: results, chain, flags + // Result types. + if (NumResults > 0) { + if (N->getTypeNum(0) != MVT::isVoid) + OS << ", MVT::" << getEnumName(N->getTypeNum(0)); + } + if (HasChain) + OS << ", MVT::Other"; + if (HasOutFlag) + OS << ", MVT::Flag"; + + // Inputs. + for (unsigned i = 0, e = Ops.size(); i != e; ++i) + OS << ", Tmp" << Ops[i]; + if (HasChain) OS << ", Chain"; + OS << ", InFlag);\n"; + + OS << " else\n"; + OS << " Result = CurDAG->getTargetNode(" + << II.Namespace << "::" << II.TheDef->getName(); + + // Output order: results, chain, flags + // Result types. + if (NumResults > 0) { + if (N->getTypeNum(0) != MVT::isVoid) + OS << ", MVT::" << getEnumName(N->getTypeNum(0)); + } + if (HasChain) + OS << ", MVT::Other"; + if (HasOutFlag) + OS << ", MVT::Flag"; + + // Inputs. + for (unsigned i = 0, e = Ops.size(); i != e; ++i) + OS << ", Tmp" << Ops[i]; + if (HasChain) OS << ", Chain);\n"; + } else { + OS << " SDOperand Result = CurDAG->getTargetNode(" + << II.Namespace << "::" << II.TheDef->getName(); + + // Output order: results, chain, flags + // Result types. + if (NumResults > 0) { + if (N->getTypeNum(0) != MVT::isVoid) + OS << ", MVT::" << getEnumName(N->getTypeNum(0)); + } + if (HasChain) + OS << ", MVT::Other"; + if (HasOutFlag) + OS << ", MVT::Flag"; + + // Inputs. + for (unsigned i = 0, e = Ops.size(); i != e; ++i) + OS << ", Tmp" << Ops[i]; + if (HasChain) OS << ", Chain"; + if (HasInFlag || HasImpInputs) OS << ", InFlag"; + OS << ");\n"; } - if (HasChain) - OS << ", MVT::Other"; - if (HasOutFlag) - OS << ", MVT::Flag"; - - // Inputs. - for (unsigned i = 0, e = Ops.size(); i != e; ++i) - OS << ", Tmp" << Ops[i]; - if (HasChain) OS << ", Chain"; - if (HasInFlag || HasOptInFlag || HasImpInputs) OS << ", InFlag"; - OS << ");\n"; unsigned ValNo = 0; for (unsigned i = 0; i < NumResults; i++) {