mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-25 13:08:00 +00:00
emit the register table as a massive string to avoid relocations.
llvm-svn: 81741
This commit is contained in:
parent
d823d97b3a
commit
c4a64a08ec
@ -767,6 +767,7 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
|
||||
std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
|
||||
const std::vector<CodeGenRegister> &Registers = Target.getRegisters();
|
||||
|
||||
StringToOffsetTable StringTable;
|
||||
O <<
|
||||
"\n\n/// getRegisterName - This method is automatically generated by tblgen\n"
|
||||
"/// from the register set description. This returns the assembler name\n"
|
||||
@ -776,19 +777,29 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
|
||||
<< " assert(RegNo && RegNo < " << (Registers.size()+1)
|
||||
<< " && \"Invalid register number!\");\n"
|
||||
<< "\n"
|
||||
<< " static const char *const RegAsmNames[] = {\n";
|
||||
<< " static const unsigned RegAsmOffset[] = {\n ";
|
||||
for (unsigned i = 0, e = Registers.size(); i != e; ++i) {
|
||||
const CodeGenRegister &Reg = Registers[i];
|
||||
|
||||
std::string AsmName = Reg.TheDef->getValueAsString("AsmName");
|
||||
if (AsmName.empty())
|
||||
AsmName = Reg.getName();
|
||||
O << " \"" << AsmName << "\",\n";
|
||||
|
||||
|
||||
if ((i % 16) == 0)
|
||||
O << "\n ";
|
||||
|
||||
O << StringTable.GetOrAddStringOffset(AsmName) << ", ";
|
||||
}
|
||||
O << " 0\n"
|
||||
O << "0\n"
|
||||
<< " };\n"
|
||||
<< "\n"
|
||||
<< " return RegAsmNames[RegNo-1];\n"
|
||||
<< "\n";
|
||||
|
||||
O << " const char *AsmStrs =\n";
|
||||
StringTable.EmitString(O);
|
||||
O << ";\n";
|
||||
|
||||
O << " return AsmStrs+RegAsmOffset[RegNo-1];\n"
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user