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