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"
24 #include "llvm-c/TargetMachine.h"
31 * @defgroup LLVMCExecutionEngine Execution Engine
37 void LLVMLinkInJIT(void);
38 void LLVMLinkInMCJIT(void);
39 void LLVMLinkInInterpreter(void);
41 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
42 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
44 struct LLVMMCJITCompilerOptions {
46 LLVMCodeModel CodeModel;
47 LLVMBool NoFramePointerElim;
48 LLVMBool EnableFastISel;
51 /*===-- Operations on generic values --------------------------------------===*/
53 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
57 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
59 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
61 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
63 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
66 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
68 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
70 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
72 /*===-- Operations on execution engines -----------------------------------===*/
74 LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE,
78 LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp,
82 LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
87 void LLVMInitializeMCJITCompilerOptions(
88 struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions);
91 * Create an MCJIT execution engine for a module, with the given options. It is
92 * the responsibility of the caller to ensure that all fields in Options up to
93 * the given SizeOfOptions are initialized. It is correct to pass a smaller
94 * value of SizeOfOptions that omits some fields. The canonical way of using
97 * LLVMMCJITCompilerOptions options;
98 * LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
99 * ... fill in those options you care about
100 * LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options),
103 * Note that this is also correct, though possibly suboptimal:
105 * LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
107 LLVMBool LLVMCreateMCJITCompilerForModule(
108 LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M,
109 struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions,
112 /** Deprecated: Use LLVMCreateExecutionEngineForModule instead. */
113 LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
114 LLVMModuleProviderRef MP,
117 /** Deprecated: Use LLVMCreateInterpreterForModule instead. */
118 LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
119 LLVMModuleProviderRef MP,
122 /** Deprecated: Use LLVMCreateJITCompilerForModule instead. */
123 LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
124 LLVMModuleProviderRef MP,
128 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
130 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
132 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
134 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
135 unsigned ArgC, const char * const *ArgV,
136 const char * const *EnvP);
138 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
140 LLVMGenericValueRef *Args);
142 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
144 void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M);
146 /** Deprecated: Use LLVMAddModule instead. */
147 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
149 LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M,
150 LLVMModuleRef *OutMod, char **OutError);
152 /** Deprecated: Use LLVMRemoveModule instead. */
153 LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
154 LLVMModuleProviderRef MP,
155 LLVMModuleRef *OutMod, char **OutError);
157 LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
158 LLVMValueRef *OutFn);
160 void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE,
163 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
165 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
168 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
176 #endif /* defined(__cplusplus) */