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

42 lines
729 B
Plaintext

fun i32 @fibonacci (i32) {
init:
bid: b0
allocations:
%l0:i32:n
block b0:
%b0:p0:i32:n
%b0:i0:unit = nop
%b0:i1:unit = nop
%b0:i2:u1 = cmp lt %b0:p0:i32 2:i32
br %b0:i2:u1, b1(), b3(%b0:p0:i32)
block b1:
%b1:i0:unit = nop
%b1:i1:i32 = add %b0:p0:i32 2:i32
%b1:i2:unit = nop
j b3(%b1:i1:i32)
block b3:
%b3:p0:i32:n
%b3:i0:unit = nop
%b3:i1:i32 = sub %b3:p0:i32 2:i32
%b3:i2:i32 = call @fibonacci:[ret:i32 params:(i32)]*(%b3:i1:i32)
%b3:i3:unit = nop
%b3:i4:i32 = sub %b3:p0:i32 1:i32
%b3:i5:i32 = call @fibonacci:[ret:i32 params:(i32)]*(%b3:i4:i32)
%b3:i6:i32 = add %b3:i2:i32 %b3:i5:i32
ret %b3:i6:i32
}
fun i32 @main () {
init:
bid: b0
allocations:
block b0:
ret 1:i32
}