Skip to content

Commit 17727ba

Browse files
committed
Figure out how many operands each instruction has, keep track of whether
or not it's variable. llvm-svn: 22885
1 parent 33acb2c commit 17727ba

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

llvm/utils/TableGen/CodeGenInstruction.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ namespace llvm {
5656
/// OperandList may not match the MachineInstr operand num. Until it
5757
/// does, this contains the MI operand index of this operand.
5858
unsigned MIOperandNo;
59+
unsigned MINumOperands; // The number of operands.
5960

6061
OperandInfo(Record *R, MVT::ValueType T, const std::string &N,
61-
const std::string &PMN, unsigned MION)
62-
: Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION) {}
62+
const std::string &PMN, unsigned MION, unsigned MINO)
63+
: Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION),
64+
MINumOperands(MINO) {}
6365
};
6466

6567
/// OperandList - The list of declared operands, along with their declared
@@ -78,6 +80,7 @@ namespace llvm {
7880
bool isCommutable;
7981
bool isTerminator;
8082
bool hasDelaySlot;
83+
bool hasVariableNumberOfOperands;
8184

8285
CodeGenInstruction(Record *R, const std::string &AsmStr);
8386

llvm/utils/TableGen/CodeGenTarget.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
237237
isCommutable = R->getValueAsBit("isCommutable");
238238
isTerminator = R->getValueAsBit("isTerminator");
239239
hasDelaySlot = R->getValueAsBit("hasDelaySlot");
240-
240+
hasVariableNumberOfOperands = false;
241+
241242
try {
242243
DagInit *DI = R->getValueAsDag("OperandList");
243244

@@ -248,18 +249,20 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
248249
MVT::ValueType Ty;
249250
std::string PrintMethod = "printOperand";
250251
unsigned NumOps = 1;
251-
if (Rec->isSubClassOf("RegisterClass"))
252+
if (Rec->isSubClassOf("RegisterClass")) {
252253
Ty = getValueType(Rec->getValueAsDef("RegType"));
253-
else if (Rec->isSubClassOf("Operand")) {
254+
} else if (Rec->isSubClassOf("Operand")) {
254255
Ty = getValueType(Rec->getValueAsDef("Type"));
255256
PrintMethod = Rec->getValueAsString("PrintMethod");
256257
NumOps = Rec->getValueAsInt("NumMIOperands");
258+
} else if (Rec->getName() == "variable_ops") {
259+
hasVariableNumberOfOperands = true;
257260
} else
258261
throw "Unknown operand class '" + Rec->getName() +
259262
"' in instruction '" + R->getName() + "' instruction!";
260263

261264
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
262-
PrintMethod, MIOperandNo));
265+
PrintMethod, MIOperandNo, NumOps));
263266
MIOperandNo += NumOps;
264267
} else {
265268
throw "Illegal operand for the '" + R->getName() + "' instruction!";

0 commit comments

Comments
 (0)