summaryrefslogtreecommitdiffstats
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
commit28dc9d0ad98fbeeac19bba1aca6a2267036454d8 (patch)
tree80c6417803f49a1450df0fd65564b9acd0c4d428
parentc5faeb82b5a969ac708ebcfa126ac346ff0ab3d8 (diff)
downloadbcm5719-llvm-28dc9d0ad98fbeeac19bba1aca6a2267036454d8.tar.gz
bcm5719-llvm-28dc9d0ad98fbeeac19bba1aca6a2267036454d8.zip
Factor out asmprinter out of ppc
llvm-svn: 54887
-rw-r--r--llvm/lib/Target/PowerPC/AsmPrinter/Makefile15
-rw-r--r--llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (renamed from llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp)8
-rw-r--r--llvm/lib/Target/PowerPC/Makefile4
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.cpp24
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.h14
5 files changed, 57 insertions, 8 deletions
diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/Makefile b/llvm/lib/Target/PowerPC/AsmPrinter/Makefile
new file mode 100644
index 00000000000..640bf02acce
--- /dev/null
+++ b/llvm/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/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 1c545903b5e..c5ed305a8d5 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/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/llvm/lib/Target/PowerPC/Makefile b/llvm/lib/Target/PowerPC/Makefile
index 6cf3fa32d21..2ec959c14b6 100644
--- a/llvm/lib/Target/PowerPC/Makefile
+++ b/llvm/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/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index 7c90eca3c44..7857848674f 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/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/llvm/lib/Target/PowerPC/PPCTargetMachine.h b/llvm/lib/Target/PowerPC/PPCTargetMachine.h
index ac2c2aa723e..58fd55d5529 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.h
+++ b/llvm/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);
OpenPOWER on IntegriCloud