Debian Codegraph @

gcc/testsuite/gcc.target/bpf/atomic-fetch-op-1.c

raw
1 /* Test 64-bit atomic-fetch-op instructions. */
2
3 /* { dg-do compile } */
4 /* { dg-options "-mv3-atomics -O2 -masm=normal" } */
5
6 long val;
7
8 long
9 test_atomic_fetch_add (long x)
10 {
11 return __atomic_fetch_add (&val, x, __ATOMIC_ACQUIRE);
12 }
13
14 long
15 test_atomic_fetch_sub (long x)
16 {
17 return __atomic_fetch_sub (&val, x, __ATOMIC_RELEASE);
18 }
19
20 long
21 test_atomic_fetch_and (long x)
22 {
23 return __atomic_fetch_and (&val, x, __ATOMIC_ACQUIRE);
24 }
25
26 long
27 test_atomic_fetch_nand (long x)
28 {
29 return __atomic_fetch_nand (&val, x, __ATOMIC_ACQUIRE);
30 }
31
32 long
33 test_atomic_fetch_or (long x)
34 {
35 return __atomic_fetch_or (&val, x, __ATOMIC_ACQUIRE);
36 }
37
38 long
39 test_atomic_fetch_xor (long x)
40 {
41 return __atomic_fetch_xor (&val, x, __ATOMIC_ACQUIRE);
42 }
43
44 /* sub implemented in terms of add */
45 /* { dg-final { scan-assembler-times "afadd\t" 2 } } */
46 /* { dg-final { scan-assembler-times "afand\t" 1 } } */
47 /* nand must use a compare-exchange loop */
48 /* { dg-final { scan-assembler "acmp\t" } } */
49 /* { dg-final { scan-assembler-times "afor\t" 1 } } */
50 /* { dg-final { scan-assembler-times "afxor\t" 1 } } */