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:
Owen Anderson
2012-09-11 23:32:17 +00:00
parent 2a3fcb382e
commit d2c699706c
3 changed files with 15 additions and 6 deletions
+5 -6
View File
@@ -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::