summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-08-17 13:54:28 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-08-17 13:54:28 +0000
commit06be997654120c92f99850bf1a1704a2042ef639 (patch)
tree1101fde06edb3351a7b9c66bce5419d762162b99 /lib/Target
parent3c3bc48d331db26aaff3ff4f7a61f60a17fea112 (diff)
downloadllvm-06be997654120c92f99850bf1a1704a2042ef639.tar.gz
llvm-06be997654120c92f99850bf1a1704a2042ef639.tar.bz2
llvm-06be997654120c92f99850bf1a1704a2042ef639.tar.xz
Factor out asmprinter out of ppc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/PowerPC/AsmPrinter/Makefile15
-rw-r--r--lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (renamed from lib/Target/PowerPC/PPCAsmPrinter.cpp)8
-rw-r--r--lib/Target/PowerPC/Makefile4
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.cpp24
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.h14
5 files changed, 57 insertions, 8 deletions
diff --git a/lib/Target/PowerPC/AsmPrinter/Makefile b/lib/Target/PowerPC/AsmPrinter/Makefile
new file mode 100644
index 0000000000..640bf02acc
--- /dev/null
+++ b/lib/Target/PowerPC/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 = LLVMPowerPCAsmPrinter
+
+# 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/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 1c545903b5..c5ed305a8d 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -1117,3 +1117,11 @@ FunctionPass *llvm::createPPCAsmPrinterPass(std::ostream &o,
return new PPCLinuxAsmPrinter(o, tm, tm.getTargetAsmInfo());
}
}
+
+namespace {
+ static struct Register {
+ Register() {
+ PPCTargetMachine::registerAsmPrinter(createPPCAsmPrinterPass);
+ }
+ } Registrator;
+}
diff --git a/lib/Target/PowerPC/Makefile b/lib/Target/PowerPC/Makefile
index 6cf3fa32d2..2ec959c14b 100644
--- a/lib/Target/PowerPC/Makefile
+++ b/lib/Target/PowerPC/Makefile
@@ -7,7 +7,7 @@
#
##===----------------------------------------------------------------------===##
LEVEL = ../../..
-LIBRARYNAME = LLVMPowerPC
+LIBRARYNAME = LLVMPowerPCCodegen
TARGET = PPC
# Make sure that tblgen is run, first thing.
@@ -17,4 +17,6 @@ BUILT_SOURCES = PPCGenInstrNames.inc PPCGenRegisterNames.inc \
PPCGenInstrInfo.inc PPCGenDAGISel.inc \
PPCGenSubtarget.inc PPCGenCallingConv.inc
+DIRS = AsmPrinter
+
include $(LEVEL)/Makefile.common
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index 7c90eca3c4..7857848674 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -26,6 +26,9 @@ X("ppc32", " PowerPC 32");
static RegisterTarget<PPC64TargetMachine>
Y("ppc64", " PowerPC 64");
+// No assembler printer by default
+PPCTargetMachine::AsmPrinterCtorFn PPCTargetMachine::AsmPrinterCtor = 0;
+
const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
if (Subtarget.isDarwin())
return new PPCDarwinTargetAsmInfo(*this);
@@ -132,7 +135,10 @@ bool PPCTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) {
bool PPCTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
std::ostream &Out) {
- PM.add(createPPCAsmPrinterPass(Out, *this));
+ assert(AsmPrinterCtor && "AsmPrinter was not linked in");
+ if (AsmPrinterCtor)
+ PM.add(AsmPrinterCtor(Out, *this));
+
return false;
}
@@ -158,8 +164,12 @@ bool PPCTargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
// Machine code emitter pass for PowerPC.
PM.add(createPPCCodeEmitterPass(*this, MCE));
- if (DumpAsm)
- PM.add(createPPCAsmPrinterPass(*cerr.stream(), *this));
+ if (DumpAsm) {
+ assert(AsmPrinterCtor && "AsmPrinter was not linked in");
+ if (AsmPrinterCtor)
+ PM.add(AsmPrinterCtor(*cerr.stream(), *this));
+ }
+
return false;
}
@@ -167,7 +177,11 @@ bool PPCTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
bool DumpAsm, MachineCodeEmitter &MCE) {
// Machine code emitter pass for PowerPC.
PM.add(createPPCCodeEmitterPass(*this, MCE));
- if (DumpAsm)
- PM.add(createPPCAsmPrinterPass(*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/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h
index ac2c2aa723..58fd55d552 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.h
+++ b/lib/Target/PowerPC/PPCTargetMachine.h
@@ -41,7 +41,13 @@ class PPCTargetMachine : public LLVMTargetMachine {
protected:
virtual const TargetAsmInfo *createTargetAsmInfo() const;
-
+
+ // 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,
+ PPCTargetMachine &tm);
+ static AsmPrinterCtorFn AsmPrinterCtor;
+
public:
PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
@@ -63,7 +69,11 @@ public:
virtual const PPCMachOWriterInfo *getMachOWriterInfo() const {
return &MachOWriterInfo;
}
-
+
+ static void registerAsmPrinter(AsmPrinterCtorFn F) {
+ AsmPrinterCtor = F;
+ }
+
// Pass Pipeline Configuration
virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);