[llvm-commits] CVS: llvm/utils/TableGen/CodeGenTarget.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Sep 14 14:05:13 PDT 2005
Changes in directory llvm/utils/TableGen:
CodeGenTarget.cpp updated: 1.37 -> 1.38
---
Log message:
Check that operands have unique names. REJECT instructions with broken operand
lists: only don't parse them if they are entirely missing (sparcv9).
---
Diffs of the changes: (+39 -29)
CodeGenTarget.cpp | 68 ++++++++++++++++++++++++++++++------------------------
1 files changed, 39 insertions(+), 29 deletions(-)
Index: llvm/utils/TableGen/CodeGenTarget.cpp
diff -u llvm/utils/TableGen/CodeGenTarget.cpp:1.37 llvm/utils/TableGen/CodeGenTarget.cpp:1.38
--- llvm/utils/TableGen/CodeGenTarget.cpp:1.37 Tue Sep 13 16:44:28 2005
+++ llvm/utils/TableGen/CodeGenTarget.cpp Wed Sep 14 16:05:02 2005
@@ -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,39 +251,48 @@
usesCustomDAGSchedInserter = R->getValueAsBit("usesCustomDAGSchedInserter");
hasVariableNumberOfOperands = false;
+ DagInit *DI;
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")) {
- 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!";
- }
+ DI = R->getValueAsDag("OperandList");
} catch (...) {
- // Error parsing operands list, just ignore it.
+ // Error getting operand list, just ignore it (sparcv9).
AsmString.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;
}
}
More information about the llvm-commits
mailing list