scf ops. Plain Python if/for executes at trace time (useful for compile-time unrolling); use these constructs for runtime GPU control flow.
enigma.for_range
| Parameter | Type | Default | Description |
|---|---|---|---|
lo | int or IRValue | required | Lower bound (inclusive) |
hi | int or IRValue | required | Upper bound (exclusive) |
step | int or IRValue | 1 | Loop step |
dtype | str | "int" | Induction variable type |
init | list or None | None | Initial values for loop-carried accumulators |
init, the context yields the induction variable:
init, yields (iv, carry) where carry is a mutable Carry object:
enigma.if_
enigma.while_
IRValue of type i1.
enigma.range (AST preprocessor)
Inside @enigma.kernel, Python-style for loops with enigma.range are rewritten by the AST preprocessor into for_range calls with automatic carry tracking:
enigma.range_constexpr
Unrolls at trace time — the loop body is traced N times as separate ops:
Predicated memory access
For boundary checks without fullif_ branches:
| Function | Description |
|---|---|
enigma.load_if(buf, index, mask, default=0) | Load if mask is true, else return default |
enigma.store_if(buf, index, value, mask) | Store only when mask is true |
load_if emits an unconditional load + select. store_if wraps the store in an scf.if.