mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Switch constant pool printing over to use the Shared AsmPrinter version
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24765 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -35,7 +35,11 @@ namespace {
|
|||||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||||
|
|
||||||
struct SparcV8AsmPrinter : public AsmPrinter {
|
struct SparcV8AsmPrinter : public AsmPrinter {
|
||||||
SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {}
|
SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {
|
||||||
|
Data16bitsDirective = "\t.half\t";
|
||||||
|
Data32bitsDirective = "\t.word\t";
|
||||||
|
Data64bitsDirective = "\t.xword\t";
|
||||||
|
}
|
||||||
|
|
||||||
/// We name each basic block in a Function with a unique number, so
|
/// We name each basic block in a Function with a unique number, so
|
||||||
/// that we can consistently refer to them later. This is cleared
|
/// that we can consistently refer to them later. This is cleared
|
||||||
@ -50,7 +54,6 @@ namespace {
|
|||||||
|
|
||||||
void emitConstantValueOnly(const Constant *CV);
|
void emitConstantValueOnly(const Constant *CV);
|
||||||
void emitGlobalConstant(const Constant *CV);
|
void emitGlobalConstant(const Constant *CV);
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
|
||||||
void printOperand(const MachineInstr *MI, int opNum);
|
void printOperand(const MachineInstr *MI, int opNum);
|
||||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
@ -277,33 +280,15 @@ void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) {
|
|||||||
O << "\n";
|
O << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printConstantPool - Print to the current output stream assembly
|
|
||||||
/// representations of the constants in the constant pool MCP. This is
|
|
||||||
/// used to print out constants which have been "spilled to memory" by
|
|
||||||
/// the code generator.
|
|
||||||
///
|
|
||||||
void SparcV8AsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|
||||||
const std::vector<Constant*> &CP = MCP->getConstants();
|
|
||||||
const TargetData &TD = TM.getTargetData();
|
|
||||||
|
|
||||||
if (CP.empty()) return;
|
|
||||||
|
|
||||||
SwitchSection(".section \".rodata\"\n", 0);
|
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
|
||||||
O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
|
|
||||||
<< "\n";
|
|
||||||
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t!"
|
|
||||||
<< *CP[i] << "\n";
|
|
||||||
emitGlobalConstant(CP[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||||
/// method to print assembly for each instruction.
|
/// method to print assembly for each instruction.
|
||||||
///
|
///
|
||||||
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
SetupMachineFunction(MF);
|
SetupMachineFunction(MF);
|
||||||
|
|
||||||
|
// Print out constants referenced by the function
|
||||||
|
EmitConstantPool(MF.getConstantPool());
|
||||||
|
|
||||||
// BBNumber is used here so that a given Printer will never give two
|
// BBNumber is used here so that a given Printer will never give two
|
||||||
// BBs the same name. (If you have a better way, please let me know!)
|
// BBs the same name. (If you have a better way, please let me know!)
|
||||||
static unsigned BBNumber = 0;
|
static unsigned BBNumber = 0;
|
||||||
@ -312,9 +297,6 @@ bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// What's my mangled name?
|
// What's my mangled name?
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
CurrentFnName = Mang->getValueName(MF.getFunction());
|
||||||
|
|
||||||
// Print out constants referenced by the function
|
|
||||||
printConstantPool(MF.getConstantPool());
|
|
||||||
|
|
||||||
// Print out labels for the function.
|
// Print out labels for the function.
|
||||||
O << "\t.text\n";
|
O << "\t.text\n";
|
||||||
O << "\t.align 16\n";
|
O << "\t.align 16\n";
|
||||||
@ -398,7 +380,8 @@ void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
|
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
|
||||||
|
<< MO.getConstantPoolIndex();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
O << "<unknown operand type>"; abort (); break;
|
O << "<unknown operand type>"; abort (); break;
|
||||||
|
@ -35,7 +35,11 @@ namespace {
|
|||||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||||
|
|
||||||
struct SparcV8AsmPrinter : public AsmPrinter {
|
struct SparcV8AsmPrinter : public AsmPrinter {
|
||||||
SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {}
|
SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {
|
||||||
|
Data16bitsDirective = "\t.half\t";
|
||||||
|
Data32bitsDirective = "\t.word\t";
|
||||||
|
Data64bitsDirective = "\t.xword\t";
|
||||||
|
}
|
||||||
|
|
||||||
/// We name each basic block in a Function with a unique number, so
|
/// We name each basic block in a Function with a unique number, so
|
||||||
/// that we can consistently refer to them later. This is cleared
|
/// that we can consistently refer to them later. This is cleared
|
||||||
@ -50,7 +54,6 @@ namespace {
|
|||||||
|
|
||||||
void emitConstantValueOnly(const Constant *CV);
|
void emitConstantValueOnly(const Constant *CV);
|
||||||
void emitGlobalConstant(const Constant *CV);
|
void emitGlobalConstant(const Constant *CV);
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
|
||||||
void printOperand(const MachineInstr *MI, int opNum);
|
void printOperand(const MachineInstr *MI, int opNum);
|
||||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
@ -277,33 +280,15 @@ void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) {
|
|||||||
O << "\n";
|
O << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printConstantPool - Print to the current output stream assembly
|
|
||||||
/// representations of the constants in the constant pool MCP. This is
|
|
||||||
/// used to print out constants which have been "spilled to memory" by
|
|
||||||
/// the code generator.
|
|
||||||
///
|
|
||||||
void SparcV8AsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|
||||||
const std::vector<Constant*> &CP = MCP->getConstants();
|
|
||||||
const TargetData &TD = TM.getTargetData();
|
|
||||||
|
|
||||||
if (CP.empty()) return;
|
|
||||||
|
|
||||||
SwitchSection(".section \".rodata\"\n", 0);
|
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
|
||||||
O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
|
|
||||||
<< "\n";
|
|
||||||
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t!"
|
|
||||||
<< *CP[i] << "\n";
|
|
||||||
emitGlobalConstant(CP[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||||
/// method to print assembly for each instruction.
|
/// method to print assembly for each instruction.
|
||||||
///
|
///
|
||||||
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
SetupMachineFunction(MF);
|
SetupMachineFunction(MF);
|
||||||
|
|
||||||
|
// Print out constants referenced by the function
|
||||||
|
EmitConstantPool(MF.getConstantPool());
|
||||||
|
|
||||||
// BBNumber is used here so that a given Printer will never give two
|
// BBNumber is used here so that a given Printer will never give two
|
||||||
// BBs the same name. (If you have a better way, please let me know!)
|
// BBs the same name. (If you have a better way, please let me know!)
|
||||||
static unsigned BBNumber = 0;
|
static unsigned BBNumber = 0;
|
||||||
@ -312,9 +297,6 @@ bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// What's my mangled name?
|
// What's my mangled name?
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
CurrentFnName = Mang->getValueName(MF.getFunction());
|
||||||
|
|
||||||
// Print out constants referenced by the function
|
|
||||||
printConstantPool(MF.getConstantPool());
|
|
||||||
|
|
||||||
// Print out labels for the function.
|
// Print out labels for the function.
|
||||||
O << "\t.text\n";
|
O << "\t.text\n";
|
||||||
O << "\t.align 16\n";
|
O << "\t.align 16\n";
|
||||||
@ -398,7 +380,8 @@ void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
|
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
|
||||||
|
<< MO.getConstantPoolIndex();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
O << "<unknown operand type>"; abort (); break;
|
O << "<unknown operand type>"; abort (); break;
|
||||||
|
Reference in New Issue
Block a user