aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp8
-rw-r--r--lib/Target/Mips/MipsTargetMachine.cpp9
-rw-r--r--lib/Target/Mips/MipsTargetMachine.h15
3 files changed, 28 insertions, 4 deletions
diff --git a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
index 201ee05..077ec96 100644
--- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
@@ -579,6 +579,14 @@ doFinalization(Module &M)
return AsmPrinter::doFinalization(M);
}
+namespace {
+ static struct Register {
+ Register() {
+ MipsTargetMachine::registerAsmPrinter(createMipsCodePrinterPass);
+ }
+ } Registrator;
+}
+
// Force static initialization when called from
// llvm/InitializeAllAsmPrinters.h
namespace llvm {
diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp
index 720e9a8..83b9b62 100644
--- a/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/lib/Target/Mips/MipsTargetMachine.cpp
@@ -31,6 +31,9 @@ int MipsTargetMachineModule = 0;
static RegisterTarget<MipsTargetMachine> X("mips", "Mips");
static RegisterTarget<MipselTargetMachine> Y("mipsel", "Mipsel");
+MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0;
+
+
// Force static initialization when called from llvm/InitializeAllTargets.h
namespace llvm {
void InitializeMipsTarget() { }
@@ -130,9 +133,9 @@ addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
// true if AssemblyEmitter is supported
bool MipsTargetMachine::
addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
- bool Verbose, raw_ostream &Out)
-{
+ bool Verbose, raw_ostream &Out) {
// Output assembly language.
- PM.add(createMipsCodePrinterPass(Out, *this, OptLevel, Verbose));
+ assert(AsmPrinterCtor && "AsmPrinter was not linked in");
+ PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose));
return false;
}
diff --git a/lib/Target/Mips/MipsTargetMachine.h b/lib/Target/Mips/MipsTargetMachine.h
index a9e1df2..85fafad 100644
--- a/lib/Target/Mips/MipsTargetMachine.h
+++ b/lib/Target/Mips/MipsTargetMachine.h
@@ -33,10 +33,23 @@ namespace llvm {
protected:
virtual const TargetAsmInfo *createTargetAsmInfo() const;
-
+ protected:
+ // To avoid having target depend on the asmprinter stuff libraries,
+ // asmprinter set this functions to ctor pointer at startup time if they are
+ // linked in.
+ typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
+ MipsTargetMachine &tm,
+ CodeGenOpt::Level OptLevel,
+ bool verbose);
+ static AsmPrinterCtorFn AsmPrinterCtor;
+
public:
MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
+ static void registerAsmPrinter(AsmPrinterCtorFn F) {
+ AsmPrinterCtor = F;
+ }
+
virtual const MipsInstrInfo *getInstrInfo() const
{ return &InstrInfo; }
virtual const TargetFrameInfo *getFrameInfo() const