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.
162 lines
3.9 KiB
162 lines
3.9 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 @main() {
|
|
entry:
|
|
%t0 = alloca i32
|
|
store i32 1, i32* %t0
|
|
%t1 = alloca i32
|
|
store i32 2, i32* %t1
|
|
%t2 = alloca i32
|
|
store i32 3, i32* %t2
|
|
%t3 = alloca i32
|
|
store i32 4, i32* %t3
|
|
%t4 = alloca i32
|
|
store i32 5, i32* %t4
|
|
%t5 = alloca i32
|
|
store i32 6, i32* %t5
|
|
%t6 = load i32, i32* %t0
|
|
%t7 = load i32, i32* %t1
|
|
%t8 = mul i32 %t6, %t7
|
|
%t9 = load i32, i32* %t2
|
|
%t10 = add i32 %t8, %t9
|
|
%t11 = icmp slt i32 %t10, 6
|
|
%t12 = zext i1 %t11 to i32
|
|
%t13 = icmp ne i32 %t12, 0
|
|
br i1 %t13, label %land.rhs.4, label %if.else.2
|
|
if.then.1:
|
|
%t18 = load i32, i32* %t4
|
|
%t19 = icmp ne i32 %t18, 0
|
|
br i1 %t19, label %if.then.5, label %lor.rhs.8
|
|
if.else.2:
|
|
ret i32 1
|
|
if.end.3:
|
|
ret i32 0
|
|
land.rhs.4:
|
|
%t14 = load i32, i32* %t3
|
|
%t15 = icmp ne i32 %t14, 0
|
|
%t16 = zext i1 %t15 to i32
|
|
%t17 = icmp ne i32 %t16, 0
|
|
br i1 %t17, label %if.then.1, label %if.else.2
|
|
if.then.5:
|
|
%t24 = load i32, i32* %t2
|
|
%t25 = icmp eq i32 %t24, 2
|
|
%t26 = zext i1 %t25 to i32
|
|
%t27 = icmp ne i32 %t26, 0
|
|
br i1 %t27, label %land.rhs.12, label %if.else.10
|
|
if.else.6:
|
|
ret i32 2
|
|
if.end.7:
|
|
ret i32 0
|
|
lor.rhs.8:
|
|
%t20 = load i32, i32* %t0
|
|
%t21 = icmp eq i32 %t20, 0
|
|
%t22 = zext i1 %t21 to i32
|
|
%t23 = icmp ne i32 %t22, 0
|
|
br i1 %t23, label %if.then.5, label %if.else.6
|
|
if.then.9:
|
|
ret i32 3
|
|
if.else.10:
|
|
%t34 = load i32, i32* %t5
|
|
%t35 = load i32, i32* %t2
|
|
%t36 = srem i32 %t34, %t35
|
|
%t37 = icmp ne i32 %t36, 0
|
|
br i1 %t37, label %land.rhs.16, label %if.else.14
|
|
if.end.11:
|
|
ret i32 0
|
|
land.rhs.12:
|
|
%t28 = load i32, i32* %t3
|
|
%t29 = load i32, i32* %t4
|
|
%t30 = add i32 %t28, %t29
|
|
%t31 = icmp sgt i32 %t30, 2
|
|
%t32 = zext i1 %t31 to i32
|
|
%t33 = icmp ne i32 %t32, 0
|
|
br i1 %t33, label %if.then.9, label %if.else.10
|
|
if.then.13:
|
|
ret i32 4
|
|
if.else.14:
|
|
%t40 = load i32, i32* %t3
|
|
%t41 = load i32, i32* %t1
|
|
%t42 = sdiv i32 %t40, %t41
|
|
%t43 = load i32, i32* %t0
|
|
%t44 = add i32 %t42, %t43
|
|
%t45 = icmp sge i32 %t44, 2
|
|
%t46 = zext i1 %t45 to i32
|
|
%t47 = icmp ne i32 %t46, 0
|
|
br i1 %t47, label %if.then.17, label %if.else.18
|
|
if.end.15:
|
|
ret i32 0
|
|
land.rhs.16:
|
|
%t38 = load i32, i32* %t4
|
|
%t39 = icmp ne i32 %t38, 0
|
|
br i1 %t39, label %if.then.13, label %if.else.14
|
|
if.then.17:
|
|
%t48 = load i32, i32* %t4
|
|
%t49 = load i32, i32* %t5
|
|
%t50 = sub i32 %t48, %t49
|
|
%t51 = icmp sge i32 %t50, 0
|
|
%t52 = zext i1 %t51 to i32
|
|
%t53 = icmp ne i32 %t52, 0
|
|
br i1 %t53, label %if.then.20, label %lor.rhs.23
|
|
if.else.18:
|
|
ret i32 5
|
|
if.end.19:
|
|
ret i32 0
|
|
if.then.20:
|
|
ret i32 6
|
|
if.else.21:
|
|
%t58 = load i32, i32* %t2
|
|
%t59 = load i32, i32* %t5
|
|
%t60 = icmp ne i32 %t58, %t59
|
|
%t61 = zext i1 %t60 to i32
|
|
%t62 = icmp ne i32 %t61, 0
|
|
br i1 %t62, label %if.then.24, label %if.else.25
|
|
if.end.22:
|
|
ret i32 0
|
|
lor.rhs.23:
|
|
%t54 = load i32, i32* %t3
|
|
%t55 = icmp sgt i32 %t54, 4
|
|
%t56 = zext i1 %t55 to i32
|
|
%t57 = icmp ne i32 %t56, 0
|
|
br i1 %t57, label %if.then.20, label %if.else.21
|
|
if.then.24:
|
|
%t63 = load i32, i32* %t1
|
|
%t64 = load i32, i32* %t4
|
|
%t65 = load i32, i32* %t3
|
|
%t66 = mul i32 %t64, %t65
|
|
%t67 = add i32 %t63, %t66
|
|
%t68 = icmp sgt i32 %t67, 10
|
|
%t69 = zext i1 %t68 to i32
|
|
%t70 = icmp ne i32 %t69, 0
|
|
br i1 %t70, label %if.then.27, label %if.else.28
|
|
if.else.25:
|
|
ret i32 7
|
|
if.end.26:
|
|
ret i32 0
|
|
if.then.27:
|
|
%t71 = load i32, i32* %t5
|
|
%t72 = icmp eq i32 %t71, 0
|
|
%t73 = zext i1 %t72 to i32
|
|
%t74 = icmp ne i32 %t73, 0
|
|
br i1 %t74, label %if.then.30, label %if.else.31
|
|
if.else.28:
|
|
ret i32 8
|
|
if.end.29:
|
|
ret i32 0
|
|
if.then.30:
|
|
ret i32 9
|
|
if.else.31:
|
|
ret i32 10
|
|
if.end.32:
|
|
ret i32 0
|
|
}
|