21#include <llvm-c/Core.h>
22#include <llvm-c/Error.h>
23#include <llvm-c/LLJIT.h>
24#include <llvm-c/Support.h>
25#include <llvm-c/Target.h>
37 char *err_msg = LLVMGetErrorMessage(err);
38 UNUSED(fprintf(stderr,
"Error: %s\n", err_msg));
39 LLVMDisposeErrorMessage(err_msg);
61 LLVMInitializeNativeTarget();
62 LLVMInitializeNativeAsmPrinter();
64 LLVMErrorRef err =
nullptr;
81 LLVMErrorRef err = LLVMOrcDisposeLLJIT(jit->
llvm_jit);
92 LLVMOrcLLJITRef j = ctx->
engine->jit->llvm_jit;
94 LLVMOrcJITDylibRef jd = LLVMOrcLLJITGetMainJITDylib(j);
95 LLVMErrorRef err = LLVMOrcLLJITAddLLVMIRModule(j, jd, module->
tsm);
106 char *jit_err_msg = LLVMGetErrorMessage(err);
107 char *msg =
srn_copy_bytes(ctx, jit_err_msg, strlen(jit_err_msg) + 1,
alignof(
char));
109 LLVMDisposeErrorMessage(jit_err_msg);
srn_error_t * srn_errors_make(const srn_context_t *ctx, srn_error_tag_t tag, const char *msg)
Build an error in ctx's memory, tagged tag and carrying msg.
#define srn_mm_immortal_allocate(mm, T)
int srn_jit_shutdown(srn_jit_t *jit)
srn_jit_t * srn_jit_make(srn_mm_t *mm)
static int handle_error(LLVMErrorRef err)
srn_error_t * srn_jit_add_module(srn_context_t *ctx, srn_jit_module_t *module)
Add a module to the jit compiler.
int srn_jit_init(srn_jit_t *result)
Creates a jit engine and sets the given result to it.
srn_engine_t * engine
Long term state of the compiler.
A runtime error, a tag classifying the failure and a human-readable message.
LLVMOrcThreadSafeModuleRef tsm
LLVMOrcLLJITBuilderRef builder
Main memory manager structure that will own all the allocated blocks and data.
#define PANIC_IF_NULL(ptr)
char * srn_copy_bytes(const srn_context_t *ctx, const char *src, size_t len, size_t alignment)