llvm.org GIT mirror llvm / 72e3d1c
Merge from mainline git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_24@57701 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
2 changed file(s) with 6 addition(s) and 98 deletion(s). Raw diff Collapse all Expand all
0 // Test frontend handling of __sync builtins.
11 // Modified from a gcc testcase.
2 // RUN: %llvmgcc -S %s -o - | grep atomic | count 192
2 // RUN: %llvmgcc -S %s -o - | grep atomic | count 150
33 // RUN: %llvmgcc -S %s -o - | grep p0i8 | count 50
44 // RUN: %llvmgcc -S %s -o - | grep p0i16 | count 50
5 // RUN: %llvmgcc -S %s -o - | grep p0i32 | count 92
6 // RUN: %llvmgcc -S %s -o - | grep volatile | count 8
5 // RUN: %llvmgcc -S %s -o - | grep p0i32 | count 50
6 // RUN: %llvmgcc -S %s -o - | grep volatile | count 6
77
88 // Currently this is implemented only for Alpha, X86, PowerPC.
99 // Add your target here if it doesn't work.
1616 unsigned short us;
1717 signed int si;
1818 unsigned int ui;
19 signed long sl;
20 unsigned long ul;
2119
2220 void test_op_ignore (void)
2321 {
2725 (void) __sync_fetch_and_add (&us, 1);
2826 (void) __sync_fetch_and_add (&si, 1);
2927 (void) __sync_fetch_and_add (&ui, 1);
30 (void) __sync_fetch_and_add (&sl, 1);
31 (void) __sync_fetch_and_add (&ul, 1);
3228
3329 (void) __sync_fetch_and_sub (&sc, 1);
3430 (void) __sync_fetch_and_sub (&uc, 1);
3632 (void) __sync_fetch_and_sub (&us, 1);
3733 (void) __sync_fetch_and_sub (&si, 1);
3834 (void) __sync_fetch_and_sub (&ui, 1);
39 (void) __sync_fetch_and_sub (&sl, 1);
40 (void) __sync_fetch_and_sub (&ul, 1);
4135
4236 (void) __sync_fetch_and_or (&sc, 1);
4337 (void) __sync_fetch_and_or (&uc, 1);
4539 (void) __sync_fetch_and_or (&us, 1);
4640 (void) __sync_fetch_and_or (&si, 1);
4741 (void) __sync_fetch_and_or (&ui, 1);
48 (void) __sync_fetch_and_or (&sl, 1);
49 (void) __sync_fetch_and_or (&ul, 1);
5042
5143 (void) __sync_fetch_and_xor (&sc, 1);
5244 (void) __sync_fetch_and_xor (&uc, 1);
5446 (void) __sync_fetch_and_xor (&us, 1);
5547 (void) __sync_fetch_and_xor (&si, 1);
5648 (void) __sync_fetch_and_xor (&ui, 1);
57 (void) __sync_fetch_and_xor (&sl, 1);
58 (void) __sync_fetch_and_xor (&ul, 1);
5949
6050 (void) __sync_fetch_and_and (&sc, 1);
6151 (void) __sync_fetch_and_and (&uc, 1);
6353 (void) __sync_fetch_and_and (&us, 1);
6454 (void) __sync_fetch_and_and (&si, 1);
6555 (void) __sync_fetch_and_and (&ui, 1);
66 (void) __sync_fetch_and_and (&sl, 1);
67 (void) __sync_fetch_and_and (&ul, 1);
6856
6957 (void) __sync_fetch_and_nand (&sc, 1);
7058 (void) __sync_fetch_and_nand (&uc, 1);
7260 (void) __sync_fetch_and_nand (&us, 1);
7361 (void) __sync_fetch_and_nand (&si, 1);
7462 (void) __sync_fetch_and_nand (&ui, 1);
75 (void) __sync_fetch_and_nand (&sl, 1);
76 (void) __sync_fetch_and_nand (&ul, 1);
7763 }
7864
7965 void test_fetch_and_op (void)
8470 us = __sync_fetch_and_add (&us, 11);
8571 si = __sync_fetch_and_add (&si, 11);
8672 ui = __sync_fetch_and_add (&ui, 11);
87 sl = __sync_fetch_and_add (&sl, 11);
88 ul = __sync_fetch_and_add (&ul, 11);
8973
9074 sc = __sync_fetch_and_sub (&sc, 11);
9175 uc = __sync_fetch_and_sub (&uc, 11);
9377 us = __sync_fetch_and_sub (&us, 11);
9478 si = __sync_fetch_and_sub (&si, 11);
9579 ui = __sync_fetch_and_sub (&ui, 11);
96 sl = __sync_fetch_and_sub (&sl, 11);
97 ul = __sync_fetch_and_sub (&ul, 11);
9880
9981 sc = __sync_fetch_and_or (&sc, 11);
10082 uc = __sync_fetch_and_or (&uc, 11);
10284 us = __sync_fetch_and_or (&us, 11);
10385 si = __sync_fetch_and_or (&si, 11);
10486 ui = __sync_fetch_and_or (&ui, 11);
105 sl = __sync_fetch_and_or (&sl, 11);
106 ul = __sync_fetch_and_or (&ul, 11);
10787
10888 sc = __sync_fetch_and_xor (&sc, 11);
10989 uc = __sync_fetch_and_xor (&uc, 11);
11191 us = __sync_fetch_and_xor (&us, 11);
11292 si = __sync_fetch_and_xor (&si, 11);
11393 ui = __sync_fetch_and_xor (&ui, 11);
114 sl = __sync_fetch_and_xor (&sl, 11);
115 ul = __sync_fetch_and_xor (&ul, 11);
11694
11795 sc = __sync_fetch_and_and (&sc, 11);
11896 uc = __sync_fetch_and_and (&uc, 11);
12098 us = __sync_fetch_and_and (&us, 11);
12199 si = __sync_fetch_and_and (&si, 11);
122100 ui = __sync_fetch_and_and (&ui, 11);
123 sl = __sync_fetch_and_and (&sl, 11);
124 ul = __sync_fetch_and_and (&ul, 11);
125101
126102 sc = __sync_fetch_and_nand (&sc, 11);
127103 uc = __sync_fetch_and_nand (&uc, 11);
129105 us = __sync_fetch_and_nand (&us, 11);
130106 si = __sync_fetch_and_nand (&si, 11);
131107 ui = __sync_fetch_and_nand (&ui, 11);
132 sl = __sync_fetch_and_nand (&sl, 11);
133 ul = __sync_fetch_and_nand (&ul, 11);
134108 }
135109
136110 void test_op_and_fetch (void)
141115 us = __sync_add_and_fetch (&us, uc);
142116 si = __sync_add_and_fetch (&si, uc);
143117 ui = __sync_add_and_fetch (&ui, uc);
144 sl = __sync_add_and_fetch (&sl, uc);
145 ul = __sync_add_and_fetch (&ul, uc);
146118
147119 sc = __sync_sub_and_fetch (&sc, uc);
148120 uc = __sync_sub_and_fetch (&uc, uc);
150122 us = __sync_sub_and_fetch (&us, uc);
151123 si = __sync_sub_and_fetch (&si, uc);
152124 ui = __sync_sub_and_fetch (&ui, uc);
153 sl = __sync_sub_and_fetch (&sl, uc);
154 ul = __sync_sub_and_fetch (&ul, uc);
155125
156126 sc = __sync_or_and_fetch (&sc, uc);
157127 uc = __sync_or_and_fetch (&uc, uc);
159129 us = __sync_or_and_fetch (&us, uc);
160130 si = __sync_or_and_fetch (&si, uc);
161131 ui = __sync_or_and_fetch (&ui, uc);
162 sl = __sync_or_and_fetch (&sl, uc);
163 ul = __sync_or_and_fetch (&ul, uc);
164132
165133 sc = __sync_xor_and_fetch (&sc, uc);
166134 uc = __sync_xor_and_fetch (&uc, uc);
168136 us = __sync_xor_and_fetch (&us, uc);
169137 si = __sync_xor_and_fetch (&si, uc);
170138 ui = __sync_xor_and_fetch (&ui, uc);
171 sl = __sync_xor_and_fetch (&sl, uc);
172 ul = __sync_xor_and_fetch (&ul, uc);
173139
174140 sc = __sync_and_and_fetch (&sc, uc);
175141 uc = __sync_and_and_fetch (&uc, uc);
177143 us = __sync_and_and_fetch (&us, uc);
178144 si = __sync_and_and_fetch (&si, uc);
179145 ui = __sync_and_and_fetch (&ui, uc);
180 sl = __sync_and_and_fetch (&sl, uc);
181 ul = __sync_and_and_fetch (&ul, uc);
182146
183147 sc = __sync_nand_and_fetch (&sc, uc);
184148 uc = __sync_nand_and_fetch (&uc, uc);
186150 us = __sync_nand_and_fetch (&us, uc);
187151 si = __sync_nand_and_fetch (&si, uc);
188152 ui = __sync_nand_and_fetch (&ui, uc);
189 sl = __sync_nand_and_fetch (&sl, uc);
190 ul = __sync_nand_and_fetch (&ul, uc);
191153 }
192154
193155 void test_compare_and_swap (void)
198160 us = __sync_val_compare_and_swap (&us, uc, sc);
199161 si = __sync_val_compare_and_swap (&si, uc, sc);
200162 ui = __sync_val_compare_and_swap (&ui, uc, sc);
201 sl = __sync_val_compare_and_swap (&sl, uc, sc);
202 ul = __sync_val_compare_and_swap (&ul, uc, sc);
203163
204164 ui = __sync_bool_compare_and_swap (&sc, uc, sc);
205165 ui = __sync_bool_compare_and_swap (&uc, uc, sc);
207167 ui = __sync_bool_compare_and_swap (&us, uc, sc);
208168 ui = __sync_bool_compare_and_swap (&si, uc, sc);
209169 ui = __sync_bool_compare_and_swap (&ui, uc, sc);
210 ui = __sync_bool_compare_and_swap (&sl, uc, sc);
211 ui = __sync_bool_compare_and_swap (&ul, uc, sc);
212170 }
213171
214172 void test_lock (void)
219177 us = __sync_lock_test_and_set (&us, 1);
220178 si = __sync_lock_test_and_set (&si, 1);
221179 ui = __sync_lock_test_and_set (&ui, 1);
222 sl = __sync_lock_test_and_set (&sl, 1);
223 ul = __sync_lock_test_and_set (&ul, 1);
224180
225181 __sync_synchronize ();
226182
230186 __sync_lock_release (&us);
231187 __sync_lock_release (&si);
232188 __sync_lock_release (&ui);
233 __sync_lock_release (&sl);
234 __sync_lock_release (&ul);
235189 }
0 // Test frontend handling of __sync builtins.
11 // Modified from a gcc testcase.
2 // RUN: %llvmgcc -S %s -o - | grep atomic | count 242
2 // RUN: %llvmgcc -S %s -o - | grep atomic | count 200
33 // RUN: %llvmgcc -S %s -o - | grep p0i8 | count 50
44 // RUN: %llvmgcc -S %s -o - | grep p0i16 | count 50
5 // RUN: %llvmgcc -S %s -o - | grep p0i32 | count 92
6 // RUN: %llvmgcc -S %s -o - | grep volatile | count 10
5 // RUN: %llvmgcc -S %s -o - | grep p0i32 | count 50
6 // RUN: %llvmgcc -S %s -o - | grep volatile | count 8
77
88 // Currently this is implemented only for Alpha, X86, PowerPC.
99 // Add your target here if it doesn't work.
1616 unsigned short us;
1717 signed int si;
1818 unsigned int ui;
19 signed long sl;
20 unsigned long ul;
2119 signed long long sll;
2220 unsigned long long ull;
2321
2927 (void) __sync_fetch_and_add (&us, 1);
3028 (void) __sync_fetch_and_add (&si, 1);
3129 (void) __sync_fetch_and_add (&ui, 1);
32 (void) __sync_fetch_and_add (&sl, 1);
33 (void) __sync_fetch_and_add (&ul, 1);
3430 (void) __sync_fetch_and_add (&sll, 1);
3531 (void) __sync_fetch_and_add (&ull, 1);
3632
4036 (void) __sync_fetch_and_sub (&us, 1);
4137 (void) __sync_fetch_and_sub (&si, 1);
4238 (void) __sync_fetch_and_sub (&ui, 1);
43 (void) __sync_fetch_and_sub (&sl, 1);
44 (void) __sync_fetch_and_sub (&ul, 1);
4539 (void) __sync_fetch_and_sub (&sll, 1);
4640 (void) __sync_fetch_and_sub (&ull, 1);
4741
5145 (void) __sync_fetch_and_or (&us, 1);
5246 (void) __sync_fetch_and_or (&si, 1);
5347 (void) __sync_fetch_and_or (&ui, 1);
54 (void) __sync_fetch_and_or (&sl, 1);
55 (void) __sync_fetch_and_or (&ul, 1);
5648 (void) __sync_fetch_and_or (&sll, 1);
5749 (void) __sync_fetch_and_or (&ull, 1);
5850
6254 (void) __sync_fetch_and_xor (&us, 1);
6355 (void) __sync_fetch_and_xor (&si, 1);
6456 (void) __sync_fetch_and_xor (&ui, 1);
65 (void) __sync_fetch_and_xor (&sl, 1);
66 (void) __sync_fetch_and_xor (&ul, 1);
6757 (void) __sync_fetch_and_xor (&sll, 1);
6858 (void) __sync_fetch_and_xor (&ull, 1);
6959
7363 (void) __sync_fetch_and_and (&us, 1);
7464 (void) __sync_fetch_and_and (&si, 1);
7565 (void) __sync_fetch_and_and (&ui, 1);
76 (void) __sync_fetch_and_and (&sl, 1);
77 (void) __sync_fetch_and_and (&ul, 1);
7866 (void) __sync_fetch_and_and (&sll, 1);
7967 (void) __sync_fetch_and_and (&ull, 1);
8068
8472 (void) __sync_fetch_and_nand (&us, 1);
8573 (void) __sync_fetch_and_nand (&si, 1);
8674 (void) __sync_fetch_and_nand (&ui, 1);
87 (void) __sync_fetch_and_nand (&sl, 1);
88 (void) __sync_fetch_and_nand (&ul, 1);
8975 (void) __sync_fetch_and_nand (&sll, 1);
9076 (void) __sync_fetch_and_nand (&ull, 1);
9177 }
9884 us = __sync_fetch_and_add (&us, 11);
9985 si = __sync_fetch_and_add (&si, 11);
10086 ui = __sync_fetch_and_add (&ui, 11);
101 sl = __sync_fetch_and_add (&sl, 11);
102 ul = __sync_fetch_and_add (&ul, 11);
10387 sll = __sync_fetch_and_add (&sll, 11);
10488 ull = __sync_fetch_and_add (&ull, 11);
10589
10993 us = __sync_fetch_and_sub (&us, 11);
11094 si = __sync_fetch_and_sub (&si, 11);
11195 ui = __sync_fetch_and_sub (&ui, 11);
112 sl = __sync_fetch_and_sub (&sl, 11);
113 ul = __sync_fetch_and_sub (&ul, 11);
11496 sll = __sync_fetch_and_sub (&sll, 11);
11597 ull = __sync_fetch_and_sub (&ull, 11);
11698
120102 us = __sync_fetch_and_or (&us, 11);
121103 si = __sync_fetch_and_or (&si, 11);
122104 ui = __sync_fetch_and_or (&ui, 11);
123 sl = __sync_fetch_and_or (&sl, 11);
124 ul = __sync_fetch_and_or (&ul, 11);
125105 sll = __sync_fetch_and_or (&sll, 11);
126106 ull = __sync_fetch_and_or (&ull, 11);
127107
131111 us = __sync_fetch_and_xor (&us, 11);
132112 si = __sync_fetch_and_xor (&si, 11);
133113 ui = __sync_fetch_and_xor (&ui, 11);
134 sl = __sync_fetch_and_xor (&sl, 11);
135 ul = __sync_fetch_and_xor (&ul, 11);
136114 sll = __sync_fetch_and_xor (&sll, 11);
137115 ull = __sync_fetch_and_xor (&ull, 11);
138116
142120 us = __sync_fetch_and_and (&us, 11);
143121 si = __sync_fetch_and_and (&si, 11);
144122 ui = __sync_fetch_and_and (&ui, 11);
145 sl = __sync_fetch_and_and (&sl, 11);
146 ul = __sync_fetch_and_and (&ul, 11);
147123 sll = __sync_fetch_and_and (&sll, 11);
148124 ull = __sync_fetch_and_and (&ull, 11);
149125
153129 us = __sync_fetch_and_nand (&us, 11);
154130 si = __sync_fetch_and_nand (&si, 11);
155131 ui = __sync_fetch_and_nand (&ui, 11);
156 sl = __sync_fetch_and_nand (&sl, 11);
157 ul = __sync_fetch_and_nand (&ul, 11);
158132 sll = __sync_fetch_and_nand (&sll, 11);
159133 ull = __sync_fetch_and_nand (&ull, 11);
160134 }
167141 us = __sync_add_and_fetch (&us, uc);
168142 si = __sync_add_and_fetch (&si, uc);
169143 ui = __sync_add_and_fetch (&ui, uc);
170 sl = __sync_add_and_fetch (&sl, uc);
171 ul = __sync_add_and_fetch (&ul, uc);
172144 sll = __sync_add_and_fetch (&sll, uc);
173145 ull = __sync_add_and_fetch (&ull, uc);
174146
178150 us = __sync_sub_and_fetch (&us, uc);
179151 si = __sync_sub_and_fetch (&si, uc);
180152 ui = __sync_sub_and_fetch (&ui, uc);
181 sl = __sync_sub_and_fetch (&sl, uc);
182 ul = __sync_sub_and_fetch (&ul, uc);
183153 sll = __sync_sub_and_fetch (&sll, uc);
184154 ull = __sync_sub_and_fetch (&ull, uc);
185155
189159 us = __sync_or_and_fetch (&us, uc);
190160 si = __sync_or_and_fetch (&si, uc);
191161 ui = __sync_or_and_fetch (&ui, uc);
192 sl = __sync_or_and_fetch (&sl, uc);
193 ul = __sync_or_and_fetch (&ul, uc);
194162 sll = __sync_or_and_fetch (&sll, uc);
195163 ull = __sync_or_and_fetch (&ull, uc);
196164
200168 us = __sync_xor_and_fetch (&us, uc);
201169 si = __sync_xor_and_fetch (&si, uc);
202170 ui = __sync_xor_and_fetch (&ui, uc);
203 sl = __sync_xor_and_fetch (&sl, uc);
204 ul = __sync_xor_and_fetch (&ul, uc);
205171 sll = __sync_xor_and_fetch (&sll, uc);
206172 ull = __sync_xor_and_fetch (&ull, uc);
207173
211177 us = __sync_and_and_fetch (&us, uc);
212178 si = __sync_and_and_fetch (&si, uc);
213179 ui = __sync_and_and_fetch (&ui, uc);
214 sl = __sync_and_and_fetch (&sl, uc);
215 ul = __sync_and_and_fetch (&ul, uc);
216180 sll = __sync_and_and_fetch (&sll, uc);
217181 ull = __sync_and_and_fetch (&ull, uc);
218182
222186 us = __sync_nand_and_fetch (&us, uc);
223187 si = __sync_nand_and_fetch (&si, uc);
224188 ui = __sync_nand_and_fetch (&ui, uc);
225 sl = __sync_nand_and_fetch (&sl, uc);
226 ul = __sync_nand_and_fetch (&ul, uc);
227189 sll = __sync_nand_and_fetch (&sll, uc);
228190 ull = __sync_nand_and_fetch (&ull, uc);
229191 }
236198 us = __sync_val_compare_and_swap (&us, uc, sc);
237199 si = __sync_val_compare_and_swap (&si, uc, sc);
238200 ui = __sync_val_compare_and_swap (&ui, uc, sc);
239 sl = __sync_val_compare_and_swap (&sl, uc, sc);
240 ul = __sync_val_compare_and_swap (&ul, uc, sc);
241201 sll = __sync_val_compare_and_swap (&sll, uc, sc);
242202 ull = __sync_val_compare_and_swap (&ull, uc, sc);
243203
247207 ui = __sync_bool_compare_and_swap (&us, uc, sc);
248208 ui = __sync_bool_compare_and_swap (&si, uc, sc);
249209 ui = __sync_bool_compare_and_swap (&ui, uc, sc);
250 ui = __sync_bool_compare_and_swap (&sl, uc, sc);
251 ui = __sync_bool_compare_and_swap (&ul, uc, sc);
252210 ui = __sync_bool_compare_and_swap (&sll, uc, sc);
253211 ui = __sync_bool_compare_and_swap (&ull, uc, sc);
254212 }
261219 us = __sync_lock_test_and_set (&us, 1);
262220 si = __sync_lock_test_and_set (&si, 1);
263221 ui = __sync_lock_test_and_set (&ui, 1);
264 sl = __sync_lock_test_and_set (&sl, 1);
265 ul = __sync_lock_test_and_set (&ul, 1);
266222 sll = __sync_lock_test_and_set (&sll, 1);
267223 ull = __sync_lock_test_and_set (&ull, 1);
268224
274230 __sync_lock_release (&us);
275231 __sync_lock_release (&si);
276232 __sync_lock_release (&ui);
277 __sync_lock_release (&sl);
278 __sync_lock_release (&ul);
279233 __sync_lock_release (&sll);
280234 __sync_lock_release (&ull);
281235 }