#include <llvm-c/LLJIT.h>
#include "serene/rt/errors.h"
Go to the source code of this file.
◆ srn_context_t
| typedef struct srn_context_t srn_context_t |
Definition at line 33 of file jit.h.
◆ srn_engine_t
| typedef struct srn_engine_t srn_engine_t |
Definition at line 25 of file jit.h.
◆ srn_jit_module_t
| typedef struct srn_jit_module_t srn_jit_module_t |
◆ srn_jit_t
| typedef struct srn_jit_t srn_jit_t |
◆ srn_mm_t
| typedef struct srn_mm_t srn_mm_t |
Definition at line 26 of file jit.h.
◆ srn_jit_add_module()
Add a module to the jit compiler.
Definition at line 83 of file jit.c.
83 {
86
87 LLVMOrcLLJITRef j = ctx->
engine->jit->llvm_jit;
88
89 LLVMOrcJITDylibRef jd = LLVMOrcLLJITGetMainJITDylib(j);
90 LLVMErrorRef err = LLVMOrcLLJITAddLLVMIRModule(j, jd, module->
tsm);
92
93 if (err != nullptr) {
94
95
96
97
98
99 char *jit_err_msg = LLVMGetErrorMessage(err);
100 char *msg =
srn_copy_bytes(ctx, jit_err_msg, strlen(jit_err_msg),
alignof(
char));
102 LLVMDisposeErrorMessage(jit_err_msg);
103 }
104 return srn_err;
105}
srn_error_t * srn_errors_make(const srn_context_t *ctx, srn_error_tag_t tag, const char *msg)
@ FAILED_TO_ADD_MODULE
Failed to add a module to the jit engine.
srn_engine_t * engine
Long term state of the compiler.
LLVMOrcThreadSafeModuleRef tsm
#define PANIC_IF_NULL(ptr)
char * srn_copy_bytes(srn_context_t *ctx, const char *src, size_t len, size_t alignment)
◆ srn_jit_init()
Creates a jit engine and sets the given result to it.
◆ srn_jit_make()
Definition at line 44 of file jit.c.
44 {
50 return jit;
51}
#define srn_mm_immortal_allocate(mm, T)
LLVMOrcLLJITBuilderRef builder
◆ srn_jit_shutdown()
Definition at line 75 of file jit.c.
75 {
76 LLVMErrorRef err = LLVMOrcDisposeLLJIT(jit->
llvm_jit);
77 if (err) {
79 }
80 return 0;
81}
static int handle_error(LLVMErrorRef err)