-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathLLVM.Imports.OrcBindings.pas
114 lines (89 loc) · 4.25 KB
/
LLVM.Imports.OrcBindings.pas
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
unit LLVM.Imports.OrcBindings;
interface
//based on OrcBindings.h
uses
LLVM.Imports,
LLVM.Imports.Types,
LLVM.Imports.TargetMachine,
LLVM.Imports.Error;
type
TLLVMSharedModuleRef = type TLLVMRef;
TLLVMSharedObjectBufferRef = type TLLVMRef;
TLLVMOrcJITStackRef = type TLLVMRef;
TLLVMOrcModuleHandle = type UInt64;
TLLVMOrcTargetAddress = type UInt64;
TLLVMOrcSymbolResolverFn = function(const Name: PLLVMChar; LookupCtx: Pointer): UInt64; cdecl;
TLLVMOrcLazyCompileCallbackFn = function(JITStack: TLLVMOrcJITStackRef; CallbackCtx: Pointer): UInt64; cdecl;
{$MINENUMSIZE 4}
{**
* Create an ORC JIT stack.
*
* The client owns the resulting stack, and must call OrcDisposeInstance(...)
* to destroy it and free its memory. The JIT stack will take ownership of the
* TargetMachine, which will be destroyed when the stack is destroyed. The
* client should not attempt to dispose of the Target Machine, or it will result
* in a double-free.
*}
function LLVMOrcCreateInstance(TM: TLLVMTargetMachineRef): TLLVMOrcJITStackRef; cdecl; external CLLVMLibrary;
{**
* Get the error message for the most recent error (if any).
*
* This message is owned by the ORC JIT Stack and will be freed when the stack
* is disposed of by LLVMOrcDisposeInstance.
*}
function LLVMOrcGetErrorMsg(JITStack: TLLVMOrcJITStackRef): PLLVMChar; cdecl; external CLLVMLibrary;
{**
* Mangle the given symbol.
* Memory will be allocated for MangledSymbol to hold the result. The client
*}
procedure LLVMOrcGetMangledSymbol(JITStack: TLLVMOrcJITStackRef; out MangledSymbol: PLLVMChar; const Symbol: PLLVMChar); cdecl; external CLLVMLibrary;
{**
* Dispose of a mangled symbol.
*}
procedure LLVMOrcDisposeMangledSymbol(MangledSymbol: PLLVMChar); cdecl; external CLLVMLibrary;
{**
* Create a lazy compile callback.
*}
function LLVMOrcCreateLazyCompileCallback(JITStack: TLLVMOrcJITStackRef; var RetAddr: TLLVMOrcTargetAddress; Callback: TLLVMOrcLazyCompileCallbackFn; CallbackCtx: Pointer): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Create a named indirect call stub.
*}
function LLVMOrcCreateIndirectStub(JITStack: TLLVMOrcJITStackRef; const StubName: PLLVMChar; InitAddr: TLLVMOrcTargetAddress): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Set the pointer for the given indirect stub.
*}
function LLVMOrcSetIndirectStubPointer(JITStack: TLLVMOrcJITStackRef; const StubName: PLLVMChar; NewAddr: TLLVMOrcTargetAddress): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Add module to be eagerly compiled.
*}
function LLVMOrcAddEagerlyCompiledIR(JITStack: TLLVMOrcJITStackRef; out RetHandle: TLLVMOrcModuleHandle; Module: TLLVMSharedModuleRef; SymbolResolver: TLLVMOrcSymbolResolverFn; SymbolResolverCtx: Pointer): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Add module to be lazily compiled one function at a time.
*}
function LLVMOrcAddLazilyCompiledIR(JITStack: TLLVMOrcJITStackRef; out RetHandle: TLLVMOrcModuleHandle; Module: TLLVMSharedModuleRef; SymbolResolver: TLLVMOrcSymbolResolverFn; SymbolResolverCtx: Pointer): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Add an object file.
*}
function LLVMOrcAddObjectFile(JITStack: TLLVMOrcJITStackRef; out RetHandle: TLLVMOrcModuleHandle; Obj: TLLVMSharedObjectBufferRef; SymbolResolver: TLLVMOrcSymbolResolverFn; SymbolResolverCtx: Pointer): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Remove a module set from the JIT.
*
* This works for all modules that can be added via OrcAdd*, including object
* files.
*}
function LLVMOrcRemoveModule(JITStack: TLLVMOrcJITStackRef; H: TLLVMOrcModuleHandle): TLLVMErrorRef; cdecl; external CLLVMLibrary;
{**
* Get symbol address from JIT instance.
*}
function LLVMOrcGetSymbolAddress(JITStack: TLLVMOrcJITStackRef; out RetAddr: TLLVMOrcTargetAddress; const SymbolName: PLLVMChar): TLLVMErrorRef; cdecl; external CLLVMLibrary;
(**
* Get symbol address from JIT instance, searching only the specified
* handle.
*)
function LLVMOrcGetSymbolAddressIn(JITStack: TLLVMOrcJITStackRef; out RetAddr: TLLVMOrcTargetAddress; H: TLLVMOrcModuleHandle; const SymbolName: PLLVMChar):TLLVMErrorRef;cdecl; external CLLVMLibrary;
{**
* Dispose of an ORC JIT stack.
*}
function LLVMOrcDisposeInstance(JITStack: TLLVMOrcJITStackRef): TLLVMErrorRef; cdecl; external CLLVMLibrary;
implementation
end.