xref: /llvm-project/clang/test/CodeGen/bitfield-access-unit.c (revision 617cf8a72d2ab568bf0e84452faf4e35a322b32f)
1a8ca4abfSNathan Sidwell // Check arches with 32bit ints. (Not you, AVR & MSP430)
2a8ca4abfSNathan Sidwell 
3a8ca4abfSNathan Sidwell // Configs that have cheap unaligned access
4a8ca4abfSNathan Sidwell 
5a8ca4abfSNathan Sidwell // 64-bit Little Endian
6a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=aarch64-apple-darwin %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64-DWN %s
7a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=aarch64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64,LAYOUT-64-FLEX %s
8a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=loongarch64-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64,LAYOUT-64-FLEX %s
9a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=ve-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64 %s
10a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=wasm64 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64 %s
11a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64,LAYOUT-64-FLEX %s
12a8ca4abfSNathan Sidwell 
13a8ca4abfSNathan Sidwell // 64-bit Big Endian
14a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpc64-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64,LAYOUT-64-FLEX %s
15a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=systemz %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX64,CHECK-64,LAYOUT-64,LAYOUT-64-FLEX %s
16a8ca4abfSNathan Sidwell 
17a8ca4abfSNathan Sidwell // 32-bit Little Endian
18a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-apple-darwin %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-DWN32,LAYOUT-DWN32-FLEX %s
19a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-none-eabi %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX32 %s
20a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=i686-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX32 %s
21a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpcle-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX32 %s
22a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=wasm32 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX32 %s
23a8ca4abfSNathan Sidwell 
24a8ca4abfSNathan Sidwell // 32-bit Big Endian
25a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=powerpc-linux-gnu %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-FLEX,LAYOUT-FLEX32 %s
26a8ca4abfSNathan Sidwell 
27a8ca4abfSNathan Sidwell // Configs that have expensive unaligned access
28a8ca4abfSNathan Sidwell // 64-bit Little Endian
29a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=aarch64-linux-gnu %s -target-feature +strict-align -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT,CHECK-64,LAYOUT-64,LAYOUT-64-STRICT %s
30a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=amdgcn-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT,CHECK-64,LAYOUT-64,LAYOUT-64-STRICT %s
31a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=loongarch64-elf -target-feature -ual %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT,CHECK-64,LAYOUT-64,LAYOUT-64-STRICT %s
32a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=riscv64 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT,CHECK-64,LAYOUT-64,LAYOUT-64-STRICT %s
33a8ca4abfSNathan Sidwell 
34a8ca4abfSNathan Sidwell // 64-big Big endian
35a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=mips64-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT,CHECK-64,LAYOUT-64,LAYOUT-64-STRICT %s
36a8ca4abfSNathan Sidwell 
37a8ca4abfSNathan Sidwell // 32-bit Little Endian
38a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arc-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
39a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-apple-darwin %s -target-feature +strict-align -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT-DWN32,LAYOUT-DWN32-STRICT %s
40a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=arm-none-eabi %s -target-feature +strict-align -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
41a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=bpf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
42a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=csky %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
43a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=hexagon-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
44a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=loongarch32-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
45a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=nvptx-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
46a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=riscv32 %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
47a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=spir-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
48a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=xcore-none-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
49a8ca4abfSNathan Sidwell 
50a8ca4abfSNathan Sidwell // 32-bit Big Endian
51a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=lanai-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
52a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=mips-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
53a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=sparc-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
54a8ca4abfSNathan Sidwell // RUN: %clang_cc1 -triple=tce-elf %s -emit-llvm -o /dev/null -fdump-record-layouts-simple | FileCheck --check-prefixes CHECK,LAYOUT,LAYOUT-STRICT %s
55a8ca4abfSNathan Sidwell 
56*617cf8a7SAaron Ballman // m68-elf is a strict alignment ISA with 4-byte aligned 64-bit or 2-byte
57*617cf8a7SAaron Ballman // aligned 32-bit integer types. This more compex to describe here.
58a8ca4abfSNathan Sidwell 
59a8ca4abfSNathan Sidwell // If unaligned access is expensive don't stick these together.
60a8ca4abfSNathan Sidwell struct A {
61a8ca4abfSNathan Sidwell   char a : 7;
62a8ca4abfSNathan Sidwell   char b : 7;
63a8ca4abfSNathan Sidwell } a;
64a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.A =
6549839f97SNathan Sidwell // LAYOUT-FLEX-SAME: type { i16 }
66a8ca4abfSNathan Sidwell // LAYOUT-STRICT-SAME: type { i8, i8 }
67a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type { i16 }
68a8ca4abfSNathan Sidwell // CHECK: BitFields:[
6949839f97SNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
7049839f97SNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
71a8ca4abfSNathan Sidwell 
72a8ca4abfSNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:0
73a8ca4abfSNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:1
74a8ca4abfSNathan Sidwell 
75a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
76a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
77a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
78a8ca4abfSNathan Sidwell 
79a8ca4abfSNathan Sidwell // But do here.
80a8ca4abfSNathan Sidwell struct __attribute__((aligned(2))) B {
81a8ca4abfSNathan Sidwell   char a : 7;
82a8ca4abfSNathan Sidwell   char b : 7;
83a8ca4abfSNathan Sidwell } b;
84a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.B =
8549839f97SNathan Sidwell // LAYOUT-SAME: type { i16 }
86a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type { i16 }
87a8ca4abfSNathan Sidwell // CHECK: BitFields:[
8849839f97SNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
8949839f97SNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
90a8ca4abfSNathan Sidwell 
91a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
92a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:0
93a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
94a8ca4abfSNathan Sidwell 
95a8ca4abfSNathan Sidwell // Not here -- poor alignment within struct
96a8ca4abfSNathan Sidwell struct C {
97a8ca4abfSNathan Sidwell   int f1;
98a8ca4abfSNathan Sidwell   char f2;
99a8ca4abfSNathan Sidwell   char a : 7;
100a8ca4abfSNathan Sidwell   char b : 7;
101a8ca4abfSNathan Sidwell } c;
102a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.C =
10349839f97SNathan Sidwell // LAYOUT-FLEX-SAME: type <{ i32, i8, i16, i8 }>
104a8ca4abfSNathan Sidwell // LAYOUT-STRICT-SAME: type { i32, i8, i8, i8 }
105a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type <{ i32, i8, i16, i8 }>
106a8ca4abfSNathan Sidwell // CHECK: BitFields:[
10749839f97SNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:5
10849839f97SNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:5
109a8ca4abfSNathan Sidwell 
110a8ca4abfSNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:5
111a8ca4abfSNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:6
112a8ca4abfSNathan Sidwell 
113a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:5
114a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:16 StorageOffset:5
115a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
116a8ca4abfSNathan Sidwell 
117a8ca4abfSNathan Sidwell // Not here, we're packed
118a8ca4abfSNathan Sidwell struct __attribute__((packed)) D {
119a8ca4abfSNathan Sidwell   int f1;
120a8ca4abfSNathan Sidwell   int a : 8;
121a8ca4abfSNathan Sidwell   int b : 8;
122a8ca4abfSNathan Sidwell   char _;
123a8ca4abfSNathan Sidwell } d;
124a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.D =
125a8ca4abfSNathan Sidwell // LAYOUT-FLEX-SAME: type <{ i32, i16, i8 }>
12649839f97SNathan Sidwell // LAYOUT-STRICT-SAME: type <{ i32, i8, i8, i8 }>
127a8ca4abfSNathan Sidwell // LAYOUT-DWN32-FLEX-SAME: type <{ i32, i16, i8 }>
12849839f97SNathan Sidwell // LAYOUT-DWN32-STRICT-SAME: type <{ i32, i8, i8, i8 }>
129a8ca4abfSNathan Sidwell // CHECK: BitFields:[
130a8ca4abfSNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:16 StorageOffset:4
131a8ca4abfSNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:16 StorageOffset:4
132a8ca4abfSNathan Sidwell 
13349839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:4
13449839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:5
135a8ca4abfSNathan Sidwell 
136a8ca4abfSNathan Sidwell // LAYOUT-DWN32-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:16 StorageOffset:4
137a8ca4abfSNathan Sidwell // LAYOUT-DWN32-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:16 StorageOffset:4
13849839f97SNathan Sidwell // LAYOUT-DWN32-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:4
13949839f97SNathan Sidwell // LAYOUT-DWN32-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:5
140a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
141a8ca4abfSNathan Sidwell 
142a8ca4abfSNathan Sidwell struct E {
143a8ca4abfSNathan Sidwell   char a : 7;
144a8ca4abfSNathan Sidwell   short b : 13;
145a8ca4abfSNathan Sidwell   unsigned c : 12;
146a8ca4abfSNathan Sidwell } e;
147a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.E =
14849839f97SNathan Sidwell // LAYOUT-FLEX64-SAME: type { i64 }
14949839f97SNathan Sidwell // LAYOUT-FLEX32-SAME: type { i32, i16 }
15049839f97SNathan Sidwell // LAYOUT-STRICT-SAME: type { i32, i16 }
151a8ca4abfSNathan Sidwell // LAYOUT-DWN32-SAME: type { i32 }
152a8ca4abfSNathan Sidwell // CHECK: BitFields:[
15349839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:64 StorageOffset:0
15449839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:64 StorageOffset:0
15549839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:64 StorageOffset:0
156a8ca4abfSNathan Sidwell 
15749839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
15849839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
159a8ca4abfSNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:16 StorageOffset:4
160a8ca4abfSNathan Sidwell 
16149839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
16249839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
163a8ca4abfSNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:16 StorageOffset:4
164a8ca4abfSNathan Sidwell 
165a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
166a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
167a8ca4abfSNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:32 StorageOffset:0
168a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
169a8ca4abfSNathan Sidwell 
170a8ca4abfSNathan Sidwell struct F {
171a8ca4abfSNathan Sidwell   char a : 7;
172a8ca4abfSNathan Sidwell   short b : 13;
173a8ca4abfSNathan Sidwell   unsigned c : 12;
174a8ca4abfSNathan Sidwell   signed char d : 7;
175a8ca4abfSNathan Sidwell } f;
176a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.F =
17749839f97SNathan Sidwell // LAYOUT-FLEX64-SAME: type { i64 }
17849839f97SNathan Sidwell // LAYOUT-FLEX32-SAME: type { i32, i32 }
17949839f97SNathan Sidwell // LAYOUT-STRICT-SAME: type { i32, i32 }
18049839f97SNathan Sidwell // LAYOUT-DWN32-SAME: type <{ i32, i8 }>
181a8ca4abfSNathan Sidwell // CHECK: BitFields:[
18249839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:64 StorageOffset:0
18349839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:64 StorageOffset:0
18449839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:64 StorageOffset:0
18549839f97SNathan Sidwell // LAYOUT-FLEX64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:64 StorageOffset:0
186a8ca4abfSNathan Sidwell 
18749839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
18849839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
18949839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:32 StorageOffset:4
19049839f97SNathan Sidwell // LAYOUT-FLEX32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:4
191a8ca4abfSNathan Sidwell 
19249839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
19349839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
19449839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:32 StorageOffset:4
19549839f97SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:4
196a8ca4abfSNathan Sidwell 
19749839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
19849839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
19949839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:32 StorageOffset:0
20049839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:4
201a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
202a8ca4abfSNathan Sidwell 
203a8ca4abfSNathan Sidwell struct G {
204a8ca4abfSNathan Sidwell   char a : 7;
205a8ca4abfSNathan Sidwell   short b : 13;
206a8ca4abfSNathan Sidwell   unsigned c : 12;
207a8ca4abfSNathan Sidwell   signed char d : 7;
208a8ca4abfSNathan Sidwell   signed char e;
209a8ca4abfSNathan Sidwell } g;
210a8ca4abfSNathan Sidwell // CHECK-LABEL: LLVMType:%struct.G =
21149839f97SNathan Sidwell // LAYOUT-SAME: type { i32, i16, i8, i8 }
21249839f97SNathan Sidwell // LAYOUT-DWN32-SAME: type <{ i32, i8, i8 }>
213a8ca4abfSNathan Sidwell // CHECK: BitFields:[
21449839f97SNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
21549839f97SNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
216a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:16 StorageOffset:4
217a8ca4abfSNathan Sidwell // LAYOUT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:6
218a8ca4abfSNathan Sidwell 
21949839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:32 StorageOffset:0
22049839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:13 IsSigned:1 StorageSize:32 StorageOffset:0
22149839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:12 IsSigned:0 StorageSize:32 StorageOffset:0
22249839f97SNathan Sidwell // LAYOUT-DWN32-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:8 StorageOffset:4
223a8ca4abfSNathan Sidwell // CHECK-NEXT: ]>
224a8ca4abfSNathan Sidwell 
22569d861e1SNathan Sidwell struct __attribute__((aligned(8))) H {
22669d861e1SNathan Sidwell   char a;
22769d861e1SNathan Sidwell   unsigned b : 24; // on expensive alignment we want this to stay 24
22869d861e1SNathan Sidwell   unsigned c __attribute__((aligned(8))); // Think 'long long' or lp64 ptr
22969d861e1SNathan Sidwell } h;
23069d861e1SNathan Sidwell // CHECK-LABEL: LLVMType:%struct.H =
23169d861e1SNathan Sidwell // LAYOUT-FLEX-SAME: type <{ i8, i32, [3 x i8], i32, [4 x i8] }>
23269d861e1SNathan Sidwell // LAYOUT-STRICT-SAME: type { i8, [3 x i8], [4 x i8], i32, [4 x i8] }
23369d861e1SNathan Sidwell // LAYOUT-DWN32-FLEX-SAME: type <{ i8, i32, [3 x i8], i32, [4 x i8] }>
23469d861e1SNathan Sidwell // LAYOUT-DWN32-STRICT-SAME: type { i8, [3 x i8], [4 x i8], i32, [4 x i8] }
23569d861e1SNathan Sidwell // CHECK: BitFields:[
23669d861e1SNathan Sidwell // LAYOUT-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:24 IsSigned:0 StorageSize:32 StorageOffset:1
23769d861e1SNathan Sidwell // LAYOUT-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:24 IsSigned:0 StorageSize:24 StorageOffset:1
23869d861e1SNathan Sidwell 
23969d861e1SNathan Sidwell // LAYOUT-DWN32-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:24 IsSigned:0 StorageSize:32 StorageOffset:1
24069d861e1SNathan Sidwell // LAYOUT-DWN32-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:24 IsSigned:0 StorageSize:24 StorageOffset:1
24169d861e1SNathan Sidwell // CHECK-NEXT: ]>
24269d861e1SNathan Sidwell 
243a8ca4abfSNathan Sidwell #if _LP64
244a8ca4abfSNathan Sidwell struct A64 {
245a8ca4abfSNathan Sidwell   int a : 16;
246a8ca4abfSNathan Sidwell   short b : 8;
247a8ca4abfSNathan Sidwell   long c : 16;
248a8ca4abfSNathan Sidwell   int d : 16;
249a8ca4abfSNathan Sidwell   signed char e : 8;
250a8ca4abfSNathan Sidwell } a64;
251a8ca4abfSNathan Sidwell // CHECK-64-LABEL: LLVMType:%struct.A64 =
252a8ca4abfSNathan Sidwell // LAYOUT-64-SAME: type { i64 }
253a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-SAME: type { i64 }
254a8ca4abfSNathan Sidwell // CHECK-64: BitFields:[
255a8ca4abfSNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
256a8ca4abfSNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
257a8ca4abfSNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
258a8ca4abfSNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
259a8ca4abfSNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
260a8ca4abfSNathan Sidwell 
261a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
262a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
263a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
264a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
265a8ca4abfSNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
266a8ca4abfSNathan Sidwell // CHECK-64-NEXT: ]>
267a8ca4abfSNathan Sidwell 
268a8ca4abfSNathan Sidwell struct B64 {
269a8ca4abfSNathan Sidwell   int a : 16;
270a8ca4abfSNathan Sidwell   short b : 8;
271a8ca4abfSNathan Sidwell   long c : 16;
272a8ca4abfSNathan Sidwell   int d : 16;
273a8ca4abfSNathan Sidwell   signed char e; // not a bitfield
274a8ca4abfSNathan Sidwell } b64;
275a8ca4abfSNathan Sidwell // CHECK-64-LABEL: LLVMType:%struct.B64 =
27649839f97SNathan Sidwell // LAYOUT-64-FLEX-SAME: type <{ i16, i8, i32, i8 }>
27749839f97SNathan Sidwell // LAYOUT-64-STRICT-SAME: type <{ i16, i8, i16, i16, i8 }>
27849839f97SNathan Sidwell // LAYOUT-64-DWN-SAME: type <{ i16, i8, i32, i8 }>
279a8ca4abfSNathan Sidwell // CHECK-64: BitFields:[
28049839f97SNathan Sidwell // LAYOUT-64-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:16 StorageOffset:0
28149839f97SNathan Sidwell // LAYOUT-64-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:2
28249839f97SNathan Sidwell // LAYOUT-64-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:32 StorageOffset:3
28349839f97SNathan Sidwell // LAYOUT-64-FLEX-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:32 StorageOffset:3
284a8ca4abfSNathan Sidwell 
28549839f97SNathan Sidwell // LAYOUT-64-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:16 StorageOffset:0
28649839f97SNathan Sidwell // LAYOUT-64-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:2
28749839f97SNathan Sidwell // LAYOUT-64-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:16 StorageOffset:3
28849839f97SNathan Sidwell // LAYOUT-64-STRICT-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:16 StorageOffset:5
289a8ca4abfSNathan Sidwell 
29049839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:16 StorageOffset:0
29149839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:8 StorageOffset:2
29249839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:32 StorageOffset:3
29349839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:32 StorageOffset:3
294a8ca4abfSNathan Sidwell // CHECK-64-NEXT: ]>
295a8ca4abfSNathan Sidwell 
296a8ca4abfSNathan Sidwell struct C64 {
297a8ca4abfSNathan Sidwell   int a : 15;
298a8ca4abfSNathan Sidwell   short b : 8;
299a8ca4abfSNathan Sidwell   long c : 16;
300a8ca4abfSNathan Sidwell   int d : 15;
301a8ca4abfSNathan Sidwell   signed char e : 7;
302a8ca4abfSNathan Sidwell } c64;
303a8ca4abfSNathan Sidwell // CHECK-64-LABEL: LLVMType:%struct.C64 =
30449839f97SNathan Sidwell // LAYOUT-64-SAME: type {  i64 }
30549839f97SNathan Sidwell // LAYOUT-64-DWN-SAME: type {  i64 }
306a8ca4abfSNathan Sidwell // CHECK-64: BitFields:[
30749839f97SNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:1 StorageSize:64 StorageOffset:0
30849839f97SNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
30949839f97SNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
31049839f97SNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:1 StorageSize:64 StorageOffset:0
31149839f97SNathan Sidwell // LAYOUT-64-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:64 StorageOffset:0
312a8ca4abfSNathan Sidwell 
31349839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:1 StorageSize:64 StorageOffset:0
31449839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:8 IsSigned:1 StorageSize:64 StorageOffset:0
31549839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:16 IsSigned:1 StorageSize:64 StorageOffset:0
31649839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:15 IsSigned:1 StorageSize:64 StorageOffset:0
31749839f97SNathan Sidwell // LAYOUT-64-DWN-NEXT: <CGBitFieldInfo Offset:{{[0-9]+}} Size:7 IsSigned:1 StorageSize:64 StorageOffset:0
318a8ca4abfSNathan Sidwell // CHECK-64-NEXT: ]>
319a8ca4abfSNathan Sidwell 
320a8ca4abfSNathan Sidwell #endif
321