11.11. Loop unrolling
The UNROLL module implements compile-time loop unrolling. The unroll
macro replaces a for loop with a constant range bound by stamping
out each iteration as separate inlined code, eliminating loop overhead.
All functions and symbols are in “unroll” module, use require to get access to it.
require daslib/unroll
Example:
require daslib/unroll
[export]
def main() {
unroll() {
for (i in range(4)) {
print("step {i}\n")
}
}
}
// output:
// step 0
// step 1
// step 2
// step 3
11.11.1. Function annotations
- UnrollMacro
This macro implements loop unrolling in the form of unroll function.
11.11.2. Unrolling
- unroll(blk: block<():void> )
Unrolls the for loop (with fixed range)
- Arguments:
blk : block<void>