mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 23:18:48 +00:00
Update skeleton
This commit is contained in:
67
examples/ir/foo4.ir
Normal file
67
examples/ir/foo4.ir
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
fun i32 @foo {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
%l0:i32:i
|
||||
%l1:i32:j
|
||||
%l2:i32:k
|
||||
|
||||
block b0:
|
||||
%b0:i0:unit = store %b0:p0:i32 %l0:*i32
|
||||
%b0:i1:unit = store %b0:p1:i32 %l1:*i32
|
||||
%b0:i2:unit = store %b0:p2:i32 %l2:*i32
|
||||
%b0:i3:i32 = load %l0:*i32
|
||||
%b0:i4:i32 = load %l1:*i32
|
||||
%b0:i5:i32 = add %b0:i3:i32 %b0:i4:i32
|
||||
%b0:i6:i32 = load %l2:*i32
|
||||
%b0:i7:i32 = add %b0:i5:i32 %b0:i6:i32
|
||||
ret %b0:i7:i32
|
||||
|
||||
block b1:
|
||||
ret undef:i32
|
||||
}
|
||||
|
||||
fun *i32 (i32, i32, i32) @foo2 {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
|
||||
block b0:
|
||||
ret @foo:*i32 (i32, i32, i32)
|
||||
|
||||
block b1:
|
||||
ret undef:*i32 (i32, i32, i32)
|
||||
}
|
||||
|
||||
fun **i32 (i32, i32, i32) () @foo3 {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
|
||||
block b0:
|
||||
ret @foo2:**i32 (i32, i32, i32) ()
|
||||
|
||||
block b1:
|
||||
ret undef:**i32 (i32, i32, i32) ()
|
||||
}
|
||||
|
||||
fun i32 @main {
|
||||
init:
|
||||
bid: b0
|
||||
allocations:
|
||||
|
||||
|
||||
block b0:
|
||||
%b0:i0:**i32 (i32, i32, i32) () = call @foo3()
|
||||
%b0:i1:*i32 (i32, i32, i32) = call %b0:i0()
|
||||
%b0:i2:i32 = call %b0:i1(2:i32, 2:i32, 2:i32)
|
||||
%b0:i3:u1 = cmp eq %b0:i2:i32 6:i32
|
||||
%b0:i4:i32 = typecast %b0:i3:u1 to i32
|
||||
ret %b0:i4:i32
|
||||
|
||||
block b1:
|
||||
ret 0:i32
|
||||
}
|
||||
Reference in New Issue
Block a user