Debian Codegraph @

gcc/testsuite/gcc.dg/debug/btf/btf-bitfields-1.c

raw
1 /* Basic tests for BTF bitfields.
2
3 The structure containing bitfield members should be marked with KIND_FLAG=1
4 The bitfield member offsets should be encoded as:
5 (bit_size << 24) | bit_offset
6 - (0xa << 24) | 0x20
7 - (0x7 << 24) | 0x2a
8 - (0x13 << 24) | 0x40 - note that this is aligned to 0x40.
9 - (0x13 << 24) | 0x31 - in case structures are packed. */
10
11 /* { dg-do compile } */
12 /* { dg-options "-O0 -gbtf -dA" } */
13 /* { dg-require-effective-target int32plus } */
14
15 /* { dg-final { scan-assembler-times "\[\t \]0x84000004\[\t \]+\[^\n\]*btt_info" 1 } } */
16
17 /* { dg-final { scan-assembler-times "\[\t \]0xa000020\[\t \]+\[^\n\]*btm_offset" 1 } } */
18 /* { dg-final { scan-assembler-times "\[\t \]0x700002a\[\t \]+\[^\n\]*btm_offset" 1 } } */
19 /* { dg-final { scan-assembler-times "\[\t \]0x13000040\[\t \]+\[^\n\]*btm_offset" 1 { target { ! default_packed } } } } */
20 /* { dg-final { scan-assembler-times "\[\t \]0x13000031\[\t \]+\[^\n\]*btm_offset" 1 { target { default_packed } } } } */
21
22 struct bitt {
23 int a;
24 unsigned int bitfield_a : 10;
25 unsigned int bitfield_b : 7;
26 unsigned int bitfield_c : 19;
27 } bitty;
28
29 struct no_bitt {
30 int a;
31 int b;
32 } no_bitty;
33
34 int main ()
35 {
36 return bitty.bitfield_b + bitty.a;
37 }