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