Files
c3c/test/test_suite2/bitstruct/embedded_bitstruct.c3t
Christoffer Lerno 44df6eb75b Cleanup.
2022-08-12 18:13:24 +02:00

80 lines
2.0 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
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %b, ptr align 4 @.__const, i32 12, i1 false)
%0 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 1
%1 = getelementptr inbounds %anon, ptr %0, i32 0, i32 0
%2 = getelementptr inbounds %anon.0, ptr %1, i32 0, i32 0
%3 = load i32, ptr %2, align 4
%4 = getelementptr inbounds %Bar, ptr %b, i32 0, i32 2
%5 = load i32, ptr %4, align 4
%shl = shl i32 %5, 21
%ashr = ashr i32 %shl, 23
call void (ptr, ...) @printf(ptr @.str, i32 %3, i32 %ashr)
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %f, ptr align 4 @.__const.10, i32 16, i1 false)
%6 = getelementptr inbounds %Foo, ptr %f, i32 0, i32 0
%7 = getelementptr inbounds %anon.1, ptr %6, i32 0, i32 0
%8 = getelementptr inbounds %anon.2, ptr %7, i32 0, i32 0
%9 = load i32, ptr %8, align 4
%10 = getelementptr inbounds %Foo, ptr %f, i32 0, i32 0
%11 = getelementptr inbounds %anon.1, ptr %10, i32 0, i32 1
%12 = getelementptr inbounds %anon.3, ptr %11, i32 0, i32 0
%13 = load i32, ptr %12, align 4
%14 = getelementptr inbounds %Foo, ptr %f, i32 0, i32 0
%15 = getelementptr inbounds %anon.1, ptr %14, i32 0, i32 2
%16 = load i32, ptr %15, align 4
%17 = getelementptr inbounds %Foo, ptr %f, i32 0, i32 1
%18 = load i32, ptr %17, align 4
call void (ptr, ...) @printf(ptr @.str.11, i32 %9, i32 %13, i32 %16, i32 %18)
ret void
}