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