mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +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 << " return 0;\n}\n\n";
|
||||||
|
|
||||||
OS << "unsigned " << ClassName
|
OS << "unsigned " << ClassName
|
||||||
<< "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n"
|
<< "::getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const {\n";
|
||||||
<< " switch (RegNo) {\n"
|
if (SubRegIndices.size()) {
|
||||||
<< " default:\n return 0;\n";
|
OS << " for (unsigned I = 0; I != array_lengthof("
|
||||||
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
|
<< TargetName << "SubRegTable[0]); ++I)\n"
|
||||||
const CodeGenRegister::SubRegMap &SRM = Regs[i]->getSubRegs();
|
<< " if (" << TargetName << "SubRegTable[RegNo - 1][I] == SubRegNo)\n"
|
||||||
if (SRM.empty())
|
<< " return I + 1;\n";
|
||||||
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";
|
|
||||||
}
|
}
|
||||||
OS << " };\n";
|
|
||||||
OS << " return 0;\n";
|
OS << " return 0;\n";
|
||||||
OS << "}\n\n";
|
OS << "}\n\n";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user