ExecutionEngine.h revision 193323
1193323Sed/*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
2193323Sed|*                                                                            *|
3193323Sed|*                     The LLVM Compiler Infrastructure                       *|
4193323Sed|*                                                                            *|
5193323Sed|* This file is distributed under the University of Illinois Open Source      *|
6193323Sed|* License. See LICENSE.TXT for details.                                      *|
7193323Sed|*                                                                            *|
8193323Sed|*===----------------------------------------------------------------------===*|
9193323Sed|*                                                                            *|
10193323Sed|* This header declares the C interface to libLLVMExecutionEngine.o, which    *|
11193323Sed|* implements various analyses of the LLVM IR.                                *|
12193323Sed|*                                                                            *|
13193323Sed|* Many exotic languages can interoperate with C code but have a harder time  *|
14193323Sed|* with C++ due to name mangling. So in addition to C, this interface enables *|
15193323Sed|* tools written in such languages.                                           *|
16193323Sed|*                                                                            *|
17193323Sed\*===----------------------------------------------------------------------===*/
18193323Sed
19193323Sed#ifndef LLVM_C_EXECUTIONENGINE_H
20193323Sed#define LLVM_C_EXECUTIONENGINE_H
21193323Sed
22193323Sed#include "llvm-c/Core.h"
23193323Sed#include "llvm-c/Target.h"
24193323Sed
25193323Sed#ifdef __cplusplus
26193323Sedextern "C" {
27193323Sed#endif
28193323Sed
29193323Sedtypedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
30193323Sedtypedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
31193323Sed
32193323Sed/*===-- Operations on generic values --------------------------------------===*/
33193323Sed
34193323SedLLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
35193323Sed                                                unsigned long long N,
36193323Sed                                                int IsSigned);
37193323Sed
38193323SedLLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
39193323Sed
40193323SedLLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
41193323Sed
42193323Sedunsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
43193323Sed
44193323Sedunsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
45193323Sed                                         int IsSigned);
46193323Sed
47193323Sedvoid *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
48193323Sed
49193323Seddouble LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
50193323Sed
51193323Sedvoid LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
52193323Sed
53193323Sed/*===-- Operations on execution engines -----------------------------------===*/
54193323Sed
55193323Sedint LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
56193323Sed                              LLVMModuleProviderRef MP,
57193323Sed                              char **OutError);
58193323Sed
59193323Sedint LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
60193323Sed                          LLVMModuleProviderRef MP,
61193323Sed                          char **OutError);
62193323Sed
63193323Sedint LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
64193323Sed                          LLVMModuleProviderRef MP,
65193323Sed                          unsigned OptLevel,
66193323Sed                          char **OutError);
67193323Sed
68193323Sedvoid LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
69193323Sed
70193323Sedvoid LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
71193323Sed
72193323Sedvoid LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
73193323Sed
74193323Sedint LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
75193323Sed                          unsigned ArgC, const char * const *ArgV,
76193323Sed                          const char * const *EnvP);
77193323Sed
78193323SedLLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
79193323Sed                                    unsigned NumArgs,
80193323Sed                                    LLVMGenericValueRef *Args);
81193323Sed
82193323Sedvoid LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
83193323Sed
84193323Sedvoid LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
85193323Sed
86193323Sedint LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
87193323Sed                             LLVMModuleProviderRef MP,
88193323Sed                             LLVMModuleRef *OutMod, char **OutError);
89193323Sed
90193323Sedint LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
91193323Sed                     LLVMValueRef *OutFn);
92193323Sed
93193323SedLLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
94193323Sed
95193323Sedvoid LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
96193323Sed                          void* Addr);
97193323Sed
98193323Sedvoid *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
99193323Sed
100193323Sed#ifdef __cplusplus
101193323Sed}
102193323Sed
103193323Sednamespace llvm {
104193323Sed  class GenericValue;
105193323Sed  class ExecutionEngine;
106193323Sed
107193323Sed  #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)   \
108193323Sed    inline ty *unwrap(ref P) {                          \
109193323Sed      return reinterpret_cast<ty*>(P);                  \
110193323Sed    }                                                   \
111193323Sed                                                        \
112193323Sed    inline ref wrap(const ty *P) {                      \
113193323Sed      return reinterpret_cast<ref>(const_cast<ty*>(P)); \
114193323Sed    }
115193323Sed
116193323Sed  DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue,    LLVMGenericValueRef   )
117193323Sed  DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
118193323Sed
119193323Sed  #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
120193323Sed}
121193323Sed
122193323Sed#endif /* defined(__cplusplus) */
123193323Sed
124193323Sed#endif
125