mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-02 10:32:56 +00:00
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:
parent
3a7319d5ed
commit
5d7d3dba9c
@ -18,6 +18,7 @@
|
|||||||
#include "Record.h"
|
#include "Record.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned>
|
||||||
@ -250,39 +251,48 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
|
|||||||
usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
|
usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
|
||||||
hasVariableNumberOfOperands = false;
|
hasVariableNumberOfOperands = false;
|
||||||
|
|
||||||
|
DagInit *DI;
|
||||||
try {
|
try {
|
||||||
DagInit *DI = R->getValueAsDag("OperandList");
|
DI = R->getValueAsDag("OperandList");
|
||||||
|
|
||||||
unsigned MIOperandNo = 0;
|
|
||||||
for (unsigned i = 0, e = DI->getNumArgs(); i != e; ++i)
|
|
||||||
if (DefInit *Arg = dynamic_cast<DefInit*>(DI->getArg(i))) {
|
|
||||||
Record *Rec = Arg->getDef();
|
|
||||||
MVT::ValueType Ty;
|
|
||||||
std::string PrintMethod = "printOperand";
|
|
||||||
unsigned NumOps = 1;
|
|
||||||
if (Rec->isSubClassOf("RegisterClass")) {
|
|
||||||
Ty = getValueType(Rec->getValueAsDef("RegType"));
|
|
||||||
} else if (Rec->isSubClassOf("Operand")) {
|
|
||||||
Ty = getValueType(Rec->getValueAsDef("Type"));
|
|
||||||
PrintMethod = Rec->getValueAsString("PrintMethod");
|
|
||||||
NumOps = Rec->getValueAsInt("NumMIOperands");
|
|
||||||
} else if (Rec->getName() == "variable_ops") {
|
|
||||||
hasVariableNumberOfOperands = true;
|
|
||||||
continue;
|
|
||||||
} else
|
|
||||||
throw "Unknown operand class '" + Rec->getName() +
|
|
||||||
"' in instruction '" + R->getName() + "' instruction!";
|
|
||||||
|
|
||||||
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
|
|
||||||
PrintMethod, MIOperandNo, NumOps));
|
|
||||||
MIOperandNo += NumOps;
|
|
||||||
} else {
|
|
||||||
throw "Illegal operand for the '" + R->getName() + "' instruction!";
|
|
||||||
}
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// Error parsing operands list, just ignore it.
|
// Error getting operand list, just ignore it (sparcv9).
|
||||||
AsmString.clear();
|
AsmString.clear();
|
||||||
OperandList.clear();
|
OperandList.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned MIOperandNo = 0;
|
||||||
|
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";
|
||||||
|
unsigned NumOps = 1;
|
||||||
|
if (Rec->isSubClassOf("RegisterClass")) {
|
||||||
|
Ty = getValueType(Rec->getValueAsDef("RegType"));
|
||||||
|
} else if (Rec->isSubClassOf("Operand")) {
|
||||||
|
Ty = getValueType(Rec->getValueAsDef("Type"));
|
||||||
|
PrintMethod = Rec->getValueAsString("PrintMethod");
|
||||||
|
NumOps = Rec->getValueAsInt("NumMIOperands");
|
||||||
|
} else if (Rec->getName() == "variable_ops") {
|
||||||
|
hasVariableNumberOfOperands = true;
|
||||||
|
continue;
|
||||||
|
} else
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user