diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-06 01:12:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-06 01:12:44 +0000 |
commit | 951740afb41bbae2c8b034bab1911c9ec949ccf4 (patch) | |
tree | a52af76a0e62b724686705acb5e296e939e76a93 /utils/TableGen/InstrInfoEmitter.cpp | |
parent | fe71893183f504feff290e343bf740bd32432129 (diff) | |
download | llvm-951740afb41bbae2c8b034bab1911c9ec949ccf4.tar.gz llvm-951740afb41bbae2c8b034bab1911c9ec949ccf4.tar.bz2 llvm-951740afb41bbae2c8b034bab1911c9ec949ccf4.tar.xz |
simplify some code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45642 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/InstrInfoEmitter.cpp')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 10962041e7..b3ca0aa912 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -175,10 +175,7 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num, else OS << Inst.Name; - unsigned ItinClass = !IsItineraries ? 0 : - ItinClassNumber(Inst.TheDef->getValueAsDef("Itinerary")->getName()); - - OS << "\",\t" << ItinClass << ", 0"; + OS << "\",\t" << getItinClassNumber(Inst.TheDef) << ", 0"; // Try to determine (from the pattern), if the instruction is a store. bool isStore = false; @@ -258,28 +255,23 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num, OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n"; } -struct LessRecord { +struct RecordNameComparator { 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; - - std::sort(DefList.begin(), DefList.end(), LessRecord()); + std::sort(DefList.begin(), DefList.end(), RecordNameComparator()); - for (unsigned i = 0, N = DefList.size(); i < N; i++) { - Record *Def = DefList[i]; - ItinClassMap[Def->getName()] = i; - } + for (unsigned i = 0, N = DefList.size(); i < N; i++) + ItinClassMap[DefList[i]->getName()] = i; } -unsigned InstrInfoEmitter::ItinClassNumber(std::string ItinName) { - return ItinClassMap[ItinName]; +unsigned InstrInfoEmitter::getItinClassNumber(const Record *InstRec) { + return ItinClassMap[InstRec->getValueAsDef("Itinerary")->getName()]; } void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val, |