Skip to main content
Enigma provides tracing-compatible control flow that lowers to MLIR 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

Without init, the context yields the induction variable:
With init, yields (iv, carry) where carry is a mutable Carry object:

enigma.if_

Simple if (no else):

enigma.while_

The condition is a zero-argument callable returning an 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:
The preprocessor detects modified variables and threads them as loop carries automatically.

enigma.range_constexpr

Unrolls at trace time — the loop body is traced N times as separate ops:
Equivalent to writing the body 4 times. Use for small fixed-count inner loops where you want full unrolling.

Predicated memory access

For boundary checks without full if_ branches:
load_if emits an unconditional load + select. store_if wraps the store in an scf.if.