[llvm-commits] [llvm] r81741 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
Chris Lattner
sabre at nondot.org
Sun Sep 13 18:26:18 PDT 2009
Author: lattner
Date: Sun Sep 13 20:26:18 2009
New Revision: 81741
URL: http://llvm.org/viewvc/llvm-project?rev=81741&view=rev
Log:
emit the register table as a massive string to avoid relocations.
Modified:
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=81741&r1=81740&r2=81741&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Sun Sep 13 20:26:18 2009
@@ -767,6 +767,7 @@
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 @@
<< " 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";
}
More information about the llvm-commits
mailing list