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.
96 lines
2.4 KiB
96 lines
2.4 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 @get_one(i32 %arg.a) {
|
|
entry:
|
|
%t0 = alloca i32
|
|
store i32 %arg.a, i32* %t0
|
|
ret i32 1
|
|
}
|
|
define i32 @deepWhileBr(i32 %arg.a, i32 %arg.b) {
|
|
entry:
|
|
%t3 = alloca i32
|
|
%t11 = alloca i32
|
|
%t23 = alloca i32
|
|
%t1 = alloca i32
|
|
store i32 %arg.a, i32* %t1
|
|
%t2 = alloca i32
|
|
store i32 %arg.b, i32* %t2
|
|
store i32 0, i32* %t3
|
|
%t4 = load i32, i32* %t1
|
|
%t5 = load i32, i32* %t2
|
|
%t6 = add i32 %t4, %t5
|
|
store i32 %t6, i32* %t3
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t7 = load i32, i32* %t3
|
|
%t8 = icmp slt i32 %t7, 75
|
|
%t9 = zext i1 %t8 to i32
|
|
%t10 = icmp ne i32 %t9, 0
|
|
br i1 %t10, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
store i32 0, i32* %t11
|
|
store i32 42, i32* %t11
|
|
%t12 = load i32, i32* %t3
|
|
%t13 = icmp slt i32 %t12, 100
|
|
%t14 = zext i1 %t13 to i32
|
|
%t15 = icmp ne i32 %t14, 0
|
|
br i1 %t15, label %if.then.4, label %if.end.5
|
|
while.end.3:
|
|
%t32 = load i32, i32* %t3
|
|
ret i32 %t32
|
|
if.then.4:
|
|
%t16 = load i32, i32* %t3
|
|
%t17 = load i32, i32* %t11
|
|
%t18 = add i32 %t16, %t17
|
|
store i32 %t18, i32* %t3
|
|
%t19 = load i32, i32* %t3
|
|
%t20 = icmp sgt i32 %t19, 99
|
|
%t21 = zext i1 %t20 to i32
|
|
%t22 = icmp ne i32 %t21, 0
|
|
br i1 %t22, label %if.then.6, label %if.end.7
|
|
if.end.5:
|
|
br label %while.cond.1
|
|
if.then.6:
|
|
store i32 0, i32* %t23
|
|
%t24 = load i32, i32* %t11
|
|
%t25 = mul i32 %t24, 2
|
|
store i32 %t25, i32* %t23
|
|
%t26 = call i32 @get_one(i32 0)
|
|
%t27 = icmp eq i32 %t26, 1
|
|
%t28 = zext i1 %t27 to i32
|
|
%t29 = icmp ne i32 %t28, 0
|
|
br i1 %t29, label %if.then.8, label %if.end.9
|
|
if.end.7:
|
|
br label %if.end.5
|
|
if.then.8:
|
|
%t30 = load i32, i32* %t23
|
|
%t31 = mul i32 %t30, 2
|
|
store i32 %t31, i32* %t3
|
|
br label %if.end.9
|
|
if.end.9:
|
|
br label %if.end.7
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t33 = alloca i32
|
|
store i32 0, i32* %t33
|
|
store i32 2, i32* %t33
|
|
%t34 = load i32, i32* %t33
|
|
%t35 = load i32, i32* %t33
|
|
%t36 = call i32 @deepWhileBr(i32 %t34, i32 %t35)
|
|
store i32 %t36, i32* %t33
|
|
%t37 = load i32, i32* %t33
|
|
call void @putint(i32 %t37)
|
|
ret i32 0
|
|
}
|