mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-06 14:57:41 +00:00
Emit the asm writer's mnemonic table with SequenceToOffsetTable.
This way we can get AVX v-prefixed instructions tail merged with the normal insns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153869 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c97ef618d2
commit
94338594ef
@ -278,12 +278,27 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
|
|||||||
CGIAWIMap.insert(std::make_pair(Instructions[i].CGI, &Instructions[i]));
|
CGIAWIMap.insert(std::make_pair(Instructions[i].CGI, &Instructions[i]));
|
||||||
|
|
||||||
// Build an aggregate string, and build a table of offsets into it.
|
// Build an aggregate string, and build a table of offsets into it.
|
||||||
StringToOffsetTable StringTable;
|
SequenceToOffsetTable<std::string> StringTable;
|
||||||
|
|
||||||
/// OpcodeInfo - This encodes the index of the string to use for the first
|
/// OpcodeInfo - This encodes the index of the string to use for the first
|
||||||
/// chunk of the output as well as indices used for operand printing.
|
/// chunk of the output as well as indices used for operand printing.
|
||||||
std::vector<unsigned> OpcodeInfo;
|
std::vector<unsigned> OpcodeInfo;
|
||||||
|
|
||||||
|
// Add all strings to the string table upfront so it can generate an optimized
|
||||||
|
// representation.
|
||||||
|
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
|
||||||
|
AsmWriterInst *AWI = CGIAWIMap[NumberedInstructions[i]];
|
||||||
|
if (AWI != 0 &&
|
||||||
|
AWI->Operands[0].OperandType == AsmWriterOperand::isLiteralTextOperand &&
|
||||||
|
!AWI->Operands[0].Str.empty()) {
|
||||||
|
std::string Str = AWI->Operands[0].Str;
|
||||||
|
UnescapeString(Str);
|
||||||
|
StringTable.add(Str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTable.layout();
|
||||||
|
|
||||||
unsigned MaxStringIdx = 0;
|
unsigned MaxStringIdx = 0;
|
||||||
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
|
for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
|
||||||
AsmWriterInst *AWI = CGIAWIMap[NumberedInstructions[i]];
|
AsmWriterInst *AWI = CGIAWIMap[NumberedInstructions[i]];
|
||||||
@ -295,11 +310,11 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
|
|||||||
AsmWriterOperand::isLiteralTextOperand ||
|
AsmWriterOperand::isLiteralTextOperand ||
|
||||||
AWI->Operands[0].Str.empty()) {
|
AWI->Operands[0].Str.empty()) {
|
||||||
// Something handled by the asmwriter printer, but with no leading string.
|
// Something handled by the asmwriter printer, but with no leading string.
|
||||||
Idx = StringTable.GetOrAddStringOffset("");
|
Idx = StringTable.get("");
|
||||||
} else {
|
} else {
|
||||||
std::string Str = AWI->Operands[0].Str;
|
std::string Str = AWI->Operands[0].Str;
|
||||||
UnescapeString(Str);
|
UnescapeString(Str);
|
||||||
Idx = StringTable.GetOrAddStringOffset(Str);
|
Idx = StringTable.get(Str);
|
||||||
MaxStringIdx = std::max(MaxStringIdx, Idx);
|
MaxStringIdx = std::max(MaxStringIdx, Idx);
|
||||||
|
|
||||||
// Nuke the string from the operand list. It is now handled!
|
// Nuke the string from the operand list. It is now handled!
|
||||||
@ -374,9 +389,9 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
|
|||||||
O << " };\n\n";
|
O << " };\n\n";
|
||||||
|
|
||||||
// Emit the string itself.
|
// Emit the string itself.
|
||||||
O << " const char *const AsmStrs = \n";
|
O << " const char AsmStrs[] = {\n";
|
||||||
StringTable.EmitString(O);
|
StringTable.emit(O, printChar);
|
||||||
O << ";\n\n";
|
O << " };\n\n";
|
||||||
|
|
||||||
O << " O << \"\\t\";\n\n";
|
O << " O << \"\\t\";\n\n";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user