summaryrefslogtreecommitdiff
path: root/include/llvm-c/Target.h
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-06-23 23:59:40 +0000
committerBob Wilson <bob.wilson@apple.com>2009-06-23 23:59:40 +0000
commita96751fc8ff1cc9a225ffbba73de53e2b9e1ae35 (patch)
tree969030d74f155627cda20fd861cca31e2fb8b8cf /include/llvm-c/Target.h
parentba1da8a7b10b8a7df04f3ca47ca36ad18adad80e (diff)
Provide InitializeAllTargets and InitializeNativeTarget functions in the
C bindings. Change all the backend "Initialize" functions to have C linkage. Change the "llvm/Config/Targets.def" header to use C-style comments to avoid compile warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm-c/Target.h')
-rw-r--r--include/llvm-c/Target.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h
index 5de5bc78574..bb423bbaadf 100644
--- a/include/llvm-c/Target.h
+++ b/include/llvm-c/Target.h
@@ -20,6 +20,7 @@
#define LLVM_C_TARGET_H
#include "llvm-c/Core.h"
+#include "llvm/Config/config.h"
#ifdef __cplusplus
extern "C" {
@@ -31,6 +32,34 @@ typedef int LLVMByteOrdering;
typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
typedef struct LLVMStructLayout *LLVMStructLayoutRef;
+/* Declare all of the target-initialization functions that are available. */
+#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
+#include "llvm/Config/Targets.def"
+
+/** 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() {
+#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
+#include "llvm/Config/Targets.def"
+}
+
+/** 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. */
+static inline int LLVMInitializeNativeTarget() {
+ /* If we have a native target, initialize it to ensure it is linked in. */
+#ifdef LLVM_NATIVE_ARCH
+#define DoInit2(TARG) LLVMInitialize ## TARG ()
+#define DoInit(T) DoInit2(T)
+ DoInit(LLVM_NATIVE_ARCH);
+ return 0;
+#undef DoInit
+#undef DoInit2
+#else
+ return 1;
+#endif
+}
/*===-- Target Data -------------------------------------------------------===*/