Expose ExecutionEngine::getTargetData() to c and ocaml bindings.
[oota-llvm.git] / include / llvm-c / ExecutionEngine.h
1 /*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
2 |*                                                                            *|
3 |*                     The LLVM Compiler Infrastructure                       *|
4 |*                                                                            *|
5 |* This file is distributed under the University of Illinois Open Source      *|
6 |* License. See LICENSE.TXT for details.                                      *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* This header declares the C interface to libLLVMExecutionEngine.o, which    *|
11 |* implements various analyses of the LLVM IR.                                *|
12 |*                                                                            *|
13 |* Many exotic languages can interoperate with C code but have a harder time  *|
14 |* with C++ due to name mangling. So in addition to C, this interface enables *|
15 |* tools written in such languages.                                           *|
16 |*                                                                            *|
17 \*===----------------------------------------------------------------------===*/
18
19 #ifndef LLVM_C_EXECUTIONENGINE_H
20 #define LLVM_C_EXECUTIONENGINE_H
21
22 #include "llvm-c/Core.h"
23 #include "llvm-c/Target.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
30 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
31
32 /*===-- Operations on generic values --------------------------------------===*/
33
34 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
35                                                 unsigned long long N,
36                                                 int IsSigned);
37
38 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
39
40 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
41
42 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
43
44 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
45                                          int IsSigned);
46
47 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
48
49 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
50
51 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
52
53 /*===-- Operations on execution engines -----------------------------------===*/
54
55 int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
56                               LLVMModuleProviderRef MP,
57                               char **OutError);
58
59 int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
60                           LLVMModuleProviderRef MP,
61                           char **OutError);
62
63 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
64                           LLVMModuleProviderRef MP,
65                           char **OutError);
66
67 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
68
69 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
70
71 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
72
73 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
74                           unsigned ArgC, const char * const *ArgV,
75                           const char * const *EnvP);
76
77 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
78                                     unsigned NumArgs,
79                                     LLVMGenericValueRef *Args);
80
81 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
82
83 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
84
85 int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
86                              LLVMModuleProviderRef MP,
87                              LLVMModuleRef *OutMod, char **OutError);
88
89 int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
90                      LLVMValueRef *OutFn);
91
92 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
93
94 #ifdef __cplusplus
95 }
96
97 namespace llvm {
98   class GenericValue;
99   class ExecutionEngine;
100   
101   #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)   \
102     inline ty *unwrap(ref P) {                          \
103       return reinterpret_cast<ty*>(P);                  \
104     }                                                   \
105                                                         \
106     inline ref wrap(const ty *P) {                      \
107       return reinterpret_cast<ref>(const_cast<ty*>(P)); \
108     }
109   
110   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue,    LLVMGenericValueRef   )
111   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
112   
113   #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
114 }
115   
116 #endif /* defined(__cplusplus) */
117
118 #endif