for { let i:u32 := 0 } lt(i, 10) { i := add(i, 1)}
{
c := add(a,b)
a := b
b := c
}
Should be transpiled down to a statement which utilizes the Miden Assembly instruction
repeat.{}
Rather than the current while based implementation of for loops
Testcases
Input Yul
for { let i:u32 := 0 } lt(i, 10) { i := add(i, 1)}
{
c := add(a,b)
a := b
b := c
}
Assembly Output
use.std::math::u256
begin
# Assigning to a #
# u32 literal 10 #
push.10
# Assigning to b #
# u32 literal 5 #
push.5
# Assigning to c #
# u32 literal 0 #
push.0
repeat.10
# -- interior block -- #
# Assigning to c #
# add() #
# pushing a to the top #
dup.3
# pushing b to the top #
dup.3
add
# Assigning to a #
# pushing b to the top #
dup.3
# Assigning to b #
# pushing c to the top #
dup.1
end
end
Input Yul
{
let a:u32 := 10
let b:u32 := 5
let c:u32 := 0
for { let i:u32 := 10 } gt(i, 0) { i := sub(i, 5)}
{
let c := add(a,b)
let a := b
let b := c
}
}
Assembly Output
use.std::math::u256
begin
# Assigning to a #
# u32 literal 10 #
push.10
# Assigning to b #
# u32 literal 5 #
push.5
# Assigning to c #
# u32 literal 0 #
push.0
repeat.2
# -- interior block -- #
# Assigning to c #
# add() #
# pushing a to the top #
dup.3
# pushing b to the top #
dup.3
add
# Assigning to a #
# pushing b to the top #
dup.3
# Assigning to b #
# pushing c to the top #
dup.1
end
end
Input Yul
{
let a:u32 := 10
let b:u32 := 5
let c:u32 := 0
for { let i:u32 := 10 } lt(i, 0) { i := sub(i, 5)}
{
let c := add(a,b)
let a := b
let b := c
}
}
For Loop to Repeat Statement
Given a loop statement like
Should be transpiled down to a statement which utilizes the Miden Assembly instruction
Rather than the current
while
based implementation of for loopsTestcases