mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
47 lines
2.0 KiB
C
47 lines
2.0 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
|
|
%pair = bitcast %Rectangle* %r to { <2 x float>, <2 x float> }*
|
|
%2 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %pair, i32 0, i32 0
|
|
store <2 x float> %0, <2 x float>* %2, align 4
|
|
%3 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %pair, i32 0, i32 1
|
|
store <2 x float> %1, <2 x float>* %3, align 4
|
|
%4 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 0
|
|
store float 1.000000e+00, float* %4, align 4
|
|
%5 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 1
|
|
store float 2.000000e+00, float* %5, align 4
|
|
%6 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 2
|
|
store float 3.000000e+00, float* %6, align 4
|
|
%7 = getelementptr inbounds %Rectangle, %Rectangle* %literal, i32 0, i32 3
|
|
store float 4.000000e+00, float* %7, align 4
|
|
%8 = bitcast %Rectangle* %coerce to { <2 x float>, <2 x float> }*
|
|
%9 = bitcast { <2 x float>, <2 x float> }* %8 to i8*
|
|
%10 = bitcast %Rectangle* %literal to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %9, i8* align 4 %10, i32 16, i1 false)
|
|
%11 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %8, i32 0, i32 0
|
|
%lo = load <2 x float>, <2 x float>* %11, align 8
|
|
%12 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %8, i32 0, i32 1
|
|
%hi = load <2 x float>, <2 x float>* %12, align 8
|
|
call void @foo_test(<2 x float> %lo, <2 x float> %hi)
|
|
ret void
|
|
}
|