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 module deimos.llvm.c.executionengine; 20 21 import deimos.llvm.c.core; 22 import deimos.llvm.c.target; 23 import deimos.llvm.c.targetmachine; 24 25 extern(C) nothrow: 26 27 /** 28 * @defgroup LLVMCExecutionEngine Execution Engine 29 * @ingroup LLVMC 30 * 31 * @{ 32 */ 33 34 void LLVMLinkInJIT(); 35 void LLVMLinkInMCJIT(); 36 void LLVMLinkInInterpreter(); 37 38 struct __LLVMOpaqueGenericValue {}; 39 alias __LLVMOpaqueGenericValue *LLVMGenericValueRef; 40 struct __LLVMOpaqueExecutionEngine {}; 41 alias __LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef; 42 43 struct LLVMMCJITCompilerOptions { 44 uint OptLevel; 45 LLVMCodeModel CodeModel; 46 LLVMBool NoFramePointerElim; 47 LLVMBool EnableFastISel; 48 } 49 50 /*===-- Operations on generic values --------------------------------------===*/ 51 52 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty, 53 ulong N, 54 LLVMBool IsSigned); 55 56 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P); 57 58 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N); 59 60 uint LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef); 61 62 ulong LLVMGenericValueToInt(LLVMGenericValueRef GenVal, 63 LLVMBool IsSigned); 64 65 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal); 66 67 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal); 68 69 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal); 70 71 /*===-- Operations on execution engines -----------------------------------===*/ 72 73 LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE, 74 LLVMModuleRef M, 75 char **OutError); 76 77 LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp, 78 LLVMModuleRef M, 79 char **OutError); 80 81 LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, 82 LLVMModuleRef M, 83 uint OptLevel, 84 char **OutError); 85 86 void LLVMInitializeMCJITCompilerOptions( 87 LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions); 88 89 /** 90 * Create an MCJIT execution engine for a module, with the given options. It is 91 * the responsibility of the caller to ensure that all fields in Options up to 92 * the given SizeOfOptions are initialized. It is correct to pass a smaller 93 * value of SizeOfOptions that omits some fields. The canonical way of using 94 * this is: 95 * 96 * LLVMMCJITCompilerOptions options; 97 * LLVMInitializeMCJITCompilerOptions(&options, sizeof(options)); 98 * ... fill in those options you care about 99 * LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options), 100 * &error); 101 * 102 * Note that this is also correct, though possibly suboptimal: 103 * 104 * LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error); 105 */ 106 LLVMBool LLVMCreateMCJITCompilerForModule( 107 LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, 108 LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions, 109 char **OutError); 110 111 /** Deprecated: Use LLVMCreateExecutionEngineForModule instead. */ 112 LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE, 113 LLVMModuleProviderRef MP, 114 char **OutError); 115 116 /** Deprecated: Use LLVMCreateInterpreterForModule instead. */ 117 LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp, 118 LLVMModuleProviderRef MP, 119 char **OutError); 120 121 /** Deprecated: Use LLVMCreateJITCompilerForModule instead. */ 122 LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT, 123 LLVMModuleProviderRef MP, 124 uint OptLevel, 125 char **OutError); 126 127 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE); 128 129 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE); 130 131 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE); 132 133 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, 134 uint ArgC, const(char*) *ArgV, 135 const(char*) *EnvP); 136 137 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, 138 uint NumArgs, 139 LLVMGenericValueRef *Args); 140 141 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); 142 143 void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M); 144 145 /** Deprecated: Use LLVMAddModule instead. */ 146 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP); 147 148 LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M, 149 LLVMModuleRef *OutMod, char **OutError); 150 151 /** Deprecated: Use LLVMRemoveModule instead. */ 152 LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, 153 LLVMModuleProviderRef MP, 154 LLVMModuleRef *OutMod, char **OutError); 155 156 LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const(char) *Name, 157 LLVMValueRef *OutFn); 158 159 void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, 160 LLVMValueRef Fn); 161 162 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE); 163 164 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, 165 void* Addr); 166 167 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); 168 169 /** 170 * @} 171 */