skip to content
==> include/wasm/float_guard.h <==
1/* @ajax/wasm-float-guard: meshd's load-time check of a wasm image (alpha-rust-mesh
2 * mesh-host/src/wasm.rs `float_check`).
3 *
4 * An image declaring the cluster float mode (`float = "ftz"`, the default, required for lockstep)
5 * may hold f32 arithmetic, compares and f32<->f64 converts only inside its exported `mesh_ftz_*`
6 * helpers (mesh-ref ftz.rs / @ajax/mesh-ftz: flush in, op, flush out), and no SIMD at all; no image
7 * may use threads, shared memory or relaxed SIMD, or import anything but `mesh` functions.
8 * Errors start with "jit: " (not valid wasm), "float: " or "load: ", as meshd's load reasons. */
9#ifndef WASM_FLOAT_GUARD_H
10#define WASM_FLOAT_GUARD_H
11
12#include <stdbool.h>
13#include <stddef.h>
14#include <stdint.h>
15
16/* What the check saw: functions, the exported FTZ helpers, f32 ops (all in helpers when ftz). */
17typedef struct {
18    uint32_t funcs;
19    uint32_t helpers;
20    uint32_t f32_ops;
21} wasm_float_report;
22
23/* The ops the cluster float mode flushes: f32 arithmetic, compares, f32 <-> f64 converts. Loads,
24 * stores, constants, reinterprets, selects and int <-> f32 converts move or make values without a
25 * flush on the GPU too. */
26bool wasm_flushing_f32(uint32_t op);
27
28bool wasm_float_check(const uint8_t *wasm, size_t len, bool ftz, wasm_float_report *rep, char *err, size_t errlen);
29
30#endif