[llvm-commits] [llvm] r73573 - in /llvm/trunk/lib/Target/Mips: AsmPrinter/MipsAsmPrinter.cpp MipsTargetMachine.cpp MipsTargetMachine.h
Chris Lattner
sabre at nondot.org
Tue Jun 16 15:38:04 PDT 2009
Author: lattner
Date: Tue Jun 16 17:38:04 2009
New Revision: 73573
URL: http://llvm.org/viewvc/llvm-project?rev=73573&view=rev
Log:
fix a circular dependency between the mips code generator
and its asmprinter.
Modified:
llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
llvm/trunk/lib/Target/Mips/MipsTargetMachine.h
Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=73573&r1=73572&r2=73573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Tue Jun 16 17:38:04 2009
@@ -579,6 +579,14 @@
return AsmPrinter::doFinalization(M);
}
+namespace {
+ static struct Register {
+ Register() {
+ MipsTargetMachine::registerAsmPrinter(createMipsCodePrinterPass);
+ }
+ } Registrator;
+}
+
// Force static initialization when called from
// llvm/InitializeAllAsmPrinters.h
namespace llvm {
Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=73573&r1=73572&r2=73573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Tue Jun 16 17:38:04 2009
@@ -31,6 +31,9 @@
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 @@
// 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;
}
Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.h?rev=73573&r1=73572&r2=73573&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetMachine.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Tue Jun 16 17:38:04 2009
@@ -33,10 +33,23 @@
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
More information about the llvm-commits
mailing list