1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01: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).

llvm-svn: 151773
This commit is contained in:
Benjamin Kramer 2012-02-29 23:46:50 +00:00
parent 46c639cf8a
commit 16bdd01e87

View File

@ -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";