Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use two rules for 'select' to avoid if-then-else on valstack #655

Merged
merged 8 commits into from
Jun 25, 2024
11 changes: 8 additions & 3 deletions pykwasm/src/pykwasm/kdist/wasm-semantics/wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,16 @@ The `select` operator picks one of the second or third stack values based on the
<valstack> _ : VALSTACK => VALSTACK </valstack>

rule <instrs> select => .K ... </instrs>
<valstack> < i32 > C : V2 : V1 : VALSTACK
=> #if C =/=Int 0 #then V1 #else V2 #fi : VALSTACK
<valstack> < i32 > C : V2 : V1 : VALSTACK
=> V2 : VALSTACK
</valstack>
requires #sameType(V1, V2)
requires C ==Int 0 andBool #sameType(V1, V2)

rule <instrs> select => .K ... </instrs>
<valstack> < i32 > C : V2 : V1 : VALSTACK
=> V1 : VALSTACK
</valstack>
requires C =/=Int 0 andBool #sameType(V1, V2)
```

Structured Control Flow
Expand Down
Loading