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