From 1e1f8ba28cc05212dfd347be219daa698d7294a5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 15 Jul 2009 23:17:20 +0000 Subject: [PATCH] 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 --- lib/Target/MSP430/MSP430.h | 2 +- lib/Target/MSP430/MSP430AsmPrinter.cpp | 4 ++-- lib/Target/MSP430/MSP430TargetMachine.cpp | 11 ++++++++--- lib/Target/PIC16/PIC16.h | 2 +- lib/Target/PIC16/PIC16AsmPrinter.cpp | 2 +- lib/Target/PIC16/PIC16AsmPrinter.h | 4 ++-- lib/Target/PIC16/PIC16TargetMachine.cpp | 13 ++++++++++--- lib/Target/XCore/XCore.h | 2 +- lib/Target/XCore/XCoreAsmPrinter.cpp | 6 +++--- lib/Target/XCore/XCoreTargetMachine.cpp | 11 ++++++++--- 10 files changed, 37 insertions(+), 20 deletions(-) diff --git a/lib/Target/MSP430/MSP430.h b/lib/Target/MSP430/MSP430.h index 05628326a9e..225fc17eaa1 100644 --- a/lib/Target/MSP430/MSP430.h +++ b/lib/Target/MSP430/MSP430.h @@ -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; diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index 68cfe4072b0..2ff5eecbfd7 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -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); } diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp index bf259e2add5..1558d01e2cd 100644 --- a/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -37,7 +37,10 @@ static RegisterTarget 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; } diff --git a/lib/Target/PIC16/PIC16.h b/lib/Target/PIC16/PIC16.h index 0184b90f872..39a5119aa8d 100644 --- a/lib/Target/PIC16/PIC16.h +++ b/lib/Target/PIC16/PIC16.h @@ -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(); diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp index ebfa3cbc4ae..ca654a32fb1 100644 --- a/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -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); } diff --git a/lib/Target/PIC16/PIC16AsmPrinter.h b/lib/Target/PIC16/PIC16AsmPrinter.h index 4e854ed415b..2c8ce1219ea 100644 --- a/lib/Target/PIC16/PIC16AsmPrinter.h +++ b/lib/Target/PIC16/PIC16AsmPrinter.h @@ -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 (TM.getTargetLowering()); PTAI = static_cast (T); } private : diff --git a/lib/Target/PIC16/PIC16TargetMachine.cpp b/lib/Target/PIC16/PIC16TargetMachine.cpp index 45a61fa29be..72c117f759b 100644 --- a/lib/Target/PIC16/PIC16TargetMachine.cpp +++ b/lib/Target/PIC16/PIC16TargetMachine.cpp @@ -41,7 +41,12 @@ static RegisterTarget 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; } diff --git a/lib/Target/XCore/XCore.h b/lib/Target/XCore/XCore.h index abc69b7fa9a..75aa4fd9719 100644 --- a/lib/Target/XCore/XCore.h +++ b/lib/Target/XCore/XCore.h @@ -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; diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp index 213039f58b6..218b21d0939 100644 --- a/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -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()) {} 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); } diff --git a/lib/Target/XCore/XCoreTargetMachine.cpp b/lib/Target/XCore/XCoreTargetMachine.cpp index 7fc869495a9..857d412593a 100644 --- a/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/lib/Target/XCore/XCoreTargetMachine.cpp @@ -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; } -- 2.34.1