mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +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:
parent
1dbed16fec
commit
b5e9eb6089
@ -35,7 +35,11 @@ namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
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
|
||||
/// that we can consistently refer to them later. This is cleared
|
||||
@ -50,7 +54,6 @@ namespace {
|
||||
|
||||
void emitConstantValueOnly(const Constant *CV);
|
||||
void emitGlobalConstant(const Constant *CV);
|
||||
void printConstantPool(MachineConstantPool *MCP);
|
||||
void printOperand(const MachineInstr *MI, int opNum);
|
||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
@ -277,33 +280,15 @@ void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) {
|
||||
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()
|
||||
/// method to print assembly for each instruction.
|
||||
///
|
||||
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &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
|
||||
// BBs the same name. (If you have a better way, please let me know!)
|
||||
static unsigned BBNumber = 0;
|
||||
@ -312,9 +297,6 @@ bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
// What's my mangled name?
|
||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
||||
|
||||
// Print out constants referenced by the function
|
||||
printConstantPool(MF.getConstantPool());
|
||||
|
||||
// Print out labels for the function.
|
||||
O << "\t.text\n";
|
||||
O << "\t.align 16\n";
|
||||
@ -398,7 +380,8 @@ void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << MO.getSymbolName();
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
|
||||
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
|
||||
<< MO.getConstantPoolIndex();
|
||||
break;
|
||||
default:
|
||||
O << "<unknown operand type>"; abort (); break;
|
||||
|
@ -35,7 +35,11 @@ namespace {
|
||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||
|
||||
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
|
||||
/// that we can consistently refer to them later. This is cleared
|
||||
@ -50,7 +54,6 @@ namespace {
|
||||
|
||||
void emitConstantValueOnly(const Constant *CV);
|
||||
void emitGlobalConstant(const Constant *CV);
|
||||
void printConstantPool(MachineConstantPool *MCP);
|
||||
void printOperand(const MachineInstr *MI, int opNum);
|
||||
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
@ -277,33 +280,15 @@ void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) {
|
||||
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()
|
||||
/// method to print assembly for each instruction.
|
||||
///
|
||||
bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &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
|
||||
// BBs the same name. (If you have a better way, please let me know!)
|
||||
static unsigned BBNumber = 0;
|
||||
@ -312,9 +297,6 @@ bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
// What's my mangled name?
|
||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
||||
|
||||
// Print out constants referenced by the function
|
||||
printConstantPool(MF.getConstantPool());
|
||||
|
||||
// Print out labels for the function.
|
||||
O << "\t.text\n";
|
||||
O << "\t.align 16\n";
|
||||
@ -398,7 +380,8 @@ void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
O << MO.getSymbolName();
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
|
||||
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
|
||||
<< MO.getConstantPoolIndex();
|
||||
break;
|
||||
default:
|
||||
O << "<unknown operand type>"; abort (); break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user