diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-10 13:18:44 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-10 13:18:44 +0000 |
commit | c667ba69ac342563c0886e20509e68705d78a0a5 (patch) | |
tree | 1911023516ce937d5165eafcd85ed02c34ea0e30 /utils | |
parent | 06efdd238ed7d14eaabc3b074c3b0b292c1c3127 (diff) | |
download | external_llvm-c667ba69ac342563c0886e20509e68705d78a0a5.zip external_llvm-c667ba69ac342563c0886e20509e68705d78a0a5.tar.gz external_llvm-c667ba69ac342563c0886e20509e68705d78a0a5.tar.bz2 |
Put instruction names into an indexed string table on the side, removing a pointer from MCInstrDesc.
Make them accessible through MCInstrInfo. They are only used for debugging purposes so this doesn't
have an impact on performance. X86MCTargetDesc.o goes from 630K to 461K on x86_64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 46c9f86..4c4cd18 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -14,6 +14,7 @@ #include "InstrInfoEmitter.h" #include "CodeGenTarget.h" +#include "StringToOffsetTable.h" #include "llvm/TableGen/Record.h" #include "llvm/ADT/StringExtras.h" #include <algorithm> @@ -212,10 +213,26 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OperandInfoIDs, OS); OS << "};\n\n"; + OS << "extern const unsigned " << TargetName <<"InstrNameIndices[] = {\n "; + StringToOffsetTable StringTable; + for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) { + const CodeGenInstruction *Instr = NumberedInstructions[i]; + OS << StringTable.GetOrAddStringOffset(Instr->TheDef->getName()) << "U, "; + if (i % 8 == 0) + OS << "\n "; + } + + OS << "\n};\n\n"; + + OS << "const char *" << TargetName << "InstrNameData =\n"; + StringTable.EmitString(OS); + OS << ";\n\n"; + // MCInstrInfo initialization routine. OS << "static inline void Init" << TargetName << "MCInstrInfo(MCInstrInfo *II) {\n"; OS << " II->InitMCInstrInfo(" << TargetName << "Insts, " + << TargetName << "InstrNameIndices, " << TargetName << "InstrNameData, " << NumberedInstructions.size() << ");\n}\n\n"; OS << "} // End llvm namespace \n"; @@ -240,9 +257,12 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << "namespace llvm {\n"; OS << "extern const MCInstrDesc " << TargetName << "Insts[];\n"; + OS << "extern const unsigned " << TargetName << "InstrNameIndices[];\n"; + OS << "extern const char *" << TargetName << "InstrNameData;\n"; OS << ClassName << "::" << ClassName << "(int SO, int DO)\n" << " : TargetInstrInfoImpl(SO, DO) {\n" << " InitMCInstrInfo(" << TargetName << "Insts, " + << TargetName << "InstrNameIndices, " << TargetName << "InstrNameData, " << NumberedInstructions.size() << ");\n}\n"; OS << "} // End llvm namespace \n"; @@ -329,8 +349,6 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num, else OS << "OperandInfo" << OpInfo.find(OperandInfo)->second; - OS << ", \"" << Inst.TheDef->getName() << '"'; - OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n"; } |