[llvm-commits] CVS: llvm/utils/TableGen/InstrInfoEmitter.cpp InstrInfoEmitter.h
Jim Laskey
jlaskey at apple.com
Mon Oct 31 09:16:57 PST 2005
Changes in directory llvm/utils/TableGen:
InstrInfoEmitter.cpp updated: 1.29 -> 1.30
InstrInfoEmitter.h updated: 1.11 -> 1.12
---
Log message:
Emit itinerary class in instruction info.
---
Diffs of the changes: (+39 -2)
InstrInfoEmitter.cpp | 34 +++++++++++++++++++++++++++++++++-
InstrInfoEmitter.h | 7 ++++++-
2 files changed, 39 insertions(+), 2 deletions(-)
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
diff -u llvm/utils/TableGen/InstrInfoEmitter.cpp:1.29 llvm/utils/TableGen/InstrInfoEmitter.cpp:1.30
--- llvm/utils/TableGen/InstrInfoEmitter.cpp:1.29 Fri Oct 28 17:59:53 2005
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp Mon Oct 31 11:16:46 2005
@@ -76,6 +76,8 @@
// run - Emit the main instruction description records for the target...
void InstrInfoEmitter::run(std::ostream &OS) {
+ GatherItinClasses();
+
EmitSourceFileHeader("Target Instruction Descriptors", OS);
OS << "namespace llvm {\n\n";
@@ -168,7 +170,13 @@
OS << Inst.TheDef->getName();
else
OS << Inst.Name;
- OS << "\",\t" << NumOperands << ", -1, 0, false, 0, 0, 0, 0";
+
+ unsigned ItinClass = !IsItineraries ? 0 :
+ ItinClassNumber(Inst.TheDef->getValueAsDef("Itinerary")->getName());
+
+ OS << "\",\t" << NumOperands << ", -1, 0, false, 0, 0, "
+ << ItinClass
+ << ", 0";
// Emit all of the target indepedent flags...
if (Inst.isReturn) OS << "|M_RET_FLAG";
@@ -222,6 +230,30 @@
OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";
}
+struct LessRecord {
+ bool operator()(const Record *Rec1, const Record *Rec2) const {
+ return Rec1->getName() < Rec2->getName();
+ }
+};
+void InstrInfoEmitter::GatherItinClasses() {
+ std::vector<Record*> DefList =
+ Records.getAllDerivedDefinitions("InstrItinClass");
+ IsItineraries = !DefList.empty();
+
+ if (!IsItineraries) return;
+
+ sort(DefList.begin(), DefList.end(), LessRecord());
+
+ for (unsigned i = 0, N = DefList.size(); i < N; i++) {
+ Record *Def = DefList[i];
+ ItinClassMap[Def->getName()] = i + 1;
+ }
+}
+
+unsigned InstrInfoEmitter::ItinClassNumber(std::string ItinName) {
+ return ItinClassMap[ItinName];
+}
+
void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
IntInit *ShiftInt, std::ostream &OS) {
if (Val == 0 || ShiftInt == 0)
Index: llvm/utils/TableGen/InstrInfoEmitter.h
diff -u llvm/utils/TableGen/InstrInfoEmitter.h:1.11 llvm/utils/TableGen/InstrInfoEmitter.h:1.12
--- llvm/utils/TableGen/InstrInfoEmitter.h:1.11 Fri Oct 28 17:59:53 2005
+++ llvm/utils/TableGen/InstrInfoEmitter.h Mon Oct 31 11:16:46 2005
@@ -28,8 +28,11 @@
class InstrInfoEmitter : public TableGenBackend {
RecordKeeper &Records;
+ bool IsItineraries;
+ std::map<std::string, unsigned> ItinClassMap;
+
public:
- InstrInfoEmitter(RecordKeeper &R) : Records(R) {}
+ InstrInfoEmitter(RecordKeeper &R) : Records(R), IsItineraries(false) {}
// run - Output the instruction set description, returning true on failure.
void run(std::ostream &OS);
@@ -44,6 +47,8 @@
std::map<std::vector<Record*>, unsigned> &EL,
std::map<std::vector<Record*>, unsigned> &OpInfo,
std::ostream &OS);
+ void GatherItinClasses();
+ unsigned ItinClassNumber(std::string ItinName);
void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
std::ostream &OS);
};
More information about the llvm-commits
mailing list