summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2005-10-31 17:16:46 +0000
committerJim Laskey <jlaskey@mac.com>2005-10-31 17:16:46 +0000
commitb5a0c0ee059db5994d4fec7ebd03c048b4fcd308 (patch)
treeddeea488a4f9796fc7a9442a59644c72e35bd1e9
parent10b1dd99f342d2d7af51dd43f3840f3bf40b0b87 (diff)
downloadllvm-b5a0c0ee059db5994d4fec7ebd03c048b4fcd308.tar.gz
llvm-b5a0c0ee059db5994d4fec7ebd03c048b4fcd308.tar.bz2
llvm-b5a0c0ee059db5994d4fec7ebd03c048b4fcd308.tar.xz
Emit itinerary class in instruction info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24122 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/InstrInfoEmitter.cpp34
-rw-r--r--utils/TableGen/InstrInfoEmitter.h7
2 files changed, 39 insertions, 2 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp
index b5a1a2e462..0626a309bd 100644
--- a/utils/TableGen/InstrInfoEmitter.cpp
+++ b/utils/TableGen/InstrInfoEmitter.cpp
@@ -76,6 +76,8 @@ static std::vector<Record*> GetOperandInfo(const CodeGenInstruction &Inst) {
// 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 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
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 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
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)
diff --git a/utils/TableGen/InstrInfoEmitter.h b/utils/TableGen/InstrInfoEmitter.h
index 93f0e605ab..2389f3a951 100644
--- a/utils/TableGen/InstrInfoEmitter.h
+++ b/utils/TableGen/InstrInfoEmitter.h
@@ -28,8 +28,11 @@ struct CodeGenInstruction;
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 @@ private:
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);
};