[PATCH] request for approval to commit: llvm-c: Make target initializer functions external functions in lib.
Anders Waldenborg
anders at 0x63.nu
Mon Oct 7 13:29:35 PDT 2013
Updated patch to put the LLVMInitializeAll* in a separate object file (AllTargets) so that it is only pulled in if used when using static libraries. This fixes so that one shouldn't have to link in all targets when not using these functions.
Hi baldrick,
http://llvm-reviews.chandlerc.com/D1714
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1714?vs=4372&id=4714#toc
Files:
include/llvm-c/Target.h
lib/Target/AllTargets.cpp
lib/Target/CMakeLists.txt
Index: include/llvm-c/Target.h
===================================================================
--- include/llvm-c/Target.h
+++ include/llvm-c/Target.h
@@ -71,62 +71,37 @@
void LLVMInitialize##TargetName##Disassembler(void);
#include "llvm/Config/Disassemblers.def"
#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
-
+
/** LLVMInitializeAllTargetInfos - The main program should call this function if
it wants access to all available targets that LLVM is configured to
support. */
-static inline void LLVMInitializeAllTargetInfos(void) {
-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
-#include "llvm/Config/Targets.def"
-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
-}
+void LLVMInitializeAllTargetInfos(void);
/** LLVMInitializeAllTargets - The main program should call this function if it
wants to link in all available targets that LLVM is configured to
support. */
-static inline void LLVMInitializeAllTargets(void) {
-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
-#include "llvm/Config/Targets.def"
-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
-}
+void LLVMInitializeAllTargets(void);
/** LLVMInitializeAllTargetMCs - The main program should call this function if
it wants access to all available target MC that LLVM is configured to
support. */
-static inline void LLVMInitializeAllTargetMCs(void) {
-#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
-#include "llvm/Config/Targets.def"
-#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
-}
-
+void LLVMInitializeAllTargetMCs(void);
+
/** LLVMInitializeAllAsmPrinters - The main program should call this function if
it wants all asm printers that LLVM is configured to support, to make them
available via the TargetRegistry. */
-static inline void LLVMInitializeAllAsmPrinters(void) {
-#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
-#include "llvm/Config/AsmPrinters.def"
-#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
-}
-
+void LLVMInitializeAllAsmPrinters(void);
+
/** LLVMInitializeAllAsmParsers - The main program should call this function if
it wants all asm parsers that LLVM is configured to support, to make them
available via the TargetRegistry. */
-static inline void LLVMInitializeAllAsmParsers(void) {
-#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
-#include "llvm/Config/AsmParsers.def"
-#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
-}
-
+void LLVMInitializeAllAsmParsers(void);
+
/** LLVMInitializeAllDisassemblers - The main program should call this function
if it wants all disassemblers that LLVM is configured to support, to make
them available via the TargetRegistry. */
-static inline void LLVMInitializeAllDisassemblers(void) {
-#define LLVM_DISASSEMBLER(TargetName) \
- LLVMInitialize##TargetName##Disassembler();
-#include "llvm/Config/Disassemblers.def"
-#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
-}
-
+void LLVMInitializeAllDisassemblers(void);
+
/** LLVMInitializeNativeTarget - The main program should call this function to
initialize the native target corresponding to the host. This is useful
for JIT applications to ensure that the target gets linked in correctly. */
Index: lib/Target/AllTargets.cpp
===================================================================
--- /dev/null
+++ lib/Target/AllTargets.cpp
@@ -0,0 +1,44 @@
+//===-- AllTargets.cpp ----------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements functions for initialization of different
+// aspects of all configured targets. When calling any of these
+// functions all configured targets must be linked in.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-c/Target.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/TargetSelect.h"
+
+using namespace llvm;
+
+void LLVMInitializeAllTargetInfos(void) {
+ InitializeAllTargetInfos();
+}
+
+void LLVMInitializeAllTargets(void) {
+ InitializeAllTargets();
+}
+
+void LLVMInitializeAllTargetMCs(void) {
+ InitializeAllTargetMCs();
+}
+
+void LLVMInitializeAllAsmPrinters(void) {
+ InitializeAllAsmPrinters();
+}
+
+void LLVMInitializeAllAsmParsers(void) {
+ InitializeAllAsmParsers();
+}
+
+void LLVMInitializeAllDisassemblers(void) {
+ InitializeAllDisassemblers();
+}
Index: lib/Target/CMakeLists.txt
===================================================================
--- lib/Target/CMakeLists.txt
+++ lib/Target/CMakeLists.txt
@@ -1,4 +1,5 @@
add_llvm_library(LLVMTarget
+ AllTargets.cpp
Mangler.cpp
Target.cpp
TargetIntrinsicInfo.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1714.2.patch
Type: text/x-patch
Size: 5096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131007/c96a652a/attachment.bin>
More information about the llvm-commits
mailing list