From 5f418eafdc61f16335f2249ce2d31a6a4da75ea8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 18 Mar 2010 20:50:52 +0000 Subject: [PATCH] remove some code that was working around old sparc v9 backend bugs. Add checking that the input/output operand list in spelled right. llvm-svn: 98865 --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 3 +- llvm/utils/TableGen/CodeGenInstruction.cpp | 40 +++++++++++----------- llvm/utils/TableGen/CodeGenInstruction.h | 3 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 6e894a46bce4..35d6d771371b 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -1145,7 +1145,8 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { CodeGenInstruction &InstInfo = CDP.getTargetInfo().getInstruction(getOperator()->getName()); // Apply the result type to the node - if (NumResults == 0 || InstInfo.NumDefs == 0) { + if (NumResults == 0 || + InstInfo.NumDefs == 0) { MadeChange = UpdateNodeType(MVT::isVoid, TP); } else { Record *ResultNode = Inst.getResult(0); diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp index f5b52ecefb35..37ed84658a82 100644 --- a/llvm/utils/TableGen/CodeGenInstruction.cpp +++ b/llvm/utils/TableGen/CodeGenInstruction.cpp @@ -127,27 +127,27 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr) if (neverHasSideEffects + hasSideEffects > 1) throw R->getName() + ": multiple conflicting side-effect flags set!"; - DagInit *DI; - try { - DI = R->getValueAsDag("OutOperandList"); - } catch (...) { - // Error getting operand list, just ignore it (sparcv9). - AsmString.clear(); - OperandList.clear(); - return; - } - NumDefs = DI->getNumArgs(); + DagInit *DI = R->getValueAsDag("OutOperandList"); - DagInit *IDI; - try { - IDI = R->getValueAsDag("InOperandList"); - } catch (...) { - // Error getting operand list, just ignore it (sparcv9). - AsmString.clear(); - OperandList.clear(); - return; - } - DI = (DagInit*)(new BinOpInit(BinOpInit::CONCAT, DI, IDI, new DagRecTy))->Fold(R, 0); + if (DefInit *Init = dynamic_cast(DI->getOperator())) { + if (Init->getDef()->getName() != "ops" && + Init->getDef()->getName() != "outs") + throw R->getName() + ": invalid def name for output list: use 'outs'"; + } else + throw R->getName() + ": invalid output list: use 'outs'"; + + NumDefs = DI->getNumArgs(); + + DagInit *IDI = R->getValueAsDag("InOperandList"); + if (DefInit *Init = dynamic_cast(IDI->getOperator())) { + if (Init->getDef()->getName() != "ops" && + Init->getDef()->getName() != "ins") + throw R->getName() + ": invalid def name for input list: use 'ins'"; + } else + throw R->getName() + ": invalid input list: use 'ins'"; + + DI = (DagInit*)(new BinOpInit(BinOpInit::CONCAT, + DI, IDI, new DagRecTy))->Fold(R, 0); unsigned MIOperandNo = 0; std::set OperandNames; diff --git a/llvm/utils/TableGen/CodeGenInstruction.h b/llvm/utils/TableGen/CodeGenInstruction.h index aae2cac86a3d..8e7051bcda2f 100644 --- a/llvm/utils/TableGen/CodeGenInstruction.h +++ b/llvm/utils/TableGen/CodeGenInstruction.h @@ -105,7 +105,8 @@ namespace llvm { MINumOperands(MINO), MIOperandInfo(MIOI) {} }; - /// NumDefs - Number of def operands declared. + /// NumDefs - Number of def operands declared, this is the number of + /// elements in the instruction's (outs) list. /// unsigned NumDefs;