-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Add floating-point type support. Currently everything is i64-only, but real GPU kernels (especially matmul) operate on f32/f64.
What's needed
- Float literals (or int-to-float conversion words)
- Float arithmetic:
F+ F- F* F/ - Float load/store:
F@ F! - Type conversion:
S>F(int to float),F>S(float to int)
Design considerations
The Forth stack is currently untyped (!forth.stack backed by memref<256xi64>). Options for float support:
- Bit-casting approach: Store f32/f64 as i64 bit patterns on the stack, with F-prefixed ops doing reinterpret casts before/after arithmetic. Simple but loses type safety.
- Tagged stack: Add runtime type tags. More Forth-like but adds overhead on GPU.
- Separate float stack: Traditional Forth has a separate FP stack. Clean separation but doubles the plumbing.
- Type-parameterized stack: Make stack element type configurable. Cleanest MLIR approach but bigger refactor.
Implementation notes
- Float arithmetic maps to
arith.addf,arith.subf,arith.mulf,arith.divf - Float load/store needs
memrefwith f32/f64 element type, or bitcast at boundaries - Float literals need parser support (detecting
.orein numbers)
Priority
Important — needed for any real-world matmul or ML kernel.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request