Files
cs420/examples/ir3/side_effect.ir
2025-04-11 13:20:10 +09:00

30 lines
473 B
Plaintext

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
}