mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Builtins work. Math library exposes some builtins. Volatile store / load.
This commit is contained in:
committed by
Christoffer Lerno
parent
7bd76c973c
commit
fb56d380cc
57
test/test_suite/builtins/simple_builtins.c3t
Normal file
57
test/test_suite/builtins/simple_builtins.c3t
Normal file
@@ -0,0 +1,57 @@
|
||||
// #target: x64-darwin
|
||||
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);
|
||||
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:
|
||||
%b = alloca double, align 8
|
||||
%d = alloca double, align 8
|
||||
%e = alloca double, align 8
|
||||
%f = alloca double, align 8
|
||||
%xeb = alloca i32, align 4
|
||||
%abcd = alloca [3 x i32], align 4
|
||||
%sy = alloca i32, align 4
|
||||
store double %0, double* %b, align 8
|
||||
%1 = load double, double* %b, align 8
|
||||
%2 = call double @llvm.ceil.f64(double %1)
|
||||
store double %2, double* %d, align 8
|
||||
%3 = call double @llvm.maxnum.f64(double 1.000000e+00, double 1.000000e+00)
|
||||
store double %3, double* %e, align 8
|
||||
%4 = load double, double* %d, align 8
|
||||
%5 = load double, double* %d, align 8
|
||||
%6 = load double, double* %d, align 8
|
||||
%7 = call double @llvm.fma.f64(double %4, double %5, double %6)
|
||||
store double %7, double* %f, align 8
|
||||
store i32 13, i32* %xeb, align 4
|
||||
%8 = bitcast [3 x i32]* %abcd to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* align 4 %8, i8 0, i64 12, i1 false)
|
||||
%9 = load volatile i32, i32* %xeb, align 4
|
||||
store i32 %9, i32* %sy, align 4
|
||||
%10 = load i32, i32* %sy, align 4
|
||||
%add = add i32 %10, 1
|
||||
store volatile i32 %add, i32* %xeb, align 4
|
||||
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 2
|
||||
%12 = load i32, i32* %sy, align 4
|
||||
%add1 = add i32 %12, 2
|
||||
store volatile i32 %add1, i32* %11, align 4
|
||||
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %abcd, i64 0, i64 2
|
||||
%14 = load volatile i32, i32* %13, align 4
|
||||
store i32 %14, i32* %sy, align 4
|
||||
ret i32 1
|
||||
}
|
||||
Reference in New Issue
Block a user