[llvm-commits] [llvm] r153841 - /llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
Craig Topper
craig.topper at gmail.com
Sun Apr 1 11:14:14 PDT 2012
Author: ctopper
Date: Sun Apr 1 13:14:14 2012
New Revision: 153841
URL: http://llvm.org/viewvc/llvm-project?rev=153841&view=rev
Log:
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.
Modified:
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=153841&r1=153840&r2=153841&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Sun Apr 1 13:14:14 2012
@@ -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 @@
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 @@
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, "
More information about the llvm-commits
mailing list