1 /*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header declares the C interface to libLLVMExecutionEngine.o, which *|
11 |* implements various analyses of the LLVM IR. *|
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. *|
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"
30 * @defgroup LLVMCExecutionEngine Execution Engine
36 void LLVMLinkInJIT(void);
37 void LLVMLinkInMCJIT(void);
38 void LLVMLinkInInterpreter(void);
40 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
41 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
43 struct LLVMMCJITCompilerOptions {
45 LLVMBool NoFramePointerElim;
48 /*===-- Operations on generic values --------------------------------------===*/
50 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
54 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
56 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
58 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
60 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
63 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
65 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
67 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
69 /*===-- Operations on execution engines -----------------------------------===*/
71 LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE,
75 LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp,
79 LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
85 * Create an MCJIT execution engine for a module, with the given options. It is
86 * the responsibility of the caller to ensure that all fields in Options up to
87 * the given SizeOfOptions are initialized. It is correct to pass a smaller value
88 * of SizeOfOptions that omits some fields, and it is also correct to set any
89 * field to zero. The canonical way of using this is:
91 * LLVMMCJITCompilerOptions options;
92 * memset(&options, 0, sizeof(options));
93 * ... fill in those options you care about
94 * LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options), &error);
96 * Note that this is also correct, though possibly suboptimal:
98 * LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
100 LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
102 struct LLVMMCJITCompilerOptions *Options,
103 size_t SizeOfOptions,
106 /** Deprecated: Use LLVMCreateExecutionEngineForModule instead. */
107 LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
108 LLVMModuleProviderRef MP,
111 /** Deprecated: Use LLVMCreateInterpreterForModule instead. */
112 LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
113 LLVMModuleProviderRef MP,
116 /** Deprecated: Use LLVMCreateJITCompilerForModule instead. */
117 LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
118 LLVMModuleProviderRef MP,
122 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
124 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
126 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
128 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
129 unsigned ArgC, const char * const *ArgV,
130 const char * const *EnvP);
132 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
134 LLVMGenericValueRef *Args);
136 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
138 void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M);
140 /** Deprecated: Use LLVMAddModule instead. */
141 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
143 LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M,
144 LLVMModuleRef *OutMod, char **OutError);
146 /** Deprecated: Use LLVMRemoveModule instead. */
147 LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
148 LLVMModuleProviderRef MP,
149 LLVMModuleRef *OutMod, char **OutError);
151 LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
152 LLVMValueRef *OutFn);
154 void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, LLVMValueRef Fn);
156 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
158 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
161 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
169 #endif /* defined(__cplusplus) */