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.

609 lines
19 KiB

@MAX_DIM_X = global i32 8
@MAX_DIM_Y = global i32 8
@test_block = global [64 x float] zeroinitializer
@test_dct = global [64 x float] zeroinitializer
@test_idct = global [64 x float] zeroinitializer
@PI = global float 0x400921FB60000000
@TWO_PI = global float 0x401921FB60000000
@EPSILON = global float 0x3EB0C6F7A0000000
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 float @my_fabs(float %arg.x) {
entry:
%t0 = alloca float
store float %arg.x, float* %t0
%t1 = load float, float* %t0
%t2 = fcmp ogt float %t1, 0x0000000000000000
%t3 = zext i1 %t2 to i32
%t4 = icmp ne i32 %t3, 0
br i1 %t4, label %if.then.1, label %if.end.2
if.then.1:
%t5 = load float, float* %t0
ret float %t5
if.end.2:
%t6 = load float, float* %t0
%t7 = fsub float 0x0000000000000000, %t6
ret float %t7
}
define float @p(float %arg.x) {
entry:
%t8 = alloca float
store float %arg.x, float* %t8
%t9 = load float, float* %t8
%t10 = fmul float 0x4008000000000000, %t9
%t11 = load float, float* %t8
%t12 = fmul float 0x4010000000000000, %t11
%t13 = load float, float* %t8
%t14 = fmul float %t12, %t13
%t15 = load float, float* %t8
%t16 = fmul float %t14, %t15
%t17 = fsub float %t10, %t16
ret float %t17
}
define float @my_sin_impl(float %arg.x) {
entry:
%t18 = alloca float
store float %arg.x, float* %t18
%t19 = load float, float* %t18
%t20 = call float @my_fabs(float %t19)
%t21 = load float, float* @EPSILON
%t22 = fcmp ole float %t20, %t21
%t23 = zext i1 %t22 to i32
%t24 = icmp ne i32 %t23, 0
br i1 %t24, label %if.then.3, label %if.end.4
if.then.3:
%t25 = load float, float* %t18
ret float %t25
if.end.4:
%t26 = load float, float* %t18
%t27 = fdiv float %t26, 0x4008000000000000
%t28 = call float @my_sin_impl(float %t27)
%t29 = call float @p(float %t28)
ret float %t29
}
define float @my_sin(float %arg.x) {
entry:
%t42 = alloca i32
%t30 = alloca float
store float %arg.x, float* %t30
%t31 = load float, float* %t30
%t32 = load float, float* @TWO_PI
%t33 = fcmp ogt float %t31, %t32
%t34 = zext i1 %t33 to i32
%t35 = icmp ne i32 %t34, 0
br i1 %t35, label %if.then.5, label %lor.rhs.7
if.then.5:
%t43 = load float, float* %t30
%t44 = load float, float* @TWO_PI
%t45 = fdiv float %t43, %t44
%t46 = fptosi float %t45 to i32
store i32 %t46, i32* %t42
%t47 = load float, float* %t30
%t48 = load i32, i32* %t42
%t49 = load float, float* @TWO_PI
%t50 = sitofp i32 %t48 to float
%t51 = fmul float %t50, %t49
%t52 = fsub float %t47, %t51
store float %t52, float* %t30
br label %if.end.6
if.end.6:
%t53 = load float, float* %t30
%t54 = load float, float* @PI
%t55 = fcmp ogt float %t53, %t54
%t56 = zext i1 %t55 to i32
%t57 = icmp ne i32 %t56, 0
br i1 %t57, label %if.then.8, label %if.end.9
lor.rhs.7:
%t36 = load float, float* %t30
%t37 = load float, float* @TWO_PI
%t38 = fsub float 0x0000000000000000, %t37
%t39 = fcmp olt float %t36, %t38
%t40 = zext i1 %t39 to i32
%t41 = icmp ne i32 %t40, 0
br i1 %t41, label %if.then.5, label %if.end.6
if.then.8:
%t58 = load float, float* %t30
%t59 = load float, float* @TWO_PI
%t60 = fsub float %t58, %t59
store float %t60, float* %t30
br label %if.end.9
if.end.9:
%t61 = load float, float* %t30
%t62 = load float, float* @PI
%t63 = fsub float 0x0000000000000000, %t62
%t64 = fcmp olt float %t61, %t63
%t65 = zext i1 %t64 to i32
%t66 = icmp ne i32 %t65, 0
br i1 %t66, label %if.then.10, label %if.end.11
if.then.10:
%t67 = load float, float* %t30
%t68 = load float, float* @TWO_PI
%t69 = fadd float %t67, %t68
store float %t69, float* %t30
br label %if.end.11
if.end.11:
%t70 = load float, float* %t30
%t71 = call float @my_sin_impl(float %t70)
ret float %t71
}
define float @my_cos(float %arg.x) {
entry:
%t72 = alloca float
store float %arg.x, float* %t72
%t73 = load float, float* %t72
%t74 = load float, float* @PI
%t75 = fdiv float %t74, 0x4000000000000000
%t76 = fadd float %t73, %t75
%t77 = call float @my_sin(float %t76)
ret float %t77
}
define void @write_mat(float* %arg.mat, i32 %arg.n, i32 %arg.m) {
entry:
%t80 = alloca i32
%t91 = alloca i32
%t78 = alloca i32
store i32 %arg.n, i32* %t78
%t79 = alloca i32
store i32 %arg.m, i32* %t79
store i32 0, i32* %t80
br label %while.cond.12
while.cond.12:
%t81 = load i32, i32* %t80
%t82 = load i32, i32* %t78
%t83 = icmp slt i32 %t81, %t82
%t84 = zext i1 %t83 to i32
%t85 = icmp ne i32 %t84, 0
br i1 %t85, label %while.body.13, label %while.end.14
while.body.13:
%t86 = load i32, i32* %t80
%t87 = mul i32 %t86, 8
%t88 = getelementptr inbounds float, float* %arg.mat, i32 %t87
%t89 = load float, float* %t88
call void @putfloat(float %t89)
store i32 1, i32* %t91
br label %while.cond.15
while.end.14:
call void @putch(i32 10)
ret void
while.cond.15:
%t92 = load i32, i32* %t91
%t93 = load i32, i32* %t79
%t94 = icmp slt i32 %t92, %t93
%t95 = zext i1 %t94 to i32
%t96 = icmp ne i32 %t95, 0
br i1 %t96, label %while.body.16, label %while.end.17
while.body.16:
call void @putch(i32 32)
%t98 = load i32, i32* %t80
%t99 = load i32, i32* %t91
%t100 = mul i32 %t98, 8
%t101 = add i32 %t100, %t99
%t102 = getelementptr inbounds float, float* %arg.mat, i32 %t101
%t103 = load float, float* %t102
call void @putfloat(float %t103)
%t105 = load i32, i32* %t91
%t106 = add i32 %t105, 1
store i32 %t106, i32* %t91
br label %while.cond.15
while.end.17:
call void @putch(i32 10)
%t108 = load i32, i32* %t80
%t109 = add i32 %t108, 1
store i32 %t109, i32* %t80
br label %while.cond.12
}
define void @dct(float* %arg.dct_mat, float* %arg.mat, i32 %arg.n, i32 %arg.m) {
entry:
%t113 = alloca i32
%t119 = alloca i32
%t130 = alloca i32
%t136 = alloca i32
%t111 = alloca i32
store i32 %arg.n, i32* %t111
%t112 = alloca i32
store i32 %arg.m, i32* %t112
store i32 0, i32* %t113
br label %while.cond.18
while.cond.18:
%t114 = load i32, i32* %t113
%t115 = load i32, i32* %t111
%t116 = icmp slt i32 %t114, %t115
%t117 = zext i1 %t116 to i32
%t118 = icmp ne i32 %t117, 0
br i1 %t118, label %while.body.19, label %while.end.20
while.body.19:
store i32 0, i32* %t119
br label %while.cond.21
while.end.20:
ret void
while.cond.21:
%t120 = load i32, i32* %t119
%t121 = load i32, i32* %t112
%t122 = icmp slt i32 %t120, %t121
%t123 = zext i1 %t122 to i32
%t124 = icmp ne i32 %t123, 0
br i1 %t124, label %while.body.22, label %while.end.23
while.body.22:
%t125 = load i32, i32* %t113
%t126 = load i32, i32* %t119
%t127 = mul i32 %t125, 8
%t128 = add i32 %t127, %t126
%t129 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t128
store float 0x0000000000000000, float* %t129
store i32 0, i32* %t130
br label %while.cond.24
while.end.23:
%t192 = load i32, i32* %t113
%t193 = add i32 %t192, 1
store i32 %t193, i32* %t113
br label %while.cond.18
while.cond.24:
%t131 = load i32, i32* %t130
%t132 = load i32, i32* %t111
%t133 = icmp slt i32 %t131, %t132
%t134 = zext i1 %t133 to i32
%t135 = icmp ne i32 %t134, 0
br i1 %t135, label %while.body.25, label %while.end.26
while.body.25:
store i32 0, i32* %t136
br label %while.cond.27
while.end.26:
%t190 = load i32, i32* %t119
%t191 = add i32 %t190, 1
store i32 %t191, i32* %t119
br label %while.cond.21
while.cond.27:
%t137 = load i32, i32* %t136
%t138 = load i32, i32* %t112
%t139 = icmp slt i32 %t137, %t138
%t140 = zext i1 %t139 to i32
%t141 = icmp ne i32 %t140, 0
br i1 %t141, label %while.body.28, label %while.end.29
while.body.28:
%t142 = load i32, i32* %t113
%t143 = load i32, i32* %t119
%t144 = mul i32 %t142, 8
%t145 = add i32 %t144, %t143
%t146 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t145
%t147 = load i32, i32* %t113
%t148 = load i32, i32* %t119
%t149 = mul i32 %t147, 8
%t150 = add i32 %t149, %t148
%t151 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t150
%t152 = load float, float* %t151
%t153 = load i32, i32* %t130
%t154 = load i32, i32* %t136
%t155 = mul i32 %t153, 8
%t156 = add i32 %t155, %t154
%t157 = getelementptr inbounds float, float* %arg.mat, i32 %t156
%t158 = load float, float* %t157
%t159 = load float, float* @PI
%t160 = load i32, i32* %t111
%t161 = sitofp i32 %t160 to float
%t162 = fdiv float %t159, %t161
%t163 = load i32, i32* %t130
%t164 = sitofp i32 %t163 to float
%t165 = fadd float %t164, 0x3FE0000000000000
%t166 = fmul float %t162, %t165
%t167 = load i32, i32* %t113
%t168 = sitofp i32 %t167 to float
%t169 = fmul float %t166, %t168
%t170 = call float @my_cos(float %t169)
%t171 = fmul float %t158, %t170
%t172 = load float, float* @PI
%t173 = load i32, i32* %t112
%t174 = sitofp i32 %t173 to float
%t175 = fdiv float %t172, %t174
%t176 = load i32, i32* %t136
%t177 = sitofp i32 %t176 to float
%t178 = fadd float %t177, 0x3FE0000000000000
%t179 = fmul float %t175, %t178
%t180 = load i32, i32* %t119
%t181 = sitofp i32 %t180 to float
%t182 = fmul float %t179, %t181
%t183 = call float @my_cos(float %t182)
%t184 = fmul float %t171, %t183
%t185 = fadd float %t152, %t184
store float %t185, float* %t146
%t186 = load i32, i32* %t136
%t187 = add i32 %t186, 1
store i32 %t187, i32* %t136
br label %while.cond.27
while.end.29:
%t188 = load i32, i32* %t130
%t189 = add i32 %t188, 1
store i32 %t189, i32* %t130
br label %while.cond.24
}
define void @idct(float* %arg.mat, float* %arg.dct_mat, i32 %arg.n, i32 %arg.m) {
entry:
%t196 = alloca i32
%t202 = alloca i32
%t216 = alloca i32
%t217 = alloca i32
%t194 = alloca i32
store i32 %arg.n, i32* %t194
%t195 = alloca i32
store i32 %arg.m, i32* %t195
store i32 0, i32* %t196
br label %while.cond.30
while.cond.30:
%t197 = load i32, i32* %t196
%t198 = load i32, i32* %t194
%t199 = icmp slt i32 %t197, %t198
%t200 = zext i1 %t199 to i32
%t201 = icmp ne i32 %t200, 0
br i1 %t201, label %while.body.31, label %while.end.32
while.body.31:
store i32 0, i32* %t202
br label %while.cond.33
while.end.32:
ret void
while.cond.33:
%t203 = load i32, i32* %t202
%t204 = load i32, i32* %t195
%t205 = icmp slt i32 %t203, %t204
%t206 = zext i1 %t205 to i32
%t207 = icmp ne i32 %t206, 0
br i1 %t207, label %while.body.34, label %while.end.35
while.body.34:
%t208 = load i32, i32* %t196
%t209 = load i32, i32* %t202
%t210 = mul i32 %t208, 8
%t211 = add i32 %t210, %t209
%t212 = getelementptr inbounds float, float* %arg.mat, i32 %t211
%t213 = getelementptr inbounds float, float* %arg.dct_mat, i32 0
%t214 = load float, float* %t213
%t215 = fmul float 0x3FD0000000000000, %t214
store float %t215, float* %t212
store i32 0, i32* %t216
store i32 0, i32* %t217
store i32 1, i32* %t216
br label %while.cond.36
while.end.35:
%t344 = load i32, i32* %t196
%t345 = add i32 %t344, 1
store i32 %t345, i32* %t196
br label %while.cond.30
while.cond.36:
%t218 = load i32, i32* %t216
%t219 = load i32, i32* %t194
%t220 = icmp slt i32 %t218, %t219
%t221 = zext i1 %t220 to i32
%t222 = icmp ne i32 %t221, 0
br i1 %t222, label %while.body.37, label %while.end.38
while.body.37:
%t223 = load i32, i32* %t196
%t224 = load i32, i32* %t202
%t225 = mul i32 %t223, 8
%t226 = add i32 %t225, %t224
%t227 = getelementptr inbounds float, float* %arg.mat, i32 %t226
%t228 = load i32, i32* %t196
%t229 = load i32, i32* %t202
%t230 = mul i32 %t228, 8
%t231 = add i32 %t230, %t229
%t232 = getelementptr inbounds float, float* %arg.mat, i32 %t231
%t233 = load float, float* %t232
%t234 = load i32, i32* %t216
%t235 = mul i32 %t234, 8
%t236 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t235
%t237 = load float, float* %t236
%t238 = fmul float 0x3FE0000000000000, %t237
%t239 = fadd float %t233, %t238
store float %t239, float* %t227
%t240 = load i32, i32* %t216
%t241 = add i32 %t240, 1
store i32 %t241, i32* %t216
br label %while.cond.36
while.end.38:
store i32 1, i32* %t217
br label %while.cond.39
while.cond.39:
%t242 = load i32, i32* %t217
%t243 = load i32, i32* %t195
%t244 = icmp slt i32 %t242, %t243
%t245 = zext i1 %t244 to i32
%t246 = icmp ne i32 %t245, 0
br i1 %t246, label %while.body.40, label %while.end.41
while.body.40:
%t247 = load i32, i32* %t196
%t248 = load i32, i32* %t202
%t249 = mul i32 %t247, 8
%t250 = add i32 %t249, %t248
%t251 = getelementptr inbounds float, float* %arg.mat, i32 %t250
%t252 = load i32, i32* %t196
%t253 = load i32, i32* %t202
%t254 = mul i32 %t252, 8
%t255 = add i32 %t254, %t253
%t256 = getelementptr inbounds float, float* %arg.mat, i32 %t255
%t257 = load float, float* %t256
%t258 = load i32, i32* %t217
%t259 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t258
%t260 = load float, float* %t259
%t261 = fmul float 0x3FE0000000000000, %t260
%t262 = fadd float %t257, %t261
store float %t262, float* %t251
%t263 = load i32, i32* %t217
%t264 = add i32 %t263, 1
store i32 %t264, i32* %t217
br label %while.cond.39
while.end.41:
store i32 1, i32* %t216
br label %while.cond.42
while.cond.42:
%t265 = load i32, i32* %t216
%t266 = load i32, i32* %t194
%t267 = icmp slt i32 %t265, %t266
%t268 = zext i1 %t267 to i32
%t269 = icmp ne i32 %t268, 0
br i1 %t269, label %while.body.43, label %while.end.44
while.body.43:
store i32 1, i32* %t217
br label %while.cond.45
while.end.44:
%t323 = load i32, i32* %t196
%t324 = load i32, i32* %t202
%t325 = mul i32 %t323, 8
%t326 = add i32 %t325, %t324
%t327 = getelementptr inbounds float, float* %arg.mat, i32 %t326
%t328 = load i32, i32* %t196
%t329 = load i32, i32* %t202
%t330 = mul i32 %t328, 8
%t331 = add i32 %t330, %t329
%t332 = getelementptr inbounds float, float* %arg.mat, i32 %t331
%t333 = load float, float* %t332
%t334 = fmul float %t333, 0x4000000000000000
%t335 = load i32, i32* %t194
%t336 = sitofp i32 %t335 to float
%t337 = fdiv float %t334, %t336
%t338 = fmul float %t337, 0x4000000000000000
%t339 = load i32, i32* %t195
%t340 = sitofp i32 %t339 to float
%t341 = fdiv float %t338, %t340
store float %t341, float* %t327
%t342 = load i32, i32* %t202
%t343 = add i32 %t342, 1
store i32 %t343, i32* %t202
br label %while.cond.33
while.cond.45:
%t270 = load i32, i32* %t217
%t271 = load i32, i32* %t195
%t272 = icmp slt i32 %t270, %t271
%t273 = zext i1 %t272 to i32
%t274 = icmp ne i32 %t273, 0
br i1 %t274, label %while.body.46, label %while.end.47
while.body.46:
%t275 = load i32, i32* %t196
%t276 = load i32, i32* %t202
%t277 = mul i32 %t275, 8
%t278 = add i32 %t277, %t276
%t279 = getelementptr inbounds float, float* %arg.mat, i32 %t278
%t280 = load i32, i32* %t196
%t281 = load i32, i32* %t202
%t282 = mul i32 %t280, 8
%t283 = add i32 %t282, %t281
%t284 = getelementptr inbounds float, float* %arg.mat, i32 %t283
%t285 = load float, float* %t284
%t286 = load i32, i32* %t216
%t287 = load i32, i32* %t217
%t288 = mul i32 %t286, 8
%t289 = add i32 %t288, %t287
%t290 = getelementptr inbounds float, float* %arg.dct_mat, i32 %t289
%t291 = load float, float* %t290
%t292 = load float, float* @PI
%t293 = load i32, i32* %t194
%t294 = sitofp i32 %t293 to float
%t295 = fdiv float %t292, %t294
%t296 = load i32, i32* %t196
%t297 = sitofp i32 %t296 to float
%t298 = fadd float %t297, 0x3FE0000000000000
%t299 = fmul float %t295, %t298
%t300 = load i32, i32* %t216
%t301 = sitofp i32 %t300 to float
%t302 = fmul float %t299, %t301
%t303 = call float @my_cos(float %t302)
%t304 = fmul float %t291, %t303
%t305 = load float, float* @PI
%t306 = load i32, i32* %t195
%t307 = sitofp i32 %t306 to float
%t308 = fdiv float %t305, %t307
%t309 = load i32, i32* %t202
%t310 = sitofp i32 %t309 to float
%t311 = fadd float %t310, 0x3FE0000000000000
%t312 = fmul float %t308, %t311
%t313 = load i32, i32* %t217
%t314 = sitofp i32 %t313 to float
%t315 = fmul float %t312, %t314
%t316 = call float @my_cos(float %t315)
%t317 = fmul float %t304, %t316
%t318 = fadd float %t285, %t317
store float %t318, float* %t279
%t319 = load i32, i32* %t217
%t320 = add i32 %t319, 1
store i32 %t320, i32* %t217
br label %while.cond.45
while.end.47:
%t321 = load i32, i32* %t216
%t322 = add i32 %t321, 1
store i32 %t322, i32* %t216
br label %while.cond.42
}
define i32 @main() {
entry:
%t346 = alloca i32
%t348 = alloca i32
%t350 = alloca i32
%t356 = alloca i32
%t347 = call i32 @getint()
store i32 %t347, i32* %t346
%t349 = call i32 @getint()
store i32 %t349, i32* %t348
store i32 0, i32* %t350
br label %while.cond.48
while.cond.48:
%t351 = load i32, i32* %t350
%t352 = load i32, i32* %t346
%t353 = icmp slt i32 %t351, %t352
%t354 = zext i1 %t353 to i32
%t355 = icmp ne i32 %t354, 0
br i1 %t355, label %while.body.49, label %while.end.50
while.body.49:
store i32 0, i32* %t356
br label %while.cond.51
while.end.50:
%t372 = load i32, i32* %t346
%t373 = load i32, i32* %t348
%t374 = getelementptr inbounds [64 x float], [64 x float]* @test_dct, i32 0, i32 0
%t375 = getelementptr inbounds [64 x float], [64 x float]* @test_block, i32 0, i32 0
call void @dct(float* %t374, float* %t375, i32 %t372, i32 %t373)
%t377 = load i32, i32* %t346
%t378 = load i32, i32* %t348
%t379 = getelementptr inbounds [64 x float], [64 x float]* @test_dct, i32 0, i32 0
call void @write_mat(float* %t379, i32 %t377, i32 %t378)
%t381 = load i32, i32* %t346
%t382 = load i32, i32* %t348
%t383 = getelementptr inbounds [64 x float], [64 x float]* @test_idct, i32 0, i32 0
%t384 = getelementptr inbounds [64 x float], [64 x float]* @test_dct, i32 0, i32 0
call void @idct(float* %t383, float* %t384, i32 %t381, i32 %t382)
%t386 = load i32, i32* %t346
%t387 = load i32, i32* %t348
%t388 = getelementptr inbounds [64 x float], [64 x float]* @test_idct, i32 0, i32 0
call void @write_mat(float* %t388, i32 %t386, i32 %t387)
ret i32 0
while.cond.51:
%t357 = load i32, i32* %t356
%t358 = load i32, i32* %t348
%t359 = icmp slt i32 %t357, %t358
%t360 = zext i1 %t359 to i32
%t361 = icmp ne i32 %t360, 0
br i1 %t361, label %while.body.52, label %while.end.53
while.body.52:
%t362 = load i32, i32* %t350
%t363 = load i32, i32* %t356
%t364 = mul i32 %t362, 8
%t365 = add i32 %t364, %t363
%t366 = getelementptr inbounds [64 x float], [64 x float]* @test_block, i32 0, i32 %t365
%t367 = call float @getfloat()
store float %t367, float* %t366
%t368 = load i32, i32* %t356
%t369 = add i32 %t368, 1
store i32 %t369, i32* %t356
br label %while.cond.51
while.end.53:
%t370 = load i32, i32* %t350
%t371 = add i32 %t370, 1
store i32 %t371, i32* %t350
br label %while.cond.48
}