diff options
author | Bob Wilson <bob.wilson@apple.com> | 2009-06-23 23:59:40 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2009-06-23 23:59:40 +0000 |
commit | 5a495fea076baefce2901adda01bd6103b2bf2c1 (patch) | |
tree | 7bb346a1011e1498cd2324e8cd24a624955efeeb /llvm/include/llvm-c/Target.h | |
parent | a83edb0cc1f3e0f191ec88526db7c777e93072d4 (diff) | |
download | bcm5719-llvm-5a495fea076baefce2901adda01bd6103b2bf2c1.tar.gz bcm5719-llvm-5a495fea076baefce2901adda01bd6103b2bf2c1.zip |
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.
llvm-svn: 74026
Diffstat (limited to 'llvm/include/llvm-c/Target.h')
-rw-r--r-- | llvm/include/llvm-c/Target.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/include/llvm-c/Target.h b/llvm/include/llvm-c/Target.h index 5de5bc78574..bb423bbaadf 100644 --- a/llvm/include/llvm-c/Target.h +++ b/llvm/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 -------------------------------------------------------===*/ |