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.
148 lines
3.8 KiB
148 lines
3.8 KiB
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 @main() {
|
|
entry:
|
|
%t0 = alloca i32
|
|
%t1 = alloca i32
|
|
%t6 = alloca i32
|
|
%t11 = alloca i32
|
|
%t16 = alloca i32
|
|
%t39 = alloca i32
|
|
store i32 0, i32* %t0
|
|
store i32 0, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t2 = load i32, i32* %t1
|
|
%t3 = icmp slt i32 %t2, 20
|
|
%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:
|
|
store i32 0, i32* %t6
|
|
br label %while.cond.4
|
|
while.end.3:
|
|
%t58 = load i32, i32* %t0
|
|
ret i32 %t58
|
|
while.cond.4:
|
|
%t7 = load i32, i32* %t6
|
|
%t8 = icmp slt i32 %t7, 10
|
|
%t9 = zext i1 %t8 to i32
|
|
%t10 = icmp ne i32 %t9, 0
|
|
br i1 %t10, label %while.body.5, label %while.end.6
|
|
while.body.5:
|
|
store i32 0, i32* %t11
|
|
br label %while.cond.7
|
|
while.end.6:
|
|
%t56 = load i32, i32* %t1
|
|
%t57 = add i32 %t56, 1
|
|
store i32 %t57, i32* %t1
|
|
br label %while.cond.1
|
|
while.cond.7:
|
|
%t12 = load i32, i32* %t11
|
|
%t13 = icmp slt i32 %t12, 5
|
|
%t14 = zext i1 %t13 to i32
|
|
%t15 = icmp ne i32 %t14, 0
|
|
br i1 %t15, label %while.body.8, label %while.end.9
|
|
while.body.8:
|
|
store i32 0, i32* %t16
|
|
br label %while.cond.10
|
|
while.end.9:
|
|
%t54 = load i32, i32* %t6
|
|
%t55 = add i32 %t54, 1
|
|
store i32 %t55, i32* %t6
|
|
br label %while.cond.4
|
|
while.cond.10:
|
|
%t17 = load i32, i32* %t16
|
|
%t18 = icmp slt i32 %t17, 3
|
|
%t19 = zext i1 %t18 to i32
|
|
%t20 = icmp ne i32 %t19, 0
|
|
br i1 %t20, label %while.body.11, label %while.end.12
|
|
while.body.11:
|
|
%t21 = load i32, i32* %t16
|
|
%t22 = add i32 %t21, 1
|
|
%t23 = icmp sge i32 %t22, 3
|
|
%t24 = zext i1 %t23 to i32
|
|
%t25 = icmp ne i32 %t24, 0
|
|
br i1 %t25, label %if.then.13, label %if.end.14
|
|
while.end.12:
|
|
br label %while.cond.25
|
|
if.then.13:
|
|
%t26 = load i32, i32* %t16
|
|
%t27 = icmp ne i32 %t26, 0
|
|
br i1 %t27, label %if.then.15, label %if.end.16
|
|
if.end.14:
|
|
store i32 0, i32* %t39
|
|
br label %while.cond.22
|
|
if.then.15:
|
|
%t28 = load i32, i32* %t16
|
|
%t29 = icmp ne i32 %t28, 0
|
|
br i1 %t29, label %if.then.17, label %lor.rhs.19
|
|
if.end.16:
|
|
br label %if.end.14
|
|
if.then.17:
|
|
%t34 = load i32, i32* %t16
|
|
%t35 = sub i32 %t34, -1
|
|
%t36 = icmp sge i32 %t35, 3
|
|
%t37 = zext i1 %t36 to i32
|
|
%t38 = icmp ne i32 %t37, 0
|
|
br i1 %t38, label %if.then.20, label %if.end.21
|
|
if.end.18:
|
|
br label %if.end.16
|
|
lor.rhs.19:
|
|
%t30 = load i32, i32* %t16
|
|
%t31 = icmp eq i32 %t30, 0
|
|
%t32 = zext i1 %t31 to i32
|
|
%t33 = icmp ne i32 %t32, 0
|
|
br i1 %t33, label %if.then.17, label %if.end.18
|
|
if.then.20:
|
|
br label %while.end.12
|
|
if.end.21:
|
|
br label %if.end.18
|
|
while.cond.22:
|
|
%t40 = load i32, i32* %t39
|
|
%t41 = icmp slt i32 %t40, 2
|
|
%t42 = zext i1 %t41 to i32
|
|
%t43 = icmp ne i32 %t42, 0
|
|
br i1 %t43, label %while.body.23, label %while.end.24
|
|
while.body.23:
|
|
%t44 = load i32, i32* %t39
|
|
%t45 = add i32 %t44, 1
|
|
store i32 %t45, i32* %t39
|
|
br label %while.cond.22
|
|
while.end.24:
|
|
%t46 = load i32, i32* %t16
|
|
%t47 = add i32 %t46, 1
|
|
store i32 %t47, i32* %t16
|
|
%t48 = load i32, i32* %t0
|
|
%t49 = add i32 %t48, 1
|
|
store i32 %t49, i32* %t0
|
|
br label %while.cond.10
|
|
while.cond.25:
|
|
%t50 = icmp ne i32 1, 0
|
|
br i1 %t50, label %while.body.26, label %while.end.27
|
|
while.body.26:
|
|
br label %while.cond.28
|
|
while.end.27:
|
|
%t52 = load i32, i32* %t11
|
|
%t53 = add i32 %t52, 1
|
|
store i32 %t53, i32* %t11
|
|
br label %while.cond.7
|
|
while.cond.28:
|
|
%t51 = icmp ne i32 1, 0
|
|
br i1 %t51, label %while.body.29, label %while.end.30
|
|
while.body.29:
|
|
br label %while.end.30
|
|
while.end.30:
|
|
br label %while.end.27
|
|
}
|