Files
cs420/examples/ir4/struct.ir
Jeehoon Kang ea9e6afcf8 Add tests
2020-06-09 14:45:11 +00:00

74 lines
2.0 KiB
Plaintext

struct %t1 : { i8, struct %t0, f64 }
struct %t0 : { [4 x [5 x i32]] }
fun unit @init (i32, i32, *[5 x i32]) {
init:
bid: b0
allocations:
block b0:
j b2(0:i32)
block b2:
%b2:p0:i32:i
%b2:i0:u1 = cmp lt %b2:p0:i32 %b0:p0:i32
br %b2:i0:u1, b3(), b5()
block b3:
j b7(0:i32)
block b5:
ret unit:unit
block b7:
%b7:p0:i32:j
%b7:i0:u1 = cmp lt %b7:p0:i32 %b0:p1:i32
br %b7:i0:u1, b8(), b10()
block b8:
%b8:i0:i64 = typecast %b2:p0:i32 to i64
%b8:i1:i64 = mul %b8:i0:i64 20:i64
%b8:i2:*[5 x i32] = getelementptr %b0:p2:*[5 x i32] offset %b8:i1:i64
%b8:i3:*i32 = getelementptr %b8:i2:*[5 x i32] offset 0:i32
%b8:i4:i64 = typecast %b7:p0:i32 to i64
%b8:i5:i64 = mul %b8:i4:i64 4:i64
%b8:i6:*i32 = getelementptr %b8:i3:*i32 offset %b8:i5:i64
%b8:i7:i32 = mul %b2:p0:i32 %b7:p0:i32
%b8:i8:unit = store %b8:i7:i32 %b8:i6:*i32
%b8:i9:i32 = add %b7:p0:i32 1:i32
j b7(%b8:i9:i32)
block b10:
%b10:i0:i32 = add %b2:p0:i32 1:i32
j b2(%b10:i0:i32)
}
fun i32 @main () {
init:
bid: b0
allocations:
%l0: struct %t1:temp
%l1: struct %t1:temp2
block b0:
%b0:i0:*[4 x [5 x i32]] = getelementptr %l0:* struct %t1 offset 4:i64
%b0:i1:*[5 x i32] = getelementptr %b0:i0:*[4 x [5 x i32]] offset 0:i32
%b0:i2:unit = call @init:*[ret:unit params:(i32, i32, *[5 x i32])](4:i32, 5:i32, %b0:i1:*[5 x i32])
%b0:i3: struct %t1 = load %l0:* struct %t1
%b0:i4:unit = store %b0:i3: struct %t1 %l1:* struct %t1
%b0:i5:*[4 x [5 x i32]] = getelementptr %l1:* struct %t1 offset 4:i64
%b0:i6:*[5 x i32] = getelementptr %b0:i5:*[4 x [5 x i32]] offset 0:i32
%b0:i7:i64 = typecast 2:i32 to i64
%b0:i8:i64 = mul %b0:i7:i64 20:i64
%b0:i9:*[5 x i32] = getelementptr %b0:i6:*[5 x i32] offset %b0:i8:i64
%b0:i10:*i32 = getelementptr %b0:i9:*[5 x i32] offset 0:i32
%b0:i11:i64 = typecast 3:i32 to i64
%b0:i12:i64 = mul %b0:i11:i64 4:i64
%b0:i13:*i32 = getelementptr %b0:i10:*i32 offset %b0:i12:i64
%b0:i14:i32 = load %b0:i13:*i32
%b0:i15:u1 = cmp eq %b0:i14:i32 6:i32
%b0:i16:i32 = typecast %b0:i15:u1 to i32
ret %b0:i16:i32
}