Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.target / s390 / htm-builtins-compile-1.c
blob982a7483dbe7032ea445a9b53091bf03d084df8d
1 /* This checks the availability of the low-level builtins introduced
2 for transactional execution. */
4 /* { dg-do compile } */
5 /* { dg-options "-O3 -march=zEC12 -mzarch" } */
7 #include <stdint.h>
8 #include <htmintrin.h>
10 int global = 0;
11 uint64_t g;
12 struct __htm_tdb global_tdb;
14 int
15 foo (struct __htm_tdb* tdb, int reg, int *mem, uint64_t *mem64)
18 int cc;
19 int n;
21 __builtin_tbegin ((void *)0);
22 __builtin_tbegin ((void *)-99999);
23 __builtin_tbegin ((void *)99999);
24 while (__builtin_tbegin ((void *)0) != 0)
27 cc = __builtin_tbegin ((void *)0x12345678);
28 cc = __builtin_tbegin (tdb);
29 cc = __builtin_tbegin (&global_tdb);
30 cc = __builtin_tbegin ((void *)(long)(reg + 0x12345678));
31 cc = __builtin_tbegin ((void *)(long)(reg));
33 __builtin_tbegin_nofloat ((void *)0);
34 __builtin_tbegin_nofloat ((void *)-99999);
35 __builtin_tbegin_nofloat ((void *)99999);
36 cc = __builtin_tbegin_nofloat ((void *)0x12345678);
37 cc = __builtin_tbegin_nofloat (tdb);
38 cc = __builtin_tbegin_nofloat (&global_tdb);
39 cc = __builtin_tbegin_nofloat ((void *)(long)(reg + 0x12345678));
40 cc = __builtin_tbegin_nofloat ((void *)(long)(reg));
42 __builtin_tbegin_retry ((void *)0, 0);
43 cc = __builtin_tbegin_retry ((void *)0, 1);
44 cc = __builtin_tbegin_retry ((void *)0, -1);
45 cc = __builtin_tbegin_retry ((void *)0, 42);
46 cc = __builtin_tbegin_retry ((void *)0, reg);
47 cc = __builtin_tbegin_retry ((void *)0, *mem);
48 cc = __builtin_tbegin_retry ((void *)0, global);
49 cc = __builtin_tbegin_retry (tdb, 42);
50 cc = __builtin_tbegin_retry (&global_tdb, 42);
51 cc = __builtin_tbegin_retry ((void *)0x12345678, global);
52 cc = __builtin_tbegin_retry (
53 (void *)(long) (reg + 0x12345678), global + 1);
54 cc = __builtin_tbegin_retry (
55 (void *)(long)(reg), global - 1);
57 __builtin_tbegin_retry_nofloat ((void *)0, 0);
58 cc = __builtin_tbegin_retry_nofloat ((void *)0, 1);
59 cc = __builtin_tbegin_retry_nofloat ((void *)0, -1);
60 cc = __builtin_tbegin_retry_nofloat ((void *)0, 42);
61 cc = __builtin_tbegin_retry_nofloat ((void *)0, reg);
62 cc = __builtin_tbegin_retry_nofloat ((void *)0, *mem);
63 cc = __builtin_tbegin_retry_nofloat ((void *)0, global);
64 cc = __builtin_tbegin_retry_nofloat (tdb, 42);
65 cc = __builtin_tbegin_retry_nofloat (&global_tdb, 42);
66 cc = __builtin_tbegin_retry_nofloat ((void *)0x12345678, global);
67 cc = __builtin_tbegin_retry_nofloat (
68 (void *)(long) (reg + 0x12345678), global + 1);
69 cc = __builtin_tbegin_retry_nofloat (
70 (void *)(long)(reg), global - 1);
72 __builtin_tbeginc ();
74 __builtin_tx_nesting_depth ();
75 n = __builtin_tx_nesting_depth ();
77 __builtin_non_tx_store (mem64, 0);
79 const uint64_t val_var = 0x1122334455667788;
81 __builtin_non_tx_store (mem64, val_var);
83 __builtin_non_tx_store (mem64, (uint64_t)reg);
84 __builtin_non_tx_store (mem64, g);
85 __builtin_non_tx_store ((uint64_t *)0, 0);
86 __builtin_non_tx_store ((uint64_t *)0x12345678, 0);
87 __builtin_non_tx_store (&g, 23);
88 __builtin_non_tx_store (&g, reg);
89 __builtin_non_tx_store (&g, *mem);
90 __builtin_non_tx_store (&g, global);
92 __builtin_tend();
94 __builtin_tx_assist (0);
95 __builtin_tx_assist (1);
96 __builtin_tx_assist (reg);
97 __builtin_tx_assist (*mem);
98 __builtin_tx_assist (global);
101 /* The taborts must go into separate function since they are
102 "noreturn". */
104 void
105 tabort1 ()
107 __builtin_tabort (256);
110 void
111 tabort2 (int reg)
113 __builtin_tabort (reg);
116 void
117 tabort3 (int reg)
119 /* { dg-final { scan-assembler-times "tabort\t255" 1 } } */
120 __builtin_tabort (reg + 255);
123 void
124 tabort4 (int *mem)
126 __builtin_tabort (*mem);
129 void
130 tabort5 ()
132 __builtin_tabort (global);
135 void
136 tabort6 (int *mem)
138 /* Here global + 255 gets reloaded into a reg. Better would be to
139 just reload global or *mem and get the +255 for free as address
140 arithmetic. */
141 __builtin_tabort (*mem + 255);
144 void
145 tabort7 ()
147 __builtin_tabort (global + 255);
150 void
151 tabort8 ()
153 __builtin_tabort (-1);
157 /* Make sure the tdb NULL argument ends up as immediate value in the
158 instruction. */
159 /* { dg-final { scan-assembler-times "tbegin\t0," 17 } } */
160 /* { dg-final { scan-assembler-times "tbegin\t" 41 } } */
161 /* Check number of occurences of certain instructions. */
162 /* { dg-final { scan-assembler-times "tbeginc\t" 1 } } */
163 /* { dg-final { scan-assembler-times "tabort\t" 8 } } */
164 /* { dg-final { scan-assembler "ppa\t" } } */