Emit itinerary class in instruction info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24122 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey
2005-10-31 17:16:46 +00:00
parent 10b1dd99f3
commit b5a0c0ee05
2 changed files with 39 additions and 2 deletions
+33 -1
View File
@@ -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)