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.
311 lines
9.5 KiB
311 lines
9.5 KiB
@n = global i32 1400
|
|
@A = global [1960000 x i32] zeroinitializer
|
|
@b = global [1400 x i32] zeroinitializer
|
|
@x = global [1400 x i32] zeroinitializer
|
|
@y = global [1400 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 @kernel_ludcmp(i32 %arg.n, i32* %arg.A, i32* %arg.b, i32* %arg.x, i32* %arg.y) {
|
|
entry:
|
|
%t1 = alloca i32
|
|
%t2 = alloca i32
|
|
%t3 = alloca i32
|
|
%t4 = 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* %t4
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t5 = load i32, i32* %t1
|
|
%t6 = load i32, i32* %t0
|
|
%t7 = icmp slt i32 %t5, %t6
|
|
%t8 = zext i1 %t7 to i32
|
|
%t9 = icmp ne i32 %t8, 0
|
|
br i1 %t9, 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
|
|
br label %while.cond.16
|
|
while.cond.4:
|
|
%t10 = load i32, i32* %t2
|
|
%t11 = load i32, i32* %t1
|
|
%t12 = icmp slt i32 %t10, %t11
|
|
%t13 = zext i1 %t12 to i32
|
|
%t14 = icmp ne i32 %t13, 0
|
|
br i1 %t14, label %while.body.5, label %while.end.6
|
|
while.body.5:
|
|
%t15 = load i32, i32* %t1
|
|
%t16 = load i32, i32* %t2
|
|
%t17 = mul i32 %t15, 1400
|
|
%t18 = add i32 %t17, %t16
|
|
%t19 = getelementptr inbounds i32, i32* %arg.A, i32 %t18
|
|
%t20 = load i32, i32* %t19
|
|
store i32 %t20, i32* %t4
|
|
store i32 0, i32* %t3
|
|
br label %while.cond.7
|
|
while.end.6:
|
|
%t58 = load i32, i32* %t1
|
|
store i32 %t58, i32* %t2
|
|
br label %while.cond.10
|
|
while.cond.7:
|
|
%t21 = load i32, i32* %t3
|
|
%t22 = load i32, i32* %t2
|
|
%t23 = icmp slt i32 %t21, %t22
|
|
%t24 = zext i1 %t23 to i32
|
|
%t25 = icmp ne i32 %t24, 0
|
|
br i1 %t25, label %while.body.8, label %while.end.9
|
|
while.body.8:
|
|
%t26 = load i32, i32* %t4
|
|
%t27 = load i32, i32* %t1
|
|
%t28 = load i32, i32* %t3
|
|
%t29 = mul i32 %t27, 1400
|
|
%t30 = add i32 %t29, %t28
|
|
%t31 = getelementptr inbounds i32, i32* %arg.A, i32 %t30
|
|
%t32 = load i32, i32* %t31
|
|
%t33 = load i32, i32* %t3
|
|
%t34 = load i32, i32* %t2
|
|
%t35 = mul i32 %t33, 1400
|
|
%t36 = add i32 %t35, %t34
|
|
%t37 = getelementptr inbounds i32, i32* %arg.A, i32 %t36
|
|
%t38 = load i32, i32* %t37
|
|
%t39 = mul i32 %t32, %t38
|
|
%t40 = sub i32 %t26, %t39
|
|
store i32 %t40, i32* %t4
|
|
%t41 = load i32, i32* %t3
|
|
%t42 = add i32 %t41, 1
|
|
store i32 %t42, i32* %t3
|
|
br label %while.cond.7
|
|
while.end.9:
|
|
%t43 = load i32, i32* %t1
|
|
%t44 = load i32, i32* %t2
|
|
%t45 = mul i32 %t43, 1400
|
|
%t46 = add i32 %t45, %t44
|
|
%t47 = getelementptr inbounds i32, i32* %arg.A, i32 %t46
|
|
%t48 = load i32, i32* %t4
|
|
%t49 = load i32, i32* %t2
|
|
%t50 = load i32, i32* %t2
|
|
%t51 = mul i32 %t49, 1400
|
|
%t52 = add i32 %t51, %t50
|
|
%t53 = getelementptr inbounds i32, i32* %arg.A, i32 %t52
|
|
%t54 = load i32, i32* %t53
|
|
%t55 = sdiv i32 %t48, %t54
|
|
store i32 %t55, i32* %t47
|
|
%t56 = load i32, i32* %t2
|
|
%t57 = add i32 %t56, 1
|
|
store i32 %t57, i32* %t2
|
|
br label %while.cond.4
|
|
while.cond.10:
|
|
%t59 = load i32, i32* %t2
|
|
%t60 = load i32, i32* %t0
|
|
%t61 = icmp slt i32 %t59, %t60
|
|
%t62 = zext i1 %t61 to i32
|
|
%t63 = icmp ne i32 %t62, 0
|
|
br i1 %t63, label %while.body.11, label %while.end.12
|
|
while.body.11:
|
|
%t64 = load i32, i32* %t1
|
|
%t65 = load i32, i32* %t2
|
|
%t66 = mul i32 %t64, 1400
|
|
%t67 = add i32 %t66, %t65
|
|
%t68 = getelementptr inbounds i32, i32* %arg.A, i32 %t67
|
|
%t69 = load i32, i32* %t68
|
|
store i32 %t69, i32* %t4
|
|
store i32 0, i32* %t3
|
|
br label %while.cond.13
|
|
while.end.12:
|
|
%t100 = load i32, i32* %t1
|
|
%t101 = add i32 %t100, 1
|
|
store i32 %t101, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.13:
|
|
%t70 = load i32, i32* %t3
|
|
%t71 = load i32, i32* %t1
|
|
%t72 = icmp slt i32 %t70, %t71
|
|
%t73 = zext i1 %t72 to i32
|
|
%t74 = icmp ne i32 %t73, 0
|
|
br i1 %t74, label %while.body.14, label %while.end.15
|
|
while.body.14:
|
|
%t75 = load i32, i32* %t4
|
|
%t76 = load i32, i32* %t1
|
|
%t77 = load i32, i32* %t3
|
|
%t78 = mul i32 %t76, 1400
|
|
%t79 = add i32 %t78, %t77
|
|
%t80 = getelementptr inbounds i32, i32* %arg.A, i32 %t79
|
|
%t81 = load i32, i32* %t80
|
|
%t82 = load i32, i32* %t3
|
|
%t83 = load i32, i32* %t2
|
|
%t84 = mul i32 %t82, 1400
|
|
%t85 = add i32 %t84, %t83
|
|
%t86 = getelementptr inbounds i32, i32* %arg.A, i32 %t85
|
|
%t87 = load i32, i32* %t86
|
|
%t88 = mul i32 %t81, %t87
|
|
%t89 = sub i32 %t75, %t88
|
|
store i32 %t89, i32* %t4
|
|
%t90 = load i32, i32* %t3
|
|
%t91 = add i32 %t90, 1
|
|
store i32 %t91, i32* %t3
|
|
br label %while.cond.13
|
|
while.end.15:
|
|
%t92 = load i32, i32* %t1
|
|
%t93 = load i32, i32* %t2
|
|
%t94 = mul i32 %t92, 1400
|
|
%t95 = add i32 %t94, %t93
|
|
%t96 = getelementptr inbounds i32, i32* %arg.A, i32 %t95
|
|
%t97 = load i32, i32* %t4
|
|
store i32 %t97, i32* %t96
|
|
%t98 = load i32, i32* %t2
|
|
%t99 = add i32 %t98, 1
|
|
store i32 %t99, i32* %t2
|
|
br label %while.cond.10
|
|
while.cond.16:
|
|
%t102 = load i32, i32* %t1
|
|
%t103 = load i32, i32* %t0
|
|
%t104 = icmp slt i32 %t102, %t103
|
|
%t105 = zext i1 %t104 to i32
|
|
%t106 = icmp ne i32 %t105, 0
|
|
br i1 %t106, label %while.body.17, label %while.end.18
|
|
while.body.17:
|
|
%t107 = load i32, i32* %t1
|
|
%t108 = getelementptr inbounds i32, i32* %arg.b, i32 %t107
|
|
%t109 = load i32, i32* %t108
|
|
store i32 %t109, i32* %t4
|
|
store i32 0, i32* %t2
|
|
br label %while.cond.19
|
|
while.end.18:
|
|
%t134 = load i32, i32* %t0
|
|
%t135 = sub i32 %t134, 1
|
|
store i32 %t135, i32* %t1
|
|
br label %while.cond.22
|
|
while.cond.19:
|
|
%t110 = load i32, i32* %t2
|
|
%t111 = load i32, i32* %t1
|
|
%t112 = icmp slt i32 %t110, %t111
|
|
%t113 = zext i1 %t112 to i32
|
|
%t114 = icmp ne i32 %t113, 0
|
|
br i1 %t114, label %while.body.20, label %while.end.21
|
|
while.body.20:
|
|
%t115 = load i32, i32* %t4
|
|
%t116 = load i32, i32* %t1
|
|
%t117 = load i32, i32* %t2
|
|
%t118 = mul i32 %t116, 1400
|
|
%t119 = add i32 %t118, %t117
|
|
%t120 = getelementptr inbounds i32, i32* %arg.A, i32 %t119
|
|
%t121 = load i32, i32* %t120
|
|
%t122 = load i32, i32* %t2
|
|
%t123 = getelementptr inbounds i32, i32* %arg.y, i32 %t122
|
|
%t124 = load i32, i32* %t123
|
|
%t125 = mul i32 %t121, %t124
|
|
%t126 = sub i32 %t115, %t125
|
|
store i32 %t126, i32* %t4
|
|
%t127 = load i32, i32* %t2
|
|
%t128 = add i32 %t127, 1
|
|
store i32 %t128, i32* %t2
|
|
br label %while.cond.19
|
|
while.end.21:
|
|
%t129 = load i32, i32* %t1
|
|
%t130 = getelementptr inbounds i32, i32* %arg.y, i32 %t129
|
|
%t131 = load i32, i32* %t4
|
|
store i32 %t131, i32* %t130
|
|
%t132 = load i32, i32* %t1
|
|
%t133 = add i32 %t132, 1
|
|
store i32 %t133, i32* %t1
|
|
br label %while.cond.16
|
|
while.cond.22:
|
|
%t136 = load i32, i32* %t1
|
|
%t137 = icmp sge i32 %t136, 0
|
|
%t138 = zext i1 %t137 to i32
|
|
%t139 = icmp ne i32 %t138, 0
|
|
br i1 %t139, label %while.body.23, label %while.end.24
|
|
while.body.23:
|
|
%t140 = load i32, i32* %t1
|
|
%t141 = getelementptr inbounds i32, i32* %arg.y, i32 %t140
|
|
%t142 = load i32, i32* %t141
|
|
store i32 %t142, i32* %t4
|
|
%t143 = load i32, i32* %t1
|
|
%t144 = add i32 %t143, 1
|
|
store i32 %t144, i32* %t2
|
|
br label %while.cond.25
|
|
while.end.24:
|
|
ret void
|
|
while.cond.25:
|
|
%t145 = load i32, i32* %t2
|
|
%t146 = load i32, i32* %t0
|
|
%t147 = icmp slt i32 %t145, %t146
|
|
%t148 = zext i1 %t147 to i32
|
|
%t149 = icmp ne i32 %t148, 0
|
|
br i1 %t149, label %while.body.26, label %while.end.27
|
|
while.body.26:
|
|
%t150 = load i32, i32* %t4
|
|
%t151 = load i32, i32* %t1
|
|
%t152 = load i32, i32* %t2
|
|
%t153 = mul i32 %t151, 1400
|
|
%t154 = add i32 %t153, %t152
|
|
%t155 = getelementptr inbounds i32, i32* %arg.A, i32 %t154
|
|
%t156 = load i32, i32* %t155
|
|
%t157 = load i32, i32* %t2
|
|
%t158 = getelementptr inbounds i32, i32* %arg.x, i32 %t157
|
|
%t159 = load i32, i32* %t158
|
|
%t160 = mul i32 %t156, %t159
|
|
%t161 = sub i32 %t150, %t160
|
|
store i32 %t161, i32* %t4
|
|
%t162 = load i32, i32* %t2
|
|
%t163 = add i32 %t162, 1
|
|
store i32 %t163, i32* %t2
|
|
br label %while.cond.25
|
|
while.end.27:
|
|
%t164 = load i32, i32* %t1
|
|
%t165 = getelementptr inbounds i32, i32* %arg.x, i32 %t164
|
|
%t166 = load i32, i32* %t4
|
|
%t167 = load i32, i32* %t1
|
|
%t168 = load i32, i32* %t1
|
|
%t169 = mul i32 %t167, 1400
|
|
%t170 = add i32 %t169, %t168
|
|
%t171 = getelementptr inbounds i32, i32* %arg.A, i32 %t170
|
|
%t172 = load i32, i32* %t171
|
|
%t173 = sdiv i32 %t166, %t172
|
|
store i32 %t173, i32* %t165
|
|
%t174 = load i32, i32* %t1
|
|
%t175 = sub i32 %t174, 1
|
|
store i32 %t175, i32* %t1
|
|
br label %while.cond.22
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t176 = getelementptr inbounds [1960000 x i32], [1960000 x i32]* @A, i32 0, i32 0
|
|
%t177 = call i32 @getarray(i32* %t176)
|
|
%t178 = getelementptr inbounds [1400 x i32], [1400 x i32]* @b, i32 0, i32 0
|
|
%t179 = call i32 @getarray(i32* %t178)
|
|
%t180 = getelementptr inbounds [1400 x i32], [1400 x i32]* @x, i32 0, i32 0
|
|
%t181 = call i32 @getarray(i32* %t180)
|
|
%t182 = getelementptr inbounds [1400 x i32], [1400 x i32]* @y, i32 0, i32 0
|
|
%t183 = call i32 @getarray(i32* %t182)
|
|
call void @starttime()
|
|
%t185 = load i32, i32* @n
|
|
%t186 = getelementptr inbounds [1960000 x i32], [1960000 x i32]* @A, i32 0, i32 0
|
|
%t187 = getelementptr inbounds [1400 x i32], [1400 x i32]* @b, i32 0, i32 0
|
|
%t188 = getelementptr inbounds [1400 x i32], [1400 x i32]* @x, i32 0, i32 0
|
|
%t189 = getelementptr inbounds [1400 x i32], [1400 x i32]* @y, i32 0, i32 0
|
|
call void @kernel_ludcmp(i32 %t185, i32* %t186, i32* %t187, i32* %t188, i32* %t189)
|
|
call void @stoptime()
|
|
%t192 = load i32, i32* @n
|
|
%t193 = getelementptr inbounds [1400 x i32], [1400 x i32]* @x, i32 0, i32 0
|
|
call void @putarray(i32 %t192, i32* %t193)
|
|
ret i32 0
|
|
}
|