Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 1 | /*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* The LLVM Compiler Infrastructure *| |
| 4 | |* *| |
Chris Lattner | 7ed47a1 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | |* This file is distributed under the University of Illinois Open Source *| |
| 6 | |* License. See LICENSE.TXT for details. *| |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 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" |
Erick Tryzelaar | 7c1483b | 2008-03-27 00:27:14 +0000 | [diff] [blame] | 23 | #include "llvm-c/Target.h" |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 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, |
Gordon Henriksen | c13c4d6 | 2008-08-08 20:49:28 +0000 | [diff] [blame] | 65 | int Fast, |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 66 | char **OutError); |
| 67 | |
| 68 | void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE); |
| 69 | |
| 70 | void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE); |
| 71 | |
| 72 | void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE); |
| 73 | |
| 74 | int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, |
| 75 | unsigned ArgC, const char * const *ArgV, |
| 76 | const char * const *EnvP); |
| 77 | |
| 78 | LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, |
| 79 | unsigned NumArgs, |
| 80 | LLVMGenericValueRef *Args); |
| 81 | |
| 82 | void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); |
| 83 | |
| 84 | void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP); |
| 85 | |
| 86 | int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, |
| 87 | LLVMModuleProviderRef MP, |
| 88 | LLVMModuleRef *OutMod, char **OutError); |
| 89 | |
| 90 | int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, |
| 91 | LLVMValueRef *OutFn); |
| 92 | |
Erick Tryzelaar | 7c1483b | 2008-03-27 00:27:14 +0000 | [diff] [blame] | 93 | LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE); |
| 94 | |
Gordon Henriksen | 54227f6 | 2008-06-20 02:16:11 +0000 | [diff] [blame] | 95 | void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, |
| 96 | void* Addr); |
| 97 | |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 98 | #ifdef __cplusplus |
| 99 | } |
| 100 | |
| 101 | namespace llvm { |
| 102 | class GenericValue; |
| 103 | class ExecutionEngine; |
| 104 | |
| 105 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ |
| 106 | inline ty *unwrap(ref P) { \ |
| 107 | return reinterpret_cast<ty*>(P); \ |
| 108 | } \ |
| 109 | \ |
| 110 | inline ref wrap(const ty *P) { \ |
| 111 | return reinterpret_cast<ref>(const_cast<ty*>(P)); \ |
| 112 | } |
| 113 | |
| 114 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef ) |
| 115 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef) |
| 116 | |
| 117 | #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS |
| 118 | } |
| 119 | |
| 120 | #endif /* defined(__cplusplus) */ |
| 121 | |
| 122 | #endif |