13 #ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H 14 #define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H 49 std::function<void(VModuleKey K, ThreadSafeModule TSM)>;
52 std::unique_ptr<IRCompiler> Compile);
61 mutable std::mutex IRLayerMutex;
63 std::unique_ptr<IRCompiler> Compile;
73 template <
typename BaseLayerT,
typename CompileFtor>
78 std::function<void(VModuleKey K, std::unique_ptr<Module>)>;
84 BaseLayerT &BaseLayer, CompileFtor Compile,
86 "ORCv1 layers (layers with the 'Legacy' prefix) are deprecated. Please " 88 "the ORCv2 IRCompileLayer instead");
95 : BaseLayer(BaseLayer), Compile(
std::move(Compile)),
96 NotifyCompiled(
std::move(NotifyCompiled)) {}
103 this->NotifyCompiled = std::move(NotifyCompiled);
109 auto Obj = Compile(*M);
111 return Obj.takeError();
112 if (
auto Err = BaseLayer.addObject(std::move(K), std::move(*Obj)))
115 NotifyCompiled(std::move(K), std::move(M));
127 return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
139 bool ExportedSymbolsOnly) {
140 return BaseLayer.findSymbolIn(K, Name, ExportedSymbolsOnly);
149 BaseLayerT &BaseLayer;
154 template <
typename BaseLayerT,
typename CompileFtor>
156 BaseLayerT &BaseLayer, CompileFtor Compile,
158 : BaseLayer(BaseLayer), Compile(std::move(Compile)),
159 NotifyCompiled(std::move(NotifyCompiled)) {}
164 #endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled)
Represents a symbol in the JIT.
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
IRMaterializationUnit::ManglingOptions & manglingOptions()
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void emit(MaterializationResponsibility R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
virtual Expected< std::unique_ptr< MemoryBuffer > > operator()(Module &M)=0
std::function< void(VModuleKey K, std::unique_ptr< Module >)> NotifyCompiledCallback
Callback type for notifications when modules are compiled.
Error removeModule(VModuleKey K)
Remove the module associated with the VModuleKey K.
Error emitAndFinalize(VModuleKey K)
Immediately emit and finalize the module represented by the given handle.
Tagged union holding either a T or a Error.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
IRCompiler & getCompiler()
JITSymbol findSymbolIn(VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly)
Get the address of the given symbol in compiled module represented by the handle H.
ORCv1DeprecationAcknowledgement
LegacyIRCompileLayer(ORCv1DeprecationAcknowledgement, BaseLayerT &BaseLayer, CompileFtor Compile, NotifyCompiledCallback NotifyCompiled=NotifyCompiledCallback())
Legacy layer constructor with deprecation acknowledgement.
An LLVM Module together with a shared ThreadSafeContext.
IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer, std::unique_ptr< IRCompiler > Compile)
Eager IR compiling layer.
Interface for layers that accept LLVM IR.
#define LLVM_ATTRIBUTE_DEPRECATED(decl, message)
static ErrorSuccess success()
Create a success value.
CompileFtor & getCompiler()
Get a reference to the compiler functor.
const IRMaterializationUnit::ManglingOptions & getManglingOptions() const
void setNotifyCompiled(NotifyCompiledCallback NotifyCompiled)
(Re)set the NotifyCompiled callback.
An ExecutionSession represents a running JIT program.
IRCompiler(IRMaterializationUnit::ManglingOptions MO)
uint8_t uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
Error addModule(VModuleKey K, std::unique_ptr< Module > M)
Compile the module, and add the resulting object to the base layer along with the given memory manage...
Lightweight error class with error context and mandatory checking.
Interface for Layers that accept object files.
std::function< void(VModuleKey K, ThreadSafeModule TSM)> NotifyCompiledFunction
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly)
Search for the given named symbol.