mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-27 15:29:51 +00:00
Switch MSP430, SPU, Sparc, and SystemZ to use EmitFunctionBody().
Diffstat: 6 files changed, 30 insertions(+), 284 deletions(-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94727 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ca752c9020
commit
745ec06ad2
@ -19,12 +19,8 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/DwarfWriter.h"
|
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
@ -33,20 +29,12 @@
|
|||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
|
||||||
#include "llvm/Support/Debug.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|
||||||
|
|
||||||
const std::string bss_section(".bss");
|
|
||||||
|
|
||||||
class SPUAsmPrinter : public AsmPrinter {
|
class SPUAsmPrinter : public AsmPrinter {
|
||||||
public:
|
public:
|
||||||
explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
||||||
@ -67,7 +55,9 @@ namespace {
|
|||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
|
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr *MI);
|
void EmitInstruction(const MachineInstr *MI) {
|
||||||
|
printInstruction(MI);
|
||||||
|
}
|
||||||
void printOp(const MachineOperand &MO);
|
void printOp(const MachineOperand &MO);
|
||||||
|
|
||||||
/// printRegister - Print register according to target requirements.
|
/// printRegister - Print register according to target requirements.
|
||||||
@ -276,8 +266,6 @@ namespace {
|
|||||||
llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm");
|
llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool runOnMachineFunction(MachineFunction &F) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// LinuxAsmPrinter - SPU assembly printer, customized for Linux
|
/// LinuxAsmPrinter - SPU assembly printer, customized for Linux
|
||||||
@ -290,15 +278,6 @@ namespace {
|
|||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
return "STI CBEA SPU Assembly Printer";
|
return "STI CBEA SPU Assembly Printer";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
||||||
AU.setPreservesAll();
|
|
||||||
AU.addRequired<MachineModuleInfo>();
|
|
||||||
AU.addRequired<DwarfWriter>();
|
|
||||||
SPUAsmPrinter::getAnalysisUsage(AU);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
@ -386,54 +365,6 @@ bool SPUAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax
|
|
||||||
/// to the current output stream.
|
|
||||||
///
|
|
||||||
void SPUAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|
||||||
++EmittedInsts;
|
|
||||||
processDebugLoc(MI, true);
|
|
||||||
printInstruction(MI);
|
|
||||||
if (VerboseAsm)
|
|
||||||
EmitComments(*MI);
|
|
||||||
processDebugLoc(MI, false);
|
|
||||||
O << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
|
||||||
/// method to print assembly for each instruction.
|
|
||||||
///
|
|
||||||
bool LinuxAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|
||||||
SetupMachineFunction(MF);
|
|
||||||
O << "\n\n";
|
|
||||||
|
|
||||||
EmitFunctionHeader();
|
|
||||||
|
|
||||||
// Print out code for the function.
|
|
||||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
||||||
I != E; ++I) {
|
|
||||||
// Print a label for the basic block.
|
|
||||||
if (I != MF.begin()) {
|
|
||||||
EmitBasicBlockStart(I);
|
|
||||||
}
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
|
||||||
II != E; ++II) {
|
|
||||||
// Print the assembly for the instruction.
|
|
||||||
printMachineInstruction(II);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
O << "\t.size\t" << *CurrentFnSym << ",.-" << *CurrentFnSym << "\n";
|
|
||||||
|
|
||||||
// Print out jump tables referenced by the function.
|
|
||||||
EmitJumpTableInfo();
|
|
||||||
|
|
||||||
// Emit post-function debug information.
|
|
||||||
DW->EndFunction(&MF);
|
|
||||||
|
|
||||||
// We didn't modify anything.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force static initialization.
|
// Force static initialization.
|
||||||
extern "C" void LLVMInitializeCellSPUAsmPrinter() {
|
extern "C" void LLVMInitializeCellSPUAsmPrinter() {
|
||||||
RegisterAsmPrinter<LinuxAsmPrinter> X(TheCellSPUTarget);
|
RegisterAsmPrinter<LinuxAsmPrinter> X(TheCellSPUTarget);
|
||||||
|
@ -35,18 +35,9 @@
|
|||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/Support/CommandLine.h"
|
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|
||||||
|
|
||||||
static cl::opt<bool>
|
|
||||||
EnableMCInst("enable-msp430-mcinst-printer", cl::Hidden,
|
|
||||||
cl::desc("enable experimental mcinst gunk in the msp430 backend"));
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class MSP430AsmPrinter : public AsmPrinter {
|
class MSP430AsmPrinter : public AsmPrinter {
|
||||||
public:
|
public:
|
||||||
@ -76,9 +67,7 @@ namespace {
|
|||||||
bool PrintAsmMemoryOperand(const MachineInstr *MI,
|
bool PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||||
unsigned OpNo, unsigned AsmVariant,
|
unsigned OpNo, unsigned AsmVariant,
|
||||||
const char *ExtraCode);
|
const char *ExtraCode);
|
||||||
void printInstructionThroughMCStreamer(const MachineInstr *MI);
|
void EmitInstruction(const MachineInstr *MI);
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AsmPrinter::getAnalysisUsage(AU);
|
AsmPrinter::getAnalysisUsage(AU);
|
||||||
@ -88,52 +77,11 @@ namespace {
|
|||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|
||||||
SetupMachineFunction(MF);
|
|
||||||
O << "\n\n";
|
|
||||||
|
|
||||||
EmitFunctionHeader();
|
|
||||||
|
|
||||||
// Print out code for the function.
|
|
||||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
||||||
I != E; ++I) {
|
|
||||||
// Print a label for the basic block.
|
|
||||||
EmitBasicBlockStart(I);
|
|
||||||
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
|
||||||
II != E; ++II)
|
|
||||||
// Print the assembly for the instruction.
|
|
||||||
printMachineInstruction(II);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MAI->hasDotTypeDotSizeDirective())
|
|
||||||
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
|
||||||
|
|
||||||
// Print out constants referenced by the function
|
|
||||||
EmitJumpTableInfo();
|
|
||||||
|
|
||||||
// We didn't modify anything
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|
||||||
++EmittedInsts;
|
|
||||||
|
|
||||||
processDebugLoc(MI, true);
|
|
||||||
|
|
||||||
printInstructionThroughMCStreamer(MI);
|
|
||||||
|
|
||||||
if (VerboseAsm)
|
|
||||||
EmitComments(*MI);
|
|
||||||
O << '\n';
|
|
||||||
|
|
||||||
processDebugLoc(MI, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
const char* Modifier) {
|
const char* Modifier) {
|
||||||
const MachineOperand &MO = MI->getOperand(OpNum);
|
const MachineOperand &MO = MI->getOperand(OpNum);
|
||||||
switch (MO.getType()) {
|
switch (MO.getType()) {
|
||||||
|
default: assert(0 && "Not implemented yet!");
|
||||||
case MachineOperand::MO_Register:
|
case MachineOperand::MO_Register:
|
||||||
O << MSP430InstPrinter::getRegisterName(MO.getReg());
|
O << MSP430InstPrinter::getRegisterName(MO.getReg());
|
||||||
return;
|
return;
|
||||||
@ -166,8 +114,6 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||||||
O << MAI->getGlobalPrefix() << MO.getSymbolName();
|
O << MAI->getGlobalPrefix() << MO.getSymbolName();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
llvm_unreachable("Not implemented yet!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,30 +142,14 @@ void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int OpNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MSP430AsmPrinter::printCCOperand(const MachineInstr *MI, int OpNum) {
|
void MSP430AsmPrinter::printCCOperand(const MachineInstr *MI, int OpNum) {
|
||||||
unsigned CC = MI->getOperand(OpNum).getImm();
|
switch (MI->getOperand(OpNum).getImm()) {
|
||||||
|
default: assert(0 && "Unknown cond");
|
||||||
switch (CC) {
|
case MSP430CC::COND_E: O << "eq"; break;
|
||||||
default:
|
case MSP430CC::COND_NE: O << "ne"; break;
|
||||||
llvm_unreachable("Unsupported CC code");
|
case MSP430CC::COND_HS: O << "hs"; break;
|
||||||
break;
|
case MSP430CC::COND_LO: O << "lo"; break;
|
||||||
case MSP430CC::COND_E:
|
case MSP430CC::COND_GE: O << "ge"; break;
|
||||||
O << "eq";
|
case MSP430CC::COND_L: O << 'l'; break;
|
||||||
break;
|
|
||||||
case MSP430CC::COND_NE:
|
|
||||||
O << "ne";
|
|
||||||
break;
|
|
||||||
case MSP430CC::COND_HS:
|
|
||||||
O << "hs";
|
|
||||||
break;
|
|
||||||
case MSP430CC::COND_LO:
|
|
||||||
O << "lo";
|
|
||||||
break;
|
|
||||||
case MSP430CC::COND_GE:
|
|
||||||
O << "ge";
|
|
||||||
break;
|
|
||||||
case MSP430CC::COND_L:
|
|
||||||
O << 'l';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +177,7 @@ bool MSP430AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
void MSP430AsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI){
|
void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
|
|
||||||
MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
|
MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
|
||||||
|
|
||||||
switch (MI->getOpcode()) {
|
switch (MI->getOpcode()) {
|
||||||
|
@ -74,7 +74,6 @@ namespace {
|
|||||||
void printHex32(unsigned int Value);
|
void printHex32(unsigned int Value);
|
||||||
|
|
||||||
const char *emitCurrentABIString();
|
const char *emitCurrentABIString();
|
||||||
void emitFunctionEnd(MachineFunction &MF);
|
|
||||||
void emitFrameDirective(MachineFunction &MF);
|
void emitFrameDirective(MachineFunction &MF);
|
||||||
|
|
||||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
@ -207,19 +206,6 @@ const char *MipsAsmPrinter::emitCurrentABIString() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit the directives used by GAS on the end of functions
|
|
||||||
void MipsAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
|
|
||||||
// There are instruction for this macros, but they must
|
|
||||||
// always be at the function end, and we can't emit and
|
|
||||||
// break with BB logic.
|
|
||||||
O << "\t.set\tmacro\n";
|
|
||||||
O << "\t.set\treorder\n";
|
|
||||||
|
|
||||||
O << "\t.end\t" << *CurrentFnSym << '\n';
|
|
||||||
if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
|
|
||||||
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
void MipsAsmPrinter::EmitFunctionEntryLabel() {
|
void MipsAsmPrinter::EmitFunctionEntryLabel() {
|
||||||
O << "\t.ent\t" << *CurrentFnSym << '\n';
|
O << "\t.ent\t" << *CurrentFnSym << '\n';
|
||||||
OutStreamer.EmitLabel(CurrentFnSym);
|
OutStreamer.EmitLabel(CurrentFnSym);
|
||||||
@ -264,8 +250,15 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit function end directives
|
// There are instruction for this macros, but they must
|
||||||
emitFunctionEnd(MF);
|
// always be at the function end, and we can't emit and
|
||||||
|
// break with BB logic.
|
||||||
|
O << "\t.set\tmacro\n";
|
||||||
|
O << "\t.set\treorder\n";
|
||||||
|
|
||||||
|
O << "\t.end\t" << *CurrentFnSym << '\n';
|
||||||
|
if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
|
||||||
|
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
||||||
|
|
||||||
// Print out jump tables referenced by the function
|
// Print out jump tables referenced by the function
|
||||||
EmitJumpTableInfo();
|
EmitJumpTableInfo();
|
||||||
|
@ -16,32 +16,15 @@
|
|||||||
#include "Sparc.h"
|
#include "Sparc.h"
|
||||||
#include "SparcInstrInfo.h"
|
#include "SparcInstrInfo.h"
|
||||||
#include "SparcTargetMachine.h"
|
#include "SparcTargetMachine.h"
|
||||||
#include "llvm/Constants.h"
|
|
||||||
#include "llvm/DerivedTypes.h"
|
|
||||||
#include "llvm/Module.h"
|
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/DwarfWriter.h"
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstring>
|
|
||||||
#include <map>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class SparcAsmPrinter : public AsmPrinter {
|
class SparcAsmPrinter : public AsmPrinter {
|
||||||
public:
|
public:
|
||||||
@ -58,10 +41,12 @@ namespace {
|
|||||||
const char *Modifier = 0);
|
const char *Modifier = 0);
|
||||||
void printCCOperand(const MachineInstr *MI, int opNum);
|
void printCCOperand(const MachineInstr *MI, int opNum);
|
||||||
|
|
||||||
|
virtual void EmitInstruction(const MachineInstr *MI) {
|
||||||
|
printInstruction(MI);
|
||||||
|
}
|
||||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
|
||||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
unsigned AsmVariant, const char *ExtraCode);
|
unsigned AsmVariant, const char *ExtraCode);
|
||||||
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
@ -73,44 +58,6 @@ namespace {
|
|||||||
|
|
||||||
#include "SparcGenAsmWriter.inc"
|
#include "SparcGenAsmWriter.inc"
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printInstruction()
|
|
||||||
/// method to print assembly for each instruction.
|
|
||||||
///
|
|
||||||
bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|
||||||
SetupMachineFunction(MF);
|
|
||||||
|
|
||||||
EmitFunctionHeader();
|
|
||||||
|
|
||||||
// Print out code for the function.
|
|
||||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
||||||
I != E; ++I) {
|
|
||||||
// Print a label for the basic block.
|
|
||||||
if (I != MF.begin())
|
|
||||||
EmitBasicBlockStart(I);
|
|
||||||
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
|
||||||
II != E; ++II) {
|
|
||||||
// Print the assembly for the instruction.
|
|
||||||
processDebugLoc(II, true);
|
|
||||||
printInstruction(II);
|
|
||||||
|
|
||||||
if (VerboseAsm)
|
|
||||||
EmitComments(*II);
|
|
||||||
O << '\n';
|
|
||||||
processDebugLoc(II, false);
|
|
||||||
++EmittedInsts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit post-function debug information.
|
|
||||||
DW->EndFunction(&MF);
|
|
||||||
|
|
||||||
// We didn't modify anything.
|
|
||||||
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||||
const MachineOperand &MO = MI->getOperand (opNum);
|
const MachineOperand &MO = MI->getOperand (opNum);
|
||||||
bool CloseParen = false;
|
bool CloseParen = false;
|
||||||
|
@ -32,13 +32,10 @@
|
|||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class SystemZAsmPrinter : public AsmPrinter {
|
class SystemZAsmPrinter : public AsmPrinter {
|
||||||
public:
|
public:
|
||||||
@ -67,9 +64,7 @@ namespace {
|
|||||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr * MI);
|
void EmitInstruction(const MachineInstr *MI);
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
|
||||||
|
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AsmPrinter::getAnalysisUsage(AU);
|
AsmPrinter::getAnalysisUsage(AU);
|
||||||
@ -80,50 +75,9 @@ namespace {
|
|||||||
|
|
||||||
#include "SystemZGenAsmWriter.inc"
|
#include "SystemZGenAsmWriter.inc"
|
||||||
|
|
||||||
|
void SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
|
|
||||||
bool SystemZAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|
||||||
SetupMachineFunction(MF);
|
|
||||||
O << "\n\n";
|
|
||||||
|
|
||||||
// Print the 'header' of function
|
|
||||||
EmitFunctionHeader();
|
|
||||||
|
|
||||||
// Print out code for the function.
|
|
||||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
||||||
I != E; ++I) {
|
|
||||||
// Print a label for the basic block.
|
|
||||||
EmitBasicBlockStart(I);
|
|
||||||
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
|
||||||
II != E; ++II)
|
|
||||||
// Print the assembly for the instruction.
|
|
||||||
printMachineInstruction(II);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MAI->hasDotTypeDotSizeDirective())
|
|
||||||
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
|
||||||
|
|
||||||
// Print out jump tables referenced by the function.
|
|
||||||
EmitJumpTableInfo();
|
|
||||||
|
|
||||||
// We didn't modify anything
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SystemZAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|
||||||
++EmittedInsts;
|
|
||||||
|
|
||||||
processDebugLoc(MI, true);
|
|
||||||
|
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
printInstruction(MI);
|
printInstruction(MI);
|
||||||
|
|
||||||
if (VerboseAsm)
|
|
||||||
EmitComments(*MI);
|
|
||||||
O << '\n';
|
|
||||||
|
|
||||||
processDebugLoc(MI, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
|
void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
|
||||||
|
@ -74,7 +74,6 @@ namespace {
|
|||||||
virtual void EmitGlobalVariable(const GlobalVariable *GV);
|
virtual void EmitGlobalVariable(const GlobalVariable *GV);
|
||||||
|
|
||||||
void emitFunctionStart(MachineFunction &MF);
|
void emitFunctionStart(MachineFunction &MF);
|
||||||
void emitFunctionEnd(MachineFunction &MF);
|
|
||||||
|
|
||||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||||
static const char *getRegisterName(unsigned RegNo);
|
static const char *getRegisterName(unsigned RegNo);
|
||||||
@ -220,12 +219,6 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
|
|||||||
O << *CurrentFnSym << ":\n";
|
O << *CurrentFnSym << ":\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit the directives on the end of functions
|
|
||||||
void XCoreAsmPrinter::emitFunctionEnd(MachineFunction &MF) {
|
|
||||||
// Mark the end of the function
|
|
||||||
O << "\t.cc_bottom " << *CurrentFnSym << ".function\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||||
/// method to print assembly for each instruction.
|
/// method to print assembly for each instruction.
|
||||||
///
|
///
|
||||||
@ -246,9 +239,8 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
|
|
||||||
// Print a label for the basic block.
|
// Print a label for the basic block.
|
||||||
if (I != MF.begin()) {
|
if (I != MF.begin())
|
||||||
EmitBasicBlockStart(I);
|
EmitBasicBlockStart(I);
|
||||||
}
|
|
||||||
|
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
@ -261,7 +253,7 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Emit function end directives
|
// Emit function end directives
|
||||||
emitFunctionEnd(MF);
|
O << "\t.cc_bottom " << *CurrentFnSym << ".function\n";
|
||||||
|
|
||||||
// Print out jump tables referenced by the function
|
// Print out jump tables referenced by the function
|
||||||
EmitJumpTableInfo();
|
EmitJumpTableInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user