mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
fix the column output stuff in the asmwriter from being dynamic and
driven by TAI to being static, driven by tblgen. This means that a target doesn't get impacted by this stuff at all if it doesn't opt into it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78427 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8a11c98b1d
commit
59e8677b19
@ -465,6 +465,17 @@ class AsmWriter {
|
|||||||
// will specify which alternative to use. For example "{x|y|z}" with Variant
|
// will specify which alternative to use. For example "{x|y|z}" with Variant
|
||||||
// == 1, will expand to "y".
|
// == 1, will expand to "y".
|
||||||
int Variant = 0;
|
int Variant = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// FirstOperandColumn/OperandSpacing - If the assembler syntax uses a columnar
|
||||||
|
// layout, the asmwriter can actually generate output in this columns (in
|
||||||
|
// verbose-asm mode). These two values indicate the width of the first column
|
||||||
|
// (the "opcode" area) and the width to reserve for subsequent operands. When
|
||||||
|
// verbose asm mode is enabled, operands will be indented to respect this.
|
||||||
|
int FirstOperandColumn = -1;
|
||||||
|
|
||||||
|
// OperandSpacing - Space between operand columns.
|
||||||
|
int OperandSpacing = -1;
|
||||||
}
|
}
|
||||||
def DefaultAsmWriter : AsmWriter;
|
def DefaultAsmWriter : AsmWriter;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace llvm {
|
|||||||
std::vector<AsmWriterOperand> Operands;
|
std::vector<AsmWriterOperand> Operands;
|
||||||
const CodeGenInstruction *CGI;
|
const CodeGenInstruction *CGI;
|
||||||
|
|
||||||
AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant);
|
AsmWriterInst(const CodeGenInstruction &CGI, Record *AsmWriter);
|
||||||
|
|
||||||
/// MatchesAllButOneOp - If this instruction is exactly identical to the
|
/// MatchesAllButOneOp - If this instruction is exactly identical to the
|
||||||
/// specified instruction except for one differing operand, return the
|
/// specified instruction except for one differing operand, return the
|
||||||
@ -132,10 +132,19 @@ std::string AsmWriterOperand::getCode() const {
|
|||||||
/// ParseAsmString - Parse the specified Instruction's AsmString into this
|
/// ParseAsmString - Parse the specified Instruction's AsmString into this
|
||||||
/// AsmWriterInst.
|
/// AsmWriterInst.
|
||||||
///
|
///
|
||||||
AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, Record *AsmWriter) {
|
||||||
this->CGI = &CGI;
|
this->CGI = &CGI;
|
||||||
|
|
||||||
|
unsigned Variant = AsmWriter->getValueAsInt("Variant");
|
||||||
|
int FirstOperandColumn = AsmWriter->getValueAsInt("FirstOperandColumn");
|
||||||
|
int OperandSpacing = AsmWriter->getValueAsInt("OperandSpacing");
|
||||||
|
|
||||||
unsigned CurVariant = ~0U; // ~0 if we are outside a {.|.|.} region, other #.
|
unsigned CurVariant = ~0U; // ~0 if we are outside a {.|.|.} region, other #.
|
||||||
|
|
||||||
|
// This is the number of tabs we've seen if we're doing columnar layout.
|
||||||
|
unsigned CurColumn = 0;
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Any extensions to this code need to be mirrored in the
|
// NOTE: Any extensions to this code need to be mirrored in the
|
||||||
// AsmPrinter::printInlineAsm code that executes as compile time (assuming
|
// AsmPrinter::printInlineAsm code that executes as compile time (assuming
|
||||||
// that inline asm strings should also get the new feature)!
|
// that inline asm strings should also get the new feature)!
|
||||||
@ -155,11 +164,19 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
|||||||
case '\n':
|
case '\n':
|
||||||
AddLiteralString("\\n");
|
AddLiteralString("\\n");
|
||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
|
// If the asm writer is not using a columnar layout, \t is not
|
||||||
|
// magic.
|
||||||
|
if (FirstOperandColumn == -1 || OperandSpacing == -1) {
|
||||||
|
AddLiteralString("\\t");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We recognize a tab as an operand delimeter.
|
||||||
|
unsigned DestColumn = FirstOperandColumn +
|
||||||
|
CurColumn++ * OperandSpacing;
|
||||||
Operands.push_back(
|
Operands.push_back(
|
||||||
// We recognize a tab as an operand delimeter. Either
|
AsmWriterOperand("O.PadToColumn(" + utostr(DestColumn) + ",1);\n",
|
||||||
// output column padding if enabled or emit a space.
|
|
||||||
AsmWriterOperand("PadToColumn(OperandColumn++);\n",
|
|
||||||
AsmWriterOperand::isLiteralStatementOperand));
|
AsmWriterOperand::isLiteralStatementOperand));
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
@ -181,11 +198,20 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
|||||||
if (AsmString[DollarPos+1] == 'n') {
|
if (AsmString[DollarPos+1] == 'n') {
|
||||||
AddLiteralString("\\n");
|
AddLiteralString("\\n");
|
||||||
} else if (AsmString[DollarPos+1] == 't') {
|
} else if (AsmString[DollarPos+1] == 't') {
|
||||||
|
// If the asm writer is not using a columnar layout, \t is not
|
||||||
|
// magic.
|
||||||
|
if (FirstOperandColumn == -1 || OperandSpacing == -1) {
|
||||||
|
AddLiteralString("\\t");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We recognize a tab as an operand delimeter.
|
||||||
|
unsigned DestColumn = FirstOperandColumn +
|
||||||
|
CurColumn++ * OperandSpacing;
|
||||||
Operands.push_back(
|
Operands.push_back(
|
||||||
// We recognize a tab as an operand delimeter. Either
|
AsmWriterOperand("O.PadToColumn(" + utostr(DestColumn) + ", 1);\n",
|
||||||
// output column padding if enabled or emit a space.
|
|
||||||
AsmWriterOperand("PadToColumn(OperandColumn++);\n",
|
|
||||||
AsmWriterOperand::isLiteralStatementOperand));
|
AsmWriterOperand::isLiteralStatementOperand));
|
||||||
|
break;
|
||||||
} else if (std::string("${|}\\").find(AsmString[DollarPos+1])
|
} else if (std::string("${|}\\").find(AsmString[DollarPos+1])
|
||||||
!= std::string::npos) {
|
!= std::string::npos) {
|
||||||
AddLiteralString(std::string(1, AsmString[DollarPos+1]));
|
AddLiteralString(std::string(1, AsmString[DollarPos+1]));
|
||||||
@ -532,7 +558,6 @@ void AsmWriterEmitter::run(raw_ostream &O) {
|
|||||||
CodeGenTarget Target;
|
CodeGenTarget Target;
|
||||||
Record *AsmWriter = Target.getAsmWriter();
|
Record *AsmWriter = Target.getAsmWriter();
|
||||||
std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
|
std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
|
||||||
unsigned Variant = AsmWriter->getValueAsInt("Variant");
|
|
||||||
|
|
||||||
O <<
|
O <<
|
||||||
"/// printInstruction - This method is automatically generated by tablegen\n"
|
"/// printInstruction - This method is automatically generated by tablegen\n"
|
||||||
@ -547,7 +572,7 @@ void AsmWriterEmitter::run(raw_ostream &O) {
|
|||||||
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
|
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
|
||||||
E = Target.inst_end(); I != E; ++I)
|
E = Target.inst_end(); I != E; ++I)
|
||||||
if (!I->second.AsmString.empty())
|
if (!I->second.AsmString.empty())
|
||||||
Instructions.push_back(AsmWriterInst(I->second, Variant));
|
Instructions.push_back(AsmWriterInst(I->second, AsmWriter));
|
||||||
|
|
||||||
// Get the instruction numbering.
|
// Get the instruction numbering.
|
||||||
Target.getInstructionsByEnumValue(NumberedInstructions);
|
Target.getInstructionsByEnumValue(NumberedInstructions);
|
||||||
@ -728,10 +753,6 @@ void AsmWriterEmitter::run(raw_ostream &O) {
|
|||||||
<< " if (Bits == 0) return false;\n"
|
<< " if (Bits == 0) return false;\n"
|
||||||
<< " O << AsmStrs+(Bits & " << (1 << AsmStrBits)-1 << ");\n\n";
|
<< " O << AsmStrs+(Bits & " << (1 << AsmStrBits)-1 << ");\n\n";
|
||||||
|
|
||||||
// This variable may be unused, suppress build warnings.
|
|
||||||
O << " unsigned OperandColumn = 1;\n";
|
|
||||||
O << " (void) OperandColumn;\n\n";
|
|
||||||
|
|
||||||
// Output the table driven operand information.
|
// Output the table driven operand information.
|
||||||
BitsLeft = 32-AsmStrBits;
|
BitsLeft = 32-AsmStrBits;
|
||||||
for (unsigned i = 0, e = TableDrivenOperandPrinters.size(); i != e; ++i) {
|
for (unsigned i = 0, e = TableDrivenOperandPrinters.size(); i != e; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user