1 /*===----------- llvm-c/OrcBindings.h - Orc Lib C Iface ---------*- C++ -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header declares the C interface to libLLVMOrcJIT.a, which implements *|
11 |* JIT compilation of LLVM IR. *|
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. *|
17 |* Note: This interface is experimental. It is *NOT* stable, and may be *|
18 |* changed without warning. *|
20 \*===----------------------------------------------------------------------===*/
22 #ifndef LLVM_C_ORCBINDINGS_H
23 #define LLVM_C_ORCBINDINGS_H
25 #include "llvm-c/Object.h"
26 #include "llvm-c/Support.h"
27 #include "llvm-c/TargetMachine.h"
33 typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef;
34 typedef uint32_t LLVMOrcModuleHandle;
35 typedef uint64_t LLVMOrcTargetAddress;
36 typedef uint64_t (*LLVMOrcSymbolResolverFn)(const char *Name,
40 * Create an ORC JIT stack.
42 * The client owns the resulting stack, and must call OrcDisposeInstance(...)
43 * to destroy it and free its memory. The JIT stack will take ownership of the
44 * TargetMachine, which will be destroyed when the stack is destroyed. The
45 * client should not attempt to dispose of the Target Machine, or it will result
48 LLVMOrcJITStackRef LLVMOrcCreateInstance(LLVMTargetMachineRef TM,
49 LLVMContextRef Context);
52 * Mangle the given symbol.
53 * Memory will be allocated for MangledSymbol to hold the result. The client
55 void LLVMOrcGetMangledSymbol(LLVMOrcJITStackRef JITStack, char **MangledSymbol,
59 * Dispose of a mangled symbol.
62 void LLVMOrcDisposeMangledSymbol(char *MangledSymbol);
65 * Add module to be eagerly compiled.
68 LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
69 LLVMOrcSymbolResolverFn SymbolResolver,
70 void *SymbolResolverCtx);
73 * Add module to be lazily compiled one function at a time.
76 LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
77 LLVMOrcSymbolResolverFn SymbolResolver,
78 void *SymbolResolverCtx);
84 LLVMOrcAddObjectFile(LLVMOrcJITStackRef JITStack, LLVMObjectFileRef Obj,
85 LLVMOrcSymbolResolverFn SymbolResolver,
86 void *SymbolResolverCtx);
89 * Remove a module set from the JIT.
91 * This works for all modules that can be added via OrcAdd*, including object
94 void LLVMOrcRemoveModule(LLVMOrcJITStackRef JITStack, LLVMOrcModuleHandle H);
97 * Get symbol address from JIT instance.
99 LLVMOrcTargetAddress LLVMOrcGetSymbolAddress(LLVMOrcJITStackRef JITStack,
100 const char *SymbolName);
103 * Dispose of an ORC JIT stack.
105 void LLVMOrcDisposeInstance(LLVMOrcJITStackRef JITStack);
109 #endif /* extern "C" */
111 #endif /* LLVM_C_ORCBINDINGS_H */