Skip to content

MLIR: wasm32 ILP32 pointer width and u32 correctness #255

Closed

Description

@godofecht

doom-flow's MLIR build on wasm32 produces incorrect memory layout unless the Flow code manually works around ILP32 assumptions.

Details:

  • Hardcoded * 8 / i64 row strides for ptr<void> arrays scramble light tables and wall colormaps on wasm32. doom-flow added rmain_ptr_bytes() in rmain.flow and draw_ensure_buffers() in draw.flow to use the target pointer size.
  • u32 to i32 casts and unsigned subtraction / multiplication in timer.flow I_GetTime and rdata.flow texture offsets cause sign / overflow bugs. doom-flow masks byte reads in rdata_short_at and rdata_long_at.

Current workaround: manual pointer-size probes and explicit masking throughout the port.

Requested change: flow.transpiler --mlir --llvm should use the target pointer width for ptr indexing and generate correct zext/trunc for u32 / i32 casts and arithmetic on 32-bit targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions