[llvm-commits] CVS: llvm/utils/TableGen/InstrInfoEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon May 1 16:46:29 PDT 2006
Changes in directory llvm/utils/TableGen:
InstrInfoEmitter.cpp updated: 1.38 -> 1.39
---
Log message:
Put instruction names into the first non TargetInstrInfo namespace found.
---
Diffs of the changes: (+18 -10)
InstrInfoEmitter.cpp | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.38 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.39
--- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.38 Mon May 1 04:30:17 2006
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp Mon May 1 18:46:16 2006
@@ -28,23 +28,31 @@
// We must emit the PHI opcode first...
Record *InstrInfo = Target.getInstructionSet();
- std::string Namespace = Target.inst_begin()->second.Namespace;
-
- if (!Namespace.empty())
- OS << "namespace " << Namespace << " {\n";
- OS << " enum {\n";
+ std::string Namespace;
+ for (CodeGenTarget::inst_iterator II = Target.inst_begin(),
+ E = Target.inst_end(); II != E; ++II) {
+ if (II->second.Namespace != "TargetInstrInfo") {
+ Namespace = II->second.Namespace;
+ break;
+ }
+ }
+
+ if (Namespace.empty()) {
+ std::cerr << "No instructions defined!\n";
+ exit(1);
+ }
std::vector<const CodeGenInstruction*> NumberedInstructions;
Target.getInstructionsByEnumValue(NumberedInstructions);
+ OS << "namespace " << Namespace << " {\n";
+ OS << " enum {\n";
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
OS << " " << NumberedInstructions[i]->TheDef->getName()
- << ", \t// " << i << "\n";
+ << "\t= " << i << ",\n";
}
- OS << " INSTRUCTION_LIST_END\n";
- OS << " };\n";
- if (!Namespace.empty())
- OS << "}\n";
+ OS << " INSTRUCTION_LIST_END = " << NumberedInstructions.size() << "\n";
+ OS << " };\n}\n";
OS << "} // End llvm namespace \n";
}
More information about the llvm-commits
mailing list