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.
86 lines
2.1 KiB
86 lines
2.1 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 @ifElseIf() {
|
|
entry:
|
|
%t0 = alloca i32
|
|
%t1 = alloca i32
|
|
store i32 0, i32* %t0
|
|
store i32 5, i32* %t0
|
|
store i32 0, i32* %t1
|
|
store i32 10, i32* %t1
|
|
%t2 = load i32, i32* %t0
|
|
%t3 = icmp eq i32 %t2, 6
|
|
%t4 = zext i1 %t3 to i32
|
|
%t5 = icmp ne i32 %t4, 0
|
|
br i1 %t5, label %if.then.1, label %lor.rhs.4
|
|
if.then.1:
|
|
%t10 = load i32, i32* %t0
|
|
ret i32 %t10
|
|
if.else.2:
|
|
%t11 = load i32, i32* %t1
|
|
%t12 = icmp eq i32 %t11, 10
|
|
%t13 = zext i1 %t12 to i32
|
|
%t14 = icmp ne i32 %t13, 0
|
|
br i1 %t14, label %land.rhs.8, label %if.else.6
|
|
if.end.3:
|
|
%t31 = load i32, i32* %t0
|
|
ret i32 %t31
|
|
lor.rhs.4:
|
|
%t6 = load i32, i32* %t1
|
|
%t7 = icmp eq i32 %t6, 11
|
|
%t8 = zext i1 %t7 to i32
|
|
%t9 = icmp ne i32 %t8, 0
|
|
br i1 %t9, label %if.then.1, label %if.else.2
|
|
if.then.5:
|
|
store i32 25, i32* %t0
|
|
br label %if.end.7
|
|
if.else.6:
|
|
%t19 = load i32, i32* %t1
|
|
%t20 = icmp eq i32 %t19, 10
|
|
%t21 = zext i1 %t20 to i32
|
|
%t22 = icmp ne i32 %t21, 0
|
|
br i1 %t22, label %land.rhs.12, label %if.else.10
|
|
if.end.7:
|
|
br label %if.end.3
|
|
land.rhs.8:
|
|
%t15 = load i32, i32* %t0
|
|
%t16 = icmp eq i32 %t15, 1
|
|
%t17 = zext i1 %t16 to i32
|
|
%t18 = icmp ne i32 %t17, 0
|
|
br i1 %t18, label %if.then.5, label %if.else.6
|
|
if.then.9:
|
|
%t27 = load i32, i32* %t0
|
|
%t28 = add i32 %t27, 15
|
|
store i32 %t28, i32* %t0
|
|
br label %if.end.11
|
|
if.else.10:
|
|
%t29 = load i32, i32* %t0
|
|
%t30 = sub i32 0, %t29
|
|
store i32 %t30, i32* %t0
|
|
br label %if.end.11
|
|
if.end.11:
|
|
br label %if.end.7
|
|
land.rhs.12:
|
|
%t23 = load i32, i32* %t0
|
|
%t24 = icmp eq i32 %t23, -5
|
|
%t25 = zext i1 %t24 to i32
|
|
%t26 = icmp ne i32 %t25, 0
|
|
br i1 %t26, label %if.then.9, label %if.else.10
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t32 = call i32 @ifElseIf()
|
|
call void @putint(i32 %t32)
|
|
ret i32 0
|
|
}
|