LLVM 22.0.0git
OrcEE.h
Go to the documentation of this file.
1/*===-- llvm-c/OrcEE.h - OrcV2 C bindings ExecutionEngine utils -*- 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 ExecutionEngine based utils, e.g. *|
11|* RTDyldObjectLinkingLayer (based on RuntimeDyld) in Orc. *|
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|* Note: This interface is experimental. It is *NOT* stable, and may be *|
18|* changed without warning. Only C API usage documentation is *|
19|* provided. See the C++ documentation for all higher level ORC API *|
20|* details. *|
21|* *|
22\*===----------------------------------------------------------------------===*/
23
24#ifndef LLVM_C_ORCEE_H
25#define LLVM_C_ORCEE_H
26
27#include "llvm-c/Error.h"
29#include "llvm-c/Orc.h"
31#include "llvm-c/Types.h"
32#include "llvm-c/Visibility.h"
33
35
36typedef void *(*LLVMMemoryManagerCreateContextCallback)(void *CtxCtx);
37typedef void (*LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx);
38
39/**
40 * @defgroup LLVMCExecutionEngineORCEE ExecutionEngine-based ORC Utils
41 * @ingroup LLVMCExecutionEngine
42 *
43 * @{
44 */
45
46/**
47 * Create a RTDyldObjectLinkingLayer instance using the standard
48 * SectionMemoryManager for memory management.
49 */
53
54/**
55 * Create a RTDyldObjectLinkingLayer instance using MCJIT-memory-manager-like
56 * callbacks.
57 *
58 * This is intended to simplify transitions for existing MCJIT clients. The
59 * callbacks used are similar (but not identical) to the callbacks for
60 * LLVMCreateSimpleMCJITMemoryManager: Unlike MCJIT, RTDyldObjectLinkingLayer
61 * will create a new memory manager for each object linked by calling the given
62 * CreateContext callback. This allows for code removal by destroying each
63 * allocator individually. Every allocator will be destroyed (if it has not been
64 * already) at RTDyldObjectLinkingLayer destruction time, and the
65 * NotifyTerminating callback will be called to indicate that no further
66 * allocation contexts will be created.
67 *
68 * To implement MCJIT-like behavior clients can implement CreateContext,
69 * NotifyTerminating, and Destroy as:
70 *
71 * void *CreateContext(void *CtxCtx) { return CtxCtx; }
72 * void NotifyTerminating(void *CtxCtx) { MyOriginalDestroy(CtxCtx); }
73 * void Destroy(void *Ctx) { }
74 *
75 * This scheme simply reuses the CreateContextCtx pointer as the one-and-only
76 * allocation context.
77 */
80 LLVMOrcExecutionSessionRef ES, void *CreateContextCtx,
87
88/**
89 * Add the given listener to the given RTDyldObjectLinkingLayer.
90 *
91 * Note: Layer must be an RTDyldObjectLinkingLayer instance or
92 * behavior is undefined.
93 */
95 LLVMOrcObjectLayerRef RTDyldObjLinkingLayer,
97
98/**
99 * @}
100 */
101
103
104#endif /* LLVM_C_ORCEE_H */
#define LLVM_C_EXTERN_C_BEGIN
Definition ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition ExternC.h:36
LLVM_C_EXTERN_C_BEGIN typedef void *(* LLVMMemoryManagerCreateContextCallback)(void *CtxCtx)
Definition OrcEE.h:36
void(* LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx)
Definition OrcEE.h:37
#define LLVM_C_ABI
LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...
Definition Visibility.h:40
LLVM_C_ABI void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(LLVMOrcObjectLayerRef RTDyldObjLinkingLayer, LLVMJITEventListenerRef Listener)
Add the given listener to the given RTDyldObjectLinkingLayer.
LLVM_C_ABI LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
Create a RTDyldObjectLinkingLayer instance using the standard SectionMemoryManager for memory managem...
LLVM_C_ABI LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks(LLVMOrcExecutionSessionRef ES, void *CreateContextCtx, LLVMMemoryManagerCreateContextCallback CreateContext, LLVMMemoryManagerNotifyTerminatingCallback NotifyTerminating, LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection, LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection, LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory, LLVMMemoryManagerDestroyCallback Destroy)
Create a RTDyldObjectLinkingLayer instance using MCJIT-memory-manager-like callbacks.
struct LLVMOrcOpaqueExecutionSession * LLVMOrcExecutionSessionRef
A reference to an orc::ExecutionSession instance.
Definition Orc.h:89
struct LLVMOrcOpaqueObjectLayer * LLVMOrcObjectLayerRef
A reference to an orc::ObjectLayer instance.
Definition Orc.h:410
void(* LLVMMemoryManagerDestroyCallback)(void *Opaque)
LLVMBool(* LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg)
uint8_t *(* LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName, LLVMBool IsReadOnly)
uint8_t *(* LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, const char *SectionName)
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition Types.h:165