13 #ifndef LLVM_EXECUTIONENGINE_ORC_LLJIT_H 14 #define LLVM_EXECUTIONENGINE_ORC_LLJIT_H 29 class LLJITBuilderState;
30 class LLLazyJITBuilderState;
57 return ES->getJITDylibByName(Name);
67 return ES->createJITDylib(std::move(Name));
124 static std::unique_ptr<ObjectLayer>
139 std::unique_ptr<ExecutionSession>
ES;
162 TransformLayer->setTransform(std::move(Transform));
168 CODLayer->setPartitionFunction(std::move(Partition));
176 return addLazyIRModule(
Main, std::move(M));
184 std::unique_ptr<LazyCallThroughManager> LCTMgr;
185 std::unique_ptr<IRTransformLayer> TransformLayer;
186 std::unique_ptr<CompileOnDemandLayer> CODLayer;
195 std::function<Expected<std::unique_ptr<IRCompileLayer::IRCompiler>>(
198 std::unique_ptr<ExecutionSession>
ES;
202 unsigned NumCompileThreads = 0;
205 Error prepareForConstruction();
208 template <
typename JITType,
typename SetterImpl,
typename State>
216 impl().JTMB = std::move(JTMB);
232 impl().CreateObjectLinkingLayer = std::move(CreateObjectLinkingLayer);
244 impl().CreateCompileFunction = std::move(CreateCompileFunction);
257 impl().NumCompileThreads = NumCompileThreads;
263 if (
auto Err =
impl().prepareForConstruction())
264 return std::move(Err);
267 std::unique_ptr<JITType> J(
new JITType(
impl(), Err));
269 return std::move(Err);
274 SetterImpl &
impl() {
return static_cast<SetterImpl &
>(*this); }
287 std::function<std::unique_ptr<IndirectStubsManager>()>;
291 std::unique_ptr<LazyCallThroughManager>
LCTMgr;
294 Error prepareForConstruction();
297 template <
typename JITType,
typename SetterImpl,
typename State>
305 this->
impl().LazyCompileFailureAddr = Addr;
315 this->
impl().LCTMgr = std::move(LCTMgr);
325 this->
impl().ISMBuilder = std::move(ISMBuilder);
334 LLLazyJITBuilderState> {};
339 #endif // LLVM_EXECUTIONENGINE_ORC_LLJIT_H Constructs LLLazyJIT instances.
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this instance.
A parsed version of the target data layout string in and methods for querying it. ...
SetterImpl & setLazyCallthroughManager(std::unique_ptr< LazyCallThroughManager > LCTMgr)
Set the lazy-callthrough manager.
Error addObjectFile(std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
JITDylib & createJITDylib(std::string Name)
Create a new JITDylib with the given name and return a reference to it.
This class represents lattice values for constants.
Error defineAbsolute(StringRef Name, JITEvaluatedSymbol Address)
Convenience method for defining an absolute symbol.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLJIT(LLJITBuilderState &S, Error &Err)
Create an LLJIT instance with a single compile thread.
std::unique_ptr< ExecutionSession > ES
const DataLayout & getDataLayout() const
Returns a reference to the DataLayout for this instance.
Error addIRModule(JITDylib &JD, ThreadSafeModule TSM)
Adds an IR module to the given JITDylib.
Optional< JITTargetMachineBuilder > & getJITTargetMachineBuilder()
Return a reference to the JITTargetMachineBuilder.
Error runConstructors()
Runs all not-yet-run static constructors.
std::function< Optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
ObjectTransformLayer & getObjTransformLayer()
Returns a reference to the object transform layer.
Tagged union holding either a T or a Error.
SetterImpl & setIndirectStubsManagerBuilder(LLLazyJITBuilderState::IndirectStubsManagerBuilderFunction ISMBuilder)
Set the IndirectStubsManager builder function.
place backedge safepoints impl
CtorDtorRunner DtorRunner
SetterImpl & setObjectLinkingLayerCreator(LLJITBuilderState::ObjectLinkingLayerCreator CreateObjectLinkingLayer)
Set an ObjectLinkingLayer creation function.
ObjectLayer & getObjLinkingLayer()
Returns a reference to the ObjLinkingLayer.
std::function< Expected< std::unique_ptr< IRCompileLayer::IRCompiler > >(JITTargetMachineBuilder JTMB)> CompileFunctionCreator
SetterImpl & setNumCompileThreads(unsigned NumCompileThreads)
Set the number of compile threads to use.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Error addLazyIRModule(ThreadSafeModule M)
Add a module to be lazily compiled to the main JITDylib.
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction(LLJITBuilderState &S, JITTargetMachineBuilder JTMB)
std::function< std::unique_ptr< ObjectLayer >(ExecutionSession &, const Triple &TT)> ObjectLinkingLayerCreator
Error runDestructors()
Runs all not-yet-run static destructors.
Expected< JITEvaluatedSymbol > lookup(StringRef UnmangledName)
Look up a symbol in the main JITDylib based on its IR symbol name.
JITDylib * getJITDylibByName(StringRef Name)
Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists...
std::string mangle(StringRef UnmangledName)
std::unique_ptr< IRCompileLayer > CompileLayer
CompileFunctionCreator CreateCompileFunction
An LLVM Module together with a shared ThreadSafeContext.
CtorDtorRunner CtorRunner
Expected< JITEvaluatedSymbol > lookup(JITDylib &JD, StringRef UnmangledName)
Look up a symbol in JITDylib JD based on its IR symbol name.
void setLazyCompileTransform(IRTransformLayer::TransformFunction Transform)
Set an IR transform (e.g.
Triple - Helper class for working with autoconf configuration names.
ObjectLinkingLayerCreator CreateObjectLinkingLayer
SetterImpl & setJITTargetMachineBuilder(JITTargetMachineBuilder JTMB)
Set the JITTargetMachineBuilder for this instance.
SetterImpl & setLazyCompileFailureAddr(JITTargetAddress Addr)
Set the address in the target address to call if a lazy compile fails.
std::unique_ptr< ThreadPool > CompileThreads
std::unique_ptr< ExecutionSession > ES
static ErrorSuccess success()
Create a success value.
void recordCtorDtors(Module &M)
Expected< JITEvaluatedSymbol > lookupLinkerMangled(StringRef Name)
Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based o...
static Expected< std::unique_ptr< LLJIT > > Create(LLJITBuilderState &S)
Expected< std::unique_ptr< JITType > > create()
Create an instance of the JIT.
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilderFunction
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
An ExecutionSession represents a running JIT program.
An extended version of LLJIT that supports lazy function-at-a-time compilation of LLVM IR...
std::unique_ptr< ObjectLayer > ObjLinkingLayer
void setPartitionFunction(CompileOnDemandLayer::PartitionFunction Partition)
Sets the partition function.
Represents a symbol that has been evaluated to an address already.
Error addIRModule(ThreadSafeModule TSM)
Adds an IR module to the Main JITDylib.
Expected< JITEvaluatedSymbol > lookupLinkerMangled(JITDylib &JD, StringRef Name)
Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...
Error addObjectFile(JITDylib &JD, std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
Constructs LLJIT instances.
Error applyDataLayout(Module &M)
~LLJIT()
Destruct this instance.
SetterImpl & setCompileFunctionCreator(LLJITBuilderState::CompileFunctionCreator CreateCompileFunction)
Set a CompileFunctionCreator.
std::unique_ptr< LazyCallThroughManager > LCTMgr
Lightweight error class with error context and mandatory checking.
Interface for Layers that accept object files.
StringRef - Represent a constant reference to a string, i.e.
JITDylib & getMainJITDylib()
Returns a reference to the JITDylib representing the JIT'd main program.
static std::unique_ptr< ObjectLayer > createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES)
Optional< JITTargetMachineBuilder > JTMB
IndirectStubsManagerBuilderFunction ISMBuilder
ObjectTransformLayer ObjTransformLayer
A symbol table that supports asynchoronous symbol queries.
A utility class for building TargetMachines for JITs.