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"
29 typedef struct LLVMOpaqueGenericValue
*LLVMGenericValueRef
;
30 typedef struct LLVMOpaqueExecutionEngine
*LLVMExecutionEngineRef
;
32 /*===-- Operations on generic values --------------------------------------===*/
34 LLVMGenericValueRef
LLVMCreateGenericValueOfInt(LLVMTypeRef Ty
,
38 LLVMGenericValueRef
LLVMCreateGenericValueOfPointer(void *P
);
40 LLVMGenericValueRef
LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty
, double N
);
42 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef
);
44 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal
,
47 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal
);
49 double LLVMGenericValueToFloat(LLVMTypeRef TyRef
, LLVMGenericValueRef GenVal
);
51 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal
);
53 /*===-- Operations on execution engines -----------------------------------===*/
55 int LLVMCreateExecutionEngine(LLVMExecutionEngineRef
*OutEE
,
56 LLVMModuleProviderRef MP
,
59 int LLVMCreateInterpreter(LLVMExecutionEngineRef
*OutInterp
,
60 LLVMModuleProviderRef MP
,
63 int LLVMCreateJITCompiler(LLVMExecutionEngineRef
*OutJIT
,
64 LLVMModuleProviderRef MP
,
68 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE
);
70 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE
);
72 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE
);
74 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE
, LLVMValueRef F
,
75 unsigned ArgC
, const char * const *ArgV
,
76 const char * const *EnvP
);
78 LLVMGenericValueRef
LLVMRunFunction(LLVMExecutionEngineRef EE
, LLVMValueRef F
,
80 LLVMGenericValueRef
*Args
);
82 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE
, LLVMValueRef F
);
84 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE
, LLVMModuleProviderRef MP
);
86 int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE
,
87 LLVMModuleProviderRef MP
,
88 LLVMModuleRef
*OutMod
, char **OutError
);
90 int LLVMFindFunction(LLVMExecutionEngineRef EE
, const char *Name
,
93 LLVMTargetDataRef
LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE
);
95 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE
, LLVMValueRef Global
,
98 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE
, LLVMValueRef Global
);
105 class ExecutionEngine
;
107 #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
108 inline ty *unwrap(ref P) { \
109 return reinterpret_cast<ty*>(P); \
112 inline ref wrap(const ty *P) { \
113 return reinterpret_cast<ref>(const_cast<ty*>(P)); \
116 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue
, LLVMGenericValueRef
)
117 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine
, LLVMExecutionEngineRef
)
119 #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
122 #endif /* defined(__cplusplus) */