2013-10-17 Charles Bayis <charles.baylis@linaro.org>
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob8701cf6c21df120f7e15e958e7ca5cd55451eee1
1 # Copyright (C) 1999-2013 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # This file defines procs for determining features supported by the target.
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.
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.
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"
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
46 } else {
47 set options ""
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 }
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
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
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
89 return [list $lines $scan_output]
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 ""
99 return $answer
102 # Implement an effective-target check for property PROP by invoking
103 # the Tcl command ARGS and seeing if it returns true.
105 proc check_cached_effective_target { prop args } {
106 global et_cache
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]
115 set value $et_cache($prop,value)
116 verbose "check_cached_effective_target $prop: returning $value for $target" 2
117 return $value
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]
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
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.)
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
152 set result [eval [list check_compile $basename] $args]
153 set lines [lindex $result 0]
154 set output [lindex $result 1]
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
164 remote_file build delete $output
165 return $ok
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
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
184 set result [eval [list check_compile $basename executable $contents] $args]
185 set lines [lindex $result 0]
186 set output [lindex $result 1]
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
198 remote_file build delete $output
199 return $ok
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
208 return [check_cached_effective_target $prop {
209 eval [list check_runtime_nocache $prop] $args
213 ###############################
214 # proc check_weak_available { }
215 ###############################
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
220 proc check_weak_available { } {
221 global target_cpu
223 # All mips targets should support it
225 if { [ string first "mips" $target_cpu ] >= 0 } {
226 return 1
229 # All AIX targets should support it
231 if { [istarget *-*-aix*] } {
232 return 1
235 # All solaris2 targets should support it
237 if { [istarget *-*-solaris2*] } {
238 return 1
241 # Windows targets Cygwin and MingW32 support it
243 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
244 return 1
247 # HP-UX 10.X doesn't support it
249 if { [istarget hppa*-*-hpux10*] } {
250 return 0
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
256 set objformat [gcc_target_object_format]
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 }
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
276 proc check_weak_override_available { } {
277 if { [istarget *-*-mingw*] } {
278 return 0
280 return [check_weak_available]
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
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.
291 proc check_visibility_available { what_kind } {
292 if [string match "" $what_kind] { set what_kind "hidden" }
294 return [check_no_compiler_messages visibility_available_$what_kind object "
295 void f() __attribute__((visibility(\"$what_kind\")));
296 void f() {}
300 ###############################
301 # proc check_alias_available { }
302 ###############################
304 # Determine if the target toolchain supports the alias attribute.
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.
311 proc check_alias_available { } {
312 global alias_available_saved
313 global tool
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
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
339 set objformat [gcc_target_object_format]
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
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
357 verbose "check_alias_available returning $alias_available_saved" 2
360 return $alias_available_saved
363 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
365 proc check_effective_target_alias { } {
366 if { [check_alias_available] < 2 } {
367 return 0
368 } else {
369 return 1
373 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
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")));
385 # Returns true if --gc-sections is supported on the target.
387 proc check_gc_sections_available { } {
388 global gc_sections_available_saved
389 global tool
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
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
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
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
427 return $gc_sections_available_saved
430 # Return 1 if according to target_info struct and explicit target list
431 # target is supposed to support trampolines.
433 proc check_effective_target_trampolines { } {
434 if [target_info exists no_trampolines] {
435 return 0
437 if { [istarget avr-*-*]
438 || [istarget msp430-*-*]
439 || [istarget hppa2.0w-hp-hpux11.23]
440 || [istarget hppa64-hp-hpux11.23] } {
441 return 0;
443 return 1
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.
450 proc check_effective_target_keeps_null_pointer_checks { } {
451 if [target_info exists keeps_null_pointer_checks] {
452 return 1
454 if { [istarget avr-*-*] } {
455 return 1;
457 return 0
460 # Return true if profiling is supported on the target.
462 proc check_profiling_available { test_what } {
463 global profiling_available_saved
465 verbose "Profiling argument is <$test_what>" 1
467 # These conditions depend on the argument so examine them before
468 # looking at the cache variable.
470 # Tree profiling requires TLS runtime support.
471 if { $test_what == "-fprofile-generate" } {
472 if { ![check_effective_target_tls_runtime] } {
473 return 0
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
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
492 # MinGW does not support -p.
493 if { [istarget *-*-mingw*] && $test_what == "-p" } {
494 return 0
497 # cygwin does not support -p.
498 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
499 return 0
502 # uClibc does not have gcrt1.o.
503 if { [check_effective_target_uclibc]
504 && ($test_what == "-p" || $test_what == "-pg") } {
505 return 0
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 picochip-*-*]
534 || [istarget powerpc-*-eabi*]
535 || [istarget powerpc-*-elf]
536 || [istarget rx-*-*]
537 || [istarget tic6x-*-elf]
538 || [istarget xstormy16-*]
539 || [istarget xtensa*-*-elf]
540 || [istarget *-*-rtems*]
541 || [istarget *-*-vxworks*] } {
542 set profiling_available_saved 0
543 } else {
544 set profiling_available_saved 1
548 return $profiling_available_saved
551 # Check to see if a target is "freestanding". This is as per the definition
552 # in Section 4 of C99 standard. Effectively, it is a target which supports no
553 # extra headers or libraries other than what is considered essential.
554 proc check_effective_target_freestanding { } {
555 if { [istarget picochip-*-*] } then {
556 return 1
557 } else {
558 return 0
562 # Return 1 if target has packed layout of structure members by
563 # default, 0 otherwise. Note that this is slightly different than
564 # whether the target has "natural alignment": both attributes may be
565 # false.
567 proc check_effective_target_default_packed { } {
568 return [check_no_compiler_messages default_packed assembly {
569 struct x { char a; long b; } c;
570 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
574 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
575 # documentation, where the test also comes from.
577 proc check_effective_target_pcc_bitfield_type_matters { } {
578 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
579 # bitfields, but let's stick to the example code from the docs.
580 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
581 struct foo1 { char x; char :0; char y; };
582 struct foo2 { char x; int :0; char y; };
583 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
587 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
589 proc add_options_for_tls { flags } {
590 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
591 # libthread, so always pass -pthread for native TLS. Same for AIX.
592 # Need to duplicate native TLS check from
593 # check_effective_target_tls_native to avoid recursion.
594 if { ([istarget *-*-solaris2.9*] || [istarget powerpc-ibm-aix*]) &&
595 [check_no_messages_and_pattern tls_native "!emutls" assembly {
596 __thread int i;
597 int f (void) { return i; }
598 void g (int j) { i = j; }
599 }] } {
600 return "$flags -pthread"
602 return $flags
605 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
607 proc check_effective_target_tls {} {
608 return [check_no_compiler_messages tls assembly {
609 __thread int i;
610 int f (void) { return i; }
611 void g (int j) { i = j; }
615 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
617 proc check_effective_target_tls_native {} {
618 # VxWorks uses emulated TLS machinery, but with non-standard helper
619 # functions, so we fail to automatically detect it.
620 if { [istarget *-*-vxworks*] } {
621 return 0
624 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
625 __thread int i;
626 int f (void) { return i; }
627 void g (int j) { i = j; }
631 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
633 proc check_effective_target_tls_emulated {} {
634 # VxWorks uses emulated TLS machinery, but with non-standard helper
635 # functions, so we fail to automatically detect it.
636 if { [istarget *-*-vxworks*] } {
637 return 1
640 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
641 __thread int i;
642 int f (void) { return i; }
643 void g (int j) { i = j; }
647 # Return 1 if TLS executables can run correctly, 0 otherwise.
649 proc check_effective_target_tls_runtime {} {
650 # MSP430 runtime does not have TLS support, but just
651 # running the test below is insufficient to show this.
652 if { [istarget msp430-*-*] } {
653 return 0
655 return [check_runtime tls_runtime {
656 __thread int thr = 0;
657 int main (void) { return thr; }
658 } [add_options_for_tls ""]]
661 # Return 1 if atomic compare-and-swap is supported on 'int'
663 proc check_effective_target_cas_char {} {
664 return [check_no_compiler_messages cas_char assembly {
665 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
666 #error unsupported
667 #endif
668 } ""]
671 proc check_effective_target_cas_int {} {
672 return [check_no_compiler_messages cas_int assembly {
673 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
674 /* ok */
675 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
676 /* ok */
677 #else
678 #error unsupported
679 #endif
680 } ""]
683 # Return 1 if -ffunction-sections is supported, 0 otherwise.
685 proc check_effective_target_function_sections {} {
686 # Darwin has its own scheme and silently accepts -ffunction-sections.
687 if { [istarget *-*-darwin*] } {
688 return 0
691 return [check_no_compiler_messages functionsections assembly {
692 void foo (void) { }
693 } "-ffunction-sections"]
696 # Return 1 if instruction scheduling is available, 0 otherwise.
698 proc check_effective_target_scheduling {} {
699 return [check_no_compiler_messages scheduling object {
700 void foo (void) { }
701 } "-fschedule-insns"]
704 # Return 1 if compilation with -fgraphite is error-free for trivial
705 # code, 0 otherwise.
707 proc check_effective_target_fgraphite {} {
708 return [check_no_compiler_messages fgraphite object {
709 void foo (void) { }
710 } "-O1 -fgraphite"]
713 # Return 1 if compilation with -fopenmp is error-free for trivial
714 # code, 0 otherwise.
716 proc check_effective_target_fopenmp {} {
717 return [check_no_compiler_messages fopenmp object {
718 void foo (void) { }
719 } "-fopenmp"]
722 # Return 1 if compilation with -fgnu-tm is error-free for trivial
723 # code, 0 otherwise.
725 proc check_effective_target_fgnu_tm {} {
726 return [check_no_compiler_messages fgnu_tm object {
727 void foo (void) { }
728 } "-fgnu-tm"]
731 # Return 1 if the target supports mmap, 0 otherwise.
733 proc check_effective_target_mmap {} {
734 return [check_function_available "mmap"]
737 # Return 1 if the target supports dlopen, 0 otherwise.
738 proc check_effective_target_dlopen {} {
739 return [check_function_available "dlopen"]
742 # Return 1 if the target supports clone, 0 otherwise.
743 proc check_effective_target_clone {} {
744 return [check_function_available "clone"]
747 # Return 1 if the target supports setrlimit, 0 otherwise.
748 proc check_effective_target_setrlimit {} {
749 # Darwin has non-posix compliant RLIMIT_AS
750 if { [istarget *-*-darwin*] } {
751 return 0
753 return [check_function_available "setrlimit"]
756 # Return 1 if the target supports swapcontext, 0 otherwise.
757 proc check_effective_target_swapcontext {} {
758 return [check_no_compiler_messages swapcontext executable {
759 #include <ucontext.h>
760 int main (void)
762 ucontext_t orig_context,child_context;
763 if (swapcontext(&child_context, &orig_context) < 0) { }
768 # Return 1 if compilation with -pthread is error-free for trivial
769 # code, 0 otherwise.
771 proc check_effective_target_pthread {} {
772 return [check_no_compiler_messages pthread object {
773 void foo (void) { }
774 } "-pthread"]
777 # Return 1 if compilation with -mpe-aligned-commons is error-free
778 # for trivial code, 0 otherwise.
780 proc check_effective_target_pe_aligned_commons {} {
781 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
782 return [check_no_compiler_messages pe_aligned_commons object {
783 int foo;
784 } "-mpe-aligned-commons"]
786 return 0
789 # Return 1 if the target supports -static
790 proc check_effective_target_static {} {
791 return [check_no_compiler_messages static executable {
792 int main (void) { return 0; }
793 } "-static"]
796 # Return 1 if the target supports -fstack-protector
797 proc check_effective_target_fstack_protector {} {
798 return [check_runtime fstack_protector {
799 int main (void) { return 0; }
800 } "-fstack-protector"]
803 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
804 # for trivial code, 0 otherwise.
806 proc check_effective_target_freorder {} {
807 return [check_no_compiler_messages freorder object {
808 void foo (void) { }
809 } "-freorder-blocks-and-partition"]
812 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
813 # emitted, 0 otherwise. Whether a shared library can actually be built is
814 # out of scope for this test.
816 proc check_effective_target_fpic { } {
817 # Note that M68K has a multilib that supports -fpic but not
818 # -fPIC, so we need to check both. We test with a program that
819 # requires GOT references.
820 foreach arg {fpic fPIC} {
821 if [check_no_compiler_messages $arg object {
822 extern int foo (void); extern int bar;
823 int baz (void) { return foo () + bar; }
824 } "-$arg"] {
825 return 1
828 return 0
831 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
833 proc check_effective_target_pie { } {
834 if { [istarget *-*-darwin\[912\]*]
835 || [istarget *-*-linux*]
836 || [istarget *-*-gnu*] } {
837 return 1;
839 return 0
842 # Return true if the target supports -mpaired-single (as used on MIPS).
844 proc check_effective_target_mpaired_single { } {
845 return [check_no_compiler_messages mpaired_single object {
846 void foo (void) { }
847 } "-mpaired-single"]
850 # Return true if the target has access to FPU instructions.
852 proc check_effective_target_hard_float { } {
853 if { [istarget mips*-*-*] } {
854 return [check_no_compiler_messages hard_float assembly {
855 #if (defined __mips_soft_float || defined __mips16)
856 #error FOO
857 #endif
861 # This proc is actually checking the availabilty of FPU
862 # support for doubles, so on the RX we must fail if the
863 # 64-bit double multilib has been selected.
864 if { [istarget rx-*-*] } {
865 return 0
866 # return [check_no_compiler_messages hard_float assembly {
867 #if defined __RX_64_BIT_DOUBLES__
868 #error FOO
869 #endif
870 # }]
873 # The generic test equates hard_float with "no call for adding doubles".
874 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
875 double a (double b, double c) { return b + c; }
879 # Return true if the target is a 64-bit MIPS target.
881 proc check_effective_target_mips64 { } {
882 return [check_no_compiler_messages mips64 assembly {
883 #ifndef __mips64
884 #error FOO
885 #endif
889 # Return true if the target is a MIPS target that does not produce
890 # MIPS16 code.
892 proc check_effective_target_nomips16 { } {
893 return [check_no_compiler_messages nomips16 object {
894 #ifndef __mips
895 #error FOO
896 #else
897 /* A cheap way of testing for -mflip-mips16. */
898 void foo (void) { asm ("addiu $20,$20,1"); }
899 void bar (void) { asm ("addiu $20,$20,1"); }
900 #endif
904 # Add the options needed for MIPS16 function attributes. At the moment,
905 # we don't support MIPS16 PIC.
907 proc add_options_for_mips16_attribute { flags } {
908 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
911 # Return true if we can force a mode that allows MIPS16 code generation.
912 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
913 # for o32 and o64.
915 proc check_effective_target_mips16_attribute { } {
916 return [check_no_compiler_messages mips16_attribute assembly {
917 #ifdef PIC
918 #error FOO
919 #endif
920 #if defined __mips_hard_float \
921 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
922 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
923 #error FOO
924 #endif
925 } [add_options_for_mips16_attribute ""]]
928 # Return 1 if the target supports long double larger than double when
929 # using the new ABI, 0 otherwise.
931 proc check_effective_target_mips_newabi_large_long_double { } {
932 return [check_no_compiler_messages mips_newabi_large_long_double object {
933 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
934 } "-mabi=64"]
937 # Return true if the target is a MIPS target that has access
938 # to the LL and SC instructions.
940 proc check_effective_target_mips_llsc { } {
941 if { ![istarget mips*-*-*] } {
942 return 0
944 # Assume that these instructions are always implemented for
945 # non-elf* targets, via emulation if necessary.
946 if { ![istarget *-*-elf*] } {
947 return 1
949 # Otherwise assume LL/SC support for everything but MIPS I.
950 return [check_no_compiler_messages mips_llsc assembly {
951 #if __mips == 1
952 #error FOO
953 #endif
957 # Return true if the target is a MIPS target that uses in-place relocations.
959 proc check_effective_target_mips_rel { } {
960 if { ![istarget mips*-*-*] } {
961 return 0
963 return [check_no_compiler_messages mips_rel object {
964 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
965 || (defined _ABI64 && _MIPS_SIM == _ABI64)
966 #error FOO
967 #endif
971 # Return true if the target is a MIPS target that uses the EABI.
973 proc check_effective_target_mips_eabi { } {
974 if { ![istarget mips*-*-*] } {
975 return 0
977 return [check_no_compiler_messages mips_eabi object {
978 #ifndef __mips_eabi
979 #error FOO
980 #endif
984 # Return 1 if the current multilib does not generate PIC by default.
986 proc check_effective_target_nonpic { } {
987 return [check_no_compiler_messages nonpic assembly {
988 #if __PIC__
989 #error FOO
990 #endif
994 # Return 1 if the target does not use a status wrapper.
996 proc check_effective_target_unwrapped { } {
997 if { [target_info needs_status_wrapper] != "" \
998 && [target_info needs_status_wrapper] != "0" } {
999 return 0
1001 return 1
1004 # Return true if iconv is supported on the target. In particular IBM1047.
1006 proc check_iconv_available { test_what } {
1007 global libiconv
1009 # If the tool configuration file has not set libiconv, try "-liconv"
1010 if { ![info exists libiconv] } {
1011 set libiconv "-liconv"
1013 set test_what [lindex $test_what 1]
1014 return [check_runtime_nocache $test_what [subst {
1015 #include <iconv.h>
1016 int main (void)
1018 iconv_t cd;
1020 cd = iconv_open ("$test_what", "UTF-8");
1021 if (cd == (iconv_t) -1)
1022 return 1;
1023 return 0;
1025 }] $libiconv]
1028 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1030 proc check_ascii_locale_available { } {
1031 return 1
1034 # Return true if named sections are supported on this target.
1036 proc check_named_sections_available { } {
1037 return [check_no_compiler_messages named_sections assembly {
1038 int __attribute__ ((section("whatever"))) foo;
1042 # Return true if the "naked" function attribute is supported on this target.
1044 proc check_effective_target_naked_functions { } {
1045 return [check_no_compiler_messages naked_functions assembly {
1046 void f() __attribute__((naked));
1050 # Return 1 if the target supports Fortran real kinds larger than real(8),
1051 # 0 otherwise.
1053 # When the target name changes, replace the cached result.
1055 proc check_effective_target_fortran_large_real { } {
1056 return [check_no_compiler_messages fortran_large_real executable {
1057 ! Fortran
1058 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1059 real(kind=k) :: x
1060 x = cos (x)
1065 # Return 1 if the target supports Fortran real kind real(16),
1066 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1067 # this checks for Real(16) only; the other returned real(10) if
1068 # both real(10) and real(16) are available.
1070 # When the target name changes, replace the cached result.
1072 proc check_effective_target_fortran_real_16 { } {
1073 return [check_no_compiler_messages fortran_real_16 executable {
1074 ! Fortran
1075 real(kind=16) :: x
1076 x = cos (x)
1082 # Return 1 if the target supports SQRT for the largest floating-point
1083 # type. (Some targets lack the libm support for this FP type.)
1084 # On most targets, this check effectively checks either whether sqrtl is
1085 # available or on __float128 systems whether libquadmath is installed,
1086 # which provides sqrtq.
1088 # When the target name changes, replace the cached result.
1090 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1091 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1092 ! Fortran
1093 use iso_fortran_env, only: real_kinds
1094 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1095 real(kind=maxFP), volatile :: x
1096 x = 2.0_maxFP
1097 x = sqrt (x)
1103 # Return 1 if the target supports Fortran integer kinds larger than
1104 # integer(8), 0 otherwise.
1106 # When the target name changes, replace the cached result.
1108 proc check_effective_target_fortran_large_int { } {
1109 return [check_no_compiler_messages fortran_large_int executable {
1110 ! Fortran
1111 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1112 integer(kind=k) :: i
1117 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1119 # When the target name changes, replace the cached result.
1121 proc check_effective_target_fortran_integer_16 { } {
1122 return [check_no_compiler_messages fortran_integer_16 executable {
1123 ! Fortran
1124 integer(16) :: i
1129 # Return 1 if we can statically link libgfortran, 0 otherwise.
1131 # When the target name changes, replace the cached result.
1133 proc check_effective_target_static_libgfortran { } {
1134 return [check_no_compiler_messages static_libgfortran executable {
1135 ! Fortran
1136 print *, 'test'
1138 } "-static"]
1141 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1143 proc check_effective_target_cilkplus { } {
1144 # Skip cilk-plus tests on int16 and size16 targets for now.
1145 # The cilk-plus tests are not generic enough to cover these
1146 # cases and would throw hundreds of FAILs.
1147 if { [check_effective_target_int16]
1148 || ![check_effective_target_size32plus] } {
1149 return 0;
1152 # Skip AVR, its RAM is too small and too many tests would fail.
1153 if { [istarget avr-*-*] } {
1154 return 0;
1156 return 1
1159 proc check_linker_plugin_available { } {
1160 return [check_no_compiler_messages_nocache linker_plugin executable {
1161 int main() { return 0; }
1162 } "-flto -fuse-linker-plugin"]
1165 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1166 # otherwise. Cache the result.
1168 proc check_750cl_hw_available { } {
1169 return [check_cached_effective_target 750cl_hw_available {
1170 # If this is not the right target then we can skip the test.
1171 if { ![istarget powerpc-*paired*] } {
1172 expr 0
1173 } else {
1174 check_runtime_nocache 750cl_hw_available {
1175 int main()
1177 #ifdef __MACH__
1178 asm volatile ("ps_mul v0,v0,v0");
1179 #else
1180 asm volatile ("ps_mul 0,0,0");
1181 #endif
1182 return 0;
1184 } "-mpaired"
1189 # Return 1 if the target OS supports running SSE executables, 0
1190 # otherwise. Cache the result.
1192 proc check_sse_os_support_available { } {
1193 return [check_cached_effective_target sse_os_support_available {
1194 # If this is not the right target then we can skip the test.
1195 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1196 expr 0
1197 } elseif { [istarget i?86-*-solaris2*] } {
1198 # The Solaris 2 kernel doesn't save and restore SSE registers
1199 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1200 check_runtime_nocache sse_os_support_available {
1201 int main ()
1203 asm volatile ("movaps %xmm0,%xmm0");
1204 return 0;
1206 } "-msse"
1207 } else {
1208 expr 1
1213 # Return 1 if the target OS supports running AVX executables, 0
1214 # otherwise. Cache the result.
1216 proc check_avx_os_support_available { } {
1217 return [check_cached_effective_target avx_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 } else {
1222 # Check that OS has AVX and SSE saving enabled.
1223 check_runtime_nocache avx_os_support_available {
1224 int main ()
1226 unsigned int eax, edx;
1228 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1229 return (eax & 6) != 6;
1231 } ""
1236 # Return 1 if the target supports executing SSE instructions, 0
1237 # otherwise. Cache the result.
1239 proc check_sse_hw_available { } {
1240 return [check_cached_effective_target sse_hw_available {
1241 # If this is not the right target then we can skip the test.
1242 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1243 expr 0
1244 } else {
1245 check_runtime_nocache sse_hw_available {
1246 #include "cpuid.h"
1247 int main ()
1249 unsigned int eax, ebx, ecx, edx;
1250 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1251 return !(edx & bit_SSE);
1252 return 1;
1254 } ""
1259 # Return 1 if the target supports executing SSE2 instructions, 0
1260 # otherwise. Cache the result.
1262 proc check_sse2_hw_available { } {
1263 return [check_cached_effective_target sse2_hw_available {
1264 # If this is not the right target then we can skip the test.
1265 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1266 expr 0
1267 } else {
1268 check_runtime_nocache sse2_hw_available {
1269 #include "cpuid.h"
1270 int main ()
1272 unsigned int eax, ebx, ecx, edx;
1273 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1274 return !(edx & bit_SSE2);
1275 return 1;
1277 } ""
1282 # Return 1 if the target supports executing AVX instructions, 0
1283 # otherwise. Cache the result.
1285 proc check_avx_hw_available { } {
1286 return [check_cached_effective_target avx_hw_available {
1287 # If this is not the right target then we can skip the test.
1288 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1289 expr 0
1290 } else {
1291 check_runtime_nocache avx_hw_available {
1292 #include "cpuid.h"
1293 int main ()
1295 unsigned int eax, ebx, ecx, edx;
1296 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1297 return ((ecx & (bit_AVX | bit_OSXSAVE))
1298 != (bit_AVX | bit_OSXSAVE));
1299 return 1;
1301 } ""
1306 # Return 1 if the target supports running SSE executables, 0 otherwise.
1308 proc check_effective_target_sse_runtime { } {
1309 if { [check_effective_target_sse]
1310 && [check_sse_hw_available]
1311 && [check_sse_os_support_available] } {
1312 return 1
1314 return 0
1317 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1319 proc check_effective_target_sse2_runtime { } {
1320 if { [check_effective_target_sse2]
1321 && [check_sse2_hw_available]
1322 && [check_sse_os_support_available] } {
1323 return 1
1325 return 0
1328 # Return 1 if the target supports running AVX executables, 0 otherwise.
1330 proc check_effective_target_avx_runtime { } {
1331 if { [check_effective_target_avx]
1332 && [check_avx_hw_available]
1333 && [check_avx_os_support_available] } {
1334 return 1
1336 return 0
1339 # Return 1 if the target supports executing power8 vector instructions, 0
1340 # otherwise. Cache the result.
1342 proc check_p8vector_hw_available { } {
1343 return [check_cached_effective_target p8vector_hw_available {
1344 # Some simulators are known to not support VSX/power8 instructions.
1345 # For now, disable on Darwin
1346 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1347 expr 0
1348 } else {
1349 set options "-mpower8-vector"
1350 check_runtime_nocache p8vector_hw_available {
1351 int main()
1353 #ifdef __MACH__
1354 asm volatile ("xxlorc vs0,vs0,vs0");
1355 #else
1356 asm volatile ("xxlorc 0,0,0");
1357 #endif
1358 return 0;
1360 } $options
1365 # Return 1 if the target supports executing VSX instructions, 0
1366 # otherwise. Cache the result.
1368 proc check_vsx_hw_available { } {
1369 return [check_cached_effective_target vsx_hw_available {
1370 # Some simulators are known to not support VSX instructions.
1371 # For now, disable on Darwin
1372 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1373 expr 0
1374 } else {
1375 set options "-mvsx"
1376 check_runtime_nocache vsx_hw_available {
1377 int main()
1379 #ifdef __MACH__
1380 asm volatile ("xxlor vs0,vs0,vs0");
1381 #else
1382 asm volatile ("xxlor 0,0,0");
1383 #endif
1384 return 0;
1386 } $options
1391 # Return 1 if the target supports executing AltiVec instructions, 0
1392 # otherwise. Cache the result.
1394 proc check_vmx_hw_available { } {
1395 return [check_cached_effective_target vmx_hw_available {
1396 # Some simulators are known to not support VMX instructions.
1397 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1398 expr 0
1399 } else {
1400 # Most targets don't require special flags for this test case, but
1401 # Darwin does. Just to be sure, make sure VSX is not enabled for
1402 # the altivec tests.
1403 if { [istarget *-*-darwin*]
1404 || [istarget *-*-aix*] } {
1405 set options "-maltivec -mno-vsx"
1406 } else {
1407 set options "-mno-vsx"
1409 check_runtime_nocache vmx_hw_available {
1410 int main()
1412 #ifdef __MACH__
1413 asm volatile ("vor v0,v0,v0");
1414 #else
1415 asm volatile ("vor 0,0,0");
1416 #endif
1417 return 0;
1419 } $options
1424 proc check_ppc_recip_hw_available { } {
1425 return [check_cached_effective_target ppc_recip_hw_available {
1426 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1427 # For now, disable on Darwin
1428 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1429 expr 0
1430 } else {
1431 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1432 check_runtime_nocache ppc_recip_hw_available {
1433 volatile double d_recip, d_rsqrt, d_four = 4.0;
1434 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1435 int main()
1437 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1438 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1439 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1440 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1441 return 0;
1443 } $options
1448 # Return 1 if the target supports executing AltiVec and Cell PPU
1449 # instructions, 0 otherwise. Cache the result.
1451 proc check_effective_target_cell_hw { } {
1452 return [check_cached_effective_target cell_hw_available {
1453 # Some simulators are known to not support VMX and PPU instructions.
1454 if { [istarget powerpc-*-eabi*] } {
1455 expr 0
1456 } else {
1457 # Most targets don't require special flags for this test
1458 # case, but Darwin and AIX do.
1459 if { [istarget *-*-darwin*]
1460 || [istarget *-*-aix*] } {
1461 set options "-maltivec -mcpu=cell"
1462 } else {
1463 set options "-mcpu=cell"
1465 check_runtime_nocache cell_hw_available {
1466 int main()
1468 #ifdef __MACH__
1469 asm volatile ("vor v0,v0,v0");
1470 asm volatile ("lvlx v0,r0,r0");
1471 #else
1472 asm volatile ("vor 0,0,0");
1473 asm volatile ("lvlx 0,0,0");
1474 #endif
1475 return 0;
1477 } $options
1482 # Return 1 if the target supports executing 64-bit instructions, 0
1483 # otherwise. Cache the result.
1485 proc check_effective_target_powerpc64 { } {
1486 global powerpc64_available_saved
1487 global tool
1489 if [info exists powerpc64_available_saved] {
1490 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1491 } else {
1492 set powerpc64_available_saved 0
1494 # Some simulators are known to not support powerpc64 instructions.
1495 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1496 verbose "check_effective_target_powerpc64 returning 0" 2
1497 return $powerpc64_available_saved
1500 # Set up, compile, and execute a test program containing a 64-bit
1501 # instruction. Include the current process ID in the file
1502 # names to prevent conflicts with invocations for multiple
1503 # testsuites.
1504 set src ppc[pid].c
1505 set exe ppc[pid].x
1507 set f [open $src "w"]
1508 puts $f "int main() {"
1509 puts $f "#ifdef __MACH__"
1510 puts $f " asm volatile (\"extsw r0,r0\");"
1511 puts $f "#else"
1512 puts $f " asm volatile (\"extsw 0,0\");"
1513 puts $f "#endif"
1514 puts $f " return 0; }"
1515 close $f
1517 set opts "additional_flags=-mcpu=G5"
1519 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1520 set lines [${tool}_target_compile $src $exe executable "$opts"]
1521 file delete $src
1523 if [string match "" $lines] then {
1524 # No error message, compilation succeeded.
1525 set result [${tool}_load "./$exe" "" ""]
1526 set status [lindex $result 0]
1527 remote_file build delete $exe
1528 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1530 if { $status == "pass" } then {
1531 set powerpc64_available_saved 1
1533 } else {
1534 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1538 return $powerpc64_available_saved
1541 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1542 # complex float arguments. This affects gfortran tests that call cabsf
1543 # in libm built by an earlier compiler. Return 1 if libm uses the same
1544 # argument passing as the compiler under test, 0 otherwise.
1546 # When the target name changes, replace the cached result.
1548 proc check_effective_target_broken_cplxf_arg { } {
1549 return [check_cached_effective_target broken_cplxf_arg {
1550 # Skip the work for targets known not to be affected.
1551 if { ![istarget powerpc64-*-linux*] } {
1552 expr 0
1553 } elseif { ![is-effective-target lp64] } {
1554 expr 0
1555 } else {
1556 check_runtime_nocache broken_cplxf_arg {
1557 #include <complex.h>
1558 extern void abort (void);
1559 float fabsf (float);
1560 float cabsf (_Complex float);
1561 int main ()
1563 _Complex float cf;
1564 float f;
1565 cf = 3 + 4.0fi;
1566 f = cabsf (cf);
1567 if (fabsf (f - 5.0) > 0.0001)
1568 abort ();
1569 return 0;
1571 } "-lm"
1576 # Return 1 is this is a TI C6X target supporting C67X instructions
1577 proc check_effective_target_ti_c67x { } {
1578 return [check_no_compiler_messages ti_c67x assembly {
1579 #if !defined(_TMS320C6700)
1580 #error FOO
1581 #endif
1585 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1586 proc check_effective_target_ti_c64xp { } {
1587 return [check_no_compiler_messages ti_c64xp assembly {
1588 #if !defined(_TMS320C6400_PLUS)
1589 #error FOO
1590 #endif
1595 proc check_alpha_max_hw_available { } {
1596 return [check_runtime alpha_max_hw_available {
1597 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1601 # Returns true iff the FUNCTION is available on the target system.
1602 # (This is essentially a Tcl implementation of Autoconf's
1603 # AC_CHECK_FUNC.)
1605 proc check_function_available { function } {
1606 return [check_no_compiler_messages ${function}_available \
1607 executable [subst {
1608 #ifdef __cplusplus
1609 extern "C"
1610 #endif
1611 char $function ();
1612 int main () { $function (); }
1613 }] "-fno-builtin" ]
1616 # Returns true iff "fork" is available on the target system.
1618 proc check_fork_available {} {
1619 return [check_function_available "fork"]
1622 # Returns true iff "mkfifo" is available on the target system.
1624 proc check_mkfifo_available {} {
1625 if { [istarget *-*-cygwin*] } {
1626 # Cygwin has mkfifo, but support is incomplete.
1627 return 0
1630 return [check_function_available "mkfifo"]
1633 # Returns true iff "__cxa_atexit" is used on the target system.
1635 proc check_cxa_atexit_available { } {
1636 return [check_cached_effective_target cxa_atexit_available {
1637 if { [istarget hppa*-*-hpux10*] } {
1638 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1639 expr 0
1640 } elseif { [istarget *-*-vxworks] } {
1641 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1642 expr 0
1643 } else {
1644 check_runtime_nocache cxa_atexit_available {
1645 // C++
1646 #include <stdlib.h>
1647 static unsigned int count;
1648 struct X
1650 X() { count = 1; }
1651 ~X()
1653 if (count != 3)
1654 exit(1);
1655 count = 4;
1658 void f()
1660 static X x;
1662 struct Y
1664 Y() { f(); count = 2; }
1665 ~Y()
1667 if (count != 2)
1668 exit(1);
1669 count = 3;
1672 Y y;
1673 int main() { return 0; }
1679 proc check_effective_target_objc2 { } {
1680 return [check_no_compiler_messages objc2 object {
1681 #ifdef __OBJC2__
1682 int dummy[1];
1683 #else
1684 #error
1685 #endif
1689 proc check_effective_target_next_runtime { } {
1690 return [check_no_compiler_messages objc2 object {
1691 #ifdef __NEXT_RUNTIME__
1692 int dummy[1];
1693 #else
1694 #error
1695 #endif
1699 # Return 1 if we're generating 32-bit code using default options, 0
1700 # otherwise.
1702 proc check_effective_target_ilp32 { } {
1703 return [check_no_compiler_messages ilp32 object {
1704 int dummy[sizeof (int) == 4
1705 && sizeof (void *) == 4
1706 && sizeof (long) == 4 ? 1 : -1];
1710 # Return 1 if we're generating ia32 code using default options, 0
1711 # otherwise.
1713 proc check_effective_target_ia32 { } {
1714 return [check_no_compiler_messages ia32 object {
1715 int dummy[sizeof (int) == 4
1716 && sizeof (void *) == 4
1717 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1721 # Return 1 if we're generating x32 code using default options, 0
1722 # otherwise.
1724 proc check_effective_target_x32 { } {
1725 return [check_no_compiler_messages x32 object {
1726 int dummy[sizeof (int) == 4
1727 && sizeof (void *) == 4
1728 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1732 # Return 1 if we're generating 32-bit integers using default
1733 # options, 0 otherwise.
1735 proc check_effective_target_int32 { } {
1736 return [check_no_compiler_messages int32 object {
1737 int dummy[sizeof (int) == 4 ? 1 : -1];
1741 # Return 1 if we're generating 32-bit or larger integers using default
1742 # options, 0 otherwise.
1744 proc check_effective_target_int32plus { } {
1745 return [check_no_compiler_messages int32plus object {
1746 int dummy[sizeof (int) >= 4 ? 1 : -1];
1750 # Return 1 if we're generating 32-bit or larger pointers using default
1751 # options, 0 otherwise.
1753 proc check_effective_target_ptr32plus { } {
1754 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
1755 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
1756 # cannot really hold a 32-bit address, so we always return false here.
1757 if { [istarget msp430-*-*] } {
1758 return 0
1761 return [check_no_compiler_messages ptr32plus object {
1762 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1766 # Return 1 if we support 32-bit or larger array and structure sizes
1767 # using default options, 0 otherwise.
1769 proc check_effective_target_size32plus { } {
1770 return [check_no_compiler_messages size32plus object {
1771 char dummy[65537];
1775 # Returns 1 if we're generating 16-bit or smaller integers with the
1776 # default options, 0 otherwise.
1778 proc check_effective_target_int16 { } {
1779 return [check_no_compiler_messages int16 object {
1780 int dummy[sizeof (int) < 4 ? 1 : -1];
1784 # Return 1 if we're generating 64-bit code using default options, 0
1785 # otherwise.
1787 proc check_effective_target_lp64 { } {
1788 return [check_no_compiler_messages lp64 object {
1789 int dummy[sizeof (int) == 4
1790 && sizeof (void *) == 8
1791 && sizeof (long) == 8 ? 1 : -1];
1795 # Return 1 if we're generating 64-bit code using default llp64 options,
1796 # 0 otherwise.
1798 proc check_effective_target_llp64 { } {
1799 return [check_no_compiler_messages llp64 object {
1800 int dummy[sizeof (int) == 4
1801 && sizeof (void *) == 8
1802 && sizeof (long long) == 8
1803 && sizeof (long) == 4 ? 1 : -1];
1807 # Return 1 if long and int have different sizes,
1808 # 0 otherwise.
1810 proc check_effective_target_long_neq_int { } {
1811 return [check_no_compiler_messages long_ne_int object {
1812 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
1816 # Return 1 if the target supports long double larger than double,
1817 # 0 otherwise.
1819 proc check_effective_target_large_long_double { } {
1820 return [check_no_compiler_messages large_long_double object {
1821 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1825 # Return 1 if the target supports double larger than float,
1826 # 0 otherwise.
1828 proc check_effective_target_large_double { } {
1829 return [check_no_compiler_messages large_double object {
1830 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1834 # Return 1 if the target supports double of 64 bits,
1835 # 0 otherwise.
1837 proc check_effective_target_double64 { } {
1838 return [check_no_compiler_messages double64 object {
1839 int dummy[sizeof(double) == 8 ? 1 : -1];
1843 # Return 1 if the target supports double of at least 64 bits,
1844 # 0 otherwise.
1846 proc check_effective_target_double64plus { } {
1847 return [check_no_compiler_messages double64plus object {
1848 int dummy[sizeof(double) >= 8 ? 1 : -1];
1852 # Return 1 if the target supports 'w' suffix on floating constant
1853 # 0 otherwise.
1855 proc check_effective_target_has_w_floating_suffix { } {
1856 set opts ""
1857 if [check_effective_target_c++] {
1858 append opts "-std=gnu++03"
1860 return [check_no_compiler_messages w_fp_suffix object {
1861 float dummy = 1.0w;
1862 } "$opts"]
1865 # Return 1 if the target supports 'q' suffix on floating constant
1866 # 0 otherwise.
1868 proc check_effective_target_has_q_floating_suffix { } {
1869 set opts ""
1870 if [check_effective_target_c++] {
1871 append opts "-std=gnu++03"
1873 return [check_no_compiler_messages q_fp_suffix object {
1874 float dummy = 1.0q;
1875 } "$opts"]
1877 # Return 1 if the target supports compiling fixed-point,
1878 # 0 otherwise.
1880 proc check_effective_target_fixed_point { } {
1881 return [check_no_compiler_messages fixed_point object {
1882 _Sat _Fract x; _Sat _Accum y;
1886 # Return 1 if the target supports compiling decimal floating point,
1887 # 0 otherwise.
1889 proc check_effective_target_dfp_nocache { } {
1890 verbose "check_effective_target_dfp_nocache: compiling source" 2
1891 set ret [check_no_compiler_messages_nocache dfp object {
1892 float x __attribute__((mode(DD)));
1894 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1895 return $ret
1898 proc check_effective_target_dfprt_nocache { } {
1899 return [check_runtime_nocache dfprt {
1900 typedef float d64 __attribute__((mode(DD)));
1901 d64 x = 1.2df, y = 2.3dd, z;
1902 int main () { z = x + y; return 0; }
1906 # Return 1 if the target supports compiling Decimal Floating Point,
1907 # 0 otherwise.
1909 # This won't change for different subtargets so cache the result.
1911 proc check_effective_target_dfp { } {
1912 return [check_cached_effective_target dfp {
1913 check_effective_target_dfp_nocache
1917 # Return 1 if the target supports linking and executing Decimal Floating
1918 # Point, 0 otherwise.
1920 # This won't change for different subtargets so cache the result.
1922 proc check_effective_target_dfprt { } {
1923 return [check_cached_effective_target dfprt {
1924 check_effective_target_dfprt_nocache
1928 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1930 proc check_effective_target_ucn_nocache { } {
1931 # -std=c99 is only valid for C
1932 if [check_effective_target_c] {
1933 set ucnopts "-std=c99"
1935 append ucnopts " -fextended-identifiers"
1936 verbose "check_effective_target_ucn_nocache: compiling source" 2
1937 set ret [check_no_compiler_messages_nocache ucn object {
1938 int \u00C0;
1939 } $ucnopts]
1940 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1941 return $ret
1944 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1946 # This won't change for different subtargets, so cache the result.
1948 proc check_effective_target_ucn { } {
1949 return [check_cached_effective_target ucn {
1950 check_effective_target_ucn_nocache
1954 # Return 1 if the target needs a command line argument to enable a SIMD
1955 # instruction set.
1957 proc check_effective_target_vect_cmdline_needed { } {
1958 global et_vect_cmdline_needed_saved
1959 global et_vect_cmdline_needed_target_name
1961 if { ![info exists et_vect_cmdline_needed_target_name] } {
1962 set et_vect_cmdline_needed_target_name ""
1965 # If the target has changed since we set the cached value, clear it.
1966 set current_target [current_target_name]
1967 if { $current_target != $et_vect_cmdline_needed_target_name } {
1968 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1969 set et_vect_cmdline_needed_target_name $current_target
1970 if { [info exists et_vect_cmdline_needed_saved] } {
1971 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1972 unset et_vect_cmdline_needed_saved
1976 if [info exists et_vect_cmdline_needed_saved] {
1977 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1978 } else {
1979 set et_vect_cmdline_needed_saved 1
1980 if { [istarget alpha*-*-*]
1981 || [istarget ia64-*-*]
1982 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1983 && ([check_effective_target_x32]
1984 || [check_effective_target_lp64]))
1985 || ([istarget powerpc*-*-*]
1986 && ([check_effective_target_powerpc_spe]
1987 || [check_effective_target_powerpc_altivec]))
1988 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1989 || [istarget spu-*-*]
1990 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1991 set et_vect_cmdline_needed_saved 0
1995 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1996 return $et_vect_cmdline_needed_saved
1999 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2001 # This won't change for different subtargets so cache the result.
2003 proc check_effective_target_vect_int { } {
2004 global et_vect_int_saved
2006 if [info exists et_vect_int_saved] {
2007 verbose "check_effective_target_vect_int: using cached result" 2
2008 } else {
2009 set et_vect_int_saved 0
2010 if { [istarget i?86-*-*]
2011 || ([istarget powerpc*-*-*]
2012 && ![istarget powerpc-*-linux*paired*])
2013 || [istarget spu-*-*]
2014 || [istarget x86_64-*-*]
2015 || [istarget sparc*-*-*]
2016 || [istarget alpha*-*-*]
2017 || [istarget ia64-*-*]
2018 || [istarget aarch64*-*-*]
2019 || [check_effective_target_arm32]
2020 || ([istarget mips*-*-*]
2021 && [check_effective_target_mips_loongson]) } {
2022 set et_vect_int_saved 1
2026 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2027 return $et_vect_int_saved
2030 # Return 1 if the target supports signed int->float conversion
2033 proc check_effective_target_vect_intfloat_cvt { } {
2034 global et_vect_intfloat_cvt_saved
2036 if [info exists et_vect_intfloat_cvt_saved] {
2037 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2038 } else {
2039 set et_vect_intfloat_cvt_saved 0
2040 if { [istarget i?86-*-*]
2041 || ([istarget powerpc*-*-*]
2042 && ![istarget powerpc-*-linux*paired*])
2043 || [istarget x86_64-*-*]
2044 || ([istarget arm*-*-*]
2045 && [check_effective_target_arm_neon_ok])} {
2046 set et_vect_intfloat_cvt_saved 1
2050 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2051 return $et_vect_intfloat_cvt_saved
2054 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2056 proc check_effective_target_int128 { } {
2057 return [check_no_compiler_messages int128 object {
2058 int dummy[
2059 #ifndef __SIZEOF_INT128__
2061 #else
2063 #endif
2068 # Return 1 if the target supports unsigned int->float conversion
2071 proc check_effective_target_vect_uintfloat_cvt { } {
2072 global et_vect_uintfloat_cvt_saved
2074 if [info exists et_vect_uintfloat_cvt_saved] {
2075 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2076 } else {
2077 set et_vect_uintfloat_cvt_saved 0
2078 if { [istarget i?86-*-*]
2079 || ([istarget powerpc*-*-*]
2080 && ![istarget powerpc-*-linux*paired*])
2081 || [istarget x86_64-*-*]
2082 || [istarget aarch64*-*-*]
2083 || ([istarget arm*-*-*]
2084 && [check_effective_target_arm_neon_ok])} {
2085 set et_vect_uintfloat_cvt_saved 1
2089 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2090 return $et_vect_uintfloat_cvt_saved
2094 # Return 1 if the target supports signed float->int conversion
2097 proc check_effective_target_vect_floatint_cvt { } {
2098 global et_vect_floatint_cvt_saved
2100 if [info exists et_vect_floatint_cvt_saved] {
2101 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2102 } else {
2103 set et_vect_floatint_cvt_saved 0
2104 if { [istarget i?86-*-*]
2105 || ([istarget powerpc*-*-*]
2106 && ![istarget powerpc-*-linux*paired*])
2107 || [istarget x86_64-*-*]
2108 || ([istarget arm*-*-*]
2109 && [check_effective_target_arm_neon_ok])} {
2110 set et_vect_floatint_cvt_saved 1
2114 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2115 return $et_vect_floatint_cvt_saved
2118 # Return 1 if the target supports unsigned float->int conversion
2121 proc check_effective_target_vect_floatuint_cvt { } {
2122 global et_vect_floatuint_cvt_saved
2124 if [info exists et_vect_floatuint_cvt_saved] {
2125 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2126 } else {
2127 set et_vect_floatuint_cvt_saved 0
2128 if { ([istarget powerpc*-*-*]
2129 && ![istarget powerpc-*-linux*paired*])
2130 || ([istarget arm*-*-*]
2131 && [check_effective_target_arm_neon_ok])} {
2132 set et_vect_floatuint_cvt_saved 1
2136 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2137 return $et_vect_floatuint_cvt_saved
2140 # Return 1 if this is a AArch64 target supporting big endian
2141 proc check_effective_target_aarch64_big_endian { } {
2142 return [check_no_compiler_messages aarch64_big_endian assembly {
2143 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2144 #error FOO
2145 #endif
2149 # Return 1 if this is a AArch64 target supporting little endian
2150 proc check_effective_target_aarch64_little_endian { } {
2151 return [check_no_compiler_messages aarch64_little_endian assembly {
2152 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2153 #error FOO
2154 #endif
2158 # Return 1 is this is an arm target using 32-bit instructions
2159 proc check_effective_target_arm32 { } {
2160 return [check_no_compiler_messages arm32 assembly {
2161 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2162 #error FOO
2163 #endif
2167 # Return 1 is this is an arm target not using Thumb
2168 proc check_effective_target_arm_nothumb { } {
2169 return [check_no_compiler_messages arm_nothumb assembly {
2170 #if (defined(__thumb__) || defined(__thumb2__))
2171 #error FOO
2172 #endif
2176 # Return 1 if this is a little-endian ARM target
2177 proc check_effective_target_arm_little_endian { } {
2178 return [check_no_compiler_messages arm_little_endian assembly {
2179 #if !defined(__arm__) || !defined(__ARMEL__)
2180 #error FOO
2181 #endif
2185 # Return 1 if this is an ARM target that only supports aligned vector accesses
2186 proc check_effective_target_arm_vect_no_misalign { } {
2187 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2188 #if !defined(__arm__) \
2189 || (defined(__ARMEL__) \
2190 && (!defined(__thumb__) || defined(__thumb2__)))
2191 #error FOO
2192 #endif
2197 # Return 1 if this is an ARM target supporting -mfpu=vfp
2198 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2199 # options.
2201 proc check_effective_target_arm_vfp_ok { } {
2202 if { [check_effective_target_arm32] } {
2203 return [check_no_compiler_messages arm_vfp_ok object {
2204 int dummy;
2205 } "-mfpu=vfp -mfloat-abi=softfp"]
2206 } else {
2207 return 0
2211 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2212 # -mfloat-abi=softfp.
2213 proc check_effective_target_arm_v8_vfp_ok {} {
2214 if { [check_effective_target_arm32] } {
2215 return [check_no_compiler_messages arm_v8_vfp_ok object {
2216 int foo (void)
2218 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2219 return 0;
2221 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2222 } else {
2223 return 0
2227 # Return 1 if this is an ARM target supporting -mfpu=vfp
2228 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2229 # options.
2231 proc check_effective_target_arm_hard_vfp_ok { } {
2232 if { [check_effective_target_arm32]
2233 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2234 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2235 int main() { return 0;}
2236 } "-mfpu=vfp -mfloat-abi=hard"]
2237 } else {
2238 return 0
2242 # Return 1 if this is an ARM target that supports DSP multiply with
2243 # current multilib flags.
2245 proc check_effective_target_arm_dsp { } {
2246 return [check_no_compiler_messages arm_dsp assembly {
2247 #ifndef __ARM_FEATURE_DSP
2248 #error not DSP
2249 #endif
2250 int i;
2254 # Return 1 if this is an ARM target that supports unaligned word/halfword
2255 # load/store instructions.
2257 proc check_effective_target_arm_unaligned { } {
2258 return [check_no_compiler_messages arm_unaligned assembly {
2259 #ifndef __ARM_FEATURE_UNALIGNED
2260 #error no unaligned support
2261 #endif
2262 int i;
2266 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2267 # or -mfloat-abi=hard, but if one is already specified by the
2268 # multilib, use it. Similarly, if a -mfpu option already enables
2269 # NEON, do not add -mfpu=neon.
2271 proc add_options_for_arm_neon { flags } {
2272 if { ! [check_effective_target_arm_neon_ok] } {
2273 return "$flags"
2275 global et_arm_neon_flags
2276 return "$flags $et_arm_neon_flags"
2279 proc add_options_for_arm_v8_vfp { flags } {
2280 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2281 return "$flags"
2283 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2286 proc add_options_for_arm_v8_neon { flags } {
2287 if { ! [check_effective_target_arm_v8_neon_ok] } {
2288 return "$flags"
2290 global et_arm_v8_neon_flags
2291 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2294 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2295 # or -mfloat-abi=hard, but if one is already specified by the
2296 # multilib, use it. Similarly, if a -mfpu option already enables
2297 # NEON, do not add -mfpu=neon.
2299 proc add_options_for_arm_neonv2 { flags } {
2300 if { ! [check_effective_target_arm_neonv2_ok] } {
2301 return "$flags"
2303 global et_arm_neonv2_flags
2304 return "$flags $et_arm_neonv2_flags"
2307 # Return 1 if this is an ARM target supporting -mfpu=neon
2308 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2309 # incompatible with these options. Also set et_arm_neon_flags to the
2310 # best options to add.
2312 proc check_effective_target_arm_neon_ok_nocache { } {
2313 global et_arm_neon_flags
2314 set et_arm_neon_flags ""
2315 if { [check_effective_target_arm32] } {
2316 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2317 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2318 #include "arm_neon.h"
2319 int dummy;
2320 } "$flags"] } {
2321 set et_arm_neon_flags $flags
2322 return 1
2327 return 0
2330 proc check_effective_target_arm_neon_ok { } {
2331 return [check_cached_effective_target arm_neon_ok \
2332 check_effective_target_arm_neon_ok_nocache]
2335 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2336 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2337 # incompatible with these options. Also set et_arm_neon_flags to the
2338 # best options to add.
2340 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2341 global et_arm_neon_fp16_flags
2342 set et_arm_neon_fp16_flags ""
2343 if { [check_effective_target_arm32] } {
2344 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2345 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
2346 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2347 #include "arm_neon.h"
2348 float16x4_t
2349 foo (float32x4_t arg)
2351 return vcvt_f16_f32 (arg);
2353 } "$flags"] } {
2354 set et_arm_neon_fp16_flags $flags
2355 return 1
2360 return 0
2363 proc check_effective_target_arm_neon_fp16_ok { } {
2364 return [check_cached_effective_target arm_neon_fp16_ok \
2365 check_effective_target_arm_neon_fp16_ok_nocache]
2368 proc add_options_for_arm_neon_fp16 { flags } {
2369 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2370 return "$flags"
2372 global et_arm_neon_fp16_flags
2373 return "$flags $et_arm_neon_fp16_flags"
2376 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2377 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2378 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2379 # best options to add.
2381 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2382 global et_arm_v8_neon_flags
2383 set et_arm_v8_neon_flags ""
2384 if { [check_effective_target_arm32] } {
2385 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2386 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2387 #include "arm_neon.h"
2388 void
2389 foo ()
2391 __asm__ volatile ("vrintn.f32 q0, q0");
2393 } "$flags"] } {
2394 set et_arm_v8_neon_flags $flags
2395 return 1
2400 return 0
2403 proc check_effective_target_arm_v8_neon_ok { } {
2404 return [check_cached_effective_target arm_v8_neon_ok \
2405 check_effective_target_arm_v8_neon_ok_nocache]
2408 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2409 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2410 # incompatible with these options. Also set et_arm_neonv2_flags to the
2411 # best options to add.
2413 proc check_effective_target_arm_neonv2_ok_nocache { } {
2414 global et_arm_neonv2_flags
2415 set et_arm_neonv2_flags ""
2416 if { [check_effective_target_arm32] } {
2417 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2418 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2419 #include "arm_neon.h"
2420 float32x2_t
2421 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2423 return vfma_f32 (a, b, c);
2425 } "$flags"] } {
2426 set et_arm_neonv2_flags $flags
2427 return 1
2432 return 0
2435 proc check_effective_target_arm_neonv2_ok { } {
2436 return [check_cached_effective_target arm_neonv2_ok \
2437 check_effective_target_arm_neonv2_ok_nocache]
2440 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2441 # or -mfloat-abi=hard, but if one is already specified by the
2442 # multilib, use it.
2444 proc add_options_for_arm_fp16 { flags } {
2445 if { ! [check_effective_target_arm_fp16_ok] } {
2446 return "$flags"
2448 global et_arm_fp16_flags
2449 return "$flags $et_arm_fp16_flags"
2452 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2453 # Skip multilibs that are incompatible with these options and set
2454 # et_arm_fp16_flags to the best options to add.
2456 proc check_effective_target_arm_fp16_ok_nocache { } {
2457 global et_arm_fp16_flags
2458 set et_arm_fp16_flags ""
2459 if { ! [check_effective_target_arm32] } {
2460 return 0;
2462 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2463 # Multilib flags would override -mfpu.
2464 return 0
2466 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2467 # Must generate floating-point instructions.
2468 return 0
2470 if [check_effective_target_arm_hf_eabi] {
2471 # Use existing float-abi and force an fpu which supports fp16
2472 set et_arm_fp16_flags "-mfpu=vfpv4"
2473 return 1;
2475 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2476 # The existing -mfpu value is OK; use it, but add softfp.
2477 set et_arm_fp16_flags "-mfloat-abi=softfp"
2478 return 1;
2480 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2481 # macro to check for this support.
2482 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2483 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2484 int dummy;
2485 } "$flags"] } {
2486 set et_arm_fp16_flags "$flags"
2487 return 1
2490 return 0
2493 proc check_effective_target_arm_fp16_ok { } {
2494 return [check_cached_effective_target arm_fp16_ok \
2495 check_effective_target_arm_fp16_ok_nocache]
2498 # Creates a series of routines that return 1 if the given architecture
2499 # can be selected and a routine to give the flags to select that architecture
2500 # Note: Extra flags may be added to disable options from newer compilers
2501 # (Thumb in particular - but others may be added in the future)
2502 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2503 # /* { dg-add-options arm_arch_v5 } */
2504 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2505 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2506 v4t "-march=armv4t" __ARM_ARCH_4T__
2507 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2508 v5t "-march=armv5t" __ARM_ARCH_5T__
2509 v5te "-march=armv5te" __ARM_ARCH_5TE__
2510 v6 "-march=armv6" __ARM_ARCH_6__
2511 v6k "-march=armv6k" __ARM_ARCH_6K__
2512 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2513 v6z "-march=armv6z" __ARM_ARCH_6Z__
2514 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2515 v7a "-march=armv7-a" __ARM_ARCH_7A__
2516 v7r "-march=armv7-r" __ARM_ARCH_7R__
2517 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2518 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2519 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2520 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2521 proc check_effective_target_arm_arch_FUNC_ok { } {
2522 if { [ string match "*-marm*" "FLAG" ] &&
2523 ![check_effective_target_arm_arm_ok] } {
2524 return 0
2526 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2527 #if !defined (DEF)
2528 #error FOO
2529 #endif
2530 } "FLAG" ]
2533 proc add_options_for_arm_arch_FUNC { flags } {
2534 return "$flags FLAG"
2537 proc check_effective_target_arm_arch_FUNC_multilib { } {
2538 return [check_runtime arm_arch_FUNC_multilib {
2540 main (void)
2542 return 0;
2544 } [add_options_for_arm_arch_FUNC ""]]
2549 # Return 1 if this is an ARM target where -marm causes ARM to be
2550 # used (not Thumb)
2552 proc check_effective_target_arm_arm_ok { } {
2553 return [check_no_compiler_messages arm_arm_ok assembly {
2554 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2555 #error FOO
2556 #endif
2557 } "-marm"]
2561 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2562 # used.
2564 proc check_effective_target_arm_thumb1_ok { } {
2565 return [check_no_compiler_messages arm_thumb1_ok assembly {
2566 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2567 #error FOO
2568 #endif
2569 } "-mthumb"]
2572 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2573 # used.
2575 proc check_effective_target_arm_thumb2_ok { } {
2576 return [check_no_compiler_messages arm_thumb2_ok assembly {
2577 #if !defined(__thumb2__)
2578 #error FOO
2579 #endif
2580 } "-mthumb"]
2583 # Return 1 if this is an ARM target where Thumb-1 is used without options
2584 # added by the test.
2586 proc check_effective_target_arm_thumb1 { } {
2587 return [check_no_compiler_messages arm_thumb1 assembly {
2588 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2589 #error not thumb1
2590 #endif
2591 int i;
2592 } ""]
2595 # Return 1 if this is an ARM target where Thumb-2 is used without options
2596 # added by the test.
2598 proc check_effective_target_arm_thumb2 { } {
2599 return [check_no_compiler_messages arm_thumb2 assembly {
2600 #if !defined(__thumb2__)
2601 #error FOO
2602 #endif
2603 int i;
2604 } ""]
2607 # Return 1 if this is an ARM target where conditional execution is available.
2609 proc check_effective_target_arm_cond_exec { } {
2610 return [check_no_compiler_messages arm_cond_exec assembly {
2611 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
2612 #error FOO
2613 #endif
2614 int i;
2615 } ""]
2618 # Return 1 if this is an ARM cortex-M profile cpu
2620 proc check_effective_target_arm_cortex_m { } {
2621 return [check_no_compiler_messages arm_cortex_m assembly {
2622 #if !defined(__ARM_ARCH_7M__) \
2623 && !defined (__ARM_ARCH_7EM__) \
2624 && !defined (__ARM_ARCH_6M__)
2625 #error FOO
2626 #endif
2627 int i;
2628 } "-mthumb"]
2631 # Return 1 if the target supports executing NEON instructions, 0
2632 # otherwise. Cache the result.
2634 proc check_effective_target_arm_neon_hw { } {
2635 return [check_runtime arm_neon_hw_available {
2637 main (void)
2639 long long a = 0, b = 1;
2640 asm ("vorr %P0, %P1, %P2"
2641 : "=w" (a)
2642 : "0" (a), "w" (b));
2643 return (a != 1);
2645 } [add_options_for_arm_neon ""]]
2648 proc check_effective_target_arm_neonv2_hw { } {
2649 return [check_runtime arm_neon_hwv2_available {
2650 #include "arm_neon.h"
2652 main (void)
2654 float32x2_t a, b, c;
2655 asm ("vfma.f32 %P0, %P1, %P2"
2656 : "=w" (a)
2657 : "w" (b), "w" (c));
2658 return 0;
2660 } [add_options_for_arm_neonv2 ""]]
2663 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
2664 # otherwise.
2666 proc check_effective_target_arm_v8_neon_hw { } {
2667 return [check_runtime arm_v8_neon_hw_available {
2668 #include "arm_neon.h"
2670 main (void)
2672 float32x2_t a;
2673 asm ("vrinta.f32 %P0, %P1"
2674 : "=w" (a)
2675 : "0" (a));
2676 return 0;
2678 } [add_options_for_arm_v8_neon ""]]
2681 # Return 1 if this is a ARM target with NEON enabled.
2683 proc check_effective_target_arm_neon { } {
2684 if { [check_effective_target_arm32] } {
2685 return [check_no_compiler_messages arm_neon object {
2686 #ifndef __ARM_NEON__
2687 #error not NEON
2688 #else
2689 int dummy;
2690 #endif
2692 } else {
2693 return 0
2697 proc check_effective_target_arm_neonv2 { } {
2698 if { [check_effective_target_arm32] } {
2699 return [check_no_compiler_messages arm_neon object {
2700 #ifndef __ARM_NEON__
2701 #error not NEON
2702 #else
2703 #ifndef __ARM_FEATURE_FMA
2704 #error not NEONv2
2705 #else
2706 int dummy;
2707 #endif
2708 #endif
2710 } else {
2711 return 0
2715 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2716 # the Loongson vector modes.
2718 proc check_effective_target_mips_loongson { } {
2719 return [check_no_compiler_messages loongson assembly {
2720 #if !defined(__mips_loongson_vector_rev)
2721 #error FOO
2722 #endif
2726 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2727 # Architecture.
2729 proc check_effective_target_arm_eabi { } {
2730 return [check_no_compiler_messages arm_eabi object {
2731 #ifndef __ARM_EABI__
2732 #error not EABI
2733 #else
2734 int dummy;
2735 #endif
2739 # Return 1 if this is an ARM target that adheres to the hard-float variant of
2740 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
2742 proc check_effective_target_arm_hf_eabi { } {
2743 return [check_no_compiler_messages arm_hf_eabi object {
2744 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
2745 #error not hard-float EABI
2746 #else
2747 int dummy;
2748 #endif
2752 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2753 # Some multilibs may be incompatible with this option.
2755 proc check_effective_target_arm_iwmmxt_ok { } {
2756 if { [check_effective_target_arm32] } {
2757 return [check_no_compiler_messages arm_iwmmxt_ok object {
2758 int dummy;
2759 } "-mcpu=iwmmxt"]
2760 } else {
2761 return 0
2765 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
2766 # for an ARM target.
2767 proc check_effective_target_arm_prefer_ldrd_strd { } {
2768 if { ![check_effective_target_arm32] } {
2769 return 0;
2772 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
2773 void foo (int *p) { p[0] = 1; p[1] = 0;}
2774 } "-O2 -mthumb" ]
2777 # Return 1 if this is a PowerPC target supporting -meabi.
2779 proc check_effective_target_powerpc_eabi_ok { } {
2780 if { [istarget powerpc*-*-*] } {
2781 return [check_no_compiler_messages powerpc_eabi_ok object {
2782 int dummy;
2783 } "-meabi"]
2784 } else {
2785 return 0
2789 # Return 1 if this is a PowerPC target with floating-point registers.
2791 proc check_effective_target_powerpc_fprs { } {
2792 if { [istarget powerpc*-*-*]
2793 || [istarget rs6000-*-*] } {
2794 return [check_no_compiler_messages powerpc_fprs object {
2795 #ifdef __NO_FPRS__
2796 #error no FPRs
2797 #else
2798 int dummy;
2799 #endif
2801 } else {
2802 return 0
2806 # Return 1 if this is a PowerPC target with hardware double-precision
2807 # floating point.
2809 proc check_effective_target_powerpc_hard_double { } {
2810 if { [istarget powerpc*-*-*]
2811 || [istarget rs6000-*-*] } {
2812 return [check_no_compiler_messages powerpc_hard_double object {
2813 #ifdef _SOFT_DOUBLE
2814 #error soft double
2815 #else
2816 int dummy;
2817 #endif
2819 } else {
2820 return 0
2824 # Return 1 if this is a PowerPC target supporting -maltivec.
2826 proc check_effective_target_powerpc_altivec_ok { } {
2827 if { ([istarget powerpc*-*-*]
2828 && ![istarget powerpc-*-linux*paired*])
2829 || [istarget rs6000-*-*] } {
2830 # AltiVec is not supported on AIX before 5.3.
2831 if { [istarget powerpc*-*-aix4*]
2832 || [istarget powerpc*-*-aix5.1*]
2833 || [istarget powerpc*-*-aix5.2*] } {
2834 return 0
2836 return [check_no_compiler_messages powerpc_altivec_ok object {
2837 int dummy;
2838 } "-maltivec"]
2839 } else {
2840 return 0
2844 # Return 1 if this is a PowerPC target supporting -mpower8-vector
2846 proc check_effective_target_powerpc_p8vector_ok { } {
2847 if { ([istarget powerpc*-*-*]
2848 && ![istarget powerpc-*-linux*paired*])
2849 || [istarget rs6000-*-*] } {
2850 # AltiVec is not supported on AIX before 5.3.
2851 if { [istarget powerpc*-*-aix4*]
2852 || [istarget powerpc*-*-aix5.1*]
2853 || [istarget powerpc*-*-aix5.2*] } {
2854 return 0
2856 return [check_no_compiler_messages powerpc_p8vector_ok object {
2857 int main (void) {
2858 #ifdef __MACH__
2859 asm volatile ("xxlorc vs0,vs0,vs0");
2860 #else
2861 asm volatile ("xxlorc 0,0,0");
2862 #endif
2863 return 0;
2865 } "-mpower8-vector"]
2866 } else {
2867 return 0
2871 # Return 1 if this is a PowerPC target supporting -mvsx
2873 proc check_effective_target_powerpc_vsx_ok { } {
2874 if { ([istarget powerpc*-*-*]
2875 && ![istarget powerpc-*-linux*paired*])
2876 || [istarget rs6000-*-*] } {
2877 # VSX is not supported on AIX before 7.1.
2878 if { [istarget powerpc*-*-aix4*]
2879 || [istarget powerpc*-*-aix5*]
2880 || [istarget powerpc*-*-aix6*] } {
2881 return 0
2883 return [check_no_compiler_messages powerpc_vsx_ok object {
2884 int main (void) {
2885 #ifdef __MACH__
2886 asm volatile ("xxlor vs0,vs0,vs0");
2887 #else
2888 asm volatile ("xxlor 0,0,0");
2889 #endif
2890 return 0;
2892 } "-mvsx"]
2893 } else {
2894 return 0
2898 # Return 1 if this is a PowerPC target supporting -mhtm
2900 proc check_effective_target_powerpc_htm_ok { } {
2901 if { ([istarget powerpc*-*-*]
2902 && ![istarget powerpc-*-linux*paired*])
2903 || [istarget rs6000-*-*] } {
2904 # HTM is not supported on AIX yet.
2905 if { [istarget powerpc*-*-aix*] } {
2906 return 0
2908 return [check_no_compiler_messages powerpc_htm_ok object {
2909 int main (void) {
2910 asm volatile ("tbegin. 0");
2911 return 0;
2913 } "-mhtm"]
2914 } else {
2915 return 0
2919 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2921 proc check_effective_target_powerpc_ppu_ok { } {
2922 if [check_effective_target_powerpc_altivec_ok] {
2923 return [check_no_compiler_messages cell_asm_available object {
2924 int main (void) {
2925 #ifdef __MACH__
2926 asm volatile ("lvlx v0,v0,v0");
2927 #else
2928 asm volatile ("lvlx 0,0,0");
2929 #endif
2930 return 0;
2933 } else {
2934 return 0
2938 # Return 1 if this is a PowerPC target that supports SPU.
2940 proc check_effective_target_powerpc_spu { } {
2941 if { [istarget powerpc*-*-linux*] } {
2942 return [check_effective_target_powerpc_altivec_ok]
2943 } else {
2944 return 0
2948 # Return 1 if this is a PowerPC SPE target. The check includes options
2949 # specified by dg-options for this test, so don't cache the result.
2951 proc check_effective_target_powerpc_spe_nocache { } {
2952 if { [istarget powerpc*-*-*] } {
2953 return [check_no_compiler_messages_nocache powerpc_spe object {
2954 #ifndef __SPE__
2955 #error not SPE
2956 #else
2957 int dummy;
2958 #endif
2959 } [current_compiler_flags]]
2960 } else {
2961 return 0
2965 # Return 1 if this is a PowerPC target with SPE enabled.
2967 proc check_effective_target_powerpc_spe { } {
2968 if { [istarget powerpc*-*-*] } {
2969 return [check_no_compiler_messages powerpc_spe object {
2970 #ifndef __SPE__
2971 #error not SPE
2972 #else
2973 int dummy;
2974 #endif
2976 } else {
2977 return 0
2981 # Return 1 if this is a PowerPC target with Altivec enabled.
2983 proc check_effective_target_powerpc_altivec { } {
2984 if { [istarget powerpc*-*-*] } {
2985 return [check_no_compiler_messages powerpc_altivec object {
2986 #ifndef __ALTIVEC__
2987 #error not Altivec
2988 #else
2989 int dummy;
2990 #endif
2992 } else {
2993 return 0
2997 # Return 1 if this is a PowerPC 405 target. The check includes options
2998 # specified by dg-options for this test, so don't cache the result.
3000 proc check_effective_target_powerpc_405_nocache { } {
3001 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3002 return [check_no_compiler_messages_nocache powerpc_405 object {
3003 #ifdef __PPC405__
3004 int dummy;
3005 #else
3006 #error not a PPC405
3007 #endif
3008 } [current_compiler_flags]]
3009 } else {
3010 return 0
3014 # Return 1 if this is a SPU target with a toolchain that
3015 # supports automatic overlay generation.
3017 proc check_effective_target_spu_auto_overlay { } {
3018 if { [istarget spu*-*-elf*] } {
3019 return [check_no_compiler_messages spu_auto_overlay executable {
3020 int main (void) { }
3021 } "-Wl,--auto-overlay" ]
3022 } else {
3023 return 0
3027 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3028 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3029 # test environment appears to run executables on such a simulator.
3031 proc check_effective_target_ultrasparc_hw { } {
3032 return [check_runtime ultrasparc_hw {
3033 int main() { return 0; }
3034 } "-mcpu=ultrasparc"]
3037 # Return 1 if the test environment supports executing UltraSPARC VIS2
3038 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3040 proc check_effective_target_ultrasparc_vis2_hw { } {
3041 return [check_runtime ultrasparc_vis2_hw {
3042 int main() { __asm__(".word 0x81b00320"); return 0; }
3043 } "-mcpu=ultrasparc3"]
3046 # Return 1 if the test environment supports executing UltraSPARC VIS3
3047 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3049 proc check_effective_target_ultrasparc_vis3_hw { } {
3050 return [check_runtime ultrasparc_vis3_hw {
3051 int main() { __asm__(".word 0x81b00220"); return 0; }
3052 } "-mcpu=niagara3"]
3055 # Return 1 if this is a SPARC-V9 target.
3057 proc check_effective_target_sparc_v9 { } {
3058 if { [istarget sparc*-*-*] } {
3059 return [check_no_compiler_messages sparc_v9 object {
3060 int main (void) {
3061 asm volatile ("return %i7+8");
3062 return 0;
3065 } else {
3066 return 0
3070 # Return 1 if this is a SPARC target with VIS enabled.
3072 proc check_effective_target_sparc_vis { } {
3073 if { [istarget sparc*-*-*] } {
3074 return [check_no_compiler_messages sparc_vis object {
3075 #ifndef __VIS__
3076 #error not VIS
3077 #else
3078 int dummy;
3079 #endif
3081 } else {
3082 return 0
3086 # Return 1 if the target supports hardware vector shift operation.
3088 proc check_effective_target_vect_shift { } {
3089 global et_vect_shift_saved
3091 if [info exists et_vect_shift_saved] {
3092 verbose "check_effective_target_vect_shift: using cached result" 2
3093 } else {
3094 set et_vect_shift_saved 0
3095 if { ([istarget powerpc*-*-*]
3096 && ![istarget powerpc-*-linux*paired*])
3097 || [istarget ia64-*-*]
3098 || [istarget i?86-*-*]
3099 || [istarget x86_64-*-*]
3100 || [istarget aarch64*-*-*]
3101 || [check_effective_target_arm32]
3102 || ([istarget mips*-*-*]
3103 && [check_effective_target_mips_loongson]) } {
3104 set et_vect_shift_saved 1
3108 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3109 return $et_vect_shift_saved
3112 # Return 1 if the target supports hardware vector shift operation for char.
3114 proc check_effective_target_vect_shift_char { } {
3115 global et_vect_shift_char_saved
3117 if [info exists et_vect_shift_char_saved] {
3118 verbose "check_effective_target_vect_shift_char: using cached result" 2
3119 } else {
3120 set et_vect_shift_char_saved 0
3121 if { ([istarget powerpc*-*-*]
3122 && ![istarget powerpc-*-linux*paired*])
3123 || [check_effective_target_arm32] } {
3124 set et_vect_shift_char_saved 1
3128 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3129 return $et_vect_shift_char_saved
3132 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3134 # This can change for different subtargets so do not cache the result.
3136 proc check_effective_target_vect_long { } {
3137 if { [istarget i?86-*-*]
3138 || (([istarget powerpc*-*-*]
3139 && ![istarget powerpc-*-linux*paired*])
3140 && [check_effective_target_ilp32])
3141 || [istarget x86_64-*-*]
3142 || [check_effective_target_arm32]
3143 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3144 set answer 1
3145 } else {
3146 set answer 0
3149 verbose "check_effective_target_vect_long: returning $answer" 2
3150 return $answer
3153 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3155 # This won't change for different subtargets so cache the result.
3157 proc check_effective_target_vect_float { } {
3158 global et_vect_float_saved
3160 if [info exists et_vect_float_saved] {
3161 verbose "check_effective_target_vect_float: using cached result" 2
3162 } else {
3163 set et_vect_float_saved 0
3164 if { [istarget i?86-*-*]
3165 || [istarget powerpc*-*-*]
3166 || [istarget spu-*-*]
3167 || [istarget mips-sde-elf]
3168 || [istarget mipsisa64*-*-*]
3169 || [istarget x86_64-*-*]
3170 || [istarget ia64-*-*]
3171 || [istarget aarch64*-*-*]
3172 || [check_effective_target_arm32] } {
3173 set et_vect_float_saved 1
3177 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
3178 return $et_vect_float_saved
3181 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
3183 # This won't change for different subtargets so cache the result.
3185 proc check_effective_target_vect_double { } {
3186 global et_vect_double_saved
3188 if [info exists et_vect_double_saved] {
3189 verbose "check_effective_target_vect_double: using cached result" 2
3190 } else {
3191 set et_vect_double_saved 0
3192 if { [istarget i?86-*-*]
3193 || [istarget aarch64*-*-*]
3194 || [istarget x86_64-*-*] } {
3195 if { [check_no_compiler_messages vect_double assembly {
3196 #ifdef __tune_atom__
3197 # error No double vectorizer support.
3198 #endif
3199 }] } {
3200 set et_vect_double_saved 1
3201 } else {
3202 set et_vect_double_saved 0
3204 } elseif { [istarget spu-*-*] } {
3205 set et_vect_double_saved 1
3209 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3210 return $et_vect_double_saved
3213 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3215 # This won't change for different subtargets so cache the result.
3217 proc check_effective_target_vect_long_long { } {
3218 global et_vect_long_long_saved
3220 if [info exists et_vect_long_long_saved] {
3221 verbose "check_effective_target_vect_long_long: using cached result" 2
3222 } else {
3223 set et_vect_long_long_saved 0
3224 if { [istarget i?86-*-*]
3225 || [istarget x86_64-*-*] } {
3226 set et_vect_long_long_saved 1
3230 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3231 return $et_vect_long_long_saved
3235 # Return 1 if the target plus current options does not support a vector
3236 # max instruction on "int", 0 otherwise.
3238 # This won't change for different subtargets so cache the result.
3240 proc check_effective_target_vect_no_int_max { } {
3241 global et_vect_no_int_max_saved
3243 if [info exists et_vect_no_int_max_saved] {
3244 verbose "check_effective_target_vect_no_int_max: using cached result" 2
3245 } else {
3246 set et_vect_no_int_max_saved 0
3247 if { [istarget sparc*-*-*]
3248 || [istarget spu-*-*]
3249 || [istarget alpha*-*-*]
3250 || ([istarget mips*-*-*]
3251 && [check_effective_target_mips_loongson]) } {
3252 set et_vect_no_int_max_saved 1
3255 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
3256 return $et_vect_no_int_max_saved
3259 # Return 1 if the target plus current options does not support a vector
3260 # add instruction on "int", 0 otherwise.
3262 # This won't change for different subtargets so cache the result.
3264 proc check_effective_target_vect_no_int_add { } {
3265 global et_vect_no_int_add_saved
3267 if [info exists et_vect_no_int_add_saved] {
3268 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3269 } else {
3270 set et_vect_no_int_add_saved 0
3271 # Alpha only supports vector add on V8QI and V4HI.
3272 if { [istarget alpha*-*-*] } {
3273 set et_vect_no_int_add_saved 1
3276 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3277 return $et_vect_no_int_add_saved
3280 # Return 1 if the target plus current options does not support vector
3281 # bitwise instructions, 0 otherwise.
3283 # This won't change for different subtargets so cache the result.
3285 proc check_effective_target_vect_no_bitwise { } {
3286 global et_vect_no_bitwise_saved
3288 if [info exists et_vect_no_bitwise_saved] {
3289 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3290 } else {
3291 set et_vect_no_bitwise_saved 0
3293 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3294 return $et_vect_no_bitwise_saved
3297 # Return 1 if the target plus current options supports vector permutation,
3298 # 0 otherwise.
3300 # This won't change for different subtargets so cache the result.
3302 proc check_effective_target_vect_perm { } {
3303 global et_vect_perm
3305 if [info exists et_vect_perm_saved] {
3306 verbose "check_effective_target_vect_perm: using cached result" 2
3307 } else {
3308 set et_vect_perm_saved 0
3309 if { [is-effective-target arm_neon_ok]
3310 || [istarget aarch64*-*-*]
3311 || [istarget powerpc*-*-*]
3312 || [istarget spu-*-*]
3313 || [istarget i?86-*-*]
3314 || [istarget x86_64-*-*]
3315 || ([istarget mips*-*-*]
3316 && [check_effective_target_mpaired_single]) } {
3317 set et_vect_perm_saved 1
3320 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3321 return $et_vect_perm_saved
3324 # Return 1 if the target plus current options supports vector permutation
3325 # on byte-sized elements, 0 otherwise.
3327 # This won't change for different subtargets so cache the result.
3329 proc check_effective_target_vect_perm_byte { } {
3330 global et_vect_perm_byte
3332 if [info exists et_vect_perm_byte_saved] {
3333 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3334 } else {
3335 set et_vect_perm_byte_saved 0
3336 if { ([is-effective-target arm_neon_ok]
3337 && [is-effective-target arm_little_endian])
3338 || [istarget aarch64*-*-*]
3339 || [istarget powerpc*-*-*]
3340 || [istarget spu-*-*] } {
3341 set et_vect_perm_byte_saved 1
3344 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3345 return $et_vect_perm_byte_saved
3348 # Return 1 if the target plus current options supports vector permutation
3349 # on short-sized elements, 0 otherwise.
3351 # This won't change for different subtargets so cache the result.
3353 proc check_effective_target_vect_perm_short { } {
3354 global et_vect_perm_short
3356 if [info exists et_vect_perm_short_saved] {
3357 verbose "check_effective_target_vect_perm_short: using cached result" 2
3358 } else {
3359 set et_vect_perm_short_saved 0
3360 if { ([is-effective-target arm_neon_ok]
3361 && [is-effective-target arm_little_endian])
3362 || [istarget aarch64*-*-*]
3363 || [istarget powerpc*-*-*]
3364 || [istarget spu-*-*] } {
3365 set et_vect_perm_short_saved 1
3368 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3369 return $et_vect_perm_short_saved
3372 # Return 1 if the target plus current options supports a vector
3373 # widening summation of *short* args into *int* result, 0 otherwise.
3375 # This won't change for different subtargets so cache the result.
3377 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3378 global et_vect_widen_sum_hi_to_si_pattern
3380 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3381 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3382 } else {
3383 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3384 if { [istarget powerpc*-*-*]
3385 || [istarget ia64-*-*] } {
3386 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3389 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3390 return $et_vect_widen_sum_hi_to_si_pattern_saved
3393 # Return 1 if the target plus current options supports a vector
3394 # widening summation of *short* args into *int* result, 0 otherwise.
3395 # A target can also support this widening summation if it can support
3396 # promotion (unpacking) from shorts to ints.
3398 # This won't change for different subtargets so cache the result.
3400 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3401 global et_vect_widen_sum_hi_to_si
3403 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3404 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3405 } else {
3406 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3407 if { [istarget powerpc*-*-*]
3408 || [istarget ia64-*-*] } {
3409 set et_vect_widen_sum_hi_to_si_saved 1
3412 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3413 return $et_vect_widen_sum_hi_to_si_saved
3416 # Return 1 if the target plus current options supports a vector
3417 # widening summation of *char* args into *short* result, 0 otherwise.
3418 # A target can also support this widening summation if it can support
3419 # promotion (unpacking) from chars to shorts.
3421 # This won't change for different subtargets so cache the result.
3423 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3424 global et_vect_widen_sum_qi_to_hi
3426 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3427 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3428 } else {
3429 set et_vect_widen_sum_qi_to_hi_saved 0
3430 if { [check_effective_target_vect_unpack]
3431 || [check_effective_target_arm_neon_ok]
3432 || [istarget ia64-*-*] } {
3433 set et_vect_widen_sum_qi_to_hi_saved 1
3436 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3437 return $et_vect_widen_sum_qi_to_hi_saved
3440 # Return 1 if the target plus current options supports a vector
3441 # widening summation of *char* args into *int* result, 0 otherwise.
3443 # This won't change for different subtargets so cache the result.
3445 proc check_effective_target_vect_widen_sum_qi_to_si { } {
3446 global et_vect_widen_sum_qi_to_si
3448 if [info exists et_vect_widen_sum_qi_to_si_saved] {
3449 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3450 } else {
3451 set et_vect_widen_sum_qi_to_si_saved 0
3452 if { [istarget powerpc*-*-*] } {
3453 set et_vect_widen_sum_qi_to_si_saved 1
3456 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3457 return $et_vect_widen_sum_qi_to_si_saved
3460 # Return 1 if the target plus current options supports a vector
3461 # widening multiplication of *char* args into *short* result, 0 otherwise.
3462 # A target can also support this widening multplication if it can support
3463 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
3464 # multiplication of shorts).
3466 # This won't change for different subtargets so cache the result.
3469 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3470 global et_vect_widen_mult_qi_to_hi
3472 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3473 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3474 } else {
3475 if { [check_effective_target_vect_unpack]
3476 && [check_effective_target_vect_short_mult] } {
3477 set et_vect_widen_mult_qi_to_hi_saved 1
3478 } else {
3479 set et_vect_widen_mult_qi_to_hi_saved 0
3481 if { [istarget powerpc*-*-*]
3482 || [istarget aarch64*-*-*]
3483 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3484 set et_vect_widen_mult_qi_to_hi_saved 1
3487 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3488 return $et_vect_widen_mult_qi_to_hi_saved
3491 # Return 1 if the target plus current options supports a vector
3492 # widening multiplication of *short* args into *int* result, 0 otherwise.
3493 # A target can also support this widening multplication if it can support
3494 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3495 # multiplication of ints).
3497 # This won't change for different subtargets so cache the result.
3500 proc check_effective_target_vect_widen_mult_hi_to_si { } {
3501 global et_vect_widen_mult_hi_to_si
3503 if [info exists et_vect_widen_mult_hi_to_si_saved] {
3504 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3505 } else {
3506 if { [check_effective_target_vect_unpack]
3507 && [check_effective_target_vect_int_mult] } {
3508 set et_vect_widen_mult_hi_to_si_saved 1
3509 } else {
3510 set et_vect_widen_mult_hi_to_si_saved 0
3512 if { [istarget powerpc*-*-*]
3513 || [istarget spu-*-*]
3514 || [istarget ia64-*-*]
3515 || [istarget aarch64*-*-*]
3516 || [istarget i?86-*-*]
3517 || [istarget x86_64-*-*]
3518 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3519 set et_vect_widen_mult_hi_to_si_saved 1
3522 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3523 return $et_vect_widen_mult_hi_to_si_saved
3526 # Return 1 if the target plus current options supports a vector
3527 # widening multiplication of *char* args into *short* result, 0 otherwise.
3529 # This won't change for different subtargets so cache the result.
3531 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3532 global et_vect_widen_mult_qi_to_hi_pattern
3534 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3535 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3536 } else {
3537 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3538 if { [istarget powerpc*-*-*]
3539 || ([istarget arm*-*-*]
3540 && [check_effective_target_arm_neon_ok]
3541 && [check_effective_target_arm_little_endian]) } {
3542 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3545 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3546 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3549 # Return 1 if the target plus current options supports a vector
3550 # widening multiplication of *short* args into *int* result, 0 otherwise.
3552 # This won't change for different subtargets so cache the result.
3554 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3555 global et_vect_widen_mult_hi_to_si_pattern
3557 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3558 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3559 } else {
3560 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3561 if { [istarget powerpc*-*-*]
3562 || [istarget spu-*-*]
3563 || [istarget ia64-*-*]
3564 || [istarget i?86-*-*]
3565 || [istarget x86_64-*-*]
3566 || ([istarget arm*-*-*]
3567 && [check_effective_target_arm_neon_ok]
3568 && [check_effective_target_arm_little_endian]) } {
3569 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3572 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3573 return $et_vect_widen_mult_hi_to_si_pattern_saved
3576 # Return 1 if the target plus current options supports a vector
3577 # widening shift, 0 otherwise.
3579 # This won't change for different subtargets so cache the result.
3581 proc check_effective_target_vect_widen_shift { } {
3582 global et_vect_widen_shift_saved
3584 if [info exists et_vect_shift_saved] {
3585 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3586 } else {
3587 set et_vect_widen_shift_saved 0
3588 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3589 set et_vect_widen_shift_saved 1
3592 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3593 return $et_vect_widen_shift_saved
3596 # Return 1 if the target plus current options supports a vector
3597 # dot-product of signed chars, 0 otherwise.
3599 # This won't change for different subtargets so cache the result.
3601 proc check_effective_target_vect_sdot_qi { } {
3602 global et_vect_sdot_qi
3604 if [info exists et_vect_sdot_qi_saved] {
3605 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3606 } else {
3607 set et_vect_sdot_qi_saved 0
3608 if { [istarget ia64-*-*] } {
3609 set et_vect_udot_qi_saved 1
3612 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3613 return $et_vect_sdot_qi_saved
3616 # Return 1 if the target plus current options supports a vector
3617 # dot-product of unsigned chars, 0 otherwise.
3619 # This won't change for different subtargets so cache the result.
3621 proc check_effective_target_vect_udot_qi { } {
3622 global et_vect_udot_qi
3624 if [info exists et_vect_udot_qi_saved] {
3625 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3626 } else {
3627 set et_vect_udot_qi_saved 0
3628 if { [istarget powerpc*-*-*]
3629 || [istarget ia64-*-*] } {
3630 set et_vect_udot_qi_saved 1
3633 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3634 return $et_vect_udot_qi_saved
3637 # Return 1 if the target plus current options supports a vector
3638 # dot-product of signed shorts, 0 otherwise.
3640 # This won't change for different subtargets so cache the result.
3642 proc check_effective_target_vect_sdot_hi { } {
3643 global et_vect_sdot_hi
3645 if [info exists et_vect_sdot_hi_saved] {
3646 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3647 } else {
3648 set et_vect_sdot_hi_saved 0
3649 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3650 || [istarget ia64-*-*]
3651 || [istarget i?86-*-*]
3652 || [istarget x86_64-*-*] } {
3653 set et_vect_sdot_hi_saved 1
3656 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3657 return $et_vect_sdot_hi_saved
3660 # Return 1 if the target plus current options supports a vector
3661 # dot-product of unsigned shorts, 0 otherwise.
3663 # This won't change for different subtargets so cache the result.
3665 proc check_effective_target_vect_udot_hi { } {
3666 global et_vect_udot_hi
3668 if [info exists et_vect_udot_hi_saved] {
3669 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3670 } else {
3671 set et_vect_udot_hi_saved 0
3672 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3673 set et_vect_udot_hi_saved 1
3676 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3677 return $et_vect_udot_hi_saved
3681 # Return 1 if the target plus current options supports a vector
3682 # demotion (packing) of shorts (to chars) and ints (to shorts)
3683 # using modulo arithmetic, 0 otherwise.
3685 # This won't change for different subtargets so cache the result.
3687 proc check_effective_target_vect_pack_trunc { } {
3688 global et_vect_pack_trunc
3690 if [info exists et_vect_pack_trunc_saved] {
3691 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3692 } else {
3693 set et_vect_pack_trunc_saved 0
3694 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3695 || [istarget i?86-*-*]
3696 || [istarget x86_64-*-*]
3697 || [istarget aarch64*-*-*]
3698 || [istarget spu-*-*]
3699 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3700 && [check_effective_target_arm_little_endian]) } {
3701 set et_vect_pack_trunc_saved 1
3704 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3705 return $et_vect_pack_trunc_saved
3708 # Return 1 if the target plus current options supports a vector
3709 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3711 # This won't change for different subtargets so cache the result.
3713 proc check_effective_target_vect_unpack { } {
3714 global et_vect_unpack
3716 if [info exists et_vect_unpack_saved] {
3717 verbose "check_effective_target_vect_unpack: using cached result" 2
3718 } else {
3719 set et_vect_unpack_saved 0
3720 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3721 || [istarget i?86-*-*]
3722 || [istarget x86_64-*-*]
3723 || [istarget spu-*-*]
3724 || [istarget ia64-*-*]
3725 || [istarget aarch64*-*-*]
3726 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3727 && [check_effective_target_arm_little_endian]) } {
3728 set et_vect_unpack_saved 1
3731 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3732 return $et_vect_unpack_saved
3735 # Return 1 if the target plus current options does not guarantee
3736 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3738 # This won't change for different subtargets so cache the result.
3740 proc check_effective_target_unaligned_stack { } {
3741 global et_unaligned_stack_saved
3743 if [info exists et_unaligned_stack_saved] {
3744 verbose "check_effective_target_unaligned_stack: using cached result" 2
3745 } else {
3746 set et_unaligned_stack_saved 0
3748 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3749 return $et_unaligned_stack_saved
3752 # Return 1 if the target plus current options does not support a vector
3753 # alignment mechanism, 0 otherwise.
3755 # This won't change for different subtargets so cache the result.
3757 proc check_effective_target_vect_no_align { } {
3758 global et_vect_no_align_saved
3760 if [info exists et_vect_no_align_saved] {
3761 verbose "check_effective_target_vect_no_align: using cached result" 2
3762 } else {
3763 set et_vect_no_align_saved 0
3764 if { [istarget mipsisa64*-*-*]
3765 || [istarget mips-sde-elf]
3766 || [istarget sparc*-*-*]
3767 || [istarget ia64-*-*]
3768 || [check_effective_target_arm_vect_no_misalign]
3769 || ([istarget mips*-*-*]
3770 && [check_effective_target_mips_loongson]) } {
3771 set et_vect_no_align_saved 1
3774 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3775 return $et_vect_no_align_saved
3778 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3780 # This won't change for different subtargets so cache the result.
3782 proc check_effective_target_vect_hw_misalign { } {
3783 global et_vect_hw_misalign_saved
3785 if [info exists et_vect_hw_misalign_saved] {
3786 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3787 } else {
3788 set et_vect_hw_misalign_saved 0
3789 if { ([istarget x86_64-*-*]
3790 || [istarget aarch64*-*-*]
3791 || [istarget i?86-*-*]) } {
3792 set et_vect_hw_misalign_saved 1
3795 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3796 return $et_vect_hw_misalign_saved
3800 # Return 1 if arrays are aligned to the vector alignment
3801 # boundary, 0 otherwise.
3803 # This won't change for different subtargets so cache the result.
3805 proc check_effective_target_vect_aligned_arrays { } {
3806 global et_vect_aligned_arrays
3808 if [info exists et_vect_aligned_arrays_saved] {
3809 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3810 } else {
3811 set et_vect_aligned_arrays_saved 0
3812 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3813 if { ([is-effective-target lp64]
3814 && ( ![check_avx_available]
3815 || [check_prefer_avx128])) } {
3816 set et_vect_aligned_arrays_saved 1
3819 if [istarget spu-*-*] {
3820 set et_vect_aligned_arrays_saved 1
3823 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3824 return $et_vect_aligned_arrays_saved
3827 # Return 1 if types of size 32 bit or less are naturally aligned
3828 # (aligned to their type-size), 0 otherwise.
3830 # This won't change for different subtargets so cache the result.
3832 proc check_effective_target_natural_alignment_32 { } {
3833 global et_natural_alignment_32
3835 if [info exists et_natural_alignment_32_saved] {
3836 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3837 } else {
3838 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3839 set et_natural_alignment_32_saved 1
3840 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3841 set et_natural_alignment_32_saved 0
3844 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3845 return $et_natural_alignment_32_saved
3848 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3849 # type-size), 0 otherwise.
3851 # This won't change for different subtargets so cache the result.
3853 proc check_effective_target_natural_alignment_64 { } {
3854 global et_natural_alignment_64
3856 if [info exists et_natural_alignment_64_saved] {
3857 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3858 } else {
3859 set et_natural_alignment_64_saved 0
3860 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3861 || [istarget spu-*-*] } {
3862 set et_natural_alignment_64_saved 1
3865 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3866 return $et_natural_alignment_64_saved
3869 # Return 1 if all vector types are naturally aligned (aligned to their
3870 # type-size), 0 otherwise.
3872 # This won't change for different subtargets so cache the result.
3874 proc check_effective_target_vect_natural_alignment { } {
3875 global et_vect_natural_alignment
3877 if [info exists et_vect_natural_alignment_saved] {
3878 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
3879 } else {
3880 set et_vect_natural_alignment_saved 1
3881 if { [check_effective_target_arm_eabi] } {
3882 set et_vect_natural_alignment_saved 0
3885 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
3886 return $et_vect_natural_alignment_saved
3889 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3891 # This won't change for different subtargets so cache the result.
3893 proc check_effective_target_vector_alignment_reachable { } {
3894 global et_vector_alignment_reachable
3896 if [info exists et_vector_alignment_reachable_saved] {
3897 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3898 } else {
3899 if { [check_effective_target_vect_aligned_arrays]
3900 || [check_effective_target_natural_alignment_32] } {
3901 set et_vector_alignment_reachable_saved 1
3902 } else {
3903 set et_vector_alignment_reachable_saved 0
3906 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3907 return $et_vector_alignment_reachable_saved
3910 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3912 # This won't change for different subtargets so cache the result.
3914 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3915 global et_vector_alignment_reachable_for_64bit
3917 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3918 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3919 } else {
3920 if { [check_effective_target_vect_aligned_arrays]
3921 || [check_effective_target_natural_alignment_64] } {
3922 set et_vector_alignment_reachable_for_64bit_saved 1
3923 } else {
3924 set et_vector_alignment_reachable_for_64bit_saved 0
3927 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3928 return $et_vector_alignment_reachable_for_64bit_saved
3931 # Return 1 if the target only requires element alignment for vector accesses
3933 proc check_effective_target_vect_element_align { } {
3934 global et_vect_element_align
3936 if [info exists et_vect_element_align] {
3937 verbose "check_effective_target_vect_element_align: using cached result" 2
3938 } else {
3939 set et_vect_element_align 0
3940 if { ([istarget arm*-*-*]
3941 && ![check_effective_target_arm_vect_no_misalign])
3942 || [check_effective_target_vect_hw_misalign] } {
3943 set et_vect_element_align 1
3947 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3948 return $et_vect_element_align
3951 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3953 proc check_effective_target_vect_condition { } {
3954 global et_vect_cond_saved
3956 if [info exists et_vect_cond_saved] {
3957 verbose "check_effective_target_vect_cond: using cached result" 2
3958 } else {
3959 set et_vect_cond_saved 0
3960 if { [istarget aarch64*-*-*]
3961 || [istarget powerpc*-*-*]
3962 || [istarget ia64-*-*]
3963 || [istarget i?86-*-*]
3964 || [istarget spu-*-*]
3965 || [istarget x86_64-*-*]
3966 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3967 set et_vect_cond_saved 1
3971 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3972 return $et_vect_cond_saved
3975 # Return 1 if the target supports vector conditional operations where
3976 # the comparison has different type from the lhs, 0 otherwise.
3978 proc check_effective_target_vect_cond_mixed { } {
3979 global et_vect_cond_mixed_saved
3981 if [info exists et_vect_cond_mixed_saved] {
3982 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3983 } else {
3984 set et_vect_cond_mixed_saved 0
3985 if { [istarget i?86-*-*]
3986 || [istarget x86_64-*-*]
3987 || [istarget powerpc*-*-*] } {
3988 set et_vect_cond_mixed_saved 1
3992 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3993 return $et_vect_cond_mixed_saved
3996 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3998 proc check_effective_target_vect_char_mult { } {
3999 global et_vect_char_mult_saved
4001 if [info exists et_vect_char_mult_saved] {
4002 verbose "check_effective_target_vect_char_mult: using cached result" 2
4003 } else {
4004 set et_vect_char_mult_saved 0
4005 if { [istarget aarch64*-*-*]
4006 || [istarget ia64-*-*]
4007 || [istarget i?86-*-*]
4008 || [istarget x86_64-*-*]
4009 || [check_effective_target_arm32] } {
4010 set et_vect_char_mult_saved 1
4014 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4015 return $et_vect_char_mult_saved
4018 # Return 1 if the target supports vector short multiplication, 0 otherwise.
4020 proc check_effective_target_vect_short_mult { } {
4021 global et_vect_short_mult_saved
4023 if [info exists et_vect_short_mult_saved] {
4024 verbose "check_effective_target_vect_short_mult: using cached result" 2
4025 } else {
4026 set et_vect_short_mult_saved 0
4027 if { [istarget ia64-*-*]
4028 || [istarget spu-*-*]
4029 || [istarget i?86-*-*]
4030 || [istarget x86_64-*-*]
4031 || [istarget powerpc*-*-*]
4032 || [istarget aarch64*-*-*]
4033 || [check_effective_target_arm32]
4034 || ([istarget mips*-*-*]
4035 && [check_effective_target_mips_loongson]) } {
4036 set et_vect_short_mult_saved 1
4040 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4041 return $et_vect_short_mult_saved
4044 # Return 1 if the target supports vector int multiplication, 0 otherwise.
4046 proc check_effective_target_vect_int_mult { } {
4047 global et_vect_int_mult_saved
4049 if [info exists et_vect_int_mult_saved] {
4050 verbose "check_effective_target_vect_int_mult: using cached result" 2
4051 } else {
4052 set et_vect_int_mult_saved 0
4053 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4054 || [istarget spu-*-*]
4055 || [istarget i?86-*-*]
4056 || [istarget x86_64-*-*]
4057 || [istarget ia64-*-*]
4058 || [istarget aarch64*-*-*]
4059 || [check_effective_target_arm32] } {
4060 set et_vect_int_mult_saved 1
4064 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4065 return $et_vect_int_mult_saved
4068 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
4070 proc check_effective_target_vect_extract_even_odd { } {
4071 global et_vect_extract_even_odd_saved
4073 if [info exists et_vect_extract_even_odd_saved] {
4074 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
4075 } else {
4076 set et_vect_extract_even_odd_saved 0
4077 if { [istarget aarch64*-*-*]
4078 || [istarget powerpc*-*-*]
4079 || [is-effective-target arm_neon_ok]
4080 || [istarget i?86-*-*]
4081 || [istarget x86_64-*-*]
4082 || [istarget ia64-*-*]
4083 || [istarget spu-*-*]
4084 || ([istarget mips*-*-*]
4085 && [check_effective_target_mpaired_single]) } {
4086 set et_vect_extract_even_odd_saved 1
4090 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4091 return $et_vect_extract_even_odd_saved
4094 # Return 1 if the target supports vector interleaving, 0 otherwise.
4096 proc check_effective_target_vect_interleave { } {
4097 global et_vect_interleave_saved
4099 if [info exists et_vect_interleave_saved] {
4100 verbose "check_effective_target_vect_interleave: using cached result" 2
4101 } else {
4102 set et_vect_interleave_saved 0
4103 if { [istarget aarch64*-*-*]
4104 || [istarget powerpc*-*-*]
4105 || [is-effective-target arm_neon_ok]
4106 || [istarget i?86-*-*]
4107 || [istarget x86_64-*-*]
4108 || [istarget ia64-*-*]
4109 || [istarget spu-*-*]
4110 || ([istarget mips*-*-*]
4111 && [check_effective_target_mpaired_single]) } {
4112 set et_vect_interleave_saved 1
4116 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4117 return $et_vect_interleave_saved
4120 foreach N {2 3 4 8} {
4121 eval [string map [list N $N] {
4122 # Return 1 if the target supports 2-vector interleaving
4123 proc check_effective_target_vect_stridedN { } {
4124 global et_vect_stridedN_saved
4126 if [info exists et_vect_stridedN_saved] {
4127 verbose "check_effective_target_vect_stridedN: using cached result" 2
4128 } else {
4129 set et_vect_stridedN_saved 0
4130 if { (N & -N) == N
4131 && [check_effective_target_vect_interleave]
4132 && [check_effective_target_vect_extract_even_odd] } {
4133 set et_vect_stridedN_saved 1
4135 if { ([istarget arm*-*-*]
4136 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
4137 set et_vect_stridedN_saved 1
4141 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4142 return $et_vect_stridedN_saved
4147 # Return 1 if the target supports multiple vector sizes
4149 proc check_effective_target_vect_multiple_sizes { } {
4150 global et_vect_multiple_sizes_saved
4152 set et_vect_multiple_sizes_saved 0
4153 if { ([istarget aarch64*-*-*]
4154 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
4155 set et_vect_multiple_sizes_saved 1
4157 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4158 if { ([check_avx_available] && ![check_prefer_avx128]) } {
4159 set et_vect_multiple_sizes_saved 1
4163 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4164 return $et_vect_multiple_sizes_saved
4167 # Return 1 if the target supports vectors of 64 bits.
4169 proc check_effective_target_vect64 { } {
4170 global et_vect64_saved
4172 if [info exists et_vect64_saved] {
4173 verbose "check_effective_target_vect64: using cached result" 2
4174 } else {
4175 set et_vect64_saved 0
4176 if { ([istarget arm*-*-*]
4177 && [check_effective_target_arm_neon_ok]
4178 && [check_effective_target_arm_little_endian]) } {
4179 set et_vect64_saved 1
4183 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
4184 return $et_vect64_saved
4187 # Return 1 if the target supports vector copysignf calls.
4189 proc check_effective_target_vect_call_copysignf { } {
4190 global et_vect_call_copysignf_saved
4192 if [info exists et_vect_call_copysignf_saved] {
4193 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
4194 } else {
4195 set et_vect_call_copysignf_saved 0
4196 if { [istarget i?86-*-*]
4197 || [istarget x86_64-*-*]
4198 || [istarget powerpc*-*-*] } {
4199 set et_vect_call_copysignf_saved 1
4203 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4204 return $et_vect_call_copysignf_saved
4207 # Return 1 if the target supports vector sqrtf calls.
4209 proc check_effective_target_vect_call_sqrtf { } {
4210 global et_vect_call_sqrtf_saved
4212 if [info exists et_vect_call_sqrtf_saved] {
4213 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
4214 } else {
4215 set et_vect_call_sqrtf_saved 0
4216 if { [istarget aarch64*-*-*]
4217 || [istarget i?86-*-*]
4218 || [istarget x86_64-*-*]
4219 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
4220 set et_vect_call_sqrtf_saved 1
4224 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4225 return $et_vect_call_sqrtf_saved
4228 # Return 1 if the target supports vector lrint calls.
4230 proc check_effective_target_vect_call_lrint { } {
4231 set et_vect_call_lrint 0
4232 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
4233 set et_vect_call_lrint 1
4236 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4237 return $et_vect_call_lrint
4240 # Return 1 if the target supports vector btrunc calls.
4242 proc check_effective_target_vect_call_btrunc { } {
4243 global et_vect_call_btrunc_saved
4245 if [info exists et_vect_call_btrunc_saved] {
4246 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4247 } else {
4248 set et_vect_call_btrunc_saved 0
4249 if { [istarget aarch64*-*-*] } {
4250 set et_vect_call_btrunc_saved 1
4254 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4255 return $et_vect_call_btrunc_saved
4258 # Return 1 if the target supports vector btruncf calls.
4260 proc check_effective_target_vect_call_btruncf { } {
4261 global et_vect_call_btruncf_saved
4263 if [info exists et_vect_call_btruncf_saved] {
4264 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4265 } else {
4266 set et_vect_call_btruncf_saved 0
4267 if { [istarget aarch64*-*-*] } {
4268 set et_vect_call_btruncf_saved 1
4272 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4273 return $et_vect_call_btruncf_saved
4276 # Return 1 if the target supports vector ceil calls.
4278 proc check_effective_target_vect_call_ceil { } {
4279 global et_vect_call_ceil_saved
4281 if [info exists et_vect_call_ceil_saved] {
4282 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4283 } else {
4284 set et_vect_call_ceil_saved 0
4285 if { [istarget aarch64*-*-*] } {
4286 set et_vect_call_ceil_saved 1
4290 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4291 return $et_vect_call_ceil_saved
4294 # Return 1 if the target supports vector ceilf calls.
4296 proc check_effective_target_vect_call_ceilf { } {
4297 global et_vect_call_ceilf_saved
4299 if [info exists et_vect_call_ceilf_saved] {
4300 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4301 } else {
4302 set et_vect_call_ceilf_saved 0
4303 if { [istarget aarch64*-*-*] } {
4304 set et_vect_call_ceilf_saved 1
4308 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4309 return $et_vect_call_ceilf_saved
4312 # Return 1 if the target supports vector floor calls.
4314 proc check_effective_target_vect_call_floor { } {
4315 global et_vect_call_floor_saved
4317 if [info exists et_vect_call_floor_saved] {
4318 verbose "check_effective_target_vect_call_floor: using cached result" 2
4319 } else {
4320 set et_vect_call_floor_saved 0
4321 if { [istarget aarch64*-*-*] } {
4322 set et_vect_call_floor_saved 1
4326 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4327 return $et_vect_call_floor_saved
4330 # Return 1 if the target supports vector floorf calls.
4332 proc check_effective_target_vect_call_floorf { } {
4333 global et_vect_call_floorf_saved
4335 if [info exists et_vect_call_floorf_saved] {
4336 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4337 } else {
4338 set et_vect_call_floorf_saved 0
4339 if { [istarget aarch64*-*-*] } {
4340 set et_vect_call_floorf_saved 1
4344 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4345 return $et_vect_call_floorf_saved
4348 # Return 1 if the target supports vector lceil calls.
4350 proc check_effective_target_vect_call_lceil { } {
4351 global et_vect_call_lceil_saved
4353 if [info exists et_vect_call_lceil_saved] {
4354 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4355 } else {
4356 set et_vect_call_lceil_saved 0
4357 if { [istarget aarch64*-*-*] } {
4358 set et_vect_call_lceil_saved 1
4362 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4363 return $et_vect_call_lceil_saved
4366 # Return 1 if the target supports vector lfloor calls.
4368 proc check_effective_target_vect_call_lfloor { } {
4369 global et_vect_call_lfloor_saved
4371 if [info exists et_vect_call_lfloor_saved] {
4372 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4373 } else {
4374 set et_vect_call_lfloor_saved 0
4375 if { [istarget aarch64*-*-*] } {
4376 set et_vect_call_lfloor_saved 1
4380 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4381 return $et_vect_call_lfloor_saved
4384 # Return 1 if the target supports vector nearbyint calls.
4386 proc check_effective_target_vect_call_nearbyint { } {
4387 global et_vect_call_nearbyint_saved
4389 if [info exists et_vect_call_nearbyint_saved] {
4390 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
4391 } else {
4392 set et_vect_call_nearbyint_saved 0
4393 if { [istarget aarch64*-*-*] } {
4394 set et_vect_call_nearbyint_saved 1
4398 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4399 return $et_vect_call_nearbyint_saved
4402 # Return 1 if the target supports vector nearbyintf calls.
4404 proc check_effective_target_vect_call_nearbyintf { } {
4405 global et_vect_call_nearbyintf_saved
4407 if [info exists et_vect_call_nearbyintf_saved] {
4408 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
4409 } else {
4410 set et_vect_call_nearbyintf_saved 0
4411 if { [istarget aarch64*-*-*] } {
4412 set et_vect_call_nearbyintf_saved 1
4416 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4417 return $et_vect_call_nearbyintf_saved
4420 # Return 1 if the target supports vector round calls.
4422 proc check_effective_target_vect_call_round { } {
4423 global et_vect_call_round_saved
4425 if [info exists et_vect_call_round_saved] {
4426 verbose "check_effective_target_vect_call_round: using cached result" 2
4427 } else {
4428 set et_vect_call_round_saved 0
4429 if { [istarget aarch64*-*-*] } {
4430 set et_vect_call_round_saved 1
4434 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
4435 return $et_vect_call_round_saved
4438 # Return 1 if the target supports vector roundf calls.
4440 proc check_effective_target_vect_call_roundf { } {
4441 global et_vect_call_roundf_saved
4443 if [info exists et_vect_call_roundf_saved] {
4444 verbose "check_effective_target_vect_call_roundf: using cached result" 2
4445 } else {
4446 set et_vect_call_roundf_saved 0
4447 if { [istarget aarch64*-*-*] } {
4448 set et_vect_call_roundf_saved 1
4452 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
4453 return $et_vect_call_roundf_saved
4456 # Return 1 if the target supports section-anchors
4458 proc check_effective_target_section_anchors { } {
4459 global et_section_anchors_saved
4461 if [info exists et_section_anchors_saved] {
4462 verbose "check_effective_target_section_anchors: using cached result" 2
4463 } else {
4464 set et_section_anchors_saved 0
4465 if { [istarget powerpc*-*-*]
4466 || [istarget arm*-*-*] } {
4467 set et_section_anchors_saved 1
4471 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
4472 return $et_section_anchors_saved
4475 # Return 1 if the target supports atomic operations on "int_128" values.
4477 proc check_effective_target_sync_int_128 { } {
4478 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4479 && ![is-effective-target ia32] } {
4480 return 1
4481 } else {
4482 return 0
4486 # Return 1 if the target supports atomic operations on "int_128" values
4487 # and can execute them.
4489 proc check_effective_target_sync_int_128_runtime { } {
4490 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4491 && ![is-effective-target ia32] } {
4492 return [check_cached_effective_target sync_int_128_available {
4493 check_runtime_nocache sync_int_128_available {
4494 #include "cpuid.h"
4495 int main ()
4497 unsigned int eax, ebx, ecx, edx;
4498 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4499 return !(ecx & bit_CMPXCHG16B);
4500 return 1;
4502 } ""
4504 } else {
4505 return 0
4509 # Return 1 if the target supports atomic operations on "long long".
4511 # Note: 32bit x86 targets require -march=pentium in dg-options.
4513 proc check_effective_target_sync_long_long { } {
4514 if { [istarget x86_64-*-*]
4515 || [istarget i?86-*-*])
4516 || [istarget aarch64*-*-*]
4517 || [istarget arm*-*-*]
4518 || [istarget alpha*-*-*]
4519 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
4520 return 1
4521 } else {
4522 return 0
4526 # Return 1 if the target supports atomic operations on "long long"
4527 # and can execute them.
4529 # Note: 32bit x86 targets require -march=pentium in dg-options.
4531 proc check_effective_target_sync_long_long_runtime { } {
4532 if { [istarget x86_64-*-*]
4533 || [istarget i?86-*-*] } {
4534 return [check_cached_effective_target sync_long_long_available {
4535 check_runtime_nocache sync_long_long_available {
4536 #include "cpuid.h"
4537 int main ()
4539 unsigned int eax, ebx, ecx, edx;
4540 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4541 return !(edx & bit_CMPXCHG8B);
4542 return 1;
4544 } ""
4546 } elseif { [istarget aarch64*-*-*] } {
4547 return 1
4548 } elseif { [istarget arm*-*-linux-*] } {
4549 return [check_runtime sync_longlong_runtime {
4550 #include <stdlib.h>
4551 int main ()
4553 long long l1;
4555 if (sizeof (long long) != 8)
4556 exit (1);
4558 /* Just check for native; checking for kernel fallback is tricky. */
4559 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
4561 exit (0);
4563 } "" ]
4564 } elseif { [istarget alpha*-*-*] } {
4565 return 1
4566 } elseif { ([istarget sparc*-*-*]
4567 && [check_effective_target_lp64]
4568 && [check_effective_target_ultrasparc_hw]) } {
4569 return 1
4570 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
4571 return 1
4572 } else {
4573 return 0
4577 # Return 1 if the target supports atomic operations on "int" and "long".
4579 proc check_effective_target_sync_int_long { } {
4580 global et_sync_int_long_saved
4582 if [info exists et_sync_int_long_saved] {
4583 verbose "check_effective_target_sync_int_long: using cached result" 2
4584 } else {
4585 set et_sync_int_long_saved 0
4586 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4587 # load-reserved/store-conditional instructions.
4588 if { [istarget ia64-*-*]
4589 || [istarget i?86-*-*]
4590 || [istarget x86_64-*-*]
4591 || [istarget aarch64*-*-*]
4592 || [istarget alpha*-*-*]
4593 || [istarget arm*-*-linux-*]
4594 || [istarget bfin*-*linux*]
4595 || [istarget hppa*-*linux*]
4596 || [istarget s390*-*-*]
4597 || [istarget powerpc*-*-*]
4598 || [istarget crisv32-*-*] || [istarget cris-*-*]
4599 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4600 || [check_effective_target_mips_llsc] } {
4601 set et_sync_int_long_saved 1
4605 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
4606 return $et_sync_int_long_saved
4609 # Return 1 if the target supports atomic operations on "char" and "short".
4611 proc check_effective_target_sync_char_short { } {
4612 global et_sync_char_short_saved
4614 if [info exists et_sync_char_short_saved] {
4615 verbose "check_effective_target_sync_char_short: using cached result" 2
4616 } else {
4617 set et_sync_char_short_saved 0
4618 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4619 # load-reserved/store-conditional instructions.
4620 if { [istarget aarch64*-*-*]
4621 || [istarget ia64-*-*]
4622 || [istarget i?86-*-*]
4623 || [istarget x86_64-*-*]
4624 || [istarget alpha*-*-*]
4625 || [istarget arm*-*-linux-*]
4626 || [istarget hppa*-*linux*]
4627 || [istarget s390*-*-*]
4628 || [istarget powerpc*-*-*]
4629 || [istarget crisv32-*-*] || [istarget cris-*-*]
4630 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4631 || [check_effective_target_mips_llsc] } {
4632 set et_sync_char_short_saved 1
4636 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
4637 return $et_sync_char_short_saved
4640 # Return 1 if the target uses a ColdFire FPU.
4642 proc check_effective_target_coldfire_fpu { } {
4643 return [check_no_compiler_messages coldfire_fpu assembly {
4644 #ifndef __mcffpu__
4645 #error FOO
4646 #endif
4650 # Return true if this is a uClibc target.
4652 proc check_effective_target_uclibc {} {
4653 return [check_no_compiler_messages uclibc object {
4654 #include <features.h>
4655 #if !defined (__UCLIBC__)
4656 #error FOO
4657 #endif
4661 # Return true if this is a uclibc target and if the uclibc feature
4662 # described by __$feature__ is not present.
4664 proc check_missing_uclibc_feature {feature} {
4665 return [check_no_compiler_messages $feature object "
4666 #include <features.h>
4667 #if !defined (__UCLIBC) || defined (__${feature}__)
4668 #error FOO
4669 #endif
4673 # Return true if this is a Newlib target.
4675 proc check_effective_target_newlib {} {
4676 return [check_no_compiler_messages newlib object {
4677 #include <newlib.h>
4681 # Return true if this is NOT a Bionic target.
4683 proc check_effective_target_non_bionic {} {
4684 return [check_no_compiler_messages non_bionic object {
4685 #include <ctype.h>
4686 #if defined (__BIONIC__)
4687 #error FOO
4688 #endif
4692 # Return 1 if
4693 # (a) an error of a few ULP is expected in string to floating-point
4694 # conversion functions; and
4695 # (b) overflow is not always detected correctly by those functions.
4697 proc check_effective_target_lax_strtofp {} {
4698 # By default, assume that all uClibc targets suffer from this.
4699 return [check_effective_target_uclibc]
4702 # Return 1 if this is a target for which wcsftime is a dummy
4703 # function that always returns 0.
4705 proc check_effective_target_dummy_wcsftime {} {
4706 # By default, assume that all uClibc targets suffer from this.
4707 return [check_effective_target_uclibc]
4710 # Return 1 if constructors with initialization priority arguments are
4711 # supposed on this target.
4713 proc check_effective_target_init_priority {} {
4714 return [check_no_compiler_messages init_priority assembly "
4715 void f() __attribute__((constructor (1000)));
4716 void f() \{\}
4720 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
4721 # This can be used with any check_* proc that takes no argument and
4722 # returns only 1 or 0. It could be used with check_* procs that take
4723 # arguments with keywords that pass particular arguments.
4725 proc is-effective-target { arg } {
4726 set selected 0
4727 if { [info procs check_effective_target_${arg}] != [list] } {
4728 set selected [check_effective_target_${arg}]
4729 } else {
4730 switch $arg {
4731 "vmx_hw" { set selected [check_vmx_hw_available] }
4732 "vsx_hw" { set selected [check_vsx_hw_available] }
4733 "p8vector_hw" { set selected [check_p8vector_hw_available] }
4734 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
4735 "named_sections" { set selected [check_named_sections_available] }
4736 "gc_sections" { set selected [check_gc_sections_available] }
4737 "cxa_atexit" { set selected [check_cxa_atexit_available] }
4738 default { error "unknown effective target keyword `$arg'" }
4741 verbose "is-effective-target: $arg $selected" 2
4742 return $selected
4745 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
4747 proc is-effective-target-keyword { arg } {
4748 if { [info procs check_effective_target_${arg}] != [list] } {
4749 return 1
4750 } else {
4751 # These have different names for their check_* procs.
4752 switch $arg {
4753 "vmx_hw" { return 1 }
4754 "vsx_hw" { return 1 }
4755 "p8vector_hw" { return 1 }
4756 "ppc_recip_hw" { return 1 }
4757 "named_sections" { return 1 }
4758 "gc_sections" { return 1 }
4759 "cxa_atexit" { return 1 }
4760 default { return 0 }
4765 # Return 1 if target default to short enums
4767 proc check_effective_target_short_enums { } {
4768 return [check_no_compiler_messages short_enums assembly {
4769 enum foo { bar };
4770 int s[sizeof (enum foo) == 1 ? 1 : -1];
4774 # Return 1 if target supports merging string constants at link time.
4776 proc check_effective_target_string_merging { } {
4777 return [check_no_messages_and_pattern string_merging \
4778 "rodata\\.str" assembly {
4779 const char *var = "String";
4780 } {-O2}]
4783 # Return 1 if target has the basic signed and unsigned types in
4784 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
4785 # working <stdint.h> for all targets.
4787 proc check_effective_target_stdint_types { } {
4788 return [check_no_compiler_messages stdint_types assembly {
4789 #include <stdint.h>
4790 int8_t a; int16_t b; int32_t c; int64_t d;
4791 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4795 # Return 1 if target has the basic signed and unsigned types in
4796 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
4797 # these types agree with those in the header, as some systems have
4798 # only <inttypes.h>.
4800 proc check_effective_target_inttypes_types { } {
4801 return [check_no_compiler_messages inttypes_types assembly {
4802 #include <inttypes.h>
4803 int8_t a; int16_t b; int32_t c; int64_t d;
4804 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4808 # Return 1 if programs are intended to be run on a simulator
4809 # (i.e. slowly) rather than hardware (i.e. fast).
4811 proc check_effective_target_simulator { } {
4813 # All "src/sim" simulators set this one.
4814 if [board_info target exists is_simulator] {
4815 return [board_info target is_simulator]
4818 # The "sid" simulators don't set that one, but at least they set
4819 # this one.
4820 if [board_info target exists slow_simulator] {
4821 return [board_info target slow_simulator]
4824 return 0
4827 # Return 1 if programs are intended to be run on hardware rather than
4828 # on a simulator
4830 proc check_effective_target_hw { } {
4832 # All "src/sim" simulators set this one.
4833 if [board_info target exists is_simulator] {
4834 if [board_info target is_simulator] {
4835 return 0
4836 } else {
4837 return 1
4841 # The "sid" simulators don't set that one, but at least they set
4842 # this one.
4843 if [board_info target exists slow_simulator] {
4844 if [board_info target slow_simulator] {
4845 return 0
4846 } else {
4847 return 1
4851 return 1
4854 # Return 1 if the target is a VxWorks kernel.
4856 proc check_effective_target_vxworks_kernel { } {
4857 return [check_no_compiler_messages vxworks_kernel assembly {
4858 #if !defined __vxworks || defined __RTP__
4859 #error NO
4860 #endif
4864 # Return 1 if the target is a VxWorks RTP.
4866 proc check_effective_target_vxworks_rtp { } {
4867 return [check_no_compiler_messages vxworks_rtp assembly {
4868 #if !defined __vxworks || !defined __RTP__
4869 #error NO
4870 #endif
4874 # Return 1 if the target is expected to provide wide character support.
4876 proc check_effective_target_wchar { } {
4877 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4878 return 0
4880 return [check_no_compiler_messages wchar assembly {
4881 #include <wchar.h>
4885 # Return 1 if the target has <pthread.h>.
4887 proc check_effective_target_pthread_h { } {
4888 return [check_no_compiler_messages pthread_h assembly {
4889 #include <pthread.h>
4893 # Return 1 if the target can truncate a file from a file-descriptor,
4894 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4895 # chsize. We test for a trivially functional truncation; no stubs.
4896 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4897 # different function to be used.
4899 proc check_effective_target_fd_truncate { } {
4900 set prog {
4901 #define _FILE_OFFSET_BITS 64
4902 #include <unistd.h>
4903 #include <stdio.h>
4904 #include <stdlib.h>
4905 int main ()
4907 FILE *f = fopen ("tst.tmp", "wb");
4908 int fd;
4909 const char t[] = "test writing more than ten characters";
4910 char s[11];
4911 int status = 0;
4912 fd = fileno (f);
4913 write (fd, t, sizeof (t) - 1);
4914 lseek (fd, 0, 0);
4915 if (ftruncate (fd, 10) != 0)
4916 status = 1;
4917 close (fd);
4918 fclose (f);
4919 if (status)
4921 unlink ("tst.tmp");
4922 exit (status);
4924 f = fopen ("tst.tmp", "rb");
4925 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4926 status = 1;
4927 fclose (f);
4928 unlink ("tst.tmp");
4929 exit (status);
4933 if { [check_runtime ftruncate $prog] } {
4934 return 1;
4937 regsub "ftruncate" $prog "chsize" prog
4938 return [check_runtime chsize $prog]
4941 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4943 proc add_options_for_c99_runtime { flags } {
4944 if { [istarget *-*-solaris2*] } {
4945 return "$flags -std=c99"
4947 if { [istarget powerpc-*-darwin*] } {
4948 return "$flags -mmacosx-version-min=10.3"
4950 return $flags
4953 # Add to FLAGS all the target-specific flags needed to enable
4954 # full IEEE compliance mode.
4956 proc add_options_for_ieee { flags } {
4957 if { [istarget alpha*-*-*]
4958 || [istarget sh*-*-*] } {
4959 return "$flags -mieee"
4961 if { [istarget rx-*-*] } {
4962 return "$flags -mnofpu"
4964 return $flags
4967 # Add to FLAGS the flags needed to enable functions to bind locally
4968 # when using pic/PIC passes in the testsuite.
4970 proc add_options_for_bind_pic_locally { flags } {
4971 if {[check_no_compiler_messages using_pic2 assembly {
4972 #if __PIC__ != 2
4973 #error FOO
4974 #endif
4975 }]} {
4976 return "$flags -fPIE"
4978 if {[check_no_compiler_messages using_pic1 assembly {
4979 #if __PIC__ != 1
4980 #error FOO
4981 #endif
4982 }]} {
4983 return "$flags -fpie"
4986 return $flags
4989 # Add to FLAGS the flags needed to enable 64-bit vectors.
4991 proc add_options_for_double_vectors { flags } {
4992 if [is-effective-target arm_neon_ok] {
4993 return "$flags -mvectorize-with-neon-double"
4996 return $flags
4999 # Return 1 if the target provides a full C99 runtime.
5001 proc check_effective_target_c99_runtime { } {
5002 return [check_cached_effective_target c99_runtime {
5003 global srcdir
5005 set file [open "$srcdir/gcc.dg/builtins-config.h"]
5006 set contents [read $file]
5007 close $file
5008 append contents {
5009 #ifndef HAVE_C99_RUNTIME
5010 #error FOO
5011 #endif
5013 check_no_compiler_messages_nocache c99_runtime assembly \
5014 $contents [add_options_for_c99_runtime ""]
5018 # Return 1 if target wchar_t is at least 4 bytes.
5020 proc check_effective_target_4byte_wchar_t { } {
5021 return [check_no_compiler_messages 4byte_wchar_t object {
5022 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
5026 # Return 1 if the target supports automatic stack alignment.
5028 proc check_effective_target_automatic_stack_alignment { } {
5029 # Ordinarily x86 supports automatic stack alignment ...
5030 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
5031 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
5032 # ... except Win64 SEH doesn't. Succeed for Win32 though.
5033 return [check_effective_target_ilp32];
5035 return 1;
5037 return 0;
5040 # Return true if we are compiling for AVX target.
5042 proc check_avx_available { } {
5043 if { [check_no_compiler_messages avx_available assembly {
5044 #ifndef __AVX__
5045 #error unsupported
5046 #endif
5047 } ""] } {
5048 return 1;
5050 return 0;
5053 # Return true if 32- and 16-bytes vectors are available.
5055 proc check_effective_target_vect_sizes_32B_16B { } {
5056 return [check_avx_available];
5059 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5060 # are available.
5062 proc check_prefer_avx128 { } {
5063 if ![check_avx_available] {
5064 return 0;
5066 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5067 float a[1024],b[1024],c[1024];
5068 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5069 } "-O2 -ftree-vectorize"]
5073 # Return 1 if avx instructions can be compiled.
5075 proc check_effective_target_avx { } {
5076 return [check_no_compiler_messages avx object {
5077 void _mm256_zeroall (void)
5079 __builtin_ia32_vzeroall ();
5081 } "-O2 -mavx" ]
5084 # Return 1 if sse instructions can be compiled.
5085 proc check_effective_target_sse { } {
5086 return [check_no_compiler_messages sse object {
5087 int main ()
5089 __builtin_ia32_stmxcsr ();
5090 return 0;
5092 } "-O2 -msse" ]
5095 # Return 1 if sse2 instructions can be compiled.
5096 proc check_effective_target_sse2 { } {
5097 return [check_no_compiler_messages sse2 object {
5098 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5100 __m128i _mm_srli_si128 (__m128i __A, int __N)
5102 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5104 } "-O2 -msse2" ]
5107 # Return 1 if F16C instructions can be compiled.
5109 proc check_effective_target_f16c { } {
5110 return [check_no_compiler_messages f16c object {
5111 #include "immintrin.h"
5112 float
5113 foo (unsigned short val)
5115 return _cvtsh_ss (val);
5117 } "-O2 -mf16c" ]
5120 # Return 1 if C wchar_t type is compatible with char16_t.
5122 proc check_effective_target_wchar_t_char16_t_compatible { } {
5123 return [check_no_compiler_messages wchar_t_char16_t object {
5124 __WCHAR_TYPE__ wc;
5125 __CHAR16_TYPE__ *p16 = &wc;
5126 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5130 # Return 1 if C wchar_t type is compatible with char32_t.
5132 proc check_effective_target_wchar_t_char32_t_compatible { } {
5133 return [check_no_compiler_messages wchar_t_char32_t object {
5134 __WCHAR_TYPE__ wc;
5135 __CHAR32_TYPE__ *p32 = &wc;
5136 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5140 # Return 1 if pow10 function exists.
5142 proc check_effective_target_pow10 { } {
5143 return [check_runtime pow10 {
5144 #include <math.h>
5145 int main () {
5146 double x;
5147 x = pow10 (1);
5148 return 0;
5150 } "-lm" ]
5153 # Return 1 if current options generate DFP instructions, 0 otherwise.
5155 proc check_effective_target_hard_dfp {} {
5156 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5157 typedef float d64 __attribute__((mode(DD)));
5158 d64 x, y, z;
5159 void foo (void) { z = x + y; }
5163 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5164 # for strchr etc. functions.
5166 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5167 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5168 #include <string.h>
5169 #include <wchar.h>
5170 #if !defined(__cplusplus) \
5171 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5172 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5173 ISO C++ correct string.h and wchar.h protos not supported.
5174 #else
5175 int i;
5176 #endif
5180 # Return 1 if GNU as is used.
5182 proc check_effective_target_gas { } {
5183 global use_gas_saved
5184 global tool
5186 if {![info exists use_gas_saved]} {
5187 # Check if the as used by gcc is GNU as.
5188 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5189 # Provide /dev/null as input, otherwise gas times out reading from
5190 # stdin.
5191 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5192 set as_output [lindex $status 1]
5193 if { [ string first "GNU" $as_output ] >= 0 } {
5194 set use_gas_saved 1
5195 } else {
5196 set use_gas_saved 0
5199 return $use_gas_saved
5202 # Return 1 if GNU ld is used.
5204 proc check_effective_target_gld { } {
5205 global use_gld_saved
5206 global tool
5208 if {![info exists use_gld_saved]} {
5209 # Check if the ld used by gcc is GNU ld.
5210 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5211 set status [remote_exec host "$gcc_ld" "--version"]
5212 set ld_output [lindex $status 1]
5213 if { [ string first "GNU" $ld_output ] >= 0 } {
5214 set use_gld_saved 1
5215 } else {
5216 set use_gld_saved 0
5219 return $use_gld_saved
5222 # Return 1 if the compiler has been configure with link-time optimization
5223 # (LTO) support.
5225 proc check_effective_target_lto { } {
5226 global ENABLE_LTO
5227 return [info exists ENABLE_LTO]
5230 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
5232 proc check_effective_target_maybe_x32 { } {
5233 return [check_no_compiler_messages maybe_x32 object {
5234 void foo (void) {}
5235 } "-mx32 -maddress-mode=short"]
5238 # Return 1 if this target supports the -fsplit-stack option, 0
5239 # otherwise.
5241 proc check_effective_target_split_stack {} {
5242 return [check_no_compiler_messages split_stack object {
5243 void foo (void) { }
5244 } "-fsplit-stack"]
5247 # Return 1 if this target supports the -masm=intel option, 0
5248 # otherwise
5250 proc check_effective_target_masm_intel {} {
5251 return [check_no_compiler_messages masm_intel object {
5252 extern void abort (void);
5253 } "-masm=intel"]
5256 # Return 1 if the language for the compiler under test is C.
5258 proc check_effective_target_c { } {
5259 global tool
5260 if [string match $tool "gcc"] {
5261 return 1
5263 return 0
5266 # Return 1 if the language for the compiler under test is C++.
5268 proc check_effective_target_c++ { } {
5269 global tool
5270 if [string match $tool "g++"] {
5271 return 1
5273 return 0
5276 # Check which language standard is active by checking for the presence of
5277 # one of the C++11 -std flags. This assumes that the default for the
5278 # compiler is C++98, and that there will never be multiple -std= arguments
5279 # on the command line.
5280 proc check_effective_target_c++11 { } {
5281 if ![check_effective_target_c++] {
5282 return 0
5284 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
5287 proc check_effective_target_c++1y { } {
5288 if ![check_effective_target_c++] {
5289 return 0
5291 return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }]
5294 proc check_effective_target_c++98 { } {
5295 if ![check_effective_target_c++] {
5296 return 0
5298 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }]
5301 # Return 1 if expensive testcases should be run.
5303 proc check_effective_target_run_expensive_tests { } {
5304 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
5305 return 1
5307 return 0
5310 # Returns 1 if "mempcpy" is available on the target system.
5312 proc check_effective_target_mempcpy {} {
5313 return [check_function_available "mempcpy"]
5316 # Check whether the vectorizer tests are supported by the target and
5317 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
5318 # Set dg-do-what-default to either compile or run, depending on target
5319 # capabilities. Return 1 if vectorizer tests are supported by
5320 # target, 0 otherwise.
5322 proc check_vect_support_and_set_flags { } {
5323 global DEFAULT_VECTCFLAGS
5324 global dg-do-what-default
5326 if [istarget powerpc-*paired*] {
5327 lappend DEFAULT_VECTCFLAGS "-mpaired"
5328 if [check_750cl_hw_available] {
5329 set dg-do-what-default run
5330 } else {
5331 set dg-do-what-default compile
5333 } elseif [istarget powerpc*-*-*] {
5334 # Skip targets not supporting -maltivec.
5335 if ![is-effective-target powerpc_altivec_ok] {
5336 return 0
5339 lappend DEFAULT_VECTCFLAGS "-maltivec"
5340 if [check_p8vector_hw_available] {
5341 lappend DEFAULT_VECTCFLAGS "-mpower8-vector" "-mno-allow-movmisalign"
5342 } elseif [check_vsx_hw_available] {
5343 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
5346 if [check_vmx_hw_available] {
5347 set dg-do-what-default run
5348 } else {
5349 if [is-effective-target ilp32] {
5350 # Specify a cpu that supports VMX for compile-only tests.
5351 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
5353 set dg-do-what-default compile
5355 } elseif { [istarget spu-*-*] } {
5356 set dg-do-what-default run
5357 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5358 lappend DEFAULT_VECTCFLAGS "-msse2"
5359 if { [check_effective_target_sse2_runtime] } {
5360 set dg-do-what-default run
5361 } else {
5362 set dg-do-what-default compile
5364 } elseif { [istarget mips*-*-*]
5365 && ([check_effective_target_mpaired_single]
5366 || [check_effective_target_mips_loongson])
5367 && [check_effective_target_nomips16] } {
5368 if { [check_effective_target_mpaired_single] } {
5369 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
5371 set dg-do-what-default run
5372 } elseif [istarget sparc*-*-*] {
5373 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
5374 if [check_effective_target_ultrasparc_hw] {
5375 set dg-do-what-default run
5376 } else {
5377 set dg-do-what-default compile
5379 } elseif [istarget alpha*-*-*] {
5380 # Alpha's vectorization capabilities are extremely limited.
5381 # It's more effort than its worth disabling all of the tests
5382 # that it cannot pass. But if you actually want to see what
5383 # does work, command out the return.
5384 return 0
5386 lappend DEFAULT_VECTCFLAGS "-mmax"
5387 if [check_alpha_max_hw_available] {
5388 set dg-do-what-default run
5389 } else {
5390 set dg-do-what-default compile
5392 } elseif [istarget ia64-*-*] {
5393 set dg-do-what-default run
5394 } elseif [is-effective-target arm_neon_ok] {
5395 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
5396 # NEON does not support denormals, so is not used for vectorization by
5397 # default to avoid loss of precision. We must pass -ffast-math to test
5398 # vectorization of float operations.
5399 lappend DEFAULT_VECTCFLAGS "-ffast-math"
5400 if [is-effective-target arm_neon_hw] {
5401 set dg-do-what-default run
5402 } else {
5403 set dg-do-what-default compile
5405 } elseif [istarget "aarch64*-*-*"] {
5406 set dg-do-what-default run
5407 } else {
5408 return 0
5411 return 1
5414 proc check_effective_target_non_strict_align {} {
5415 return [check_no_compiler_messages non_strict_align assembly {
5416 char *y;
5417 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
5418 c *z;
5419 void foo(void) { z = (c *) y; }
5420 } "-Wcast-align"]
5423 # Return 1 if the target has <ucontext.h>.
5425 proc check_effective_target_ucontext_h { } {
5426 return [check_no_compiler_messages ucontext_h assembly {
5427 #include <ucontext.h>
5431 proc check_effective_target_aarch64_tiny { } {
5432 if { [istarget aarch64*-*-*] } {
5433 return [check_no_compiler_messages aarch64_tiny object {
5434 #ifdef __AARCH64_CMODEL_TINY__
5435 int dummy;
5436 #else
5437 #error target not AArch64 tiny code model
5438 #endif
5440 } else {
5441 return 0
5445 proc check_effective_target_aarch64_small { } {
5446 if { [istarget aarch64*-*-*] } {
5447 return [check_no_compiler_messages aarch64_small object {
5448 #ifdef __AARCH64_CMODEL_SMALL__
5449 int dummy;
5450 #else
5451 #error target not AArch64 small code model
5452 #endif
5454 } else {
5455 return 0
5459 proc check_effective_target_aarch64_large { } {
5460 if { [istarget aarch64*-*-*] } {
5461 return [check_no_compiler_messages aarch64_large object {
5462 #ifdef __AARCH64_CMODEL_LARGE__
5463 int dummy;
5464 #else
5465 #error target not AArch64 large code model
5466 #endif
5468 } else {
5469 return 0