2 #include <JitCpp/Compiler/Compiler.hpp>
4 #include <llvm/ExecutionEngine/ExecutionEngine.h>
5 #include <llvm/Support/PrettyStackTrace.h>
12 Driver(
const std::string& fname)
14 , ts_ctx{std::make_unique<llvm::LLVMContext>()}
19 template <
typename Fun_T>
20 std::function<Fun_T> operator()(
21 const std::string& sourceCode,
const std::vector<std::string>& flags,
24 auto t0 = std::chrono::high_resolution_clock::now();
26 auto sourceFileName = saveSourceFile(sourceCode);
30 std::string cpp = *sourceFileName;
31 auto filename = QFileInfo(QString::fromStdString(cpp)).fileName();
33 qDebug(
"Compiling...");
34 jit.compile(cpp, flags, opts, ts_ctx);
35 auto t1 = std::chrono::high_resolution_clock::now();
37 if(!jit.errors().isEmpty())
39 throw std::runtime_error{jit.errors().toStdString()};
42 auto jitedFn = jit.getFunction<Fun_T>(factory_name);
49 std::cerr <<
"\n\nADDON BUILD DURATION: "
50 << std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0).count()
56 llvm::PrettyStackTraceProgram X;
57 llvm::LLVMContext context;
58 llvm::orc::ThreadSafeContext ts_ctx;
60 std::string factory_name;
Definition: Compiler.hpp:13
Definition: JitOptions.hpp:7
Definition: Driver.hpp:11
Definition: JitUtils.hpp:16