summaryrefslogtreecommitdiff
path: root/utils/TableGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-18 23:38:41 +0000
committerChris Lattner <sabre@nondot.org>2005-08-18 23:38:41 +0000
commitcfbf96aa9c3bd317548f72e022ba28a40353f95a (patch)
tree1de8de0444be5b8f6106e3f82461838313d3788f /utils/TableGen
parentc15ed447f494c77a76c24661893e22192ebb2103 (diff)
downloadllvm-cfbf96aa9c3bd317548f72e022ba28a40353f95a.tar.gz
llvm-cfbf96aa9c3bd317548f72e022ba28a40353f95a.tar.bz2
llvm-cfbf96aa9c3bd317548f72e022ba28a40353f95a.tar.xz
Figure out how many operands each instruction has, keep track of whether
or not it's variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r--utils/TableGen/CodeGenInstruction.h7
-rw-r--r--utils/TableGen/CodeGenTarget.cpp11
2 files changed, 12 insertions, 6 deletions
diff --git a/utils/TableGen/CodeGenInstruction.h b/utils/TableGen/CodeGenInstruction.h
index 3b3babf592..54f4b983a9 100644
--- a/utils/TableGen/CodeGenInstruction.h
+++ b/utils/TableGen/CodeGenInstruction.h
@@ -56,10 +56,12 @@ namespace llvm {
/// OperandList may not match the MachineInstr operand num. Until it
/// does, this contains the MI operand index of this operand.
unsigned MIOperandNo;
+ unsigned MINumOperands; // The number of operands.
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) {}
+ const std::string &PMN, unsigned MION, unsigned MINO)
+ : Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION),
+ MINumOperands(MINO) {}
};
/// OperandList - The list of declared operands, along with their declared
@@ -78,6 +80,7 @@ namespace llvm {
bool isCommutable;
bool isTerminator;
bool hasDelaySlot;
+ bool hasVariableNumberOfOperands;
CodeGenInstruction(Record *R, const std::string &AsmStr);
diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp
index 02678e9821..da6bf8df29 100644
--- a/utils/TableGen/CodeGenTarget.cpp
+++ b/utils/TableGen/CodeGenTarget.cpp
@@ -237,7 +237,8 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
isCommutable = R->getValueAsBit("isCommutable");
isTerminator = R->getValueAsBit("isTerminator");
hasDelaySlot = R->getValueAsBit("hasDelaySlot");
-
+ hasVariableNumberOfOperands = false;
+
try {
DagInit *DI = R->getValueAsDag("OperandList");
@@ -248,18 +249,20 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
MVT::ValueType Ty;
std::string PrintMethod = "printOperand";
unsigned NumOps = 1;
- if (Rec->isSubClassOf("RegisterClass"))
+ if (Rec->isSubClassOf("RegisterClass")) {
Ty = getValueType(Rec->getValueAsDef("RegType"));
- else if (Rec->isSubClassOf("Operand")) {
+ } 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;
} else
throw "Unknown operand class '" + Rec->getName() +
"' in instruction '" + R->getName() + "' instruction!";
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
- PrintMethod, MIOperandNo));
+ PrintMethod, MIOperandNo, NumOps));
MIOperandNo += NumOps;
} else {
throw "Illegal operand for the '" + R->getName() + "' instruction!";