Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
jit.cpp File Reference
#include "serene/jit/jit.h"
#include <llvm/ExecutionEngine/JITEventListener.h>
#include <llvm/ExecutionEngine/ObjectCache.h>
#include <llvm/ExecutionEngine/Orc/LLJIT.h>
#include <llvm/Support/Error.h>
#include <llvm/Support/TargetSelect.h>
#include <memory>
#include <string>
#include <utility>
Include dependency graph for jit.cpp:

Go to the source code of this file.

Data Structures

struct  srn_object_cache_t
struct  srn_jit_t

Functions

srn_jit_t * srn_jit_create (srn_mm_t *mm, const srn_jit_config_t *config)
void srn_jit_destroy (srn_jit_t *jit)
const char * srn_jit_data_layout (srn_jit_t *jit)
const char * srn_jit_triple (srn_jit_t *jit)
srn_error_t * srn_jit_add_ir (srn_jit_t *, srn_context_t *ctx, const char *, size_t, srn_jit_module_t **)
srn_error_t * srn_jit_add_bitcode (srn_jit_t *, srn_context_t *ctx, const void *, size_t, srn_jit_module_t **)
srn_error_t * srn_jit_define (srn_jit_t *, srn_context_t *ctx, const char *, void *)
srn_error_t * srn_jit_expose_process_symbols (srn_jit_t *, srn_context_t *ctx)
srn_error_t * srn_jit_lookup (srn_jit_t *, srn_context_t *ctx, const char *, void **)
srn_error_t * srn_jit_remove (srn_jit_t *, srn_context_t *ctx, srn_jit_module_t *)

Function Documentation

◆ srn_jit_add_bitcode()

srn_error_t * srn_jit_add_bitcode ( srn_jit_t * ,
srn_context_t * ctx,
const void * ,
size_t ,
srn_jit_module_t **  )

Definition at line 112 of file jit.cpp.

112 {
113 return srn_errors_make(ctx, NOT_IMPLEMENTED, "srn_jit_add_bitcode is not yet implemented");
114}
srn_error_t * srn_errors_make(const srn_context_t *ctx, srn_error_tag_t tag, const char *msg, void *caller)
Build an error in ctx's memory, tagged tag and carrying msg.
Definition errors.c:196
@ NOT_IMPLEMENTED
Definition errors.h:94
Here is the call graph for this function:

◆ srn_jit_add_ir()

srn_error_t * srn_jit_add_ir ( srn_jit_t * ,
srn_context_t * ctx,
const char * ,
size_t ,
srn_jit_module_t **  )

Definition at line 107 of file jit.cpp.

107 {
108 return srn_errors_make(ctx, NOT_IMPLEMENTED, "srn_jit_add_ir is not yet implemented");
109}
Here is the call graph for this function:

◆ srn_jit_create()

srn_jit_t * srn_jit_create ( srn_mm_t * mm,
const srn_jit_config_t * config )

Definition at line 72 of file jit.cpp.

72 {
73 if (mm == nullptr) {
74 return nullptr;
75 }
76
77 // TODO(lxsameer): long term, we might want to check the binfmt and enable none
78 // native targets here as well.
79 llvm::InitializeNativeTarget();
80 llvm::InitializeNativeTargetAsmPrinter();
81
82 auto jit_or_err = llvm::orc::LLJITBuilder().create();
83 if (!jit_or_err) {
84 llvm::consumeError(jit_or_err.takeError());
85 return nullptr;
86 }
87
88 auto *self = new srn_jit_t{};
89 self->mm = mm;
90 self->jit = std::move(*jit_or_err);
91 self->data_layout = self->jit->getDataLayout().getStringRepresentation();
92 self->triple = self->jit->getTargetTriple();
93 self->config = (config != nullptr)
94 ? *config
95 : srn_jit_config_t{.opt_level = 2, .install_default_pipeline = true};
96
97 return self;
98}
srn_mm_t * mm
Definition jit.cpp:52

◆ srn_jit_data_layout()

const char * srn_jit_data_layout ( srn_jit_t * jit)

Definition at line 102 of file jit.cpp.

102{ return jit->data_layout.c_str(); }
llvm::DataLayout & data_layout
Definition jit.cpp:63

◆ srn_jit_define()

srn_error_t * srn_jit_define ( srn_jit_t * ,
srn_context_t * ctx,
const char * ,
void *  )

Definition at line 116 of file jit.cpp.

116 {
117 return srn_errors_make(ctx, NOT_IMPLEMENTED, "srn_jit_define is not yet implemented");
118}
Here is the call graph for this function:

◆ srn_jit_destroy()

void srn_jit_destroy ( srn_jit_t * jit)

Definition at line 100 of file jit.cpp.

100{ delete jit; }

◆ srn_jit_expose_process_symbols()

srn_error_t * srn_jit_expose_process_symbols ( srn_jit_t * ,
srn_context_t * ctx )

Definition at line 120 of file jit.cpp.

120 {
121 return srn_errors_make(
122 ctx, NOT_IMPLEMENTED, "srn_jit_expose_process_symbols is not yet implemented"
123 );
124}
Here is the call graph for this function:

◆ srn_jit_lookup()

srn_error_t * srn_jit_lookup ( srn_jit_t * ,
srn_context_t * ctx,
const char * ,
void **  )

Definition at line 126 of file jit.cpp.

126 {
127 return srn_errors_make(ctx, NOT_IMPLEMENTED, "srn_jit_lookup is not yet implemented");
128}
Here is the call graph for this function:

◆ srn_jit_remove()

srn_error_t * srn_jit_remove ( srn_jit_t * ,
srn_context_t * ctx,
srn_jit_module_t *  )

Definition at line 130 of file jit.cpp.

130 {
131 return srn_errors_make(ctx, NOT_IMPLEMENTED, "srn_jit_remove is not yet implemented");
132}
Here is the call graph for this function:

◆ srn_jit_triple()

const char * srn_jit_triple ( srn_jit_t * jit)

Definition at line 104 of file jit.cpp.

104{ return jit->triple.c_str(); }
llvm::Triple triple
Definition jit.cpp:66