Debian Codegraph @

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

raw
1 /* Test 32-bit atomic-fetch-op instructions. */
2
3 /* { dg-do compile } */
4 /* { dg-options "-mv3-atomics -O2 -masm=normal" } */
5
6 int val;
7
8 int
9 test_atomic_fetch_add (int x)
10 {
11 return __atomic_fetch_add (&val, x, __ATOMIC_ACQUIRE);
12 }
13
14 int
15 test_atomic_fetch_sub (int x)
16 {
17 return __atomic_fetch_sub (&val, x, __ATOMIC_RELEASE);
18 }
19
20 int
21 test_atomic_fetch_and (int x)
22 {
23 return __atomic_fetch_and (&val, x, __ATOMIC_ACQUIRE);
24 }
25
26 int
27 test_atomic_fetch_nand (int x)
28 {
29 return __atomic_fetch_nand (&val, x, __ATOMIC_ACQUIRE);
30 }
31
32 int
33 test_atomic_fetch_or (int x)
34 {
35 return __atomic_fetch_or (&val, x, __ATOMIC_ACQUIRE);
36 }
37
38 int
39 test_atomic_fetch_xor (int 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 "afadd32\t" 2 } } */
46 /* { dg-final { scan-assembler-times "afand32\t" 1 } } */
47 /* nand must use a compare-exchange loop */
48 /* { dg-final { scan-assembler "acmp32\t" } } */
49 /* { dg-final { scan-assembler-times "afor32\t" 1 } } */
50 /* { dg-final { scan-assembler-times "afxor32\t" 1 } } */