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
diff --git a/lib/Target/MSP430/MSP430.h b/lib/Target/MSP430/MSP430.h
index 0562832..225fc17 100644
--- a/lib/Target/MSP430/MSP430.h
+++ b/lib/Target/MSP430/MSP430.h
@@ -25,7 +25,7 @@
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 68cfe40..2ff5eec 100644
--- a/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp
@@ -40,7 +40,7 @@
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 @@
/// 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 bf259e2..1558d01 100644
--- a/lib/Target/MSP430/MSP430TargetMachine.cpp
+++ b/lib/Target/MSP430/MSP430TargetMachine.cpp
@@ -37,7 +37,10 @@
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 @@
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 0184b90..39a5119 100644
--- a/lib/Target/PIC16/PIC16.h
+++ b/lib/Target/PIC16/PIC16.h
@@ -344,7 +344,7 @@
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 ebfa3cb..ca654a3 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -113,7 +113,7 @@
/// 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 4e854ed..2c8ce12 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<const PIC16TargetLowering *> (TM.getTargetLowering());
PTAI = static_cast<const PIC16TargetAsmInfo *> (T);
}
private :
diff --git a/lib/Target/PIC16/PIC16TargetMachine.cpp b/lib/Target/PIC16/PIC16TargetMachine.cpp
index 45a61fa..72c117f 100644
--- a/lib/Target/PIC16/PIC16TargetMachine.cpp
+++ b/lib/Target/PIC16/PIC16TargetMachine.cpp
@@ -41,7 +41,12 @@
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 @@
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 abc69b7..75aa4fd 100644
--- a/lib/Target/XCore/XCore.h
+++ b/lib/Target/XCore/XCore.h
@@ -25,7 +25,7 @@
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 213039f..218b21d 100644
--- a/lib/Target/XCore/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/XCoreAsmPrinter.cpp
@@ -52,10 +52,10 @@
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 @@
/// 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 7fc8694..857d412 100644
--- a/lib/Target/XCore/XCoreTargetMachine.cpp
+++ b/lib/Target/XCore/XCoreTargetMachine.cpp
@@ -33,7 +33,10 @@
}
// 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 @@
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;
}