Check that operands have unique names. REJECT instructions with broken operand

lists: only don't parse them if they are entirely missing (sparcv9).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-09-14 21:05:02 +00:00
parent 3a7319d5ed
commit 5d7d3dba9c

View File

@ -18,6 +18,7 @@
#include "Record.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CommandLine.h"
#include <set>
using namespace llvm;
static cl::opt<unsigned>
@ -250,12 +251,23 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
hasVariableNumberOfOperands = false;
DagInit *DI;
try {
DagInit *DI = R->getValueAsDag("OperandList");
DI = R->getValueAsDag("OperandList");
} catch (...) {
// Error getting operand list, just ignore it (sparcv9).
AsmString.clear();
OperandList.clear();
return;
}
unsigned MIOperandNo = 0;
for (unsigned i = 0, e = DI->getNumArgs(); i != e; ++i)
if (DefInit *Arg = dynamic_cast<DefInit*>(DI->getArg(i))) {
std::set<std::string> OperandNames;
for (unsigned i = 0, e = DI->getNumArgs(); i != e; ++i) {
DefInit *Arg = dynamic_cast<DefInit*>(DI->getArg(i));
if (!Arg)
throw "Illegal operand for the '" + R->getName() + "' instruction!";
Record *Rec = Arg->getDef();
MVT::ValueType Ty;
std::string PrintMethod = "printOperand";
@ -273,16 +285,14 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
throw "Unknown operand class '" + Rec->getName() +
"' in instruction '" + R->getName() + "' instruction!";
if (!DI->getArgName(i).empty() &&
!OperandNames.insert(DI->getArgName(i)).second)
throw "In instruction '" + R->getName() + "', operand #" + utostr(i) +
" has the same name as a previous operand!";
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
PrintMethod, MIOperandNo, NumOps));
MIOperandNo += NumOps;
} else {
throw "Illegal operand for the '" + R->getName() + "' instruction!";
}
} catch (...) {
// Error parsing operands list, just ignore it.
AsmString.clear();
OperandList.clear();
}
}