forked from NUDT-compiler/nudt-compiler-cpp
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.
313 lines
9.1 KiB
313 lines
9.1 KiB
@N = global i32 1024
|
|
@A = global [1048576 x i32] zeroinitializer
|
|
@B = global [1048576 x i32] zeroinitializer
|
|
@C = global [1048576 x i32] zeroinitializer
|
|
|
|
declare i32 @getint()
|
|
declare float @getfloat()
|
|
declare i32 @getarray(i32* %arg.a)
|
|
declare i32 @getfarray(float* %arg.a)
|
|
declare i32 @getch()
|
|
declare void @putint(i32 %arg.x)
|
|
declare void @putfloat(float %arg.x)
|
|
declare void @putarray(i32 %arg.n, i32* %arg.a)
|
|
declare void @putfarray(i32 %arg.n, float* %arg.a)
|
|
declare void @putch(i32 %arg.x)
|
|
declare void @starttime()
|
|
declare void @stoptime()
|
|
define void @mm(i32 %arg.n, i32* %arg.A, i32* %arg.B, i32* %arg.C) {
|
|
entry:
|
|
%t1 = alloca i32
|
|
%t2 = alloca i32
|
|
%t3 = alloca i32
|
|
%t0 = alloca i32
|
|
store i32 %arg.n, i32* %t0
|
|
store i32 0, i32* %t1
|
|
store i32 0, i32* %t2
|
|
store i32 0, i32* %t3
|
|
store i32 0, i32* %t1
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t4 = load i32, i32* %t1
|
|
%t5 = load i32, i32* %t0
|
|
%t6 = icmp slt i32 %t4, %t5
|
|
%t7 = zext i1 %t6 to i32
|
|
%t8 = icmp ne i32 %t7, 0
|
|
br i1 %t8, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.4
|
|
while.end.3:
|
|
store i32 0, i32* %t1
|
|
store i32 0, i32* %t2
|
|
store i32 0, i32* %t3
|
|
br label %while.cond.7
|
|
while.cond.4:
|
|
%t9 = load i32, i32* %t2
|
|
%t10 = load i32, i32* %t0
|
|
%t11 = icmp slt i32 %t9, %t10
|
|
%t12 = zext i1 %t11 to i32
|
|
%t13 = icmp ne i32 %t12, 0
|
|
br i1 %t13, label %while.body.5, label %while.end.6
|
|
while.body.5:
|
|
%t14 = load i32, i32* %t1
|
|
%t15 = load i32, i32* %t2
|
|
%t16 = mul i32 %t14, 1024
|
|
%t17 = add i32 %t16, %t15
|
|
%t18 = getelementptr inbounds i32, i32* %arg.C, i32 %t17
|
|
store i32 0, i32* %t18
|
|
%t19 = load i32, i32* %t2
|
|
%t20 = add i32 %t19, 1
|
|
store i32 %t20, i32* %t2
|
|
br label %while.cond.4
|
|
while.end.6:
|
|
%t21 = load i32, i32* %t1
|
|
%t22 = add i32 %t21, 1
|
|
store i32 %t22, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.7:
|
|
%t23 = load i32, i32* %t3
|
|
%t24 = load i32, i32* %t0
|
|
%t25 = icmp slt i32 %t23, %t24
|
|
%t26 = zext i1 %t25 to i32
|
|
%t27 = icmp ne i32 %t26, 0
|
|
br i1 %t27, label %while.body.8, label %while.end.9
|
|
while.body.8:
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.10
|
|
while.end.9:
|
|
ret void
|
|
while.cond.10:
|
|
%t28 = load i32, i32* %t1
|
|
%t29 = load i32, i32* %t0
|
|
%t30 = icmp slt i32 %t28, %t29
|
|
%t31 = zext i1 %t30 to i32
|
|
%t32 = icmp ne i32 %t31, 0
|
|
br i1 %t32, label %while.body.11, label %while.end.12
|
|
while.body.11:
|
|
%t33 = load i32, i32* %t1
|
|
%t34 = load i32, i32* %t3
|
|
%t35 = mul i32 %t33, 1024
|
|
%t36 = add i32 %t35, %t34
|
|
%t37 = getelementptr inbounds i32, i32* %arg.A, i32 %t36
|
|
%t38 = load i32, i32* %t37
|
|
%t39 = icmp eq i32 %t38, 0
|
|
%t40 = zext i1 %t39 to i32
|
|
%t41 = icmp ne i32 %t40, 0
|
|
br i1 %t41, label %if.then.13, label %if.end.14
|
|
while.end.12:
|
|
%t78 = load i32, i32* %t3
|
|
%t79 = add i32 %t78, 1
|
|
store i32 %t79, i32* %t3
|
|
br label %while.cond.7
|
|
if.then.13:
|
|
%t42 = load i32, i32* %t1
|
|
%t43 = add i32 %t42, 1
|
|
store i32 %t43, i32* %t1
|
|
br label %while.cond.10
|
|
if.end.14:
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.15
|
|
while.cond.15:
|
|
%t44 = load i32, i32* %t2
|
|
%t45 = load i32, i32* %t0
|
|
%t46 = icmp slt i32 %t44, %t45
|
|
%t47 = zext i1 %t46 to i32
|
|
%t48 = icmp ne i32 %t47, 0
|
|
br i1 %t48, label %while.body.16, label %while.end.17
|
|
while.body.16:
|
|
%t49 = load i32, i32* %t1
|
|
%t50 = load i32, i32* %t2
|
|
%t51 = mul i32 %t49, 1024
|
|
%t52 = add i32 %t51, %t50
|
|
%t53 = getelementptr inbounds i32, i32* %arg.C, i32 %t52
|
|
%t54 = load i32, i32* %t1
|
|
%t55 = load i32, i32* %t2
|
|
%t56 = mul i32 %t54, 1024
|
|
%t57 = add i32 %t56, %t55
|
|
%t58 = getelementptr inbounds i32, i32* %arg.C, i32 %t57
|
|
%t59 = load i32, i32* %t58
|
|
%t60 = load i32, i32* %t1
|
|
%t61 = load i32, i32* %t3
|
|
%t62 = mul i32 %t60, 1024
|
|
%t63 = add i32 %t62, %t61
|
|
%t64 = getelementptr inbounds i32, i32* %arg.A, i32 %t63
|
|
%t65 = load i32, i32* %t64
|
|
%t66 = load i32, i32* %t3
|
|
%t67 = load i32, i32* %t2
|
|
%t68 = mul i32 %t66, 1024
|
|
%t69 = add i32 %t68, %t67
|
|
%t70 = getelementptr inbounds i32, i32* %arg.B, i32 %t69
|
|
%t71 = load i32, i32* %t70
|
|
%t72 = mul i32 %t65, %t71
|
|
%t73 = add i32 %t59, %t72
|
|
store i32 %t73, i32* %t53
|
|
%t74 = load i32, i32* %t2
|
|
%t75 = add i32 %t74, 1
|
|
store i32 %t75, i32* %t2
|
|
br label %while.cond.15
|
|
while.end.17:
|
|
%t76 = load i32, i32* %t1
|
|
%t77 = add i32 %t76, 1
|
|
store i32 %t77, i32* %t1
|
|
br label %while.cond.10
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t80 = alloca i32
|
|
%t82 = alloca i32
|
|
%t83 = alloca i32
|
|
%t141 = alloca i32
|
|
%t81 = call i32 @getint()
|
|
store i32 %t81, i32* %t80
|
|
store i32 0, i32* %t82
|
|
store i32 0, i32* %t83
|
|
store i32 0, i32* %t82
|
|
store i32 0, i32* %t83
|
|
br label %while.cond.18
|
|
while.cond.18:
|
|
%t84 = load i32, i32* %t82
|
|
%t85 = load i32, i32* %t80
|
|
%t86 = icmp slt i32 %t84, %t85
|
|
%t87 = zext i1 %t86 to i32
|
|
%t88 = icmp ne i32 %t87, 0
|
|
br i1 %t88, label %while.body.19, label %while.end.20
|
|
while.body.19:
|
|
store i32 0, i32* %t83
|
|
br label %while.cond.21
|
|
while.end.20:
|
|
store i32 0, i32* %t82
|
|
store i32 0, i32* %t83
|
|
br label %while.cond.24
|
|
while.cond.21:
|
|
%t89 = load i32, i32* %t83
|
|
%t90 = load i32, i32* %t80
|
|
%t91 = icmp slt i32 %t89, %t90
|
|
%t92 = zext i1 %t91 to i32
|
|
%t93 = icmp ne i32 %t92, 0
|
|
br i1 %t93, label %while.body.22, label %while.end.23
|
|
while.body.22:
|
|
%t94 = load i32, i32* %t82
|
|
%t95 = load i32, i32* %t83
|
|
%t96 = mul i32 %t94, 1024
|
|
%t97 = add i32 %t96, %t95
|
|
%t98 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @A, i32 0, i32 %t97
|
|
%t99 = call i32 @getint()
|
|
store i32 %t99, i32* %t98
|
|
%t100 = load i32, i32* %t83
|
|
%t101 = add i32 %t100, 1
|
|
store i32 %t101, i32* %t83
|
|
br label %while.cond.21
|
|
while.end.23:
|
|
%t102 = load i32, i32* %t82
|
|
%t103 = add i32 %t102, 1
|
|
store i32 %t103, i32* %t82
|
|
br label %while.cond.18
|
|
while.cond.24:
|
|
%t104 = load i32, i32* %t82
|
|
%t105 = load i32, i32* %t80
|
|
%t106 = icmp slt i32 %t104, %t105
|
|
%t107 = zext i1 %t106 to i32
|
|
%t108 = icmp ne i32 %t107, 0
|
|
br i1 %t108, label %while.body.25, label %while.end.26
|
|
while.body.25:
|
|
store i32 0, i32* %t83
|
|
br label %while.cond.27
|
|
while.end.26:
|
|
call void @starttime()
|
|
store i32 0, i32* %t82
|
|
br label %while.cond.30
|
|
while.cond.27:
|
|
%t109 = load i32, i32* %t83
|
|
%t110 = load i32, i32* %t80
|
|
%t111 = icmp slt i32 %t109, %t110
|
|
%t112 = zext i1 %t111 to i32
|
|
%t113 = icmp ne i32 %t112, 0
|
|
br i1 %t113, label %while.body.28, label %while.end.29
|
|
while.body.28:
|
|
%t114 = load i32, i32* %t82
|
|
%t115 = load i32, i32* %t83
|
|
%t116 = mul i32 %t114, 1024
|
|
%t117 = add i32 %t116, %t115
|
|
%t118 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @B, i32 0, i32 %t117
|
|
%t119 = call i32 @getint()
|
|
store i32 %t119, i32* %t118
|
|
%t120 = load i32, i32* %t83
|
|
%t121 = add i32 %t120, 1
|
|
store i32 %t121, i32* %t83
|
|
br label %while.cond.27
|
|
while.end.29:
|
|
%t122 = load i32, i32* %t82
|
|
%t123 = add i32 %t122, 1
|
|
store i32 %t123, i32* %t82
|
|
br label %while.cond.24
|
|
while.cond.30:
|
|
%t125 = load i32, i32* %t82
|
|
%t126 = icmp slt i32 %t125, 5
|
|
%t127 = zext i1 %t126 to i32
|
|
%t128 = icmp ne i32 %t127, 0
|
|
br i1 %t128, label %while.body.31, label %while.end.32
|
|
while.body.31:
|
|
%t129 = load i32, i32* %t80
|
|
%t130 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @A, i32 0, i32 0
|
|
%t131 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @B, i32 0, i32 0
|
|
%t132 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @C, i32 0, i32 0
|
|
call void @mm(i32 %t129, i32* %t130, i32* %t131, i32* %t132)
|
|
%t134 = load i32, i32* %t80
|
|
%t135 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @A, i32 0, i32 0
|
|
%t136 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @C, i32 0, i32 0
|
|
%t137 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @B, i32 0, i32 0
|
|
call void @mm(i32 %t134, i32* %t135, i32* %t136, i32* %t137)
|
|
%t139 = load i32, i32* %t82
|
|
%t140 = add i32 %t139, 1
|
|
store i32 %t140, i32* %t82
|
|
br label %while.cond.30
|
|
while.end.32:
|
|
store i32 0, i32* %t141
|
|
store i32 0, i32* %t82
|
|
br label %while.cond.33
|
|
while.cond.33:
|
|
%t142 = load i32, i32* %t82
|
|
%t143 = load i32, i32* %t80
|
|
%t144 = icmp slt i32 %t142, %t143
|
|
%t145 = zext i1 %t144 to i32
|
|
%t146 = icmp ne i32 %t145, 0
|
|
br i1 %t146, label %while.body.34, label %while.end.35
|
|
while.body.34:
|
|
store i32 0, i32* %t83
|
|
br label %while.cond.36
|
|
while.end.35:
|
|
call void @stoptime()
|
|
%t165 = load i32, i32* %t141
|
|
call void @putint(i32 %t165)
|
|
call void @putch(i32 10)
|
|
ret i32 0
|
|
while.cond.36:
|
|
%t147 = load i32, i32* %t83
|
|
%t148 = load i32, i32* %t80
|
|
%t149 = icmp slt i32 %t147, %t148
|
|
%t150 = zext i1 %t149 to i32
|
|
%t151 = icmp ne i32 %t150, 0
|
|
br i1 %t151, label %while.body.37, label %while.end.38
|
|
while.body.37:
|
|
%t152 = load i32, i32* %t141
|
|
%t153 = load i32, i32* %t82
|
|
%t154 = load i32, i32* %t83
|
|
%t155 = mul i32 %t153, 1024
|
|
%t156 = add i32 %t155, %t154
|
|
%t157 = getelementptr inbounds [1048576 x i32], [1048576 x i32]* @B, i32 0, i32 %t156
|
|
%t158 = load i32, i32* %t157
|
|
%t159 = add i32 %t152, %t158
|
|
store i32 %t159, i32* %t141
|
|
%t160 = load i32, i32* %t83
|
|
%t161 = add i32 %t160, 1
|
|
store i32 %t161, i32* %t83
|
|
br label %while.cond.36
|
|
while.end.38:
|
|
%t162 = load i32, i32* %t82
|
|
%t163 = add i32 %t162, 1
|
|
store i32 %t163, i32* %t82
|
|
br label %while.cond.33
|
|
}
|