Path: blob/main/contrib/llvm-project/llvm/include/llvm-c/OrcEE.h
35233 views
/*===-- llvm-c/OrcEE.h - OrcV2 C bindings ExecutionEngine utils -*- C++ -*-===*\1|* *|2|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|3|* Exceptions. *|4|* See https://llvm.org/LICENSE.txt for license information. *|5|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|6|* *|7|*===----------------------------------------------------------------------===*|8|* *|9|* This header declares the C interface to ExecutionEngine based utils, e.g. *|10|* RTDyldObjectLinkingLayer (based on RuntimeDyld) in Orc. *|11|* *|12|* Many exotic languages can interoperate with C code but have a harder time *|13|* with C++ due to name mangling. So in addition to C, this interface enables *|14|* tools written in such languages. *|15|* *|16|* Note: This interface is experimental. It is *NOT* stable, and may be *|17|* changed without warning. Only C API usage documentation is *|18|* provided. See the C++ documentation for all higher level ORC API *|19|* details. *|20|* *|21\*===----------------------------------------------------------------------===*/2223#ifndef LLVM_C_ORCEE_H24#define LLVM_C_ORCEE_H2526#include "llvm-c/Error.h"27#include "llvm-c/ExecutionEngine.h"28#include "llvm-c/Orc.h"29#include "llvm-c/TargetMachine.h"30#include "llvm-c/Types.h"3132LLVM_C_EXTERN_C_BEGIN3334typedef void *(*LLVMMemoryManagerCreateContextCallback)(void *CtxCtx);35typedef void (*LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx);3637/**38* @defgroup LLVMCExecutionEngineORCEE ExecutionEngine-based ORC Utils39* @ingroup LLVMCExecutionEngine40*41* @{42*/4344/**45* Create a RTDyldObjectLinkingLayer instance using the standard46* SectionMemoryManager for memory management.47*/48LLVMOrcObjectLayerRef49LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(50LLVMOrcExecutionSessionRef ES);5152/**53* Create a RTDyldObjectLinkingLayer instance using MCJIT-memory-manager-like54* callbacks.55*56* This is intended to simplify transitions for existing MCJIT clients. The57* callbacks used are similar (but not identical) to the callbacks for58* LLVMCreateSimpleMCJITMemoryManager: Unlike MCJIT, RTDyldObjectLinkingLayer59* will create a new memory manager for each object linked by calling the given60* CreateContext callback. This allows for code removal by destroying each61* allocator individually. Every allocator will be destroyed (if it has not been62* already) at RTDyldObjectLinkingLayer destruction time, and the63* NotifyTerminating callback will be called to indicate that no further64* allocation contexts will be created.65*66* To implement MCJIT-like behavior clients can implement CreateContext,67* NotifyTerminating, and Destroy as:68*69* void *CreateContext(void *CtxCtx) { return CtxCtx; }70* void NotifyTerminating(void *CtxCtx) { MyOriginalDestroy(CtxCtx); }71* void Destroy(void *Ctx) { }72*73* This scheme simply reuses the CreateContextCtx pointer as the one-and-only74* allocation context.75*/76LLVMOrcObjectLayerRef77LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks(78LLVMOrcExecutionSessionRef ES, void *CreateContextCtx,79LLVMMemoryManagerCreateContextCallback CreateContext,80LLVMMemoryManagerNotifyTerminatingCallback NotifyTerminating,81LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection,82LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection,83LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory,84LLVMMemoryManagerDestroyCallback Destroy);8586/**87* Add the given listener to the given RTDyldObjectLinkingLayer.88*89* Note: Layer must be an RTDyldObjectLinkingLayer instance or90* behavior is undefined.91*/92void LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(93LLVMOrcObjectLayerRef RTDyldObjLinkingLayer,94LLVMJITEventListenerRef Listener);9596/**97* @}98*/99100LLVM_C_EXTERN_C_END101102#endif /* LLVM_C_ORCEE_H */103104105