diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index 8f8f89a79b0..9b8325c3779 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -767,6 +767,7 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) { std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName"); const std::vector &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"; }