mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 06:58:50 +00:00
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:
29
examples/ir4/side_effect.ir
Normal file
29
examples/ir4/side_effect.ir
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user