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