[llvm-commits] CVS: llvm/lib/Target/SparcV8/Makefile SparcV8AsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Dec 15 22:34:28 PST 2005
Changes in directory llvm/lib/Target/SparcV8:
Makefile updated: 1.10 -> 1.11
SparcV8AsmPrinter.cpp updated: 1.35 -> 1.36
---
Log message:
Plug in basic hooks for an autogenerated asm printer to fill in.
---
Diffs of the changes: (+19 -14)
Makefile | 2 +-
SparcV8AsmPrinter.cpp | 31 ++++++++++++++++++-------------
2 files changed, 19 insertions(+), 14 deletions(-)
Index: llvm/lib/Target/SparcV8/Makefile
diff -u llvm/lib/Target/SparcV8/Makefile:1.10 llvm/lib/Target/SparcV8/Makefile:1.11
--- llvm/lib/Target/SparcV8/Makefile:1.10 Fri Dec 16 00:06:07 2005
+++ llvm/lib/Target/SparcV8/Makefile Fri Dec 16 00:34:17 2005
@@ -13,7 +13,7 @@
# 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
Index: llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.35 llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.36
--- llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp:1.35 Wed Aug 17 15:04:34 2005
+++ llvm/lib/Target/SparcV8/SparcV8AsmPrinter.cpp Fri Dec 16 00:34:17 2005
@@ -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;
More information about the llvm-commits
mailing list