mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
39 lines
909 B
C
39 lines
909 B
C
// #target: x64-darwin
|
|
|
|
module unionx64;
|
|
|
|
union Foo
|
|
{
|
|
long a;
|
|
char[12] b;
|
|
}
|
|
extern fn void hello2(Foo f);
|
|
|
|
fn void hello(Foo f)
|
|
{
|
|
hello2(f);
|
|
}
|
|
|
|
// #expect: unionx64.ll
|
|
|
|
%Foo = type { i64, [8 x i8] }
|
|
|
|
declare void @hello2(i64, i64) #0
|
|
|
|
define void @unionx64.hello(i64 %0, i64 %1) #0 {
|
|
entry:
|
|
%f = alloca %Foo, align 8
|
|
%pair = bitcast %Foo* %f to { i64, i64 }*
|
|
%2 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 0
|
|
store i64 %0, i64* %2, align 8
|
|
%3 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %pair, i32 0, i32 1
|
|
store i64 %1, i64* %3, align 8
|
|
%4 = bitcast %Foo* %f to { i64, i64 }*
|
|
%5 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 0
|
|
%lo = load i64, i64* %5, align 8
|
|
%6 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 1
|
|
%hi = load i64, i64* %6, align 8
|
|
call void @hello2(i64 %lo, i64 %hi)
|
|
ret void
|
|
}
|