diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-08-17 13:55:10 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-08-17 13:55:10 +0000 |
commit | 0bd89712c03c59ea43ce37763685e7f7c0bdd977 (patch) | |
tree | f334686501c2ba9f04ac7ac0336fb31959d05132 /lib/Target | |
parent | 676fa7df9c53f97fd1a9419780573dfb788049b4 (diff) | |
download | external_llvm-0bd89712c03c59ea43ce37763685e7f7c0bdd977.zip external_llvm-0bd89712c03c59ea43ce37763685e7f7c0bdd977.tar.gz external_llvm-0bd89712c03c59ea43ce37763685e7f7c0bdd977.tar.bz2 |
Move ARM to pluggable asmprinter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/ARM/ARMTargetMachine.cpp | 24 | ||||
-rw-r--r-- | lib/Target/ARM/ARMTargetMachine.h | 20 | ||||
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (renamed from lib/Target/ARM/ARMAsmPrinter.cpp) | 28 | ||||
-rw-r--r-- | lib/Target/ARM/AsmPrinter/Makefile | 15 | ||||
-rw-r--r-- | lib/Target/ARM/Makefile | 4 |
5 files changed, 71 insertions, 20 deletions
diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 4685074..5b7018f 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -31,6 +31,9 @@ static cl::opt<bool> DisableIfConversion("disable-arm-if-conversion",cl::Hidden, static RegisterTarget<ARMTargetMachine> X("arm", " ARM"); static RegisterTarget<ThumbTargetMachine> Y("thumb", " Thumb"); +// No assembler printer by default +ARMTargetMachine::AsmPrinterCtorFn ARMTargetMachine::AsmPrinterCtor = 0; + /// ThumbTargetMachine - Create an Thumb architecture model. /// unsigned ThumbTargetMachine::getJITMatchQuality() { @@ -142,7 +145,10 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, std::ostream &Out) { // Output assembly language. - PM.add(createARMCodePrinterPass(Out, *this)); + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(Out, *this)); + return false; } @@ -154,8 +160,12 @@ bool ARMTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast, // Machine code emitter pass for ARM. PM.add(createARMCodeEmitterPass(*this, MCE)); - if (DumpAsm) - PM.add(createARMCodePrinterPass(*cerr.stream(), *this)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(*cerr.stream(), *this)); + } + return false; } @@ -163,7 +173,11 @@ bool ARMTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, bool DumpAsm, MachineCodeEmitter &MCE) { // Machine code emitter pass for ARM. PM.add(createARMCodeEmitterPass(*this, MCE)); - if (DumpAsm) - PM.add(createARMCodePrinterPass(*cerr.stream(), *this)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(*cerr.stream(), *this)); + } + return false; } diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h index 79aa45d..a485897 100644 --- a/lib/Target/ARM/ARMTargetMachine.h +++ b/lib/Target/ARM/ARMTargetMachine.h @@ -35,6 +35,13 @@ class ARMTargetMachine : public LLVMTargetMachine { ARMJITInfo JITInfo; ARMTargetLowering TLInfo; +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)(std::ostream &o, + ARMTargetMachine &tm); + static AsmPrinterCtorFn AsmPrinterCtor; + public: ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false); @@ -46,18 +53,23 @@ public: } virtual const TargetData *getTargetData() const { return &DataLayout; } virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; } - virtual ARMTargetLowering *getTargetLowering() const { - return const_cast<ARMTargetLowering*>(&TLInfo); + virtual ARMTargetLowering *getTargetLowering() const { + return const_cast<ARMTargetLowering*>(&TLInfo); + } + + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; } + static unsigned getModuleMatchQuality(const Module &M); static unsigned getJITMatchQuality(); virtual const TargetAsmInfo *createTargetAsmInfo() const; - + // Pass Pipeline Configuration virtual bool addInstSelector(PassManagerBase &PM, bool Fast); virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast); - virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, + virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, std::ostream &Out); virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast, bool DumpAsm, MachineCodeEmitter &MCE); diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 89b0a8a..2ab8b63 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -174,16 +174,6 @@ namespace { #include "ARMGenAsmWriter.inc" -/// createARMCodePrinterPass - Returns a pass that prints the ARM -/// assembly code for a MachineFunction to the given output stream, -/// using the given target machine description. This should work -/// regardless of whether the function is in SSA form. -/// -FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o, - ARMTargetMachine &tm) { - return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo()); -} - // Substitute old hook with new one temporary std::string ARMAsmPrinter::getSectionForFunction(const Function &F) const { return TAI->SectionForGlobal(&F); @@ -1028,3 +1018,21 @@ bool ARMAsmPrinter::doFinalization(Module &M) { return AsmPrinter::doFinalization(M); } + +/// createARMCodePrinterPass - Returns a pass that prints the ARM +/// assembly code for a MachineFunction to the given output stream, +/// using the given target machine description. This should work +/// regardless of whether the function is in SSA form. +/// +FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o, + ARMTargetMachine &tm) { + return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo()); +} + +namespace { + static struct Register { + Register() { + ARMTargetMachine::registerAsmPrinter(createARMCodePrinterPass); + } + } Registrator; +} diff --git a/lib/Target/ARM/AsmPrinter/Makefile b/lib/Target/ARM/AsmPrinter/Makefile new file mode 100644 index 0000000..a896681 --- /dev/null +++ b/lib/Target/ARM/AsmPrinter/Makefile @@ -0,0 +1,15 @@ +##===- lib/Target/X86/Makefile -----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +LEVEL = ../../../.. +LIBRARYNAME = LLVMARMAsmPrinter + +# Hack: we need to include 'main' x86 target directory to grab private headers +CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/.. + +include $(LEVEL)/Makefile.common diff --git a/lib/Target/ARM/Makefile b/lib/Target/ARM/Makefile index 50313a9..febc333 100644 --- a/lib/Target/ARM/Makefile +++ b/lib/Target/ARM/Makefile @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = ../../.. -LIBRARYNAME = LLVMARM +LIBRARYNAME = LLVMARMCodeGen TARGET = ARM # Make sure that tblgen is run, first thing. @@ -17,4 +17,6 @@ BUILT_SOURCES = ARMGenRegisterInfo.h.inc ARMGenRegisterNames.inc \ ARMGenInstrInfo.inc ARMGenAsmWriter.inc \ ARMGenDAGISel.inc ARMGenSubtarget.inc +DIRS = AsmPrinter + include $(LEVEL)/Makefile.common |