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