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.
101 lines
2.5 KiB
101 lines
2.5 KiB
@a = global i32 -1
|
|
@b = global i32 1
|
|
|
|
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 @inc_a() {
|
|
entry:
|
|
%t0 = alloca i32
|
|
%t1 = load i32, i32* @a
|
|
store i32 %t1, i32* %t0
|
|
%t2 = load i32, i32* %t0
|
|
%t3 = add i32 %t2, 1
|
|
store i32 %t3, i32* %t0
|
|
%t4 = load i32, i32* %t0
|
|
store i32 %t4, i32* @a
|
|
%t5 = load i32, i32* @a
|
|
ret i32 %t5
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t6 = alloca i32
|
|
store i32 5, i32* %t6
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t7 = load i32, i32* %t6
|
|
%t8 = icmp sge i32 %t7, 0
|
|
%t9 = icmp ne i32 %t8, 0
|
|
br i1 %t9, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
%t10 = call i32 @inc_a()
|
|
%t11 = icmp ne i32 %t10, 0
|
|
br i1 %t11, label %land.rhs.7, label %if.end.5
|
|
while.end.3:
|
|
%t40 = load i32, i32* @a
|
|
call void @putint(i32 %t40)
|
|
call void @putch(i32 32)
|
|
%t43 = load i32, i32* @b
|
|
call void @putint(i32 %t43)
|
|
call void @putch(i32 10)
|
|
%t46 = load i32, i32* @a
|
|
ret i32 %t46
|
|
if.then.4:
|
|
%t16 = load i32, i32* @a
|
|
call void @putint(i32 %t16)
|
|
call void @putch(i32 32)
|
|
%t19 = load i32, i32* @b
|
|
call void @putint(i32 %t19)
|
|
call void @putch(i32 10)
|
|
br label %if.end.5
|
|
if.end.5:
|
|
%t22 = call i32 @inc_a()
|
|
%t23 = icmp slt i32 %t22, 14
|
|
%t24 = icmp ne i32 %t23, 0
|
|
br i1 %t24, label %if.then.8, label %lor.rhs.11
|
|
land.rhs.6:
|
|
%t14 = call i32 @inc_a()
|
|
%t15 = icmp ne i32 %t14, 0
|
|
br i1 %t15, label %if.then.4, label %if.end.5
|
|
land.rhs.7:
|
|
%t12 = call i32 @inc_a()
|
|
%t13 = icmp ne i32 %t12, 0
|
|
br i1 %t13, label %land.rhs.6, label %if.end.5
|
|
if.then.8:
|
|
%t32 = load i32, i32* @a
|
|
call void @putint(i32 %t32)
|
|
call void @putch(i32 10)
|
|
%t35 = load i32, i32* @b
|
|
%t36 = mul i32 %t35, 2
|
|
store i32 %t36, i32* @b
|
|
br label %if.end.9
|
|
if.end.9:
|
|
%t38 = load i32, i32* %t6
|
|
%t39 = sub i32 %t38, 1
|
|
store i32 %t39, i32* %t6
|
|
br label %while.cond.1
|
|
if.else.10:
|
|
%t37 = call i32 @inc_a()
|
|
br label %if.end.9
|
|
lor.rhs.11:
|
|
%t25 = call i32 @inc_a()
|
|
%t26 = icmp ne i32 %t25, 0
|
|
br i1 %t26, label %land.rhs.12, label %if.else.10
|
|
land.rhs.12:
|
|
%t27 = call i32 @inc_a()
|
|
%t28 = call i32 @inc_a()
|
|
%t29 = sub i32 %t27, %t28
|
|
%t30 = add i32 %t29, 1
|
|
%t31 = icmp ne i32 %t30, 0
|
|
br i1 %t31, label %if.then.8, label %if.else.10
|
|
}
|