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.
183 lines
4.6 KiB
183 lines
4.6 KiB
@g = global i32 0
|
|
@h = global i32 0
|
|
@f = global i32 0
|
|
@e = 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 @EightWhile() {
|
|
entry:
|
|
%t0 = alloca i32
|
|
%t1 = alloca i32
|
|
%t2 = alloca i32
|
|
%t3 = alloca i32
|
|
store i32 0, i32* %t0
|
|
store i32 5, i32* %t0
|
|
store i32 0, i32* %t1
|
|
store i32 0, i32* %t2
|
|
store i32 6, i32* %t1
|
|
store i32 7, i32* %t2
|
|
store i32 0, i32* %t3
|
|
store i32 10, i32* %t3
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t4 = load i32, i32* %t0
|
|
%t5 = icmp slt i32 %t4, 20
|
|
%t6 = zext i1 %t5 to i32
|
|
%t7 = icmp ne i32 %t6, 0
|
|
br i1 %t7, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
%t8 = load i32, i32* %t0
|
|
%t9 = add i32 %t8, 3
|
|
store i32 %t9, i32* %t0
|
|
br label %while.cond.4
|
|
while.end.3:
|
|
%t66 = load i32, i32* %t0
|
|
%t67 = load i32, i32* %t1
|
|
%t68 = load i32, i32* %t3
|
|
%t69 = add i32 %t67, %t68
|
|
%t70 = add i32 %t66, %t69
|
|
%t71 = load i32, i32* %t2
|
|
%t72 = add i32 %t70, %t71
|
|
%t73 = load i32, i32* @e
|
|
%t74 = load i32, i32* %t3
|
|
%t75 = add i32 %t73, %t74
|
|
%t76 = load i32, i32* @g
|
|
%t77 = sub i32 %t75, %t76
|
|
%t78 = load i32, i32* @h
|
|
%t79 = add i32 %t77, %t78
|
|
%t80 = sub i32 %t72, %t79
|
|
ret i32 %t80
|
|
while.cond.4:
|
|
%t10 = load i32, i32* %t1
|
|
%t11 = icmp slt i32 %t10, 10
|
|
%t12 = zext i1 %t11 to i32
|
|
%t13 = icmp ne i32 %t12, 0
|
|
br i1 %t13, label %while.body.5, label %while.end.6
|
|
while.body.5:
|
|
%t14 = load i32, i32* %t1
|
|
%t15 = add i32 %t14, 1
|
|
store i32 %t15, i32* %t1
|
|
br label %while.cond.7
|
|
while.end.6:
|
|
%t64 = load i32, i32* %t1
|
|
%t65 = sub i32 %t64, 2
|
|
store i32 %t65, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.7:
|
|
%t16 = load i32, i32* %t2
|
|
%t17 = icmp eq i32 %t16, 7
|
|
%t18 = zext i1 %t17 to i32
|
|
%t19 = icmp ne i32 %t18, 0
|
|
br i1 %t19, label %while.body.8, label %while.end.9
|
|
while.body.8:
|
|
%t20 = load i32, i32* %t2
|
|
%t21 = sub i32 %t20, 1
|
|
store i32 %t21, i32* %t2
|
|
br label %while.cond.10
|
|
while.end.9:
|
|
%t62 = load i32, i32* %t2
|
|
%t63 = add i32 %t62, 1
|
|
store i32 %t63, i32* %t2
|
|
br label %while.cond.4
|
|
while.cond.10:
|
|
%t22 = load i32, i32* %t3
|
|
%t23 = icmp slt i32 %t22, 20
|
|
%t24 = zext i1 %t23 to i32
|
|
%t25 = icmp ne i32 %t24, 0
|
|
br i1 %t25, label %while.body.11, label %while.end.12
|
|
while.body.11:
|
|
%t26 = load i32, i32* %t3
|
|
%t27 = add i32 %t26, 3
|
|
store i32 %t27, i32* %t3
|
|
br label %while.cond.13
|
|
while.end.12:
|
|
%t60 = load i32, i32* %t3
|
|
%t61 = sub i32 %t60, 1
|
|
store i32 %t61, i32* %t3
|
|
br label %while.cond.7
|
|
while.cond.13:
|
|
%t28 = load i32, i32* @e
|
|
%t29 = icmp sgt i32 %t28, 1
|
|
%t30 = zext i1 %t29 to i32
|
|
%t31 = icmp ne i32 %t30, 0
|
|
br i1 %t31, label %while.body.14, label %while.end.15
|
|
while.body.14:
|
|
%t32 = load i32, i32* @e
|
|
%t33 = sub i32 %t32, 1
|
|
store i32 %t33, i32* @e
|
|
br label %while.cond.16
|
|
while.end.15:
|
|
%t58 = load i32, i32* @e
|
|
%t59 = add i32 %t58, 1
|
|
store i32 %t59, i32* @e
|
|
br label %while.cond.10
|
|
while.cond.16:
|
|
%t34 = load i32, i32* @f
|
|
%t35 = icmp sgt i32 %t34, 2
|
|
%t36 = zext i1 %t35 to i32
|
|
%t37 = icmp ne i32 %t36, 0
|
|
br i1 %t37, label %while.body.17, label %while.end.18
|
|
while.body.17:
|
|
%t38 = load i32, i32* @f
|
|
%t39 = sub i32 %t38, 2
|
|
store i32 %t39, i32* @f
|
|
br label %while.cond.19
|
|
while.end.18:
|
|
%t56 = load i32, i32* @f
|
|
%t57 = add i32 %t56, 1
|
|
store i32 %t57, i32* @f
|
|
br label %while.cond.13
|
|
while.cond.19:
|
|
%t40 = load i32, i32* @g
|
|
%t41 = icmp slt i32 %t40, 3
|
|
%t42 = zext i1 %t41 to i32
|
|
%t43 = icmp ne i32 %t42, 0
|
|
br i1 %t43, label %while.body.20, label %while.end.21
|
|
while.body.20:
|
|
%t44 = load i32, i32* @g
|
|
%t45 = add i32 %t44, 10
|
|
store i32 %t45, i32* @g
|
|
br label %while.cond.22
|
|
while.end.21:
|
|
%t54 = load i32, i32* @g
|
|
%t55 = sub i32 %t54, 8
|
|
store i32 %t55, i32* @g
|
|
br label %while.cond.16
|
|
while.cond.22:
|
|
%t46 = load i32, i32* @h
|
|
%t47 = icmp slt i32 %t46, 10
|
|
%t48 = zext i1 %t47 to i32
|
|
%t49 = icmp ne i32 %t48, 0
|
|
br i1 %t49, label %while.body.23, label %while.end.24
|
|
while.body.23:
|
|
%t50 = load i32, i32* @h
|
|
%t51 = add i32 %t50, 8
|
|
store i32 %t51, i32* @h
|
|
br label %while.cond.22
|
|
while.end.24:
|
|
%t52 = load i32, i32* @h
|
|
%t53 = sub i32 %t52, 1
|
|
store i32 %t53, i32* @h
|
|
br label %while.cond.19
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
store i32 1, i32* @g
|
|
store i32 2, i32* @h
|
|
store i32 4, i32* @e
|
|
store i32 6, i32* @f
|
|
%t81 = call i32 @EightWhile()
|
|
ret i32 %t81
|
|
}
|