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.
45 lines
1.1 KiB
45 lines
1.1 KiB
@k = global i32 0
|
|
@n = global i32 10
|
|
|
|
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
|
|
store i32 0, i32* %t0
|
|
store i32 1, i32* @k
|
|
br label %while.cond.1
|
|
while.cond.1:
|
|
%t1 = load i32, i32* %t0
|
|
%t2 = icmp sle i32 %t1, 9
|
|
%t3 = zext i1 %t2 to i32
|
|
%t4 = icmp ne i32 %t3, 0
|
|
br i1 %t4, label %while.body.2, label %while.end.3
|
|
while.body.2:
|
|
%t5 = load i32, i32* %t0
|
|
%t6 = add i32 %t5, 1
|
|
store i32 %t6, i32* %t0
|
|
%t7 = load i32, i32* @k
|
|
%t8 = add i32 %t7, 1
|
|
%t9 = load i32, i32* @k
|
|
%t10 = load i32, i32* @k
|
|
%t11 = add i32 %t9, %t10
|
|
store i32 %t11, i32* @k
|
|
br label %while.cond.1
|
|
while.end.3:
|
|
%t12 = load i32, i32* @k
|
|
call void @putint(i32 %t12)
|
|
%t14 = load i32, i32* @k
|
|
ret i32 %t14
|
|
}
|