MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim_rt.c
Go to the documentation of this file.
1// Runtime wrappers for the MimIR `ll` backend.
2//
3// The functions in this file are implemented in C, compiled to textual LLVM IR by `clang`
4// at build time (see `add_mim_runtime` in `cmake/Mim.cmake`), and then either embedded into
5// or linked with the module emitted by the `ll` backend (selected via `-X ll:rt=embed|extern`).
6//
7// This lets the emitter offload complex or platform-dependent lowerings to `clang` instead of
8// hand-writing raw LLVM IR; see issue #486.
9// Wrappers must expose a flat, scalar ABI (no C aggregates across the boundary) so that the
10// emitter can lower a Mim intrinsic to a single `call`.
11
12#include <setjmp.h>
13#include <stdint.h>
14
15/// Size in bytes of a `jmp_buf`, used by `%clos.alloc_jmpbuf` to reserve stack space.
16/// The size is platform- and libc-dependent, so we let the C compiler compute it rather than
17/// hard-coding it in the backend.
18int64_t mim_jmpbuf_size(void) { return (int64_t)sizeof(jmp_buf); }
int64_t mim_jmpbuf_size(void)
Size in bytes of a jmp_buf, used by clos.alloc_jmpbuf to reserve stack space.
Definition mim_rt.c:18