Add AllTargetsBindings sublibrary instead of having static inlines in the llvm-c...
authorAnders Waldenborg <anders@0x63.nu>
Tue, 15 Oct 2013 12:08:59 +0000 (12:08 +0000)
committerAnders Waldenborg <anders@0x63.nu>
Tue, 15 Oct 2013 12:08:59 +0000 (12:08 +0000)
This new library will be linked in when using the "all-targets"
component and contains the LLVMInitializeAll* functions.

This means that those functions will exist as real symbols in
the shared library, and can therefore can be called from
bindings that are using ffi the shared library.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192690 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Target.h
lib/Target/AllTargetsBindings/AllTargetsBindings.cpp [new file with mode: 0644]
lib/Target/AllTargetsBindings/CMakeLists.txt [new file with mode: 0644]
lib/Target/AllTargetsBindings/LLVMBuild.txt [new file with mode: 0644]
lib/Target/AllTargetsBindings/Makefile [new file with mode: 0644]
lib/Target/CMakeLists.txt
lib/Target/LLVMBuild.txt
lib/Target/Makefile

index 80fc3e5ad72c07b1d3d65a072f04a26340a53ab4..1d7884f14247d7821c5534f6a7f92e7346b6f25f 100644 (file)
@@ -71,62 +71,37 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef;
   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. */
diff --git a/lib/Target/AllTargetsBindings/AllTargetsBindings.cpp b/lib/Target/AllTargetsBindings/AllTargetsBindings.cpp
new file mode 100644 (file)
index 0000000..5f1a9c9
--- /dev/null
@@ -0,0 +1,42 @@
+//===-- AllTargetsBindings.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 the llvm-c functions for initialization of
+// different aspects of all configured targets.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-c/Target.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();
+}
diff --git a/lib/Target/AllTargetsBindings/CMakeLists.txt b/lib/Target/AllTargetsBindings/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4b4dc77
--- /dev/null
@@ -0,0 +1,3 @@
+add_llvm_library(LLVMAllTargetsBindings
+  AllTargetsBindings.cpp
+  )
diff --git a/lib/Target/AllTargetsBindings/LLVMBuild.txt b/lib/Target/AllTargetsBindings/LLVMBuild.txt
new file mode 100644 (file)
index 0000000..ecf8aca
--- /dev/null
@@ -0,0 +1,32 @@
+;===- ./lib/Target/LLVMBuild.txt -------------------------------*- Conf -*--===;
+;
+;                     The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+; This is a special group whose required libraries are extended (by llvm-build)
+; with every built target, which makes it easy for tools to include every
+; target.
+[component_0]
+type = LibraryGroup
+name = all-targets
+parent = Libraries
+
+; This is the actual library built in this directory.
+; It just contains the llvm-c bindings LLVMInitializeAllTarget* functions
+[component_1]
+type = Library
+name = AllTargetsBindings
+parent = Libraries
+add_to_library_groups = all-targets
diff --git a/lib/Target/AllTargetsBindings/Makefile b/lib/Target/AllTargetsBindings/Makefile
new file mode 100644 (file)
index 0000000..47a6883
--- /dev/null
@@ -0,0 +1,14 @@
+#===- lib/Target/AllTargetsBindings/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 = LLVMAllTargetsBindings
+BUILD_ARCHIVE = 1
+
+include $(LEVEL)/Makefile.common
index 02ac493b42150ad380b6fbaf524a757792d18d2e..861c999c6bb02505502ba5eed65769d569049083 100644 (file)
@@ -14,3 +14,5 @@ foreach(t ${LLVM_TARGETS_TO_BUILD})
   message(STATUS "Targeting ${t}")
   add_subdirectory(${t})
 endforeach()
+
+add_subdirectory("AllTargetsBindings")
index 98d26bcac8afd6ee5a435923463d8bcabbd0fe19..10dc3dc68582f919b2a617b6d2a3b31c9eca74e0 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [common]
-subdirectories = AArch64 ARM CppBackend Hexagon MSP430 NVPTX Mips PowerPC R600 Sparc SystemZ X86 XCore
+subdirectories = AArch64 ARM CppBackend Hexagon MSP430 NVPTX Mips PowerPC R600 Sparc SystemZ X86 XCore AllTargetsBindings
 
 ; This is a special group whose required libraries are extended (by llvm-build)
 ; with the best execution engine (the native JIT, if available, or the
@@ -47,10 +47,3 @@ name = Target
 parent = Libraries
 required_libraries = Core MC Support
 
-; This is a special group whose required libraries are extended (by llvm-build)
-; with every built target, which makes it easy for tools to include every
-; target.
-[component_4]
-type = LibraryGroup
-name = all-targets
-parent = Libraries
index 50a360f1f868f520bdafad0ccad739568dfdb67f..cfa2edb4afeeb2b4b1230fd3e6cd721211e129c4 100644 (file)
@@ -15,6 +15,6 @@ BUILD_ARCHIVE = 1
 # value for PARALLEL_DIRS which must be set before Makefile.rules is included
 include $(LEVEL)/Makefile.config
 
-PARALLEL_DIRS := $(TARGETS_TO_BUILD)
+PARALLEL_DIRS := $(TARGETS_TO_BUILD) AllTargetsBindings
 
 include $(LLVM_SRC_ROOT)/Makefile.rules