LLVM  12.0.0git
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
llvm::orc::LLJIT Class Reference

A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT. More...

#include "llvm/ExecutionEngine/Orc/LLJIT.h"

Inheritance diagram for llvm::orc::LLJIT:
Inheritance graph
[legend]
Collaboration diagram for llvm::orc::LLJIT:
Collaboration graph
[legend]

Classes

class  PlatformSupport
 Initializer support for LLJIT. More...
 

Public Member Functions

 ~LLJIT ()
 Destruct this instance. More...
 
ExecutionSessiongetExecutionSession ()
 Returns the ExecutionSession for this instance. More...
 
const TriplegetTargetTriple () const
 Returns a reference to the triple for this instance. More...
 
const DataLayoutgetDataLayout () const
 Returns a reference to the DataLayout for this instance. More...
 
JITDylibgetMainJITDylib ()
 Returns a reference to the JITDylib representing the JIT'd main program. More...
 
JITDylibgetJITDylibByName (StringRef Name)
 Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists. More...
 
Expected< JITDylib & > createJITDylib (std::string Name)
 Create a new JITDylib with the given name and return a reference to it. More...
 
template<typename MUType >
Error define (std::unique_ptr< MUType > &&MU)
 A convenience method for defining MUs in LLJIT's Main JITDylib. More...
 
template<typename MUType >
Error define (std::unique_ptr< MUType > &MU)
 A convenience method for defining MUs in LLJIT's Main JITDylib. More...
 
Error addIRModule (JITDylib &JD, ThreadSafeModule TSM)
 Adds an IR module to the given JITDylib. More...
 
Error addIRModule (ThreadSafeModule TSM)
 Adds an IR module to the Main JITDylib. More...
 
Error addObjectFile (JITDylib &JD, std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib. More...
 
Error addObjectFile (std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib. More...
 
Expected< JITEvaluatedSymbollookupLinkerMangled (JITDylib &JD, SymbolStringPtr Name)
 Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead). More...
 
Expected< JITEvaluatedSymbollookupLinkerMangled (JITDylib &JD, StringRef Name)
 Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead). More...
 
Expected< JITEvaluatedSymbollookupLinkerMangled (StringRef Name)
 Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead). More...
 
Expected< JITEvaluatedSymbollookup (JITDylib &JD, StringRef UnmangledName)
 Look up a symbol in JITDylib JD based on its IR symbol name. More...
 
Expected< JITEvaluatedSymbollookup (StringRef UnmangledName)
 Look up a symbol in the main JITDylib based on its IR symbol name. More...
 
void setPlatformSupport (std::unique_ptr< PlatformSupport > PS)
 Set the PlatformSupport instance. More...
 
PlatformSupportgetPlatformSupport ()
 Get the PlatformSupport instance. More...
 
Error initialize (JITDylib &JD)
 Run the initializers for the given JITDylib. More...
 
Error deinitialize (JITDylib &JD)
 Run the deinitializers for the given JITDylib. More...
 
ObjectLayergetObjLinkingLayer ()
 Returns a reference to the ObjLinkingLayer. More...
 
ObjectTransformLayergetObjTransformLayer ()
 Returns a reference to the object transform layer. More...
 
IRTransformLayergetIRTransformLayer ()
 Returns a reference to the IR transform layer. More...
 
IRCompileLayergetIRCompileLayer ()
 Returns a reference to the IR compile layer. More...
 
std::string mangle (StringRef UnmangledName) const
 Returns a linker-mangled version of UnmangledName. More...
 
SymbolStringPtr mangleAndIntern (StringRef UnmangledName) const
 Returns an interned, linker-mangled version of UnmangledName. More...
 

Protected Member Functions

 LLJIT (LLJITBuilderState &S, Error &Err)
 Create an LLJIT instance with a single compile thread. More...
 
Error applyDataLayout (Module &M)
 
void recordCtorDtors (Module &M)
 

Static Protected Member Functions

static std::unique_ptr< ObjectLayercreateObjectLinkingLayer (LLJITBuilderState &S, ExecutionSession &ES)
 
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction (LLJITBuilderState &S, JITTargetMachineBuilder JTMB)
 

Protected Attributes

std::unique_ptr< ExecutionSessionES
 
std::unique_ptr< PlatformSupportPS
 
JITDylibMain = nullptr
 
DataLayout DL
 
Triple TT
 
std::unique_ptr< ThreadPoolCompileThreads
 
std::unique_ptr< ObjectLayerObjLinkingLayer
 
ObjectTransformLayer ObjTransformLayer
 
std::unique_ptr< IRCompileLayerCompileLayer
 
std::unique_ptr< IRTransformLayerTransformLayer
 
std::unique_ptr< IRTransformLayerInitHelperTransformLayer
 

Friends

template<typename , typename , typename >
class LLJITBuilderSetters
 
void setUpGenericLLVMIRPlatform (LLJIT &J)
 Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables and (if present) build initialization and deinitialization functions. More...
 

Detailed Description

A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.

Create instances using LLJITBuilder.

Definition at line 36 of file LLJIT.h.

Constructor & Destructor Documentation

◆ ~LLJIT()

llvm::orc::LLJIT::~LLJIT ( )

Destruct this instance.

If a multi-threaded instance, waits for all compile threads to complete.

Definition at line 990 of file LLJIT.cpp.

◆ LLJIT()

llvm::orc::LLJIT::LLJIT ( LLJITBuilderState S,
Error Err 
)
protected

Create an LLJIT instance with a single compile thread.

Definition at line 1062 of file LLJIT.cpp.

Referenced by mangleAndIntern().

Member Function Documentation

◆ addIRModule() [1/2]

Error llvm::orc::LLJIT::addIRModule ( JITDylib JD,
ThreadSafeModule  TSM 
)

Adds an IR module to the given JITDylib.

Definition at line 995 of file LLJIT.cpp.

References assert().

Referenced by addIRModule(), and define().

◆ addIRModule() [2/2]

Error llvm::orc::LLJIT::addIRModule ( ThreadSafeModule  TSM)
inline

Adds an IR module to the Main JITDylib.

Definition at line 108 of file LLJIT.h.

References addIRModule(), addObjectFile(), and Main.

◆ addObjectFile() [1/2]

Error llvm::orc::LLJIT::addObjectFile ( JITDylib JD,
std::unique_ptr< MemoryBuffer Obj 
)

Adds an object file to the given JITDylib.

Definition at line 1006 of file LLJIT.cpp.

References assert().

Referenced by addIRModule(), and addObjectFile().

◆ addObjectFile() [2/2]

Error llvm::orc::LLJIT::addObjectFile ( std::unique_ptr< MemoryBuffer Obj)
inline

Adds an object file to the given JITDylib.

Definition at line 116 of file LLJIT.h.

References addObjectFile(), lookupLinkerMangled(), Main, and Name.

◆ applyDataLayout()

Error llvm::orc::LLJIT::applyDataLayout ( Module M)
protected

◆ createCompileFunction()

Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > llvm::orc::LLJIT::createCompileFunction ( LLJITBuilderState S,
JITTargetMachineBuilder  JTMB 
)
staticprotected

◆ createJITDylib()

Expected<JITDylib &> llvm::orc::LLJIT::createJITDylib ( std::string  Name)
inline

Create a new JITDylib with the given name and return a reference to it.

JITDylib names must be unique. If the given name is derived from user input or elsewhere in the environment then the client should check (e.g. by calling getJITDylibByName) that the given name is not already in use.

Definition at line 84 of file LLJIT.h.

References ES.

◆ createObjectLinkingLayer()

std::unique_ptr< ObjectLayer > llvm::orc::LLJIT::createObjectLinkingLayer ( LLJITBuilderState S,
ExecutionSession ES 
)
staticprotected

◆ define() [1/2]

template<typename MUType >
Error llvm::orc::LLJIT::define ( std::unique_ptr< MUType > &&  MU)
inline

A convenience method for defining MUs in LLJIT's Main JITDylib.

This can be useful for succinctly defining absolute symbols, aliases and re-exports.

Definition at line 92 of file LLJIT.h.

References llvm::orc::JITDylib::define(), and Main.

◆ define() [2/2]

template<typename MUType >
Error llvm::orc::LLJIT::define ( std::unique_ptr< MUType > &  MU)
inline

A convenience method for defining MUs in LLJIT's Main JITDylib.

This can be usedful for succinctly defining absolute symbols, aliases and re-exports.

Definition at line 100 of file LLJIT.h.

References addIRModule(), llvm::orc::JITDylib::define(), and Main.

◆ deinitialize()

Error llvm::orc::LLJIT::deinitialize ( JITDylib JD)
inline

Run the deinitializers for the given JITDylib.

Definition at line 168 of file LLJIT.h.

References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::orc::JITDylib::getName(), and PS.

◆ getDataLayout()

const DataLayout& llvm::orc::LLJIT::getDataLayout ( ) const
inline

Returns a reference to the DataLayout for this instance.

Definition at line 67 of file LLJIT.h.

References DL.

◆ getExecutionSession()

ExecutionSession& llvm::orc::LLJIT::getExecutionSession ( )
inline

Returns the ExecutionSession for this instance.

Definition at line 61 of file LLJIT.h.

References ES.

◆ getIRCompileLayer()

IRCompileLayer& llvm::orc::LLJIT::getIRCompileLayer ( )
inline

Returns a reference to the IR compile layer.

Definition at line 187 of file LLJIT.h.

References CompileLayer, and mangle().

◆ getIRTransformLayer()

IRTransformLayer& llvm::orc::LLJIT::getIRTransformLayer ( )
inline

Returns a reference to the IR transform layer.

Definition at line 184 of file LLJIT.h.

References TransformLayer.

◆ getJITDylibByName()

JITDylib* llvm::orc::LLJIT::getJITDylibByName ( StringRef  Name)
inline

Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.

Definition at line 74 of file LLJIT.h.

References ES.

◆ getMainJITDylib()

JITDylib& llvm::orc::LLJIT::getMainJITDylib ( )
inline

Returns a reference to the JITDylib representing the JIT'd main program.

Definition at line 70 of file LLJIT.h.

References Main.

Referenced by llvm::orc::setUpMachOPlatform().

◆ getObjLinkingLayer()

ObjectLayer& llvm::orc::LLJIT::getObjLinkingLayer ( )
inline

Returns a reference to the ObjLinkingLayer.

Definition at line 178 of file LLJIT.h.

References ObjLinkingLayer.

◆ getObjTransformLayer()

ObjectTransformLayer& llvm::orc::LLJIT::getObjTransformLayer ( )
inline

Returns a reference to the object transform layer.

Definition at line 181 of file LLJIT.h.

References ObjTransformLayer.

◆ getPlatformSupport()

PlatformSupport* llvm::orc::LLJIT::getPlatformSupport ( )
inline

Get the PlatformSupport instance.

Definition at line 155 of file LLJIT.h.

References PS.

◆ getTargetTriple()

const Triple& llvm::orc::LLJIT::getTargetTriple ( ) const
inline

Returns a reference to the triple for this instance.

Definition at line 64 of file LLJIT.h.

References TT.

◆ initialize()

Error llvm::orc::LLJIT::initialize ( JITDylib JD)
inline

Run the initializers for the given JITDylib.

Definition at line 158 of file LLJIT.h.

References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::orc::JITDylib::getName(), and PS.

◆ lookup() [1/2]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookup ( JITDylib JD,
StringRef  UnmangledName 
)
inline

Look up a symbol in JITDylib JD based on its IR symbol name.

Definition at line 140 of file LLJIT.h.

References lookupLinkerMangled(), and mangle().

Referenced by lookup().

◆ lookup() [2/2]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookup ( StringRef  UnmangledName)
inline

Look up a symbol in the main JITDylib based on its IR symbol name.

Definition at line 145 of file LLJIT.h.

References lookup(), and Main.

◆ lookupLinkerMangled() [1/3]

Expected< JITEvaluatedSymbol > llvm::orc::LLJIT::lookupLinkerMangled ( JITDylib JD,
SymbolStringPtr  Name 
)

Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead).

Definition at line 1012 of file LLJIT.cpp.

References llvm::orc::makeJITDylibSearchOrder(), and llvm::orc::MatchAllSymbols.

Referenced by addObjectFile(), lookup(), and lookupLinkerMangled().

◆ lookupLinkerMangled() [2/3]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookupLinkerMangled ( JITDylib JD,
StringRef  Name 
)
inline

Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead).

Definition at line 127 of file LLJIT.h.

References ES, and lookupLinkerMangled().

◆ lookupLinkerMangled() [3/3]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookupLinkerMangled ( StringRef  Name)
inline

Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead).

Definition at line 135 of file LLJIT.h.

References lookupLinkerMangled(), and Main.

◆ mangle()

std::string llvm::orc::LLJIT::mangle ( StringRef  UnmangledName) const

Returns a linker-mangled version of UnmangledName.

Definition at line 1123 of file LLJIT.cpp.

References DL, and llvm::Mangler::getNameWithPrefix().

Referenced by getIRCompileLayer(), lookup(), and mangleAndIntern().

◆ mangleAndIntern()

SymbolStringPtr llvm::orc::LLJIT::mangleAndIntern ( StringRef  UnmangledName) const
inline

Returns an interned, linker-mangled version of UnmangledName.

Definition at line 193 of file LLJIT.h.

References createCompileFunction(), createObjectLinkingLayer(), ES, LLJIT(), and mangle().

◆ recordCtorDtors()

void llvm::orc::LLJIT::recordCtorDtors ( Module M)
protected

◆ setPlatformSupport()

void llvm::orc::LLJIT::setPlatformSupport ( std::unique_ptr< PlatformSupport PS)
inline

Set the PlatformSupport instance.

Definition at line 150 of file LLJIT.h.

Referenced by llvm::orc::setUpGenericLLVMIRPlatform(), and llvm::orc::setUpMachOPlatform().

Friends And Related Function Documentation

◆ LLJITBuilderSetters

template<typename , typename , typename >
friend class LLJITBuilderSetters
friend

Definition at line 37 of file LLJIT.h.

◆ setUpGenericLLVMIRPlatform

void setUpGenericLLVMIRPlatform ( LLJIT J)
friend

Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables and (if present) build initialization and deinitialization functions.

Platform specific initialization configurations should be preferred where available.

Definition at line 1146 of file LLJIT.cpp.

Member Data Documentation

◆ CompileLayer

std::unique_ptr<IRCompileLayer> llvm::orc::LLJIT::CompileLayer
protected

Definition at line 222 of file LLJIT.h.

Referenced by getIRCompileLayer().

◆ CompileThreads

std::unique_ptr<ThreadPool> llvm::orc::LLJIT::CompileThreads
protected

Definition at line 218 of file LLJIT.h.

◆ DL

DataLayout llvm::orc::LLJIT::DL
protected

Definition at line 216 of file LLJIT.h.

Referenced by applyDataLayout(), getDataLayout(), and mangle().

◆ ES

std::unique_ptr<ExecutionSession> llvm::orc::LLJIT::ES
protected

◆ InitHelperTransformLayer

std::unique_ptr<IRTransformLayer> llvm::orc::LLJIT::InitHelperTransformLayer
protected

Definition at line 224 of file LLJIT.h.

Referenced by llvm::orc::LLJIT::PlatformSupport::setInitTransform().

◆ Main

JITDylib* llvm::orc::LLJIT::Main = nullptr
protected

◆ ObjLinkingLayer

std::unique_ptr<ObjectLayer> llvm::orc::LLJIT::ObjLinkingLayer
protected

Definition at line 220 of file LLJIT.h.

Referenced by getObjLinkingLayer().

◆ ObjTransformLayer

ObjectTransformLayer llvm::orc::LLJIT::ObjTransformLayer
protected

Definition at line 221 of file LLJIT.h.

Referenced by getObjTransformLayer().

◆ PS

std::unique_ptr<PlatformSupport> llvm::orc::LLJIT::PS
protected

Definition at line 212 of file LLJIT.h.

Referenced by deinitialize(), getPlatformSupport(), and initialize().

◆ TransformLayer

std::unique_ptr<IRTransformLayer> llvm::orc::LLJIT::TransformLayer
protected

Definition at line 223 of file LLJIT.h.

Referenced by getIRTransformLayer().

◆ TT

Triple llvm::orc::LLJIT::TT
protected

Definition at line 217 of file LLJIT.h.

Referenced by getTargetTriple().


The documentation for this class was generated from the following files: