fix a circular dependency between the mips code generator

and its asmprinter.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73573 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-06-16 22:38:04 +00:00
parent 86ecd50143
commit e8f1018130
3 changed files with 28 additions and 4 deletions

View File

@ -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 {

View File

@ -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;
}

View File

@ -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