25 friend class JITMapperImpl;
27 std::unique_ptr<JITMapperImpl> impl;
30 explicit JITMapper(std::unique_ptr<JITMapperImpl> impl);
33 JITMapper(
const JITMapper &) =
delete;
34 JITMapper(JITMapper &&other);
36 JITMapper &operator=(
const JITMapper &) =
delete;
37 JITMapper &operator=(JITMapper &&other);
44 operator bool()
const {
return impl !=
nullptr; }
50 LLVMCompiler() =
default;
53 virtual ~LLVMCompiler();
55 LLVMCompiler(
const LLVMCompiler &) =
delete;
56 LLVMCompiler &operator=(
const LLVMCompiler &) =
delete;
61 static std::unique_ptr<LLVMCompiler>
create(
const llvm::Triple &triple);
66 virtual bool compile_to_elf(llvm::Module &mod, std::vector<uint8_t> &buf) = 0;
73 std::function<
void *(std::string_view)> resolver) = 0;
In-memory mapper for JIT execution.
void * lookup_global(llvm::GlobalValue *)
Get the address for a global, which must be contained in the compiled module.
virtual JITMapper compile_and_map(llvm::Module &mod, std::function< void *(std::string_view)> resolver)=0
Compile the module and map it into memory, calling resolver to resolve references to external symbols...
virtual bool compile_to_elf(llvm::Module &mod, std::vector< uint8_t > &buf)=0
Compile the module to an object file and emit it into the buffer.
static std::unique_ptr< LLVMCompiler > create(const llvm::Triple &triple)
Create a compiler for the specified target triple; returns null if the triple is not supported.