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