mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 23:18:48 +00:00
71 lines
1.2 KiB
Plaintext
71 lines
1.2 KiB
Plaintext
|
|
fun i32 @fibonacci (i32) {
|
|
init:
|
|
bid: b0
|
|
allocations:
|
|
%l0:i32:n
|
|
%l1:i32:i
|
|
%l2:i32:t1
|
|
%l3:i32:t2
|
|
%l4:i32:next_term
|
|
|
|
block b0:
|
|
%b0:p0:i32:n
|
|
%b0:i0:unit = nop
|
|
%b0:i1:unit = nop
|
|
%b0:i2:unit = nop
|
|
%b0:i3:unit = nop
|
|
%b0:i4:unit = nop
|
|
%b0:i5:unit = nop
|
|
%b0:i6:u1 = cmp lt %b0:p0:i32 2:i32
|
|
br %b0:i6:u1, b1(), b2()
|
|
|
|
block b1:
|
|
%b1:i0:unit = nop
|
|
ret %b0:p0:i32
|
|
|
|
block b2:
|
|
%b2:i0:unit = nop
|
|
j b6(1:i32, 0:i32, 1:i32)
|
|
|
|
block b6:
|
|
%b6:p0:i32:i
|
|
%b6:p1:i32:t1
|
|
%b6:p2:i32:t2
|
|
%b6:i0:unit = nop
|
|
%b6:i1:unit = nop
|
|
%b6:i2:u1 = cmp lt %b6:p0:i32 %b0:p0:i32
|
|
br %b6:i2:u1, b7(), b9()
|
|
|
|
block b7:
|
|
%b7:i0:unit = nop
|
|
%b7:i1:unit = nop
|
|
%b7:i2:i32 = add %b6:p1:i32 %b6:p2:i32
|
|
%b7:i3:unit = nop
|
|
%b7:i4:unit = nop
|
|
%b7:i5:unit = nop
|
|
%b7:i6:unit = nop
|
|
%b7:i7:unit = nop
|
|
%b7:i8:unit = nop
|
|
%b7:i9:i32 = add %b6:p0:i32 1:i32
|
|
%b7:i10:unit = nop
|
|
j b6(%b7:i9:i32, %b6:p2:i32, %b7:i2:i32)
|
|
|
|
block b9:
|
|
%b9:i0:unit = nop
|
|
ret %b6:p2:i32
|
|
}
|
|
|
|
fun i32 @main () {
|
|
init:
|
|
bid: b0
|
|
allocations:
|
|
|
|
|
|
block b0:
|
|
%b0:i0:i32 = call @fibonacci:[ret:i32 params:(i32)]*(9:i32)
|
|
%b0:i1:u1 = cmp eq %b0:i0:i32 34:i32
|
|
%b0:i2:i32 = typecast %b0:i1:u1 to i32
|
|
ret %b0:i2:i32
|
|
}
|