mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-19 16:35:10 +00:00
Start parsing more information from the Operand information
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15644 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
552a8428fa
commit
cf03da0ce9
@ -31,15 +31,35 @@ namespace llvm {
|
||||
/// instruction.
|
||||
std::string AsmString;
|
||||
|
||||
/// OperandInfo - For each operand declared in the OperandList of the
|
||||
/// instruction, keep track of its record (which specifies the class of the
|
||||
/// operand), its type, and the name given to the operand, if any.
|
||||
/// OperandInfo - The information we keep track of for each operand in the
|
||||
/// operand list for a tablegen instruction.
|
||||
struct OperandInfo {
|
||||
/// Rec - The definition this operand is declared as.
|
||||
Record *Rec;
|
||||
|
||||
/// Ty - The MachineValueType of the operand.
|
||||
///
|
||||
MVT::ValueType Ty;
|
||||
|
||||
/// Name - If this operand was assigned a symbolic name, this is it,
|
||||
/// otherwise, it's empty.
|
||||
std::string Name;
|
||||
OperandInfo(Record *R, MVT::ValueType T, const std::string &N)
|
||||
: Rec(R), Ty(T), Name(N) {}
|
||||
|
||||
/// PrinterMethodName - The method used to print operands of this type in
|
||||
/// the asmprinter.
|
||||
std::string PrinterMethodName;
|
||||
|
||||
/// MIOperandNo - Currently (this is meant to be phased out), some logical
|
||||
/// operands correspond to multiple MachineInstr operands. In the X86
|
||||
/// target for example, one address operand is represented as 4
|
||||
/// MachineOperands. Because of this, the operand number in the
|
||||
/// OperandList may not match the MachineInstr operand num. Until it
|
||||
/// does, this contains the MI operand index of this operand.
|
||||
unsigned MIOperandNo;
|
||||
|
||||
OperandInfo(Record *R, MVT::ValueType T, const std::string &N,
|
||||
const std::string &PMN, unsigned MION)
|
||||
: Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION) {}
|
||||
};
|
||||
|
||||
/// OperandList - The list of declared operands, along with their declared
|
||||
|
@ -132,19 +132,26 @@ CodeGenInstruction::CodeGenInstruction(Record *R) : TheDef(R) {
|
||||
try {
|
||||
DagInit *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"))
|
||||
else if (Rec->isSubClassOf("Operand")) {
|
||||
Ty = getValueType(Rec->getValueAsDef("Type"));
|
||||
else
|
||||
PrintMethod = Rec->getValueAsString("PrintMethod");
|
||||
NumOps = Rec->getValueAsInt("NumMIOperands");
|
||||
} else
|
||||
throw "Unknown operand class '" + Rec->getName() +
|
||||
"' in instruction '" + R->getName() + "' instruction!";
|
||||
|
||||
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i)));
|
||||
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
|
||||
PrintMethod, MIOperandNo));
|
||||
MIOperandNo += NumOps;
|
||||
} else {
|
||||
throw "Illegal operand for the '" + R->getName() + "' instruction!";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user