Skip to content

Remaining control flow gaps vs standard Forth #16

@tetsuo-cpp

Description

@tetsuo-cpp

Summary

WarpForth uses a compile-time control-flow stack in the translator, emitting cf.br/cf.cond_br directly. This matches standard Forth's cf-stack semantics and supports interleaved control flow patterns (multi-WHILE, WHILE+UNTIL, etc.).

Remaining Gaps

High impact for GPU kernels

Feature Standard Forth Notes
LEAVE / UNLOOP Early exit from DO...LOOP Very common in search/scan patterns. Requires adding a forward branch target to LoopContext and branching to the exit block.
EXIT Early return from a word Common in utility words with multiple exit conditions. Requires emitting func.return mid-body.

Medium impact

Feature Standard Forth Notes
+LOOP Arbitrary loop step Useful for strided iteration. The current LOOP always increments by 1; +LOOP would pop the step from the stack. Straightforward to add.

Low/no impact for GPU kernels

Feature Why
BEGIN...AGAIN Infinite loops hang the GPU; trivial workaround BEGIN 0 UNTIL
?DO...LOOP WarpForth's DO already behaves like ?DO (zero-trip safe via arith.cmpi slt check)
RECURSE Recursion is dangerous on GPUs (tiny call stacks, thread divergence)
CS-PICK / CS-ROLL Exotic metaprogramming, never used in kernel code

Related

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