mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
Compute a map from register names to registers, rather than scanning the list of registers every time we want to look up a register by name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163659 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a3fcb382e
commit
d2c699706c
@ -993,6 +993,12 @@ CodeGenRegBank::CodeGenRegBank(RecordKeeper &Records) {
|
||||
for (unsigned i = 0, e = Registers.size(); i != e; ++i)
|
||||
Registers[i]->buildObjectGraph(*this);
|
||||
|
||||
// Compute register name map.
|
||||
for (unsigned i = 0, e = Registers.size(); i != e; ++i)
|
||||
RegistersByName.GetOrCreateValue(
|
||||
Registers[i]->TheDef->getValueAsString("AsmName"),
|
||||
Registers[i]);
|
||||
|
||||
// Precompute all sub-register maps.
|
||||
// This will create Composite entries for all inferred sub-register indices.
|
||||
for (unsigned i = 0, e = Registers.size(); i != e; ++i)
|
||||
|
@ -440,6 +440,7 @@ namespace llvm {
|
||||
|
||||
// Registers.
|
||||
std::vector<CodeGenRegister*> Registers;
|
||||
StringMap<CodeGenRegister*> RegistersByName;
|
||||
DenseMap<Record*, CodeGenRegister*> Def2Reg;
|
||||
unsigned NumNativeRegUnits;
|
||||
|
||||
@ -522,6 +523,9 @@ namespace llvm {
|
||||
}
|
||||
|
||||
const std::vector<CodeGenRegister*> &getRegisters() { return Registers; }
|
||||
const StringMap<CodeGenRegister*> &getRegistersByName() {
|
||||
return RegistersByName;
|
||||
}
|
||||
|
||||
// Find a register from its Record def.
|
||||
CodeGenRegister *getReg(Record*);
|
||||
|
@ -199,12 +199,11 @@ void CodeGenTarget::ReadRegAltNameIndices() const {
|
||||
/// getRegisterByName - If there is a register with the specific AsmName,
|
||||
/// return it.
|
||||
const CodeGenRegister *CodeGenTarget::getRegisterByName(StringRef Name) const {
|
||||
const std::vector<CodeGenRegister*> &Regs = getRegBank().getRegisters();
|
||||
for (unsigned i = 0, e = Regs.size(); i != e; ++i)
|
||||
if (Regs[i]->TheDef->getValueAsString("AsmName") == Name)
|
||||
return Regs[i];
|
||||
|
||||
return 0;
|
||||
const StringMap<CodeGenRegister*> &Regs = getRegBank().getRegistersByName();
|
||||
StringMap<CodeGenRegister*>::const_iterator I = Regs.find(Name);
|
||||
if (I == Regs.end())
|
||||
return 0;
|
||||
return I->second;
|
||||
}
|
||||
|
||||
std::vector<MVT::SimpleValueType> CodeGenTarget::
|
||||
|
Loading…
Reference in New Issue
Block a user