Files
c3c/test/test_suite/builtins/simple_builtins.c3t

62 lines
1.9 KiB
Plaintext

// #target: macos-x64
module foo;
fn int foo(double b)
{
double d = $$ceil(b);
double e = $$max(1.0, d);
double f = $$fma(d, 2.0, 3.0);
double m = $$fmuladd(d, 2.0, 3.0);
int xeb = 13;
int[3] abcd;
int sy = $$volatile_load(&xeb);
$$volatile_store(&xeb, sy + 1);
$$volatile_store(&abcd[2], sy + 2);
sy = $$volatile_load(&abcd[2]);
return 1;
}
/* #expect: foo.ll
define i32 @foo.foo(double %0) #0 {
entry:
%d = alloca double, align 8
%e = alloca double, align 8
%f = alloca double, align 8
%m = alloca double, align 8
%xeb = alloca i32, align 4
%abcd = alloca [3 x i32], align 4
%sy = alloca i32, align 4
%1 = call double @llvm.ceil.f64(double %0)
store double %1, ptr %d, align 8
%2 = load double, ptr %d, align 8
%3 = call double @llvm.maxnum.f64(double 1.000000e+00, double %2)
store double %3, ptr %e, align 8
%4 = load double, ptr %d, align 8
%5 = call double @llvm.fma.f64(double %4, double 2.000000e+00, double 3.000000e+00)
store double %5, ptr %f, align 8
%6 = load double, ptr %d, align 8
%7 = call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double 3.000000e+00)
store double %7, ptr %m, align 8
store i32 13, ptr %xeb, align 4
store i32 0, ptr %abcd, align 4
%ptradd = getelementptr inbounds i8, ptr %abcd, i64 4
store i32 0, ptr %ptradd, align 4
%ptradd1 = getelementptr inbounds i8, ptr %abcd, i64 8
store i32 0, ptr %ptradd1, align 4
%8 = load volatile i32, ptr %xeb, align 4
store i32 %8, ptr %sy, align 4
%9 = load i32, ptr %sy, align 4
%add = add i32 %9, 1
store volatile i32 %add, ptr %xeb, align 4
%ptradd2 = getelementptr inbounds i8, ptr %abcd, i64 8
%10 = load i32, ptr %sy, align 4
%add3 = add i32 %10, 2
store volatile i32 %add3, ptr %ptradd2, align 4
%ptradd4 = getelementptr inbounds i8, ptr %abcd, i64 8
%11 = load volatile i32, ptr %ptradd4, align 4
store i32 %11, ptr %sy, align 4
ret i32 1
}