forked from Memnarch/LLVM4D
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLLVM.Imports.ExecutionEngine.pas
More file actions
130 lines (84 loc) · 6.57 KB
/
Copy pathLLVM.Imports.ExecutionEngine.pas
File metadata and controls
130 lines (84 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
unit LLVM.Imports.ExecutionEngine;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
//based on ExecutionEngine.h
uses
LLVM.Imports,
LLVM.Imports.Types,
LLVM.Imports.Target,
LLVM.Imports.TargetMachine;
procedure LLVMLinkInMCJIT; cdecl; external CLLVMLibrary;
procedure LLVMLinkInInterpreter; cdecl; external CLLVMLibrary;
type
TLLVMGenericValueRef = type TLLVMRef;
PLLVMGenericValueRef = ^TLLVMGenericValueRef;
TLLVMExecutionEngineRef = type TLLVMRef;
TLLVMMCJITMemoryManagerRef = type TLLVMRef;
TLLVMMCJITCompilerOptions = packed record
OptLevel: Cardinal;
CodeModel: TLLVMCodeModel;
NoFramePointerElim: TLLVMBool;
EnableFastISel: TLLVMBool;
MCJMM: TLLVMMCJITMemoryManagerRef;
end;
function LLVMCreateGenericValueOfInt(Ty: TLLVMTypeRef; N: UInt64; IsSigned: TLLVMBool): TLLVMGenericValueRef; cdecl; external CLLVMLibrary;
function LLVMCreateGenericValueOfPointer(P: Pointer): TLLVMGenericValueRef; cdecl; external CLLVMLibrary;
function LLVMCreateGenericValueOfFloat(Ty: TLLVMTypeRef; N: Double): TLLVMGenericValueRef; cdecl; external CLLVMLibrary;
function LLVMGenericValueIntWidth(GenValRef: TLLVMGenericValueRef): Cardinal; cdecl; external CLLVMLibrary;
function LLVMGenericValueToInt(GenVal: TLLVMGenericValueRef; IsSigned: TLLVMBool): UInt64; cdecl; external CLLVMLibrary;
function LLVMGenericValueToPointer(GenVal: TLLVMGenericValueRef): Pointer; cdecl; external CLLVMLibrary;
function LLVMGenericValueToFloat(TyRef: TLLVMTypeRef; GenVal: TLLVMGenericValueRef): Double; cdecl; external CLLVMLibrary;
procedure LLVMDisposeGenericValue(GenVal: TLLVMGenericValueRef); cdecl; external CLLVMLibrary;
function LLVMCreateExecutionEngineForModule(out OutEE: TLLVMExecutionEngineRef; M: TLLVMModuleRef; out OutError: TLLVMChar): TLLVMBool; cdecl; external CLLVMLibrary;
function LLVMCreateInterpreterForModule(out OutInterp: TLLVMExecutionEngineRef; M: TLLVMModuleRef; out OutError: TLLVMChar): TLLVMBool; cdecl; external CLLVMLibrary;
function LLVMCreateJITCompilerForModule(out OutJIT: TLLVMExecutionEngineRef; M: TLLVMModuleRef; OptLevel: Cardinal; out OutError: TLLVMChar): TLLVMBool; cdecl; external CLLVMLibrary;
procedure LLVMInitializeMCJITCompilerOptions(var Options: TLLVMMCJITCompilerOptions; SizeOfOptions: TLLVMSizeT = SizeOf(TLLVMMCJITCompilerOptions)); cdecl; external CLLVMLibrary;
function LLVMCreateMCJITCompilerForModule(out OutJIT: TLLVMExecutionEngineRef; M: TLLVMModuleRef; var Options: TLLVMMCJITCompilerOptions; SizeOfOptions: TLLVMSizeT; out OutError: TLLVMChar): TLLVMBool; cdecl; external CLLVMLibrary;
procedure LLVMDisposeExecutionEngine(EE: TLLVMExecutionEngineRef); cdecl; external CLLVMLibrary;
procedure LLVMRunStaticConstructors(EE: TLLVMExecutionEngineRef); cdecl; external CLLVMLibrary;
procedure LLVMRunStaticDestructors(EE: TLLVMExecutionEngineRef); cdecl; external CLLVMLibrary;
function LLVMRunFunctionAsMain(EE: TLLVMExecutionEngineRef; F: TLLVMValueRef; ArgC: Cardinal; ArgV: Pointer; EnvP: Pointer): Integer; cdecl; external CLLVMLibrary;
function LLVMRunFunction(EE: TLLVMExecutionEngineRef; F: TLLVMValueRef; NumArgs: Cardinal; Args: PLLVMGenericValueRef): TLLVMGenericValueRef; cdecl; external CLLVMLibrary;
procedure LLVMFreeMachineCodeForFunction(EE: TLLVMExecutionEngineRef; F: TLLVMValueRef); cdecl; external CLLVMLibrary;
procedure LLVMAddModule(EE: TLLVMExecutionEngineRef; M: TLLVMModuleRef); cdecl; external CLLVMLibrary;
function LLVMRemoveModule(EE: TLLVMExecutionEngineRef; M: TLLVMModuleRef; out OutMod: TLLVMModuleRef; out OutError: TLLVMChar): TLLVMBool; cdecl; external CLLVMLibrary;
function LLVMFindFunction(EE: TLLVMExecutionEngineRef; const Name: PLLVMChar; out OutFn: TLLVMValueRef): TLLVMBool; cdecl; external CLLVMLibrary;
function LLVMRecompileAndRelinkFunction(EE: TLLVMExecutionEngineRef; Fn: TLLVMValueRef): Pointer; cdecl; external CLLVMLibrary;
function LLVMGetExecutionEngineTargetData(EE: TLLVMExecutionEngineRef): TLLVMTargetDataRef; cdecl; external CLLVMLibrary;
function LLVMGetExecutionEngineTargetMachine(EE: TLLVMExecutionEngineRef): TLLVMTargetMachineRef; cdecl; external CLLVMLibrary;
procedure LLVMAddGlobalMapping(EE: TLLVMExecutionEngineRef; Global: TLLVMValueRef; Addr: Pointer); cdecl; external CLLVMLibrary;
function LLVMGetPointerToGlobal(EE: TLLVMExecutionEngineRef; Global: TLLVMValueRef): Pointer; cdecl; external CLLVMLibrary;
function LLVMGetGlobalValueAddress(EE: TLLVMExecutionEngineRef; const Name: PLLVMChar): UInt64; cdecl; external CLLVMLibrary;
function LLVMGetFunctionAddress(EE: TLLVMExecutionEngineRef; const Name: PLLVMChar): UInt64; cdecl; external CLLVMLibrary;
type
TLLVMMemoryManagerAllocateCodeSectionCallback = function(Opaque: Pointer; Size: NativeUInt; Alignment: Cardinal; SectionID: Cardinal; const SectionName: PLLVMChar): Pointer; cdecl;
TLLVMMemoryManagerAllocateDataSectionCallback = function(Opaque: Pointer; SIze: NativeUInt; Alignment: Cardinal; SectionID: Cardinal; const SectionName: PLLVMChar; IsReadOnly: TLLVMBool): Pointer; cdecl;
TLLVMMemoryManagerFinalizeMemoryCallback = function(Opaque: Pointer; out ErrMsg: PLLVMChar): TLLVMBool; cdecl;
TLLVMMemoryManagerDestroyCallback = procedure(Opaque: Pointer); cdecl;
{**
* Create a simple custom MCJIT memory manager. This memory manager can
* intercept allocations in a module-oblivious way. This will return NULL
* if any of the passed functions are NULL.
*
* @param Opaque An opaque client object to pass back to the callbacks.
* @param AllocateCodeSection Allocate a block of memory for executable code.
* @param AllocateDataSection Allocate a block of memory for data.
* @param FinalizeMemory Set page permissions and flush cache. Return 0 on
* success, 1 on error.
*}
function LLVMCreateSimpleMCJITMemoryManager(
Opaque: Pointer;
AllocateCodeSection: TLLVMMemoryManagerAllocateCodeSectionCallback;
AllocateDataSection: TLLVMMemoryManagerAllocateDataSectionCallback;
FinalizeMemory: TLLVMMemoryManagerFinalizeMemoryCallback;
Destroy: TLLVMMemoryManagerDestroyCallback): TLLVMMCJITMemoryManagerRef; cdecl; external CLLVMLibrary;
procedure LLVMDisposeMCJITMemoryManager(MM: TLLVMMCJITMemoryManagerRef); cdecl; external CLLVMLibrary;
(*===-- JIT Event Listener functions -------------------------------------===*)
function LLVMCreateGDBRegistrationListener: TLLVMJITEventListenerRef; cdecl; external CLLVMLibrary;
function LLVMCreateIntelJITEventListener: TLLVMJITEventListenerRef; cdecl; external CLLVMLibrary;
function LLVMCreateOProfileJITEventListener: TLLVMJITEventListenerRef; cdecl; external CLLVMLibrary;
function LLVMCreatePerfJITEventListener: TLLVMJITEventListenerRef; cdecl; external CLLVMLibrary;
implementation
end.