File: core-builtin-fieldinfo-lshift-1-le.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (37 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download
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
/* { dg-do compile } */
/* { dg-options "-O0 -dA -gbtf -mco-re -mlittle-endian -masm=normal" } */

struct S {
  int x1: 6;
  int x2: 3;
  int x3: 7;
  int x4: 16;
};

enum {
  FIELD_LSHIFT_U64 = 4,
};

unsigned int foo (struct S *s)
{
  /* little endian: x1=58, x2=55, x3=48, x4=32 */
  /* big endian:    x1=32, x2=38, x3=41, x4=48 */
  unsigned x1 = __builtin_preserve_field_info (s->x1, FIELD_LSHIFT_U64);
  unsigned x2 = __builtin_preserve_field_info (s->x2, FIELD_LSHIFT_U64);
  unsigned x3 = __builtin_preserve_field_info (s->x3, FIELD_LSHIFT_U64);
  unsigned x4 = __builtin_preserve_field_info (s->x4, FIELD_LSHIFT_U64);

  return x1 + x2 + x3 + x4;
}

/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],58" 1 } } */
/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],55" 1 } } */
/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],48" 1 } } */
/* { dg-final { scan-assembler-times "\[\t \]lddw\[\t \]%r\[0-9\],32" 1 } } */

/* { dg-final { scan-assembler-times "ascii \"0:0.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
/* { dg-final { scan-assembler-times "ascii \"0:1.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
/* { dg-final { scan-assembler-times "ascii \"0:2.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */
/* { dg-final { scan-assembler-times "ascii \"0:3.0\"\[\t \]+\[^\n\]*btf_aux_string" 1 } } */

/* { dg-final { scan-assembler-times "0x4\[\t \]+\[^\n\]*bpfcr_kind" 4 } } */