LLVM  14.0.0git
ExecutionEngine.h
Go to the documentation of this file.
1 /*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
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/ExternC.h"
23 #include "llvm-c/Target.h"
24 #include "llvm-c/TargetMachine.h"
25 #include "llvm-c/Types.h"
26 
28 
29 /**
30  * @defgroup LLVMCExecutionEngine Execution Engine
31  * @ingroup LLVMC
32  *
33  * @{
34  */
35 
36 void LLVMLinkInMCJIT(void);
37 void LLVMLinkInInterpreter(void);
38 
39 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
40 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
41 typedef struct LLVMOpaqueMCJITMemoryManager *LLVMMCJITMemoryManagerRef;
42 
44  unsigned OptLevel;
49 };
50 
51 /*===-- Operations on generic values --------------------------------------===*/
52 
54  unsigned long long N,
55  LLVMBool IsSigned);
56 
58 
60 
62 
63 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
64  LLVMBool IsSigned);
65 
67 
69 
71 
72 /*===-- Operations on execution engines -----------------------------------===*/
73 
76  char **OutError);
77 
80  char **OutError);
81 
84  unsigned OptLevel,
85  char **OutError);
86 
88  struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions);
89 
90 /**
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
95  * this is:
96  *
97  * LLVMMCJITCompilerOptions options;
98  * LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
99  * ... fill in those options you care about
100  * LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options),
101  * &error);
102  *
103  * Note that this is also correct, though possibly suboptimal:
104  *
105  * LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
106  */
109  struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions,
110  char **OutError);
111 
113 
115 
117 
119  unsigned ArgC, const char * const *ArgV,
120  const char * const *EnvP);
121 
123  unsigned NumArgs,
125 
127 
129 
131  LLVMModuleRef *OutMod, char **OutError);
132 
134  LLVMValueRef *OutFn);
135 
137  LLVMValueRef Fn);
138 
142 
144  void* Addr);
145 
147 
149 
151 
152 /// Returns true on error, false on success. If true is returned then the error
153 /// message is copied to OutStr and cleared in the ExecutionEngine instance.
155  char **OutError);
156 
157 /*===-- Operations on memory managers -------------------------------------===*/
158 
159 typedef uint8_t *(*LLVMMemoryManagerAllocateCodeSectionCallback)(
160  void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID,
161  const char *SectionName);
162 typedef uint8_t *(*LLVMMemoryManagerAllocateDataSectionCallback)(
163  void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID,
164  const char *SectionName, LLVMBool IsReadOnly);
166  void *Opaque, char **ErrMsg);
167 typedef void (*LLVMMemoryManagerDestroyCallback)(void *Opaque);
168 
169 /**
170  * Create a simple custom MCJIT memory manager. This memory manager can
171  * intercept allocations in a module-oblivious way. This will return NULL
172  * if any of the passed functions are NULL.
173  *
174  * @param Opaque An opaque client object to pass back to the callbacks.
175  * @param AllocateCodeSection Allocate a block of memory for executable code.
176  * @param AllocateDataSection Allocate a block of memory for data.
177  * @param FinalizeMemory Set page permissions and flush cache. Return 0 on
178  * success, 1 on error.
179  */
181  void *Opaque,
186 
188 
189 /*===-- JIT Event Listener functions -------------------------------------===*/
190 
195 
196 /**
197  * @}
198  */
199 
201 
202 #endif
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
LLVMInitializeMCJITCompilerOptions
void LLVMInitializeMCJITCompilerOptions(struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions)
Definition: ExecutionEngineBindings.cpp:150
LLVMFindFunction
LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, LLVMValueRef *OutFn)
Definition: ExecutionEngineBindings.cpp:268
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
LLVMDisposeGenericValue
void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal)
Definition: ExecutionEngineBindings.cpp:97
LLVMMemoryManagerAllocateCodeSectionCallback
uint8_t *(* LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName)
Definition: ExecutionEngine.h:159
LLVMCreateGenericValueOfFloat
LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N)
Definition: ExecutionEngineBindings.cpp:54
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
LLVMExecutionEngineRef
struct LLVMOpaqueExecutionEngine * LLVMExecutionEngineRef
Definition: ExecutionEngine.h:40
Types.h
LLVMCreateJITCompilerForModule
LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, unsigned OptLevel, char **OutError)
Definition: ExecutionEngineBindings.cpp:133
LLVMRunStaticConstructors
void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE)
Definition: ExecutionEngineBindings.cpp:219
LLVMGenericValueToFloat
double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal)
Definition: ExecutionEngineBindings.cpp:86
LLVMMCJITMemoryManagerRef
struct LLVMOpaqueMCJITMemoryManager * LLVMMCJITMemoryManagerRef
Definition: ExecutionEngine.h:41
LLVMRecompileAndRelinkFunction
void * LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, LLVMValueRef Fn)
Definition: ExecutionEngineBindings.cpp:277
LLVMAddGlobalMapping
void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, void *Addr)
Definition: ExecutionEngineBindings.cpp:291
F
#define F(x, y, z)
Definition: MD5.cpp:56
LLVMTargetDataRef
struct LLVMOpaqueTargetData * LLVMTargetDataRef
Definition: DataLayout.h:41
LLVMGenericValueToPointer
void * LLVMGenericValueToPointer(LLVMGenericValueRef GenVal)
Definition: ExecutionEngineBindings.cpp:82
LLVMCreateOProfileJITEventListener
LLVMJITEventListenerRef LLVMCreateOProfileJITEventListener(void)
Definition: ExecutionEngineBindings.cpp:436
LLVMGetFunctionAddress
uint64_t LLVMGetFunctionAddress(LLVMExecutionEngineRef EE, const char *Name)
Definition: ExecutionEngineBindings.cpp:306
LLVMCreateGenericValueOfPointer
LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P)
Definition: ExecutionEngineBindings.cpp:48
LLVMCreateSimpleMCJITMemoryManager
LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(void *Opaque, LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection, LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection, LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory, LLVMMemoryManagerDestroyCallback Destroy)
Create a simple custom MCJIT memory manager.
Definition: ExecutionEngineBindings.cpp:402
LLVMRunFunctionAsMain
int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned ArgC, const char *const *ArgV, const char *const *EnvP)
Definition: ExecutionEngineBindings.cpp:229
LLVMMCJITCompilerOptions::OptLevel
unsigned OptLevel
Definition: ExecutionEngine.h:44
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::AMDGPU::ElfNote::SectionName
const char SectionName[]
Definition: AMDGPUPTNote.h:24
LLVMTypeRef
struct LLVMOpaqueType * LLVMTypeRef
Each value in the LLVM IR has a type, an LLVMTypeRef.
Definition: Types.h:68
LLVMMCJITCompilerOptions::CodeModel
LLVMCodeModel CodeModel
Definition: ExecutionEngine.h:45
LLVMLinkInMCJIT
void LLVMLinkInMCJIT(void)
Definition: MCJIT.cpp:40
LLVMCreateIntelJITEventListener
LLVMJITEventListenerRef LLVMCreateIntelJITEventListener(void)
Definition: ExecutionEngineBindings.cpp:429
LLVMCreatePerfJITEventListener
LLVMJITEventListenerRef LLVMCreatePerfJITEventListener(void)
Definition: ExecutionEngineBindings.cpp:443
LLVMCreateGenericValueOfInt
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty, unsigned long long N, LLVMBool IsSigned)
Definition: ExecutionEngineBindings.cpp:40
LLVMMemoryManagerFinalizeMemoryCallback
LLVMBool(* LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg)
Definition: ExecutionEngine.h:165
Target.h
LLVMMCJITCompilerOptions
Definition: ExecutionEngine.h:43
LLVMDisposeMCJITMemoryManager
void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM)
Definition: ExecutionEngineBindings.cpp:421
LLVMDisposeExecutionEngine
void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE)
Definition: ExecutionEngineBindings.cpp:215
LLVMCreateExecutionEngineForModule
LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE, LLVMModuleRef M, char **OutError)
Definition: ExecutionEngineBindings.cpp:103
uint64_t
LLVMTargetMachineRef
typedefLLVM_C_EXTERN_C_BEGIN struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Definition: TargetMachine.h:28
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
LLVMMCJITCompilerOptions::NoFramePointerElim
LLVMBool NoFramePointerElim
Definition: ExecutionEngine.h:46
LLVMGetExecutionEngineTargetData
LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE)
Definition: ExecutionEngineBindings.cpp:282
LLVMMCJITCompilerOptions::MCJMM
LLVMMCJITMemoryManagerRef MCJMM
Definition: ExecutionEngine.h:48
LLVMGetPointerToGlobal
void * LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global)
Definition: ExecutionEngineBindings.cpp:296
LLVMMemoryManagerAllocateDataSectionCallback
uint8_t *(* LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName, LLVMBool IsReadOnly)
Definition: ExecutionEngine.h:162
LLVMCreateGDBRegistrationListener
LLVMJITEventListenerRef LLVMCreateGDBRegistrationListener(void)
Definition: GDBRegistrationListener.cpp:242
LLVMLinkInInterpreter
void LLVMLinkInInterpreter(void)
Definition: Interpreter.cpp:30
LLVM_C_EXTERN_C_END
#define LLVM_C_EXTERN_C_END
Definition: ExternC.h:36
LLVMAddModule
void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M)
Definition: ExecutionEngineBindings.cpp:256
LLVMRunStaticDestructors
void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE)
Definition: ExecutionEngineBindings.cpp:224
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVMBool
int LLVMBool
Definition: Types.h:28
TargetMachine.h
LLVMGenericValueToInt
unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal, LLVMBool IsSigned)
Definition: ExecutionEngineBindings.cpp:73
LLVMCreateInterpreterForModule
LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp, LLVMModuleRef M, char **OutError)
Definition: ExecutionEngineBindings.cpp:118
LLVMExecutionEngineGetErrMsg
LLVMBool LLVMExecutionEngineGetErrMsg(LLVMExecutionEngineRef EE, char **OutError)
Returns true on error, false on success.
Definition: ExecutionEngineBindings.cpp:310
LLVMRunFunction
LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned NumArgs, LLVMGenericValueRef *Args)
Definition: ExecutionEngineBindings.cpp:238
LLVMMCJITCompilerOptions::EnableFastISel
LLVMBool EnableFastISel
Definition: ExecutionEngine.h:47
LLVM_C_EXTERN_C_BEGIN
#define LLVM_C_EXTERN_C_BEGIN
Definition: ExternC.h:35
LLVMCreateMCJITCompilerForModule
LLVMBool LLVMCreateMCJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, LLVMModuleRef M, struct LLVMMCJITCompilerOptions *Options, size_t SizeOfOptions, char **OutError)
Create an MCJIT execution engine for a module, with the given options.
Definition: ExecutionEngineBindings.cpp:160
LLVMGenericValueIntWidth
unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef)
Definition: ExecutionEngineBindings.cpp:69
LLVMCodeModel
LLVMCodeModel
Definition: TargetMachine.h:48
LLVMGetExecutionEngineTargetMachine
LLVMTargetMachineRef LLVMGetExecutionEngineTargetMachine(LLVMExecutionEngineRef EE)
Definition: ExecutionEngineBindings.cpp:287
LLVMFreeMachineCodeForFunction
void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F)
Definition: ExecutionEngineBindings.cpp:253
LLVMGetGlobalValueAddress
uint64_t LLVMGetGlobalValueAddress(LLVMExecutionEngineRef EE, const char *Name)
Definition: ExecutionEngineBindings.cpp:302
N
#define N
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:75
LLVMMemoryManagerDestroyCallback
void(* LLVMMemoryManagerDestroyCallback)(void *Opaque)
Definition: ExecutionEngine.h:167
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
LLVMRemoveModule
LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M, LLVMModuleRef *OutMod, char **OutError)
Definition: ExecutionEngineBindings.cpp:260
LLVMJITEventListenerRef
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition: Types.h:163
ExternC.h
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
LLVMGenericValueRef
struct LLVMOpaqueGenericValue * LLVMGenericValueRef
Definition: ExecutionEngine.h:39