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.
209 lines
6.5 KiB
209 lines
6.5 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 @add(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
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t1 = load i32, i32* %t0
|
|
%t2 = load i32, i32* @M
|
|
%t3 = icmp slt i32 %t1, %t2
|
|
%t4 = zext i1 %t3 to i32
|
|
%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 float, float* %arg.c0, i32 %t6
|
|
%t8 = load i32, i32* %t0
|
|
%t9 = getelementptr inbounds float, float* %arg.a0, i32 %t8
|
|
%t10 = load float, float* %t9
|
|
%t11 = load i32, i32* %t0
|
|
%t12 = getelementptr inbounds float, float* %arg.b0, i32 %t11
|
|
%t13 = load float, float* %t12
|
|
%t14 = fadd float %t10, %t13
|
|
store float %t14, float* %t7
|
|
%t15 = load i32, i32* %t0
|
|
%t16 = getelementptr inbounds float, float* %arg.c1, i32 %t15
|
|
%t17 = load i32, i32* %t0
|
|
%t18 = getelementptr inbounds float, float* %arg.a1, i32 %t17
|
|
%t19 = load float, float* %t18
|
|
%t20 = load i32, i32* %t0
|
|
%t21 = getelementptr inbounds float, float* %arg.b1, i32 %t20
|
|
%t22 = load float, float* %t21
|
|
%t23 = fadd float %t19, %t22
|
|
store float %t23, float* %t16
|
|
%t24 = load i32, i32* %t0
|
|
%t25 = getelementptr inbounds float, float* %arg.c2, i32 %t24
|
|
%t26 = load i32, i32* %t0
|
|
%t27 = getelementptr inbounds float, float* %arg.a2, i32 %t26
|
|
%t28 = load float, float* %t27
|
|
%t29 = load i32, i32* %t0
|
|
%t30 = getelementptr inbounds float, float* %arg.b2, i32 %t29
|
|
%t31 = load float, float* %t30
|
|
%t32 = fadd float %t28, %t31
|
|
store float %t32, float* %t25
|
|
%t33 = load i32, i32* %t0
|
|
%t34 = add i32 %t33, 1
|
|
store i32 %t34, i32* %t0
|
|
br label %while.cond.1
|
|
while.end.3:
|
|
ret i32 0
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t35 = alloca float, i32 3
|
|
%t36 = alloca float, i32 3
|
|
%t37 = alloca float, i32 3
|
|
%t38 = alloca float, i32 3
|
|
%t39 = alloca float, i32 3
|
|
%t40 = alloca float, i32 3
|
|
%t41 = alloca float, i32 6
|
|
%t42 = alloca float, i32 3
|
|
%t43 = alloca float, i32 3
|
|
%t44 = alloca i32
|
|
%t77 = alloca i32
|
|
store i32 3, i32* @N
|
|
store i32 3, i32* @M
|
|
store i32 3, i32* @L
|
|
store i32 0, i32* %t44
|
|
store i32 0, i32* %t44
|
|
br label %while.cond.4
|
|
while.cond.4:
|
|
%t45 = load i32, i32* %t44
|
|
%t46 = load i32, i32* @M
|
|
%t47 = icmp slt i32 %t45, %t46
|
|
%t48 = zext i1 %t47 to i32
|
|
%t49 = icmp ne i32 %t48, 0
|
|
br i1 %t49, label %while.body.5, label %while.end.6
|
|
while.body.5:
|
|
%t50 = load i32, i32* %t44
|
|
%t51 = getelementptr inbounds float, float* %t35, i32 %t50
|
|
%t52 = load i32, i32* %t44
|
|
%t53 = sitofp i32 %t52 to float
|
|
store float %t53, float* %t51
|
|
%t54 = load i32, i32* %t44
|
|
%t55 = getelementptr inbounds float, float* %t36, i32 %t54
|
|
%t56 = load i32, i32* %t44
|
|
%t57 = sitofp i32 %t56 to float
|
|
store float %t57, float* %t55
|
|
%t58 = load i32, i32* %t44
|
|
%t59 = getelementptr inbounds float, float* %t37, i32 %t58
|
|
%t60 = load i32, i32* %t44
|
|
%t61 = sitofp i32 %t60 to float
|
|
store float %t61, float* %t59
|
|
%t62 = load i32, i32* %t44
|
|
%t63 = getelementptr inbounds float, float* %t38, i32 %t62
|
|
%t64 = load i32, i32* %t44
|
|
%t65 = sitofp i32 %t64 to float
|
|
store float %t65, float* %t63
|
|
%t66 = load i32, i32* %t44
|
|
%t67 = getelementptr inbounds float, float* %t39, i32 %t66
|
|
%t68 = load i32, i32* %t44
|
|
%t69 = sitofp i32 %t68 to float
|
|
store float %t69, float* %t67
|
|
%t70 = load i32, i32* %t44
|
|
%t71 = getelementptr inbounds float, float* %t40, i32 %t70
|
|
%t72 = load i32, i32* %t44
|
|
%t73 = sitofp i32 %t72 to float
|
|
store float %t73, float* %t71
|
|
%t74 = load i32, i32* %t44
|
|
%t75 = add i32 %t74, 1
|
|
store i32 %t75, i32* %t44
|
|
br label %while.cond.4
|
|
while.end.6:
|
|
%t76 = call i32 @add(float* %t35, float* %t36, float* %t37, float* %t38, float* %t39, float* %t40, float* %t41, float* %t42, float* %t43)
|
|
store i32 %t76, i32* %t44
|
|
store i32 0, i32* %t77
|
|
br label %while.cond.7
|
|
while.cond.7:
|
|
%t78 = load i32, i32* %t44
|
|
%t79 = load i32, i32* @N
|
|
%t80 = icmp slt i32 %t78, %t79
|
|
%t81 = zext i1 %t80 to i32
|
|
%t82 = icmp ne i32 %t81, 0
|
|
br i1 %t82, label %while.body.8, label %while.end.9
|
|
while.body.8:
|
|
%t83 = load i32, i32* %t44
|
|
%t84 = getelementptr inbounds float, float* %t41, i32 %t83
|
|
%t85 = load float, float* %t84
|
|
%t86 = fptosi float %t85 to i32
|
|
store i32 %t86, i32* %t77
|
|
%t87 = load i32, i32* %t77
|
|
call void @putint(i32 %t87)
|
|
%t89 = load i32, i32* %t44
|
|
%t90 = add i32 %t89, 1
|
|
store i32 %t90, i32* %t44
|
|
br label %while.cond.7
|
|
while.end.9:
|
|
store i32 10, i32* %t77
|
|
%t91 = load i32, i32* %t77
|
|
call void @putch(i32 %t91)
|
|
store i32 0, i32* %t44
|
|
br label %while.cond.10
|
|
while.cond.10:
|
|
%t93 = load i32, i32* %t44
|
|
%t94 = load i32, i32* @N
|
|
%t95 = icmp slt i32 %t93, %t94
|
|
%t96 = zext i1 %t95 to i32
|
|
%t97 = icmp ne i32 %t96, 0
|
|
br i1 %t97, label %while.body.11, label %while.end.12
|
|
while.body.11:
|
|
%t98 = load i32, i32* %t44
|
|
%t99 = getelementptr inbounds float, float* %t42, i32 %t98
|
|
%t100 = load float, float* %t99
|
|
%t101 = fptosi float %t100 to i32
|
|
store i32 %t101, i32* %t77
|
|
%t102 = load i32, i32* %t77
|
|
call void @putint(i32 %t102)
|
|
%t104 = load i32, i32* %t44
|
|
%t105 = add i32 %t104, 1
|
|
store i32 %t105, i32* %t44
|
|
br label %while.cond.10
|
|
while.end.12:
|
|
store i32 10, i32* %t77
|
|
%t106 = load i32, i32* %t77
|
|
call void @putch(i32 %t106)
|
|
store i32 0, i32* %t44
|
|
br label %while.cond.13
|
|
while.cond.13:
|
|
%t108 = load i32, i32* %t44
|
|
%t109 = load i32, i32* @N
|
|
%t110 = icmp slt i32 %t108, %t109
|
|
%t111 = zext i1 %t110 to i32
|
|
%t112 = icmp ne i32 %t111, 0
|
|
br i1 %t112, label %while.body.14, label %while.end.15
|
|
while.body.14:
|
|
%t113 = load i32, i32* %t44
|
|
%t114 = getelementptr inbounds float, float* %t43, i32 %t113
|
|
%t115 = load float, float* %t114
|
|
%t116 = fptosi float %t115 to i32
|
|
store i32 %t116, i32* %t77
|
|
%t117 = load i32, i32* %t77
|
|
call void @putint(i32 %t117)
|
|
%t119 = load i32, i32* %t44
|
|
%t120 = add i32 %t119, 1
|
|
store i32 %t120, i32* %t44
|
|
br label %while.cond.13
|
|
while.end.15:
|
|
store i32 10, i32* %t77
|
|
%t121 = load i32, i32* %t77
|
|
call void @putch(i32 %t121)
|
|
ret i32 0
|
|
}
|