Update model solution.

- Stop calculating operands for & operators.
- Evaluate the lhs of compound operators only once.
- Add `side-effect.c` example.
This commit is contained in:
Jaewoo Kim
2025-04-07 11:03:18 +00:00
parent 7a95032d43
commit 32283f2ed1
26 changed files with 331 additions and 210 deletions

View File

@@ -0,0 +1,29 @@
var i32 @g = 0
fun i32* @foo () {
init:
bid: b0
allocations:
block b0:
%b0:i0:i32 = load @g:i32*
%b0:i1:i32 = add %b0:i0:i32 10:i32
%b0:i2:unit = store %b0:i1:i32 @g:i32*
ret @g:i32*
}
fun i32 @main () {
init:
bid: b0
allocations:
block b0:
%b0:i0:i32* = call @foo:[ret:i32* params:()]*()
%b0:i1:i32 = load %b0:i0:i32*
%b0:i2:i32 = add %b0:i1:i32 1:i32
%b0:i3:unit = store %b0:i2:i32 %b0:i0:i32*
%b0:i4:i32 = load @g:i32*
ret %b0:i4:i32
}