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.

336 lines
12 KiB

@M = global i32 0
@L = global i32 0
@N = 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 i32 @mul(float* %arg.a0, float* %arg.a1, float* %arg.a2, float* %arg.b0, float* %arg.b1, float* %arg.b2, float* %arg.c0, float* %arg.c1, float* %arg.c2) {
entry:
%t0 = alloca i32
store i32 0, i32* %t0
store i32 0, i32* %t0
%t1 = getelementptr inbounds float, float* %arg.c0, i32 0
%t2 = getelementptr inbounds float, float* %arg.a0, i32 0
%t3 = load float, float* %t2
%t4 = getelementptr inbounds float, float* %arg.b0, i32 0
%t5 = load float, float* %t4
%t6 = fmul float %t3, %t5
%t7 = getelementptr inbounds float, float* %arg.a0, i32 1
%t8 = load float, float* %t7
%t9 = getelementptr inbounds float, float* %arg.b1, i32 0
%t10 = load float, float* %t9
%t11 = fmul float %t8, %t10
%t12 = fadd float %t6, %t11
%t13 = getelementptr inbounds float, float* %arg.a0, i32 2
%t14 = load float, float* %t13
%t15 = getelementptr inbounds float, float* %arg.b2, i32 0
%t16 = load float, float* %t15
%t17 = fmul float %t14, %t16
%t18 = fadd float %t12, %t17
store float %t18, float* %t1
%t19 = getelementptr inbounds float, float* %arg.c0, i32 1
%t20 = getelementptr inbounds float, float* %arg.a0, i32 0
%t21 = load float, float* %t20
%t22 = getelementptr inbounds float, float* %arg.b0, i32 1
%t23 = load float, float* %t22
%t24 = fmul float %t21, %t23
%t25 = getelementptr inbounds float, float* %arg.a0, i32 1
%t26 = load float, float* %t25
%t27 = getelementptr inbounds float, float* %arg.b1, i32 1
%t28 = load float, float* %t27
%t29 = fmul float %t26, %t28
%t30 = fadd float %t24, %t29
%t31 = getelementptr inbounds float, float* %arg.a0, i32 2
%t32 = load float, float* %t31
%t33 = getelementptr inbounds float, float* %arg.b2, i32 1
%t34 = load float, float* %t33
%t35 = fmul float %t32, %t34
%t36 = fadd float %t30, %t35
store float %t36, float* %t19
%t37 = getelementptr inbounds float, float* %arg.c0, i32 2
%t38 = getelementptr inbounds float, float* %arg.a0, i32 0
%t39 = load float, float* %t38
%t40 = getelementptr inbounds float, float* %arg.b0, i32 2
%t41 = load float, float* %t40
%t42 = fmul float %t39, %t41
%t43 = getelementptr inbounds float, float* %arg.a0, i32 1
%t44 = load float, float* %t43
%t45 = getelementptr inbounds float, float* %arg.b1, i32 2
%t46 = load float, float* %t45
%t47 = fmul float %t44, %t46
%t48 = fadd float %t42, %t47
%t49 = getelementptr inbounds float, float* %arg.a0, i32 2
%t50 = load float, float* %t49
%t51 = getelementptr inbounds float, float* %arg.b2, i32 2
%t52 = load float, float* %t51
%t53 = fmul float %t50, %t52
%t54 = fadd float %t48, %t53
store float %t54, float* %t37
%t55 = getelementptr inbounds float, float* %arg.c1, i32 0
%t56 = getelementptr inbounds float, float* %arg.a1, i32 0
%t57 = load float, float* %t56
%t58 = getelementptr inbounds float, float* %arg.b0, i32 0
%t59 = load float, float* %t58
%t60 = fmul float %t57, %t59
%t61 = getelementptr inbounds float, float* %arg.a1, i32 1
%t62 = load float, float* %t61
%t63 = getelementptr inbounds float, float* %arg.b1, i32 0
%t64 = load float, float* %t63
%t65 = fmul float %t62, %t64
%t66 = fadd float %t60, %t65
%t67 = getelementptr inbounds float, float* %arg.a1, i32 2
%t68 = load float, float* %t67
%t69 = getelementptr inbounds float, float* %arg.b2, i32 0
%t70 = load float, float* %t69
%t71 = fmul float %t68, %t70
%t72 = fadd float %t66, %t71
store float %t72, float* %t55
%t73 = getelementptr inbounds float, float* %arg.c1, i32 1
%t74 = getelementptr inbounds float, float* %arg.a1, i32 0
%t75 = load float, float* %t74
%t76 = getelementptr inbounds float, float* %arg.b0, i32 1
%t77 = load float, float* %t76
%t78 = fmul float %t75, %t77
%t79 = getelementptr inbounds float, float* %arg.a1, i32 1
%t80 = load float, float* %t79
%t81 = getelementptr inbounds float, float* %arg.b1, i32 1
%t82 = load float, float* %t81
%t83 = fmul float %t80, %t82
%t84 = fadd float %t78, %t83
%t85 = getelementptr inbounds float, float* %arg.a1, i32 2
%t86 = load float, float* %t85
%t87 = getelementptr inbounds float, float* %arg.b2, i32 1
%t88 = load float, float* %t87
%t89 = fmul float %t86, %t88
%t90 = fadd float %t84, %t89
store float %t90, float* %t73
%t91 = getelementptr inbounds float, float* %arg.c1, i32 2
%t92 = getelementptr inbounds float, float* %arg.a1, i32 0
%t93 = load float, float* %t92
%t94 = getelementptr inbounds float, float* %arg.b0, i32 2
%t95 = load float, float* %t94
%t96 = fmul float %t93, %t95
%t97 = getelementptr inbounds float, float* %arg.a1, i32 1
%t98 = load float, float* %t97
%t99 = getelementptr inbounds float, float* %arg.b1, i32 2
%t100 = load float, float* %t99
%t101 = fmul float %t98, %t100
%t102 = fadd float %t96, %t101
%t103 = getelementptr inbounds float, float* %arg.a1, i32 2
%t104 = load float, float* %t103
%t105 = getelementptr inbounds float, float* %arg.b2, i32 2
%t106 = load float, float* %t105
%t107 = fmul float %t104, %t106
%t108 = fadd float %t102, %t107
store float %t108, float* %t91
%t109 = getelementptr inbounds float, float* %arg.c2, i32 0
%t110 = getelementptr inbounds float, float* %arg.a2, i32 0
%t111 = load float, float* %t110
%t112 = getelementptr inbounds float, float* %arg.b0, i32 0
%t113 = load float, float* %t112
%t114 = fmul float %t111, %t113
%t115 = getelementptr inbounds float, float* %arg.a2, i32 1
%t116 = load float, float* %t115
%t117 = getelementptr inbounds float, float* %arg.b1, i32 0
%t118 = load float, float* %t117
%t119 = fmul float %t116, %t118
%t120 = fadd float %t114, %t119
%t121 = getelementptr inbounds float, float* %arg.a2, i32 2
%t122 = load float, float* %t121
%t123 = getelementptr inbounds float, float* %arg.b2, i32 0
%t124 = load float, float* %t123
%t125 = fmul float %t122, %t124
%t126 = fadd float %t120, %t125
store float %t126, float* %t109
%t127 = getelementptr inbounds float, float* %arg.c2, i32 1
%t128 = getelementptr inbounds float, float* %arg.a2, i32 0
%t129 = load float, float* %t128
%t130 = getelementptr inbounds float, float* %arg.b0, i32 1
%t131 = load float, float* %t130
%t132 = fmul float %t129, %t131
%t133 = getelementptr inbounds float, float* %arg.a2, i32 1
%t134 = load float, float* %t133
%t135 = getelementptr inbounds float, float* %arg.b1, i32 1
%t136 = load float, float* %t135
%t137 = fmul float %t134, %t136
%t138 = fadd float %t132, %t137
%t139 = getelementptr inbounds float, float* %arg.a2, i32 2
%t140 = load float, float* %t139
%t141 = getelementptr inbounds float, float* %arg.b2, i32 1
%t142 = load float, float* %t141
%t143 = fmul float %t140, %t142
%t144 = fadd float %t138, %t143
store float %t144, float* %t127
%t145 = getelementptr inbounds float, float* %arg.c2, i32 2
%t146 = getelementptr inbounds float, float* %arg.a2, i32 0
%t147 = load float, float* %t146
%t148 = getelementptr inbounds float, float* %arg.b0, i32 2
%t149 = load float, float* %t148
%t150 = fmul float %t147, %t149
%t151 = getelementptr inbounds float, float* %arg.a2, i32 1
%t152 = load float, float* %t151
%t153 = getelementptr inbounds float, float* %arg.b1, i32 2
%t154 = load float, float* %t153
%t155 = fmul float %t152, %t154
%t156 = fadd float %t150, %t155
%t157 = getelementptr inbounds float, float* %arg.a2, i32 2
%t158 = load float, float* %t157
%t159 = getelementptr inbounds float, float* %arg.b2, i32 2
%t160 = load float, float* %t159
%t161 = fmul float %t158, %t160
%t162 = fadd float %t156, %t161
store float %t162, float* %t145
ret i32 0
}
define i32 @main() {
entry:
%t163 = alloca float, i32 3
%t164 = alloca float, i32 3
%t165 = alloca float, i32 3
%t166 = alloca float, i32 3
%t167 = alloca float, i32 3
%t168 = alloca float, i32 3
%t169 = alloca float, i32 6
%t170 = alloca float, i32 3
%t171 = alloca float, i32 3
%t172 = alloca i32
%t205 = alloca i32
store i32 3, i32* @N
store i32 3, i32* @M
store i32 3, i32* @L
store i32 0, i32* %t172
store i32 0, i32* %t172
br label %while.cond.1
while.cond.1:
%t173 = load i32, i32* %t172
%t174 = load i32, i32* @M
%t175 = icmp slt i32 %t173, %t174
%t176 = zext i1 %t175 to i32
%t177 = icmp ne i32 %t176, 0
br i1 %t177, label %while.body.2, label %while.end.3
while.body.2:
%t178 = load i32, i32* %t172
%t179 = getelementptr inbounds float, float* %t163, i32 %t178
%t180 = load i32, i32* %t172
%t181 = sitofp i32 %t180 to float
store float %t181, float* %t179
%t182 = load i32, i32* %t172
%t183 = getelementptr inbounds float, float* %t164, i32 %t182
%t184 = load i32, i32* %t172
%t185 = sitofp i32 %t184 to float
store float %t185, float* %t183
%t186 = load i32, i32* %t172
%t187 = getelementptr inbounds float, float* %t165, i32 %t186
%t188 = load i32, i32* %t172
%t189 = sitofp i32 %t188 to float
store float %t189, float* %t187
%t190 = load i32, i32* %t172
%t191 = getelementptr inbounds float, float* %t166, i32 %t190
%t192 = load i32, i32* %t172
%t193 = sitofp i32 %t192 to float
store float %t193, float* %t191
%t194 = load i32, i32* %t172
%t195 = getelementptr inbounds float, float* %t167, i32 %t194
%t196 = load i32, i32* %t172
%t197 = sitofp i32 %t196 to float
store float %t197, float* %t195
%t198 = load i32, i32* %t172
%t199 = getelementptr inbounds float, float* %t168, i32 %t198
%t200 = load i32, i32* %t172
%t201 = sitofp i32 %t200 to float
store float %t201, float* %t199
%t202 = load i32, i32* %t172
%t203 = add i32 %t202, 1
store i32 %t203, i32* %t172
br label %while.cond.1
while.end.3:
%t204 = call i32 @mul(float* %t163, float* %t164, float* %t165, float* %t166, float* %t167, float* %t168, float* %t169, float* %t170, float* %t171)
store i32 %t204, i32* %t172
store i32 0, i32* %t205
br label %while.cond.4
while.cond.4:
%t206 = load i32, i32* %t172
%t207 = load i32, i32* @N
%t208 = icmp slt i32 %t206, %t207
%t209 = zext i1 %t208 to i32
%t210 = icmp ne i32 %t209, 0
br i1 %t210, label %while.body.5, label %while.end.6
while.body.5:
%t211 = load i32, i32* %t172
%t212 = getelementptr inbounds float, float* %t169, i32 %t211
%t213 = load float, float* %t212
%t214 = fptosi float %t213 to i32
store i32 %t214, i32* %t205
%t215 = load i32, i32* %t205
call void @putint(i32 %t215)
%t217 = load i32, i32* %t172
%t218 = add i32 %t217, 1
store i32 %t218, i32* %t172
br label %while.cond.4
while.end.6:
store i32 10, i32* %t205
store i32 0, i32* %t172
%t219 = load i32, i32* %t205
call void @putch(i32 %t219)
br label %while.cond.7
while.cond.7:
%t221 = load i32, i32* %t172
%t222 = load i32, i32* @N
%t223 = icmp slt i32 %t221, %t222
%t224 = zext i1 %t223 to i32
%t225 = icmp ne i32 %t224, 0
br i1 %t225, label %while.body.8, label %while.end.9
while.body.8:
%t226 = load i32, i32* %t172
%t227 = getelementptr inbounds float, float* %t170, i32 %t226
%t228 = load float, float* %t227
%t229 = fptosi float %t228 to i32
store i32 %t229, i32* %t205
%t230 = load i32, i32* %t205
call void @putint(i32 %t230)
%t232 = load i32, i32* %t172
%t233 = add i32 %t232, 1
store i32 %t233, i32* %t172
br label %while.cond.7
while.end.9:
store i32 10, i32* %t205
store i32 0, i32* %t172
%t234 = load i32, i32* %t205
call void @putch(i32 %t234)
br label %while.cond.10
while.cond.10:
%t236 = load i32, i32* %t172
%t237 = load i32, i32* @N
%t238 = icmp slt i32 %t236, %t237
%t239 = zext i1 %t238 to i32
%t240 = icmp ne i32 %t239, 0
br i1 %t240, label %while.body.11, label %while.end.12
while.body.11:
%t241 = load i32, i32* %t172
%t242 = getelementptr inbounds float, float* %t171, i32 %t241
%t243 = load float, float* %t242
%t244 = fptosi float %t243 to i32
store i32 %t244, i32* %t205
%t245 = load i32, i32* %t205
call void @putint(i32 %t245)
%t247 = load i32, i32* %t172
%t248 = add i32 %t247, 1
store i32 %t248, i32* %t172
br label %while.cond.10
while.end.12:
store i32 10, i32* %t205
%t249 = load i32, i32* %t205
call void @putch(i32 %t249)
ret i32 0
}