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.
102 lines
2.5 KiB
102 lines
2.5 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 @FourWhile() {
|
|
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:
|
|
%t34 = load i32, i32* %t0
|
|
%t35 = load i32, i32* %t1
|
|
%t36 = load i32, i32* %t3
|
|
%t37 = add i32 %t35, %t36
|
|
%t38 = add i32 %t34, %t37
|
|
%t39 = load i32, i32* %t2
|
|
%t40 = add i32 %t38, %t39
|
|
ret i32 %t40
|
|
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:
|
|
%t32 = load i32, i32* %t1
|
|
%t33 = sub i32 %t32, 2
|
|
store i32 %t33, 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:
|
|
%t30 = load i32, i32* %t2
|
|
%t31 = add i32 %t30, 1
|
|
store i32 %t31, 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.10
|
|
while.end.12:
|
|
%t28 = load i32, i32* %t3
|
|
%t29 = sub i32 %t28, 1
|
|
store i32 %t29, i32* %t3
|
|
br label %while.cond.7
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t41 = call i32 @FourWhile()
|
|
ret i32 %t41
|
|
}
|