Files
c3c/test/test_suite/bitstruct/embedded_bitstruct.c3t
2022-08-13 03:04:09 +02:00

82 lines
2.3 KiB
C

// #target: macos-x64
module foo;
struct Bar
{
int x;
struct
{
struct
{
int y;
}
}
bitstruct : uint
{
int ww : 2..10;
}
}
struct Foo
{
struct
{
struct
{
int x;
}
struct
{
int y;
}
int z;
}
int w;
}
extern fn void printf(char*, ...);
fn void main()
{
Bar b = { 1, 2, -5 };
printf("%d %d\n", b.y, b.ww);
Foo f = { 5, 6, 7, 8 };
printf("%d %d %d %d\n", f.x, f.y, f.z, f.w);
}
/* #expect: foo.ll
define void @foo_main() #0 {
entry:
%b = alloca %Bar, align 4
%f = alloca %Foo, align 4
%0 = bitcast %Bar* %b to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 bitcast (%Bar* @.__const to i8*), i32 12, i1 false)
%1 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 1
%2 = getelementptr inbounds %.anon, %.anon* %1, i32 0, i32 0
%3 = getelementptr inbounds %.anon.0, %.anon.0* %2, i32 0, i32 0
%4 = load i32, i32* %3, align 4
%5 = getelementptr inbounds %Bar, %Bar* %b, i32 0, i32 2
%6 = load i32, i32* %5, align 4
%shl = shl i32 %6, 21
%ashr = ashr i32 %shl, 23
call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 %4, i32 %ashr)
%7 = bitcast %Foo* %f to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %7, i8* align 4 bitcast (%Foo* @.__const.10 to i8*), i32 16, i1 false)
%8 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0
%9 = getelementptr inbounds %.anon.1, %.anon.1* %8, i32 0, i32 0
%10 = getelementptr inbounds %.anon.2, %.anon.2* %9, i32 0, i32 0
%11 = load i32, i32* %10, align 4
%12 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0
%13 = getelementptr inbounds %.anon.1, %.anon.1* %12, i32 0, i32 1
%14 = getelementptr inbounds %.anon.3, %.anon.3* %13, i32 0, i32 0
%15 = load i32, i32* %14, align 4
%16 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 0
%17 = getelementptr inbounds %.anon.1, %.anon.1* %16, i32 0, i32 2
%18 = load i32, i32* %17, align 4
%19 = getelementptr inbounds %Foo, %Foo* %f, i32 0, i32 1
%20 = load i32, i32* %19, align 4
call void (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i32 0, i32 0), i32 %11, i32 %15, i32 %18, i32 %20)
ret void
}