mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
simplify some code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fe71893183
commit
951740afb4
@ -175,10 +175,7 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
|
|||||||
else
|
else
|
||||||
OS << Inst.Name;
|
OS << Inst.Name;
|
||||||
|
|
||||||
unsigned ItinClass = !IsItineraries ? 0 :
|
OS << "\",\t" << getItinClassNumber(Inst.TheDef) << ", 0";
|
||||||
ItinClassNumber(Inst.TheDef->getValueAsDef("Itinerary")->getName());
|
|
||||||
|
|
||||||
OS << "\",\t" << ItinClass << ", 0";
|
|
||||||
|
|
||||||
// Try to determine (from the pattern), if the instruction is a store.
|
// Try to determine (from the pattern), if the instruction is a store.
|
||||||
bool isStore = false;
|
bool isStore = false;
|
||||||
@ -258,28 +255,23 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
|
|||||||
OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";
|
OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LessRecord {
|
struct RecordNameComparator {
|
||||||
bool operator()(const Record *Rec1, const Record *Rec2) const {
|
bool operator()(const Record *Rec1, const Record *Rec2) const {
|
||||||
return Rec1->getName() < Rec2->getName();
|
return Rec1->getName() < Rec2->getName();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void InstrInfoEmitter::GatherItinClasses() {
|
void InstrInfoEmitter::GatherItinClasses() {
|
||||||
std::vector<Record*> DefList =
|
std::vector<Record*> DefList =
|
||||||
Records.getAllDerivedDefinitions("InstrItinClass");
|
Records.getAllDerivedDefinitions("InstrItinClass");
|
||||||
IsItineraries = !DefList.empty();
|
std::sort(DefList.begin(), DefList.end(), RecordNameComparator());
|
||||||
|
|
||||||
if (!IsItineraries) return;
|
for (unsigned i = 0, N = DefList.size(); i < N; i++)
|
||||||
|
ItinClassMap[DefList[i]->getName()] = i;
|
||||||
std::sort(DefList.begin(), DefList.end(), LessRecord());
|
|
||||||
|
|
||||||
for (unsigned i = 0, N = DefList.size(); i < N; i++) {
|
|
||||||
Record *Def = DefList[i];
|
|
||||||
ItinClassMap[Def->getName()] = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned InstrInfoEmitter::ItinClassNumber(std::string ItinName) {
|
unsigned InstrInfoEmitter::getItinClassNumber(const Record *InstRec) {
|
||||||
return ItinClassMap[ItinName];
|
return ItinClassMap[InstRec->getValueAsDef("Itinerary")->getName()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
|
void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val,
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#define INSTRINFO_EMITTER_H
|
#define INSTRINFO_EMITTER_H
|
||||||
|
|
||||||
#include "TableGenBackend.h"
|
#include "TableGenBackend.h"
|
||||||
|
#include "CodeGenDAGPatterns.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -28,11 +29,11 @@ class CodeGenInstruction;
|
|||||||
|
|
||||||
class InstrInfoEmitter : public TableGenBackend {
|
class InstrInfoEmitter : public TableGenBackend {
|
||||||
RecordKeeper &Records;
|
RecordKeeper &Records;
|
||||||
bool IsItineraries;
|
CodeGenDAGPatterns CDP;
|
||||||
std::map<std::string, unsigned> ItinClassMap;
|
std::map<std::string, unsigned> ItinClassMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InstrInfoEmitter(RecordKeeper &R) : Records(R), IsItineraries(false) {}
|
InstrInfoEmitter(RecordKeeper &R) : Records(R), CDP(R) { }
|
||||||
|
|
||||||
// run - Output the instruction set description, returning true on failure.
|
// run - Output the instruction set description, returning true on failure.
|
||||||
void run(std::ostream &OS);
|
void run(std::ostream &OS);
|
||||||
@ -46,7 +47,7 @@ private:
|
|||||||
std::map<std::vector<std::string>, unsigned> &OpInfo,
|
std::map<std::vector<std::string>, unsigned> &OpInfo,
|
||||||
std::ostream &OS);
|
std::ostream &OS);
|
||||||
void GatherItinClasses();
|
void GatherItinClasses();
|
||||||
unsigned ItinClassNumber(std::string ItinName);
|
unsigned getItinClassNumber(const Record *InstRec);
|
||||||
void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
|
void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
|
||||||
std::ostream &OS);
|
std::ostream &OS);
|
||||||
std::vector<std::string> GetOperandInfo(const CodeGenInstruction &Inst);
|
std::vector<std::string> GetOperandInfo(const CodeGenInstruction &Inst);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user