Register AsmPrinter for XCore, MSP430, and PIC16 targets.

- Switch to standard addAssemblyEmitter logic.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75854 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-07-15 23:17:20 +00:00
parent fea4ec6dff
commit 1e1f8ba28c
10 changed files with 37 additions and 20 deletions

View File

@ -25,7 +25,7 @@ namespace llvm {
FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM,
CodeGenOpt::Level OptLevel);
FunctionPass *createMSP430CodePrinterPass(formatted_raw_ostream &o,
MSP430TargetMachine &tm,
TargetMachine &tm,
bool verbose);
} // end namespace llvm;

View File

@ -40,7 +40,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
namespace {
class VISIBILITY_HIDDEN MSP430AsmPrinter : public AsmPrinter {
public:
MSP430AsmPrinter(formatted_raw_ostream &O, MSP430TargetMachine &TM,
MSP430AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *TAI, bool V)
: AsmPrinter(O, TM, TAI, V) {}
@ -76,7 +76,7 @@ namespace {
/// regardless of whether the function is in SSA form.
///
FunctionPass *llvm::createMSP430CodePrinterPass(formatted_raw_ostream &o,
MSP430TargetMachine &tm,
TargetMachine &tm,
bool verbose) {
return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}

View File

@ -37,7 +37,10 @@ static RegisterTarget<MSP430TargetMachine>
X(TheMSP430Target, "msp430", "MSP430 [experimental]");
// Force static initialization.
extern "C" void LLVMInitializeMSP430Target() { }
extern "C" void LLVMInitializeMSP430Target() {
TargetRegistry::RegisterAsmPrinter(TheMSP430Target,
&createMSP430CodePrinterPass);
}
MSP430TargetMachine::MSP430TargetMachine(const Target &T,
const Module &M,
@ -64,8 +67,10 @@ bool MSP430TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createMSP430CodePrinterPass(Out, *this, Verbose));
FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
if (!Printer)
llvm_report_error("unable to create assembly printer");
PM.add(Printer);
return false;
}

View File

@ -344,7 +344,7 @@ namespace PIC16CC {
FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
FunctionPass *createPIC16CodePrinterPass(formatted_raw_ostream &OS,
PIC16TargetMachine &TM,
TargetMachine &TM,
bool Verbose);
// Banksel optimzer pass.
FunctionPass *createPIC16MemSelOptimizerPass();

View File

@ -113,7 +113,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
/// regardless of whether the function is in SSA form.
///
FunctionPass *llvm::createPIC16CodePrinterPass(formatted_raw_ostream &o,
PIC16TargetMachine &tm,
TargetMachine &tm,
bool verbose) {
return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}

View File

@ -29,10 +29,10 @@
namespace llvm {
struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
explicit PIC16AsmPrinter(formatted_raw_ostream &O, PIC16TargetMachine &TM,
explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DbgInfo(O, T) {
PTLI = TM.getTargetLowering();
PTLI = static_cast<const PIC16TargetLowering *> (TM.getTargetLowering());
PTAI = static_cast<const PIC16TargetAsmInfo *> (T);
}
private :

View File

@ -41,7 +41,12 @@ static RegisterTarget<CooperTargetMachine>
Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
// Force static initialization.
extern "C" void LLVMInitializePIC16Target() { }
extern "C" void LLVMInitializePIC16Target() {
TargetRegistry::RegisterAsmPrinter(ThePIC16Target,
&createPIC16CodePrinterPass);
TargetRegistry::RegisterAsmPrinter(TheCooperTarget,
&createPIC16CodePrinterPass);
}
// PIC16TargetMachine - Traditional PIC16 Machine.
PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M,
@ -74,8 +79,10 @@ bool PIC16TargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createPIC16CodePrinterPass(Out, *this, Verbose));
FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
if (!Printer)
llvm_report_error("unable to create assembly printer");
PM.add(Printer);
return false;
}

View File

@ -25,7 +25,7 @@ namespace llvm {
FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM);
FunctionPass *createXCoreCodePrinterPass(formatted_raw_ostream &OS,
XCoreTargetMachine &TM,
TargetMachine &TM,
bool Verbose);
} // end namespace llvm;

View File

@ -52,10 +52,10 @@ namespace {
DwarfWriter *DW;
const XCoreSubtarget &Subtarget;
public:
explicit XCoreAsmPrinter(formatted_raw_ostream &O, XCoreTargetMachine &TM,
explicit XCoreAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DW(0),
Subtarget(*TM.getSubtargetImpl()) {}
Subtarget(TM.getSubtarget<XCoreSubtarget>()) {}
virtual const char *getPassName() const {
return "XCore Assembly Printer";
@ -98,7 +98,7 @@ namespace {
/// regardless of whether the function is in SSA form.
///
FunctionPass *llvm::createXCoreCodePrinterPass(formatted_raw_ostream &o,
XCoreTargetMachine &tm,
TargetMachine &tm,
bool verbose) {
return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}

View File

@ -33,7 +33,10 @@ namespace {
}
// Force static initialization.
extern "C" void LLVMInitializeXCoreTarget() { }
extern "C" void LLVMInitializeXCoreTarget() {
TargetRegistry::RegisterAsmPrinter(TheXCoreTarget,
&createXCoreCodePrinterPass);
}
const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
return new XCoreTargetAsmInfo(*this);
@ -62,7 +65,9 @@ bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
CodeGenOpt::Level OptLevel,
bool Verbose,
formatted_raw_ostream &Out) {
// Output assembly language.
PM.add(createXCoreCodePrinterPass(Out, *this, Verbose));
FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
if (!Printer)
llvm_report_error("unable to create assembly printer");
PM.add(Printer);
return false;
}