mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Add tests
This commit is contained in:
40
examples/ir2/simple_if.ir
Normal file
40
examples/ir2/simple_if.ir
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
fun i32 @fibonacci (i32) {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:n
|
||||
|
||||
block b0:
|
||||
%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
|
||||
}
|
||||
Reference in New Issue
Block a user