target-supports.exp (force_conventional_output_for): New procedure.
[gcc.git] / gcc / testsuite / lib / target-supports.exp
1 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile the code given by CONTENTS into an output file of
23 # type TYPE, where TYPE is as for target_compile. Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the name of the output file.
26 #
27 # BASENAME is a prefix to use for source and output files.
28 # If ARGS is not empty, its first element is a string that
29 # should be added to the command line.
30 #
31 # Assume by default that CONTENTS is C code.
32 # Otherwise, code should contain:
33 # "// C++" for c++,
34 # "! Fortran" for Fortran code,
35 # "/* ObjC", for ObjC
36 # "// ObjC++" for ObjC++
37 # and "// Go" for Go
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
43
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
46 } else {
47 set options ""
48 }
49 switch -glob -- $contents {
50 "*! Fortran*" { set src ${basename}[pid].f90 }
51 "*// C++*" { set src ${basename}[pid].cc }
52 "*// ObjC++*" { set src ${basename}[pid].mm }
53 "*/* ObjC*" { set src ${basename}[pid].m }
54 "*// Go*" { set src ${basename}[pid].go }
55 default {
56 switch -- $tool {
57 "objc" { set src ${basename}[pid].m }
58 "obj-c++" { set src ${basename}[pid].mm }
59 default { set src ${basename}[pid].c }
60 }
61 }
62 }
63
64 set compile_type $type
65 switch -glob $type {
66 assembly { set output ${basename}[pid].s }
67 object { set output ${basename}[pid].o }
68 executable { set output ${basename}[pid].exe }
69 "rtl-*" {
70 set output ${basename}[pid].s
71 lappend options "additional_flags=-fdump-$type"
72 set compile_type assembly
73 }
74 }
75 set f [open $src "w"]
76 puts $f $contents
77 close $f
78 set lines [${tool}_target_compile $src $output $compile_type "$options"]
79 file delete $src
80
81 set scan_output $output
82 # Don't try folding this into the switch above; calling "glob" before the
83 # file is created won't work.
84 if [regexp "rtl-(.*)" $type dummy rtl_type] {
85 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
86 file delete $output
87 }
88
89 return [list $lines $scan_output]
90 }
91
92 proc current_target_name { } {
93 global target_info
94 if [info exists target_info(target,name)] {
95 set answer $target_info(target,name)
96 } else {
97 set answer ""
98 }
99 return $answer
100 }
101
102 # Implement an effective-target check for property PROP by invoking
103 # the Tcl command ARGS and seeing if it returns true.
104
105 proc check_cached_effective_target { prop args } {
106 global et_cache
107
108 set target [current_target_name]
109 if {![info exists et_cache($prop,target)]
110 || $et_cache($prop,target) != $target} {
111 verbose "check_cached_effective_target $prop: checking $target" 2
112 set et_cache($prop,target) $target
113 set et_cache($prop,value) [uplevel eval $args]
114 }
115 set value $et_cache($prop,value)
116 verbose "check_cached_effective_target $prop: returning $value for $target" 2
117 return $value
118 }
119
120 # Like check_compile, but delete the output file and return true if the
121 # compiler printed no messages.
122 proc check_no_compiler_messages_nocache {args} {
123 set result [eval check_compile $args]
124 set lines [lindex $result 0]
125 set output [lindex $result 1]
126 remote_file build delete $output
127 return [string match "" $lines]
128 }
129
130 # Like check_no_compiler_messages_nocache, but cache the result.
131 # PROP is the property we're checking, and doubles as a prefix for
132 # temporary filenames.
133 proc check_no_compiler_messages {prop args} {
134 return [check_cached_effective_target $prop {
135 eval [list check_no_compiler_messages_nocache $prop] $args
136 }]
137 }
138
139 # Like check_compile, but return true if the compiler printed no
140 # messages and if the contents of the output file satisfy PATTERN.
141 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
142 # don't match regular expression REGEXP, otherwise they satisfy it
143 # if they do match regular expression PATTERN. (PATTERN can start
144 # with something like "[!]" if the regular expression needs to match
145 # "!" as the first character.)
146 #
147 # Delete the output file before returning. The other arguments are
148 # as for check_compile.
149 proc check_no_messages_and_pattern_nocache {basename pattern args} {
150 global tool
151
152 set result [eval [list check_compile $basename] $args]
153 set lines [lindex $result 0]
154 set output [lindex $result 1]
155
156 set ok 0
157 if { [string match "" $lines] } {
158 set chan [open "$output"]
159 set invert [regexp {^!(.*)} $pattern dummy pattern]
160 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
161 close $chan
162 }
163
164 remote_file build delete $output
165 return $ok
166 }
167
168 # Like check_no_messages_and_pattern_nocache, but cache the result.
169 # PROP is the property we're checking, and doubles as a prefix for
170 # temporary filenames.
171 proc check_no_messages_and_pattern {prop pattern args} {
172 return [check_cached_effective_target $prop {
173 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
174 }]
175 }
176
177 # Try to compile and run an executable from code CONTENTS. Return true
178 # if the compiler reports no messages and if execution "passes" in the
179 # usual DejaGNU sense. The arguments are as for check_compile, with
180 # TYPE implicitly being "executable".
181 proc check_runtime_nocache {basename contents args} {
182 global tool
183
184 set result [eval [list check_compile $basename executable $contents] $args]
185 set lines [lindex $result 0]
186 set output [lindex $result 1]
187
188 set ok 0
189 if { [string match "" $lines] } {
190 # No error messages, everything is OK.
191 set result [remote_load target "./$output" "" ""]
192 set status [lindex $result 0]
193 verbose "check_runtime_nocache $basename: status is <$status>" 2
194 if { $status == "pass" } {
195 set ok 1
196 }
197 }
198 remote_file build delete $output
199 return $ok
200 }
201
202 # Like check_runtime_nocache, but cache the result. PROP is the
203 # property we're checking, and doubles as a prefix for temporary
204 # filenames.
205 proc check_runtime {prop args} {
206 global tool
207
208 return [check_cached_effective_target $prop {
209 eval [list check_runtime_nocache $prop] $args
210 }]
211 }
212
213 ###############################
214 # proc check_weak_available { }
215 ###############################
216
217 # weak symbols are only supported in some configs/object formats
218 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
219
220 proc check_weak_available { } {
221 global target_cpu
222
223 # All mips targets should support it
224
225 if { [ string first "mips" $target_cpu ] >= 0 } {
226 return 1
227 }
228
229 # All AIX targets should support it
230
231 if { [istarget *-*-aix*] } {
232 return 1
233 }
234
235 # All solaris2 targets should support it
236
237 if { [istarget *-*-solaris2*] } {
238 return 1
239 }
240
241 # Windows targets Cygwin and MingW32 support it
242
243 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
244 return 1
245 }
246
247 # HP-UX 10.X doesn't support it
248
249 if { [istarget hppa*-*-hpux10*] } {
250 return 0
251 }
252
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
255
256 set objformat [gcc_target_object_format]
257
258 switch $objformat {
259 elf { return 1 }
260 ecoff { return 1 }
261 a.out { return 1 }
262 mach-o { return 1 }
263 som { return 1 }
264 unknown { return -1 }
265 default { return 0 }
266 }
267 }
268
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
272
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
275
276 proc check_weak_override_available { } {
277 if { [istarget *-*-mingw*] } {
278 return 0
279 }
280 return [check_weak_available]
281 }
282
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
286
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
290
291 proc check_visibility_available { what_kind } {
292 if [string match "" $what_kind] { set what_kind "hidden" }
293
294 return [check_no_compiler_messages visibility_available_$what_kind object "
295 void f() __attribute__((visibility(\"$what_kind\")));
296 void f() {}
297 "]
298 }
299
300 ###############################
301 # proc check_alias_available { }
302 ###############################
303
304 # Determine if the target toolchain supports the alias attribute.
305
306 # Returns 2 if the target supports aliases. Returns 1 if the target
307 # only supports weak aliased. Returns 0 if the target does not
308 # support aliases at all. Returns -1 if support for aliases could not
309 # be determined.
310
311 proc check_alias_available { } {
312 global alias_available_saved
313 global tool
314
315 if [info exists alias_available_saved] {
316 verbose "check_alias_available returning saved $alias_available_saved" 2
317 } else {
318 set src alias[pid].c
319 set obj alias[pid].o
320 verbose "check_alias_available compiling testfile $src" 2
321 set f [open $src "w"]
322 # Compile a small test program. The definition of "g" is
323 # necessary to keep the Solaris assembler from complaining
324 # about the program.
325 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
326 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
327 close $f
328 set lines [${tool}_target_compile $src $obj object ""]
329 file delete $src
330 remote_file build delete $obj
331
332 if [string match "" $lines] then {
333 # No error messages, everything is OK.
334 set alias_available_saved 2
335 } else {
336 if [regexp "alias definitions not supported" $lines] {
337 verbose "check_alias_available target does not support aliases" 2
338
339 set objformat [gcc_target_object_format]
340
341 if { $objformat == "elf" } {
342 verbose "check_alias_available but target uses ELF format, so it ought to" 2
343 set alias_available_saved -1
344 } else {
345 set alias_available_saved 0
346 }
347 } else {
348 if [regexp "only weak aliases are supported" $lines] {
349 verbose "check_alias_available target supports only weak aliases" 2
350 set alias_available_saved 1
351 } else {
352 set alias_available_saved -1
353 }
354 }
355 }
356
357 verbose "check_alias_available returning $alias_available_saved" 2
358 }
359
360 return $alias_available_saved
361 }
362
363 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
364
365 proc check_effective_target_alias { } {
366 if { [check_alias_available] < 2 } {
367 return 0
368 } else {
369 return 1
370 }
371 }
372
373 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
374
375 proc check_ifunc_available { } {
376 return [check_no_compiler_messages ifunc_available object {
377 #ifdef __cplusplus
378 extern "C"
379 #endif
380 void g() {}
381 void f() __attribute__((ifunc("g")));
382 }]
383 }
384
385 # Returns true if --gc-sections is supported on the target.
386
387 proc check_gc_sections_available { } {
388 global gc_sections_available_saved
389 global tool
390
391 if {![info exists gc_sections_available_saved]} {
392 # Some targets don't support gc-sections despite whatever's
393 # advertised by ld's options.
394 if { [istarget alpha*-*-*]
395 || [istarget ia64-*-*] } {
396 set gc_sections_available_saved 0
397 return 0
398 }
399
400 # elf2flt uses -q (--emit-relocs), which is incompatible with
401 # --gc-sections.
402 if { [board_info target exists ldflags]
403 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
404 set gc_sections_available_saved 0
405 return 0
406 }
407
408 # VxWorks kernel modules are relocatable objects linked with -r,
409 # while RTP executables are linked with -q (--emit-relocs).
410 # Both of these options are incompatible with --gc-sections.
411 if { [istarget *-*-vxworks*] } {
412 set gc_sections_available_saved 0
413 return 0
414 }
415
416 # Check if the ld used by gcc supports --gc-sections.
417 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
418 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
419 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
420 set ld_output [remote_exec host "$gcc_ld" "--help"]
421 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
422 set gc_sections_available_saved 1
423 } else {
424 set gc_sections_available_saved 0
425 }
426 }
427 return $gc_sections_available_saved
428 }
429
430 # Return 1 if according to target_info struct and explicit target list
431 # target is supposed to support trampolines.
432
433 proc check_effective_target_trampolines { } {
434 if [target_info exists no_trampolines] {
435 return 0
436 }
437 if { [istarget avr-*-*]
438 || [istarget msp430-*-*]
439 || [istarget hppa2.0w-hp-hpux11.23]
440 || [istarget hppa64-hp-hpux11.23] } {
441 return 0;
442 }
443 return 1
444 }
445
446 # Return 1 if according to target_info struct and explicit target list
447 # target is supposed to keep null pointer checks. This could be due to
448 # use of option fno-delete-null-pointer-checks or hardwired in target.
449
450 proc check_effective_target_keeps_null_pointer_checks { } {
451 if [target_info exists keeps_null_pointer_checks] {
452 return 1
453 }
454 if { [istarget avr-*-*] } {
455 return 1;
456 }
457 return 0
458 }
459
460 # Return true if profiling is supported on the target.
461
462 proc check_profiling_available { test_what } {
463 global profiling_available_saved
464
465 verbose "Profiling argument is <$test_what>" 1
466
467 # These conditions depend on the argument so examine them before
468 # looking at the cache variable.
469
470 # Tree profiling requires TLS runtime support.
471 if { $test_what == "-fprofile-generate" } {
472 if { ![check_effective_target_tls_runtime] } {
473 return 0
474 }
475 }
476
477 # Support for -p on solaris2 relies on mcrt1.o which comes with the
478 # vendor compiler. We cannot reliably predict the directory where the
479 # vendor compiler (and thus mcrt1.o) is installed so we can't
480 # necessarily find mcrt1.o even if we have it.
481 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
482 return 0
483 }
484
485 # We don't yet support profiling for MIPS16.
486 if { [istarget mips*-*-*]
487 && ![check_effective_target_nomips16]
488 && ($test_what == "-p" || $test_what == "-pg") } {
489 return 0
490 }
491
492 # MinGW does not support -p.
493 if { [istarget *-*-mingw*] && $test_what == "-p" } {
494 return 0
495 }
496
497 # cygwin does not support -p.
498 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
499 return 0
500 }
501
502 # uClibc does not have gcrt1.o.
503 if { [check_effective_target_uclibc]
504 && ($test_what == "-p" || $test_what == "-pg") } {
505 return 0
506 }
507
508 # Now examine the cache variable.
509 if {![info exists profiling_available_saved]} {
510 # Some targets don't have any implementation of __bb_init_func or are
511 # missing other needed machinery.
512 if { [istarget aarch64*-*-elf]
513 || [istarget am3*-*-linux*]
514 || [istarget arm*-*-eabi*]
515 || [istarget arm*-*-elf]
516 || [istarget arm*-*-symbianelf*]
517 || [istarget avr-*-*]
518 || [istarget bfin-*-*]
519 || [istarget cris-*-*]
520 || [istarget crisv32-*-*]
521 || [istarget fido-*-elf]
522 || [istarget h8300-*-*]
523 || [istarget lm32-*-*]
524 || [istarget m32c-*-elf]
525 || [istarget m68k-*-elf]
526 || [istarget m68k-*-uclinux*]
527 || [istarget mep-*-elf]
528 || [istarget mips*-*-elf*]
529 || [istarget mmix-*-*]
530 || [istarget mn10300-*-elf*]
531 || [istarget moxie-*-elf*]
532 || [istarget msp430-*-*]
533 || [istarget nds32*-*-elf]
534 || [istarget nios2-*-elf]
535 || [istarget picochip-*-*]
536 || [istarget powerpc-*-eabi*]
537 || [istarget powerpc-*-elf]
538 || [istarget rx-*-*]
539 || [istarget tic6x-*-elf]
540 || [istarget xstormy16-*]
541 || [istarget xtensa*-*-elf]
542 || [istarget *-*-rtems*]
543 || [istarget *-*-vxworks*] } {
544 set profiling_available_saved 0
545 } else {
546 set profiling_available_saved 1
547 }
548 }
549
550 return $profiling_available_saved
551 }
552
553 # Check to see if a target is "freestanding". This is as per the definition
554 # in Section 4 of C99 standard. Effectively, it is a target which supports no
555 # extra headers or libraries other than what is considered essential.
556 proc check_effective_target_freestanding { } {
557 if { [istarget picochip-*-*] } then {
558 return 1
559 } else {
560 return 0
561 }
562 }
563
564 # Return 1 if target has packed layout of structure members by
565 # default, 0 otherwise. Note that this is slightly different than
566 # whether the target has "natural alignment": both attributes may be
567 # false.
568
569 proc check_effective_target_default_packed { } {
570 return [check_no_compiler_messages default_packed assembly {
571 struct x { char a; long b; } c;
572 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
573 }]
574 }
575
576 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
577 # documentation, where the test also comes from.
578
579 proc check_effective_target_pcc_bitfield_type_matters { } {
580 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
581 # bitfields, but let's stick to the example code from the docs.
582 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
583 struct foo1 { char x; char :0; char y; };
584 struct foo2 { char x; int :0; char y; };
585 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
586 }]
587 }
588
589 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
590
591 proc add_options_for_tls { flags } {
592 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
593 # libthread, so always pass -pthread for native TLS. Same for AIX.
594 # Need to duplicate native TLS check from
595 # check_effective_target_tls_native to avoid recursion.
596 if { ([istarget *-*-solaris2.9*] || [istarget powerpc-ibm-aix*]) &&
597 [check_no_messages_and_pattern tls_native "!emutls" assembly {
598 __thread int i;
599 int f (void) { return i; }
600 void g (int j) { i = j; }
601 }] } {
602 return "$flags -pthread"
603 }
604 return $flags
605 }
606
607 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
608
609 proc check_effective_target_tls {} {
610 return [check_no_compiler_messages tls assembly {
611 __thread int i;
612 int f (void) { return i; }
613 void g (int j) { i = j; }
614 }]
615 }
616
617 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
618
619 proc check_effective_target_tls_native {} {
620 # VxWorks uses emulated TLS machinery, but with non-standard helper
621 # functions, so we fail to automatically detect it.
622 if { [istarget *-*-vxworks*] } {
623 return 0
624 }
625
626 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
627 __thread int i;
628 int f (void) { return i; }
629 void g (int j) { i = j; }
630 }]
631 }
632
633 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
634
635 proc check_effective_target_tls_emulated {} {
636 # VxWorks uses emulated TLS machinery, but with non-standard helper
637 # functions, so we fail to automatically detect it.
638 if { [istarget *-*-vxworks*] } {
639 return 1
640 }
641
642 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
643 __thread int i;
644 int f (void) { return i; }
645 void g (int j) { i = j; }
646 }]
647 }
648
649 # Return 1 if TLS executables can run correctly, 0 otherwise.
650
651 proc check_effective_target_tls_runtime {} {
652 # MSP430 runtime does not have TLS support, but just
653 # running the test below is insufficient to show this.
654 if { [istarget msp430-*-*] } {
655 return 0
656 }
657 return [check_runtime tls_runtime {
658 __thread int thr = 0;
659 int main (void) { return thr; }
660 } [add_options_for_tls ""]]
661 }
662
663 # Return 1 if atomic compare-and-swap is supported on 'int'
664
665 proc check_effective_target_cas_char {} {
666 return [check_no_compiler_messages cas_char assembly {
667 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
668 #error unsupported
669 #endif
670 } ""]
671 }
672
673 proc check_effective_target_cas_int {} {
674 return [check_no_compiler_messages cas_int assembly {
675 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
676 /* ok */
677 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
678 /* ok */
679 #else
680 #error unsupported
681 #endif
682 } ""]
683 }
684
685 # Return 1 if -ffunction-sections is supported, 0 otherwise.
686
687 proc check_effective_target_function_sections {} {
688 # Darwin has its own scheme and silently accepts -ffunction-sections.
689 if { [istarget *-*-darwin*] } {
690 return 0
691 }
692
693 return [check_no_compiler_messages functionsections assembly {
694 void foo (void) { }
695 } "-ffunction-sections"]
696 }
697
698 # Return 1 if instruction scheduling is available, 0 otherwise.
699
700 proc check_effective_target_scheduling {} {
701 return [check_no_compiler_messages scheduling object {
702 void foo (void) { }
703 } "-fschedule-insns"]
704 }
705
706 # Return 1 if trapping arithmetic is available, 0 otherwise.
707
708 proc check_effective_target_trapping {} {
709 return [check_no_compiler_messages scheduling object {
710 add (int a, int b) { return a + b; }
711 } "-ftrapv"]
712 }
713
714 # Return 1 if compilation with -fgraphite is error-free for trivial
715 # code, 0 otherwise.
716
717 proc check_effective_target_fgraphite {} {
718 return [check_no_compiler_messages fgraphite object {
719 void foo (void) { }
720 } "-O1 -fgraphite"]
721 }
722
723 # Return 1 if compilation with -fopenmp is error-free for trivial
724 # code, 0 otherwise.
725
726 proc check_effective_target_fopenmp {} {
727 return [check_no_compiler_messages fopenmp object {
728 void foo (void) { }
729 } "-fopenmp"]
730 }
731
732 # Return 1 if compilation with -fgnu-tm is error-free for trivial
733 # code, 0 otherwise.
734
735 proc check_effective_target_fgnu_tm {} {
736 return [check_no_compiler_messages fgnu_tm object {
737 void foo (void) { }
738 } "-fgnu-tm"]
739 }
740
741 # Return 1 if the target supports mmap, 0 otherwise.
742
743 proc check_effective_target_mmap {} {
744 return [check_function_available "mmap"]
745 }
746
747 # Return 1 if the target supports dlopen, 0 otherwise.
748 proc check_effective_target_dlopen {} {
749 return [check_function_available "dlopen"]
750 }
751
752 # Return 1 if the target supports clone, 0 otherwise.
753 proc check_effective_target_clone {} {
754 return [check_function_available "clone"]
755 }
756
757 # Return 1 if the target supports setrlimit, 0 otherwise.
758 proc check_effective_target_setrlimit {} {
759 # Darwin has non-posix compliant RLIMIT_AS
760 if { [istarget *-*-darwin*] } {
761 return 0
762 }
763 return [check_function_available "setrlimit"]
764 }
765
766 # Return 1 if the target supports swapcontext, 0 otherwise.
767 proc check_effective_target_swapcontext {} {
768 return [check_no_compiler_messages swapcontext executable {
769 #include <ucontext.h>
770 int main (void)
771 {
772 ucontext_t orig_context,child_context;
773 if (swapcontext(&child_context, &orig_context) < 0) { }
774 }
775 }]
776 }
777
778 # Return 1 if compilation with -pthread is error-free for trivial
779 # code, 0 otherwise.
780
781 proc check_effective_target_pthread {} {
782 return [check_no_compiler_messages pthread object {
783 void foo (void) { }
784 } "-pthread"]
785 }
786
787 # Return 1 if compilation with -mpe-aligned-commons is error-free
788 # for trivial code, 0 otherwise.
789
790 proc check_effective_target_pe_aligned_commons {} {
791 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
792 return [check_no_compiler_messages pe_aligned_commons object {
793 int foo;
794 } "-mpe-aligned-commons"]
795 }
796 return 0
797 }
798
799 # Return 1 if the target supports -static
800 proc check_effective_target_static {} {
801 return [check_no_compiler_messages static executable {
802 int main (void) { return 0; }
803 } "-static"]
804 }
805
806 # Return 1 if the target supports -fstack-protector
807 proc check_effective_target_fstack_protector {} {
808 return [check_runtime fstack_protector {
809 int main (void) { return 0; }
810 } "-fstack-protector"]
811 }
812
813 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
814 # for trivial code, 0 otherwise.
815
816 proc check_effective_target_freorder {} {
817 return [check_no_compiler_messages freorder object {
818 void foo (void) { }
819 } "-freorder-blocks-and-partition"]
820 }
821
822 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
823 # emitted, 0 otherwise. Whether a shared library can actually be built is
824 # out of scope for this test.
825
826 proc check_effective_target_fpic { } {
827 # Note that M68K has a multilib that supports -fpic but not
828 # -fPIC, so we need to check both. We test with a program that
829 # requires GOT references.
830 foreach arg {fpic fPIC} {
831 if [check_no_compiler_messages $arg object {
832 extern int foo (void); extern int bar;
833 int baz (void) { return foo () + bar; }
834 } "-$arg"] {
835 return 1
836 }
837 }
838 return 0
839 }
840
841 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
842
843 proc check_effective_target_pie { } {
844 if { [istarget *-*-darwin\[912\]*]
845 || [istarget *-*-linux*]
846 || [istarget *-*-gnu*] } {
847 return 1;
848 }
849 return 0
850 }
851
852 # Return true if the target supports -mpaired-single (as used on MIPS).
853
854 proc check_effective_target_mpaired_single { } {
855 return [check_no_compiler_messages mpaired_single object {
856 void foo (void) { }
857 } "-mpaired-single"]
858 }
859
860 # Return true if the target has access to FPU instructions.
861
862 proc check_effective_target_hard_float { } {
863 if { [istarget mips*-*-*] } {
864 return [check_no_compiler_messages hard_float assembly {
865 #if (defined __mips_soft_float || defined __mips16)
866 #error FOO
867 #endif
868 }]
869 }
870
871 # This proc is actually checking the availabilty of FPU
872 # support for doubles, so on the RX we must fail if the
873 # 64-bit double multilib has been selected.
874 if { [istarget rx-*-*] } {
875 return 0
876 # return [check_no_compiler_messages hard_float assembly {
877 #if defined __RX_64_BIT_DOUBLES__
878 #error FOO
879 #endif
880 # }]
881 }
882
883 # The generic test equates hard_float with "no call for adding doubles".
884 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
885 double a (double b, double c) { return b + c; }
886 }]
887 }
888
889 # Return true if the target is a 64-bit MIPS target.
890
891 proc check_effective_target_mips64 { } {
892 return [check_no_compiler_messages mips64 assembly {
893 #ifndef __mips64
894 #error FOO
895 #endif
896 }]
897 }
898
899 # Return true if the target is a MIPS target that does not produce
900 # MIPS16 code.
901
902 proc check_effective_target_nomips16 { } {
903 return [check_no_compiler_messages nomips16 object {
904 #ifndef __mips
905 #error FOO
906 #else
907 /* A cheap way of testing for -mflip-mips16. */
908 void foo (void) { asm ("addiu $20,$20,1"); }
909 void bar (void) { asm ("addiu $20,$20,1"); }
910 #endif
911 }]
912 }
913
914 # Add the options needed for MIPS16 function attributes. At the moment,
915 # we don't support MIPS16 PIC.
916
917 proc add_options_for_mips16_attribute { flags } {
918 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
919 }
920
921 # Return true if we can force a mode that allows MIPS16 code generation.
922 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
923 # for o32 and o64.
924
925 proc check_effective_target_mips16_attribute { } {
926 return [check_no_compiler_messages mips16_attribute assembly {
927 #ifdef PIC
928 #error FOO
929 #endif
930 #if defined __mips_hard_float \
931 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
932 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
933 #error FOO
934 #endif
935 } [add_options_for_mips16_attribute ""]]
936 }
937
938 # Return 1 if the target supports long double larger than double when
939 # using the new ABI, 0 otherwise.
940
941 proc check_effective_target_mips_newabi_large_long_double { } {
942 return [check_no_compiler_messages mips_newabi_large_long_double object {
943 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
944 } "-mabi=64"]
945 }
946
947 # Return true if the target is a MIPS target that has access
948 # to the LL and SC instructions.
949
950 proc check_effective_target_mips_llsc { } {
951 if { ![istarget mips*-*-*] } {
952 return 0
953 }
954 # Assume that these instructions are always implemented for
955 # non-elf* targets, via emulation if necessary.
956 if { ![istarget *-*-elf*] } {
957 return 1
958 }
959 # Otherwise assume LL/SC support for everything but MIPS I.
960 return [check_no_compiler_messages mips_llsc assembly {
961 #if __mips == 1
962 #error FOO
963 #endif
964 }]
965 }
966
967 # Return true if the target is a MIPS target that uses in-place relocations.
968
969 proc check_effective_target_mips_rel { } {
970 if { ![istarget mips*-*-*] } {
971 return 0
972 }
973 return [check_no_compiler_messages mips_rel object {
974 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
975 || (defined _ABI64 && _MIPS_SIM == _ABI64)
976 #error FOO
977 #endif
978 }]
979 }
980
981 # Return true if the target is a MIPS target that uses the EABI.
982
983 proc check_effective_target_mips_eabi { } {
984 if { ![istarget mips*-*-*] } {
985 return 0
986 }
987 return [check_no_compiler_messages mips_eabi object {
988 #ifndef __mips_eabi
989 #error FOO
990 #endif
991 }]
992 }
993
994 # Return 1 if the current multilib does not generate PIC by default.
995
996 proc check_effective_target_nonpic { } {
997 return [check_no_compiler_messages nonpic assembly {
998 #if __PIC__
999 #error FOO
1000 #endif
1001 }]
1002 }
1003
1004 # Return 1 if the target does not use a status wrapper.
1005
1006 proc check_effective_target_unwrapped { } {
1007 if { [target_info needs_status_wrapper] != "" \
1008 && [target_info needs_status_wrapper] != "0" } {
1009 return 0
1010 }
1011 return 1
1012 }
1013
1014 # Return true if iconv is supported on the target. In particular IBM1047.
1015
1016 proc check_iconv_available { test_what } {
1017 global libiconv
1018
1019 # If the tool configuration file has not set libiconv, try "-liconv"
1020 if { ![info exists libiconv] } {
1021 set libiconv "-liconv"
1022 }
1023 set test_what [lindex $test_what 1]
1024 return [check_runtime_nocache $test_what [subst {
1025 #include <iconv.h>
1026 int main (void)
1027 {
1028 iconv_t cd;
1029
1030 cd = iconv_open ("$test_what", "UTF-8");
1031 if (cd == (iconv_t) -1)
1032 return 1;
1033 return 0;
1034 }
1035 }] $libiconv]
1036 }
1037
1038 # Return true if Cilk Library is supported on the target.
1039 proc check_libcilkrts_available { } {
1040 return [ check_no_compiler_messages_nocache libcilkrts_available executable {
1041 #ifdef __cplusplus
1042 extern "C"
1043 #endif
1044 int __cilkrts_set_param (const char *, const char *);
1045 int main (void) {
1046 int x = __cilkrts_set_param ("nworkers", "0");
1047 return x;
1048 }
1049 } "-fcilkplus -lcilkrts" ]
1050 }
1051
1052 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1053
1054 proc check_ascii_locale_available { } {
1055 return 1
1056 }
1057
1058 # Return true if named sections are supported on this target.
1059
1060 proc check_named_sections_available { } {
1061 return [check_no_compiler_messages named_sections assembly {
1062 int __attribute__ ((section("whatever"))) foo;
1063 }]
1064 }
1065
1066 # Return true if the "naked" function attribute is supported on this target.
1067
1068 proc check_effective_target_naked_functions { } {
1069 return [check_no_compiler_messages naked_functions assembly {
1070 void f() __attribute__((naked));
1071 }]
1072 }
1073
1074 # Return 1 if the target supports Fortran real kinds larger than real(8),
1075 # 0 otherwise.
1076 #
1077 # When the target name changes, replace the cached result.
1078
1079 proc check_effective_target_fortran_large_real { } {
1080 return [check_no_compiler_messages fortran_large_real executable {
1081 ! Fortran
1082 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1083 real(kind=k) :: x
1084 x = cos (x)
1085 end
1086 }]
1087 }
1088
1089 # Return 1 if the target supports Fortran real kind real(16),
1090 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1091 # this checks for Real(16) only; the other returned real(10) if
1092 # both real(10) and real(16) are available.
1093 #
1094 # When the target name changes, replace the cached result.
1095
1096 proc check_effective_target_fortran_real_16 { } {
1097 return [check_no_compiler_messages fortran_real_16 executable {
1098 ! Fortran
1099 real(kind=16) :: x
1100 x = cos (x)
1101 end
1102 }]
1103 }
1104
1105
1106 # Return 1 if the target supports SQRT for the largest floating-point
1107 # type. (Some targets lack the libm support for this FP type.)
1108 # On most targets, this check effectively checks either whether sqrtl is
1109 # available or on __float128 systems whether libquadmath is installed,
1110 # which provides sqrtq.
1111 #
1112 # When the target name changes, replace the cached result.
1113
1114 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1115 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1116 ! Fortran
1117 use iso_fortran_env, only: real_kinds
1118 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1119 real(kind=maxFP), volatile :: x
1120 x = 2.0_maxFP
1121 x = sqrt (x)
1122 end
1123 }]
1124 }
1125
1126
1127 # Return 1 if the target supports Fortran integer kinds larger than
1128 # integer(8), 0 otherwise.
1129 #
1130 # When the target name changes, replace the cached result.
1131
1132 proc check_effective_target_fortran_large_int { } {
1133 return [check_no_compiler_messages fortran_large_int executable {
1134 ! Fortran
1135 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1136 integer(kind=k) :: i
1137 end
1138 }]
1139 }
1140
1141 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1142 #
1143 # When the target name changes, replace the cached result.
1144
1145 proc check_effective_target_fortran_integer_16 { } {
1146 return [check_no_compiler_messages fortran_integer_16 executable {
1147 ! Fortran
1148 integer(16) :: i
1149 end
1150 }]
1151 }
1152
1153 # Return 1 if we can statically link libgfortran, 0 otherwise.
1154 #
1155 # When the target name changes, replace the cached result.
1156
1157 proc check_effective_target_static_libgfortran { } {
1158 return [check_no_compiler_messages static_libgfortran executable {
1159 ! Fortran
1160 print *, 'test'
1161 end
1162 } "-static"]
1163 }
1164
1165 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1166
1167 proc check_effective_target_cilkplus { } {
1168 # Skip cilk-plus tests on int16 and size16 targets for now.
1169 # The cilk-plus tests are not generic enough to cover these
1170 # cases and would throw hundreds of FAILs.
1171 if { [check_effective_target_int16]
1172 || ![check_effective_target_size32plus] } {
1173 return 0;
1174 }
1175
1176 # Skip AVR, its RAM is too small and too many tests would fail.
1177 if { [istarget avr-*-*] } {
1178 return 0;
1179 }
1180 return 1
1181 }
1182
1183 proc check_linker_plugin_available { } {
1184 return [check_no_compiler_messages_nocache linker_plugin executable {
1185 int main() { return 0; }
1186 } "-flto -fuse-linker-plugin"]
1187 }
1188
1189 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1190 # otherwise. Cache the result.
1191
1192 proc check_750cl_hw_available { } {
1193 return [check_cached_effective_target 750cl_hw_available {
1194 # If this is not the right target then we can skip the test.
1195 if { ![istarget powerpc-*paired*] } {
1196 expr 0
1197 } else {
1198 check_runtime_nocache 750cl_hw_available {
1199 int main()
1200 {
1201 #ifdef __MACH__
1202 asm volatile ("ps_mul v0,v0,v0");
1203 #else
1204 asm volatile ("ps_mul 0,0,0");
1205 #endif
1206 return 0;
1207 }
1208 } "-mpaired"
1209 }
1210 }]
1211 }
1212
1213 # Return 1 if the target OS supports running SSE executables, 0
1214 # otherwise. Cache the result.
1215
1216 proc check_sse_os_support_available { } {
1217 return [check_cached_effective_target sse_os_support_available {
1218 # If this is not the right target then we can skip the test.
1219 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1220 expr 0
1221 } elseif { [istarget i?86-*-solaris2*] } {
1222 # The Solaris 2 kernel doesn't save and restore SSE registers
1223 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1224 check_runtime_nocache sse_os_support_available {
1225 int main ()
1226 {
1227 asm volatile ("movaps %xmm0,%xmm0");
1228 return 0;
1229 }
1230 } "-msse"
1231 } else {
1232 expr 1
1233 }
1234 }]
1235 }
1236
1237 # Return 1 if the target OS supports running AVX executables, 0
1238 # otherwise. Cache the result.
1239
1240 proc check_avx_os_support_available { } {
1241 return [check_cached_effective_target avx_os_support_available {
1242 # If this is not the right target then we can skip the test.
1243 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1244 expr 0
1245 } else {
1246 # Check that OS has AVX and SSE saving enabled.
1247 check_runtime_nocache avx_os_support_available {
1248 int main ()
1249 {
1250 unsigned int eax, edx;
1251
1252 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1253 return (eax & 6) != 6;
1254 }
1255 } ""
1256 }
1257 }]
1258 }
1259
1260 # Return 1 if the target supports executing SSE instructions, 0
1261 # otherwise. Cache the result.
1262
1263 proc check_sse_hw_available { } {
1264 return [check_cached_effective_target sse_hw_available {
1265 # If this is not the right target then we can skip the test.
1266 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1267 expr 0
1268 } else {
1269 check_runtime_nocache sse_hw_available {
1270 #include "cpuid.h"
1271 int main ()
1272 {
1273 unsigned int eax, ebx, ecx, edx;
1274 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1275 return !(edx & bit_SSE);
1276 return 1;
1277 }
1278 } ""
1279 }
1280 }]
1281 }
1282
1283 # Return 1 if the target supports executing SSE2 instructions, 0
1284 # otherwise. Cache the result.
1285
1286 proc check_sse2_hw_available { } {
1287 return [check_cached_effective_target sse2_hw_available {
1288 # If this is not the right target then we can skip the test.
1289 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1290 expr 0
1291 } else {
1292 check_runtime_nocache sse2_hw_available {
1293 #include "cpuid.h"
1294 int main ()
1295 {
1296 unsigned int eax, ebx, ecx, edx;
1297 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1298 return !(edx & bit_SSE2);
1299 return 1;
1300 }
1301 } ""
1302 }
1303 }]
1304 }
1305
1306 # Return 1 if the target supports executing AVX instructions, 0
1307 # otherwise. Cache the result.
1308
1309 proc check_avx_hw_available { } {
1310 return [check_cached_effective_target avx_hw_available {
1311 # If this is not the right target then we can skip the test.
1312 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1313 expr 0
1314 } else {
1315 check_runtime_nocache avx_hw_available {
1316 #include "cpuid.h"
1317 int main ()
1318 {
1319 unsigned int eax, ebx, ecx, edx;
1320 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1321 return ((ecx & (bit_AVX | bit_OSXSAVE))
1322 != (bit_AVX | bit_OSXSAVE));
1323 return 1;
1324 }
1325 } ""
1326 }
1327 }]
1328 }
1329
1330 # Return 1 if the target supports running SSE executables, 0 otherwise.
1331
1332 proc check_effective_target_sse_runtime { } {
1333 if { [check_effective_target_sse]
1334 && [check_sse_hw_available]
1335 && [check_sse_os_support_available] } {
1336 return 1
1337 }
1338 return 0
1339 }
1340
1341 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1342
1343 proc check_effective_target_sse2_runtime { } {
1344 if { [check_effective_target_sse2]
1345 && [check_sse2_hw_available]
1346 && [check_sse_os_support_available] } {
1347 return 1
1348 }
1349 return 0
1350 }
1351
1352 # Return 1 if the target supports running AVX executables, 0 otherwise.
1353
1354 proc check_effective_target_avx_runtime { } {
1355 if { [check_effective_target_avx]
1356 && [check_avx_hw_available]
1357 && [check_avx_os_support_available] } {
1358 return 1
1359 }
1360 return 0
1361 }
1362
1363 # Return 1 if the target supports executing power8 vector instructions, 0
1364 # otherwise. Cache the result.
1365
1366 proc check_p8vector_hw_available { } {
1367 return [check_cached_effective_target p8vector_hw_available {
1368 # Some simulators are known to not support VSX/power8 instructions.
1369 # For now, disable on Darwin
1370 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1371 expr 0
1372 } else {
1373 set options "-mpower8-vector"
1374 check_runtime_nocache p8vector_hw_available {
1375 int main()
1376 {
1377 #ifdef __MACH__
1378 asm volatile ("xxlorc vs0,vs0,vs0");
1379 #else
1380 asm volatile ("xxlorc 0,0,0");
1381 #endif
1382 return 0;
1383 }
1384 } $options
1385 }
1386 }]
1387 }
1388
1389 # Return 1 if the target supports executing VSX instructions, 0
1390 # otherwise. Cache the result.
1391
1392 proc check_vsx_hw_available { } {
1393 return [check_cached_effective_target vsx_hw_available {
1394 # Some simulators are known to not support VSX instructions.
1395 # For now, disable on Darwin
1396 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1397 expr 0
1398 } else {
1399 set options "-mvsx"
1400 check_runtime_nocache vsx_hw_available {
1401 int main()
1402 {
1403 #ifdef __MACH__
1404 asm volatile ("xxlor vs0,vs0,vs0");
1405 #else
1406 asm volatile ("xxlor 0,0,0");
1407 #endif
1408 return 0;
1409 }
1410 } $options
1411 }
1412 }]
1413 }
1414
1415 # Return 1 if the target supports executing AltiVec instructions, 0
1416 # otherwise. Cache the result.
1417
1418 proc check_vmx_hw_available { } {
1419 return [check_cached_effective_target vmx_hw_available {
1420 # Some simulators are known to not support VMX instructions.
1421 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1422 expr 0
1423 } else {
1424 # Most targets don't require special flags for this test case, but
1425 # Darwin does. Just to be sure, make sure VSX is not enabled for
1426 # the altivec tests.
1427 if { [istarget *-*-darwin*]
1428 || [istarget *-*-aix*] } {
1429 set options "-maltivec -mno-vsx"
1430 } else {
1431 set options "-mno-vsx"
1432 }
1433 check_runtime_nocache vmx_hw_available {
1434 int main()
1435 {
1436 #ifdef __MACH__
1437 asm volatile ("vor v0,v0,v0");
1438 #else
1439 asm volatile ("vor 0,0,0");
1440 #endif
1441 return 0;
1442 }
1443 } $options
1444 }
1445 }]
1446 }
1447
1448 proc check_ppc_recip_hw_available { } {
1449 return [check_cached_effective_target ppc_recip_hw_available {
1450 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1451 # For now, disable on Darwin
1452 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1453 expr 0
1454 } else {
1455 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1456 check_runtime_nocache ppc_recip_hw_available {
1457 volatile double d_recip, d_rsqrt, d_four = 4.0;
1458 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1459 int main()
1460 {
1461 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1462 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1463 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1464 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1465 return 0;
1466 }
1467 } $options
1468 }
1469 }]
1470 }
1471
1472 # Return 1 if the target supports executing AltiVec and Cell PPU
1473 # instructions, 0 otherwise. Cache the result.
1474
1475 proc check_effective_target_cell_hw { } {
1476 return [check_cached_effective_target cell_hw_available {
1477 # Some simulators are known to not support VMX and PPU instructions.
1478 if { [istarget powerpc-*-eabi*] } {
1479 expr 0
1480 } else {
1481 # Most targets don't require special flags for this test
1482 # case, but Darwin and AIX do.
1483 if { [istarget *-*-darwin*]
1484 || [istarget *-*-aix*] } {
1485 set options "-maltivec -mcpu=cell"
1486 } else {
1487 set options "-mcpu=cell"
1488 }
1489 check_runtime_nocache cell_hw_available {
1490 int main()
1491 {
1492 #ifdef __MACH__
1493 asm volatile ("vor v0,v0,v0");
1494 asm volatile ("lvlx v0,r0,r0");
1495 #else
1496 asm volatile ("vor 0,0,0");
1497 asm volatile ("lvlx 0,0,0");
1498 #endif
1499 return 0;
1500 }
1501 } $options
1502 }
1503 }]
1504 }
1505
1506 # Return 1 if the target supports executing 64-bit instructions, 0
1507 # otherwise. Cache the result.
1508
1509 proc check_effective_target_powerpc64 { } {
1510 global powerpc64_available_saved
1511 global tool
1512
1513 if [info exists powerpc64_available_saved] {
1514 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1515 } else {
1516 set powerpc64_available_saved 0
1517
1518 # Some simulators are known to not support powerpc64 instructions.
1519 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1520 verbose "check_effective_target_powerpc64 returning 0" 2
1521 return $powerpc64_available_saved
1522 }
1523
1524 # Set up, compile, and execute a test program containing a 64-bit
1525 # instruction. Include the current process ID in the file
1526 # names to prevent conflicts with invocations for multiple
1527 # testsuites.
1528 set src ppc[pid].c
1529 set exe ppc[pid].x
1530
1531 set f [open $src "w"]
1532 puts $f "int main() {"
1533 puts $f "#ifdef __MACH__"
1534 puts $f " asm volatile (\"extsw r0,r0\");"
1535 puts $f "#else"
1536 puts $f " asm volatile (\"extsw 0,0\");"
1537 puts $f "#endif"
1538 puts $f " return 0; }"
1539 close $f
1540
1541 set opts "additional_flags=-mcpu=G5"
1542
1543 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1544 set lines [${tool}_target_compile $src $exe executable "$opts"]
1545 file delete $src
1546
1547 if [string match "" $lines] then {
1548 # No error message, compilation succeeded.
1549 set result [${tool}_load "./$exe" "" ""]
1550 set status [lindex $result 0]
1551 remote_file build delete $exe
1552 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1553
1554 if { $status == "pass" } then {
1555 set powerpc64_available_saved 1
1556 }
1557 } else {
1558 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1559 }
1560 }
1561
1562 return $powerpc64_available_saved
1563 }
1564
1565 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1566 # complex float arguments. This affects gfortran tests that call cabsf
1567 # in libm built by an earlier compiler. Return 1 if libm uses the same
1568 # argument passing as the compiler under test, 0 otherwise.
1569 #
1570 # When the target name changes, replace the cached result.
1571
1572 proc check_effective_target_broken_cplxf_arg { } {
1573 return [check_cached_effective_target broken_cplxf_arg {
1574 # Skip the work for targets known not to be affected.
1575 if { ![istarget powerpc64-*-linux*] } {
1576 expr 0
1577 } elseif { ![is-effective-target lp64] } {
1578 expr 0
1579 } else {
1580 check_runtime_nocache broken_cplxf_arg {
1581 #include <complex.h>
1582 extern void abort (void);
1583 float fabsf (float);
1584 float cabsf (_Complex float);
1585 int main ()
1586 {
1587 _Complex float cf;
1588 float f;
1589 cf = 3 + 4.0fi;
1590 f = cabsf (cf);
1591 if (fabsf (f - 5.0) > 0.0001)
1592 abort ();
1593 return 0;
1594 }
1595 } "-lm"
1596 }
1597 }]
1598 }
1599
1600 # Return 1 is this is a TI C6X target supporting C67X instructions
1601 proc check_effective_target_ti_c67x { } {
1602 return [check_no_compiler_messages ti_c67x assembly {
1603 #if !defined(_TMS320C6700)
1604 #error FOO
1605 #endif
1606 }]
1607 }
1608
1609 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1610 proc check_effective_target_ti_c64xp { } {
1611 return [check_no_compiler_messages ti_c64xp assembly {
1612 #if !defined(_TMS320C6400_PLUS)
1613 #error FOO
1614 #endif
1615 }]
1616 }
1617
1618
1619 proc check_alpha_max_hw_available { } {
1620 return [check_runtime alpha_max_hw_available {
1621 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1622 }]
1623 }
1624
1625 # Returns true iff the FUNCTION is available on the target system.
1626 # (This is essentially a Tcl implementation of Autoconf's
1627 # AC_CHECK_FUNC.)
1628
1629 proc check_function_available { function } {
1630 return [check_no_compiler_messages ${function}_available \
1631 executable [subst {
1632 #ifdef __cplusplus
1633 extern "C"
1634 #endif
1635 char $function ();
1636 int main () { $function (); }
1637 }] "-fno-builtin" ]
1638 }
1639
1640 # Returns true iff "fork" is available on the target system.
1641
1642 proc check_fork_available {} {
1643 return [check_function_available "fork"]
1644 }
1645
1646 # Returns true iff "mkfifo" is available on the target system.
1647
1648 proc check_mkfifo_available {} {
1649 if { [istarget *-*-cygwin*] } {
1650 # Cygwin has mkfifo, but support is incomplete.
1651 return 0
1652 }
1653
1654 return [check_function_available "mkfifo"]
1655 }
1656
1657 # Returns true iff "__cxa_atexit" is used on the target system.
1658
1659 proc check_cxa_atexit_available { } {
1660 return [check_cached_effective_target cxa_atexit_available {
1661 if { [istarget hppa*-*-hpux10*] } {
1662 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1663 expr 0
1664 } elseif { [istarget *-*-vxworks] } {
1665 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1666 expr 0
1667 } else {
1668 check_runtime_nocache cxa_atexit_available {
1669 // C++
1670 #include <stdlib.h>
1671 static unsigned int count;
1672 struct X
1673 {
1674 X() { count = 1; }
1675 ~X()
1676 {
1677 if (count != 3)
1678 exit(1);
1679 count = 4;
1680 }
1681 };
1682 void f()
1683 {
1684 static X x;
1685 }
1686 struct Y
1687 {
1688 Y() { f(); count = 2; }
1689 ~Y()
1690 {
1691 if (count != 2)
1692 exit(1);
1693 count = 3;
1694 }
1695 };
1696 Y y;
1697 int main() { return 0; }
1698 }
1699 }
1700 }]
1701 }
1702
1703 proc check_effective_target_objc2 { } {
1704 return [check_no_compiler_messages objc2 object {
1705 #ifdef __OBJC2__
1706 int dummy[1];
1707 #else
1708 #error
1709 #endif
1710 }]
1711 }
1712
1713 proc check_effective_target_next_runtime { } {
1714 return [check_no_compiler_messages objc2 object {
1715 #ifdef __NEXT_RUNTIME__
1716 int dummy[1];
1717 #else
1718 #error
1719 #endif
1720 }]
1721 }
1722
1723 # Return 1 if we're generating 32-bit code using default options, 0
1724 # otherwise.
1725
1726 proc check_effective_target_ilp32 { } {
1727 return [check_no_compiler_messages ilp32 object {
1728 int dummy[sizeof (int) == 4
1729 && sizeof (void *) == 4
1730 && sizeof (long) == 4 ? 1 : -1];
1731 }]
1732 }
1733
1734 # Return 1 if we're generating ia32 code using default options, 0
1735 # otherwise.
1736
1737 proc check_effective_target_ia32 { } {
1738 return [check_no_compiler_messages ia32 object {
1739 int dummy[sizeof (int) == 4
1740 && sizeof (void *) == 4
1741 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1742 }]
1743 }
1744
1745 # Return 1 if we're generating x32 code using default options, 0
1746 # otherwise.
1747
1748 proc check_effective_target_x32 { } {
1749 return [check_no_compiler_messages x32 object {
1750 int dummy[sizeof (int) == 4
1751 && sizeof (void *) == 4
1752 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1753 }]
1754 }
1755
1756 # Return 1 if we're generating 32-bit integers using default
1757 # options, 0 otherwise.
1758
1759 proc check_effective_target_int32 { } {
1760 return [check_no_compiler_messages int32 object {
1761 int dummy[sizeof (int) == 4 ? 1 : -1];
1762 }]
1763 }
1764
1765 # Return 1 if we're generating 32-bit or larger integers using default
1766 # options, 0 otherwise.
1767
1768 proc check_effective_target_int32plus { } {
1769 return [check_no_compiler_messages int32plus object {
1770 int dummy[sizeof (int) >= 4 ? 1 : -1];
1771 }]
1772 }
1773
1774 # Return 1 if we're generating 32-bit or larger pointers using default
1775 # options, 0 otherwise.
1776
1777 proc check_effective_target_ptr32plus { } {
1778 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
1779 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
1780 # cannot really hold a 32-bit address, so we always return false here.
1781 if { [istarget msp430-*-*] } {
1782 return 0
1783 }
1784
1785 return [check_no_compiler_messages ptr32plus object {
1786 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1787 }]
1788 }
1789
1790 # Return 1 if we support 32-bit or larger array and structure sizes
1791 # using default options, 0 otherwise.
1792
1793 proc check_effective_target_size32plus { } {
1794 return [check_no_compiler_messages size32plus object {
1795 char dummy[65537];
1796 }]
1797 }
1798
1799 # Returns 1 if we're generating 16-bit or smaller integers with the
1800 # default options, 0 otherwise.
1801
1802 proc check_effective_target_int16 { } {
1803 return [check_no_compiler_messages int16 object {
1804 int dummy[sizeof (int) < 4 ? 1 : -1];
1805 }]
1806 }
1807
1808 # Return 1 if we're generating 64-bit code using default options, 0
1809 # otherwise.
1810
1811 proc check_effective_target_lp64 { } {
1812 return [check_no_compiler_messages lp64 object {
1813 int dummy[sizeof (int) == 4
1814 && sizeof (void *) == 8
1815 && sizeof (long) == 8 ? 1 : -1];
1816 }]
1817 }
1818
1819 # Return 1 if we're generating 64-bit code using default llp64 options,
1820 # 0 otherwise.
1821
1822 proc check_effective_target_llp64 { } {
1823 return [check_no_compiler_messages llp64 object {
1824 int dummy[sizeof (int) == 4
1825 && sizeof (void *) == 8
1826 && sizeof (long long) == 8
1827 && sizeof (long) == 4 ? 1 : -1];
1828 }]
1829 }
1830
1831 # Return 1 if long and int have different sizes,
1832 # 0 otherwise.
1833
1834 proc check_effective_target_long_neq_int { } {
1835 return [check_no_compiler_messages long_ne_int object {
1836 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
1837 }]
1838 }
1839
1840 # Return 1 if the target supports long double larger than double,
1841 # 0 otherwise.
1842
1843 proc check_effective_target_large_long_double { } {
1844 return [check_no_compiler_messages large_long_double object {
1845 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1846 }]
1847 }
1848
1849 # Return 1 if the target supports double larger than float,
1850 # 0 otherwise.
1851
1852 proc check_effective_target_large_double { } {
1853 return [check_no_compiler_messages large_double object {
1854 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1855 }]
1856 }
1857
1858 # Return 1 if the target supports double of 64 bits,
1859 # 0 otherwise.
1860
1861 proc check_effective_target_double64 { } {
1862 return [check_no_compiler_messages double64 object {
1863 int dummy[sizeof(double) == 8 ? 1 : -1];
1864 }]
1865 }
1866
1867 # Return 1 if the target supports double of at least 64 bits,
1868 # 0 otherwise.
1869
1870 proc check_effective_target_double64plus { } {
1871 return [check_no_compiler_messages double64plus object {
1872 int dummy[sizeof(double) >= 8 ? 1 : -1];
1873 }]
1874 }
1875
1876 # Return 1 if the target supports 'w' suffix on floating constant
1877 # 0 otherwise.
1878
1879 proc check_effective_target_has_w_floating_suffix { } {
1880 set opts ""
1881 if [check_effective_target_c++] {
1882 append opts "-std=gnu++03"
1883 }
1884 return [check_no_compiler_messages w_fp_suffix object {
1885 float dummy = 1.0w;
1886 } "$opts"]
1887 }
1888
1889 # Return 1 if the target supports 'q' suffix on floating constant
1890 # 0 otherwise.
1891
1892 proc check_effective_target_has_q_floating_suffix { } {
1893 set opts ""
1894 if [check_effective_target_c++] {
1895 append opts "-std=gnu++03"
1896 }
1897 return [check_no_compiler_messages q_fp_suffix object {
1898 float dummy = 1.0q;
1899 } "$opts"]
1900 }
1901 # Return 1 if the target supports compiling fixed-point,
1902 # 0 otherwise.
1903
1904 proc check_effective_target_fixed_point { } {
1905 return [check_no_compiler_messages fixed_point object {
1906 _Sat _Fract x; _Sat _Accum y;
1907 }]
1908 }
1909
1910 # Return 1 if the target supports compiling decimal floating point,
1911 # 0 otherwise.
1912
1913 proc check_effective_target_dfp_nocache { } {
1914 verbose "check_effective_target_dfp_nocache: compiling source" 2
1915 set ret [check_no_compiler_messages_nocache dfp object {
1916 float x __attribute__((mode(DD)));
1917 }]
1918 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1919 return $ret
1920 }
1921
1922 proc check_effective_target_dfprt_nocache { } {
1923 return [check_runtime_nocache dfprt {
1924 typedef float d64 __attribute__((mode(DD)));
1925 d64 x = 1.2df, y = 2.3dd, z;
1926 int main () { z = x + y; return 0; }
1927 }]
1928 }
1929
1930 # Return 1 if the target supports compiling Decimal Floating Point,
1931 # 0 otherwise.
1932 #
1933 # This won't change for different subtargets so cache the result.
1934
1935 proc check_effective_target_dfp { } {
1936 return [check_cached_effective_target dfp {
1937 check_effective_target_dfp_nocache
1938 }]
1939 }
1940
1941 # Return 1 if the target supports linking and executing Decimal Floating
1942 # Point, 0 otherwise.
1943 #
1944 # This won't change for different subtargets so cache the result.
1945
1946 proc check_effective_target_dfprt { } {
1947 return [check_cached_effective_target dfprt {
1948 check_effective_target_dfprt_nocache
1949 }]
1950 }
1951
1952 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1953
1954 proc check_effective_target_ucn_nocache { } {
1955 # -std=c99 is only valid for C
1956 if [check_effective_target_c] {
1957 set ucnopts "-std=c99"
1958 }
1959 append ucnopts " -fextended-identifiers"
1960 verbose "check_effective_target_ucn_nocache: compiling source" 2
1961 set ret [check_no_compiler_messages_nocache ucn object {
1962 int \u00C0;
1963 } $ucnopts]
1964 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1965 return $ret
1966 }
1967
1968 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1969 #
1970 # This won't change for different subtargets, so cache the result.
1971
1972 proc check_effective_target_ucn { } {
1973 return [check_cached_effective_target ucn {
1974 check_effective_target_ucn_nocache
1975 }]
1976 }
1977
1978 # Return 1 if the target needs a command line argument to enable a SIMD
1979 # instruction set.
1980
1981 proc check_effective_target_vect_cmdline_needed { } {
1982 global et_vect_cmdline_needed_saved
1983 global et_vect_cmdline_needed_target_name
1984
1985 if { ![info exists et_vect_cmdline_needed_target_name] } {
1986 set et_vect_cmdline_needed_target_name ""
1987 }
1988
1989 # If the target has changed since we set the cached value, clear it.
1990 set current_target [current_target_name]
1991 if { $current_target != $et_vect_cmdline_needed_target_name } {
1992 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1993 set et_vect_cmdline_needed_target_name $current_target
1994 if { [info exists et_vect_cmdline_needed_saved] } {
1995 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1996 unset et_vect_cmdline_needed_saved
1997 }
1998 }
1999
2000 if [info exists et_vect_cmdline_needed_saved] {
2001 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2002 } else {
2003 set et_vect_cmdline_needed_saved 1
2004 if { [istarget alpha*-*-*]
2005 || [istarget ia64-*-*]
2006 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
2007 && ([check_effective_target_x32]
2008 || [check_effective_target_lp64]))
2009 || ([istarget powerpc*-*-*]
2010 && ([check_effective_target_powerpc_spe]
2011 || [check_effective_target_powerpc_altivec]))
2012 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2013 || [istarget spu-*-*]
2014 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2015 || [istarget aarch64*-*-*] } {
2016 set et_vect_cmdline_needed_saved 0
2017 }
2018 }
2019
2020 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2021 return $et_vect_cmdline_needed_saved
2022 }
2023
2024 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2025 #
2026 # This won't change for different subtargets so cache the result.
2027
2028 proc check_effective_target_vect_int { } {
2029 global et_vect_int_saved
2030
2031 if [info exists et_vect_int_saved] {
2032 verbose "check_effective_target_vect_int: using cached result" 2
2033 } else {
2034 set et_vect_int_saved 0
2035 if { [istarget i?86-*-*]
2036 || ([istarget powerpc*-*-*]
2037 && ![istarget powerpc-*-linux*paired*])
2038 || [istarget spu-*-*]
2039 || [istarget x86_64-*-*]
2040 || [istarget sparc*-*-*]
2041 || [istarget alpha*-*-*]
2042 || [istarget ia64-*-*]
2043 || [istarget aarch64*-*-*]
2044 || [check_effective_target_arm32]
2045 || ([istarget mips*-*-*]
2046 && [check_effective_target_mips_loongson]) } {
2047 set et_vect_int_saved 1
2048 }
2049 }
2050
2051 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2052 return $et_vect_int_saved
2053 }
2054
2055 # Return 1 if the target supports signed int->float conversion
2056 #
2057
2058 proc check_effective_target_vect_intfloat_cvt { } {
2059 global et_vect_intfloat_cvt_saved
2060
2061 if [info exists et_vect_intfloat_cvt_saved] {
2062 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2063 } else {
2064 set et_vect_intfloat_cvt_saved 0
2065 if { [istarget i?86-*-*]
2066 || ([istarget powerpc*-*-*]
2067 && ![istarget powerpc-*-linux*paired*])
2068 || [istarget x86_64-*-*]
2069 || ([istarget arm*-*-*]
2070 && [check_effective_target_arm_neon_ok])} {
2071 set et_vect_intfloat_cvt_saved 1
2072 }
2073 }
2074
2075 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2076 return $et_vect_intfloat_cvt_saved
2077 }
2078
2079 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2080
2081 proc check_effective_target_int128 { } {
2082 return [check_no_compiler_messages int128 object {
2083 int dummy[
2084 #ifndef __SIZEOF_INT128__
2085 -1
2086 #else
2087 1
2088 #endif
2089 ];
2090 }]
2091 }
2092
2093 # Return 1 if the target supports unsigned int->float conversion
2094 #
2095
2096 proc check_effective_target_vect_uintfloat_cvt { } {
2097 global et_vect_uintfloat_cvt_saved
2098
2099 if [info exists et_vect_uintfloat_cvt_saved] {
2100 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2101 } else {
2102 set et_vect_uintfloat_cvt_saved 0
2103 if { [istarget i?86-*-*]
2104 || ([istarget powerpc*-*-*]
2105 && ![istarget powerpc-*-linux*paired*])
2106 || [istarget x86_64-*-*]
2107 || [istarget aarch64*-*-*]
2108 || ([istarget arm*-*-*]
2109 && [check_effective_target_arm_neon_ok])} {
2110 set et_vect_uintfloat_cvt_saved 1
2111 }
2112 }
2113
2114 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2115 return $et_vect_uintfloat_cvt_saved
2116 }
2117
2118
2119 # Return 1 if the target supports signed float->int conversion
2120 #
2121
2122 proc check_effective_target_vect_floatint_cvt { } {
2123 global et_vect_floatint_cvt_saved
2124
2125 if [info exists et_vect_floatint_cvt_saved] {
2126 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2127 } else {
2128 set et_vect_floatint_cvt_saved 0
2129 if { [istarget i?86-*-*]
2130 || ([istarget powerpc*-*-*]
2131 && ![istarget powerpc-*-linux*paired*])
2132 || [istarget x86_64-*-*]
2133 || ([istarget arm*-*-*]
2134 && [check_effective_target_arm_neon_ok])} {
2135 set et_vect_floatint_cvt_saved 1
2136 }
2137 }
2138
2139 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2140 return $et_vect_floatint_cvt_saved
2141 }
2142
2143 # Return 1 if the target supports unsigned float->int conversion
2144 #
2145
2146 proc check_effective_target_vect_floatuint_cvt { } {
2147 global et_vect_floatuint_cvt_saved
2148
2149 if [info exists et_vect_floatuint_cvt_saved] {
2150 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2151 } else {
2152 set et_vect_floatuint_cvt_saved 0
2153 if { ([istarget powerpc*-*-*]
2154 && ![istarget powerpc-*-linux*paired*])
2155 || ([istarget arm*-*-*]
2156 && [check_effective_target_arm_neon_ok])} {
2157 set et_vect_floatuint_cvt_saved 1
2158 }
2159 }
2160
2161 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2162 return $et_vect_floatuint_cvt_saved
2163 }
2164
2165 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2166 #
2167 # This won't change for different subtargets so cache the result.
2168
2169 proc check_effective_target_vect_simd_clones { } {
2170 global et_vect_simd_clones_saved
2171
2172 if [info exists et_vect_simd_clones_saved] {
2173 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2174 } else {
2175 set et_vect_simd_clones_saved 0
2176 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2177 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and
2178 # avx2 clone. Only the right clone for the specified arch will be
2179 # chosen, but still we need to at least be able to assemble
2180 # avx2.
2181 if { [check_effective_target_avx2] } {
2182 set et_vect_simd_clones_saved 1
2183 }
2184 }
2185 }
2186
2187 verbose "check_effective_target_vect_simd_clones: returning $et_vect_simd_clones_saved" 2
2188 return $et_vect_simd_clones_saved
2189 }
2190
2191 # Return 1 if this is a AArch64 target supporting big endian
2192 proc check_effective_target_aarch64_big_endian { } {
2193 return [check_no_compiler_messages aarch64_big_endian assembly {
2194 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2195 #error FOO
2196 #endif
2197 }]
2198 }
2199
2200 # Return 1 if this is a AArch64 target supporting little endian
2201 proc check_effective_target_aarch64_little_endian { } {
2202 return [check_no_compiler_messages aarch64_little_endian assembly {
2203 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2204 #error FOO
2205 #endif
2206 }]
2207 }
2208
2209 # Return 1 is this is an arm target using 32-bit instructions
2210 proc check_effective_target_arm32 { } {
2211 return [check_no_compiler_messages arm32 assembly {
2212 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2213 #error FOO
2214 #endif
2215 }]
2216 }
2217
2218 # Return 1 is this is an arm target not using Thumb
2219 proc check_effective_target_arm_nothumb { } {
2220 return [check_no_compiler_messages arm_nothumb assembly {
2221 #if (defined(__thumb__) || defined(__thumb2__))
2222 #error FOO
2223 #endif
2224 }]
2225 }
2226
2227 # Return 1 if this is a little-endian ARM target
2228 proc check_effective_target_arm_little_endian { } {
2229 return [check_no_compiler_messages arm_little_endian assembly {
2230 #if !defined(__arm__) || !defined(__ARMEL__)
2231 #error FOO
2232 #endif
2233 }]
2234 }
2235
2236 # Return 1 if this is an ARM target that only supports aligned vector accesses
2237 proc check_effective_target_arm_vect_no_misalign { } {
2238 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2239 #if !defined(__arm__) \
2240 || (defined(__ARMEL__) \
2241 && (!defined(__thumb__) || defined(__thumb2__)))
2242 #error FOO
2243 #endif
2244 }]
2245 }
2246
2247
2248 # Return 1 if this is an ARM target supporting -mfpu=vfp
2249 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2250 # options.
2251
2252 proc check_effective_target_arm_vfp_ok { } {
2253 if { [check_effective_target_arm32] } {
2254 return [check_no_compiler_messages arm_vfp_ok object {
2255 int dummy;
2256 } "-mfpu=vfp -mfloat-abi=softfp"]
2257 } else {
2258 return 0
2259 }
2260 }
2261
2262 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2263 # -mfloat-abi=softfp.
2264 proc check_effective_target_arm_v8_vfp_ok {} {
2265 if { [check_effective_target_arm32] } {
2266 return [check_no_compiler_messages arm_v8_vfp_ok object {
2267 int foo (void)
2268 {
2269 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2270 return 0;
2271 }
2272 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2273 } else {
2274 return 0
2275 }
2276 }
2277
2278 # Return 1 if this is an ARM target supporting -mfpu=vfp
2279 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2280 # options.
2281
2282 proc check_effective_target_arm_hard_vfp_ok { } {
2283 if { [check_effective_target_arm32]
2284 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2285 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2286 int main() { return 0;}
2287 } "-mfpu=vfp -mfloat-abi=hard"]
2288 } else {
2289 return 0
2290 }
2291 }
2292
2293 # Return 1 if this is an ARM target that supports DSP multiply with
2294 # current multilib flags.
2295
2296 proc check_effective_target_arm_dsp { } {
2297 return [check_no_compiler_messages arm_dsp assembly {
2298 #ifndef __ARM_FEATURE_DSP
2299 #error not DSP
2300 #endif
2301 int i;
2302 }]
2303 }
2304
2305 # Return 1 if this is an ARM target that supports unaligned word/halfword
2306 # load/store instructions.
2307
2308 proc check_effective_target_arm_unaligned { } {
2309 return [check_no_compiler_messages arm_unaligned assembly {
2310 #ifndef __ARM_FEATURE_UNALIGNED
2311 #error no unaligned support
2312 #endif
2313 int i;
2314 }]
2315 }
2316
2317 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2318 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2319 # incompatible with these options. Also set et_arm_crypto_flags to the
2320 # best options to add.
2321
2322 proc check_effective_target_arm_crypto_ok_nocache { } {
2323 global et_arm_crypto_flags
2324 set et_arm_crypto_flags ""
2325 if { [check_effective_target_arm32] } {
2326 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2327 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2328 #include "arm_neon.h"
2329 uint8x16_t
2330 foo (uint8x16_t a, uint8x16_t b)
2331 {
2332 return vaeseq_u8 (a, b);
2333 }
2334 } "$flags"] } {
2335 set et_arm_crypto_flags $flags
2336 return 1
2337 }
2338 }
2339 }
2340
2341 return 0
2342 }
2343
2344 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2345
2346 proc check_effective_target_arm_crypto_ok { } {
2347 return [check_cached_effective_target arm_crypto_ok \
2348 check_effective_target_arm_crypto_ok_nocache]
2349 }
2350
2351 # Add options for crypto extensions.
2352 proc add_options_for_arm_crypto { flags } {
2353 if { ! [check_effective_target_arm_crypto_ok] } {
2354 return "$flags"
2355 }
2356 global et_arm_crypto_flags
2357 return "$flags $et_arm_crypto_flags"
2358 }
2359
2360 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2361 # or -mfloat-abi=hard, but if one is already specified by the
2362 # multilib, use it. Similarly, if a -mfpu option already enables
2363 # NEON, do not add -mfpu=neon.
2364
2365 proc add_options_for_arm_neon { flags } {
2366 if { ! [check_effective_target_arm_neon_ok] } {
2367 return "$flags"
2368 }
2369 global et_arm_neon_flags
2370 return "$flags $et_arm_neon_flags"
2371 }
2372
2373 proc add_options_for_arm_v8_vfp { flags } {
2374 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2375 return "$flags"
2376 }
2377 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2378 }
2379
2380 proc add_options_for_arm_v8_neon { flags } {
2381 if { ! [check_effective_target_arm_v8_neon_ok] } {
2382 return "$flags"
2383 }
2384 global et_arm_v8_neon_flags
2385 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2386 }
2387
2388 proc add_options_for_arm_crc { flags } {
2389 if { ! [check_effective_target_arm_crc_ok] } {
2390 return "$flags"
2391 }
2392 global et_arm_crc_flags
2393 return "$flags $et_arm_crc_flags"
2394 }
2395
2396 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2397 # or -mfloat-abi=hard, but if one is already specified by the
2398 # multilib, use it. Similarly, if a -mfpu option already enables
2399 # NEON, do not add -mfpu=neon.
2400
2401 proc add_options_for_arm_neonv2 { flags } {
2402 if { ! [check_effective_target_arm_neonv2_ok] } {
2403 return "$flags"
2404 }
2405 global et_arm_neonv2_flags
2406 return "$flags $et_arm_neonv2_flags"
2407 }
2408
2409 # Return 1 if this is an ARM target supporting -mfpu=neon
2410 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2411 # incompatible with these options. Also set et_arm_neon_flags to the
2412 # best options to add.
2413
2414 proc check_effective_target_arm_neon_ok_nocache { } {
2415 global et_arm_neon_flags
2416 set et_arm_neon_flags ""
2417 if { [check_effective_target_arm32] } {
2418 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2419 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2420 #include "arm_neon.h"
2421 int dummy;
2422 } "$flags"] } {
2423 set et_arm_neon_flags $flags
2424 return 1
2425 }
2426 }
2427 }
2428
2429 return 0
2430 }
2431
2432 proc check_effective_target_arm_neon_ok { } {
2433 return [check_cached_effective_target arm_neon_ok \
2434 check_effective_target_arm_neon_ok_nocache]
2435 }
2436
2437 proc check_effective_target_arm_crc_ok_nocache { } {
2438 global et_arm_crc_flags
2439 set et_arm_crc_flags "-march=armv8-a+crc"
2440 return [check_no_compiler_messages_nocache arm_crc_ok object {
2441 #if !defined (__ARM_FEATURE_CRC32)
2442 #error FOO
2443 #endif
2444 } "$et_arm_crc_flags"]
2445 }
2446
2447 proc check_effective_target_arm_crc_ok { } {
2448 return [check_cached_effective_target arm_crc_ok \
2449 check_effective_target_arm_crc_ok_nocache]
2450 }
2451
2452 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2453 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2454 # incompatible with these options. Also set et_arm_neon_flags to the
2455 # best options to add.
2456
2457 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2458 global et_arm_neon_fp16_flags
2459 set et_arm_neon_fp16_flags ""
2460 if { [check_effective_target_arm32] } {
2461 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2462 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
2463 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2464 #include "arm_neon.h"
2465 float16x4_t
2466 foo (float32x4_t arg)
2467 {
2468 return vcvt_f16_f32 (arg);
2469 }
2470 } "$flags"] } {
2471 set et_arm_neon_fp16_flags $flags
2472 return 1
2473 }
2474 }
2475 }
2476
2477 return 0
2478 }
2479
2480 proc check_effective_target_arm_neon_fp16_ok { } {
2481 return [check_cached_effective_target arm_neon_fp16_ok \
2482 check_effective_target_arm_neon_fp16_ok_nocache]
2483 }
2484
2485 proc add_options_for_arm_neon_fp16 { flags } {
2486 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2487 return "$flags"
2488 }
2489 global et_arm_neon_fp16_flags
2490 return "$flags $et_arm_neon_fp16_flags"
2491 }
2492
2493 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2494 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2495 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2496 # best options to add.
2497
2498 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2499 global et_arm_v8_neon_flags
2500 set et_arm_v8_neon_flags ""
2501 if { [check_effective_target_arm32] } {
2502 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2503 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2504 #include "arm_neon.h"
2505 void
2506 foo ()
2507 {
2508 __asm__ volatile ("vrintn.f32 q0, q0");
2509 }
2510 } "$flags"] } {
2511 set et_arm_v8_neon_flags $flags
2512 return 1
2513 }
2514 }
2515 }
2516
2517 return 0
2518 }
2519
2520 proc check_effective_target_arm_v8_neon_ok { } {
2521 return [check_cached_effective_target arm_v8_neon_ok \
2522 check_effective_target_arm_v8_neon_ok_nocache]
2523 }
2524
2525 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2526 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2527 # incompatible with these options. Also set et_arm_neonv2_flags to the
2528 # best options to add.
2529
2530 proc check_effective_target_arm_neonv2_ok_nocache { } {
2531 global et_arm_neonv2_flags
2532 set et_arm_neonv2_flags ""
2533 if { [check_effective_target_arm32] } {
2534 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2535 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2536 #include "arm_neon.h"
2537 float32x2_t
2538 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2539 {
2540 return vfma_f32 (a, b, c);
2541 }
2542 } "$flags"] } {
2543 set et_arm_neonv2_flags $flags
2544 return 1
2545 }
2546 }
2547 }
2548
2549 return 0
2550 }
2551
2552 proc check_effective_target_arm_neonv2_ok { } {
2553 return [check_cached_effective_target arm_neonv2_ok \
2554 check_effective_target_arm_neonv2_ok_nocache]
2555 }
2556
2557 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2558 # or -mfloat-abi=hard, but if one is already specified by the
2559 # multilib, use it.
2560
2561 proc add_options_for_arm_fp16 { flags } {
2562 if { ! [check_effective_target_arm_fp16_ok] } {
2563 return "$flags"
2564 }
2565 global et_arm_fp16_flags
2566 return "$flags $et_arm_fp16_flags"
2567 }
2568
2569 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2570 # Skip multilibs that are incompatible with these options and set
2571 # et_arm_fp16_flags to the best options to add.
2572
2573 proc check_effective_target_arm_fp16_ok_nocache { } {
2574 global et_arm_fp16_flags
2575 set et_arm_fp16_flags ""
2576 if { ! [check_effective_target_arm32] } {
2577 return 0;
2578 }
2579 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2580 # Multilib flags would override -mfpu.
2581 return 0
2582 }
2583 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2584 # Must generate floating-point instructions.
2585 return 0
2586 }
2587 if [check_effective_target_arm_hf_eabi] {
2588 # Use existing float-abi and force an fpu which supports fp16
2589 set et_arm_fp16_flags "-mfpu=vfpv4"
2590 return 1;
2591 }
2592 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2593 # The existing -mfpu value is OK; use it, but add softfp.
2594 set et_arm_fp16_flags "-mfloat-abi=softfp"
2595 return 1;
2596 }
2597 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2598 # macro to check for this support.
2599 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2600 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2601 int dummy;
2602 } "$flags"] } {
2603 set et_arm_fp16_flags "$flags"
2604 return 1
2605 }
2606
2607 return 0
2608 }
2609
2610 proc check_effective_target_arm_fp16_ok { } {
2611 return [check_cached_effective_target arm_fp16_ok \
2612 check_effective_target_arm_fp16_ok_nocache]
2613 }
2614
2615 # Creates a series of routines that return 1 if the given architecture
2616 # can be selected and a routine to give the flags to select that architecture
2617 # Note: Extra flags may be added to disable options from newer compilers
2618 # (Thumb in particular - but others may be added in the future)
2619 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2620 # /* { dg-add-options arm_arch_v5 } */
2621 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2622 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2623 v4t "-march=armv4t" __ARM_ARCH_4T__
2624 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2625 v5t "-march=armv5t" __ARM_ARCH_5T__
2626 v5te "-march=armv5te" __ARM_ARCH_5TE__
2627 v6 "-march=armv6" __ARM_ARCH_6__
2628 v6k "-march=armv6k" __ARM_ARCH_6K__
2629 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2630 v6z "-march=armv6z" __ARM_ARCH_6Z__
2631 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2632 v7a "-march=armv7-a" __ARM_ARCH_7A__
2633 v7r "-march=armv7-r" __ARM_ARCH_7R__
2634 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2635 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2636 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2637 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2638 proc check_effective_target_arm_arch_FUNC_ok { } {
2639 if { [ string match "*-marm*" "FLAG" ] &&
2640 ![check_effective_target_arm_arm_ok] } {
2641 return 0
2642 }
2643 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2644 #if !defined (DEF)
2645 #error FOO
2646 #endif
2647 } "FLAG" ]
2648 }
2649
2650 proc add_options_for_arm_arch_FUNC { flags } {
2651 return "$flags FLAG"
2652 }
2653
2654 proc check_effective_target_arm_arch_FUNC_multilib { } {
2655 return [check_runtime arm_arch_FUNC_multilib {
2656 int
2657 main (void)
2658 {
2659 return 0;
2660 }
2661 } [add_options_for_arm_arch_FUNC ""]]
2662 }
2663 }]
2664 }
2665
2666 # Return 1 if this is an ARM target where -marm causes ARM to be
2667 # used (not Thumb)
2668
2669 proc check_effective_target_arm_arm_ok { } {
2670 return [check_no_compiler_messages arm_arm_ok assembly {
2671 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2672 #error FOO
2673 #endif
2674 } "-marm"]
2675 }
2676
2677
2678 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2679 # used.
2680
2681 proc check_effective_target_arm_thumb1_ok { } {
2682 return [check_no_compiler_messages arm_thumb1_ok assembly {
2683 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2684 #error FOO
2685 #endif
2686 } "-mthumb"]
2687 }
2688
2689 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2690 # used.
2691
2692 proc check_effective_target_arm_thumb2_ok { } {
2693 return [check_no_compiler_messages arm_thumb2_ok assembly {
2694 #if !defined(__thumb2__)
2695 #error FOO
2696 #endif
2697 } "-mthumb"]
2698 }
2699
2700 # Return 1 if this is an ARM target where Thumb-1 is used without options
2701 # added by the test.
2702
2703 proc check_effective_target_arm_thumb1 { } {
2704 return [check_no_compiler_messages arm_thumb1 assembly {
2705 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2706 #error not thumb1
2707 #endif
2708 int i;
2709 } ""]
2710 }
2711
2712 # Return 1 if this is an ARM target where Thumb-2 is used without options
2713 # added by the test.
2714
2715 proc check_effective_target_arm_thumb2 { } {
2716 return [check_no_compiler_messages arm_thumb2 assembly {
2717 #if !defined(__thumb2__)
2718 #error FOO
2719 #endif
2720 int i;
2721 } ""]
2722 }
2723
2724 # Return 1 if this is an ARM target where conditional execution is available.
2725
2726 proc check_effective_target_arm_cond_exec { } {
2727 return [check_no_compiler_messages arm_cond_exec assembly {
2728 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
2729 #error FOO
2730 #endif
2731 int i;
2732 } ""]
2733 }
2734
2735 # Return 1 if this is an ARM cortex-M profile cpu
2736
2737 proc check_effective_target_arm_cortex_m { } {
2738 return [check_no_compiler_messages arm_cortex_m assembly {
2739 #if !defined(__ARM_ARCH_7M__) \
2740 && !defined (__ARM_ARCH_7EM__) \
2741 && !defined (__ARM_ARCH_6M__)
2742 #error FOO
2743 #endif
2744 int i;
2745 } "-mthumb"]
2746 }
2747
2748 # Return 1 if the target supports executing NEON instructions, 0
2749 # otherwise. Cache the result.
2750
2751 proc check_effective_target_arm_neon_hw { } {
2752 return [check_runtime arm_neon_hw_available {
2753 int
2754 main (void)
2755 {
2756 long long a = 0, b = 1;
2757 asm ("vorr %P0, %P1, %P2"
2758 : "=w" (a)
2759 : "0" (a), "w" (b));
2760 return (a != 1);
2761 }
2762 } [add_options_for_arm_neon ""]]
2763 }
2764
2765 proc check_effective_target_arm_neonv2_hw { } {
2766 return [check_runtime arm_neon_hwv2_available {
2767 #include "arm_neon.h"
2768 int
2769 main (void)
2770 {
2771 float32x2_t a, b, c;
2772 asm ("vfma.f32 %P0, %P1, %P2"
2773 : "=w" (a)
2774 : "w" (b), "w" (c));
2775 return 0;
2776 }
2777 } [add_options_for_arm_neonv2 ""]]
2778 }
2779
2780 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
2781 # otherwise.
2782
2783 proc check_effective_target_arm_v8_neon_hw { } {
2784 return [check_runtime arm_v8_neon_hw_available {
2785 #include "arm_neon.h"
2786 int
2787 main (void)
2788 {
2789 float32x2_t a;
2790 asm ("vrinta.f32 %P0, %P1"
2791 : "=w" (a)
2792 : "0" (a));
2793 return 0;
2794 }
2795 } [add_options_for_arm_v8_neon ""]]
2796 }
2797
2798 # Return 1 if this is a ARM target with NEON enabled.
2799
2800 proc check_effective_target_arm_neon { } {
2801 if { [check_effective_target_arm32] } {
2802 return [check_no_compiler_messages arm_neon object {
2803 #ifndef __ARM_NEON__
2804 #error not NEON
2805 #else
2806 int dummy;
2807 #endif
2808 }]
2809 } else {
2810 return 0
2811 }
2812 }
2813
2814 proc check_effective_target_arm_neonv2 { } {
2815 if { [check_effective_target_arm32] } {
2816 return [check_no_compiler_messages arm_neon object {
2817 #ifndef __ARM_NEON__
2818 #error not NEON
2819 #else
2820 #ifndef __ARM_FEATURE_FMA
2821 #error not NEONv2
2822 #else
2823 int dummy;
2824 #endif
2825 #endif
2826 }]
2827 } else {
2828 return 0
2829 }
2830 }
2831
2832 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2833 # the Loongson vector modes.
2834
2835 proc check_effective_target_mips_loongson { } {
2836 return [check_no_compiler_messages loongson assembly {
2837 #if !defined(__mips_loongson_vector_rev)
2838 #error FOO
2839 #endif
2840 }]
2841 }
2842
2843 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2844 # Architecture.
2845
2846 proc check_effective_target_arm_eabi { } {
2847 return [check_no_compiler_messages arm_eabi object {
2848 #ifndef __ARM_EABI__
2849 #error not EABI
2850 #else
2851 int dummy;
2852 #endif
2853 }]
2854 }
2855
2856 # Return 1 if this is an ARM target that adheres to the hard-float variant of
2857 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
2858
2859 proc check_effective_target_arm_hf_eabi { } {
2860 return [check_no_compiler_messages arm_hf_eabi object {
2861 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
2862 #error not hard-float EABI
2863 #else
2864 int dummy;
2865 #endif
2866 }]
2867 }
2868
2869 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2870 # Some multilibs may be incompatible with this option.
2871
2872 proc check_effective_target_arm_iwmmxt_ok { } {
2873 if { [check_effective_target_arm32] } {
2874 return [check_no_compiler_messages arm_iwmmxt_ok object {
2875 int dummy;
2876 } "-mcpu=iwmmxt"]
2877 } else {
2878 return 0
2879 }
2880 }
2881
2882 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
2883 # for an ARM target.
2884 proc check_effective_target_arm_prefer_ldrd_strd { } {
2885 if { ![check_effective_target_arm32] } {
2886 return 0;
2887 }
2888
2889 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
2890 void foo (int *p) { p[0] = 1; p[1] = 0;}
2891 } "-O2 -mthumb" ]
2892 }
2893
2894 # Return 1 if this is a PowerPC target supporting -meabi.
2895
2896 proc check_effective_target_powerpc_eabi_ok { } {
2897 if { [istarget powerpc*-*-*] } {
2898 return [check_no_compiler_messages powerpc_eabi_ok object {
2899 int dummy;
2900 } "-meabi"]
2901 } else {
2902 return 0
2903 }
2904 }
2905
2906 # Return 1 if this is a PowerPC target with floating-point registers.
2907
2908 proc check_effective_target_powerpc_fprs { } {
2909 if { [istarget powerpc*-*-*]
2910 || [istarget rs6000-*-*] } {
2911 return [check_no_compiler_messages powerpc_fprs object {
2912 #ifdef __NO_FPRS__
2913 #error no FPRs
2914 #else
2915 int dummy;
2916 #endif
2917 }]
2918 } else {
2919 return 0
2920 }
2921 }
2922
2923 # Return 1 if this is a PowerPC target with hardware double-precision
2924 # floating point.
2925
2926 proc check_effective_target_powerpc_hard_double { } {
2927 if { [istarget powerpc*-*-*]
2928 || [istarget rs6000-*-*] } {
2929 return [check_no_compiler_messages powerpc_hard_double object {
2930 #ifdef _SOFT_DOUBLE
2931 #error soft double
2932 #else
2933 int dummy;
2934 #endif
2935 }]
2936 } else {
2937 return 0
2938 }
2939 }
2940
2941 # Return 1 if this is a PowerPC target supporting -maltivec.
2942
2943 proc check_effective_target_powerpc_altivec_ok { } {
2944 if { ([istarget powerpc*-*-*]
2945 && ![istarget powerpc-*-linux*paired*])
2946 || [istarget rs6000-*-*] } {
2947 # AltiVec is not supported on AIX before 5.3.
2948 if { [istarget powerpc*-*-aix4*]
2949 || [istarget powerpc*-*-aix5.1*]
2950 || [istarget powerpc*-*-aix5.2*] } {
2951 return 0
2952 }
2953 return [check_no_compiler_messages powerpc_altivec_ok object {
2954 int dummy;
2955 } "-maltivec"]
2956 } else {
2957 return 0
2958 }
2959 }
2960
2961 # Return 1 if this is a PowerPC target supporting -mpower8-vector
2962
2963 proc check_effective_target_powerpc_p8vector_ok { } {
2964 if { ([istarget powerpc*-*-*]
2965 && ![istarget powerpc-*-linux*paired*])
2966 || [istarget rs6000-*-*] } {
2967 # AltiVec is not supported on AIX before 5.3.
2968 if { [istarget powerpc*-*-aix4*]
2969 || [istarget powerpc*-*-aix5.1*]
2970 || [istarget powerpc*-*-aix5.2*] } {
2971 return 0
2972 }
2973 return [check_no_compiler_messages powerpc_p8vector_ok object {
2974 int main (void) {
2975 #ifdef __MACH__
2976 asm volatile ("xxlorc vs0,vs0,vs0");
2977 #else
2978 asm volatile ("xxlorc 0,0,0");
2979 #endif
2980 return 0;
2981 }
2982 } "-mpower8-vector"]
2983 } else {
2984 return 0
2985 }
2986 }
2987
2988 # Return 1 if this is a PowerPC target supporting -mvsx
2989
2990 proc check_effective_target_powerpc_vsx_ok { } {
2991 if { ([istarget powerpc*-*-*]
2992 && ![istarget powerpc-*-linux*paired*])
2993 || [istarget rs6000-*-*] } {
2994 # VSX is not supported on AIX before 7.1.
2995 if { [istarget powerpc*-*-aix4*]
2996 || [istarget powerpc*-*-aix5*]
2997 || [istarget powerpc*-*-aix6*] } {
2998 return 0
2999 }
3000 return [check_no_compiler_messages powerpc_vsx_ok object {
3001 int main (void) {
3002 #ifdef __MACH__
3003 asm volatile ("xxlor vs0,vs0,vs0");
3004 #else
3005 asm volatile ("xxlor 0,0,0");
3006 #endif
3007 return 0;
3008 }
3009 } "-mvsx"]
3010 } else {
3011 return 0
3012 }
3013 }
3014
3015 # Return 1 if this is a PowerPC target supporting -mhtm
3016
3017 proc check_effective_target_powerpc_htm_ok { } {
3018 if { ([istarget powerpc*-*-*]
3019 && ![istarget powerpc-*-linux*paired*])
3020 || [istarget rs6000-*-*] } {
3021 # HTM is not supported on AIX yet.
3022 if { [istarget powerpc*-*-aix*] } {
3023 return 0
3024 }
3025 return [check_no_compiler_messages powerpc_htm_ok object {
3026 int main (void) {
3027 asm volatile ("tbegin. 0");
3028 return 0;
3029 }
3030 } "-mhtm"]
3031 } else {
3032 return 0
3033 }
3034 }
3035
3036 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
3037
3038 proc check_effective_target_powerpc_ppu_ok { } {
3039 if [check_effective_target_powerpc_altivec_ok] {
3040 return [check_no_compiler_messages cell_asm_available object {
3041 int main (void) {
3042 #ifdef __MACH__
3043 asm volatile ("lvlx v0,v0,v0");
3044 #else
3045 asm volatile ("lvlx 0,0,0");
3046 #endif
3047 return 0;
3048 }
3049 }]
3050 } else {
3051 return 0
3052 }
3053 }
3054
3055 # Return 1 if this is a PowerPC target that supports SPU.
3056
3057 proc check_effective_target_powerpc_spu { } {
3058 if { [istarget powerpc*-*-linux*] } {
3059 return [check_effective_target_powerpc_altivec_ok]
3060 } else {
3061 return 0
3062 }
3063 }
3064
3065 # Return 1 if this is a PowerPC SPE target. The check includes options
3066 # specified by dg-options for this test, so don't cache the result.
3067
3068 proc check_effective_target_powerpc_spe_nocache { } {
3069 if { [istarget powerpc*-*-*] } {
3070 return [check_no_compiler_messages_nocache powerpc_spe object {
3071 #ifndef __SPE__
3072 #error not SPE
3073 #else
3074 int dummy;
3075 #endif
3076 } [current_compiler_flags]]
3077 } else {
3078 return 0
3079 }
3080 }
3081
3082 # Return 1 if this is a PowerPC target with SPE enabled.
3083
3084 proc check_effective_target_powerpc_spe { } {
3085 if { [istarget powerpc*-*-*] } {
3086 return [check_no_compiler_messages powerpc_spe object {
3087 #ifndef __SPE__
3088 #error not SPE
3089 #else
3090 int dummy;
3091 #endif
3092 }]
3093 } else {
3094 return 0
3095 }
3096 }
3097
3098 # Return 1 if this is a PowerPC target with Altivec enabled.
3099
3100 proc check_effective_target_powerpc_altivec { } {
3101 if { [istarget powerpc*-*-*] } {
3102 return [check_no_compiler_messages powerpc_altivec object {
3103 #ifndef __ALTIVEC__
3104 #error not Altivec
3105 #else
3106 int dummy;
3107 #endif
3108 }]
3109 } else {
3110 return 0
3111 }
3112 }
3113
3114 # Return 1 if this is a PowerPC 405 target. The check includes options
3115 # specified by dg-options for this test, so don't cache the result.
3116
3117 proc check_effective_target_powerpc_405_nocache { } {
3118 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3119 return [check_no_compiler_messages_nocache powerpc_405 object {
3120 #ifdef __PPC405__
3121 int dummy;
3122 #else
3123 #error not a PPC405
3124 #endif
3125 } [current_compiler_flags]]
3126 } else {
3127 return 0
3128 }
3129 }
3130
3131 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3132
3133 proc check_effective_target_powerpc_elfv2 { } {
3134 if { [istarget powerpc*-*-*] } {
3135 return [check_no_compiler_messages powerpc_elfv2 object {
3136 #if _CALL_ELF != 2
3137 #error not ELF v2 ABI
3138 #else
3139 int dummy;
3140 #endif
3141 }]
3142 } else {
3143 return 0
3144 }
3145 }
3146
3147 # Return 1 if this is a SPU target with a toolchain that
3148 # supports automatic overlay generation.
3149
3150 proc check_effective_target_spu_auto_overlay { } {
3151 if { [istarget spu*-*-elf*] } {
3152 return [check_no_compiler_messages spu_auto_overlay executable {
3153 int main (void) { }
3154 } "-Wl,--auto-overlay" ]
3155 } else {
3156 return 0
3157 }
3158 }
3159
3160 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3161 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3162 # test environment appears to run executables on such a simulator.
3163
3164 proc check_effective_target_ultrasparc_hw { } {
3165 return [check_runtime ultrasparc_hw {
3166 int main() { return 0; }
3167 } "-mcpu=ultrasparc"]
3168 }
3169
3170 # Return 1 if the test environment supports executing UltraSPARC VIS2
3171 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3172
3173 proc check_effective_target_ultrasparc_vis2_hw { } {
3174 return [check_runtime ultrasparc_vis2_hw {
3175 int main() { __asm__(".word 0x81b00320"); return 0; }
3176 } "-mcpu=ultrasparc3"]
3177 }
3178
3179 # Return 1 if the test environment supports executing UltraSPARC VIS3
3180 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3181
3182 proc check_effective_target_ultrasparc_vis3_hw { } {
3183 return [check_runtime ultrasparc_vis3_hw {
3184 int main() { __asm__(".word 0x81b00220"); return 0; }
3185 } "-mcpu=niagara3"]
3186 }
3187
3188 # Return 1 if this is a SPARC-V9 target.
3189
3190 proc check_effective_target_sparc_v9 { } {
3191 if { [istarget sparc*-*-*] } {
3192 return [check_no_compiler_messages sparc_v9 object {
3193 int main (void) {
3194 asm volatile ("return %i7+8");
3195 return 0;
3196 }
3197 }]
3198 } else {
3199 return 0
3200 }
3201 }
3202
3203 # Return 1 if this is a SPARC target with VIS enabled.
3204
3205 proc check_effective_target_sparc_vis { } {
3206 if { [istarget sparc*-*-*] } {
3207 return [check_no_compiler_messages sparc_vis object {
3208 #ifndef __VIS__
3209 #error not VIS
3210 #else
3211 int dummy;
3212 #endif
3213 }]
3214 } else {
3215 return 0
3216 }
3217 }
3218
3219 # Return 1 if the target supports hardware vector shift operation.
3220
3221 proc check_effective_target_vect_shift { } {
3222 global et_vect_shift_saved
3223
3224 if [info exists et_vect_shift_saved] {
3225 verbose "check_effective_target_vect_shift: using cached result" 2
3226 } else {
3227 set et_vect_shift_saved 0
3228 if { ([istarget powerpc*-*-*]
3229 && ![istarget powerpc-*-linux*paired*])
3230 || [istarget ia64-*-*]
3231 || [istarget i?86-*-*]
3232 || [istarget x86_64-*-*]
3233 || [istarget aarch64*-*-*]
3234 || [check_effective_target_arm32]
3235 || ([istarget mips*-*-*]
3236 && [check_effective_target_mips_loongson]) } {
3237 set et_vect_shift_saved 1
3238 }
3239 }
3240
3241 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3242 return $et_vect_shift_saved
3243 }
3244
3245 # Return 1 if the target supports hardware vector shift operation for char.
3246
3247 proc check_effective_target_vect_shift_char { } {
3248 global et_vect_shift_char_saved
3249
3250 if [info exists et_vect_shift_char_saved] {
3251 verbose "check_effective_target_vect_shift_char: using cached result" 2
3252 } else {
3253 set et_vect_shift_char_saved 0
3254 if { ([istarget powerpc*-*-*]
3255 && ![istarget powerpc-*-linux*paired*])
3256 || [check_effective_target_arm32] } {
3257 set et_vect_shift_char_saved 1
3258 }
3259 }
3260
3261 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3262 return $et_vect_shift_char_saved
3263 }
3264
3265 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3266 #
3267 # This can change for different subtargets so do not cache the result.
3268
3269 proc check_effective_target_vect_long { } {
3270 if { [istarget i?86-*-*]
3271 || (([istarget powerpc*-*-*]
3272 && ![istarget powerpc-*-linux*paired*])
3273 && [check_effective_target_ilp32])
3274 || [istarget x86_64-*-*]
3275 || [check_effective_target_arm32]
3276 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3277 set answer 1
3278 } else {
3279 set answer 0
3280 }
3281
3282 verbose "check_effective_target_vect_long: returning $answer" 2
3283 return $answer
3284 }
3285
3286 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3287 #
3288 # This won't change for different subtargets so cache the result.
3289
3290 proc check_effective_target_vect_float { } {
3291 global et_vect_float_saved
3292
3293 if [info exists et_vect_float_saved] {
3294 verbose "check_effective_target_vect_float: using cached result" 2
3295 } else {
3296 set et_vect_float_saved 0
3297 if { [istarget i?86-*-*]
3298 || [istarget powerpc*-*-*]
3299 || [istarget spu-*-*]
3300 || [istarget mips-sde-elf]
3301 || [istarget mipsisa64*-*-*]
3302 || [istarget x86_64-*-*]
3303 || [istarget ia64-*-*]
3304 || [istarget aarch64*-*-*]
3305 || [check_effective_target_arm32] } {
3306 set et_vect_float_saved 1
3307 }
3308 }
3309
3310 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
3311 return $et_vect_float_saved
3312 }
3313
3314 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
3315 #
3316 # This won't change for different subtargets so cache the result.
3317
3318 proc check_effective_target_vect_double { } {
3319 global et_vect_double_saved
3320
3321 if [info exists et_vect_double_saved] {
3322 verbose "check_effective_target_vect_double: using cached result" 2
3323 } else {
3324 set et_vect_double_saved 0
3325 if { [istarget i?86-*-*]
3326 || [istarget aarch64*-*-*]
3327 || [istarget x86_64-*-*] } {
3328 if { [check_no_compiler_messages vect_double assembly {
3329 #ifdef __tune_atom__
3330 # error No double vectorizer support.
3331 #endif
3332 }] } {
3333 set et_vect_double_saved 1
3334 } else {
3335 set et_vect_double_saved 0
3336 }
3337 } elseif { [istarget spu-*-*] } {
3338 set et_vect_double_saved 1
3339 }
3340 }
3341
3342 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3343 return $et_vect_double_saved
3344 }
3345
3346 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3347 #
3348 # This won't change for different subtargets so cache the result.
3349
3350 proc check_effective_target_vect_long_long { } {
3351 global et_vect_long_long_saved
3352
3353 if [info exists et_vect_long_long_saved] {
3354 verbose "check_effective_target_vect_long_long: using cached result" 2
3355 } else {
3356 set et_vect_long_long_saved 0
3357 if { [istarget i?86-*-*]
3358 || [istarget x86_64-*-*] } {
3359 set et_vect_long_long_saved 1
3360 }
3361 }
3362
3363 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3364 return $et_vect_long_long_saved
3365 }
3366
3367
3368 # Return 1 if the target plus current options does not support a vector
3369 # max instruction on "int", 0 otherwise.
3370 #
3371 # This won't change for different subtargets so cache the result.
3372
3373 proc check_effective_target_vect_no_int_max { } {
3374 global et_vect_no_int_max_saved
3375
3376 if [info exists et_vect_no_int_max_saved] {
3377 verbose "check_effective_target_vect_no_int_max: using cached result" 2
3378 } else {
3379 set et_vect_no_int_max_saved 0
3380 if { [istarget sparc*-*-*]
3381 || [istarget spu-*-*]
3382 || [istarget alpha*-*-*]
3383 || ([istarget mips*-*-*]
3384 && [check_effective_target_mips_loongson]) } {
3385 set et_vect_no_int_max_saved 1
3386 }
3387 }
3388 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
3389 return $et_vect_no_int_max_saved
3390 }
3391
3392 # Return 1 if the target plus current options does not support a vector
3393 # add instruction on "int", 0 otherwise.
3394 #
3395 # This won't change for different subtargets so cache the result.
3396
3397 proc check_effective_target_vect_no_int_add { } {
3398 global et_vect_no_int_add_saved
3399
3400 if [info exists et_vect_no_int_add_saved] {
3401 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3402 } else {
3403 set et_vect_no_int_add_saved 0
3404 # Alpha only supports vector add on V8QI and V4HI.
3405 if { [istarget alpha*-*-*] } {
3406 set et_vect_no_int_add_saved 1
3407 }
3408 }
3409 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3410 return $et_vect_no_int_add_saved
3411 }
3412
3413 # Return 1 if the target plus current options does not support vector
3414 # bitwise instructions, 0 otherwise.
3415 #
3416 # This won't change for different subtargets so cache the result.
3417
3418 proc check_effective_target_vect_no_bitwise { } {
3419 global et_vect_no_bitwise_saved
3420
3421 if [info exists et_vect_no_bitwise_saved] {
3422 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3423 } else {
3424 set et_vect_no_bitwise_saved 0
3425 }
3426 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3427 return $et_vect_no_bitwise_saved
3428 }
3429
3430 # Return 1 if the target plus current options supports vector permutation,
3431 # 0 otherwise.
3432 #
3433 # This won't change for different subtargets so cache the result.
3434
3435 proc check_effective_target_vect_perm { } {
3436 global et_vect_perm
3437
3438 if [info exists et_vect_perm_saved] {
3439 verbose "check_effective_target_vect_perm: using cached result" 2
3440 } else {
3441 set et_vect_perm_saved 0
3442 if { [is-effective-target arm_neon_ok]
3443 || ([istarget aarch64*-*-*]
3444 && [is-effective-target aarch64_little_endian])
3445 || [istarget powerpc*-*-*]
3446 || [istarget spu-*-*]
3447 || [istarget i?86-*-*]
3448 || [istarget x86_64-*-*]
3449 || ([istarget mips*-*-*]
3450 && [check_effective_target_mpaired_single]) } {
3451 set et_vect_perm_saved 1
3452 }
3453 }
3454 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3455 return $et_vect_perm_saved
3456 }
3457
3458 # Return 1 if the target plus current options supports vector permutation
3459 # on byte-sized elements, 0 otherwise.
3460 #
3461 # This won't change for different subtargets so cache the result.
3462
3463 proc check_effective_target_vect_perm_byte { } {
3464 global et_vect_perm_byte
3465
3466 if [info exists et_vect_perm_byte_saved] {
3467 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3468 } else {
3469 set et_vect_perm_byte_saved 0
3470 if { ([is-effective-target arm_neon_ok]
3471 && [is-effective-target arm_little_endian])
3472 || ([istarget aarch64*-*-*]
3473 && [is-effective-target aarch64_little_endian])
3474 || [istarget powerpc*-*-*]
3475 || [istarget spu-*-*] } {
3476 set et_vect_perm_byte_saved 1
3477 }
3478 }
3479 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3480 return $et_vect_perm_byte_saved
3481 }
3482
3483 # Return 1 if the target plus current options supports vector permutation
3484 # on short-sized elements, 0 otherwise.
3485 #
3486 # This won't change for different subtargets so cache the result.
3487
3488 proc check_effective_target_vect_perm_short { } {
3489 global et_vect_perm_short
3490
3491 if [info exists et_vect_perm_short_saved] {
3492 verbose "check_effective_target_vect_perm_short: using cached result" 2
3493 } else {
3494 set et_vect_perm_short_saved 0
3495 if { ([is-effective-target arm_neon_ok]
3496 && [is-effective-target arm_little_endian])
3497 || ([istarget aarch64*-*-*]
3498 && [is-effective-target aarch64_little_endian])
3499 || [istarget powerpc*-*-*]
3500 || [istarget spu-*-*] } {
3501 set et_vect_perm_short_saved 1
3502 }
3503 }
3504 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3505 return $et_vect_perm_short_saved
3506 }
3507
3508 # Return 1 if the target plus current options supports a vector
3509 # widening summation of *short* args into *int* result, 0 otherwise.
3510 #
3511 # This won't change for different subtargets so cache the result.
3512
3513 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3514 global et_vect_widen_sum_hi_to_si_pattern
3515
3516 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3517 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3518 } else {
3519 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3520 if { [istarget powerpc*-*-*]
3521 || [istarget ia64-*-*] } {
3522 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3523 }
3524 }
3525 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3526 return $et_vect_widen_sum_hi_to_si_pattern_saved
3527 }
3528
3529 # Return 1 if the target plus current options supports a vector
3530 # widening summation of *short* args into *int* result, 0 otherwise.
3531 # A target can also support this widening summation if it can support
3532 # promotion (unpacking) from shorts to ints.
3533 #
3534 # This won't change for different subtargets so cache the result.
3535
3536 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3537 global et_vect_widen_sum_hi_to_si
3538
3539 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3540 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3541 } else {
3542 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3543 if { [istarget powerpc*-*-*]
3544 || [istarget ia64-*-*] } {
3545 set et_vect_widen_sum_hi_to_si_saved 1
3546 }
3547 }
3548 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3549 return $et_vect_widen_sum_hi_to_si_saved
3550 }
3551
3552 # Return 1 if the target plus current options supports a vector
3553 # widening summation of *char* args into *short* result, 0 otherwise.
3554 # A target can also support this widening summation if it can support
3555 # promotion (unpacking) from chars to shorts.
3556 #
3557 # This won't change for different subtargets so cache the result.
3558
3559 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3560 global et_vect_widen_sum_qi_to_hi
3561
3562 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3563 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3564 } else {
3565 set et_vect_widen_sum_qi_to_hi_saved 0
3566 if { [check_effective_target_vect_unpack]
3567 || [check_effective_target_arm_neon_ok]
3568 || [istarget ia64-*-*] } {
3569 set et_vect_widen_sum_qi_to_hi_saved 1
3570 }
3571 }
3572 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3573 return $et_vect_widen_sum_qi_to_hi_saved
3574 }
3575
3576 # Return 1 if the target plus current options supports a vector
3577 # widening summation of *char* args into *int* result, 0 otherwise.
3578 #
3579 # This won't change for different subtargets so cache the result.
3580
3581 proc check_effective_target_vect_widen_sum_qi_to_si { } {
3582 global et_vect_widen_sum_qi_to_si
3583
3584 if [info exists et_vect_widen_sum_qi_to_si_saved] {
3585 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3586 } else {
3587 set et_vect_widen_sum_qi_to_si_saved 0
3588 if { [istarget powerpc*-*-*] } {
3589 set et_vect_widen_sum_qi_to_si_saved 1
3590 }
3591 }
3592 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3593 return $et_vect_widen_sum_qi_to_si_saved
3594 }
3595
3596 # Return 1 if the target plus current options supports a vector
3597 # widening multiplication of *char* args into *short* result, 0 otherwise.
3598 # A target can also support this widening multplication if it can support
3599 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
3600 # multiplication of shorts).
3601 #
3602 # This won't change for different subtargets so cache the result.
3603
3604
3605 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3606 global et_vect_widen_mult_qi_to_hi
3607
3608 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3609 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3610 } else {
3611 if { [check_effective_target_vect_unpack]
3612 && [check_effective_target_vect_short_mult] } {
3613 set et_vect_widen_mult_qi_to_hi_saved 1
3614 } else {
3615 set et_vect_widen_mult_qi_to_hi_saved 0
3616 }
3617 if { [istarget powerpc*-*-*]
3618 || [istarget aarch64*-*-*]
3619 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3620 set et_vect_widen_mult_qi_to_hi_saved 1
3621 }
3622 }
3623 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3624 return $et_vect_widen_mult_qi_to_hi_saved
3625 }
3626
3627 # Return 1 if the target plus current options supports a vector
3628 # widening multiplication of *short* args into *int* result, 0 otherwise.
3629 # A target can also support this widening multplication if it can support
3630 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3631 # multiplication of ints).
3632 #
3633 # This won't change for different subtargets so cache the result.
3634
3635
3636 proc check_effective_target_vect_widen_mult_hi_to_si { } {
3637 global et_vect_widen_mult_hi_to_si
3638
3639 if [info exists et_vect_widen_mult_hi_to_si_saved] {
3640 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3641 } else {
3642 if { [check_effective_target_vect_unpack]
3643 && [check_effective_target_vect_int_mult] } {
3644 set et_vect_widen_mult_hi_to_si_saved 1
3645 } else {
3646 set et_vect_widen_mult_hi_to_si_saved 0
3647 }
3648 if { [istarget powerpc*-*-*]
3649 || [istarget spu-*-*]
3650 || [istarget ia64-*-*]
3651 || [istarget aarch64*-*-*]
3652 || [istarget i?86-*-*]
3653 || [istarget x86_64-*-*]
3654 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3655 set et_vect_widen_mult_hi_to_si_saved 1
3656 }
3657 }
3658 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3659 return $et_vect_widen_mult_hi_to_si_saved
3660 }
3661
3662 # Return 1 if the target plus current options supports a vector
3663 # widening multiplication of *char* args into *short* result, 0 otherwise.
3664 #
3665 # This won't change for different subtargets so cache the result.
3666
3667 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3668 global et_vect_widen_mult_qi_to_hi_pattern
3669
3670 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3671 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3672 } else {
3673 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3674 if { [istarget powerpc*-*-*]
3675 || ([istarget arm*-*-*]
3676 && [check_effective_target_arm_neon_ok]
3677 && [check_effective_target_arm_little_endian]) } {
3678 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3679 }
3680 }
3681 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3682 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3683 }
3684
3685 # Return 1 if the target plus current options supports a vector
3686 # widening multiplication of *short* args into *int* result, 0 otherwise.
3687 #
3688 # This won't change for different subtargets so cache the result.
3689
3690 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3691 global et_vect_widen_mult_hi_to_si_pattern
3692
3693 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3694 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3695 } else {
3696 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3697 if { [istarget powerpc*-*-*]
3698 || [istarget spu-*-*]
3699 || [istarget ia64-*-*]
3700 || [istarget i?86-*-*]
3701 || [istarget x86_64-*-*]
3702 || ([istarget arm*-*-*]
3703 && [check_effective_target_arm_neon_ok]
3704 && [check_effective_target_arm_little_endian]) } {
3705 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3706 }
3707 }
3708 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3709 return $et_vect_widen_mult_hi_to_si_pattern_saved
3710 }
3711
3712 # Return 1 if the target plus current options supports a vector
3713 # widening shift, 0 otherwise.
3714 #
3715 # This won't change for different subtargets so cache the result.
3716
3717 proc check_effective_target_vect_widen_shift { } {
3718 global et_vect_widen_shift_saved
3719
3720 if [info exists et_vect_shift_saved] {
3721 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3722 } else {
3723 set et_vect_widen_shift_saved 0
3724 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3725 set et_vect_widen_shift_saved 1
3726 }
3727 }
3728 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3729 return $et_vect_widen_shift_saved
3730 }
3731
3732 # Return 1 if the target plus current options supports a vector
3733 # dot-product of signed chars, 0 otherwise.
3734 #
3735 # This won't change for different subtargets so cache the result.
3736
3737 proc check_effective_target_vect_sdot_qi { } {
3738 global et_vect_sdot_qi
3739
3740 if [info exists et_vect_sdot_qi_saved] {
3741 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3742 } else {
3743 set et_vect_sdot_qi_saved 0
3744 if { [istarget ia64-*-*] } {
3745 set et_vect_udot_qi_saved 1
3746 }
3747 }
3748 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3749 return $et_vect_sdot_qi_saved
3750 }
3751
3752 # Return 1 if the target plus current options supports a vector
3753 # dot-product of unsigned chars, 0 otherwise.
3754 #
3755 # This won't change for different subtargets so cache the result.
3756
3757 proc check_effective_target_vect_udot_qi { } {
3758 global et_vect_udot_qi
3759
3760 if [info exists et_vect_udot_qi_saved] {
3761 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3762 } else {
3763 set et_vect_udot_qi_saved 0
3764 if { [istarget powerpc*-*-*]
3765 || [istarget ia64-*-*] } {
3766 set et_vect_udot_qi_saved 1
3767 }
3768 }
3769 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3770 return $et_vect_udot_qi_saved
3771 }
3772
3773 # Return 1 if the target plus current options supports a vector
3774 # dot-product of signed shorts, 0 otherwise.
3775 #
3776 # This won't change for different subtargets so cache the result.
3777
3778 proc check_effective_target_vect_sdot_hi { } {
3779 global et_vect_sdot_hi
3780
3781 if [info exists et_vect_sdot_hi_saved] {
3782 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3783 } else {
3784 set et_vect_sdot_hi_saved 0
3785 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3786 || [istarget ia64-*-*]
3787 || [istarget i?86-*-*]
3788 || [istarget x86_64-*-*] } {
3789 set et_vect_sdot_hi_saved 1
3790 }
3791 }
3792 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3793 return $et_vect_sdot_hi_saved
3794 }
3795
3796 # Return 1 if the target plus current options supports a vector
3797 # dot-product of unsigned shorts, 0 otherwise.
3798 #
3799 # This won't change for different subtargets so cache the result.
3800
3801 proc check_effective_target_vect_udot_hi { } {
3802 global et_vect_udot_hi
3803
3804 if [info exists et_vect_udot_hi_saved] {
3805 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3806 } else {
3807 set et_vect_udot_hi_saved 0
3808 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3809 set et_vect_udot_hi_saved 1
3810 }
3811 }
3812 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3813 return $et_vect_udot_hi_saved
3814 }
3815
3816
3817 # Return 1 if the target plus current options supports a vector
3818 # demotion (packing) of shorts (to chars) and ints (to shorts)
3819 # using modulo arithmetic, 0 otherwise.
3820 #
3821 # This won't change for different subtargets so cache the result.
3822
3823 proc check_effective_target_vect_pack_trunc { } {
3824 global et_vect_pack_trunc
3825
3826 if [info exists et_vect_pack_trunc_saved] {
3827 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3828 } else {
3829 set et_vect_pack_trunc_saved 0
3830 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3831 || [istarget i?86-*-*]
3832 || [istarget x86_64-*-*]
3833 || [istarget aarch64*-*-*]
3834 || [istarget spu-*-*]
3835 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3836 && [check_effective_target_arm_little_endian]) } {
3837 set et_vect_pack_trunc_saved 1
3838 }
3839 }
3840 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3841 return $et_vect_pack_trunc_saved
3842 }
3843
3844 # Return 1 if the target plus current options supports a vector
3845 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3846 #
3847 # This won't change for different subtargets so cache the result.
3848
3849 proc check_effective_target_vect_unpack { } {
3850 global et_vect_unpack
3851
3852 if [info exists et_vect_unpack_saved] {
3853 verbose "check_effective_target_vect_unpack: using cached result" 2
3854 } else {
3855 set et_vect_unpack_saved 0
3856 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3857 || [istarget i?86-*-*]
3858 || [istarget x86_64-*-*]
3859 || [istarget spu-*-*]
3860 || [istarget ia64-*-*]
3861 || [istarget aarch64*-*-*]
3862 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3863 && [check_effective_target_arm_little_endian]) } {
3864 set et_vect_unpack_saved 1
3865 }
3866 }
3867 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3868 return $et_vect_unpack_saved
3869 }
3870
3871 # Return 1 if the target plus current options does not guarantee
3872 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3873 #
3874 # This won't change for different subtargets so cache the result.
3875
3876 proc check_effective_target_unaligned_stack { } {
3877 global et_unaligned_stack_saved
3878
3879 if [info exists et_unaligned_stack_saved] {
3880 verbose "check_effective_target_unaligned_stack: using cached result" 2
3881 } else {
3882 set et_unaligned_stack_saved 0
3883 }
3884 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3885 return $et_unaligned_stack_saved
3886 }
3887
3888 # Return 1 if the target plus current options does not support a vector
3889 # alignment mechanism, 0 otherwise.
3890 #
3891 # This won't change for different subtargets so cache the result.
3892
3893 proc check_effective_target_vect_no_align { } {
3894 global et_vect_no_align_saved
3895
3896 if [info exists et_vect_no_align_saved] {
3897 verbose "check_effective_target_vect_no_align: using cached result" 2
3898 } else {
3899 set et_vect_no_align_saved 0
3900 if { [istarget mipsisa64*-*-*]
3901 || [istarget mips-sde-elf]
3902 || [istarget sparc*-*-*]
3903 || [istarget ia64-*-*]
3904 || [check_effective_target_arm_vect_no_misalign]
3905 || ([istarget mips*-*-*]
3906 && [check_effective_target_mips_loongson]) } {
3907 set et_vect_no_align_saved 1
3908 }
3909 }
3910 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3911 return $et_vect_no_align_saved
3912 }
3913
3914 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3915 #
3916 # This won't change for different subtargets so cache the result.
3917
3918 proc check_effective_target_vect_hw_misalign { } {
3919 global et_vect_hw_misalign_saved
3920
3921 if [info exists et_vect_hw_misalign_saved] {
3922 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3923 } else {
3924 set et_vect_hw_misalign_saved 0
3925 if { ([istarget x86_64-*-*]
3926 || [istarget aarch64*-*-*]
3927 || [istarget i?86-*-*]) } {
3928 set et_vect_hw_misalign_saved 1
3929 }
3930 }
3931 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3932 return $et_vect_hw_misalign_saved
3933 }
3934
3935
3936 # Return 1 if arrays are aligned to the vector alignment
3937 # boundary, 0 otherwise.
3938 #
3939 # This won't change for different subtargets so cache the result.
3940
3941 proc check_effective_target_vect_aligned_arrays { } {
3942 global et_vect_aligned_arrays
3943
3944 if [info exists et_vect_aligned_arrays_saved] {
3945 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3946 } else {
3947 set et_vect_aligned_arrays_saved 0
3948 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3949 if { ([is-effective-target lp64]
3950 && ( ![check_avx_available]
3951 || [check_prefer_avx128])) } {
3952 set et_vect_aligned_arrays_saved 1
3953 }
3954 }
3955 if [istarget spu-*-*] {
3956 set et_vect_aligned_arrays_saved 1
3957 }
3958 }
3959 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3960 return $et_vect_aligned_arrays_saved
3961 }
3962
3963 # Return 1 if types of size 32 bit or less are naturally aligned
3964 # (aligned to their type-size), 0 otherwise.
3965 #
3966 # This won't change for different subtargets so cache the result.
3967
3968 proc check_effective_target_natural_alignment_32 { } {
3969 global et_natural_alignment_32
3970
3971 if [info exists et_natural_alignment_32_saved] {
3972 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3973 } else {
3974 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3975 set et_natural_alignment_32_saved 1
3976 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3977 set et_natural_alignment_32_saved 0
3978 }
3979 }
3980 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3981 return $et_natural_alignment_32_saved
3982 }
3983
3984 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3985 # type-size), 0 otherwise.
3986 #
3987 # This won't change for different subtargets so cache the result.
3988
3989 proc check_effective_target_natural_alignment_64 { } {
3990 global et_natural_alignment_64
3991
3992 if [info exists et_natural_alignment_64_saved] {
3993 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3994 } else {
3995 set et_natural_alignment_64_saved 0
3996 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3997 || [istarget spu-*-*] } {
3998 set et_natural_alignment_64_saved 1
3999 }
4000 }
4001 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
4002 return $et_natural_alignment_64_saved
4003 }
4004
4005 # Return 1 if all vector types are naturally aligned (aligned to their
4006 # type-size), 0 otherwise.
4007 #
4008 # This won't change for different subtargets so cache the result.
4009
4010 proc check_effective_target_vect_natural_alignment { } {
4011 global et_vect_natural_alignment
4012
4013 if [info exists et_vect_natural_alignment_saved] {
4014 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
4015 } else {
4016 set et_vect_natural_alignment_saved 1
4017 if { [check_effective_target_arm_eabi] } {
4018 set et_vect_natural_alignment_saved 0
4019 }
4020 }
4021 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
4022 return $et_vect_natural_alignment_saved
4023 }
4024
4025 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
4026 #
4027 # This won't change for different subtargets so cache the result.
4028
4029 proc check_effective_target_vector_alignment_reachable { } {
4030 global et_vector_alignment_reachable
4031
4032 if [info exists et_vector_alignment_reachable_saved] {
4033 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
4034 } else {
4035 if { [check_effective_target_vect_aligned_arrays]
4036 || [check_effective_target_natural_alignment_32] } {
4037 set et_vector_alignment_reachable_saved 1
4038 } else {
4039 set et_vector_alignment_reachable_saved 0
4040 }
4041 }
4042 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
4043 return $et_vector_alignment_reachable_saved
4044 }
4045
4046 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
4047 #
4048 # This won't change for different subtargets so cache the result.
4049
4050 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
4051 global et_vector_alignment_reachable_for_64bit
4052
4053 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
4054 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
4055 } else {
4056 if { [check_effective_target_vect_aligned_arrays]
4057 || [check_effective_target_natural_alignment_64] } {
4058 set et_vector_alignment_reachable_for_64bit_saved 1
4059 } else {
4060 set et_vector_alignment_reachable_for_64bit_saved 0
4061 }
4062 }
4063 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
4064 return $et_vector_alignment_reachable_for_64bit_saved
4065 }
4066
4067 # Return 1 if the target only requires element alignment for vector accesses
4068
4069 proc check_effective_target_vect_element_align { } {
4070 global et_vect_element_align
4071
4072 if [info exists et_vect_element_align] {
4073 verbose "check_effective_target_vect_element_align: using cached result" 2
4074 } else {
4075 set et_vect_element_align 0
4076 if { ([istarget arm*-*-*]
4077 && ![check_effective_target_arm_vect_no_misalign])
4078 || [check_effective_target_vect_hw_misalign] } {
4079 set et_vect_element_align 1
4080 }
4081 }
4082
4083 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4084 return $et_vect_element_align
4085 }
4086
4087 # Return 1 if the target supports vector conditional operations, 0 otherwise.
4088
4089 proc check_effective_target_vect_condition { } {
4090 global et_vect_cond_saved
4091
4092 if [info exists et_vect_cond_saved] {
4093 verbose "check_effective_target_vect_cond: using cached result" 2
4094 } else {
4095 set et_vect_cond_saved 0
4096 if { [istarget aarch64*-*-*]
4097 || [istarget powerpc*-*-*]
4098 || [istarget ia64-*-*]
4099 || [istarget i?86-*-*]
4100 || [istarget spu-*-*]
4101 || [istarget x86_64-*-*]
4102 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4103 set et_vect_cond_saved 1
4104 }
4105 }
4106
4107 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
4108 return $et_vect_cond_saved
4109 }
4110
4111 # Return 1 if the target supports vector conditional operations where
4112 # the comparison has different type from the lhs, 0 otherwise.
4113
4114 proc check_effective_target_vect_cond_mixed { } {
4115 global et_vect_cond_mixed_saved
4116
4117 if [info exists et_vect_cond_mixed_saved] {
4118 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
4119 } else {
4120 set et_vect_cond_mixed_saved 0
4121 if { [istarget i?86-*-*]
4122 || [istarget x86_64-*-*]
4123 || [istarget powerpc*-*-*] } {
4124 set et_vect_cond_mixed_saved 1
4125 }
4126 }
4127
4128 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
4129 return $et_vect_cond_mixed_saved
4130 }
4131
4132 # Return 1 if the target supports vector char multiplication, 0 otherwise.
4133
4134 proc check_effective_target_vect_char_mult { } {
4135 global et_vect_char_mult_saved
4136
4137 if [info exists et_vect_char_mult_saved] {
4138 verbose "check_effective_target_vect_char_mult: using cached result" 2
4139 } else {
4140 set et_vect_char_mult_saved 0
4141 if { [istarget aarch64*-*-*]
4142 || [istarget ia64-*-*]
4143 || [istarget i?86-*-*]
4144 || [istarget x86_64-*-*]
4145 || [check_effective_target_arm32] } {
4146 set et_vect_char_mult_saved 1
4147 }
4148 }
4149
4150 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4151 return $et_vect_char_mult_saved
4152 }
4153
4154 # Return 1 if the target supports vector short multiplication, 0 otherwise.
4155
4156 proc check_effective_target_vect_short_mult { } {
4157 global et_vect_short_mult_saved
4158
4159 if [info exists et_vect_short_mult_saved] {
4160 verbose "check_effective_target_vect_short_mult: using cached result" 2
4161 } else {
4162 set et_vect_short_mult_saved 0
4163 if { [istarget ia64-*-*]
4164 || [istarget spu-*-*]
4165 || [istarget i?86-*-*]
4166 || [istarget x86_64-*-*]
4167 || [istarget powerpc*-*-*]
4168 || [istarget aarch64*-*-*]
4169 || [check_effective_target_arm32]
4170 || ([istarget mips*-*-*]
4171 && [check_effective_target_mips_loongson]) } {
4172 set et_vect_short_mult_saved 1
4173 }
4174 }
4175
4176 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4177 return $et_vect_short_mult_saved
4178 }
4179
4180 # Return 1 if the target supports vector int multiplication, 0 otherwise.
4181
4182 proc check_effective_target_vect_int_mult { } {
4183 global et_vect_int_mult_saved
4184
4185 if [info exists et_vect_int_mult_saved] {
4186 verbose "check_effective_target_vect_int_mult: using cached result" 2
4187 } else {
4188 set et_vect_int_mult_saved 0
4189 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4190 || [istarget spu-*-*]
4191 || [istarget i?86-*-*]
4192 || [istarget x86_64-*-*]
4193 || [istarget ia64-*-*]
4194 || [istarget aarch64*-*-*]
4195 || [check_effective_target_arm32] } {
4196 set et_vect_int_mult_saved 1
4197 }
4198 }
4199
4200 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4201 return $et_vect_int_mult_saved
4202 }
4203
4204 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
4205
4206 proc check_effective_target_vect_extract_even_odd { } {
4207 global et_vect_extract_even_odd_saved
4208
4209 if [info exists et_vect_extract_even_odd_saved] {
4210 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
4211 } else {
4212 set et_vect_extract_even_odd_saved 0
4213 if { [istarget aarch64*-*-*]
4214 || [istarget powerpc*-*-*]
4215 || [is-effective-target arm_neon_ok]
4216 || [istarget i?86-*-*]
4217 || [istarget x86_64-*-*]
4218 || [istarget ia64-*-*]
4219 || [istarget spu-*-*]
4220 || ([istarget mips*-*-*]
4221 && [check_effective_target_mpaired_single]) } {
4222 set et_vect_extract_even_odd_saved 1
4223 }
4224 }
4225
4226 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4227 return $et_vect_extract_even_odd_saved
4228 }
4229
4230 # Return 1 if the target supports vector interleaving, 0 otherwise.
4231
4232 proc check_effective_target_vect_interleave { } {
4233 global et_vect_interleave_saved
4234
4235 if [info exists et_vect_interleave_saved] {
4236 verbose "check_effective_target_vect_interleave: using cached result" 2
4237 } else {
4238 set et_vect_interleave_saved 0
4239 if { [istarget aarch64*-*-*]
4240 || [istarget powerpc*-*-*]
4241 || [is-effective-target arm_neon_ok]
4242 || [istarget i?86-*-*]
4243 || [istarget x86_64-*-*]
4244 || [istarget ia64-*-*]
4245 || [istarget spu-*-*]
4246 || ([istarget mips*-*-*]
4247 && [check_effective_target_mpaired_single]) } {
4248 set et_vect_interleave_saved 1
4249 }
4250 }
4251
4252 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4253 return $et_vect_interleave_saved
4254 }
4255
4256 foreach N {2 3 4 8} {
4257 eval [string map [list N $N] {
4258 # Return 1 if the target supports 2-vector interleaving
4259 proc check_effective_target_vect_stridedN { } {
4260 global et_vect_stridedN_saved
4261
4262 if [info exists et_vect_stridedN_saved] {
4263 verbose "check_effective_target_vect_stridedN: using cached result" 2
4264 } else {
4265 set et_vect_stridedN_saved 0
4266 if { (N & -N) == N
4267 && [check_effective_target_vect_interleave]
4268 && [check_effective_target_vect_extract_even_odd] } {
4269 set et_vect_stridedN_saved 1
4270 }
4271 if { ([istarget arm*-*-*]
4272 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
4273 set et_vect_stridedN_saved 1
4274 }
4275 }
4276
4277 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4278 return $et_vect_stridedN_saved
4279 }
4280 }]
4281 }
4282
4283 # Return 1 if the target supports multiple vector sizes
4284
4285 proc check_effective_target_vect_multiple_sizes { } {
4286 global et_vect_multiple_sizes_saved
4287
4288 set et_vect_multiple_sizes_saved 0
4289 if { ([istarget aarch64*-*-*]
4290 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
4291 set et_vect_multiple_sizes_saved 1
4292 }
4293 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4294 if { ([check_avx_available] && ![check_prefer_avx128]) } {
4295 set et_vect_multiple_sizes_saved 1
4296 }
4297 }
4298
4299 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4300 return $et_vect_multiple_sizes_saved
4301 }
4302
4303 # Return 1 if the target supports vectors of 64 bits.
4304
4305 proc check_effective_target_vect64 { } {
4306 global et_vect64_saved
4307
4308 if [info exists et_vect64_saved] {
4309 verbose "check_effective_target_vect64: using cached result" 2
4310 } else {
4311 set et_vect64_saved 0
4312 if { ([istarget arm*-*-*]
4313 && [check_effective_target_arm_neon_ok]
4314 && [check_effective_target_arm_little_endian]) } {
4315 set et_vect64_saved 1
4316 }
4317 }
4318
4319 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
4320 return $et_vect64_saved
4321 }
4322
4323 # Return 1 if the target supports vector copysignf calls.
4324
4325 proc check_effective_target_vect_call_copysignf { } {
4326 global et_vect_call_copysignf_saved
4327
4328 if [info exists et_vect_call_copysignf_saved] {
4329 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
4330 } else {
4331 set et_vect_call_copysignf_saved 0
4332 if { [istarget i?86-*-*]
4333 || [istarget x86_64-*-*]
4334 || [istarget powerpc*-*-*] } {
4335 set et_vect_call_copysignf_saved 1
4336 }
4337 }
4338
4339 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4340 return $et_vect_call_copysignf_saved
4341 }
4342
4343 # Return 1 if the target supports vector sqrtf calls.
4344
4345 proc check_effective_target_vect_call_sqrtf { } {
4346 global et_vect_call_sqrtf_saved
4347
4348 if [info exists et_vect_call_sqrtf_saved] {
4349 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
4350 } else {
4351 set et_vect_call_sqrtf_saved 0
4352 if { [istarget aarch64*-*-*]
4353 || [istarget i?86-*-*]
4354 || [istarget x86_64-*-*]
4355 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
4356 set et_vect_call_sqrtf_saved 1
4357 }
4358 }
4359
4360 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4361 return $et_vect_call_sqrtf_saved
4362 }
4363
4364 # Return 1 if the target supports vector lrint calls.
4365
4366 proc check_effective_target_vect_call_lrint { } {
4367 set et_vect_call_lrint 0
4368 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
4369 set et_vect_call_lrint 1
4370 }
4371
4372 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4373 return $et_vect_call_lrint
4374 }
4375
4376 # Return 1 if the target supports vector btrunc calls.
4377
4378 proc check_effective_target_vect_call_btrunc { } {
4379 global et_vect_call_btrunc_saved
4380
4381 if [info exists et_vect_call_btrunc_saved] {
4382 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4383 } else {
4384 set et_vect_call_btrunc_saved 0
4385 if { [istarget aarch64*-*-*] } {
4386 set et_vect_call_btrunc_saved 1
4387 }
4388 }
4389
4390 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4391 return $et_vect_call_btrunc_saved
4392 }
4393
4394 # Return 1 if the target supports vector btruncf calls.
4395
4396 proc check_effective_target_vect_call_btruncf { } {
4397 global et_vect_call_btruncf_saved
4398
4399 if [info exists et_vect_call_btruncf_saved] {
4400 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4401 } else {
4402 set et_vect_call_btruncf_saved 0
4403 if { [istarget aarch64*-*-*] } {
4404 set et_vect_call_btruncf_saved 1
4405 }
4406 }
4407
4408 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4409 return $et_vect_call_btruncf_saved
4410 }
4411
4412 # Return 1 if the target supports vector ceil calls.
4413
4414 proc check_effective_target_vect_call_ceil { } {
4415 global et_vect_call_ceil_saved
4416
4417 if [info exists et_vect_call_ceil_saved] {
4418 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4419 } else {
4420 set et_vect_call_ceil_saved 0
4421 if { [istarget aarch64*-*-*] } {
4422 set et_vect_call_ceil_saved 1
4423 }
4424 }
4425
4426 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4427 return $et_vect_call_ceil_saved
4428 }
4429
4430 # Return 1 if the target supports vector ceilf calls.
4431
4432 proc check_effective_target_vect_call_ceilf { } {
4433 global et_vect_call_ceilf_saved
4434
4435 if [info exists et_vect_call_ceilf_saved] {
4436 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4437 } else {
4438 set et_vect_call_ceilf_saved 0
4439 if { [istarget aarch64*-*-*] } {
4440 set et_vect_call_ceilf_saved 1
4441 }
4442 }
4443
4444 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4445 return $et_vect_call_ceilf_saved
4446 }
4447
4448 # Return 1 if the target supports vector floor calls.
4449
4450 proc check_effective_target_vect_call_floor { } {
4451 global et_vect_call_floor_saved
4452
4453 if [info exists et_vect_call_floor_saved] {
4454 verbose "check_effective_target_vect_call_floor: using cached result" 2
4455 } else {
4456 set et_vect_call_floor_saved 0
4457 if { [istarget aarch64*-*-*] } {
4458 set et_vect_call_floor_saved 1
4459 }
4460 }
4461
4462 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4463 return $et_vect_call_floor_saved
4464 }
4465
4466 # Return 1 if the target supports vector floorf calls.
4467
4468 proc check_effective_target_vect_call_floorf { } {
4469 global et_vect_call_floorf_saved
4470
4471 if [info exists et_vect_call_floorf_saved] {
4472 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4473 } else {
4474 set et_vect_call_floorf_saved 0
4475 if { [istarget aarch64*-*-*] } {
4476 set et_vect_call_floorf_saved 1
4477 }
4478 }
4479
4480 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4481 return $et_vect_call_floorf_saved
4482 }
4483
4484 # Return 1 if the target supports vector lceil calls.
4485
4486 proc check_effective_target_vect_call_lceil { } {
4487 global et_vect_call_lceil_saved
4488
4489 if [info exists et_vect_call_lceil_saved] {
4490 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4491 } else {
4492 set et_vect_call_lceil_saved 0
4493 if { [istarget aarch64*-*-*] } {
4494 set et_vect_call_lceil_saved 1
4495 }
4496 }
4497
4498 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4499 return $et_vect_call_lceil_saved
4500 }
4501
4502 # Return 1 if the target supports vector lfloor calls.
4503
4504 proc check_effective_target_vect_call_lfloor { } {
4505 global et_vect_call_lfloor_saved
4506
4507 if [info exists et_vect_call_lfloor_saved] {
4508 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4509 } else {
4510 set et_vect_call_lfloor_saved 0
4511 if { [istarget aarch64*-*-*] } {
4512 set et_vect_call_lfloor_saved 1
4513 }
4514 }
4515
4516 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4517 return $et_vect_call_lfloor_saved
4518 }
4519
4520 # Return 1 if the target supports vector nearbyint calls.
4521
4522 proc check_effective_target_vect_call_nearbyint { } {
4523 global et_vect_call_nearbyint_saved
4524
4525 if [info exists et_vect_call_nearbyint_saved] {
4526 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
4527 } else {
4528 set et_vect_call_nearbyint_saved 0
4529 if { [istarget aarch64*-*-*] } {
4530 set et_vect_call_nearbyint_saved 1
4531 }
4532 }
4533
4534 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4535 return $et_vect_call_nearbyint_saved
4536 }
4537
4538 # Return 1 if the target supports vector nearbyintf calls.
4539
4540 proc check_effective_target_vect_call_nearbyintf { } {
4541 global et_vect_call_nearbyintf_saved
4542
4543 if [info exists et_vect_call_nearbyintf_saved] {
4544 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
4545 } else {
4546 set et_vect_call_nearbyintf_saved 0
4547 if { [istarget aarch64*-*-*] } {
4548 set et_vect_call_nearbyintf_saved 1
4549 }
4550 }
4551
4552 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4553 return $et_vect_call_nearbyintf_saved
4554 }
4555
4556 # Return 1 if the target supports vector round calls.
4557
4558 proc check_effective_target_vect_call_round { } {
4559 global et_vect_call_round_saved
4560
4561 if [info exists et_vect_call_round_saved] {
4562 verbose "check_effective_target_vect_call_round: using cached result" 2
4563 } else {
4564 set et_vect_call_round_saved 0
4565 if { [istarget aarch64*-*-*] } {
4566 set et_vect_call_round_saved 1
4567 }
4568 }
4569
4570 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
4571 return $et_vect_call_round_saved
4572 }
4573
4574 # Return 1 if the target supports vector roundf calls.
4575
4576 proc check_effective_target_vect_call_roundf { } {
4577 global et_vect_call_roundf_saved
4578
4579 if [info exists et_vect_call_roundf_saved] {
4580 verbose "check_effective_target_vect_call_roundf: using cached result" 2
4581 } else {
4582 set et_vect_call_roundf_saved 0
4583 if { [istarget aarch64*-*-*] } {
4584 set et_vect_call_roundf_saved 1
4585 }
4586 }
4587
4588 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
4589 return $et_vect_call_roundf_saved
4590 }
4591
4592 # Return 1 if the target supports section-anchors
4593
4594 proc check_effective_target_section_anchors { } {
4595 global et_section_anchors_saved
4596
4597 if [info exists et_section_anchors_saved] {
4598 verbose "check_effective_target_section_anchors: using cached result" 2
4599 } else {
4600 set et_section_anchors_saved 0
4601 if { [istarget powerpc*-*-*]
4602 || [istarget arm*-*-*] } {
4603 set et_section_anchors_saved 1
4604 }
4605 }
4606
4607 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
4608 return $et_section_anchors_saved
4609 }
4610
4611 # Return 1 if the target supports atomic operations on "int_128" values.
4612
4613 proc check_effective_target_sync_int_128 { } {
4614 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4615 && ![is-effective-target ia32] } {
4616 return 1
4617 } else {
4618 return 0
4619 }
4620 }
4621
4622 # Return 1 if the target supports atomic operations on "int_128" values
4623 # and can execute them.
4624
4625 proc check_effective_target_sync_int_128_runtime { } {
4626 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4627 && ![is-effective-target ia32] } {
4628 return [check_cached_effective_target sync_int_128_available {
4629 check_runtime_nocache sync_int_128_available {
4630 #include "cpuid.h"
4631 int main ()
4632 {
4633 unsigned int eax, ebx, ecx, edx;
4634 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4635 return !(ecx & bit_CMPXCHG16B);
4636 return 1;
4637 }
4638 } ""
4639 }]
4640 } else {
4641 return 0
4642 }
4643 }
4644
4645 # Return 1 if the target supports atomic operations on "long long".
4646 #
4647 # Note: 32bit x86 targets require -march=pentium in dg-options.
4648
4649 proc check_effective_target_sync_long_long { } {
4650 if { [istarget x86_64-*-*]
4651 || [istarget i?86-*-*])
4652 || [istarget aarch64*-*-*]
4653 || [istarget arm*-*-*]
4654 || [istarget alpha*-*-*]
4655 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
4656 return 1
4657 } else {
4658 return 0
4659 }
4660 }
4661
4662 # Return 1 if the target supports atomic operations on "long long"
4663 # and can execute them.
4664 #
4665 # Note: 32bit x86 targets require -march=pentium in dg-options.
4666
4667 proc check_effective_target_sync_long_long_runtime { } {
4668 if { [istarget x86_64-*-*]
4669 || [istarget i?86-*-*] } {
4670 return [check_cached_effective_target sync_long_long_available {
4671 check_runtime_nocache sync_long_long_available {
4672 #include "cpuid.h"
4673 int main ()
4674 {
4675 unsigned int eax, ebx, ecx, edx;
4676 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4677 return !(edx & bit_CMPXCHG8B);
4678 return 1;
4679 }
4680 } ""
4681 }]
4682 } elseif { [istarget aarch64*-*-*] } {
4683 return 1
4684 } elseif { [istarget arm*-*-linux-*] } {
4685 return [check_runtime sync_longlong_runtime {
4686 #include <stdlib.h>
4687 int main ()
4688 {
4689 long long l1;
4690
4691 if (sizeof (long long) != 8)
4692 exit (1);
4693
4694 /* Just check for native; checking for kernel fallback is tricky. */
4695 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
4696
4697 exit (0);
4698 }
4699 } "" ]
4700 } elseif { [istarget alpha*-*-*] } {
4701 return 1
4702 } elseif { ([istarget sparc*-*-*]
4703 && [check_effective_target_lp64]
4704 && [check_effective_target_ultrasparc_hw]) } {
4705 return 1
4706 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
4707 return 1
4708 } else {
4709 return 0
4710 }
4711 }
4712
4713 # Return 1 if the target supports atomic operations on "int" and "long".
4714
4715 proc check_effective_target_sync_int_long { } {
4716 global et_sync_int_long_saved
4717
4718 if [info exists et_sync_int_long_saved] {
4719 verbose "check_effective_target_sync_int_long: using cached result" 2
4720 } else {
4721 set et_sync_int_long_saved 0
4722 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4723 # load-reserved/store-conditional instructions.
4724 if { [istarget ia64-*-*]
4725 || [istarget i?86-*-*]
4726 || [istarget x86_64-*-*]
4727 || [istarget aarch64*-*-*]
4728 || [istarget alpha*-*-*]
4729 || [istarget arm*-*-linux-*]
4730 || [istarget bfin*-*linux*]
4731 || [istarget hppa*-*linux*]
4732 || [istarget s390*-*-*]
4733 || [istarget powerpc*-*-*]
4734 || [istarget crisv32-*-*] || [istarget cris-*-*]
4735 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4736 || [check_effective_target_mips_llsc] } {
4737 set et_sync_int_long_saved 1
4738 }
4739 }
4740
4741 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
4742 return $et_sync_int_long_saved
4743 }
4744
4745 # Return 1 if the target supports atomic operations on "char" and "short".
4746
4747 proc check_effective_target_sync_char_short { } {
4748 global et_sync_char_short_saved
4749
4750 if [info exists et_sync_char_short_saved] {
4751 verbose "check_effective_target_sync_char_short: using cached result" 2
4752 } else {
4753 set et_sync_char_short_saved 0
4754 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4755 # load-reserved/store-conditional instructions.
4756 if { [istarget aarch64*-*-*]
4757 || [istarget ia64-*-*]
4758 || [istarget i?86-*-*]
4759 || [istarget x86_64-*-*]
4760 || [istarget alpha*-*-*]
4761 || [istarget arm*-*-linux-*]
4762 || [istarget hppa*-*linux*]
4763 || [istarget s390*-*-*]
4764 || [istarget powerpc*-*-*]
4765 || [istarget crisv32-*-*] || [istarget cris-*-*]
4766 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4767 || [check_effective_target_mips_llsc] } {
4768 set et_sync_char_short_saved 1
4769 }
4770 }
4771
4772 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
4773 return $et_sync_char_short_saved
4774 }
4775
4776 # Return 1 if the target uses a ColdFire FPU.
4777
4778 proc check_effective_target_coldfire_fpu { } {
4779 return [check_no_compiler_messages coldfire_fpu assembly {
4780 #ifndef __mcffpu__
4781 #error FOO
4782 #endif
4783 }]
4784 }
4785
4786 # Return true if this is a uClibc target.
4787
4788 proc check_effective_target_uclibc {} {
4789 return [check_no_compiler_messages uclibc object {
4790 #include <features.h>
4791 #if !defined (__UCLIBC__)
4792 #error FOO
4793 #endif
4794 }]
4795 }
4796
4797 # Return true if this is a uclibc target and if the uclibc feature
4798 # described by __$feature__ is not present.
4799
4800 proc check_missing_uclibc_feature {feature} {
4801 return [check_no_compiler_messages $feature object "
4802 #include <features.h>
4803 #if !defined (__UCLIBC) || defined (__${feature}__)
4804 #error FOO
4805 #endif
4806 "]
4807 }
4808
4809 # Return true if this is a Newlib target.
4810
4811 proc check_effective_target_newlib {} {
4812 return [check_no_compiler_messages newlib object {
4813 #include <newlib.h>
4814 }]
4815 }
4816
4817 # Return true if this is NOT a Bionic target.
4818
4819 proc check_effective_target_non_bionic {} {
4820 return [check_no_compiler_messages non_bionic object {
4821 #include <ctype.h>
4822 #if defined (__BIONIC__)
4823 #error FOO
4824 #endif
4825 }]
4826 }
4827
4828 # Return 1 if
4829 # (a) an error of a few ULP is expected in string to floating-point
4830 # conversion functions; and
4831 # (b) overflow is not always detected correctly by those functions.
4832
4833 proc check_effective_target_lax_strtofp {} {
4834 # By default, assume that all uClibc targets suffer from this.
4835 return [check_effective_target_uclibc]
4836 }
4837
4838 # Return 1 if this is a target for which wcsftime is a dummy
4839 # function that always returns 0.
4840
4841 proc check_effective_target_dummy_wcsftime {} {
4842 # By default, assume that all uClibc targets suffer from this.
4843 return [check_effective_target_uclibc]
4844 }
4845
4846 # Return 1 if constructors with initialization priority arguments are
4847 # supposed on this target.
4848
4849 proc check_effective_target_init_priority {} {
4850 return [check_no_compiler_messages init_priority assembly "
4851 void f() __attribute__((constructor (1000)));
4852 void f() \{\}
4853 "]
4854 }
4855
4856 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
4857 # This can be used with any check_* proc that takes no argument and
4858 # returns only 1 or 0. It could be used with check_* procs that take
4859 # arguments with keywords that pass particular arguments.
4860
4861 proc is-effective-target { arg } {
4862 set selected 0
4863 if { [info procs check_effective_target_${arg}] != [list] } {
4864 set selected [check_effective_target_${arg}]
4865 } else {
4866 switch $arg {
4867 "vmx_hw" { set selected [check_vmx_hw_available] }
4868 "vsx_hw" { set selected [check_vsx_hw_available] }
4869 "p8vector_hw" { set selected [check_p8vector_hw_available] }
4870 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
4871 "named_sections" { set selected [check_named_sections_available] }
4872 "gc_sections" { set selected [check_gc_sections_available] }
4873 "cxa_atexit" { set selected [check_cxa_atexit_available] }
4874 default { error "unknown effective target keyword `$arg'" }
4875 }
4876 }
4877 verbose "is-effective-target: $arg $selected" 2
4878 return $selected
4879 }
4880
4881 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
4882
4883 proc is-effective-target-keyword { arg } {
4884 if { [info procs check_effective_target_${arg}] != [list] } {
4885 return 1
4886 } else {
4887 # These have different names for their check_* procs.
4888 switch $arg {
4889 "vmx_hw" { return 1 }
4890 "vsx_hw" { return 1 }
4891 "p8vector_hw" { return 1 }
4892 "ppc_recip_hw" { return 1 }
4893 "named_sections" { return 1 }
4894 "gc_sections" { return 1 }
4895 "cxa_atexit" { return 1 }
4896 default { return 0 }
4897 }
4898 }
4899 }
4900
4901 # Return 1 if target default to short enums
4902
4903 proc check_effective_target_short_enums { } {
4904 return [check_no_compiler_messages short_enums assembly {
4905 enum foo { bar };
4906 int s[sizeof (enum foo) == 1 ? 1 : -1];
4907 }]
4908 }
4909
4910 # Return 1 if target supports merging string constants at link time.
4911
4912 proc check_effective_target_string_merging { } {
4913 return [check_no_messages_and_pattern string_merging \
4914 "rodata\\.str" assembly {
4915 const char *var = "String";
4916 } {-O2}]
4917 }
4918
4919 # Return 1 if target has the basic signed and unsigned types in
4920 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
4921 # working <stdint.h> for all targets.
4922
4923 proc check_effective_target_stdint_types { } {
4924 return [check_no_compiler_messages stdint_types assembly {
4925 #include <stdint.h>
4926 int8_t a; int16_t b; int32_t c; int64_t d;
4927 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4928 }]
4929 }
4930
4931 # Return 1 if target has the basic signed and unsigned types in
4932 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
4933 # these types agree with those in the header, as some systems have
4934 # only <inttypes.h>.
4935
4936 proc check_effective_target_inttypes_types { } {
4937 return [check_no_compiler_messages inttypes_types assembly {
4938 #include <inttypes.h>
4939 int8_t a; int16_t b; int32_t c; int64_t d;
4940 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4941 }]
4942 }
4943
4944 # Return 1 if programs are intended to be run on a simulator
4945 # (i.e. slowly) rather than hardware (i.e. fast).
4946
4947 proc check_effective_target_simulator { } {
4948
4949 # All "src/sim" simulators set this one.
4950 if [board_info target exists is_simulator] {
4951 return [board_info target is_simulator]
4952 }
4953
4954 # The "sid" simulators don't set that one, but at least they set
4955 # this one.
4956 if [board_info target exists slow_simulator] {
4957 return [board_info target slow_simulator]
4958 }
4959
4960 return 0
4961 }
4962
4963 # Return 1 if programs are intended to be run on hardware rather than
4964 # on a simulator
4965
4966 proc check_effective_target_hw { } {
4967
4968 # All "src/sim" simulators set this one.
4969 if [board_info target exists is_simulator] {
4970 if [board_info target is_simulator] {
4971 return 0
4972 } else {
4973 return 1
4974 }
4975 }
4976
4977 # The "sid" simulators don't set that one, but at least they set
4978 # this one.
4979 if [board_info target exists slow_simulator] {
4980 if [board_info target slow_simulator] {
4981 return 0
4982 } else {
4983 return 1
4984 }
4985 }
4986
4987 return 1
4988 }
4989
4990 # Return 1 if the target is a VxWorks kernel.
4991
4992 proc check_effective_target_vxworks_kernel { } {
4993 return [check_no_compiler_messages vxworks_kernel assembly {
4994 #if !defined __vxworks || defined __RTP__
4995 #error NO
4996 #endif
4997 }]
4998 }
4999
5000 # Return 1 if the target is a VxWorks RTP.
5001
5002 proc check_effective_target_vxworks_rtp { } {
5003 return [check_no_compiler_messages vxworks_rtp assembly {
5004 #if !defined __vxworks || !defined __RTP__
5005 #error NO
5006 #endif
5007 }]
5008 }
5009
5010 # Return 1 if the target is expected to provide wide character support.
5011
5012 proc check_effective_target_wchar { } {
5013 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
5014 return 0
5015 }
5016 return [check_no_compiler_messages wchar assembly {
5017 #include <wchar.h>
5018 }]
5019 }
5020
5021 # Return 1 if the target has <pthread.h>.
5022
5023 proc check_effective_target_pthread_h { } {
5024 return [check_no_compiler_messages pthread_h assembly {
5025 #include <pthread.h>
5026 }]
5027 }
5028
5029 # Return 1 if the target can truncate a file from a file-descriptor,
5030 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
5031 # chsize. We test for a trivially functional truncation; no stubs.
5032 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
5033 # different function to be used.
5034
5035 proc check_effective_target_fd_truncate { } {
5036 set prog {
5037 #define _FILE_OFFSET_BITS 64
5038 #include <unistd.h>
5039 #include <stdio.h>
5040 #include <stdlib.h>
5041 int main ()
5042 {
5043 FILE *f = fopen ("tst.tmp", "wb");
5044 int fd;
5045 const char t[] = "test writing more than ten characters";
5046 char s[11];
5047 int status = 0;
5048 fd = fileno (f);
5049 write (fd, t, sizeof (t) - 1);
5050 lseek (fd, 0, 0);
5051 if (ftruncate (fd, 10) != 0)
5052 status = 1;
5053 close (fd);
5054 fclose (f);
5055 if (status)
5056 {
5057 unlink ("tst.tmp");
5058 exit (status);
5059 }
5060 f = fopen ("tst.tmp", "rb");
5061 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
5062 status = 1;
5063 fclose (f);
5064 unlink ("tst.tmp");
5065 exit (status);
5066 }
5067 }
5068
5069 if { [check_runtime ftruncate $prog] } {
5070 return 1;
5071 }
5072
5073 regsub "ftruncate" $prog "chsize" prog
5074 return [check_runtime chsize $prog]
5075 }
5076
5077 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
5078
5079 proc add_options_for_c99_runtime { flags } {
5080 if { [istarget *-*-solaris2*] } {
5081 return "$flags -std=c99"
5082 }
5083 if { [istarget powerpc-*-darwin*] } {
5084 return "$flags -mmacosx-version-min=10.3"
5085 }
5086 return $flags
5087 }
5088
5089 # Add to FLAGS all the target-specific flags needed to enable
5090 # full IEEE compliance mode.
5091
5092 proc add_options_for_ieee { flags } {
5093 if { [istarget alpha*-*-*]
5094 || [istarget sh*-*-*] } {
5095 return "$flags -mieee"
5096 }
5097 if { [istarget rx-*-*] } {
5098 return "$flags -mnofpu"
5099 }
5100 return $flags
5101 }
5102
5103 # Add to FLAGS the flags needed to enable functions to bind locally
5104 # when using pic/PIC passes in the testsuite.
5105
5106 proc add_options_for_bind_pic_locally { flags } {
5107 if {[check_no_compiler_messages using_pic2 assembly {
5108 #if __PIC__ != 2
5109 #error FOO
5110 #endif
5111 }]} {
5112 return "$flags -fPIE"
5113 }
5114 if {[check_no_compiler_messages using_pic1 assembly {
5115 #if __PIC__ != 1
5116 #error FOO
5117 #endif
5118 }]} {
5119 return "$flags -fpie"
5120 }
5121
5122 return $flags
5123 }
5124
5125 # Add to FLAGS the flags needed to enable 64-bit vectors.
5126
5127 proc add_options_for_double_vectors { flags } {
5128 if [is-effective-target arm_neon_ok] {
5129 return "$flags -mvectorize-with-neon-double"
5130 }
5131
5132 return $flags
5133 }
5134
5135 # Return 1 if the target provides a full C99 runtime.
5136
5137 proc check_effective_target_c99_runtime { } {
5138 return [check_cached_effective_target c99_runtime {
5139 global srcdir
5140
5141 set file [open "$srcdir/gcc.dg/builtins-config.h"]
5142 set contents [read $file]
5143 close $file
5144 append contents {
5145 #ifndef HAVE_C99_RUNTIME
5146 #error FOO
5147 #endif
5148 }
5149 check_no_compiler_messages_nocache c99_runtime assembly \
5150 $contents [add_options_for_c99_runtime ""]
5151 }]
5152 }
5153
5154 # Return 1 if target wchar_t is at least 4 bytes.
5155
5156 proc check_effective_target_4byte_wchar_t { } {
5157 return [check_no_compiler_messages 4byte_wchar_t object {
5158 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
5159 }]
5160 }
5161
5162 # Return 1 if the target supports automatic stack alignment.
5163
5164 proc check_effective_target_automatic_stack_alignment { } {
5165 # Ordinarily x86 supports automatic stack alignment ...
5166 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
5167 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
5168 # ... except Win64 SEH doesn't. Succeed for Win32 though.
5169 return [check_effective_target_ilp32];
5170 }
5171 return 1;
5172 }
5173 return 0;
5174 }
5175
5176 # Return true if we are compiling for AVX target.
5177
5178 proc check_avx_available { } {
5179 if { [check_no_compiler_messages avx_available assembly {
5180 #ifndef __AVX__
5181 #error unsupported
5182 #endif
5183 } ""] } {
5184 return 1;
5185 }
5186 return 0;
5187 }
5188
5189 # Return true if 32- and 16-bytes vectors are available.
5190
5191 proc check_effective_target_vect_sizes_32B_16B { } {
5192 return [check_avx_available];
5193 }
5194
5195 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5196 # are available.
5197
5198 proc check_prefer_avx128 { } {
5199 if ![check_avx_available] {
5200 return 0;
5201 }
5202 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5203 float a[1024],b[1024],c[1024];
5204 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5205 } "-O2 -ftree-vectorize"]
5206 }
5207
5208
5209 # Return 1 if avx512f instructions can be compiled.
5210
5211 proc check_effective_target_avx512f { } {
5212 return [check_no_compiler_messages avx512f object {
5213 typedef double __m512d __attribute__ ((__vector_size__ (64)));
5214
5215 __m512d _mm512_add (__m512d a)
5216 {
5217 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
5218 }
5219 } "-O2 -mavx512f" ]
5220 }
5221
5222 # Return 1 if avx instructions can be compiled.
5223
5224 proc check_effective_target_avx { } {
5225 return [check_no_compiler_messages avx object {
5226 void _mm256_zeroall (void)
5227 {
5228 __builtin_ia32_vzeroall ();
5229 }
5230 } "-O2 -mavx" ]
5231 }
5232
5233 # Return 1 if avx2 instructions can be compiled.
5234 proc check_effective_target_avx2 { } {
5235 return [check_no_compiler_messages avx2 object {
5236 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
5237 __v4di
5238 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
5239 {
5240 return __builtin_ia32_andnotsi256 (__X, __Y);
5241 }
5242 } "-O0 -mavx2" ]
5243 }
5244
5245 # Return 1 if sse instructions can be compiled.
5246 proc check_effective_target_sse { } {
5247 return [check_no_compiler_messages sse object {
5248 int main ()
5249 {
5250 __builtin_ia32_stmxcsr ();
5251 return 0;
5252 }
5253 } "-O2 -msse" ]
5254 }
5255
5256 # Return 1 if sse2 instructions can be compiled.
5257 proc check_effective_target_sse2 { } {
5258 return [check_no_compiler_messages sse2 object {
5259 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5260
5261 __m128i _mm_srli_si128 (__m128i __A, int __N)
5262 {
5263 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5264 }
5265 } "-O2 -msse2" ]
5266 }
5267
5268 # Return 1 if F16C instructions can be compiled.
5269
5270 proc check_effective_target_f16c { } {
5271 return [check_no_compiler_messages f16c object {
5272 #include "immintrin.h"
5273 float
5274 foo (unsigned short val)
5275 {
5276 return _cvtsh_ss (val);
5277 }
5278 } "-O2 -mf16c" ]
5279 }
5280
5281 # Return 1 if C wchar_t type is compatible with char16_t.
5282
5283 proc check_effective_target_wchar_t_char16_t_compatible { } {
5284 return [check_no_compiler_messages wchar_t_char16_t object {
5285 __WCHAR_TYPE__ wc;
5286 __CHAR16_TYPE__ *p16 = &wc;
5287 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5288 }]
5289 }
5290
5291 # Return 1 if C wchar_t type is compatible with char32_t.
5292
5293 proc check_effective_target_wchar_t_char32_t_compatible { } {
5294 return [check_no_compiler_messages wchar_t_char32_t object {
5295 __WCHAR_TYPE__ wc;
5296 __CHAR32_TYPE__ *p32 = &wc;
5297 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5298 }]
5299 }
5300
5301 # Return 1 if pow10 function exists.
5302
5303 proc check_effective_target_pow10 { } {
5304 return [check_runtime pow10 {
5305 #include <math.h>
5306 int main () {
5307 double x;
5308 x = pow10 (1);
5309 return 0;
5310 }
5311 } "-lm" ]
5312 }
5313
5314 # Return 1 if current options generate DFP instructions, 0 otherwise.
5315
5316 proc check_effective_target_hard_dfp {} {
5317 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5318 typedef float d64 __attribute__((mode(DD)));
5319 d64 x, y, z;
5320 void foo (void) { z = x + y; }
5321 }]
5322 }
5323
5324 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5325 # for strchr etc. functions.
5326
5327 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5328 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5329 #include <string.h>
5330 #include <wchar.h>
5331 #if !defined(__cplusplus) \
5332 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5333 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5334 ISO C++ correct string.h and wchar.h protos not supported.
5335 #else
5336 int i;
5337 #endif
5338 }]
5339 }
5340
5341 # Return 1 if GNU as is used.
5342
5343 proc check_effective_target_gas { } {
5344 global use_gas_saved
5345 global tool
5346
5347 if {![info exists use_gas_saved]} {
5348 # Check if the as used by gcc is GNU as.
5349 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5350 # Provide /dev/null as input, otherwise gas times out reading from
5351 # stdin.
5352 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5353 set as_output [lindex $status 1]
5354 if { [ string first "GNU" $as_output ] >= 0 } {
5355 set use_gas_saved 1
5356 } else {
5357 set use_gas_saved 0
5358 }
5359 }
5360 return $use_gas_saved
5361 }
5362
5363 # Return 1 if GNU ld is used.
5364
5365 proc check_effective_target_gld { } {
5366 global use_gld_saved
5367 global tool
5368
5369 if {![info exists use_gld_saved]} {
5370 # Check if the ld used by gcc is GNU ld.
5371 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5372 set status [remote_exec host "$gcc_ld" "--version"]
5373 set ld_output [lindex $status 1]
5374 if { [ string first "GNU" $ld_output ] >= 0 } {
5375 set use_gld_saved 1
5376 } else {
5377 set use_gld_saved 0
5378 }
5379 }
5380 return $use_gld_saved
5381 }
5382
5383 # Return 1 if the compiler has been configure with link-time optimization
5384 # (LTO) support.
5385
5386 proc check_effective_target_lto { } {
5387 global ENABLE_LTO
5388 return [info exists ENABLE_LTO]
5389 }
5390
5391 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
5392
5393 proc check_effective_target_maybe_x32 { } {
5394 return [check_no_compiler_messages maybe_x32 object {
5395 void foo (void) {}
5396 } "-mx32 -maddress-mode=short"]
5397 }
5398
5399 # Return 1 if this target supports the -fsplit-stack option, 0
5400 # otherwise.
5401
5402 proc check_effective_target_split_stack {} {
5403 return [check_no_compiler_messages split_stack object {
5404 void foo (void) { }
5405 } "-fsplit-stack"]
5406 }
5407
5408 # Return 1 if this target supports the -masm=intel option, 0
5409 # otherwise
5410
5411 proc check_effective_target_masm_intel {} {
5412 return [check_no_compiler_messages masm_intel object {
5413 extern void abort (void);
5414 } "-masm=intel"]
5415 }
5416
5417 # Return 1 if the language for the compiler under test is C.
5418
5419 proc check_effective_target_c { } {
5420 global tool
5421 if [string match $tool "gcc"] {
5422 return 1
5423 }
5424 return 0
5425 }
5426
5427 # Return 1 if the language for the compiler under test is C++.
5428
5429 proc check_effective_target_c++ { } {
5430 global tool
5431 if [string match $tool "g++"] {
5432 return 1
5433 }
5434 return 0
5435 }
5436
5437 # Check which language standard is active by checking for the presence of
5438 # one of the C++11 -std flags. This assumes that the default for the
5439 # compiler is C++98, and that there will never be multiple -std= arguments
5440 # on the command line.
5441 proc check_effective_target_c++11 { } {
5442 if ![check_effective_target_c++] {
5443 return 0
5444 }
5445 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
5446 }
5447
5448 proc check_effective_target_c++1y { } {
5449 if ![check_effective_target_c++] {
5450 return 0
5451 }
5452 return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }]
5453 }
5454
5455 proc check_effective_target_c++98 { } {
5456 if ![check_effective_target_c++] {
5457 return 0
5458 }
5459 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }]
5460 }
5461
5462 # Return 1 if expensive testcases should be run.
5463
5464 proc check_effective_target_run_expensive_tests { } {
5465 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
5466 return 1
5467 }
5468 return 0
5469 }
5470
5471 # Returns 1 if "mempcpy" is available on the target system.
5472
5473 proc check_effective_target_mempcpy {} {
5474 return [check_function_available "mempcpy"]
5475 }
5476
5477 # Check whether the vectorizer tests are supported by the target and
5478 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
5479 # Set dg-do-what-default to either compile or run, depending on target
5480 # capabilities. Return 1 if vectorizer tests are supported by
5481 # target, 0 otherwise.
5482
5483 proc check_vect_support_and_set_flags { } {
5484 global DEFAULT_VECTCFLAGS
5485 global dg-do-what-default
5486
5487 if [istarget powerpc-*paired*] {
5488 lappend DEFAULT_VECTCFLAGS "-mpaired"
5489 if [check_750cl_hw_available] {
5490 set dg-do-what-default run
5491 } else {
5492 set dg-do-what-default compile
5493 }
5494 } elseif [istarget powerpc*-*-*] {
5495 # Skip targets not supporting -maltivec.
5496 if ![is-effective-target powerpc_altivec_ok] {
5497 return 0
5498 }
5499
5500 lappend DEFAULT_VECTCFLAGS "-maltivec"
5501 if [check_p8vector_hw_available] {
5502 lappend DEFAULT_VECTCFLAGS "-mpower8-vector" "-mno-allow-movmisalign"
5503 } elseif [check_vsx_hw_available] {
5504 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
5505 }
5506
5507 if [check_vmx_hw_available] {
5508 set dg-do-what-default run
5509 } else {
5510 if [is-effective-target ilp32] {
5511 # Specify a cpu that supports VMX for compile-only tests.
5512 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
5513 }
5514 set dg-do-what-default compile
5515 }
5516 } elseif { [istarget spu-*-*] } {
5517 set dg-do-what-default run
5518 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5519 lappend DEFAULT_VECTCFLAGS "-msse2"
5520 if { [check_effective_target_sse2_runtime] } {
5521 set dg-do-what-default run
5522 } else {
5523 set dg-do-what-default compile
5524 }
5525 } elseif { [istarget mips*-*-*]
5526 && ([check_effective_target_mpaired_single]
5527 || [check_effective_target_mips_loongson])
5528 && [check_effective_target_nomips16] } {
5529 if { [check_effective_target_mpaired_single] } {
5530 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
5531 }
5532 set dg-do-what-default run
5533 } elseif [istarget sparc*-*-*] {
5534 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
5535 if [check_effective_target_ultrasparc_hw] {
5536 set dg-do-what-default run
5537 } else {
5538 set dg-do-what-default compile
5539 }
5540 } elseif [istarget alpha*-*-*] {
5541 # Alpha's vectorization capabilities are extremely limited.
5542 # It's more effort than its worth disabling all of the tests
5543 # that it cannot pass. But if you actually want to see what
5544 # does work, command out the return.
5545 return 0
5546
5547 lappend DEFAULT_VECTCFLAGS "-mmax"
5548 if [check_alpha_max_hw_available] {
5549 set dg-do-what-default run
5550 } else {
5551 set dg-do-what-default compile
5552 }
5553 } elseif [istarget ia64-*-*] {
5554 set dg-do-what-default run
5555 } elseif [is-effective-target arm_neon_ok] {
5556 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
5557 # NEON does not support denormals, so is not used for vectorization by
5558 # default to avoid loss of precision. We must pass -ffast-math to test
5559 # vectorization of float operations.
5560 lappend DEFAULT_VECTCFLAGS "-ffast-math"
5561 if [is-effective-target arm_neon_hw] {
5562 set dg-do-what-default run
5563 } else {
5564 set dg-do-what-default compile
5565 }
5566 } elseif [istarget "aarch64*-*-*"] {
5567 set dg-do-what-default run
5568 } else {
5569 return 0
5570 }
5571
5572 return 1
5573 }
5574
5575 proc check_effective_target_non_strict_align {} {
5576 return [check_no_compiler_messages non_strict_align assembly {
5577 char *y;
5578 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
5579 c *z;
5580 void foo(void) { z = (c *) y; }
5581 } "-Wcast-align"]
5582 }
5583
5584 # Return 1 if the target has <ucontext.h>.
5585
5586 proc check_effective_target_ucontext_h { } {
5587 return [check_no_compiler_messages ucontext_h assembly {
5588 #include <ucontext.h>
5589 }]
5590 }
5591
5592 proc check_effective_target_aarch64_tiny { } {
5593 if { [istarget aarch64*-*-*] } {
5594 return [check_no_compiler_messages aarch64_tiny object {
5595 #ifdef __AARCH64_CMODEL_TINY__
5596 int dummy;
5597 #else
5598 #error target not AArch64 tiny code model
5599 #endif
5600 }]
5601 } else {
5602 return 0
5603 }
5604 }
5605
5606 proc check_effective_target_aarch64_small { } {
5607 if { [istarget aarch64*-*-*] } {
5608 return [check_no_compiler_messages aarch64_small object {
5609 #ifdef __AARCH64_CMODEL_SMALL__
5610 int dummy;
5611 #else
5612 #error target not AArch64 small code model
5613 #endif
5614 }]
5615 } else {
5616 return 0
5617 }
5618 }
5619
5620 proc check_effective_target_aarch64_large { } {
5621 if { [istarget aarch64*-*-*] } {
5622 return [check_no_compiler_messages aarch64_large object {
5623 #ifdef __AARCH64_CMODEL_LARGE__
5624 int dummy;
5625 #else
5626 #error target not AArch64 large code model
5627 #endif
5628 }]
5629 } else {
5630 return 0
5631 }
5632 }
5633
5634 # Return 1 if <fenv.h> is available with all the standard IEEE
5635 # exceptions and floating-point exceptions are raised by arithmetic
5636 # operations. (If the target requires special options for "inexact"
5637 # exceptions, those need to be specified in the testcases.)
5638
5639 proc check_effective_target_fenv_exceptions {} {
5640 return [check_runtime fenv_exceptions {
5641 #include <fenv.h>
5642 #include <stdlib.h>
5643 #ifndef FE_DIVBYZERO
5644 # error Missing FE_DIVBYZERO
5645 #endif
5646 #ifndef FE_INEXACT
5647 # error Missing FE_INEXACT
5648 #endif
5649 #ifndef FE_INVALID
5650 # error Missing FE_INVALID
5651 #endif
5652 #ifndef FE_OVERFLOW
5653 # error Missing FE_OVERFLOW
5654 #endif
5655 #ifndef FE_UNDERFLOW
5656 # error Missing FE_UNDERFLOW
5657 #endif
5658 volatile float a = 0.0f, r;
5659 int
5660 main (void)
5661 {
5662 r = a / a;
5663 if (fetestexcept (FE_INVALID))
5664 exit (0);
5665 else
5666 abort ();
5667 }
5668 } "-std=gnu99"]
5669 }
5670
5671 # Record that dg-final test TEST requires convential compilation.
5672
5673 proc force_conventional_output_for { test } {
5674 if { [info proc $test] == "" } {
5675 perror "$test does not exist"
5676 exit 1
5677 }
5678 proc ${test}_required_options {} {
5679 global gcc_force_conventional_output
5680 return $gcc_force_conventional_output
5681 }
5682 }
5683