mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Implement getSubRegIndex as a linear search on the SubRegTable instead of using a big switch.
- The search bounds are constant, in the worst case (ARM target) it will scan over 30 uint16_ts. - This method isn't very hot, I had problems finding a testcase where it's called more than a dozen of times (no perf impact). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151773 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8bee081a2c
commit
6c449ebbe6
@ -774,21 +774,13 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
|
||||
OS << " return 0;\n}\n\n";
|
||||
|
||||
OS << "unsigned " << ClassName
|
||||
<< "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n"
|
||||
<< " switch (RegNo) {\n"
|
||||
<< " default:\n return 0;\n";
|
||||
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
|
||||
const CodeGenRegister::SubRegMap &SRM = Regs[i]->getSubRegs();
|
||||
if (SRM.empty())
|
||||
continue;
|
||||
OS << " case " << getQualifiedName(Regs[i]->TheDef) << ":\n";
|
||||
for (CodeGenRegister::SubRegMap::const_iterator ii = SRM.begin(),
|
||||
ie = SRM.end(); ii != ie; ++ii)
|
||||
OS << " if (SubRegNo == " << getQualifiedName(ii->second->TheDef)
|
||||
<< ") return " << ii->first->getQualifiedName() << ";\n";
|
||||
OS << " return 0;\n";
|
||||
<< "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n";
|
||||
if (SubRegIndices.size()) {
|
||||
OS << " for (unsigned I = 0; I != array_lengthof("
|
||||
<< TargetName << "SubRegTable[0]); ++I)\n"
|
||||
<< " if (" << TargetName << "SubRegTable[RegNo - 1][I] == SubRegNo)\n"
|
||||
<< " return I + 1;\n";
|
||||
}
|
||||
OS << " };\n";
|
||||
OS << " return 0;\n";
|
||||
OS << "}\n\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user