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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* { dg-do run } */
/* { dg-options "-O2 --save-temps -fno-inline" } */
extern void abort (void);
typedef struct bitfield
{
unsigned short eight: 8;
unsigned short four: 4;
unsigned short five: 5;
unsigned short seven: 7;
unsigned int sixteen: 16;
} bitfield;
bitfield
bfi1 (bitfield a)
{
/* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 0, 8" } } */
a.eight = 3;
return a;
}
bitfield
bfi2 (bitfield a)
{
/* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 16, 5" } } */
a.five = 7;
return a;
}
bitfield
movk (bitfield a)
{
/* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0x1d6b, lsl 32" } } */
a.sixteen = 7531;
return a;
}
bitfield
set1 (bitfield a)
{
/* { dg-final { scan-assembler "orr\tx\[0-9\]+, x\[0-9\]+, 2031616" } } */
a.five = 0x1f;
return a;
}
bitfield
set0 (bitfield a)
{
/* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, -2031617" } } */
a.five = 0;
return a;
}
int
main (int argc, char** argv)
{
static bitfield a;
bitfield b = bfi1 (a);
bitfield c = bfi2 (b);
bitfield d = movk (c);
if (d.eight != 3)
abort ();
if (d.five != 7)
abort ();
if (d.sixteen != 7531)
abort ();
d = set1 (d);
if (d.five != 0x1f)
abort ();
d = set0 (d);
if (d.five != 0)
abort ();
return 0;
}
/* { dg-final { cleanup-saved-temps } } */
|