mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 15:08:52 +00:00
- Stop calculating operands for & operators. - Evaluate the lhs of compound operators only once. - Add `side-effect.c` example.
46 lines
1002 B
Plaintext
46 lines
1002 B
Plaintext
|
|
fun i32* @foo (i32*) {
|
|
init:
|
|
bid: b0
|
|
allocations:
|
|
%l0:i32*:a
|
|
|
|
block b0:
|
|
%b0:p0:i32*:a
|
|
%b0:i0:unit = nop
|
|
%b0:i1:unit = nop
|
|
ret %b0:p0:i32*
|
|
}
|
|
|
|
fun i32 @main () {
|
|
init:
|
|
bid: b0
|
|
allocations:
|
|
%l0:i32:a
|
|
%l1:i32*:p
|
|
%l2:i32**:p2
|
|
%l3:i32*:p3
|
|
|
|
block b0:
|
|
%b0:i0:unit = store 1:i32 %l0:i32*
|
|
%b0:i1:unit = store %l0:i32* %l1:i32**
|
|
%b0:i2:unit = nop
|
|
%b0:i3:i32* = load %l1:i32**
|
|
%b0:i4:unit = nop
|
|
%b0:i5:unit = nop
|
|
%b0:i6:i32* = load %l1:i32**
|
|
%b0:i7:i32* = call @foo:[ret:i32* params:(i32*)]*(%b0:i6:i32*)
|
|
%b0:i8:i32 = load %b0:i7:i32*
|
|
%b0:i9:i32 = add %b0:i8:i32 1:i32
|
|
%b0:i10:unit = store %b0:i9:i32 %b0:i7:i32*
|
|
%b0:i11:unit = nop
|
|
%b0:i12:i32* = call @foo:[ret:i32* params:(i32*)]*(%b0:i3:i32*)
|
|
%b0:i13:i32 = load %b0:i12:i32*
|
|
%b0:i14:i32 = add %b0:i13:i32 1:i32
|
|
%b0:i15:unit = store %b0:i14:i32 %b0:i12:i32*
|
|
%b0:i16:i32 = load %l0:i32*
|
|
%b0:i17:u1 = cmp eq %b0:i16:i32 3:i32
|
|
%b0:i18:i32 = typecast %b0:i17:u1 to i32
|
|
ret %b0:i18:i32
|
|
}
|