Files
c3c/test/test_suite/abi/sysv_direct_coerce.c3t
2023-01-11 18:00:08 +01:00

43 lines
1.6 KiB
C

// #target: macos-x64
module foo;
struct Rectangle
{
float x; // Rectangle top-left corner position x
float y; // Rectangle top-left corner position y
float width; // Rectangle width
float height; // Rectangle height
}
fn void test(Rectangle r)
{
test(Rectangle { 1, 2, 3, 4 });
}
/* #expect: foo.ll
define void @foo_test(<2 x float> %0, <2 x float> %1) #0 {
entry:
%r = alloca %Rectangle, align 4
%literal = alloca %Rectangle, align 4
%coerce = alloca %Rectangle, align 8
%2 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %r, i32 0, i32 0
store <2 x float> %0, ptr %2, align 4
%3 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %r, i32 0, i32 1
store <2 x float> %1, ptr %3, align 4
%4 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 0
store float 1.000000e+00, ptr %4, align 4
%5 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 1
store float 2.000000e+00, ptr %5, align 4
%6 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 2
store float 3.000000e+00, ptr %6, align 4
%7 = getelementptr inbounds %Rectangle, ptr %literal, i32 0, i32 3
store float 4.000000e+00, ptr %7, align 4
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %coerce, ptr align 4 %literal, i32 16, i1 false)
%8 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 0
%lo = load <2 x float>, ptr %8, align 8
%9 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %coerce, i32 0, i32 1
%hi = load <2 x float>, ptr %9, align 8
call void @foo_test(<2 x float> %lo, <2 x float> %hi)
ret void
}