✓
Passing This code compiles and runs correctly.
Code
// Test 390_100: kernel:self|mlir — the COMPILER generates the MLIR kernel.
//
// 8209 proves a hand-written |mlir body lowers/links/runs; 8210 proves the
// loop shape (scf.for) survives the same pipe. Here the kernel transform
// itself writes that MLIR — `std/kernel:self|mlir` selects the MLIR-producing
// variant of the self transform (same convention as const|template|js: the tag
// on a transform variant names the language its OUTPUT is written in), and the
// generated memref/scf/arith kernel produces the same answer as the Zig loop
// in 390_040_self_basic.
//
// ABI: the generated func takes the host buffer as a memref argument
// (bare-ptr call convention → C `void f(double*)`) and mutates it in place —
// one call per op, and chained ops compose (390_101 pins that).
~import std/kernel
~import std/io
~std/kernel:shape(Body) {
mass: f64,
}
~std/kernel:init(Body) {
{ mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },
}
| kernel k |> std/kernel:self|mlir { k.mass *= 2.0 }
| computed c |> std/io:print.blk {
mass[0]={{ c[0].mass:f }} mass[1]={{ c[1].mass:f }} mass[2]={{ c[2].mass:f }}
}
Actual
mass[0]=2 mass[1]=4 mass[2]=6
Expected output
mass[0]=2 mass[1]=4 mass[2]=6
Flows
flow ~shape click a branch to expand · @labels scroll to their anchor
shape (expr: Body, source: mass: f64,)
flow ~init click a branch to expand · @labels scroll to their anchor
init (expr: Body, source: { mass: 1.0 },
{ mass: 2.0 },
{ mass: 3.0 },)
Test Configuration
MUST_RUN