1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2 # 2011, 2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
23 # Try to compile the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code.
33 # Otherwise, code should contain:
35 # "! Fortran" for Fortran code,
37 # "// ObjC++" for ObjC++
39 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
40 # allow for ObjC/ObjC++ specific flags.
41 proc check_compile {basename type contents args} {
43 verbose "check_compile tool: $tool for $basename"
45 if { [llength $args] > 0 } {
46 set options [list "additional_flags=[lindex $args 0]"]
50 switch -glob -- $contents {
51 "*! Fortran*" { set src ${basename}[pid].f90 }
52 "*// C++*" { set src ${basename}[pid].cc }
53 "*// ObjC++*" { set src ${basename}[pid].mm }
54 "*/* ObjC*" { set src ${basename}[pid].m }
55 "*// Go*" { set src ${basename}[pid].go }
58 "objc" { set src ${basename}[pid].m }
59 "obj-c++" { set src ${basename}[pid].mm }
60 default { set src ${basename}[pid].c }
65 set compile_type $type
67 assembly { set output ${basename}[pid].s }
68 object { set output ${basename}[pid].o }
69 executable { set output ${basename}[pid].exe }
71 set output ${basename}[pid].s
72 lappend options "additional_flags=-fdump-$type"
73 set compile_type assembly
79 set lines [${tool}_target_compile $src $output $compile_type "$options"]
82 set scan_output $output
83 # Don't try folding this into the switch above; calling "glob" before the
84 # file is created won't work.
85 if [regexp "rtl-(.*)" $type dummy rtl_type] {
86 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
90 return [list $lines $scan_output]
93 proc current_target_name { } {
95 if [info exists target_info(target,name)] {
96 set answer $target_info(target,name)
103 # Implement an effective-target check for property PROP by invoking
104 # the Tcl command ARGS and seeing if it returns true.
106 proc check_cached_effective_target { prop args } {
109 set target [current_target_name]
110 if {![info exists et_cache($prop,target)]
111 || $et_cache($prop,target) != $target} {
112 verbose "check_cached_effective_target $prop: checking $target" 2
113 set et_cache($prop,target) $target
114 set et_cache($prop,value) [uplevel eval $args]
116 set value $et_cache($prop,value)
117 verbose "check_cached_effective_target $prop: returning $value for $target" 2
121 # Like check_compile, but delete the output file and return true if the
122 # compiler printed no messages.
123 proc check_no_compiler_messages_nocache {args} {
124 set result [eval check_compile $args]
125 set lines [lindex $result 0]
126 set output [lindex $result 1]
127 remote_file build delete $output
128 return [string match "" $lines]
131 # Like check_no_compiler_messages_nocache, but cache the result.
132 # PROP is the property we're checking, and doubles as a prefix for
133 # temporary filenames.
134 proc check_no_compiler_messages {prop args} {
135 return [check_cached_effective_target $prop {
136 eval [list check_no_compiler_messages_nocache $prop] $args
140 # Like check_compile, but return true if the compiler printed no
141 # messages and if the contents of the output file satisfy PATTERN.
142 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
143 # don't match regular expression REGEXP, otherwise they satisfy it
144 # if they do match regular expression PATTERN. (PATTERN can start
145 # with something like "[!]" if the regular expression needs to match
146 # "!" as the first character.)
148 # Delete the output file before returning. The other arguments are
149 # as for check_compile.
150 proc check_no_messages_and_pattern_nocache {basename pattern args} {
153 set result [eval [list check_compile $basename] $args]
154 set lines [lindex $result 0]
155 set output [lindex $result 1]
158 if { [string match "" $lines] } {
159 set chan [open "$output"]
160 set invert [regexp {^!(.*)} $pattern dummy pattern]
161 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
165 remote_file build delete $output
169 # Like check_no_messages_and_pattern_nocache, but cache the result.
170 # PROP is the property we're checking, and doubles as a prefix for
171 # temporary filenames.
172 proc check_no_messages_and_pattern {prop pattern args} {
173 return [check_cached_effective_target $prop {
174 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
178 # Try to compile and run an executable from code CONTENTS. Return true
179 # if the compiler reports no messages and if execution "passes" in the
180 # usual DejaGNU sense. The arguments are as for check_compile, with
181 # TYPE implicitly being "executable".
182 proc check_runtime_nocache {basename contents args} {
185 set result [eval [list check_compile $basename executable $contents] $args]
186 set lines [lindex $result 0]
187 set output [lindex $result 1]
190 if { [string match "" $lines] } {
191 # No error messages, everything is OK.
192 set result [remote_load target "./$output" "" ""]
193 set status [lindex $result 0]
194 verbose "check_runtime_nocache $basename: status is <$status>" 2
195 if { $status == "pass" } {
199 remote_file build delete $output
203 # Like check_runtime_nocache, but cache the result. PROP is the
204 # property we're checking, and doubles as a prefix for temporary
206 proc check_runtime {prop args} {
209 return [check_cached_effective_target $prop {
210 eval [list check_runtime_nocache $prop] $args
214 ###############################
215 # proc check_weak_available { }
216 ###############################
218 # weak symbols are only supported in some configs/object formats
219 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
221 proc check_weak_available { } {
224 # All mips targets should support it
226 if { [ string first "mips" $target_cpu ] >= 0 } {
230 # All solaris2 targets should support it
232 if { [istarget *-*-solaris2*] } {
236 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
238 if { [istarget alpha*-dec-osf*] } {
242 # Windows targets Cygwin and MingW32 support it
244 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
248 # HP-UX 10.X doesn't support it
250 if { [istarget hppa*-*-hpux10*] } {
254 # ELF and ECOFF support it. a.out does with gas/gld but may also with
255 # other linkers, so we should try it
257 set objformat [gcc_target_object_format]
265 unknown { return -1 }
270 ###############################
271 # proc check_weak_override_available { }
272 ###############################
274 # Like check_weak_available, but return 0 if weak symbol definitions
275 # cannot be overridden.
277 proc check_weak_override_available { } {
278 if { [istarget *-*-mingw*] } {
281 return [check_weak_available]
284 ###############################
285 # proc check_visibility_available { what_kind }
286 ###############################
288 # The visibility attribute is only support in some object formats
289 # This proc returns 1 if it is supported, 0 if not.
290 # The argument is the kind of visibility, default/protected/hidden/internal.
292 proc check_visibility_available { what_kind } {
293 if [string match "" $what_kind] { set what_kind "hidden" }
295 return [check_no_compiler_messages visibility_available_$what_kind object "
296 void f() __attribute__((visibility(\"$what_kind\")));
301 ###############################
302 # proc check_alias_available { }
303 ###############################
305 # Determine if the target toolchain supports the alias attribute.
307 # Returns 2 if the target supports aliases. Returns 1 if the target
308 # only supports weak aliased. Returns 0 if the target does not
309 # support aliases at all. Returns -1 if support for aliases could not
312 proc check_alias_available { } {
313 global alias_available_saved
316 if [info exists alias_available_saved] {
317 verbose "check_alias_available returning saved $alias_available_saved" 2
321 verbose "check_alias_available compiling testfile $src" 2
322 set f [open $src "w"]
323 # Compile a small test program. The definition of "g" is
324 # necessary to keep the Solaris assembler from complaining
326 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
327 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
329 set lines [${tool}_target_compile $src $obj object ""]
331 remote_file build delete $obj
333 if [string match "" $lines] then {
334 # No error messages, everything is OK.
335 set alias_available_saved 2
337 if [regexp "alias definitions not supported" $lines] {
338 verbose "check_alias_available target does not support aliases" 2
340 set objformat [gcc_target_object_format]
342 if { $objformat == "elf" } {
343 verbose "check_alias_available but target uses ELF format, so it ought to" 2
344 set alias_available_saved -1
346 set alias_available_saved 0
349 if [regexp "only weak aliases are supported" $lines] {
350 verbose "check_alias_available target supports only weak aliases" 2
351 set alias_available_saved 1
353 set alias_available_saved -1
358 verbose "check_alias_available returning $alias_available_saved" 2
361 return $alias_available_saved
364 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
366 proc check_ifunc_available { } {
367 return [check_no_compiler_messages ifunc_available object {
372 void f() __attribute__((ifunc("g")));
376 # Returns true if --gc-sections is supported on the target.
378 proc check_gc_sections_available { } {
379 global gc_sections_available_saved
382 if {![info exists gc_sections_available_saved]} {
383 # Some targets don't support gc-sections despite whatever's
384 # advertised by ld's options.
385 if { [istarget alpha*-*-*]
386 || [istarget ia64-*-*] } {
387 set gc_sections_available_saved 0
391 # elf2flt uses -q (--emit-relocs), which is incompatible with
393 if { [board_info target exists ldflags]
394 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
395 set gc_sections_available_saved 0
399 # VxWorks kernel modules are relocatable objects linked with -r,
400 # while RTP executables are linked with -q (--emit-relocs).
401 # Both of these options are incompatible with --gc-sections.
402 if { [istarget *-*-vxworks*] } {
403 set gc_sections_available_saved 0
407 # Check if the ld used by gcc supports --gc-sections.
408 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
409 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
410 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
411 set ld_output [remote_exec host "$gcc_ld" "--help"]
412 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
413 set gc_sections_available_saved 1
415 set gc_sections_available_saved 0
418 return $gc_sections_available_saved
421 # Return 1 if according to target_info struct and explicit target list
422 # target is supposed to support trampolines.
424 proc check_effective_target_trampolines { } {
425 if [target_info exists no_trampolines] {
428 if { [istarget avr-*-*]
429 || [istarget hppa2.0w-hp-hpux11.23]
430 || [istarget hppa64-hp-hpux11.23] } {
436 # Return 1 if according to target_info struct and explicit target list
437 # target is supposed to keep null pointer checks. This could be due to
438 # use of option fno-delete-null-pointer-checks or hardwired in target.
440 proc check_effective_target_keeps_null_pointer_checks { } {
441 if [target_info exists keeps_null_pointer_checks] {
444 if { [istarget avr-*-*] } {
450 # Return true if profiling is supported on the target.
452 proc check_profiling_available { test_what } {
453 global profiling_available_saved
455 verbose "Profiling argument is <$test_what>" 1
457 # These conditions depend on the argument so examine them before
458 # looking at the cache variable.
460 # Tree profiling requires TLS runtime support.
461 if { $test_what == "-fprofile-generate" } {
462 if { ![check_effective_target_tls_runtime] } {
467 # Support for -p on solaris2 relies on mcrt1.o which comes with the
468 # vendor compiler. We cannot reliably predict the directory where the
469 # vendor compiler (and thus mcrt1.o) is installed so we can't
470 # necessarily find mcrt1.o even if we have it.
471 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
475 # Support for -p on irix relies on libprof1.a which doesn't appear to
476 # exist on any irix6 system currently posting testsuite results.
477 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
478 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
479 if { [istarget mips*-*-irix*]
480 && ($test_what == "-p" || $test_what == "-pg") } {
484 # We don't yet support profiling for MIPS16.
485 if { [istarget mips*-*-*]
486 && ![check_effective_target_nomips16]
487 && ($test_what == "-p" || $test_what == "-pg") } {
491 # MinGW does not support -p.
492 if { [istarget *-*-mingw*] && $test_what == "-p" } {
496 # cygwin does not support -p.
497 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
501 # uClibc does not have gcrt1.o.
502 if { [check_effective_target_uclibc]
503 && ($test_what == "-p" || $test_what == "-pg") } {
507 # Now examine the cache variable.
508 if {![info exists profiling_available_saved]} {
509 # Some targets don't have any implementation of __bb_init_func or are
510 # missing other needed machinery.
511 if { [istarget am3*-*-linux*]
512 || [istarget arm*-*-eabi*]
513 || [istarget arm*-*-elf]
514 || [istarget arm*-*-symbianelf*]
515 || [istarget avr-*-*]
516 || [istarget bfin-*-*]
517 || [istarget cris-*-*]
518 || [istarget crisv32-*-*]
519 || [istarget fido-*-elf]
520 || [istarget h8300-*-*]
521 || [istarget lm32-*-*]
522 || [istarget m32c-*-elf]
523 || [istarget m68k-*-elf]
524 || [istarget m68k-*-uclinux*]
525 || [istarget mep-*-elf]
526 || [istarget mips*-*-elf*]
527 || [istarget mmix-*-*]
528 || [istarget mn10300-*-elf*]
529 || [istarget moxie-*-elf*]
530 || [istarget picochip-*-*]
531 || [istarget powerpc-*-eabi*]
532 || [istarget powerpc-*-elf]
534 || [istarget tic6x-*-elf]
535 || [istarget xstormy16-*]
536 || [istarget xtensa*-*-elf]
537 || [istarget *-*-rtems*]
538 || [istarget *-*-vxworks*] } {
539 set profiling_available_saved 0
541 set profiling_available_saved 1
545 return $profiling_available_saved
548 # Check to see if a target is "freestanding". This is as per the definition
549 # in Section 4 of C99 standard. Effectively, it is a target which supports no
550 # extra headers or libraries other than what is considered essential.
551 proc check_effective_target_freestanding { } {
552 if { [istarget picochip-*-*] } then {
559 # Return 1 if target has packed layout of structure members by
560 # default, 0 otherwise. Note that this is slightly different than
561 # whether the target has "natural alignment": both attributes may be
564 proc check_effective_target_default_packed { } {
565 return [check_no_compiler_messages default_packed assembly {
566 struct x { char a; long b; } c;
567 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
571 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
572 # documentation, where the test also comes from.
574 proc check_effective_target_pcc_bitfield_type_matters { } {
575 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
576 # bitfields, but let's stick to the example code from the docs.
577 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
578 struct foo1 { char x; char :0; char y; };
579 struct foo2 { char x; int :0; char y; };
580 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
584 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
586 proc add_options_for_tls { flags } {
587 # Tru64 UNIX uses emutls, which relies on a couple of pthread functions
588 # which only live in libpthread, so always pass -pthread for TLS.
589 if { [istarget alpha*-dec-osf*] } {
590 return "$flags -pthread"
592 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
593 # libthread, so always pass -pthread for native TLS.
594 # Need to duplicate native TLS check from
595 # check_effective_target_tls_native to avoid recursion.
596 if { [istarget *-*-solaris2.\[89\]*] &&
597 [check_no_messages_and_pattern tls_native "!emutls" assembly {
599 int f (void) { return i; }
600 void g (int j) { i = j; }
602 return "$flags -pthread"
607 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
609 proc check_effective_target_tls {} {
610 return [check_no_compiler_messages tls assembly {
612 int f (void) { return i; }
613 void g (int j) { i = j; }
617 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
619 proc check_effective_target_tls_native {} {
620 # VxWorks uses emulated TLS machinery, but with non-standard helper
621 # functions, so we fail to automatically detect it.
622 if { [istarget *-*-vxworks*] } {
626 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
628 int f (void) { return i; }
629 void g (int j) { i = j; }
633 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
635 proc check_effective_target_tls_emulated {} {
636 # VxWorks uses emulated TLS machinery, but with non-standard helper
637 # functions, so we fail to automatically detect it.
638 if { [istarget *-*-vxworks*] } {
642 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
644 int f (void) { return i; }
645 void g (int j) { i = j; }
649 # Return 1 if TLS executables can run correctly, 0 otherwise.
651 proc check_effective_target_tls_runtime {} {
652 return [check_runtime tls_runtime {
653 __thread int thr = 0;
654 int main (void) { return thr; }
655 } [add_options_for_tls ""]]
658 # Return 1 if atomic compare-and-swap is supported on 'int'
660 proc check_effective_target_cas_char {} {
661 return [check_no_compiler_messages cas_char assembly {
662 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
668 proc check_effective_target_cas_int {} {
669 return [check_no_compiler_messages cas_int assembly {
670 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
672 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
680 # Return 1 if -ffunction-sections is supported, 0 otherwise.
682 proc check_effective_target_function_sections {} {
683 # Darwin has its own scheme and silently accepts -ffunction-sections.
684 if { [istarget *-*-darwin*] } {
688 return [check_no_compiler_messages functionsections assembly {
690 } "-ffunction-sections"]
693 # Return 1 if instruction scheduling is available, 0 otherwise.
695 proc check_effective_target_scheduling {} {
696 return [check_no_compiler_messages scheduling object {
698 } "-fschedule-insns"]
701 # Return 1 if compilation with -fgraphite is error-free for trivial
704 proc check_effective_target_fgraphite {} {
705 return [check_no_compiler_messages fgraphite object {
710 # Return 1 if compilation with -fopenmp is error-free for trivial
713 proc check_effective_target_fopenmp {} {
714 return [check_no_compiler_messages fopenmp object {
719 # Return 1 if compilation with -fgnu-tm is error-free for trivial
722 proc check_effective_target_fgnu_tm {} {
723 return [check_no_compiler_messages fgnu_tm object {
728 # Return 1 if the target supports mmap, 0 otherwise.
730 proc check_effective_target_mmap {} {
731 return [check_function_available "mmap"]
734 # Return 1 if compilation with -pthread is error-free for trivial
737 proc check_effective_target_pthread {} {
738 return [check_no_compiler_messages pthread object {
743 # Return 1 if compilation with -mpe-aligned-commons is error-free
744 # for trivial code, 0 otherwise.
746 proc check_effective_target_pe_aligned_commons {} {
747 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
748 return [check_no_compiler_messages pe_aligned_commons object {
750 } "-mpe-aligned-commons"]
755 # Return 1 if the target supports -static
756 proc check_effective_target_static {} {
757 return [check_no_compiler_messages static executable {
758 int main (void) { return 0; }
762 # Return 1 if the target supports -fstack-protector
763 proc check_effective_target_fstack_protector {} {
764 return [check_runtime fstack_protector {
765 int main (void) { return 0; }
766 } "-fstack-protector"]
769 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
770 # for trivial code, 0 otherwise.
772 proc check_effective_target_freorder {} {
773 return [check_no_compiler_messages freorder object {
775 } "-freorder-blocks-and-partition"]
778 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
779 # emitted, 0 otherwise. Whether a shared library can actually be built is
780 # out of scope for this test.
782 proc check_effective_target_fpic { } {
783 # Note that M68K has a multilib that supports -fpic but not
784 # -fPIC, so we need to check both. We test with a program that
785 # requires GOT references.
786 foreach arg {fpic fPIC} {
787 if [check_no_compiler_messages $arg object {
788 extern int foo (void); extern int bar;
789 int baz (void) { return foo () + bar; }
797 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
799 proc check_effective_target_pie { } {
800 if { [istarget *-*-darwin\[912\]*]
801 || [istarget *-*-linux*] } {
807 # Return true if the target supports -mpaired-single (as used on MIPS).
809 proc check_effective_target_mpaired_single { } {
810 return [check_no_compiler_messages mpaired_single object {
815 # Return true if the target has access to FPU instructions.
817 proc check_effective_target_hard_float { } {
818 if { [istarget mips*-*-*] } {
819 return [check_no_compiler_messages hard_float assembly {
820 #if (defined __mips_soft_float || defined __mips16)
826 # This proc is actually checking the availabilty of FPU
827 # support for doubles, so on the RX we must fail if the
828 # 64-bit double multilib has been selected.
829 if { [istarget rx-*-*] } {
831 # return [check_no_compiler_messages hard_float assembly {
832 #if defined __RX_64_BIT_DOUBLES__
838 # The generic test equates hard_float with "no call for adding doubles".
839 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
840 double a (double b, double c) { return b + c; }
844 # Return true if the target is a 64-bit MIPS target.
846 proc check_effective_target_mips64 { } {
847 return [check_no_compiler_messages mips64 assembly {
854 # Return true if the target is a MIPS target that does not produce
857 proc check_effective_target_nomips16 { } {
858 return [check_no_compiler_messages nomips16 object {
862 /* A cheap way of testing for -mflip-mips16. */
863 void foo (void) { asm ("addiu $20,$20,1"); }
864 void bar (void) { asm ("addiu $20,$20,1"); }
869 # Add the options needed for MIPS16 function attributes. At the moment,
870 # we don't support MIPS16 PIC.
872 proc add_options_for_mips16_attribute { flags } {
873 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
876 # Return true if we can force a mode that allows MIPS16 code generation.
877 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
880 proc check_effective_target_mips16_attribute { } {
881 return [check_no_compiler_messages mips16_attribute assembly {
885 #if defined __mips_hard_float \
886 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
887 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
890 } [add_options_for_mips16_attribute ""]]
893 # Return 1 if the target supports long double larger than double when
894 # using the new ABI, 0 otherwise.
896 proc check_effective_target_mips_newabi_large_long_double { } {
897 return [check_no_compiler_messages mips_newabi_large_long_double object {
898 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
902 # Return true if the target is a MIPS target that has access
903 # to the LL and SC instructions.
905 proc check_effective_target_mips_llsc { } {
906 if { ![istarget mips*-*-*] } {
909 # Assume that these instructions are always implemented for
910 # non-elf* targets, via emulation if necessary.
911 if { ![istarget *-*-elf*] } {
914 # Otherwise assume LL/SC support for everything but MIPS I.
915 return [check_no_compiler_messages mips_llsc assembly {
922 # Return true if the target is a MIPS target that uses in-place relocations.
924 proc check_effective_target_mips_rel { } {
925 if { ![istarget mips*-*-*] } {
928 return [check_no_compiler_messages mips_rel object {
929 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
930 || (defined _ABI64 && _MIPS_SIM == _ABI64)
936 # Return true if the target is a MIPS target that uses the EABI.
938 proc check_effective_target_mips_eabi { } {
939 if { ![istarget mips*-*-*] } {
942 return [check_no_compiler_messages mips_eabi object {
949 # Return 1 if the current multilib does not generate PIC by default.
951 proc check_effective_target_nonpic { } {
952 return [check_no_compiler_messages nonpic assembly {
959 # Return 1 if the target does not use a status wrapper.
961 proc check_effective_target_unwrapped { } {
962 if { [target_info needs_status_wrapper] != "" \
963 && [target_info needs_status_wrapper] != "0" } {
969 # Return true if iconv is supported on the target. In particular IBM1047.
971 proc check_iconv_available { test_what } {
974 # If the tool configuration file has not set libiconv, try "-liconv"
975 if { ![info exists libiconv] } {
976 set libiconv "-liconv"
978 set test_what [lindex $test_what 1]
979 return [check_runtime_nocache $test_what [subst {
985 cd = iconv_open ("$test_what", "UTF-8");
986 if (cd == (iconv_t) -1)
993 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
995 proc check_ascii_locale_available { } {
996 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
997 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
1004 # Return true if named sections are supported on this target.
1006 proc check_named_sections_available { } {
1007 return [check_no_compiler_messages named_sections assembly {
1008 int __attribute__ ((section("whatever"))) foo;
1012 # Return 1 if the target supports Fortran real kinds larger than real(8),
1015 # When the target name changes, replace the cached result.
1017 proc check_effective_target_fortran_large_real { } {
1018 return [check_no_compiler_messages fortran_large_real executable {
1020 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1027 # Return 1 if the target supports Fortran real kind real(16),
1028 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1029 # this checks for Real(16) only; the other returned real(10) if
1030 # both real(10) and real(16) are available.
1032 # When the target name changes, replace the cached result.
1034 proc check_effective_target_fortran_real_16 { } {
1035 return [check_no_compiler_messages fortran_real_16 executable {
1044 # Return 1 if the target supports SQRT for the largest floating-point
1045 # type. (Some targets lack the libm support for this FP type.)
1046 # On most targets, this check effectively checks either whether sqrtl is
1047 # available or on __float128 systems whether libquadmath is installed,
1048 # which provides sqrtq.
1050 # When the target name changes, replace the cached result.
1052 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1053 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1055 use iso_fortran_env, only: real_kinds
1056 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1057 real(kind=maxFP), volatile :: x
1065 # Return 1 if the target supports Fortran integer kinds larger than
1066 # integer(8), 0 otherwise.
1068 # When the target name changes, replace the cached result.
1070 proc check_effective_target_fortran_large_int { } {
1071 return [check_no_compiler_messages fortran_large_int executable {
1073 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1074 integer(kind=k) :: i
1079 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1081 # When the target name changes, replace the cached result.
1083 proc check_effective_target_fortran_integer_16 { } {
1084 return [check_no_compiler_messages fortran_integer_16 executable {
1091 # Return 1 if we can statically link libgfortran, 0 otherwise.
1093 # When the target name changes, replace the cached result.
1095 proc check_effective_target_static_libgfortran { } {
1096 return [check_no_compiler_messages static_libgfortran executable {
1103 proc check_linker_plugin_available { } {
1104 return [check_no_compiler_messages_nocache linker_plugin executable {
1105 int main() { return 0; }
1106 } "-flto -fuse-linker-plugin"]
1109 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1110 # otherwise. Cache the result.
1112 proc check_750cl_hw_available { } {
1113 return [check_cached_effective_target 750cl_hw_available {
1114 # If this is not the right target then we can skip the test.
1115 if { ![istarget powerpc-*paired*] } {
1118 check_runtime_nocache 750cl_hw_available {
1122 asm volatile ("ps_mul v0,v0,v0");
1124 asm volatile ("ps_mul 0,0,0");
1133 # Return 1 if the target OS supports running SSE executables, 0
1134 # otherwise. Cache the result.
1136 proc check_sse_os_support_available { } {
1137 return [check_cached_effective_target sse_os_support_available {
1138 # If this is not the right target then we can skip the test.
1139 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1141 } elseif { [istarget i?86-*-solaris2*] } {
1142 # The Solaris 2 kernel doesn't save and restore SSE registers
1143 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1144 check_runtime_nocache sse_os_support_available {
1147 asm volatile ("movaps %xmm0,%xmm0");
1157 # Return 1 if the target OS supports running AVX executables, 0
1158 # otherwise. Cache the result.
1160 proc check_avx_os_support_available { } {
1161 return [check_cached_effective_target avx_os_support_available {
1162 # If this is not the right target then we can skip the test.
1163 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1166 # Check that OS has AVX and SSE saving enabled.
1167 check_runtime_nocache avx_os_support_available {
1170 unsigned int eax, edx;
1172 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1173 return (eax & 6) != 6;
1180 # Return 1 if the target supports executing SSE instructions, 0
1181 # otherwise. Cache the result.
1183 proc check_sse_hw_available { } {
1184 return [check_cached_effective_target sse_hw_available {
1185 # If this is not the right target then we can skip the test.
1186 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1189 check_runtime_nocache sse_hw_available {
1193 unsigned int eax, ebx, ecx, edx;
1194 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1195 return !(edx & bit_SSE);
1203 # Return 1 if the target supports executing SSE2 instructions, 0
1204 # otherwise. Cache the result.
1206 proc check_sse2_hw_available { } {
1207 return [check_cached_effective_target sse2_hw_available {
1208 # If this is not the right target then we can skip the test.
1209 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1212 check_runtime_nocache sse2_hw_available {
1216 unsigned int eax, ebx, ecx, edx;
1217 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1218 return !(edx & bit_SSE2);
1226 # Return 1 if the target supports executing AVX instructions, 0
1227 # otherwise. Cache the result.
1229 proc check_avx_hw_available { } {
1230 return [check_cached_effective_target avx_hw_available {
1231 # If this is not the right target then we can skip the test.
1232 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1235 check_runtime_nocache avx_hw_available {
1239 unsigned int eax, ebx, ecx, edx;
1240 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1241 return ((ecx & (bit_AVX | bit_OSXSAVE))
1242 != (bit_AVX | bit_OSXSAVE));
1250 # Return 1 if the target supports running SSE executables, 0 otherwise.
1252 proc check_effective_target_sse_runtime { } {
1253 if { [check_effective_target_sse]
1254 && [check_sse_hw_available]
1255 && [check_sse_os_support_available] } {
1261 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1263 proc check_effective_target_sse2_runtime { } {
1264 if { [check_effective_target_sse2]
1265 && [check_sse2_hw_available]
1266 && [check_sse_os_support_available] } {
1272 # Return 1 if the target supports running AVX executables, 0 otherwise.
1274 proc check_effective_target_avx_runtime { } {
1275 if { [check_effective_target_avx]
1276 && [check_avx_hw_available]
1277 && [check_avx_os_support_available] } {
1283 # Return 1 if the target supports executing VSX instructions, 0
1284 # otherwise. Cache the result.
1286 proc check_vsx_hw_available { } {
1287 return [check_cached_effective_target vsx_hw_available {
1288 # Some simulators are known to not support VSX instructions.
1289 # For now, disable on Darwin
1290 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1294 check_runtime_nocache vsx_hw_available {
1298 asm volatile ("xxlor vs0,vs0,vs0");
1300 asm volatile ("xxlor 0,0,0");
1309 # Return 1 if the target supports executing AltiVec instructions, 0
1310 # otherwise. Cache the result.
1312 proc check_vmx_hw_available { } {
1313 return [check_cached_effective_target vmx_hw_available {
1314 # Some simulators are known to not support VMX instructions.
1315 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1318 # Most targets don't require special flags for this test case, but
1319 # Darwin does. Just to be sure, make sure VSX is not enabled for
1320 # the altivec tests.
1321 if { [istarget *-*-darwin*]
1322 || [istarget *-*-aix*] } {
1323 set options "-maltivec -mno-vsx"
1325 set options "-mno-vsx"
1327 check_runtime_nocache vmx_hw_available {
1331 asm volatile ("vor v0,v0,v0");
1333 asm volatile ("vor 0,0,0");
1342 proc check_ppc_recip_hw_available { } {
1343 return [check_cached_effective_target ppc_recip_hw_available {
1344 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1345 # For now, disable on Darwin
1346 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1349 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1350 check_runtime_nocache ppc_recip_hw_available {
1351 volatile double d_recip, d_rsqrt, d_four = 4.0;
1352 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1355 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1356 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1357 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1358 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1366 # Return 1 if the target supports executing AltiVec and Cell PPU
1367 # instructions, 0 otherwise. Cache the result.
1369 proc check_effective_target_cell_hw { } {
1370 return [check_cached_effective_target cell_hw_available {
1371 # Some simulators are known to not support VMX and PPU instructions.
1372 if { [istarget powerpc-*-eabi*] } {
1375 # Most targets don't require special flags for this test
1376 # case, but Darwin and AIX do.
1377 if { [istarget *-*-darwin*]
1378 || [istarget *-*-aix*] } {
1379 set options "-maltivec -mcpu=cell"
1381 set options "-mcpu=cell"
1383 check_runtime_nocache cell_hw_available {
1387 asm volatile ("vor v0,v0,v0");
1388 asm volatile ("lvlx v0,r0,r0");
1390 asm volatile ("vor 0,0,0");
1391 asm volatile ("lvlx 0,0,0");
1400 # Return 1 if the target supports executing 64-bit instructions, 0
1401 # otherwise. Cache the result.
1403 proc check_effective_target_powerpc64 { } {
1404 global powerpc64_available_saved
1407 if [info exists powerpc64_available_saved] {
1408 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1410 set powerpc64_available_saved 0
1412 # Some simulators are known to not support powerpc64 instructions.
1413 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1414 verbose "check_effective_target_powerpc64 returning 0" 2
1415 return $powerpc64_available_saved
1418 # Set up, compile, and execute a test program containing a 64-bit
1419 # instruction. Include the current process ID in the file
1420 # names to prevent conflicts with invocations for multiple
1425 set f [open $src "w"]
1426 puts $f "int main() {"
1427 puts $f "#ifdef __MACH__"
1428 puts $f " asm volatile (\"extsw r0,r0\");"
1430 puts $f " asm volatile (\"extsw 0,0\");"
1432 puts $f " return 0; }"
1435 set opts "additional_flags=-mcpu=G5"
1437 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1438 set lines [${tool}_target_compile $src $exe executable "$opts"]
1441 if [string match "" $lines] then {
1442 # No error message, compilation succeeded.
1443 set result [${tool}_load "./$exe" "" ""]
1444 set status [lindex $result 0]
1445 remote_file build delete $exe
1446 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1448 if { $status == "pass" } then {
1449 set powerpc64_available_saved 1
1452 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1456 return $powerpc64_available_saved
1459 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1460 # complex float arguments. This affects gfortran tests that call cabsf
1461 # in libm built by an earlier compiler. Return 1 if libm uses the same
1462 # argument passing as the compiler under test, 0 otherwise.
1464 # When the target name changes, replace the cached result.
1466 proc check_effective_target_broken_cplxf_arg { } {
1467 return [check_cached_effective_target broken_cplxf_arg {
1468 # Skip the work for targets known not to be affected.
1469 if { ![istarget powerpc64-*-linux*] } {
1471 } elseif { ![is-effective-target lp64] } {
1474 check_runtime_nocache broken_cplxf_arg {
1475 #include <complex.h>
1476 extern void abort (void);
1477 float fabsf (float);
1478 float cabsf (_Complex float);
1485 if (fabsf (f - 5.0) > 0.0001)
1494 # Return 1 is this is a TI C6X target supporting C67X instructions
1495 proc check_effective_target_ti_c67x { } {
1496 return [check_no_compiler_messages ti_c67x assembly {
1497 #if !defined(_TMS320C6700)
1503 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1504 proc check_effective_target_ti_c64xp { } {
1505 return [check_no_compiler_messages ti_c64xp assembly {
1506 #if !defined(_TMS320C6400_PLUS)
1513 proc check_alpha_max_hw_available { } {
1514 return [check_runtime alpha_max_hw_available {
1515 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1519 # Returns true iff the FUNCTION is available on the target system.
1520 # (This is essentially a Tcl implementation of Autoconf's
1523 proc check_function_available { function } {
1524 return [check_no_compiler_messages ${function}_available \
1530 int main () { $function (); }
1534 # Returns true iff "fork" is available on the target system.
1536 proc check_fork_available {} {
1537 return [check_function_available "fork"]
1540 # Returns true iff "mkfifo" is available on the target system.
1542 proc check_mkfifo_available {} {
1543 if { [istarget *-*-cygwin*] } {
1544 # Cygwin has mkfifo, but support is incomplete.
1548 return [check_function_available "mkfifo"]
1551 # Returns true iff "__cxa_atexit" is used on the target system.
1553 proc check_cxa_atexit_available { } {
1554 return [check_cached_effective_target cxa_atexit_available {
1555 if { [istarget hppa*-*-hpux10*] } {
1556 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1558 } elseif { [istarget *-*-vxworks] } {
1559 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1562 check_runtime_nocache cxa_atexit_available {
1565 static unsigned int count;
1582 Y() { f(); count = 2; }
1591 int main() { return 0; }
1597 proc check_effective_target_objc2 { } {
1598 return [check_no_compiler_messages objc2 object {
1607 proc check_effective_target_next_runtime { } {
1608 return [check_no_compiler_messages objc2 object {
1609 #ifdef __NEXT_RUNTIME__
1617 # Return 1 if we're generating 32-bit code using default options, 0
1620 proc check_effective_target_ilp32 { } {
1621 return [check_no_compiler_messages ilp32 object {
1622 int dummy[sizeof (int) == 4
1623 && sizeof (void *) == 4
1624 && sizeof (long) == 4 ? 1 : -1];
1628 # Return 1 if we're generating ia32 code using default options, 0
1631 proc check_effective_target_ia32 { } {
1632 return [check_no_compiler_messages ia32 object {
1633 int dummy[sizeof (int) == 4
1634 && sizeof (void *) == 4
1635 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1639 # Return 1 if we're generating x32 code using default options, 0
1642 proc check_effective_target_x32 { } {
1643 return [check_no_compiler_messages x32 object {
1644 int dummy[sizeof (int) == 4
1645 && sizeof (void *) == 4
1646 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1650 # Return 1 if we're generating 32-bit or larger integers using default
1651 # options, 0 otherwise.
1653 proc check_effective_target_int32plus { } {
1654 return [check_no_compiler_messages int32plus object {
1655 int dummy[sizeof (int) >= 4 ? 1 : -1];
1659 # Return 1 if we're generating 32-bit or larger pointers using default
1660 # options, 0 otherwise.
1662 proc check_effective_target_ptr32plus { } {
1663 return [check_no_compiler_messages ptr32plus object {
1664 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1668 # Return 1 if we support 32-bit or larger array and structure sizes
1669 # using default options, 0 otherwise.
1671 proc check_effective_target_size32plus { } {
1672 return [check_no_compiler_messages size32plus object {
1677 # Returns 1 if we're generating 16-bit or smaller integers with the
1678 # default options, 0 otherwise.
1680 proc check_effective_target_int16 { } {
1681 return [check_no_compiler_messages int16 object {
1682 int dummy[sizeof (int) < 4 ? 1 : -1];
1686 # Return 1 if we're generating 64-bit code using default options, 0
1689 proc check_effective_target_lp64 { } {
1690 return [check_no_compiler_messages lp64 object {
1691 int dummy[sizeof (int) == 4
1692 && sizeof (void *) == 8
1693 && sizeof (long) == 8 ? 1 : -1];
1697 # Return 1 if we're generating 64-bit code using default llp64 options,
1700 proc check_effective_target_llp64 { } {
1701 return [check_no_compiler_messages llp64 object {
1702 int dummy[sizeof (int) == 4
1703 && sizeof (void *) == 8
1704 && sizeof (long long) == 8
1705 && sizeof (long) == 4 ? 1 : -1];
1709 # Return 1 if the target supports long double larger than double,
1712 proc check_effective_target_large_long_double { } {
1713 return [check_no_compiler_messages large_long_double object {
1714 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1718 # Return 1 if the target supports double larger than float,
1721 proc check_effective_target_large_double { } {
1722 return [check_no_compiler_messages large_double object {
1723 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1727 # Return 1 if the target supports double of 64 bits,
1730 proc check_effective_target_double64 { } {
1731 return [check_no_compiler_messages double64 object {
1732 int dummy[sizeof(double) == 8 ? 1 : -1];
1736 # Return 1 if the target supports double of at least 64 bits,
1739 proc check_effective_target_double64plus { } {
1740 return [check_no_compiler_messages double64plus object {
1741 int dummy[sizeof(double) >= 8 ? 1 : -1];
1745 # Return 1 if the target supports compiling fixed-point,
1748 proc check_effective_target_fixed_point { } {
1749 return [check_no_compiler_messages fixed_point object {
1750 _Sat _Fract x; _Sat _Accum y;
1754 # Return 1 if the target supports compiling decimal floating point,
1757 proc check_effective_target_dfp_nocache { } {
1758 verbose "check_effective_target_dfp_nocache: compiling source" 2
1759 set ret [check_no_compiler_messages_nocache dfp object {
1760 float x __attribute__((mode(DD)));
1762 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1766 proc check_effective_target_dfprt_nocache { } {
1767 return [check_runtime_nocache dfprt {
1768 typedef float d64 __attribute__((mode(DD)));
1769 d64 x = 1.2df, y = 2.3dd, z;
1770 int main () { z = x + y; return 0; }
1774 # Return 1 if the target supports compiling Decimal Floating Point,
1777 # This won't change for different subtargets so cache the result.
1779 proc check_effective_target_dfp { } {
1780 return [check_cached_effective_target dfp {
1781 check_effective_target_dfp_nocache
1785 # Return 1 if the target supports linking and executing Decimal Floating
1786 # Point, 0 otherwise.
1788 # This won't change for different subtargets so cache the result.
1790 proc check_effective_target_dfprt { } {
1791 return [check_cached_effective_target dfprt {
1792 check_effective_target_dfprt_nocache
1796 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1798 proc check_effective_target_ucn_nocache { } {
1799 # -std=c99 is only valid for C
1800 if [check_effective_target_c] {
1801 set ucnopts "-std=c99"
1803 append ucnopts " -fextended-identifiers"
1804 verbose "check_effective_target_ucn_nocache: compiling source" 2
1805 set ret [check_no_compiler_messages_nocache ucn object {
1808 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1812 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1814 # This won't change for different subtargets, so cache the result.
1816 proc check_effective_target_ucn { } {
1817 return [check_cached_effective_target ucn {
1818 check_effective_target_ucn_nocache
1822 # Return 1 if the target needs a command line argument to enable a SIMD
1825 proc check_effective_target_vect_cmdline_needed { } {
1826 global et_vect_cmdline_needed_saved
1827 global et_vect_cmdline_needed_target_name
1829 if { ![info exists et_vect_cmdline_needed_target_name] } {
1830 set et_vect_cmdline_needed_target_name ""
1833 # If the target has changed since we set the cached value, clear it.
1834 set current_target [current_target_name]
1835 if { $current_target != $et_vect_cmdline_needed_target_name } {
1836 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1837 set et_vect_cmdline_needed_target_name $current_target
1838 if { [info exists et_vect_cmdline_needed_saved] } {
1839 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1840 unset et_vect_cmdline_needed_saved
1844 if [info exists et_vect_cmdline_needed_saved] {
1845 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1847 set et_vect_cmdline_needed_saved 1
1848 if { [istarget alpha*-*-*]
1849 || [istarget ia64-*-*]
1850 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1851 && ([check_effective_target_x32]
1852 || [check_effective_target_lp64]))
1853 || ([istarget powerpc*-*-*]
1854 && ([check_effective_target_powerpc_spe]
1855 || [check_effective_target_powerpc_altivec]))
1856 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1857 || [istarget spu-*-*]
1858 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1859 set et_vect_cmdline_needed_saved 0
1863 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1864 return $et_vect_cmdline_needed_saved
1867 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1869 # This won't change for different subtargets so cache the result.
1871 proc check_effective_target_vect_int { } {
1872 global et_vect_int_saved
1874 if [info exists et_vect_int_saved] {
1875 verbose "check_effective_target_vect_int: using cached result" 2
1877 set et_vect_int_saved 0
1878 if { [istarget i?86-*-*]
1879 || ([istarget powerpc*-*-*]
1880 && ![istarget powerpc-*-linux*paired*])
1881 || [istarget spu-*-*]
1882 || [istarget x86_64-*-*]
1883 || [istarget sparc*-*-*]
1884 || [istarget alpha*-*-*]
1885 || [istarget ia64-*-*]
1886 || [check_effective_target_arm32]
1887 || ([istarget mips*-*-*]
1888 && [check_effective_target_mips_loongson]) } {
1889 set et_vect_int_saved 1
1893 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1894 return $et_vect_int_saved
1897 # Return 1 if the target supports signed int->float conversion
1900 proc check_effective_target_vect_intfloat_cvt { } {
1901 global et_vect_intfloat_cvt_saved
1903 if [info exists et_vect_intfloat_cvt_saved] {
1904 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1906 set et_vect_intfloat_cvt_saved 0
1907 if { [istarget i?86-*-*]
1908 || ([istarget powerpc*-*-*]
1909 && ![istarget powerpc-*-linux*paired*])
1910 || [istarget x86_64-*-*]
1911 || ([istarget arm*-*-*]
1912 && [check_effective_target_arm_neon_ok])} {
1913 set et_vect_intfloat_cvt_saved 1
1917 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1918 return $et_vect_intfloat_cvt_saved
1921 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1923 proc check_effective_target_int128 { } {
1924 return [check_no_compiler_messages int128 object {
1926 #ifndef __SIZEOF_INT128__
1935 # Return 1 if the target supports unsigned int->float conversion
1938 proc check_effective_target_vect_uintfloat_cvt { } {
1939 global et_vect_uintfloat_cvt_saved
1941 if [info exists et_vect_uintfloat_cvt_saved] {
1942 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1944 set et_vect_uintfloat_cvt_saved 0
1945 if { [istarget i?86-*-*]
1946 || ([istarget powerpc*-*-*]
1947 && ![istarget powerpc-*-linux*paired*])
1948 || [istarget x86_64-*-*]
1949 || ([istarget arm*-*-*]
1950 && [check_effective_target_arm_neon_ok])} {
1951 set et_vect_uintfloat_cvt_saved 1
1955 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1956 return $et_vect_uintfloat_cvt_saved
1960 # Return 1 if the target supports signed float->int conversion
1963 proc check_effective_target_vect_floatint_cvt { } {
1964 global et_vect_floatint_cvt_saved
1966 if [info exists et_vect_floatint_cvt_saved] {
1967 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1969 set et_vect_floatint_cvt_saved 0
1970 if { [istarget i?86-*-*]
1971 || ([istarget powerpc*-*-*]
1972 && ![istarget powerpc-*-linux*paired*])
1973 || [istarget x86_64-*-*]
1974 || ([istarget arm*-*-*]
1975 && [check_effective_target_arm_neon_ok])} {
1976 set et_vect_floatint_cvt_saved 1
1980 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1981 return $et_vect_floatint_cvt_saved
1984 # Return 1 if the target supports unsigned float->int conversion
1987 proc check_effective_target_vect_floatuint_cvt { } {
1988 global et_vect_floatuint_cvt_saved
1990 if [info exists et_vect_floatuint_cvt_saved] {
1991 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1993 set et_vect_floatuint_cvt_saved 0
1994 if { ([istarget powerpc*-*-*]
1995 && ![istarget powerpc-*-linux*paired*])
1996 || ([istarget arm*-*-*]
1997 && [check_effective_target_arm_neon_ok])} {
1998 set et_vect_floatuint_cvt_saved 1
2002 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2003 return $et_vect_floatuint_cvt_saved
2006 # Return 1 is this is an arm target using 32-bit instructions
2007 proc check_effective_target_arm32 { } {
2008 return [check_no_compiler_messages arm32 assembly {
2009 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2015 # Return 1 is this is an arm target not using Thumb
2016 proc check_effective_target_arm_nothumb { } {
2017 return [check_no_compiler_messages arm_nothumb assembly {
2018 #if (defined(__thumb__) || defined(__thumb2__))
2024 # Return 1 if this is a little-endian ARM target
2025 proc check_effective_target_arm_little_endian { } {
2026 return [check_no_compiler_messages arm_little_endian assembly {
2027 #if !defined(__arm__) || !defined(__ARMEL__)
2033 # Return 1 if this is an ARM target that only supports aligned vector accesses
2034 proc check_effective_target_arm_vect_no_misalign { } {
2035 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2036 #if !defined(__arm__) \
2037 || (defined(__ARMEL__) \
2038 && (!defined(__thumb__) || defined(__thumb2__)))
2045 # Return 1 if this is an ARM target supporting -mfpu=vfp
2046 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2049 proc check_effective_target_arm_vfp_ok { } {
2050 if { [check_effective_target_arm32] } {
2051 return [check_no_compiler_messages arm_vfp_ok object {
2053 } "-mfpu=vfp -mfloat-abi=softfp"]
2059 # Return 1 if this is an ARM target supporting -mfpu=vfp
2060 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2063 proc check_effective_target_arm_hard_vfp_ok { } {
2064 if { [check_effective_target_arm32]
2065 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2066 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2067 int main() { return 0;}
2068 } "-mfpu=vfp -mfloat-abi=hard"]
2074 # Return 1 if this is an ARM target that supports DSP multiply with
2075 # current multilib flags.
2077 proc check_effective_target_arm_dsp { } {
2078 return [check_no_compiler_messages arm_dsp assembly {
2079 #ifndef __ARM_FEATURE_DSP
2086 # Return 1 if this is an ARM target that supports unaligned word/halfword
2087 # load/store instructions.
2089 proc check_effective_target_arm_unaligned { } {
2090 return [check_no_compiler_messages arm_unaligned assembly {
2091 #ifndef __ARM_FEATURE_UNALIGNED
2092 #error no unaligned support
2098 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2099 # or -mfloat-abi=hard, but if one is already specified by the
2100 # multilib, use it. Similarly, if a -mfpu option already enables
2101 # NEON, do not add -mfpu=neon.
2103 proc add_options_for_arm_neon { flags } {
2104 if { ! [check_effective_target_arm_neon_ok] } {
2107 global et_arm_neon_flags
2108 return "$flags $et_arm_neon_flags"
2111 # Return 1 if this is an ARM target supporting -mfpu=neon
2112 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2113 # incompatible with these options. Also set et_arm_neon_flags to the
2114 # best options to add.
2116 proc check_effective_target_arm_neon_ok_nocache { } {
2117 global et_arm_neon_flags
2118 set et_arm_neon_flags ""
2119 if { [check_effective_target_arm32] } {
2120 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2121 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2122 #include "arm_neon.h"
2125 set et_arm_neon_flags $flags
2134 proc check_effective_target_arm_neon_ok { } {
2135 return [check_cached_effective_target arm_neon_ok \
2136 check_effective_target_arm_neon_ok_nocache]
2139 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2140 # or -mfloat-abi=hard, but if one is already specified by the
2143 proc add_options_for_arm_fp16 { flags } {
2144 if { ! [check_effective_target_arm_fp16_ok] } {
2147 global et_arm_fp16_flags
2148 return "$flags $et_arm_fp16_flags"
2151 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2152 # Skip multilibs that are incompatible with these options and set
2153 # et_arm_fp16_flags to the best options to add.
2155 proc check_effective_target_arm_fp16_ok_nocache { } {
2156 global et_arm_fp16_flags
2157 set et_arm_fp16_flags ""
2158 if { ! [check_effective_target_arm32] } {
2161 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2162 # Multilib flags would override -mfpu.
2165 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2166 # Must generate floating-point instructions.
2169 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2170 # The existing -mfpu value is OK; use it, but add softfp.
2171 set et_arm_fp16_flags "-mfloat-abi=softfp"
2174 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2175 # macro to check for this support.
2176 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2177 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2180 set et_arm_fp16_flags "$flags"
2187 proc check_effective_target_arm_fp16_ok { } {
2188 return [check_cached_effective_target arm_fp16_ok \
2189 check_effective_target_arm_fp16_ok_nocache]
2192 # Creates a series of routines that return 1 if the given architecture
2193 # can be selected and a routine to give the flags to select that architecture
2194 # Note: Extra flags may be added to disable options from newer compilers
2195 # (Thumb in particular - but others may be added in the future)
2196 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2197 # /* { dg-add-options arm_arch_v5 } */
2198 foreach { armfunc armflag armdef } { v5 "-march=armv5 -marm" __ARM_ARCH_5__
2199 v6 "-march=armv6" __ARM_ARCH_6__
2200 v6k "-march=armv6k" __ARM_ARCH_6K__
2201 v7a "-march=armv7-a" __ARM_ARCH_7A__ } {
2202 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2203 proc check_effective_target_arm_arch_FUNC_ok { } {
2204 if { [ string match "*-marm*" "FLAG" ] &&
2205 ![check_effective_target_arm_arm_ok] } {
2208 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2215 proc add_options_for_arm_arch_FUNC { flags } {
2216 return "$flags FLAG"
2221 # Return 1 if this is an ARM target where -marm causes ARM to be
2224 proc check_effective_target_arm_arm_ok { } {
2225 return [check_no_compiler_messages arm_arm_ok assembly {
2226 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2233 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2236 proc check_effective_target_arm_thumb1_ok { } {
2237 return [check_no_compiler_messages arm_thumb1_ok assembly {
2238 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2244 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2247 proc check_effective_target_arm_thumb2_ok { } {
2248 return [check_no_compiler_messages arm_thumb2_ok assembly {
2249 #if !defined(__thumb2__)
2255 # Return 1 if this is an ARM target where Thumb-1 is used without options
2256 # added by the test.
2258 proc check_effective_target_arm_thumb1 { } {
2259 return [check_no_compiler_messages arm_thumb1 assembly {
2260 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2267 # Return 1 if this is an ARM target where Thumb-2 is used without options
2268 # added by the test.
2270 proc check_effective_target_arm_thumb2 { } {
2271 return [check_no_compiler_messages arm_thumb2 assembly {
2272 #if !defined(__thumb2__)
2279 # Return 1 if this is an ARM cortex-M profile cpu
2281 proc check_effective_target_arm_cortex_m { } {
2282 return [check_no_compiler_messages arm_cortex_m assembly {
2283 #if !defined(__ARM_ARCH_7M__) \
2284 && !defined (__ARM_ARCH_7EM__) \
2285 && !defined (__ARM_ARCH_6M__)
2292 # Return 1 if the target supports executing NEON instructions, 0
2293 # otherwise. Cache the result.
2295 proc check_effective_target_arm_neon_hw { } {
2296 return [check_runtime arm_neon_hw_available {
2300 long long a = 0, b = 1;
2301 asm ("vorr %P0, %P1, %P2"
2303 : "0" (a), "w" (b));
2306 } [add_options_for_arm_neon ""]]
2309 # Return 1 if this is a ARM target with NEON enabled.
2311 proc check_effective_target_arm_neon { } {
2312 if { [check_effective_target_arm32] } {
2313 return [check_no_compiler_messages arm_neon object {
2314 #ifndef __ARM_NEON__
2325 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2326 # the Loongson vector modes.
2328 proc check_effective_target_mips_loongson { } {
2329 return [check_no_compiler_messages loongson assembly {
2330 #if !defined(__mips_loongson_vector_rev)
2336 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2339 proc check_effective_target_arm_eabi { } {
2340 return [check_no_compiler_messages arm_eabi object {
2341 #ifndef __ARM_EABI__
2349 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2350 # Some multilibs may be incompatible with this option.
2352 proc check_effective_target_arm_iwmmxt_ok { } {
2353 if { [check_effective_target_arm32] } {
2354 return [check_no_compiler_messages arm_iwmmxt_ok object {
2362 # Return 1 if this is a PowerPC target with floating-point registers.
2364 proc check_effective_target_powerpc_fprs { } {
2365 if { [istarget powerpc*-*-*]
2366 || [istarget rs6000-*-*] } {
2367 return [check_no_compiler_messages powerpc_fprs object {
2379 # Return 1 if this is a PowerPC target with hardware double-precision
2382 proc check_effective_target_powerpc_hard_double { } {
2383 if { [istarget powerpc*-*-*]
2384 || [istarget rs6000-*-*] } {
2385 return [check_no_compiler_messages powerpc_hard_double object {
2397 # Return 1 if this is a PowerPC target supporting -maltivec.
2399 proc check_effective_target_powerpc_altivec_ok { } {
2400 if { ([istarget powerpc*-*-*]
2401 && ![istarget powerpc-*-linux*paired*])
2402 || [istarget rs6000-*-*] } {
2403 # AltiVec is not supported on AIX before 5.3.
2404 if { [istarget powerpc*-*-aix4*]
2405 || [istarget powerpc*-*-aix5.1*]
2406 || [istarget powerpc*-*-aix5.2*] } {
2409 return [check_no_compiler_messages powerpc_altivec_ok object {
2417 # Return 1 if this is a PowerPC target supporting -mvsx
2419 proc check_effective_target_powerpc_vsx_ok { } {
2420 if { ([istarget powerpc*-*-*]
2421 && ![istarget powerpc-*-linux*paired*])
2422 || [istarget rs6000-*-*] } {
2423 # AltiVec is not supported on AIX before 5.3.
2424 if { [istarget powerpc*-*-aix4*]
2425 || [istarget powerpc*-*-aix5.1*]
2426 || [istarget powerpc*-*-aix5.2*] } {
2429 return [check_no_compiler_messages powerpc_vsx_ok object {
2432 asm volatile ("xxlor vs0,vs0,vs0");
2434 asm volatile ("xxlor 0,0,0");
2444 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2446 proc check_effective_target_powerpc_ppu_ok { } {
2447 if [check_effective_target_powerpc_altivec_ok] {
2448 return [check_no_compiler_messages cell_asm_available object {
2451 asm volatile ("lvlx v0,v0,v0");
2453 asm volatile ("lvlx 0,0,0");
2463 # Return 1 if this is a PowerPC target that supports SPU.
2465 proc check_effective_target_powerpc_spu { } {
2466 if { [istarget powerpc*-*-linux*] } {
2467 return [check_effective_target_powerpc_altivec_ok]
2473 # Return 1 if this is a PowerPC SPE target. The check includes options
2474 # specified by dg-options for this test, so don't cache the result.
2476 proc check_effective_target_powerpc_spe_nocache { } {
2477 if { [istarget powerpc*-*-*] } {
2478 return [check_no_compiler_messages_nocache powerpc_spe object {
2484 } [current_compiler_flags]]
2490 # Return 1 if this is a PowerPC target with SPE enabled.
2492 proc check_effective_target_powerpc_spe { } {
2493 if { [istarget powerpc*-*-*] } {
2494 return [check_no_compiler_messages powerpc_spe object {
2506 # Return 1 if this is a PowerPC target with Altivec enabled.
2508 proc check_effective_target_powerpc_altivec { } {
2509 if { [istarget powerpc*-*-*] } {
2510 return [check_no_compiler_messages powerpc_altivec object {
2522 # Return 1 if this is a PowerPC 405 target. The check includes options
2523 # specified by dg-options for this test, so don't cache the result.
2525 proc check_effective_target_powerpc_405_nocache { } {
2526 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2527 return [check_no_compiler_messages_nocache powerpc_405 object {
2533 } [current_compiler_flags]]
2539 # Return 1 if this is a SPU target with a toolchain that
2540 # supports automatic overlay generation.
2542 proc check_effective_target_spu_auto_overlay { } {
2543 if { [istarget spu*-*-elf*] } {
2544 return [check_no_compiler_messages spu_auto_overlay executable {
2546 } "-Wl,--auto-overlay" ]
2552 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2553 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2554 # test environment appears to run executables on such a simulator.
2556 proc check_effective_target_ultrasparc_hw { } {
2557 return [check_runtime ultrasparc_hw {
2558 int main() { return 0; }
2559 } "-mcpu=ultrasparc"]
2562 # Return 1 if the test environment supports executing UltraSPARC VIS2
2563 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
2565 proc check_effective_target_ultrasparc_vis2_hw { } {
2566 return [check_runtime ultrasparc_vis2_hw {
2567 int main() { __asm__(".word 0x81b00320"); return 0; }
2568 } "-mcpu=ultrasparc3"]
2571 # Return 1 if the test environment supports executing UltraSPARC VIS3
2572 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
2574 proc check_effective_target_ultrasparc_vis3_hw { } {
2575 return [check_runtime ultrasparc_vis3_hw {
2576 int main() { __asm__(".word 0x81b00220"); return 0; }
2580 # Return 1 if this is a SPARC-V9 target.
2582 proc check_effective_target_sparc_v9 { } {
2583 if { [istarget sparc*-*-*] } {
2584 return [check_no_compiler_messages sparc_v9 object {
2586 asm volatile ("return %i7+8");
2595 # Return 1 if this is a SPARC target with VIS enabled.
2597 proc check_effective_target_sparc_vis { } {
2598 if { [istarget sparc*-*-*] } {
2599 return [check_no_compiler_messages sparc_vis object {
2611 # Return 1 if the target supports hardware vector shift operation.
2613 proc check_effective_target_vect_shift { } {
2614 global et_vect_shift_saved
2616 if [info exists et_vect_shift_saved] {
2617 verbose "check_effective_target_vect_shift: using cached result" 2
2619 set et_vect_shift_saved 0
2620 if { ([istarget powerpc*-*-*]
2621 && ![istarget powerpc-*-linux*paired*])
2622 || [istarget ia64-*-*]
2623 || [istarget i?86-*-*]
2624 || [istarget x86_64-*-*]
2625 || [check_effective_target_arm32]
2626 || ([istarget mips*-*-*]
2627 && [check_effective_target_mips_loongson]) } {
2628 set et_vect_shift_saved 1
2632 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2633 return $et_vect_shift_saved
2636 # Return 1 if the target supports hardware vector shift operation for char.
2638 proc check_effective_target_vect_shift_char { } {
2639 global et_vect_shift_char_saved
2641 if [info exists et_vect_shift_char_saved] {
2642 verbose "check_effective_target_vect_shift_char: using cached result" 2
2644 set et_vect_shift_char_saved 0
2645 if { ([istarget powerpc*-*-*]
2646 && ![istarget powerpc-*-linux*paired*])
2647 || [check_effective_target_arm32] } {
2648 set et_vect_shift_char_saved 1
2652 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2653 return $et_vect_shift_char_saved
2656 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2658 # This can change for different subtargets so do not cache the result.
2660 proc check_effective_target_vect_long { } {
2661 if { [istarget i?86-*-*]
2662 || (([istarget powerpc*-*-*]
2663 && ![istarget powerpc-*-linux*paired*])
2664 && [check_effective_target_ilp32])
2665 || [istarget x86_64-*-*]
2666 || [check_effective_target_arm32]
2667 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2673 verbose "check_effective_target_vect_long: returning $answer" 2
2677 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2679 # This won't change for different subtargets so cache the result.
2681 proc check_effective_target_vect_float { } {
2682 global et_vect_float_saved
2684 if [info exists et_vect_float_saved] {
2685 verbose "check_effective_target_vect_float: using cached result" 2
2687 set et_vect_float_saved 0
2688 if { [istarget i?86-*-*]
2689 || [istarget powerpc*-*-*]
2690 || [istarget spu-*-*]
2691 || [istarget mipsisa64*-*-*]
2692 || [istarget x86_64-*-*]
2693 || [istarget ia64-*-*]
2694 || [check_effective_target_arm32] } {
2695 set et_vect_float_saved 1
2699 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2700 return $et_vect_float_saved
2703 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2705 # This won't change for different subtargets so cache the result.
2707 proc check_effective_target_vect_double { } {
2708 global et_vect_double_saved
2710 if [info exists et_vect_double_saved] {
2711 verbose "check_effective_target_vect_double: using cached result" 2
2713 set et_vect_double_saved 0
2714 if { [istarget i?86-*-*]
2715 || [istarget x86_64-*-*] } {
2716 if { [check_no_compiler_messages vect_double assembly {
2717 #ifdef __tune_atom__
2718 # error No double vectorizer support.
2721 set et_vect_double_saved 1
2723 set et_vect_double_saved 0
2725 } elseif { [istarget spu-*-*] } {
2726 set et_vect_double_saved 1
2730 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2731 return $et_vect_double_saved
2734 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2736 # This won't change for different subtargets so cache the result.
2738 proc check_effective_target_vect_long_long { } {
2739 global et_vect_long_long_saved
2741 if [info exists et_vect_long_long_saved] {
2742 verbose "check_effective_target_vect_long_long: using cached result" 2
2744 set et_vect_long_long_saved 0
2745 if { [istarget i?86-*-*]
2746 || [istarget x86_64-*-*] } {
2747 set et_vect_long_long_saved 1
2751 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2752 return $et_vect_long_long_saved
2756 # Return 1 if the target plus current options does not support a vector
2757 # max instruction on "int", 0 otherwise.
2759 # This won't change for different subtargets so cache the result.
2761 proc check_effective_target_vect_no_int_max { } {
2762 global et_vect_no_int_max_saved
2764 if [info exists et_vect_no_int_max_saved] {
2765 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2767 set et_vect_no_int_max_saved 0
2768 if { [istarget sparc*-*-*]
2769 || [istarget spu-*-*]
2770 || [istarget alpha*-*-*]
2771 || ([istarget mips*-*-*]
2772 && [check_effective_target_mips_loongson]) } {
2773 set et_vect_no_int_max_saved 1
2776 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2777 return $et_vect_no_int_max_saved
2780 # Return 1 if the target plus current options does not support a vector
2781 # add instruction on "int", 0 otherwise.
2783 # This won't change for different subtargets so cache the result.
2785 proc check_effective_target_vect_no_int_add { } {
2786 global et_vect_no_int_add_saved
2788 if [info exists et_vect_no_int_add_saved] {
2789 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2791 set et_vect_no_int_add_saved 0
2792 # Alpha only supports vector add on V8QI and V4HI.
2793 if { [istarget alpha*-*-*] } {
2794 set et_vect_no_int_add_saved 1
2797 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2798 return $et_vect_no_int_add_saved
2801 # Return 1 if the target plus current options does not support vector
2802 # bitwise instructions, 0 otherwise.
2804 # This won't change for different subtargets so cache the result.
2806 proc check_effective_target_vect_no_bitwise { } {
2807 global et_vect_no_bitwise_saved
2809 if [info exists et_vect_no_bitwise_saved] {
2810 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2812 set et_vect_no_bitwise_saved 0
2814 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2815 return $et_vect_no_bitwise_saved
2818 # Return 1 if the target plus current options supports vector permutation,
2821 # This won't change for different subtargets so cache the result.
2823 proc check_effective_target_vect_perm { } {
2826 if [info exists et_vect_perm_saved] {
2827 verbose "check_effective_target_vect_perm: using cached result" 2
2829 set et_vect_perm_saved 0
2830 if { [is-effective-target arm_neon_ok]
2831 || [istarget powerpc*-*-*]
2832 || [istarget spu-*-*]
2833 || [istarget i?86-*-*]
2834 || [istarget x86_64-*-*]
2835 || ([istarget mips*-*-*]
2836 && [check_effective_target_mpaired_single]) } {
2837 set et_vect_perm_saved 1
2840 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2841 return $et_vect_perm_saved
2844 # Return 1 if the target plus current options supports vector permutation
2845 # on byte-sized elements, 0 otherwise.
2847 # This won't change for different subtargets so cache the result.
2849 proc check_effective_target_vect_perm_byte { } {
2850 global et_vect_perm_byte
2852 if [info exists et_vect_perm_byte_saved] {
2853 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2855 set et_vect_perm_byte_saved 0
2856 if { [is-effective-target arm_neon_ok]
2857 || [istarget powerpc*-*-*]
2858 || [istarget spu-*-*] } {
2859 set et_vect_perm_byte_saved 1
2862 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2863 return $et_vect_perm_byte_saved
2866 # Return 1 if the target plus current options supports vector permutation
2867 # on short-sized elements, 0 otherwise.
2869 # This won't change for different subtargets so cache the result.
2871 proc check_effective_target_vect_perm_short { } {
2872 global et_vect_perm_short
2874 if [info exists et_vect_perm_short_saved] {
2875 verbose "check_effective_target_vect_perm_short: using cached result" 2
2877 set et_vect_perm_short_saved 0
2878 if { [is-effective-target arm_neon_ok]
2879 || [istarget powerpc*-*-*]
2880 || [istarget spu-*-*] } {
2881 set et_vect_perm_short_saved 1
2884 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2885 return $et_vect_perm_short_saved
2888 # Return 1 if the target plus current options supports a vector
2889 # widening summation of *short* args into *int* result, 0 otherwise.
2891 # This won't change for different subtargets so cache the result.
2893 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2894 global et_vect_widen_sum_hi_to_si_pattern
2896 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2897 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2899 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2900 if { [istarget powerpc*-*-*]
2901 || [istarget ia64-*-*] } {
2902 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2905 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2906 return $et_vect_widen_sum_hi_to_si_pattern_saved
2909 # Return 1 if the target plus current options supports a vector
2910 # widening summation of *short* args into *int* result, 0 otherwise.
2911 # A target can also support this widening summation if it can support
2912 # promotion (unpacking) from shorts to ints.
2914 # This won't change for different subtargets so cache the result.
2916 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2917 global et_vect_widen_sum_hi_to_si
2919 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2920 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2922 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2923 if { [istarget powerpc*-*-*]
2924 || [istarget ia64-*-*] } {
2925 set et_vect_widen_sum_hi_to_si_saved 1
2928 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2929 return $et_vect_widen_sum_hi_to_si_saved
2932 # Return 1 if the target plus current options supports a vector
2933 # widening summation of *char* args into *short* result, 0 otherwise.
2934 # A target can also support this widening summation if it can support
2935 # promotion (unpacking) from chars to shorts.
2937 # This won't change for different subtargets so cache the result.
2939 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2940 global et_vect_widen_sum_qi_to_hi
2942 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2943 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2945 set et_vect_widen_sum_qi_to_hi_saved 0
2946 if { [check_effective_target_vect_unpack]
2947 || [istarget ia64-*-*] } {
2948 set et_vect_widen_sum_qi_to_hi_saved 1
2951 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2952 return $et_vect_widen_sum_qi_to_hi_saved
2955 # Return 1 if the target plus current options supports a vector
2956 # widening summation of *char* args into *int* result, 0 otherwise.
2958 # This won't change for different subtargets so cache the result.
2960 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2961 global et_vect_widen_sum_qi_to_si
2963 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2964 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2966 set et_vect_widen_sum_qi_to_si_saved 0
2967 if { [istarget powerpc*-*-*] } {
2968 set et_vect_widen_sum_qi_to_si_saved 1
2971 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2972 return $et_vect_widen_sum_qi_to_si_saved
2975 # Return 1 if the target plus current options supports a vector
2976 # widening multiplication of *char* args into *short* result, 0 otherwise.
2977 # A target can also support this widening multplication if it can support
2978 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2979 # multiplication of shorts).
2981 # This won't change for different subtargets so cache the result.
2984 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2985 global et_vect_widen_mult_qi_to_hi
2987 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2988 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2990 if { [check_effective_target_vect_unpack]
2991 && [check_effective_target_vect_short_mult] } {
2992 set et_vect_widen_mult_qi_to_hi_saved 1
2994 set et_vect_widen_mult_qi_to_hi_saved 0
2996 if { [istarget powerpc*-*-*]
2997 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
2998 set et_vect_widen_mult_qi_to_hi_saved 1
3001 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3002 return $et_vect_widen_mult_qi_to_hi_saved
3005 # Return 1 if the target plus current options supports a vector
3006 # widening multiplication of *short* args into *int* result, 0 otherwise.
3007 # A target can also support this widening multplication if it can support
3008 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3009 # multiplication of ints).
3011 # This won't change for different subtargets so cache the result.
3014 proc check_effective_target_vect_widen_mult_hi_to_si { } {
3015 global et_vect_widen_mult_hi_to_si
3017 if [info exists et_vect_widen_mult_hi_to_si_saved] {
3018 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3020 if { [check_effective_target_vect_unpack]
3021 && [check_effective_target_vect_int_mult] } {
3022 set et_vect_widen_mult_hi_to_si_saved 1
3024 set et_vect_widen_mult_hi_to_si_saved 0
3026 if { [istarget powerpc*-*-*]
3027 || [istarget spu-*-*]
3028 || [istarget ia64-*-*]
3029 || [istarget i?86-*-*]
3030 || [istarget x86_64-*-*]
3031 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3032 set et_vect_widen_mult_hi_to_si_saved 1
3035 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3036 return $et_vect_widen_mult_hi_to_si_saved
3039 # Return 1 if the target plus current options supports a vector
3040 # widening multiplication of *char* args into *short* result, 0 otherwise.
3042 # This won't change for different subtargets so cache the result.
3044 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3045 global et_vect_widen_mult_qi_to_hi_pattern
3047 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3048 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3050 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3051 if { [istarget powerpc*-*-*]
3052 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3053 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3056 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3057 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3060 # Return 1 if the target plus current options supports a vector
3061 # widening multiplication of *short* args into *int* result, 0 otherwise.
3063 # This won't change for different subtargets so cache the result.
3065 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3066 global et_vect_widen_mult_hi_to_si_pattern
3068 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3069 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3071 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3072 if { [istarget powerpc*-*-*]
3073 || [istarget spu-*-*]
3074 || [istarget ia64-*-*]
3075 || [istarget i?86-*-*]
3076 || [istarget x86_64-*-*]
3077 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3078 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3081 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3082 return $et_vect_widen_mult_hi_to_si_pattern_saved
3085 # Return 1 if the target plus current options supports a vector
3086 # widening shift, 0 otherwise.
3088 # This won't change for different subtargets so cache the result.
3090 proc check_effective_target_vect_widen_shift { } {
3091 global et_vect_widen_shift_saved
3093 if [info exists et_vect_shift_saved] {
3094 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3096 set et_vect_widen_shift_saved 0
3097 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3098 set et_vect_widen_shift_saved 1
3101 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3102 return $et_vect_widen_shift_saved
3105 # Return 1 if the target plus current options supports a vector
3106 # dot-product of signed chars, 0 otherwise.
3108 # This won't change for different subtargets so cache the result.
3110 proc check_effective_target_vect_sdot_qi { } {
3111 global et_vect_sdot_qi
3113 if [info exists et_vect_sdot_qi_saved] {
3114 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3116 set et_vect_sdot_qi_saved 0
3117 if { [istarget ia64-*-*] } {
3118 set et_vect_udot_qi_saved 1
3121 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3122 return $et_vect_sdot_qi_saved
3125 # Return 1 if the target plus current options supports a vector
3126 # dot-product of unsigned chars, 0 otherwise.
3128 # This won't change for different subtargets so cache the result.
3130 proc check_effective_target_vect_udot_qi { } {
3131 global et_vect_udot_qi
3133 if [info exists et_vect_udot_qi_saved] {
3134 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3136 set et_vect_udot_qi_saved 0
3137 if { [istarget powerpc*-*-*]
3138 || [istarget ia64-*-*] } {
3139 set et_vect_udot_qi_saved 1
3142 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3143 return $et_vect_udot_qi_saved
3146 # Return 1 if the target plus current options supports a vector
3147 # dot-product of signed shorts, 0 otherwise.
3149 # This won't change for different subtargets so cache the result.
3151 proc check_effective_target_vect_sdot_hi { } {
3152 global et_vect_sdot_hi
3154 if [info exists et_vect_sdot_hi_saved] {
3155 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3157 set et_vect_sdot_hi_saved 0
3158 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3159 || [istarget ia64-*-*]
3160 || [istarget i?86-*-*]
3161 || [istarget x86_64-*-*] } {
3162 set et_vect_sdot_hi_saved 1
3165 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3166 return $et_vect_sdot_hi_saved
3169 # Return 1 if the target plus current options supports a vector
3170 # dot-product of unsigned shorts, 0 otherwise.
3172 # This won't change for different subtargets so cache the result.
3174 proc check_effective_target_vect_udot_hi { } {
3175 global et_vect_udot_hi
3177 if [info exists et_vect_udot_hi_saved] {
3178 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3180 set et_vect_udot_hi_saved 0
3181 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3182 set et_vect_udot_hi_saved 1
3185 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3186 return $et_vect_udot_hi_saved
3190 # Return 1 if the target plus current options supports a vector
3191 # demotion (packing) of shorts (to chars) and ints (to shorts)
3192 # using modulo arithmetic, 0 otherwise.
3194 # This won't change for different subtargets so cache the result.
3196 proc check_effective_target_vect_pack_trunc { } {
3197 global et_vect_pack_trunc
3199 if [info exists et_vect_pack_trunc_saved] {
3200 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3202 set et_vect_pack_trunc_saved 0
3203 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3204 || [istarget i?86-*-*]
3205 || [istarget x86_64-*-*]
3206 || [istarget spu-*-*]
3207 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3208 && [check_effective_target_arm_little_endian]) } {
3209 set et_vect_pack_trunc_saved 1
3212 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3213 return $et_vect_pack_trunc_saved
3216 # Return 1 if the target plus current options supports a vector
3217 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3219 # This won't change for different subtargets so cache the result.
3221 proc check_effective_target_vect_unpack { } {
3222 global et_vect_unpack
3224 if [info exists et_vect_unpack_saved] {
3225 verbose "check_effective_target_vect_unpack: using cached result" 2
3227 set et_vect_unpack_saved 0
3228 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3229 || [istarget i?86-*-*]
3230 || [istarget x86_64-*-*]
3231 || [istarget spu-*-*]
3232 || [istarget ia64-*-*]
3233 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3234 && [check_effective_target_arm_little_endian]) } {
3235 set et_vect_unpack_saved 1
3238 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3239 return $et_vect_unpack_saved
3242 # Return 1 if the target plus current options does not guarantee
3243 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3245 # This won't change for different subtargets so cache the result.
3247 proc check_effective_target_unaligned_stack { } {
3248 global et_unaligned_stack_saved
3250 if [info exists et_unaligned_stack_saved] {
3251 verbose "check_effective_target_unaligned_stack: using cached result" 2
3253 set et_unaligned_stack_saved 0
3255 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3256 return $et_unaligned_stack_saved
3259 # Return 1 if the target plus current options does not support a vector
3260 # alignment mechanism, 0 otherwise.
3262 # This won't change for different subtargets so cache the result.
3264 proc check_effective_target_vect_no_align { } {
3265 global et_vect_no_align_saved
3267 if [info exists et_vect_no_align_saved] {
3268 verbose "check_effective_target_vect_no_align: using cached result" 2
3270 set et_vect_no_align_saved 0
3271 if { [istarget mipsisa64*-*-*]
3272 || [istarget sparc*-*-*]
3273 || [istarget ia64-*-*]
3274 || [check_effective_target_arm_vect_no_misalign]
3275 || ([istarget mips*-*-*]
3276 && [check_effective_target_mips_loongson]) } {
3277 set et_vect_no_align_saved 1
3280 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3281 return $et_vect_no_align_saved
3284 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3286 # This won't change for different subtargets so cache the result.
3288 proc check_effective_target_vect_hw_misalign { } {
3289 global et_vect_hw_misalign_saved
3291 if [info exists et_vect_hw_misalign_saved] {
3292 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3294 set et_vect_hw_misalign_saved 0
3295 if { ([istarget x86_64-*-*]
3296 || [istarget i?86-*-*]) } {
3297 set et_vect_hw_misalign_saved 1
3300 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3301 return $et_vect_hw_misalign_saved
3305 # Return 1 if arrays are aligned to the vector alignment
3306 # boundary, 0 otherwise.
3308 # This won't change for different subtargets so cache the result.
3310 proc check_effective_target_vect_aligned_arrays { } {
3311 global et_vect_aligned_arrays
3313 if [info exists et_vect_aligned_arrays_saved] {
3314 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3316 set et_vect_aligned_arrays_saved 0
3317 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3318 if { ([is-effective-target lp64]
3319 && ( ![check_avx_available]
3320 || [check_prefer_avx128])) } {
3321 set et_vect_aligned_arrays_saved 1
3324 if [istarget spu-*-*] {
3325 set et_vect_aligned_arrays_saved 1
3328 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3329 return $et_vect_aligned_arrays_saved
3332 # Return 1 if types of size 32 bit or less are naturally aligned
3333 # (aligned to their type-size), 0 otherwise.
3335 # This won't change for different subtargets so cache the result.
3337 proc check_effective_target_natural_alignment_32 { } {
3338 global et_natural_alignment_32
3340 if [info exists et_natural_alignment_32_saved] {
3341 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3343 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3344 set et_natural_alignment_32_saved 1
3345 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3346 set et_natural_alignment_32_saved 0
3349 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3350 return $et_natural_alignment_32_saved
3353 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3354 # type-size), 0 otherwise.
3356 # This won't change for different subtargets so cache the result.
3358 proc check_effective_target_natural_alignment_64 { } {
3359 global et_natural_alignment_64
3361 if [info exists et_natural_alignment_64_saved] {
3362 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3364 set et_natural_alignment_64_saved 0
3365 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3366 || [istarget spu-*-*] } {
3367 set et_natural_alignment_64_saved 1
3370 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3371 return $et_natural_alignment_64_saved
3374 # Return 1 if all vector types are naturally aligned (aligned to their
3375 # type-size), 0 otherwise.
3377 # This won't change for different subtargets so cache the result.
3379 proc check_effective_target_vect_natural_alignment { } {
3380 global et_vect_natural_alignment
3382 if [info exists et_vect_natural_alignment_saved] {
3383 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
3385 set et_vect_natural_alignment_saved 1
3386 if { [check_effective_target_arm_eabi] } {
3387 set et_vect_natural_alignment_saved 0
3390 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
3391 return $et_vect_natural_alignment_saved
3394 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3396 # This won't change for different subtargets so cache the result.
3398 proc check_effective_target_vector_alignment_reachable { } {
3399 global et_vector_alignment_reachable
3401 if [info exists et_vector_alignment_reachable_saved] {
3402 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3404 if { [check_effective_target_vect_aligned_arrays]
3405 || [check_effective_target_natural_alignment_32] } {
3406 set et_vector_alignment_reachable_saved 1
3408 set et_vector_alignment_reachable_saved 0
3411 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3412 return $et_vector_alignment_reachable_saved
3415 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3417 # This won't change for different subtargets so cache the result.
3419 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3420 global et_vector_alignment_reachable_for_64bit
3422 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3423 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3425 if { [check_effective_target_vect_aligned_arrays]
3426 || [check_effective_target_natural_alignment_64] } {
3427 set et_vector_alignment_reachable_for_64bit_saved 1
3429 set et_vector_alignment_reachable_for_64bit_saved 0
3432 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3433 return $et_vector_alignment_reachable_for_64bit_saved
3436 # Return 1 if the target only requires element alignment for vector accesses
3438 proc check_effective_target_vect_element_align { } {
3439 global et_vect_element_align
3441 if [info exists et_vect_element_align] {
3442 verbose "check_effective_target_vect_element_align: using cached result" 2
3444 set et_vect_element_align 0
3445 if { ([istarget arm*-*-*]
3446 && ![check_effective_target_arm_vect_no_misalign])
3447 || [check_effective_target_vect_hw_misalign] } {
3448 set et_vect_element_align 1
3452 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3453 return $et_vect_element_align
3456 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3458 proc check_effective_target_vect_condition { } {
3459 global et_vect_cond_saved
3461 if [info exists et_vect_cond_saved] {
3462 verbose "check_effective_target_vect_cond: using cached result" 2
3464 set et_vect_cond_saved 0
3465 if { [istarget powerpc*-*-*]
3466 || [istarget ia64-*-*]
3467 || [istarget i?86-*-*]
3468 || [istarget spu-*-*]
3469 || [istarget x86_64-*-*]
3470 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3471 set et_vect_cond_saved 1
3475 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3476 return $et_vect_cond_saved
3479 # Return 1 if the target supports vector conditional operations where
3480 # the comparison has different type from the lhs, 0 otherwise.
3482 proc check_effective_target_vect_cond_mixed { } {
3483 global et_vect_cond_mixed_saved
3485 if [info exists et_vect_cond_mixed_saved] {
3486 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3488 set et_vect_cond_mixed_saved 0
3489 if { [istarget i?86-*-*]
3490 || [istarget x86_64-*-*]
3491 || [istarget powerpc*-*-*] } {
3492 set et_vect_cond_mixed_saved 1
3496 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3497 return $et_vect_cond_mixed_saved
3500 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3502 proc check_effective_target_vect_char_mult { } {
3503 global et_vect_char_mult_saved
3505 if [info exists et_vect_char_mult_saved] {
3506 verbose "check_effective_target_vect_char_mult: using cached result" 2
3508 set et_vect_char_mult_saved 0
3509 if { [istarget ia64-*-*]
3510 || [istarget i?86-*-*]
3511 || [istarget x86_64-*-*] } {
3512 set et_vect_char_mult_saved 1
3516 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3517 return $et_vect_char_mult_saved
3520 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3522 proc check_effective_target_vect_short_mult { } {
3523 global et_vect_short_mult_saved
3525 if [info exists et_vect_short_mult_saved] {
3526 verbose "check_effective_target_vect_short_mult: using cached result" 2
3528 set et_vect_short_mult_saved 0
3529 if { [istarget ia64-*-*]
3530 || [istarget spu-*-*]
3531 || [istarget i?86-*-*]
3532 || [istarget x86_64-*-*]
3533 || [istarget powerpc*-*-*]
3534 || [check_effective_target_arm32]
3535 || ([istarget mips*-*-*]
3536 && [check_effective_target_mips_loongson]) } {
3537 set et_vect_short_mult_saved 1
3541 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3542 return $et_vect_short_mult_saved
3545 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3547 proc check_effective_target_vect_int_mult { } {
3548 global et_vect_int_mult_saved
3550 if [info exists et_vect_int_mult_saved] {
3551 verbose "check_effective_target_vect_int_mult: using cached result" 2
3553 set et_vect_int_mult_saved 0
3554 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3555 || [istarget spu-*-*]
3556 || [istarget i?86-*-*]
3557 || [istarget x86_64-*-*]
3558 || [istarget ia64-*-*]
3559 || [check_effective_target_arm32] } {
3560 set et_vect_int_mult_saved 1
3564 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3565 return $et_vect_int_mult_saved
3568 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3570 proc check_effective_target_vect_extract_even_odd { } {
3571 global et_vect_extract_even_odd_saved
3573 if [info exists et_vect_extract_even_odd_saved] {
3574 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3576 set et_vect_extract_even_odd_saved 0
3577 if { [istarget powerpc*-*-*]
3578 || [is-effective-target arm_neon_ok]
3579 || [istarget i?86-*-*]
3580 || [istarget x86_64-*-*]
3581 || [istarget ia64-*-*]
3582 || [istarget spu-*-*]
3583 || ([istarget mips*-*-*]
3584 && [check_effective_target_mpaired_single]) } {
3585 set et_vect_extract_even_odd_saved 1
3589 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3590 return $et_vect_extract_even_odd_saved
3593 # Return 1 if the target supports vector interleaving, 0 otherwise.
3595 proc check_effective_target_vect_interleave { } {
3596 global et_vect_interleave_saved
3598 if [info exists et_vect_interleave_saved] {
3599 verbose "check_effective_target_vect_interleave: using cached result" 2
3601 set et_vect_interleave_saved 0
3602 if { [istarget powerpc*-*-*]
3603 || [is-effective-target arm_neon_ok]
3604 || [istarget i?86-*-*]
3605 || [istarget x86_64-*-*]
3606 || [istarget ia64-*-*]
3607 || [istarget spu-*-*]
3608 || ([istarget mips*-*-*]
3609 && [check_effective_target_mpaired_single]) } {
3610 set et_vect_interleave_saved 1
3614 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3615 return $et_vect_interleave_saved
3618 foreach N {2 3 4 8} {
3619 eval [string map [list N $N] {
3620 # Return 1 if the target supports 2-vector interleaving
3621 proc check_effective_target_vect_stridedN { } {
3622 global et_vect_stridedN_saved
3624 if [info exists et_vect_stridedN_saved] {
3625 verbose "check_effective_target_vect_stridedN: using cached result" 2
3627 set et_vect_stridedN_saved 0
3629 && [check_effective_target_vect_interleave]
3630 && [check_effective_target_vect_extract_even_odd] } {
3631 set et_vect_stridedN_saved 1
3633 if { [istarget arm*-*-*] && N >= 2 && N <= 4 } {
3634 set et_vect_stridedN_saved 1
3638 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3639 return $et_vect_stridedN_saved
3644 # Return 1 if the target supports multiple vector sizes
3646 proc check_effective_target_vect_multiple_sizes { } {
3647 global et_vect_multiple_sizes_saved
3649 set et_vect_multiple_sizes_saved 0
3650 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3651 set et_vect_multiple_sizes_saved 1
3653 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3654 if { ([check_avx_available] && ![check_prefer_avx128]) } {
3655 set et_vect_multiple_sizes_saved 1
3659 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
3660 return $et_vect_multiple_sizes_saved
3663 # Return 1 if the target supports vectors of 64 bits.
3665 proc check_effective_target_vect64 { } {
3666 global et_vect64_saved
3668 if [info exists et_vect64_saved] {
3669 verbose "check_effective_target_vect64: using cached result" 2
3671 set et_vect64_saved 0
3672 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3673 set et_vect64_saved 1
3677 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
3678 return $et_vect64_saved
3681 # Return 1 if the target supports vector copysignf calls.
3683 proc check_effective_target_vect_call_copysignf { } {
3684 global et_vect_call_copysignf_saved
3686 if [info exists et_vect_call_copysignf_saved] {
3687 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
3689 set et_vect_call_copysignf_saved 0
3690 if { [istarget i?86-*-*]
3691 || [istarget x86_64-*-*]
3692 || [istarget powerpc*-*-*] } {
3693 set et_vect_call_copysignf_saved 1
3697 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
3698 return $et_vect_call_copysignf_saved
3701 # Return 1 if the target supports vector sqrtf calls.
3703 proc check_effective_target_vect_call_sqrtf { } {
3704 global et_vect_call_sqrtf_saved
3706 if [info exists et_vect_call_sqrtf_saved] {
3707 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
3709 set et_vect_call_sqrtf_saved 0
3710 if { [istarget i?86-*-*]
3711 || [istarget x86_64-*-*]
3712 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
3713 set et_vect_call_sqrtf_saved 1
3717 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
3718 return $et_vect_call_sqrtf_saved
3721 # Return 1 if the target supports vector lrint calls.
3723 proc check_effective_target_vect_call_lrint { } {
3724 set et_vect_call_lrint 0
3725 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
3726 set et_vect_call_lrint 1
3729 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
3730 return $et_vect_call_lrint
3733 # Return 1 if the target supports section-anchors
3735 proc check_effective_target_section_anchors { } {
3736 global et_section_anchors_saved
3738 if [info exists et_section_anchors_saved] {
3739 verbose "check_effective_target_section_anchors: using cached result" 2
3741 set et_section_anchors_saved 0
3742 if { [istarget powerpc*-*-*]
3743 || [istarget arm*-*-*] } {
3744 set et_section_anchors_saved 1
3748 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3749 return $et_section_anchors_saved
3752 # Return 1 if the target supports atomic operations on "int_128" values.
3754 proc check_effective_target_sync_int_128 { } {
3755 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3756 && ![is-effective-target ia32] } {
3763 # Return 1 if the target supports atomic operations on "int_128" values
3764 # and can execute them.
3766 proc check_effective_target_sync_int_128_runtime { } {
3767 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3768 && ![is-effective-target ia32] } {
3769 return [check_cached_effective_target sync_int_128_available {
3770 check_runtime_nocache sync_int_128_available {
3774 unsigned int eax, ebx, ecx, edx;
3775 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3776 return !(ecx & bit_CMPXCHG16B);
3786 # Return 1 if the target supports atomic operations on "long long".
3788 # Note: 32bit x86 targets require -march=pentium in dg-options.
3790 proc check_effective_target_sync_long_long { } {
3791 if { [istarget x86_64-*-*]
3792 || [istarget i?86-*-*])
3793 || [istarget arm*-*-*]
3794 || [istarget alpha*-*-*]
3795 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
3802 # Return 1 if the target supports atomic operations on "long long"
3803 # and can execute them.
3805 # Note: 32bit x86 targets require -march=pentium in dg-options.
3807 proc check_effective_target_sync_long_long_runtime { } {
3808 if { [istarget x86_64-*-*]
3809 || [istarget i?86-*-*] } {
3810 return [check_cached_effective_target sync_long_long_available {
3811 check_runtime_nocache sync_long_long_available {
3815 unsigned int eax, ebx, ecx, edx;
3816 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3817 return !(edx & bit_CMPXCHG8B);
3822 } elseif { [istarget arm*-*-linux-gnueabi*] } {
3823 return [check_runtime sync_longlong_runtime {
3829 if (sizeof (long long) != 8)
3832 /* Just check for native; checking for kernel fallback is tricky. */
3833 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
3838 } elseif { [istarget alpha*-*-*] } {
3840 } elseif { ([istarget sparc*-*-*]
3841 && [check_effective_target_lp64]
3842 && [check_effective_target_ultrasparc_hw]) } {
3849 # Return 1 if the target supports atomic operations on "int" and "long".
3851 proc check_effective_target_sync_int_long { } {
3852 global et_sync_int_long_saved
3854 if [info exists et_sync_int_long_saved] {
3855 verbose "check_effective_target_sync_int_long: using cached result" 2
3857 set et_sync_int_long_saved 0
3858 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3859 # load-reserved/store-conditional instructions.
3860 if { [istarget ia64-*-*]
3861 || [istarget i?86-*-*]
3862 || [istarget x86_64-*-*]
3863 || [istarget alpha*-*-*]
3864 || [istarget arm*-*-linux-gnueabi*]
3865 || [istarget bfin*-*linux*]
3866 || [istarget hppa*-*linux*]
3867 || [istarget s390*-*-*]
3868 || [istarget powerpc*-*-*]
3869 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
3870 || [check_effective_target_mips_llsc] } {
3871 set et_sync_int_long_saved 1
3875 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3876 return $et_sync_int_long_saved
3879 # Return 1 if the target supports atomic operations on "char" and "short".
3881 proc check_effective_target_sync_char_short { } {
3882 global et_sync_char_short_saved
3884 if [info exists et_sync_char_short_saved] {
3885 verbose "check_effective_target_sync_char_short: using cached result" 2
3887 set et_sync_char_short_saved 0
3888 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3889 # load-reserved/store-conditional instructions.
3890 if { [istarget ia64-*-*]
3891 || [istarget i?86-*-*]
3892 || [istarget x86_64-*-*]
3893 || [istarget alpha*-*-*]
3894 || [istarget arm*-*-linux-gnueabi*]
3895 || [istarget hppa*-*linux*]
3896 || [istarget s390*-*-*]
3897 || [istarget powerpc*-*-*]
3898 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
3899 || [check_effective_target_mips_llsc] } {
3900 set et_sync_char_short_saved 1
3904 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3905 return $et_sync_char_short_saved
3908 # Return 1 if the target uses a ColdFire FPU.
3910 proc check_effective_target_coldfire_fpu { } {
3911 return [check_no_compiler_messages coldfire_fpu assembly {
3918 # Return true if this is a uClibc target.
3920 proc check_effective_target_uclibc {} {
3921 return [check_no_compiler_messages uclibc object {
3922 #include <features.h>
3923 #if !defined (__UCLIBC__)
3929 # Return true if this is a uclibc target and if the uclibc feature
3930 # described by __$feature__ is not present.
3932 proc check_missing_uclibc_feature {feature} {
3933 return [check_no_compiler_messages $feature object "
3934 #include <features.h>
3935 #if !defined (__UCLIBC) || defined (__${feature}__)
3941 # Return true if this is a Newlib target.
3943 proc check_effective_target_newlib {} {
3944 return [check_no_compiler_messages newlib object {
3950 # (a) an error of a few ULP is expected in string to floating-point
3951 # conversion functions; and
3952 # (b) overflow is not always detected correctly by those functions.
3954 proc check_effective_target_lax_strtofp {} {
3955 # By default, assume that all uClibc targets suffer from this.
3956 return [check_effective_target_uclibc]
3959 # Return 1 if this is a target for which wcsftime is a dummy
3960 # function that always returns 0.
3962 proc check_effective_target_dummy_wcsftime {} {
3963 # By default, assume that all uClibc targets suffer from this.
3964 return [check_effective_target_uclibc]
3967 # Return 1 if constructors with initialization priority arguments are
3968 # supposed on this target.
3970 proc check_effective_target_init_priority {} {
3971 return [check_no_compiler_messages init_priority assembly "
3972 void f() __attribute__((constructor (1000)));
3977 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3978 # This can be used with any check_* proc that takes no argument and
3979 # returns only 1 or 0. It could be used with check_* procs that take
3980 # arguments with keywords that pass particular arguments.
3982 proc is-effective-target { arg } {
3984 if { [info procs check_effective_target_${arg}] != [list] } {
3985 set selected [check_effective_target_${arg}]
3988 "vmx_hw" { set selected [check_vmx_hw_available] }
3989 "vsx_hw" { set selected [check_vsx_hw_available] }
3990 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3991 "named_sections" { set selected [check_named_sections_available] }
3992 "gc_sections" { set selected [check_gc_sections_available] }
3993 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3994 default { error "unknown effective target keyword `$arg'" }
3997 verbose "is-effective-target: $arg $selected" 2
4001 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
4003 proc is-effective-target-keyword { arg } {
4004 if { [info procs check_effective_target_${arg}] != [list] } {
4007 # These have different names for their check_* procs.
4009 "vmx_hw" { return 1 }
4010 "vsx_hw" { return 1 }
4011 "ppc_recip_hw" { return 1 }
4012 "named_sections" { return 1 }
4013 "gc_sections" { return 1 }
4014 "cxa_atexit" { return 1 }
4015 default { return 0 }
4020 # Return 1 if target default to short enums
4022 proc check_effective_target_short_enums { } {
4023 return [check_no_compiler_messages short_enums assembly {
4025 int s[sizeof (enum foo) == 1 ? 1 : -1];
4029 # Return 1 if target supports merging string constants at link time.
4031 proc check_effective_target_string_merging { } {
4032 return [check_no_messages_and_pattern string_merging \
4033 "rodata\\.str" assembly {
4034 const char *var = "String";
4038 # Return 1 if target has the basic signed and unsigned types in
4039 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
4040 # working <stdint.h> for all targets.
4042 proc check_effective_target_stdint_types { } {
4043 return [check_no_compiler_messages stdint_types assembly {
4045 int8_t a; int16_t b; int32_t c; int64_t d;
4046 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4050 # Return 1 if target has the basic signed and unsigned types in
4051 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
4052 # these types agree with those in the header, as some systems have
4053 # only <inttypes.h>.
4055 proc check_effective_target_inttypes_types { } {
4056 return [check_no_compiler_messages inttypes_types assembly {
4057 #include <inttypes.h>
4058 int8_t a; int16_t b; int32_t c; int64_t d;
4059 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4063 # Return 1 if programs are intended to be run on a simulator
4064 # (i.e. slowly) rather than hardware (i.e. fast).
4066 proc check_effective_target_simulator { } {
4068 # All "src/sim" simulators set this one.
4069 if [board_info target exists is_simulator] {
4070 return [board_info target is_simulator]
4073 # The "sid" simulators don't set that one, but at least they set
4075 if [board_info target exists slow_simulator] {
4076 return [board_info target slow_simulator]
4082 # Return 1 if the target is a VxWorks kernel.
4084 proc check_effective_target_vxworks_kernel { } {
4085 return [check_no_compiler_messages vxworks_kernel assembly {
4086 #if !defined __vxworks || defined __RTP__
4092 # Return 1 if the target is a VxWorks RTP.
4094 proc check_effective_target_vxworks_rtp { } {
4095 return [check_no_compiler_messages vxworks_rtp assembly {
4096 #if !defined __vxworks || !defined __RTP__
4102 # Return 1 if the target is expected to provide wide character support.
4104 proc check_effective_target_wchar { } {
4105 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4108 return [check_no_compiler_messages wchar assembly {
4113 # Return 1 if the target has <pthread.h>.
4115 proc check_effective_target_pthread_h { } {
4116 return [check_no_compiler_messages pthread_h assembly {
4117 #include <pthread.h>
4121 # Return 1 if the target can truncate a file from a file-descriptor,
4122 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4123 # chsize. We test for a trivially functional truncation; no stubs.
4124 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4125 # different function to be used.
4127 proc check_effective_target_fd_truncate { } {
4129 #define _FILE_OFFSET_BITS 64
4135 FILE *f = fopen ("tst.tmp", "wb");
4137 const char t[] = "test writing more than ten characters";
4141 write (fd, t, sizeof (t) - 1);
4143 if (ftruncate (fd, 10) != 0)
4152 f = fopen ("tst.tmp", "rb");
4153 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4161 if { [check_runtime ftruncate $prog] } {
4165 regsub "ftruncate" $prog "chsize" prog
4166 return [check_runtime chsize $prog]
4169 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4171 proc add_options_for_c99_runtime { flags } {
4172 if { [istarget *-*-solaris2*] } {
4173 return "$flags -std=c99"
4175 if { [istarget mips-sgi-irix6.5*] } {
4176 return "$flags -std=c99"
4178 if { [istarget powerpc-*-darwin*] } {
4179 return "$flags -mmacosx-version-min=10.3"
4184 # Add to FLAGS all the target-specific flags needed to enable
4185 # full IEEE compliance mode.
4187 proc add_options_for_ieee { flags } {
4188 if { [istarget alpha*-*-*]
4189 || [istarget sh*-*-*] } {
4190 return "$flags -mieee"
4192 if { [istarget rx-*-*] } {
4193 return "$flags -mnofpu"
4198 # Add to FLAGS the flags needed to enable functions to bind locally
4199 # when using pic/PIC passes in the testsuite.
4201 proc add_options_for_bind_pic_locally { flags } {
4202 if {[check_no_compiler_messages using_pic2 assembly {
4207 return "$flags -fPIE"
4209 if {[check_no_compiler_messages using_pic1 assembly {
4214 return "$flags -fpie"
4220 # Add to FLAGS the flags needed to enable 64-bit vectors.
4222 proc add_options_for_double_vectors { flags } {
4223 if [is-effective-target arm_neon_ok] {
4224 return "$flags -mvectorize-with-neon-double"
4230 # Return 1 if the target provides a full C99 runtime.
4232 proc check_effective_target_c99_runtime { } {
4233 return [check_cached_effective_target c99_runtime {
4236 set file [open "$srcdir/gcc.dg/builtins-config.h"]
4237 set contents [read $file]
4240 #ifndef HAVE_C99_RUNTIME
4244 check_no_compiler_messages_nocache c99_runtime assembly \
4245 $contents [add_options_for_c99_runtime ""]
4249 # Return 1 if target wchar_t is at least 4 bytes.
4251 proc check_effective_target_4byte_wchar_t { } {
4252 return [check_no_compiler_messages 4byte_wchar_t object {
4253 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
4257 # Return 1 if the target supports automatic stack alignment.
4259 proc check_effective_target_automatic_stack_alignment { } {
4260 # Ordinarily x86 supports automatic stack alignment ...
4261 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
4262 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
4263 # ... except Win64 SEH doesn't. Succeed for Win32 though.
4264 return [check_effective_target_ilp32];
4271 # Return true if we are compiling for AVX target.
4273 proc check_avx_available { } {
4274 if { [check_no_compiler_messages avx_available assembly {
4284 # Return true if 32- and 16-bytes vectors are available.
4286 proc check_effective_target_vect_sizes_32B_16B { } {
4287 return [check_avx_available];
4290 # Return true if 128-bits vectors are preferred even if 256-bits vectors
4293 proc check_prefer_avx128 { } {
4294 if ![check_avx_available] {
4297 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
4298 float a[1024],b[1024],c[1024];
4299 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
4300 } "-O2 -ftree-vectorize"]
4304 # Return 1 if avx instructions can be compiled.
4306 proc check_effective_target_avx { } {
4307 return [check_no_compiler_messages avx object {
4308 void _mm256_zeroall (void)
4310 __builtin_ia32_vzeroall ();
4315 # Return 1 if sse instructions can be compiled.
4316 proc check_effective_target_sse { } {
4317 return [check_no_compiler_messages sse object {
4320 __builtin_ia32_stmxcsr ();
4326 # Return 1 if sse2 instructions can be compiled.
4327 proc check_effective_target_sse2 { } {
4328 return [check_no_compiler_messages sse2 object {
4329 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
4331 __m128i _mm_srli_si128 (__m128i __A, int __N)
4333 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
4338 # Return 1 if F16C instructions can be compiled.
4340 proc check_effective_target_f16c { } {
4341 return [check_no_compiler_messages f16c object {
4342 #include "immintrin.h"
4344 foo (unsigned short val)
4346 return _cvtsh_ss (val);
4351 # Return 1 if C wchar_t type is compatible with char16_t.
4353 proc check_effective_target_wchar_t_char16_t_compatible { } {
4354 return [check_no_compiler_messages wchar_t_char16_t object {
4356 __CHAR16_TYPE__ *p16 = &wc;
4357 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4361 # Return 1 if C wchar_t type is compatible with char32_t.
4363 proc check_effective_target_wchar_t_char32_t_compatible { } {
4364 return [check_no_compiler_messages wchar_t_char32_t object {
4366 __CHAR32_TYPE__ *p32 = &wc;
4367 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4371 # Return 1 if pow10 function exists.
4373 proc check_effective_target_pow10 { } {
4374 return [check_runtime pow10 {
4384 # Return 1 if current options generate DFP instructions, 0 otherwise.
4386 proc check_effective_target_hard_dfp {} {
4387 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
4388 typedef float d64 __attribute__((mode(DD)));
4390 void foo (void) { z = x + y; }
4394 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
4395 # for strchr etc. functions.
4397 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
4398 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
4401 #if !defined(__cplusplus) \
4402 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
4403 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
4404 ISO C++ correct string.h and wchar.h protos not supported.
4411 # Return 1 if GNU as is used.
4413 proc check_effective_target_gas { } {
4414 global use_gas_saved
4417 if {![info exists use_gas_saved]} {
4418 # Check if the as used by gcc is GNU as.
4419 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
4420 # Provide /dev/null as input, otherwise gas times out reading from
4422 set status [remote_exec host "$gcc_as" "-v /dev/null"]
4423 set as_output [lindex $status 1]
4424 if { [ string first "GNU" $as_output ] >= 0 } {
4430 return $use_gas_saved
4433 # Return 1 if GNU ld is used.
4435 proc check_effective_target_gld { } {
4436 global use_gld_saved
4439 if {![info exists use_gld_saved]} {
4440 # Check if the ld used by gcc is GNU ld.
4441 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
4442 set status [remote_exec host "$gcc_ld" "--version"]
4443 set ld_output [lindex $status 1]
4444 if { [ string first "GNU" $ld_output ] >= 0 } {
4450 return $use_gld_saved
4453 # Return 1 if the compiler has been configure with link-time optimization
4456 proc check_effective_target_lto { } {
4458 return [info exists ENABLE_LTO]
4461 # Return 1 if this target supports the -fsplit-stack option, 0
4464 proc check_effective_target_split_stack {} {
4465 return [check_no_compiler_messages split_stack object {
4470 # Return 1 if the language for the compiler under test is C.
4472 proc check_effective_target_c { } {
4474 if [string match $tool "gcc"] {
4480 # Return 1 if the language for the compiler under test is C++.
4482 proc check_effective_target_c++ { } {
4484 if [string match $tool "g++"] {
4490 # Check which language standard is active by checking for the presence of
4491 # one of the C++11 -std flags. This assumes that the default for the
4492 # compiler is C++98, and that there will never be multiple -std= arguments
4493 # on the command line.
4494 proc check_effective_target_c++11 { } {
4495 if ![check_effective_target_c++] {
4498 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4501 proc check_effective_target_c++98 { } {
4502 if ![check_effective_target_c++] {
4505 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4508 # Return 1 if expensive testcases should be run.
4510 proc check_effective_target_run_expensive_tests { } {
4511 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
4517 # Returns 1 if "mempcpy" is available on the target system.
4519 proc check_effective_target_mempcpy {} {
4520 return [check_function_available "mempcpy"]
4523 # Check whether the vectorizer tests are supported by the target and
4524 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
4525 # Set dg-do-what-default to either compile or run, depending on target
4526 # capabilities. Return 1 if vectorizer tests are supported by
4527 # target, 0 otherwise.
4529 proc check_vect_support_and_set_flags { } {
4530 global DEFAULT_VECTCFLAGS
4531 global dg-do-what-default
4533 if [istarget powerpc-*paired*] {
4534 lappend DEFAULT_VECTCFLAGS "-mpaired"
4535 if [check_750cl_hw_available] {
4536 set dg-do-what-default run
4538 set dg-do-what-default compile
4540 } elseif [istarget powerpc*-*-*] {
4541 # Skip targets not supporting -maltivec.
4542 if ![is-effective-target powerpc_altivec_ok] {
4546 lappend DEFAULT_VECTCFLAGS "-maltivec"
4547 if [check_vsx_hw_available] {
4548 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
4551 if [check_vmx_hw_available] {
4552 set dg-do-what-default run
4554 if [is-effective-target ilp32] {
4555 # Specify a cpu that supports VMX for compile-only tests.
4556 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
4558 set dg-do-what-default compile
4560 } elseif { [istarget spu-*-*] } {
4561 set dg-do-what-default run
4562 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4563 lappend DEFAULT_VECTCFLAGS "-msse2"
4564 if { [check_effective_target_sse2_runtime] } {
4565 set dg-do-what-default run
4567 set dg-do-what-default compile
4569 } elseif { [istarget mips*-*-*]
4570 && ([check_effective_target_mpaired_single]
4571 || [check_effective_target_mips_loongson])
4572 && [check_effective_target_nomips16] } {
4573 if { [check_effective_target_mpaired_single] } {
4574 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
4576 set dg-do-what-default run
4577 } elseif [istarget sparc*-*-*] {
4578 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
4579 if [check_effective_target_ultrasparc_hw] {
4580 set dg-do-what-default run
4582 set dg-do-what-default compile
4584 } elseif [istarget alpha*-*-*] {
4585 # Alpha's vectorization capabilities are extremely limited.
4586 # It's more effort than its worth disabling all of the tests
4587 # that it cannot pass. But if you actually want to see what
4588 # does work, command out the return.
4591 lappend DEFAULT_VECTCFLAGS "-mmax"
4592 if [check_alpha_max_hw_available] {
4593 set dg-do-what-default run
4595 set dg-do-what-default compile
4597 } elseif [istarget ia64-*-*] {
4598 set dg-do-what-default run
4599 } elseif [is-effective-target arm_neon_ok] {
4600 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
4601 # NEON does not support denormals, so is not used for vectorization by
4602 # default to avoid loss of precision. We must pass -ffast-math to test
4603 # vectorization of float operations.
4604 lappend DEFAULT_VECTCFLAGS "-ffast-math"
4605 if [is-effective-target arm_neon_hw] {
4606 set dg-do-what-default run
4608 set dg-do-what-default compile
4617 proc check_effective_target_non_strict_align {} {
4618 return [check_no_compiler_messages non_strict_align assembly {
4620 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
4622 void foo(void) { z = (c *) y; }
4626 # Return 1 if the target has <ucontext.h>.
4628 proc check_effective_target_ucontext_h { } {
4629 return [check_no_compiler_messages ucontext_h assembly {
4630 #include <ucontext.h>