aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/2022-07-07-llvm-orc-jit/jit.h
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-12-19 18:53:31 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-12-19 18:54:35 +0100
commita599959a61e2a9ae313b851b2b63c0a2b97d3cb5 (patch)
treece0b3346b48df0926560c305394ff04b86fcccb3 /content/2022-07-07-llvm-orc-jit/jit.h
parent34fe7e1b93f73dc8ffb42cc172f4a9966453faa9 (diff)
downloadblog-a599959a61e2a9ae313b851b2b63c0a2b97d3cb5.tar.gz
blog-a599959a61e2a9ae313b851b2b63c0a2b97d3cb5.zip
llvm-orc-jit: migrate to llvm17
Diffstat (limited to 'content/2022-07-07-llvm-orc-jit/jit.h')
-rw-r--r--content/2022-07-07-llvm-orc-jit/jit.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/content/2022-07-07-llvm-orc-jit/jit.h b/content/2022-07-07-llvm-orc-jit/jit.h
index 10d6d4a..9ac7b0a 100644
--- a/content/2022-07-07-llvm-orc-jit/jit.h
+++ b/content/2022-07-07-llvm-orc-jit/jit.h
@@ -9,21 +9,25 @@
#include <llvm/ExecutionEngine/Orc/IRCompileLayer.h>
#include <llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h>
#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
+#include <llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h>
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
#include <llvm/IR/DataLayout.h>
#include <llvm/IR/LLVMContext.h>
namespace jit {
-
+using llvm::cantFail;
using llvm::DataLayout;
using llvm::Expected;
using llvm::JITEvaluatedSymbol;
+using llvm::JITSymbolFlags;
using llvm::SectionMemoryManager;
using llvm::StringRef;
using llvm::orc::ConcurrentIRCompiler;
// using llvm::orc::DynamicLibrarySearchGenerator;
using llvm::orc::ExecutionSession;
+using llvm::orc::ExecutorAddr;
+using llvm::orc::ExecutorSymbolDef;
using llvm::orc::IRCompileLayer;
using llvm::orc::JITDylib;
using llvm::orc::JITTargetMachineBuilder;
@@ -45,23 +49,25 @@ private:
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer CompileLayer;
- JITDylib &JD;
+ JITDylib& JD;
public:
Jit(std::unique_ptr<ExecutionSession> ES, JITTargetMachineBuilder JTMB,
- DataLayout DL)
- : ES(std::move(ES)), DL(std::move(DL)), Mangle(*this->ES, this->DL),
- ObjectLayer(*this->ES,
- []() { return std::make_unique<SectionMemoryManager>(); }),
- CompileLayer(*this->ES, ObjectLayer,
- std::make_unique<ConcurrentIRCompiler>(std::move(JTMB))),
- JD(this->ES->createBareJITDylib("main")) {
+ DataLayout DL) :
+ ES(std::move(ES)),
+ DL(std::move(DL)), Mangle(*this->ES, this->DL),
+ ObjectLayer(*this->ES,
+ []() { return std::make_unique<SectionMemoryManager>(); }),
+ CompileLayer(*this->ES, ObjectLayer,
+ std::make_unique<ConcurrentIRCompiler>(std::move(JTMB))),
+ JD(this->ES->createBareJITDylib("main")) {
// https://www.llvm.org/docs/ORCv2.html#how-to-add-process-and-library-symbols-to-jitdylibs
// JD.addGenerator(
// cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
// DL.getGlobalPrefix())));
- (void)JD.define(llvm::orc::absoluteSymbols(
- {{Mangle("libc_puts"), llvm::JITEvaluatedSymbol::fromPointer(&puts)}}));
+ cantFail(JD.define(llvm::orc::absoluteSymbols(
+ {{Mangle("libc_puts"),
+ {ExecutorAddr::fromPtr(&puts), JITSymbolFlags::Exported}}})));
}
~Jit() {
@@ -81,7 +87,6 @@ public:
return std::make_unique<Jit>(std::move(ES), std::move(JTMB), std::move(DL));
}
- // Error addModule(ThreadSafeModule TSM) {
Expected<ResourceTrackerSP> addModule(ThreadSafeModule TSM) {
auto RT = JD.createResourceTracker();
if (auto E = CompileLayer.add(RT, std::move(TSM))) {
@@ -90,11 +95,11 @@ public:
return RT;
}
- Expected<JITEvaluatedSymbol> lookup(StringRef Name) {
+ Expected<ExecutorSymbolDef> lookup(StringRef Name) {
return ES->lookup({&JD}, Mangle(Name.str()));
}
};
-} // namespace jit
+} // namespace jit
#endif