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