Skip to main content

llvm_sys_featured/
orc.rs

1//! The ORC JIT.
2
3use super::error::LLVMErrorRef;
4use super::prelude::*;
5use super::target_machine::LLVMTargetMachineRef;
6
7#[derive(Debug)]
8pub enum LLVMOrcOpaqueJITStack {}
9
10pub type LLVMOrcJITStackRef = *mut LLVMOrcOpaqueJITStack;
11pub type LLVMOrcModuleHandle = u64;
12pub type LLVMOrcTargetAddress = u64;
13
14pub type LLVMOrcSymbolResolverFn =
15    Option<extern "C" fn(*const ::libc::c_char, *mut ::libc::c_void) -> u64>;
16pub type LLVMOrcLazyCompileCallbackFn =
17    Option<extern "C" fn(LLVMOrcJITStackRef, *mut ::libc::c_void)>;
18extern "C" {
19    /// Create an ORC JIT stack.
20    ///
21    /// The client owns the returned stack and must call OrcDisposeInstance
22    /// when done with it. The JIT stack takes ownership of the provided
23    /// TargetMachine.
24    pub fn LLVMOrcCreateInstance(TM: LLVMTargetMachineRef) -> LLVMOrcJITStackRef;
25
26    /// Get the error message for the most recent error (if any).
27    ///
28    /// The returned message is owned by the ORC JIT stack.
29    pub fn LLVMOrcGetErrorMsg(JITStack: LLVMOrcJITStackRef) -> *const ::libc::c_char;
30
31    /// Mangle the given symbol.
32    ///
33    /// Memory is allocated for the mangled symbol, which will be owned by
34    /// the client.
35    pub fn LLVMOrcGetMangledSymbol(
36        JITStack: LLVMOrcJITStackRef,
37        MangledSymbol: *mut *mut ::libc::c_char,
38        Symbol: *const ::libc::c_char,
39    );
40
41    /// Dispose of a mangled symbol.
42    pub fn LLVMOrcDisposeMangledSymbol(MangledSymbol: *mut ::libc::c_char);
43
44    /// Create a lazy compile callback.
45    pub fn LLVMOrcCreateLazyCompileCallback(
46        JITStack: LLVMOrcJITStackRef,
47        RetAddr: *mut LLVMOrcTargetAddress,
48        Callback: LLVMOrcLazyCompileCallbackFn,
49        CallbackCtx: *mut ::libc::c_void,
50    ) -> LLVMErrorRef;
51
52    /// Create a named indirect call stub.
53    pub fn LLVMOrcCreateIndirectStub(
54        JITStack: LLVMOrcJITStackRef,
55        StubName: *const ::libc::c_char,
56        InitAddr: LLVMOrcTargetAddress,
57    ) -> LLVMErrorRef;
58
59    /// Set the pointer for the given indirect stub.
60    pub fn LLVMOrcSetIndirectStubPointer(
61        JITStack: LLVMOrcJITStackRef,
62        StubName: *const ::libc::c_char,
63        NewAddr: LLVMOrcTargetAddress,
64    ) -> LLVMErrorRef;
65
66    /// Add a module to be eagerly compiled.
67    pub fn LLVMOrcAddEagerlyCompiledIR(
68        JITStack: LLVMOrcJITStackRef,
69        RetHandle: *mut LLVMOrcModuleHandle,
70        Mod: LLVMModuleRef,
71        SymbolResolver: LLVMOrcSymbolResolverFn,
72        SymbolResolverCtx: *mut ::libc::c_void,
73    ) -> LLVMErrorRef;
74
75    /// Add a module to be lazily compiled one function at a time.
76    pub fn LLVMOrcAddLazilyCompiledIR(
77        JITStack: LLVMOrcJITStackRef,
78        RetHandle: *mut LLVMOrcModuleHandle,
79        Mod: LLVMModuleRef,
80        SymbolResolver: LLVMOrcSymbolResolverFn,
81        SymbolResolverCtx: *mut ::libc::c_void,
82    ) -> LLVMErrorRef;
83
84    /// Add an object file.
85    pub fn LLVMOrcAddObjectFile(
86        JITStack: LLVMOrcJITStackRef,
87        RetHandle: *mut LLVMOrcModuleHandle,
88        Obj: LLVMMemoryBufferRef,
89        SymbolResolver: LLVMOrcSymbolResolverFn,
90        SymbolResolverCtx: *mut ::libc::c_void,
91    ) -> LLVMErrorRef;
92
93    /// Remove a module set from the JIT.
94    pub fn LLVMOrcRemoveModule(
95        JITStack: LLVMOrcJITStackRef,
96        H: LLVMOrcModuleHandle,
97    ) -> LLVMErrorRef;
98
99    /// Get symbol address from JIT instance.
100    pub fn LLVMOrcGetSymbolAddress(
101        JITStack: LLVMOrcJITStackRef,
102        RetAddr: *mut LLVMOrcTargetAddress,
103        SymbolName: *const ::libc::c_char,
104    ) -> LLVMErrorRef;
105
106    /// Get symbol address from JIT instance, searching only the specified handle.
107    pub fn LLVMOrcGetSymbolAddressIn(
108        JITStack: LLVMOrcJITStackRef,
109        RetAddr: *mut LLVMOrcTargetAddress,
110        H: LLVMOrcModuleHandle,
111        SymbolName: *const ::libc::c_char,
112    ) -> LLVMErrorRef;
113
114    /// Dispose of an ORC JIT stack.
115    pub fn LLVMOrcDisposeInstance(JITStack: LLVMOrcJITStackRef) -> LLVMErrorRef;
116
117    /// Register a JIT Event Listener.
118    ///
119    /// A NULL listener is ignored.
120    pub fn LLVMOrcRegisterJITEventListener(
121        JITStack: LLVMOrcJITStackRef,
122        L: LLVMJITEventListenerRef,
123    );
124
125    /// Unegister a JIT Event Listener.
126    ///
127    /// A NULL listener is ignored.
128    pub fn LLVMOrcUnregisterJITEventListener(
129        JITStack: LLVMOrcJITStackRef,
130        L: LLVMJITEventListenerRef,
131    );
132}