# Make sure that tblgen is run, first thing.
BUILT_SOURCES = SparcV8GenRegisterInfo.h.inc SparcV8GenRegisterNames.inc \
SparcV8GenRegisterInfo.inc SparcV8GenInstrNames.inc \
- SparcV8GenInstrInfo.inc
+ SparcV8GenInstrInfo.inc SparcV8GenAsmWriter.inc
include $(LEVEL)/Makefile.common
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;
///
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
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
///
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.
// 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)) {
// 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)) {
/// 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();
/// 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;
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- O << "\t";
printMachineInstruction(II);
}
}
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;
/// 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);
/// 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);
O << "\n";
}
-bool V8Printer::doInitialization(Module &M) {
+bool SparcV8AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M);
return false; // success
}
}
}
-bool V8Printer::doFinalization(Module &M) {
+bool SparcV8AsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
std::string CurSection;
# Make sure that tblgen is run, first thing.
BUILT_SOURCES = SparcV8GenRegisterInfo.h.inc SparcV8GenRegisterNames.inc \
SparcV8GenRegisterInfo.inc SparcV8GenInstrNames.inc \
- SparcV8GenInstrInfo.inc
+ SparcV8GenInstrInfo.inc SparcV8GenAsmWriter.inc
include $(LEVEL)/Makefile.common
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;
///
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
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
///
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.
// 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)) {
// 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)) {
/// 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();
/// 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;
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
- O << "\t";
printMachineInstruction(II);
}
}
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;
/// 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);
/// 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);
O << "\n";
}
-bool V8Printer::doInitialization(Module &M) {
+bool SparcV8AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M);
return false; // success
}
}
}
-bool V8Printer::doFinalization(Module &M) {
+bool SparcV8AsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
std::string CurSection;