Plug in basic hooks for an autogenerated asm printer to fill in.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24739 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Sparc/SparcAsmPrinter.cpp b/lib/Target/Sparc/SparcAsmPrinter.cpp
index 9aeb023..bcf17e9 100644
--- a/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -33,7 +33,7 @@
namespace {
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
- struct V8Printer : public MachineFunctionPass {
+ struct SparcV8AsmPrinter : public MachineFunctionPass {
/// Output stream on which we're printing assembly code.
///
std::ostream &O;
@@ -47,7 +47,7 @@
///
Mangler *Mang;
- V8Printer(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { }
+ SparcV8AsmPrinter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { }
/// We name each basic block in a Function with a unique number, so
/// that we can consistently refer to them later. This is cleared
@@ -72,12 +72,15 @@
void printOperand(const MachineInstr *MI, int opNum);
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
void printMachineInstruction(const MachineInstr *MI);
+ bool printInstruction(const MachineInstr *MI); // autogenerated.
bool runOnMachineFunction(MachineFunction &F);
bool doInitialization(Module &M);
bool doFinalization(Module &M);
};
} // end of anonymous namespace
+#include "SparcV8GenAsmWriter.inc"
+
/// createSparcV8CodePrinterPass - Returns a pass that prints the SparcV8
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description. This should work
@@ -85,7 +88,7 @@
///
FunctionPass *llvm::createSparcV8CodePrinterPass (std::ostream &o,
TargetMachine &tm) {
- return new V8Printer(o, tm);
+ return new SparcV8AsmPrinter(o, tm);
}
/// toOctal - Convert the low order bits of X into an octal digit.
@@ -131,7 +134,7 @@
// Print out the specified constant, without a storage class. Only the
// constants valid in constant expressions can occur here.
-void V8Printer::emitConstantValueOnly(const Constant *CV) {
+void SparcV8AsmPrinter::emitConstantValueOnly(const Constant *CV) {
if (CV->isNullValue() || isa<UndefValue> (CV))
O << "0";
else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
@@ -204,7 +207,7 @@
// Print a constant value or values, with the appropriate storage class as a
// prefix.
-void V8Printer::emitGlobalConstant(const Constant *CV) {
+void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) {
const TargetData &TD = TM.getTargetData();
if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
@@ -299,7 +302,7 @@
/// used to print out constants which have been "spilled to memory" by
/// the code generator.
///
-void V8Printer::printConstantPool(MachineConstantPool *MCP) {
+void SparcV8AsmPrinter::printConstantPool(MachineConstantPool *MCP) {
const std::vector<Constant*> &CP = MCP->getConstants();
const TargetData &TD = TM.getTargetData();
@@ -318,7 +321,7 @@
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
///
-bool V8Printer::runOnMachineFunction(MachineFunction &MF) {
+bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// 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;
@@ -355,7 +358,6 @@
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- O << "\t";
printMachineInstruction(II);
}
}
@@ -364,7 +366,7 @@
return false;
}
-void V8Printer::printOperand(const MachineInstr *MI, int opNum) {
+void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
const MachineOperand &MO = MI->getOperand (opNum);
const MRegisterInfo &RI = *TM.getRegisterInfo();
bool CloseParen = false;
@@ -472,7 +474,7 @@
/// brackets is true, or may be in the form base - constant, if offset is a
/// negative constant).
///
-void V8Printer::printBaseOffsetPair (const MachineInstr *MI, int i,
+void SparcV8AsmPrinter::printBaseOffsetPair (const MachineInstr *MI, int i,
bool brackets) {
if (brackets) O << "[";
printOperand (MI, i);
@@ -492,7 +494,10 @@
/// printMachineInstruction -- Print out a single SparcV8 LLVM instruction
/// MI in GAS syntax to the current output stream.
///
-void V8Printer::printMachineInstruction(const MachineInstr *MI) {
+void SparcV8AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
+ if (printInstruction(MI)) return;
+ O << "\t";
+
unsigned Opcode = MI->getOpcode();
const TargetInstrInfo &TII = *TM.getInstrInfo();
const TargetInstrDescriptor &Desc = TII.get(Opcode);
@@ -549,7 +554,7 @@
O << "\n";
}
-bool V8Printer::doInitialization(Module &M) {
+bool SparcV8AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M);
return false; // success
}
@@ -566,7 +571,7 @@
}
}
-bool V8Printer::doFinalization(Module &M) {
+bool SparcV8AsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
std::string CurSection;