summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Target/ARM/ARMTargetMachine.cpp24
-rw-r--r--lib/Target/ARM/ARMTargetMachine.h20
-rw-r--r--lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (renamed from lib/Target/ARM/ARMAsmPrinter.cpp)28
-rw-r--r--lib/Target/ARM/AsmPrinter/Makefile15
-rw-r--r--lib/Target/ARM/Makefile4
5 files changed, 71 insertions, 20 deletions
diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
index 468507427c..5b7018f56e 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 79aa45d8de..a485897bfc 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 89b0a8a77e..2ab8b63591 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 0000000000..a896681594
--- /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 50313a9ac2..febc333d60 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