Merge branch 'master' into systemz
[llvm/systemz.git] / include / llvm-c / ExecutionEngine.h
blob05f2a892e22309bc84fbe93080e8d28742469cc8
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 \*===----------------------------------------------------------------------===*/
19 #ifndef LLVM_C_EXECUTIONENGINE_H
20 #define LLVM_C_EXECUTIONENGINE_H
22 #include "llvm-c/Core.h"
23 #include "llvm-c/Target.h"
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
29 void LLVMLinkInJIT(void);
30 void LLVMLinkInInterpreter(void);
32 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
33 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
35 /*===-- Operations on generic values --------------------------------------===*/
37 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
38 unsigned long long N,
39 int IsSigned);
41 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
43 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
45 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
47 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
48 int IsSigned);
50 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
52 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
54 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
56 /*===-- Operations on execution engines -----------------------------------===*/
58 int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
59 LLVMModuleProviderRef MP,
60 char **OutError);
62 int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
63 LLVMModuleProviderRef MP,
64 char **OutError);
66 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
67 LLVMModuleProviderRef MP,
68 unsigned OptLevel,
69 char **OutError);
71 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
73 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
75 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
77 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
78 unsigned ArgC, const char * const *ArgV,
79 const char * const *EnvP);
81 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
82 unsigned NumArgs,
83 LLVMGenericValueRef *Args);
85 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
87 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
89 int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
90 LLVMModuleProviderRef MP,
91 LLVMModuleRef *OutMod, char **OutError);
93 int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
94 LLVMValueRef *OutFn);
96 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
98 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
99 void* Addr);
101 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
103 #ifdef __cplusplus
106 namespace llvm {
107 struct GenericValue;
108 class ExecutionEngine;
110 #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
111 inline ty *unwrap(ref P) { \
112 return reinterpret_cast<ty*>(P); \
115 inline ref wrap(const ty *P) { \
116 return reinterpret_cast<ref>(const_cast<ty*>(P)); \
119 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef )
120 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
122 #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
125 #endif /* defined(__cplusplus) */
127 #endif