Skip to content

Local variables support #8

@tetsuo-cpp

Description

@tetsuo-cpp

Summary

Add Forth-style local variables to make complex algorithms readable and writable.

Motivation

Matmul tiling involves many named quantities (row, col, tile index, accumulator, etc.) that are impractical to manage on a raw stack. Local variables let you name values instead of juggling stack positions.

Design considerations

Standard Forth locals syntax options:

\ ANS Forth locals
: foo { a b c -- }  a b + c * ;

\ VALUE/TO style  
0 VALUE acc
10 TO acc

Implementation notes

  • Locals can be lowered to memref.alloca slots or MLIR SSA values
  • Parser needs to handle { ... -- } or VALUE/TO syntax
  • Scope is per-word (locals are valid until ;)
  • On GPU, locals should map to registers (scalar allocas that LLVM promotes to registers)

Priority

Important — significantly improves ergonomics for any non-trivial kernel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions