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.
124 lines
3.6 KiB
124 lines
3.6 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 float @fibFP(float %arg.n) {
|
|
entry:
|
|
%t0 = alloca float
|
|
store float %arg.n, float* %t0
|
|
%t1 = load float, float* %t0
|
|
%t2 = fcmp olt float %t1, 0x4000000000000000
|
|
%t3 = zext i1 %t2 to i32
|
|
%t4 = icmp ne i32 %t3, 0
|
|
br i1 %t4, label %if.then.1, label %if.end.2
|
|
if.then.1:
|
|
ret float 0x3FF0000000000000
|
|
if.end.2:
|
|
%t5 = load float, float* %t0
|
|
%t6 = fsub float %t5, 0x4000000000000000
|
|
%t7 = call float @fibFP(float %t6)
|
|
%t8 = load float, float* %t0
|
|
%t9 = fsub float %t8, 0x3FF0000000000000
|
|
%t10 = call float @fibFP(float %t9)
|
|
%t11 = fadd float %t7, %t10
|
|
ret float %t11
|
|
}
|
|
define float @takFP(float %arg.x, float %arg.y, float %arg.z) {
|
|
entry:
|
|
%t12 = alloca float
|
|
store float %arg.x, float* %t12
|
|
%t13 = alloca float
|
|
store float %arg.y, float* %t13
|
|
%t14 = alloca float
|
|
store float %arg.z, float* %t14
|
|
%t15 = load float, float* %t13
|
|
%t16 = load float, float* %t12
|
|
%t17 = fcmp olt float %t15, %t16
|
|
%t18 = zext i1 %t17 to i32
|
|
%t19 = icmp ne i32 %t18, 0
|
|
br i1 %t19, label %if.then.3, label %if.end.4
|
|
if.then.3:
|
|
%t20 = load float, float* %t12
|
|
%t21 = fsub float %t20, 0x3FF0000000000000
|
|
%t22 = load float, float* %t13
|
|
%t23 = load float, float* %t14
|
|
%t24 = call float @takFP(float %t21, float %t22, float %t23)
|
|
%t25 = load float, float* %t13
|
|
%t26 = fsub float %t25, 0x3FF0000000000000
|
|
%t27 = load float, float* %t14
|
|
%t28 = load float, float* %t12
|
|
%t29 = call float @takFP(float %t26, float %t27, float %t28)
|
|
%t30 = load float, float* %t14
|
|
%t31 = fsub float %t30, 0x3FF0000000000000
|
|
%t32 = load float, float* %t12
|
|
%t33 = load float, float* %t13
|
|
%t34 = call float @takFP(float %t31, float %t32, float %t33)
|
|
%t35 = call float @takFP(float %t24, float %t29, float %t34)
|
|
ret float %t35
|
|
if.end.4:
|
|
%t36 = load float, float* %t14
|
|
ret float %t36
|
|
}
|
|
define i32 @main() {
|
|
entry:
|
|
%t38 = alloca i32
|
|
%t40 = alloca float
|
|
%t42 = alloca float
|
|
%t44 = alloca float
|
|
%t46 = alloca float
|
|
%t51 = alloca float
|
|
call void @starttime()
|
|
%t39 = call i32 @getint()
|
|
store i32 %t39, i32* %t38
|
|
%t41 = call float @getfloat()
|
|
store float %t41, float* %t40
|
|
%t43 = call float @getfloat()
|
|
store float %t43, float* %t42
|
|
%t45 = call float @getfloat()
|
|
store float %t45, float* %t44
|
|
%t47 = load i32, i32* %t38
|
|
%t48 = sitofp i32 %t47 to float
|
|
%t49 = fadd float 0x403C000000000000, %t48
|
|
%t50 = call float @fibFP(float %t49)
|
|
store float %t50, float* %t46
|
|
%t52 = load float, float* %t40
|
|
%t53 = load float, float* %t42
|
|
%t54 = load float, float* %t44
|
|
%t55 = call float @takFP(float %t52, float %t53, float %t54)
|
|
store float %t55, float* %t51
|
|
%t56 = load float, float* %t46
|
|
%t57 = fcmp oeq float %t56, 0x4182A38140000000
|
|
%t58 = zext i1 %t57 to i32
|
|
%t59 = icmp ne i32 %t58, 0
|
|
br i1 %t59, label %if.then.5, label %if.else.6
|
|
if.then.5:
|
|
call void @putch(i32 112)
|
|
br label %if.end.7
|
|
if.else.6:
|
|
call void @putint(i32 1)
|
|
br label %if.end.7
|
|
if.end.7:
|
|
%t62 = load float, float* %t51
|
|
%t63 = fcmp oeq float %t62, 0x3FF0000000000000
|
|
%t64 = zext i1 %t63 to i32
|
|
%t65 = icmp ne i32 %t64, 0
|
|
br i1 %t65, label %if.then.8, label %if.else.9
|
|
if.then.8:
|
|
call void @putch(i32 112)
|
|
br label %if.end.10
|
|
if.else.9:
|
|
call void @putint(i32 1)
|
|
br label %if.end.10
|
|
if.end.10:
|
|
call void @stoptime()
|
|
ret i32 0
|
|
}
|