1 /* This file is used by test-combination.c and test-threads.c to
2 bring all of the non-failing test cases into one source file,
3 renaming each "create_code" and "verify_code" hook so that they
4 each have unique name. */
5
6 /* Include various other test cases, defining COMBINED_TEST so that
7 harness.h doesn't duplicate copes of e.g. main, and renaming the
8 hooks provided by each test case. */
9 #define COMBINED_TEST
10
11 /* test-accessing-bitfield.c */
12 #define create_code create_code_accessing_bitfield
13 #define verify_code verify_code_accessing_bitfield
14 #include "test-accessing-bitfield.c"
15 #undef create_code
16 #undef verify_code
17
18 /* test-accessing-struct.c */
19 #define create_code create_code_accessing_struct
20 #define verify_code verify_code_accessing_struct
21 #include "test-accessing-struct.c"
22 #undef create_code
23 #undef verify_code
24
25 /* test-accessing-union.c */
26 #define create_code create_code_accessing_union
27 #define verify_code verify_code_accessing_union
28 #include "test-accessing-union.c"
29 #undef create_code
30 #undef verify_code
31
32 /* test-add-driver-options.c: We don't use this one, since the extra options
33 affect the whole context. */
34
35 /* test-alignment.c */
36 #define create_code create_code_alignment
37 #define verify_code verify_code_alignment
38 #include "test-alignment.c"
39 #undef create_code
40 #undef verify_code
41
42 /* test-arith-overflow.c */
43 #define create_code create_code_arith_overflow
44 #define verify_code verify_code_arith_overflow
45 #include "test-arith-overflow.c"
46 #undef create_code
47 #undef verify_code
48
49 /* test-array-as-pointer.c */
50 #define create_code create_code_array_as_pointer
51 #define verify_code verify_code_array_as_pointer
52 #include "test-array-as-pointer.c"
53 #undef create_code
54 #undef verify_code
55
56 /* test-arrays.c */
57 #define create_code create_code_arrays
58 #define verify_code verify_code_arrays
59 #include "test-arrays.c"
60 #undef create_code
61 #undef verify_code
62
63 /* test-autovectorize.c */
64 #define create_code create_code_autovectorize
65 #define verify_code verify_code_autovectorize
66 #include "test-autovectorize.c"
67 #undef create_code
68 #undef verify_code
69
70 /* test-builtin-memcpy.c */
71 #define create_code create_code_builtin_memcpy
72 #define verify_code verify_code_builtin_memcpy
73 #include "test-builtin-memcpy.c"
74 #undef create_code
75 #undef verify_code
76
77 /* test-builtin-unreachable.c: We don't add this one, since it touches
78 the optimization level of the context as a whole. */
79
80 /* test-bitcast.c */
81 #define create_code create_code_bitcast
82 #define verify_code verify_code_bitcast
83 #include "test-bitcast.c"
84 #undef create_code
85 #undef verify_code
86
87 /* test-calling-external-function.c */
88 #define create_code create_code_calling_external_function
89 #define verify_code verify_code_calling_external_function
90 #include "test-calling-external-function.c"
91 #undef create_code
92 #undef verify_code
93
94 /* test-calling-function-ptr.c */
95 #define create_code create_code_calling_function_ptr
96 #define verify_code verify_code_calling_function_ptr
97 #include "test-calling-function-ptr.c"
98 #undef create_code
99 #undef verify_code
100
101 /* test-returning-function-ptr.c */
102 #define create_code create_code_calling_internal_function
103 #define verify_code verify_code_calling_internal_function
104 #include "test-returning-function-ptr.c"
105 #undef create_code
106 #undef verify_code
107
108 /* test-cast.c */
109 #define create_code create_code_cast
110 #define verify_code verify_code_cast
111 #include "test-cast.c"
112 #undef create_code
113 #undef verify_code
114
115 /* test-compound-assignment.c */
116 #define create_code create_code_compound_assignment
117 #define verify_code verify_code_compound_assignment
118 #include "test-compound-assignment.c"
119 #undef create_code
120 #undef verify_code
121
122 /* test-constants.c */
123 #define create_code create_code_constants
124 #define verify_code verify_code_constants
125 #include "test-constants.c"
126 #undef create_code
127 #undef verify_code
128
129 /* test-debug-strings.c */
130 #define create_code create_code_debug_strings
131 #define verify_code verify_code_debug_strings
132 #include "test-debug-strings.c"
133 #undef create_code
134 #undef verify_code
135
136 /* test-dot-product.c */
137 #define create_code create_code_dot_product
138 #define verify_code verify_code_dot_product
139 #include "test-dot-product.c"
140 #undef create_code
141 #undef verify_code
142
143 /* test-empty.c */
144 #define create_code create_code_empty
145 #define verify_code verify_code_empty
146 #include "test-empty.c"
147 #undef create_code
148 #undef verify_code
149
150 /* test-error-*.c: We don't use these test cases, since they deliberately
151 introduce errors, which we don't want here. */
152
153 /* test-expressions.c */
154 #define create_code create_code_expressions
155 #define verify_code verify_code_expressions
156 #include "test-expressions.c"
157 #undef create_code
158 #undef verify_code
159
160 /* test-extra-options.c: We don't use this one, since the extra options
161 affect the whole context. */
162
163 /* test-factorial.c */
164 #define create_code create_code_factorial
165 #define verify_code verify_code_factorial
166 #include "test-factorial.c"
167 #undef create_code
168 #undef verify_code
169
170 /* test-factorial-must-tail-call.c */
171 #define create_code create_code_factorial_must_tail_call
172 #define verify_code verify_code_factorial_must_tail_call
173 #include "test-factorial-must-tail-call.c"
174 #undef create_code
175 #undef verify_code
176
177 /* test-fibonacci.c */
178 #define create_code create_code_fibonacci
179 #define verify_code verify_code_fibonacci
180 #include "test-fibonacci.c"
181 #undef create_code
182 #undef verify_code
183
184 /* test-functions.c */
185 #define create_code create_code_functions
186 #define verify_code verify_code_functions
187 #include "test-functions.c"
188 #undef create_code
189 #undef verify_code
190
191 /* test-global-init-rvalue.c */
192 #define create_code create_code_global_init_rvalue
193 #define verify_code verify_code_global_init_rvalue
194 #include "test-global-init-rvalue.c"
195 #undef create_code
196 #undef verify_code
197
198 /* test-global-set-initializer.c */
199 #define create_code create_code_global_set_initializer
200 #define verify_code verify_code_global_set_initializer
201 #include "test-global-set-initializer.c"
202 #undef create_code
203 #undef verify_code
204
205 /* test-builtin-types.c */
206 #define create_code create_code_builtin_types
207 #define verify_code verify_code_builtin_types
208 #include "test-builtin-types.c"
209 #undef create_code
210 #undef verify_code
211
212 /* test-tls.c */
213 #define create_code create_code_tls
214 #define verify_code verify_code_tls
215 #include "test-tls.c"
216 #undef create_code
217 #undef verify_code
218
219 /* test-hello-world.c */
220 #define create_code create_code_hello_world
221 #define verify_code verify_code_hello_world
222 #include "test-hello-world.c"
223 #undef create_code
224 #undef verify_code
225
226 /* test-link-section-assembler.c: This can't be in the testcases array as it
227 doesn't have a verify_code implementation. */
228
229 /* test-linked-list.c */
230 #define create_code create_code_linked_list
231 #define verify_code verify_code_linked_list
232 #include "test-linked-list.c"
233 #undef create_code
234 #undef verify_code
235
236 /* test-local-init-rvalue.c */
237 #define create_code create_code_local_init_rvalue
238 #define verify_code verify_code_local_init_rvalue
239 #include "test-local-init-rvalue.c"
240 #undef create_code
241 #undef verify_code
242
243 /* test-long-names.c */
244 #define create_code create_code_long_names
245 #define verify_code verify_code_long_names
246 #include "test-long-names.c"
247 #undef create_code
248 #undef verify_code
249
250 /* test-long-string-literal.c */
251 #define create_code create_code_long_string_literal
252 #define verify_code verify_code_long_string_literal
253 #include "test-long-string-literal.c"
254 #undef create_code
255 #undef verify_code
256
257 /* test-quadratic.c */
258 #define create_code create_code_quadratic
259 #define verify_code verify_code_quadratic
260 #include "test-quadratic.c"
261 #undef create_code
262 #undef verify_code
263
264 /* test-nested-loops.c */
265 #define create_code create_code_nested_loop
266 #define verify_code verify_code_nested_loop
267 #include "test-nested-loops.c"
268 #undef create_code
269 #undef verify_code
270
271 /* test-pr103562.c: We don't add this one, since it touches
272 the optimization level of the context as a whole. */
273
274 /* test-pr66700-observing-write-through-ptr.c */
275 #define create_code create_code_pr66700_observing_write_through_ptr
276 #define verify_code verify_code_pr66700_observing_write_through_ptr
277 #include "test-pr66700-observing-write-through-ptr.c"
278 #undef create_code
279 #undef verify_code
280
281 /* test-pr66779.c */
282 #define create_code create_code_pr66779
283 #define verify_code verify_code_pr66779
284 #include "test-pr66779.c"
285 #undef create_code
286 #undef verify_code
287
288 /* test-pr95306-builtin-types.c. */
289 #define create_code create_code_pr95306_builtin_types
290 #define verify_code verify_code_pr95306_builtin_types
291 #include "test-pr95306-builtin-types.c"
292 #undef create_code
293 #undef verify_code
294
295 /* test-pr95314-rvalue-reuse.c. */
296 #define create_code create_code_pr95314_rvalue_reuse
297 #define verify_code verify_code_pr95314_rvalue_reuse
298 #include "test-pr95314-rvalue-reuse.c"
299 #undef create_code
300 #undef verify_code
301
302 /* test-reading-struct.c */
303 #define create_code create_code_reading_struct
304 #define verify_code verify_code_reading_struct
305 #include "test-reading-struct.c"
306 #undef create_code
307 #undef verify_code
308
309 /* test-reflection.c */
310 #define create_code create_code_reflection
311 #define verify_code verify_code_reflection
312 #include "test-reflection.c"
313 #undef create_code
314 #undef verify_code
315
316 /* test-register-variable.c: This can't be in the testcases array as it
317 is target-specific. */
318
319 /* test-setting-alignment.c: This can't be in the testcases array as it
320 is target-specific. */
321
322 /* test-string-literal.c */
323 #define create_code create_code_string_literal
324 #define verify_code verify_code_string_literal
325 #include "test-string-literal.c"
326 #undef create_code
327 #undef verify_code
328
329 /* test-sum-of-squares.c */
330 #define create_code create_code_sum_of_squares
331 #define verify_code verify_code_sum_of_squares
332 #include "test-sum-of-squares.c"
333 #undef create_code
334 #undef verify_code
335
336 /* test-switch.c */
337 #define create_code create_code_switch
338 #define verify_code verify_code_switch
339 #include "test-switch.c"
340 #undef create_code
341 #undef verify_code
342
343 /* test-types.c */
344 #define create_code create_code_types
345 #define verify_code verify_code_types
346 #include "test-types.c"
347 #undef create_code
348 #undef verify_code
349
350 /* test-using-global.c */
351 #define create_code create_code_using_global
352 #define verify_code verify_code_using_global
353 #include "test-using-global.c"
354 #undef create_code
355 #undef verify_code
356
357 /* test-validly-unreachable-block.c: We don't use this one, since the use
358 of gcc_jit_context_set_bool_allow_unreachable_blocks affects the whole
359 context. */
360
361 /* test-vector-types.cc: We don't use this, since it's C++. */
362
363 /* test-version.c */
364 #define create_code create_code_version
365 #define verify_code verify_code_version
366 #include "test-version.c"
367 #undef create_code
368 #undef verify_code
369
370 /* test-volatile.c */
371 #define create_code create_code_volatile
372 #define verify_code verify_code_volatile
373 #include "test-volatile.c"
374 #undef create_code
375 #undef verify_code
376
377 /* Now expose the individual testcases as instances of this struct. */
378
379 struct testcase
380 {
381 const char *m_name;
382 void (*m_hook_to_create_code) (gcc_jit_context *ctxt,
383 void * user_data);
384 void (*m_hook_to_verify_code) (gcc_jit_context *ctxt,
385 gcc_jit_result *result);
386 };
387
388 const struct testcase testcases[] = {
389 {"accessing_bitfield",
390 create_code_accessing_bitfield,
391 verify_code_accessing_bitfield},
392 {"accessing_struct",
393 create_code_accessing_struct,
394 verify_code_accessing_struct},
395 {"accessing_union",
396 create_code_accessing_union,
397 verify_code_accessing_union},
398 {"alignment",
399 create_code_alignment,
400 verify_code_alignment},
401 {"arith_overflow",
402 create_code_arith_overflow,
403 verify_code_arith_overflow},
404 {"array_as_pointer",
405 create_code_array_as_pointer,
406 verify_code_array_as_pointer},
407 {"arrays",
408 create_code_arrays,
409 verify_code_arrays},
410 {"autovectorize",
411 create_code_autovectorize,
412 verify_code_autovectorize},
413 {"builtin-memcpy",
414 create_code_builtin_memcpy,
415 verify_code_builtin_memcpy},
416 {"bitcast",
417 create_code_bitcast,
418 verify_code_bitcast},
419 {"calling_external_function",
420 create_code_calling_external_function,
421 verify_code_calling_external_function},
422 {"calling_function_ptr",
423 create_code_calling_function_ptr,
424 verify_code_calling_function_ptr},
425 {"calling_internal_function",
426 create_code_calling_internal_function,
427 verify_code_calling_internal_function},
428 {"cast",
429 create_code_cast,
430 verify_code_cast},
431 {"compound_assignment",
432 create_code_compound_assignment,
433 verify_code_compound_assignment},
434 {"constants",
435 create_code_constants,
436 verify_code_constants},
437 {"debug_strings",
438 create_code_debug_strings,
439 verify_code_debug_strings},
440 {"dot_product",
441 create_code_dot_product,
442 verify_code_dot_product},
443 {"expressions",
444 create_code_expressions,
445 verify_code_expressions},
446 {"empty",
447 create_code_empty,
448 verify_code_empty},
449 {"factorial",
450 create_code_factorial,
451 verify_code_factorial},
452 {"factorial_must_tail_call",
453 create_code_factorial_must_tail_call,
454 verify_code_factorial_must_tail_call},
455 {"fibonacci",
456 create_code_fibonacci,
457 verify_code_fibonacci},
458 {"functions",
459 create_code_functions,
460 verify_code_functions},
461 {"builtin-types",
462 create_code_builtin_types,
463 verify_code_builtin_types},
464 {"global_rvalue_init",
465 create_code_global_init_rvalue,
466 verify_code_global_init_rvalue},
467 {"hello_world",
468 create_code_hello_world,
469 verify_code_hello_world},
470 {"linked_list",
471 create_code_linked_list,
472 verify_code_linked_list},
473 {"local_rvalue_init",
474 create_code_local_init_rvalue,
475 verify_code_local_init_rvalue},
476 {"long_names",
477 create_code_long_names,
478 verify_code_long_names},
479 {"long_string_literal",
480 create_code_long_string_literal,
481 verify_code_long_string_literal},
482 {"quadratic",
483 create_code_quadratic,
484 verify_code_quadratic},
485 {"nested_loop",
486 create_code_nested_loop,
487 verify_code_nested_loop},
488 {"pr66700_observing_write_through_ptr",
489 create_code_pr66700_observing_write_through_ptr,
490 verify_code_pr66700_observing_write_through_ptr},
491 {"pr66779",
492 create_code_pr66779,
493 verify_code_pr66779},
494 {"pr95306_builtin_types",
495 create_code_pr95306_builtin_types,
496 verify_code_pr95306_builtin_types},
497 {"pr95314_rvalue_reuse",
498 create_code_pr95314_rvalue_reuse,
499 verify_code_pr95314_rvalue_reuse},
500 {"reading_struct ",
501 create_code_reading_struct ,
502 verify_code_reading_struct },
503 {"reflection",
504 create_code_reflection ,
505 verify_code_reflection },
506 {"string_literal",
507 create_code_string_literal,
508 verify_code_string_literal},
509 {"sum_of_squares",
510 create_code_sum_of_squares,
511 verify_code_sum_of_squares},
512 {"switch",
513 create_code_switch,
514 verify_code_switch},
515 {"tls",
516 create_code_tls,
517 verify_code_tls},
518 {"types",
519 create_code_types,
520 verify_code_types},
521 {"using_global",
522 create_code_using_global,
523 verify_code_using_global},
524 {"version",
525 create_code_version,
526 verify_code_version},
527 {"volatile",
528 create_code_volatile,
529 verify_code_volatile}
530 };
531
532 const int num_testcases = (sizeof (testcases) / sizeof (testcases[0]));