diff options
author | Craig Topper <craig.topper@gmail.com> | 2012-04-01 18:14:14 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2012-04-01 18:14:14 +0000 |
commit | 413b2e7539a1e41f8694abb809678ae48d1e6125 (patch) | |
tree | 828c099ad806b0ae8e5f2da267f4d717f24638eb /utils | |
parent | 243018ffcf764e4dde2968f909f4a2e578aafe86 (diff) | |
download | external_llvm-413b2e7539a1e41f8694abb809678ae48d1e6125.zip external_llvm-413b2e7539a1e41f8694abb809678ae48d1e6125.tar.gz external_llvm-413b2e7539a1e41f8694abb809678ae48d1e6125.tar.bz2 |
Use SequenceToOffsetTable to create instruction name table. Saves space particularly on X86 where AVX instructions just add a 'v' to the front of other instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 9a07970..0941d2e 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -14,7 +14,7 @@ #include "InstrInfoEmitter.h" #include "CodeGenTarget.h" -#include "StringToOffsetTable.h" +#include "SequenceToOffsetTable.h" #include "llvm/TableGen/Record.h" #include "llvm/ADT/StringExtras.h" #include <algorithm> @@ -214,21 +214,28 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OperandInfoIDs, OS); OS << "};\n\n"; - OS << "extern const unsigned " << TargetName <<"InstrNameIndices[] = {\n "; - StringToOffsetTable StringTable; + // Build an array of instruction names + SequenceToOffsetTable<std::string> InstrNames; for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) { const CodeGenInstruction *Instr = NumberedInstructions[i]; - OS << StringTable.GetOrAddStringOffset(Instr->TheDef->getName()) << "U, "; + InstrNames.add(Instr->TheDef->getName()); + } + + InstrNames.layout(); + OS << "extern const char " << TargetName << "InstrNameData[] = {\n"; + InstrNames.emit(OS, printChar); + OS << "};\n\n"; + + OS << "extern const unsigned " << TargetName <<"InstrNameIndices[] = {"; + for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) { if (i % 8 == 0) OS << "\n "; + const CodeGenInstruction *Instr = NumberedInstructions[i]; + OS << InstrNames.get(Instr->TheDef->getName()) << "U, "; } 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"; @@ -259,7 +266,7 @@ 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 << "extern const char " << TargetName << "InstrNameData[];\n"; OS << ClassName << "::" << ClassName << "(int SO, int DO)\n" << " : TargetInstrInfoImpl(SO, DO) {\n" << " InitMCInstrInfo(" << TargetName << "Insts, " |