You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nudt-compiler-cpp/test_outputs/22_matrix_multiply.ll

221 lines
5.5 KiB

@MAX_SIZE = global i32 100
@a = global [10000 x i32] zeroinitializer
@b = global [10000 x i32] zeroinitializer
@res = global [10000 x i32] zeroinitializer
@n1 = global i32 0
@m1 = global i32 0
@n2 = global i32 0
@m2 = global i32 0
declare i32 @getint()
declare i32 @getch()
declare void @putint(i32)
declare void @putch(i32)
declare i32 @getarray(i32*)
declare void @putarray(i32, i32*)
declare void @starttime()
declare void @stoptime()
define void @matrix_multiply() {
entry:
%t1 = alloca i32
%t2 = alloca i32
%t9 = alloca i32
%t16 = alloca i32
br label %bbt0
bbt0:
store i32 0, i32* %t2
br label %bbt3
bbt3:
%t6 = load i32, i32* %t2
%t7 = load i32, i32* @m1
%t8 = icmp slt i32 %t6, %t7
br i1 %t8, label %bbt4, label %bbt5
bbt4:
store i32 0, i32* %t9
br label %bbt10
bbt5:
ret void
bbt10:
%t13 = load i32, i32* %t9
%t14 = load i32, i32* @n2
%t15 = icmp slt i32 %t13, %t14
br i1 %t15, label %bbt11, label %bbt12
bbt11:
store i32 0, i32* %t16
br label %bbt17
bbt12:
%t56 = load i32, i32* %t2
%t57 = add i32 %t56, 1
store i32 %t57, i32* %t2
br label %bbt3
bbt17:
%t20 = load i32, i32* %t16
%t21 = load i32, i32* @n1
%t22 = icmp slt i32 %t20, %t21
br i1 %t22, label %bbt18, label %bbt19
bbt18:
%t23 = load i32, i32* %t2
%t24 = mul i32 %t23, 100
%t25 = add i32 0, %t24
%t26 = load i32, i32* %t9
%t27 = add i32 %t25, %t26
%t28 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t27
%t29 = load i32, i32* %t28
%t30 = load i32, i32* %t2
%t31 = mul i32 %t30, 100
%t32 = add i32 0, %t31
%t33 = load i32, i32* %t16
%t34 = add i32 %t32, %t33
%t35 = getelementptr [10000 x i32], [10000 x i32]* @a, i32 0, i32 %t34
%t36 = load i32, i32* %t35
%t37 = load i32, i32* %t16
%t38 = mul i32 %t37, 100
%t39 = add i32 0, %t38
%t40 = load i32, i32* %t9
%t41 = add i32 %t39, %t40
%t42 = getelementptr [10000 x i32], [10000 x i32]* @b, i32 0, i32 %t41
%t43 = load i32, i32* %t42
%t44 = mul i32 %t36, %t43
%t45 = add i32 %t29, %t44
%t46 = load i32, i32* %t2
%t47 = mul i32 %t46, 100
%t48 = add i32 0, %t47
%t49 = load i32, i32* %t9
%t50 = add i32 %t48, %t49
%t51 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t50
store i32 %t45, i32* %t51
%t52 = load i32, i32* %t16
%t53 = add i32 %t52, 1
store i32 %t53, i32* %t16
br label %bbt17
bbt19:
%t54 = load i32, i32* %t9
%t55 = add i32 %t54, 1
store i32 %t55, i32* %t9
br label %bbt10
}
define i32 @main() {
entry:
%t59 = alloca i32
%t60 = alloca i32
%t61 = alloca i32
br label %bbt58
bbt58:
store i32 0, i32* %t60
store i32 0, i32* %t61
%t62 = call i32 @getint()
store i32 %t62, i32* @m1
%t63 = call i32 @getint()
store i32 %t63, i32* @n1
store i32 0, i32* %t60
br label %bbt64
bbt64:
%t67 = load i32, i32* %t60
%t68 = load i32, i32* @m1
%t69 = icmp slt i32 %t67, %t68
br i1 %t69, label %bbt65, label %bbt66
bbt65:
store i32 0, i32* %t61
br label %bbt70
bbt66:
%t87 = call i32 @getint()
store i32 %t87, i32* @m2
%t88 = call i32 @getint()
store i32 %t88, i32* @n2
store i32 0, i32* %t60
br label %bbt89
bbt70:
%t73 = load i32, i32* %t61
%t74 = load i32, i32* @n1
%t75 = icmp slt i32 %t73, %t74
br i1 %t75, label %bbt71, label %bbt72
bbt71:
%t76 = call i32 @getint()
%t77 = load i32, i32* %t60
%t78 = mul i32 %t77, 100
%t79 = add i32 0, %t78
%t80 = load i32, i32* %t61
%t81 = add i32 %t79, %t80
%t82 = getelementptr [10000 x i32], [10000 x i32]* @a, i32 0, i32 %t81
store i32 %t76, i32* %t82
%t83 = load i32, i32* %t61
%t84 = add i32 %t83, 1
store i32 %t84, i32* %t61
br label %bbt70
bbt72:
%t85 = load i32, i32* %t60
%t86 = add i32 %t85, 1
store i32 %t86, i32* %t60
br label %bbt64
bbt89:
%t92 = load i32, i32* %t60
%t93 = load i32, i32* @m2
%t94 = icmp slt i32 %t92, %t93
br i1 %t94, label %bbt90, label %bbt91
bbt90:
store i32 0, i32* %t61
br label %bbt95
bbt91:
call void @matrix_multiply()
store i32 0, i32* %t60
br label %bbt112
bbt95:
%t98 = load i32, i32* %t61
%t99 = load i32, i32* @n2
%t100 = icmp slt i32 %t98, %t99
br i1 %t100, label %bbt96, label %bbt97
bbt96:
%t101 = call i32 @getint()
%t102 = load i32, i32* %t60
%t103 = mul i32 %t102, 100
%t104 = add i32 0, %t103
%t105 = load i32, i32* %t61
%t106 = add i32 %t104, %t105
%t107 = getelementptr [10000 x i32], [10000 x i32]* @b, i32 0, i32 %t106
store i32 %t101, i32* %t107
%t108 = load i32, i32* %t61
%t109 = add i32 %t108, 1
store i32 %t109, i32* %t61
br label %bbt95
bbt97:
%t110 = load i32, i32* %t60
%t111 = add i32 %t110, 1
store i32 %t111, i32* %t60
br label %bbt89
bbt112:
%t115 = load i32, i32* %t60
%t116 = load i32, i32* @m1
%t117 = icmp slt i32 %t115, %t116
br i1 %t117, label %bbt113, label %bbt114
bbt113:
store i32 0, i32* %t61
br label %bbt118
bbt114:
ret i32 0
bbt118:
%t121 = load i32, i32* %t61
%t122 = load i32, i32* @n2
%t123 = icmp slt i32 %t121, %t122
br i1 %t123, label %bbt119, label %bbt120
bbt119:
%t124 = load i32, i32* %t60
%t125 = mul i32 %t124, 100
%t126 = add i32 0, %t125
%t127 = load i32, i32* %t61
%t128 = add i32 %t126, %t127
%t129 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t128
%t130 = load i32, i32* %t129
call void @putint(i32 %t130)
call void @putch(i32 32)
%t131 = load i32, i32* %t61
%t132 = add i32 %t131, 1
store i32 %t132, i32* %t61
br label %bbt118
bbt120:
call void @putch(i32 10)
%t133 = load i32, i32* %t60
%t134 = add i32 %t133, 1
store i32 %t134, i32* %t60
br label %bbt112
}