Skip to content

fix(mlir): uN/null/memref + MLIR wasm preload (#222–#225) - #229

Merged
godofecht merged 6 commits into
mainfrom
fix/mlir-memref-gep
Aug 7, 2026
Merged

godofecht merged 6 commits into
mainfrom
fix/mlir-memref-gep

Conversation

@godofecht

@godofecht godofecht commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • pytest tests/unit/test_mlir_generator.py (null + array decay)
  • pytest tests/integration/test_wasm_backends.py (both backends + preload .data)
  • ./flow wasm examples/wasm/hello_wasm.flow --backend=mlir --preload … --link runtime/flow_rt_support.c
  • ./flow wasm … --backend=mlir --fs memfs errors clearly

Parent: #221

godofecht and others added 4 commits August 7, 2026 18:57
MLIR has no unsigned integer types, so flow_gfx_* externs with u8
parameters failed mlir-opt ("expected non-function type"). Lower uN to
iN of the same width and track unsigned SSA origins so widen casts still
use arith.extui.

Co-authored-by: Cursor <[email protected]>
`let p: ptr<T> = arr` was reusing the memref SSA and retagging it as
!llvm.ptr, so later arr[i] emitted llvm.getelementptr on a memref
(snake_gfx). Emit extract_aligned_pointer_as_index → inttoptr into a
fresh SSA, prefer declared memref types for indexing, and ensure void
functions terminate CF while/for exit blocks with func.return.

Co-authored-by: Cursor <[email protected]>
Ship scripts/wasm_build.py --backend=mlir (Flow→MLIR→LLVM→emcc) needed
to validate gfx games, and add a unit test that array→ptr decay keeps
memref indexing on the alloc SSA. With #222+#224, snake_gfx builds under
./flow wasm --backend=mlir.

Co-authored-by: Cursor <[email protected]>
Covers resolve_backend and builds hello_wasm with both backends when emcc
is available — guards the MLIR WASM path landed for epic #221.

Co-authored-by: Cursor <[email protected]>
godofecht and others added 2 commits August 7, 2026 19:01
arith.constant null and (null : !llvm.ptr) globals are invalid MLIR.
Lower null literals and pointer module statics to llvm.mlir.zero /
zero-init globals, use llvm.icmp for ptr equality, and ptrtoint for
ptr→int casts so null checks type-check under mlir-opt.

Co-authored-by: Cursor <[email protected]>
Stop silently dropping --preload when used without --fs. wasm_build.py
now passes --preload-file + FORCE_FILESYSTEM, accepts --link (skipping
Cocoa .m), and exposes INITIAL_MEMORY / ASYNCIFY_STACK_SIZE knobs.
./flow wasm forwards those flags and errors clearly if --fs/--threads
are combined with --backend=mlir.

Co-authored-by: Cursor <[email protected]>
@godofecht godofecht changed the title fix(mlir): unsigned iN + memref/ptr decay; MLIR wasm gfx (#222 #224) fix(mlir): uN/null/memref + MLIR wasm preload (#222–#225) Aug 7, 2026
@godofecht

Copy link
Copy Markdown
Contributor Author

Epic #221 child issues covered in this PR: #222 #224 #223 #225. Ready for review — next stretch outside this PR is doom-flow dual-build on Pages once merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant