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 the target supports mmap, 0 otherwise.
721 proc check_effective_target_mmap {} {
722 return [check_function_available "mmap"]
725 # Return 1 if compilation with -pthread is error-free for trivial
728 proc check_effective_target_pthread {} {
729 return [check_no_compiler_messages pthread object {
734 # Return 1 if compilation with -mpe-aligned-commons is error-free
735 # for trivial code, 0 otherwise.
737 proc check_effective_target_pe_aligned_commons {} {
738 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
739 return [check_no_compiler_messages pe_aligned_commons object {
741 } "-mpe-aligned-commons"]
746 # Return 1 if the target supports -static
747 proc check_effective_target_static {} {
748 return [check_no_compiler_messages static executable {
749 int main (void) { return 0; }
753 # Return 1 if the target supports -fstack-protector
754 proc check_effective_target_fstack_protector {} {
755 return [check_runtime fstack_protector {
756 int main (void) { return 0; }
757 } "-fstack-protector"]
760 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
761 # for trivial code, 0 otherwise.
763 proc check_effective_target_freorder {} {
764 return [check_no_compiler_messages freorder object {
766 } "-freorder-blocks-and-partition"]
769 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
770 # emitted, 0 otherwise. Whether a shared library can actually be built is
771 # out of scope for this test.
773 proc check_effective_target_fpic { } {
774 # Note that M68K has a multilib that supports -fpic but not
775 # -fPIC, so we need to check both. We test with a program that
776 # requires GOT references.
777 foreach arg {fpic fPIC} {
778 if [check_no_compiler_messages $arg object {
779 extern int foo (void); extern int bar;
780 int baz (void) { return foo () + bar; }
788 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
790 proc check_effective_target_pie { } {
791 if { [istarget *-*-darwin\[912\]*]
792 || [istarget *-*-linux*] } {
798 # Return true if the target supports -mpaired-single (as used on MIPS).
800 proc check_effective_target_mpaired_single { } {
801 return [check_no_compiler_messages mpaired_single object {
806 # Return true if the target has access to FPU instructions.
808 proc check_effective_target_hard_float { } {
809 if { [istarget mips*-*-*] } {
810 return [check_no_compiler_messages hard_float assembly {
811 #if (defined __mips_soft_float || defined __mips16)
817 # This proc is actually checking the availabilty of FPU
818 # support for doubles, so on the RX we must fail if the
819 # 64-bit double multilib has been selected.
820 if { [istarget rx-*-*] } {
822 # return [check_no_compiler_messages hard_float assembly {
823 #if defined __RX_64_BIT_DOUBLES__
829 # The generic test equates hard_float with "no call for adding doubles".
830 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
831 double a (double b, double c) { return b + c; }
835 # Return true if the target is a 64-bit MIPS target.
837 proc check_effective_target_mips64 { } {
838 return [check_no_compiler_messages mips64 assembly {
845 # Return true if the target is a MIPS target that does not produce
848 proc check_effective_target_nomips16 { } {
849 return [check_no_compiler_messages nomips16 object {
853 /* A cheap way of testing for -mflip-mips16. */
854 void foo (void) { asm ("addiu $20,$20,1"); }
855 void bar (void) { asm ("addiu $20,$20,1"); }
860 # Add the options needed for MIPS16 function attributes. At the moment,
861 # we don't support MIPS16 PIC.
863 proc add_options_for_mips16_attribute { flags } {
864 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
867 # Return true if we can force a mode that allows MIPS16 code generation.
868 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
871 proc check_effective_target_mips16_attribute { } {
872 return [check_no_compiler_messages mips16_attribute assembly {
876 #if defined __mips_hard_float \
877 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
878 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
881 } [add_options_for_mips16_attribute ""]]
884 # Return 1 if the target supports long double larger than double when
885 # using the new ABI, 0 otherwise.
887 proc check_effective_target_mips_newabi_large_long_double { } {
888 return [check_no_compiler_messages mips_newabi_large_long_double object {
889 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
893 # Return 1 if the current multilib does not generate PIC by default.
895 proc check_effective_target_nonpic { } {
896 return [check_no_compiler_messages nonpic assembly {
903 # Return 1 if the target does not use a status wrapper.
905 proc check_effective_target_unwrapped { } {
906 if { [target_info needs_status_wrapper] != "" \
907 && [target_info needs_status_wrapper] != "0" } {
913 # Return true if iconv is supported on the target. In particular IBM1047.
915 proc check_iconv_available { test_what } {
918 # If the tool configuration file has not set libiconv, try "-liconv"
919 if { ![info exists libiconv] } {
920 set libiconv "-liconv"
922 set test_what [lindex $test_what 1]
923 return [check_runtime_nocache $test_what [subst {
929 cd = iconv_open ("$test_what", "UTF-8");
930 if (cd == (iconv_t) -1)
937 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
939 proc check_ascii_locale_available { } {
940 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
941 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
948 # Return true if named sections are supported on this target.
950 proc check_named_sections_available { } {
951 return [check_no_compiler_messages named_sections assembly {
952 int __attribute__ ((section("whatever"))) foo;
956 # Return 1 if the target supports Fortran real kinds larger than real(8),
959 # When the target name changes, replace the cached result.
961 proc check_effective_target_fortran_large_real { } {
962 return [check_no_compiler_messages fortran_large_real executable {
964 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
971 # Return 1 if the target supports Fortran real kind real(16),
972 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
973 # this checks for Real(16) only; the other returned real(10) if
974 # both real(10) and real(16) are available.
976 # When the target name changes, replace the cached result.
978 proc check_effective_target_fortran_real_16 { } {
979 return [check_no_compiler_messages fortran_real_16 executable {
988 # Return 1 if the target supports SQRT for the largest floating-point
989 # type. (Some targets lack the libm support for this FP type.)
990 # On most targets, this check effectively checks either whether sqrtl is
991 # available or on __float128 systems whether libquadmath is installed,
992 # which provides sqrtq.
994 # When the target name changes, replace the cached result.
996 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
997 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
999 use iso_fortran_env, only: real_kinds
1000 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1001 real(kind=maxFP), volatile :: x
1009 # Return 1 if the target supports Fortran integer kinds larger than
1010 # integer(8), 0 otherwise.
1012 # When the target name changes, replace the cached result.
1014 proc check_effective_target_fortran_large_int { } {
1015 return [check_no_compiler_messages fortran_large_int executable {
1017 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1018 integer(kind=k) :: i
1023 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1025 # When the target name changes, replace the cached result.
1027 proc check_effective_target_fortran_integer_16 { } {
1028 return [check_no_compiler_messages fortran_integer_16 executable {
1035 # Return 1 if we can statically link libgfortran, 0 otherwise.
1037 # When the target name changes, replace the cached result.
1039 proc check_effective_target_static_libgfortran { } {
1040 return [check_no_compiler_messages static_libgfortran executable {
1047 proc check_linker_plugin_available { } {
1048 return [check_no_compiler_messages_nocache linker_plugin executable {
1049 int main() { return 0; }
1050 } "-flto -fuse-linker-plugin"]
1053 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1054 # otherwise. Cache the result.
1056 proc check_750cl_hw_available { } {
1057 return [check_cached_effective_target 750cl_hw_available {
1058 # If this is not the right target then we can skip the test.
1059 if { ![istarget powerpc-*paired*] } {
1062 check_runtime_nocache 750cl_hw_available {
1066 asm volatile ("ps_mul v0,v0,v0");
1068 asm volatile ("ps_mul 0,0,0");
1077 # Return 1 if the target OS supports running SSE executables, 0
1078 # otherwise. Cache the result.
1080 proc check_sse_os_support_available { } {
1081 return [check_cached_effective_target sse_os_support_available {
1082 # If this is not the right target then we can skip the test.
1083 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1085 } elseif { [istarget i?86-*-solaris2*] } {
1086 # The Solaris 2 kernel doesn't save and restore SSE registers
1087 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1088 check_runtime_nocache sse_os_support_available {
1091 asm volatile ("movaps %xmm0,%xmm0");
1101 # Return 1 if the target OS supports running AVX executables, 0
1102 # otherwise. Cache the result.
1104 proc check_avx_os_support_available { } {
1105 return [check_cached_effective_target avx_os_support_available {
1106 # If this is not the right target then we can skip the test.
1107 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1110 # Check that OS has AVX and SSE saving enabled.
1111 check_runtime_nocache avx_os_support_available {
1114 unsigned int eax, edx;
1116 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1117 return (eax & 6) != 6;
1124 # Return 1 if the target supports executing SSE instructions, 0
1125 # otherwise. Cache the result.
1127 proc check_sse_hw_available { } {
1128 return [check_cached_effective_target sse_hw_available {
1129 # If this is not the right target then we can skip the test.
1130 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1133 check_runtime_nocache sse_hw_available {
1137 unsigned int eax, ebx, ecx, edx;
1138 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1139 return !(edx & bit_SSE);
1147 # Return 1 if the target supports executing SSE2 instructions, 0
1148 # otherwise. Cache the result.
1150 proc check_sse2_hw_available { } {
1151 return [check_cached_effective_target sse2_hw_available {
1152 # If this is not the right target then we can skip the test.
1153 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1156 check_runtime_nocache sse2_hw_available {
1160 unsigned int eax, ebx, ecx, edx;
1161 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1162 return !(edx & bit_SSE2);
1170 # Return 1 if the target supports executing AVX instructions, 0
1171 # otherwise. Cache the result.
1173 proc check_avx_hw_available { } {
1174 return [check_cached_effective_target avx_hw_available {
1175 # If this is not the right target then we can skip the test.
1176 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1179 check_runtime_nocache avx_hw_available {
1183 unsigned int eax, ebx, ecx, edx;
1184 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1185 return ((ecx & (bit_AVX | bit_OSXSAVE))
1186 != (bit_AVX | bit_OSXSAVE));
1194 # Return 1 if the target supports running SSE executables, 0 otherwise.
1196 proc check_effective_target_sse_runtime { } {
1197 if { [check_effective_target_sse]
1198 && [check_sse_hw_available]
1199 && [check_sse_os_support_available] } {
1205 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1207 proc check_effective_target_sse2_runtime { } {
1208 if { [check_effective_target_sse2]
1209 && [check_sse2_hw_available]
1210 && [check_sse_os_support_available] } {
1216 # Return 1 if the target supports running AVX executables, 0 otherwise.
1218 proc check_effective_target_avx_runtime { } {
1219 if { [check_effective_target_avx]
1220 && [check_avx_hw_available]
1221 && [check_avx_os_support_available] } {
1227 # Return 1 if the target supports executing VSX instructions, 0
1228 # otherwise. Cache the result.
1230 proc check_vsx_hw_available { } {
1231 return [check_cached_effective_target vsx_hw_available {
1232 # Some simulators are known to not support VSX instructions.
1233 # For now, disable on Darwin
1234 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1238 check_runtime_nocache vsx_hw_available {
1242 asm volatile ("xxlor vs0,vs0,vs0");
1244 asm volatile ("xxlor 0,0,0");
1253 # Return 1 if the target supports executing AltiVec instructions, 0
1254 # otherwise. Cache the result.
1256 proc check_vmx_hw_available { } {
1257 return [check_cached_effective_target vmx_hw_available {
1258 # Some simulators are known to not support VMX instructions.
1259 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1262 # Most targets don't require special flags for this test case, but
1263 # Darwin does. Just to be sure, make sure VSX is not enabled for
1264 # the altivec tests.
1265 if { [istarget *-*-darwin*]
1266 || [istarget *-*-aix*] } {
1267 set options "-maltivec -mno-vsx"
1269 set options "-mno-vsx"
1271 check_runtime_nocache vmx_hw_available {
1275 asm volatile ("vor v0,v0,v0");
1277 asm volatile ("vor 0,0,0");
1286 proc check_ppc_recip_hw_available { } {
1287 return [check_cached_effective_target ppc_recip_hw_available {
1288 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1289 # For now, disable on Darwin
1290 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1293 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1294 check_runtime_nocache ppc_recip_hw_available {
1295 volatile double d_recip, d_rsqrt, d_four = 4.0;
1296 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1299 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1300 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1301 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1302 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1310 # Return 1 if the target supports executing AltiVec and Cell PPU
1311 # instructions, 0 otherwise. Cache the result.
1313 proc check_effective_target_cell_hw { } {
1314 return [check_cached_effective_target cell_hw_available {
1315 # Some simulators are known to not support VMX and PPU instructions.
1316 if { [istarget powerpc-*-eabi*] } {
1319 # Most targets don't require special flags for this test
1320 # case, but Darwin and AIX do.
1321 if { [istarget *-*-darwin*]
1322 || [istarget *-*-aix*] } {
1323 set options "-maltivec -mcpu=cell"
1325 set options "-mcpu=cell"
1327 check_runtime_nocache cell_hw_available {
1331 asm volatile ("vor v0,v0,v0");
1332 asm volatile ("lvlx v0,r0,r0");
1334 asm volatile ("vor 0,0,0");
1335 asm volatile ("lvlx 0,0,0");
1344 # Return 1 if the target supports executing 64-bit instructions, 0
1345 # otherwise. Cache the result.
1347 proc check_effective_target_powerpc64 { } {
1348 global powerpc64_available_saved
1351 if [info exists powerpc64_available_saved] {
1352 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1354 set powerpc64_available_saved 0
1356 # Some simulators are known to not support powerpc64 instructions.
1357 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1358 verbose "check_effective_target_powerpc64 returning 0" 2
1359 return $powerpc64_available_saved
1362 # Set up, compile, and execute a test program containing a 64-bit
1363 # instruction. Include the current process ID in the file
1364 # names to prevent conflicts with invocations for multiple
1369 set f [open $src "w"]
1370 puts $f "int main() {"
1371 puts $f "#ifdef __MACH__"
1372 puts $f " asm volatile (\"extsw r0,r0\");"
1374 puts $f " asm volatile (\"extsw 0,0\");"
1376 puts $f " return 0; }"
1379 set opts "additional_flags=-mcpu=G5"
1381 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1382 set lines [${tool}_target_compile $src $exe executable "$opts"]
1385 if [string match "" $lines] then {
1386 # No error message, compilation succeeded.
1387 set result [${tool}_load "./$exe" "" ""]
1388 set status [lindex $result 0]
1389 remote_file build delete $exe
1390 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1392 if { $status == "pass" } then {
1393 set powerpc64_available_saved 1
1396 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1400 return $powerpc64_available_saved
1403 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1404 # complex float arguments. This affects gfortran tests that call cabsf
1405 # in libm built by an earlier compiler. Return 1 if libm uses the same
1406 # argument passing as the compiler under test, 0 otherwise.
1408 # When the target name changes, replace the cached result.
1410 proc check_effective_target_broken_cplxf_arg { } {
1411 return [check_cached_effective_target broken_cplxf_arg {
1412 # Skip the work for targets known not to be affected.
1413 if { ![istarget powerpc64-*-linux*] } {
1415 } elseif { ![is-effective-target lp64] } {
1418 check_runtime_nocache broken_cplxf_arg {
1419 #include <complex.h>
1420 extern void abort (void);
1421 float fabsf (float);
1422 float cabsf (_Complex float);
1429 if (fabsf (f - 5.0) > 0.0001)
1438 # Return 1 is this is a TI C6X target supporting C67X instructions
1439 proc check_effective_target_ti_c67x { } {
1440 return [check_no_compiler_messages ti_c67x assembly {
1441 #if !defined(_TMS320C6700)
1447 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1448 proc check_effective_target_ti_c64xp { } {
1449 return [check_no_compiler_messages ti_c64xp assembly {
1450 #if !defined(_TMS320C6400_PLUS)
1457 proc check_alpha_max_hw_available { } {
1458 return [check_runtime alpha_max_hw_available {
1459 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1463 # Returns true iff the FUNCTION is available on the target system.
1464 # (This is essentially a Tcl implementation of Autoconf's
1467 proc check_function_available { function } {
1468 return [check_no_compiler_messages ${function}_available \
1474 int main () { $function (); }
1478 # Returns true iff "fork" is available on the target system.
1480 proc check_fork_available {} {
1481 return [check_function_available "fork"]
1484 # Returns true iff "mkfifo" is available on the target system.
1486 proc check_mkfifo_available {} {
1487 if { [istarget *-*-cygwin*] } {
1488 # Cygwin has mkfifo, but support is incomplete.
1492 return [check_function_available "mkfifo"]
1495 # Returns true iff "__cxa_atexit" is used on the target system.
1497 proc check_cxa_atexit_available { } {
1498 return [check_cached_effective_target cxa_atexit_available {
1499 if { [istarget hppa*-*-hpux10*] } {
1500 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1502 } elseif { [istarget *-*-vxworks] } {
1503 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1506 check_runtime_nocache cxa_atexit_available {
1509 static unsigned int count;
1526 Y() { f(); count = 2; }
1535 int main() { return 0; }
1541 proc check_effective_target_objc2 { } {
1542 return [check_no_compiler_messages objc2 object {
1551 proc check_effective_target_next_runtime { } {
1552 return [check_no_compiler_messages objc2 object {
1553 #ifdef __NEXT_RUNTIME__
1561 # Return 1 if we're generating 32-bit code using default options, 0
1564 proc check_effective_target_ilp32 { } {
1565 return [check_no_compiler_messages ilp32 object {
1566 int dummy[sizeof (int) == 4
1567 && sizeof (void *) == 4
1568 && sizeof (long) == 4 ? 1 : -1];
1572 # Return 1 if we're generating ia32 code using default options, 0
1575 proc check_effective_target_ia32 { } {
1576 return [check_no_compiler_messages ia32 object {
1577 int dummy[sizeof (int) == 4
1578 && sizeof (void *) == 4
1579 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1583 # Return 1 if we're generating x32 code using default options, 0
1586 proc check_effective_target_x32 { } {
1587 return [check_no_compiler_messages x32 object {
1588 int dummy[sizeof (int) == 4
1589 && sizeof (void *) == 4
1590 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1594 # Return 1 if we're generating 32-bit or larger integers using default
1595 # options, 0 otherwise.
1597 proc check_effective_target_int32plus { } {
1598 return [check_no_compiler_messages int32plus object {
1599 int dummy[sizeof (int) >= 4 ? 1 : -1];
1603 # Return 1 if we're generating 32-bit or larger pointers using default
1604 # options, 0 otherwise.
1606 proc check_effective_target_ptr32plus { } {
1607 return [check_no_compiler_messages ptr32plus object {
1608 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1612 # Return 1 if we support 32-bit or larger array and structure sizes
1613 # using default options, 0 otherwise.
1615 proc check_effective_target_size32plus { } {
1616 return [check_no_compiler_messages size32plus object {
1621 # Returns 1 if we're generating 16-bit or smaller integers with the
1622 # default options, 0 otherwise.
1624 proc check_effective_target_int16 { } {
1625 return [check_no_compiler_messages int16 object {
1626 int dummy[sizeof (int) < 4 ? 1 : -1];
1630 # Return 1 if we're generating 64-bit code using default options, 0
1633 proc check_effective_target_lp64 { } {
1634 return [check_no_compiler_messages lp64 object {
1635 int dummy[sizeof (int) == 4
1636 && sizeof (void *) == 8
1637 && sizeof (long) == 8 ? 1 : -1];
1641 # Return 1 if we're generating 64-bit code using default llp64 options,
1644 proc check_effective_target_llp64 { } {
1645 return [check_no_compiler_messages llp64 object {
1646 int dummy[sizeof (int) == 4
1647 && sizeof (void *) == 8
1648 && sizeof (long long) == 8
1649 && sizeof (long) == 4 ? 1 : -1];
1653 # Return 1 if the target supports long double larger than double,
1656 proc check_effective_target_large_long_double { } {
1657 return [check_no_compiler_messages large_long_double object {
1658 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1662 # Return 1 if the target supports double larger than float,
1665 proc check_effective_target_large_double { } {
1666 return [check_no_compiler_messages large_double object {
1667 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1671 # Return 1 if the target supports double of 64 bits,
1674 proc check_effective_target_double64 { } {
1675 return [check_no_compiler_messages double64 object {
1676 int dummy[sizeof(double) == 8 ? 1 : -1];
1680 # Return 1 if the target supports double of at least 64 bits,
1683 proc check_effective_target_double64plus { } {
1684 return [check_no_compiler_messages double64plus object {
1685 int dummy[sizeof(double) >= 8 ? 1 : -1];
1689 # Return 1 if the target supports compiling fixed-point,
1692 proc check_effective_target_fixed_point { } {
1693 return [check_no_compiler_messages fixed_point object {
1694 _Sat _Fract x; _Sat _Accum y;
1698 # Return 1 if the target supports compiling decimal floating point,
1701 proc check_effective_target_dfp_nocache { } {
1702 verbose "check_effective_target_dfp_nocache: compiling source" 2
1703 set ret [check_no_compiler_messages_nocache dfp object {
1704 float x __attribute__((mode(DD)));
1706 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1710 proc check_effective_target_dfprt_nocache { } {
1711 return [check_runtime_nocache dfprt {
1712 typedef float d64 __attribute__((mode(DD)));
1713 d64 x = 1.2df, y = 2.3dd, z;
1714 int main () { z = x + y; return 0; }
1718 # Return 1 if the target supports compiling Decimal Floating Point,
1721 # This won't change for different subtargets so cache the result.
1723 proc check_effective_target_dfp { } {
1724 return [check_cached_effective_target dfp {
1725 check_effective_target_dfp_nocache
1729 # Return 1 if the target supports linking and executing Decimal Floating
1730 # Point, 0 otherwise.
1732 # This won't change for different subtargets so cache the result.
1734 proc check_effective_target_dfprt { } {
1735 return [check_cached_effective_target dfprt {
1736 check_effective_target_dfprt_nocache
1740 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1742 proc check_effective_target_ucn_nocache { } {
1743 # -std=c99 is only valid for C
1744 if [check_effective_target_c] {
1745 set ucnopts "-std=c99"
1747 append ucnopts " -fextended-identifiers"
1748 verbose "check_effective_target_ucn_nocache: compiling source" 2
1749 set ret [check_no_compiler_messages_nocache ucn object {
1752 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1756 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1758 # This won't change for different subtargets, so cache the result.
1760 proc check_effective_target_ucn { } {
1761 return [check_cached_effective_target ucn {
1762 check_effective_target_ucn_nocache
1766 # Return 1 if the target needs a command line argument to enable a SIMD
1769 proc check_effective_target_vect_cmdline_needed { } {
1770 global et_vect_cmdline_needed_saved
1771 global et_vect_cmdline_needed_target_name
1773 if { ![info exists et_vect_cmdline_needed_target_name] } {
1774 set et_vect_cmdline_needed_target_name ""
1777 # If the target has changed since we set the cached value, clear it.
1778 set current_target [current_target_name]
1779 if { $current_target != $et_vect_cmdline_needed_target_name } {
1780 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1781 set et_vect_cmdline_needed_target_name $current_target
1782 if { [info exists et_vect_cmdline_needed_saved] } {
1783 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1784 unset et_vect_cmdline_needed_saved
1788 if [info exists et_vect_cmdline_needed_saved] {
1789 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1791 set et_vect_cmdline_needed_saved 1
1792 if { [istarget alpha*-*-*]
1793 || [istarget ia64-*-*]
1794 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1795 && ([check_effective_target_x32]
1796 || [check_effective_target_lp64]))
1797 || ([istarget powerpc*-*-*]
1798 && ([check_effective_target_powerpc_spe]
1799 || [check_effective_target_powerpc_altivec]))
1800 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1801 || [istarget spu-*-*]
1802 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1803 set et_vect_cmdline_needed_saved 0
1807 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1808 return $et_vect_cmdline_needed_saved
1811 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1813 # This won't change for different subtargets so cache the result.
1815 proc check_effective_target_vect_int { } {
1816 global et_vect_int_saved
1818 if [info exists et_vect_int_saved] {
1819 verbose "check_effective_target_vect_int: using cached result" 2
1821 set et_vect_int_saved 0
1822 if { [istarget i?86-*-*]
1823 || ([istarget powerpc*-*-*]
1824 && ![istarget powerpc-*-linux*paired*])
1825 || [istarget spu-*-*]
1826 || [istarget x86_64-*-*]
1827 || [istarget sparc*-*-*]
1828 || [istarget alpha*-*-*]
1829 || [istarget ia64-*-*]
1830 || [check_effective_target_arm32]
1831 || ([istarget mips*-*-*]
1832 && [check_effective_target_mips_loongson]) } {
1833 set et_vect_int_saved 1
1837 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1838 return $et_vect_int_saved
1841 # Return 1 if the target supports signed int->float conversion
1844 proc check_effective_target_vect_intfloat_cvt { } {
1845 global et_vect_intfloat_cvt_saved
1847 if [info exists et_vect_intfloat_cvt_saved] {
1848 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1850 set et_vect_intfloat_cvt_saved 0
1851 if { [istarget i?86-*-*]
1852 || ([istarget powerpc*-*-*]
1853 && ![istarget powerpc-*-linux*paired*])
1854 || [istarget x86_64-*-*]
1855 || ([istarget arm*-*-*]
1856 && [check_effective_target_arm_neon_ok])} {
1857 set et_vect_intfloat_cvt_saved 1
1861 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1862 return $et_vect_intfloat_cvt_saved
1865 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1867 proc check_effective_target_int128 { } {
1868 return [check_no_compiler_messages int128 object {
1870 #ifndef __SIZEOF_INT128__
1879 # Return 1 if the target supports unsigned int->float conversion
1882 proc check_effective_target_vect_uintfloat_cvt { } {
1883 global et_vect_uintfloat_cvt_saved
1885 if [info exists et_vect_uintfloat_cvt_saved] {
1886 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1888 set et_vect_uintfloat_cvt_saved 0
1889 if { [istarget i?86-*-*]
1890 || ([istarget powerpc*-*-*]
1891 && ![istarget powerpc-*-linux*paired*])
1892 || [istarget x86_64-*-*]
1893 || ([istarget arm*-*-*]
1894 && [check_effective_target_arm_neon_ok])} {
1895 set et_vect_uintfloat_cvt_saved 1
1899 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1900 return $et_vect_uintfloat_cvt_saved
1904 # Return 1 if the target supports signed float->int conversion
1907 proc check_effective_target_vect_floatint_cvt { } {
1908 global et_vect_floatint_cvt_saved
1910 if [info exists et_vect_floatint_cvt_saved] {
1911 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1913 set et_vect_floatint_cvt_saved 0
1914 if { [istarget i?86-*-*]
1915 || ([istarget powerpc*-*-*]
1916 && ![istarget powerpc-*-linux*paired*])
1917 || [istarget x86_64-*-*]
1918 || ([istarget arm*-*-*]
1919 && [check_effective_target_arm_neon_ok])} {
1920 set et_vect_floatint_cvt_saved 1
1924 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1925 return $et_vect_floatint_cvt_saved
1928 # Return 1 if the target supports unsigned float->int conversion
1931 proc check_effective_target_vect_floatuint_cvt { } {
1932 global et_vect_floatuint_cvt_saved
1934 if [info exists et_vect_floatuint_cvt_saved] {
1935 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1937 set et_vect_floatuint_cvt_saved 0
1938 if { ([istarget powerpc*-*-*]
1939 && ![istarget powerpc-*-linux*paired*])
1940 || ([istarget arm*-*-*]
1941 && [check_effective_target_arm_neon_ok])} {
1942 set et_vect_floatuint_cvt_saved 1
1946 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1947 return $et_vect_floatuint_cvt_saved
1950 # Return 1 is this is an arm target using 32-bit instructions
1951 proc check_effective_target_arm32 { } {
1952 return [check_no_compiler_messages arm32 assembly {
1953 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1959 # Return 1 is this is an arm target not using Thumb
1960 proc check_effective_target_arm_nothumb { } {
1961 return [check_no_compiler_messages arm_nothumb assembly {
1962 #if (defined(__thumb__) || defined(__thumb2__))
1968 # Return 1 if this is a little-endian ARM target
1969 proc check_effective_target_arm_little_endian { } {
1970 return [check_no_compiler_messages arm_little_endian assembly {
1971 #if !defined(__arm__) || !defined(__ARMEL__)
1977 # Return 1 if this is an ARM target that only supports aligned vector accesses
1978 proc check_effective_target_arm_vect_no_misalign { } {
1979 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1980 #if !defined(__arm__) \
1981 || (defined(__ARMEL__) \
1982 && (!defined(__thumb__) || defined(__thumb2__)))
1989 # Return 1 if this is an ARM target supporting -mfpu=vfp
1990 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1993 proc check_effective_target_arm_vfp_ok { } {
1994 if { [check_effective_target_arm32] } {
1995 return [check_no_compiler_messages arm_vfp_ok object {
1997 } "-mfpu=vfp -mfloat-abi=softfp"]
2003 # Return 1 if this is an ARM target supporting -mfpu=vfp
2004 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2007 proc check_effective_target_arm_hard_vfp_ok { } {
2008 if { [check_effective_target_arm32] } {
2009 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2010 int main() { return 0;}
2011 } "-mfpu=vfp -mfloat-abi=hard"]
2017 # Return 1 if this is an ARM target that supports DSP multiply with
2018 # current multilib flags.
2020 proc check_effective_target_arm_dsp { } {
2021 return [check_no_compiler_messages arm_dsp assembly {
2022 #ifndef __ARM_FEATURE_DSP
2029 # Return 1 if this is an ARM target that supports unaligned word/halfword
2030 # load/store instructions.
2032 proc check_effective_target_arm_unaligned { } {
2033 return [check_no_compiler_messages arm_unaligned assembly {
2034 #ifndef __ARM_FEATURE_UNALIGNED
2035 #error no unaligned support
2041 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2042 # or -mfloat-abi=hard, but if one is already specified by the
2043 # multilib, use it. Similarly, if a -mfpu option already enables
2044 # NEON, do not add -mfpu=neon.
2046 proc add_options_for_arm_neon { flags } {
2047 if { ! [check_effective_target_arm_neon_ok] } {
2050 global et_arm_neon_flags
2051 return "$flags $et_arm_neon_flags"
2054 # Return 1 if this is an ARM target supporting -mfpu=neon
2055 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2056 # incompatible with these options. Also set et_arm_neon_flags to the
2057 # best options to add.
2059 proc check_effective_target_arm_neon_ok_nocache { } {
2060 global et_arm_neon_flags
2061 set et_arm_neon_flags ""
2062 if { [check_effective_target_arm32] } {
2063 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2064 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2065 #include "arm_neon.h"
2068 set et_arm_neon_flags $flags
2077 proc check_effective_target_arm_neon_ok { } {
2078 return [check_cached_effective_target arm_neon_ok \
2079 check_effective_target_arm_neon_ok_nocache]
2082 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2083 # or -mfloat-abi=hard, but if one is already specified by the
2086 proc add_options_for_arm_fp16 { flags } {
2087 if { ! [check_effective_target_arm_fp16_ok] } {
2090 global et_arm_fp16_flags
2091 return "$flags $et_arm_fp16_flags"
2094 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2095 # Skip multilibs that are incompatible with these options and set
2096 # et_arm_fp16_flags to the best options to add.
2098 proc check_effective_target_arm_fp16_ok_nocache { } {
2099 global et_arm_fp16_flags
2100 set et_arm_fp16_flags ""
2101 if { ! [check_effective_target_arm32] } {
2104 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2105 # Multilib flags would override -mfpu.
2108 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2109 # Must generate floating-point instructions.
2112 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2113 # The existing -mfpu value is OK; use it, but add softfp.
2114 set et_arm_fp16_flags "-mfloat-abi=softfp"
2117 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2118 # macro to check for this support.
2119 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2120 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2123 set et_arm_fp16_flags "$flags"
2130 proc check_effective_target_arm_fp16_ok { } {
2131 return [check_cached_effective_target arm_fp16_ok \
2132 check_effective_target_arm_fp16_ok_nocache]
2135 # Creates a series of routines that return 1 if the given architecture
2136 # can be selected and a routine to give the flags to select that architecture
2137 # Note: Extra flags may be added to disable options from newer compilers
2138 # (Thumb in particular - but others may be added in the future)
2139 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2140 # /* { dg-add-options arm_arch_v5 } */
2141 foreach { armfunc armflag armdef } { v5 "-march=armv5 -marm" __ARM_ARCH_5__
2142 v6 "-march=armv6" __ARM_ARCH_6__
2143 v6k "-march=armv6k" __ARM_ARCH_6K__
2144 v7a "-march=armv7-a" __ARM_ARCH_7A__ } {
2145 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2146 proc check_effective_target_arm_arch_FUNC_ok { } {
2147 if { [ string match "*-marm*" "FLAG" ] &&
2148 ![check_effective_target_arm_arm_ok] } {
2151 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2158 proc add_options_for_arm_arch_FUNC { flags } {
2159 return "$flags FLAG"
2164 # Return 1 if this is an ARM target where -marm causes ARM to be
2167 proc check_effective_target_arm_arm_ok { } {
2168 return [check_no_compiler_messages arm_arm_ok assembly {
2169 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2176 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2179 proc check_effective_target_arm_thumb1_ok { } {
2180 return [check_no_compiler_messages arm_thumb1_ok assembly {
2181 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2187 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2190 proc check_effective_target_arm_thumb2_ok { } {
2191 return [check_no_compiler_messages arm_thumb2_ok assembly {
2192 #if !defined(__thumb2__)
2198 # Return 1 if this is an ARM target where Thumb-1 is used without options
2199 # added by the test.
2201 proc check_effective_target_arm_thumb1 { } {
2202 return [check_no_compiler_messages arm_thumb1 assembly {
2203 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2210 # Return 1 if this is an ARM target where Thumb-2 is used without options
2211 # added by the test.
2213 proc check_effective_target_arm_thumb2 { } {
2214 return [check_no_compiler_messages arm_thumb2 assembly {
2215 #if !defined(__thumb2__)
2222 # Return 1 if this is an ARM cortex-M profile cpu
2224 proc check_effective_target_arm_cortex_m { } {
2225 return [check_no_compiler_messages arm_cortex_m assembly {
2226 #if !defined(__ARM_ARCH_7M__) \
2227 && !defined (__ARM_ARCH_7EM__) \
2228 && !defined (__ARM_ARCH_6M__)
2235 # Return 1 if the target supports executing NEON instructions, 0
2236 # otherwise. Cache the result.
2238 proc check_effective_target_arm_neon_hw { } {
2239 return [check_runtime arm_neon_hw_available {
2243 long long a = 0, b = 1;
2244 asm ("vorr %P0, %P1, %P2"
2246 : "0" (a), "w" (b));
2249 } [add_options_for_arm_neon ""]]
2252 # Return 1 if this is a ARM target with NEON enabled.
2254 proc check_effective_target_arm_neon { } {
2255 if { [check_effective_target_arm32] } {
2256 return [check_no_compiler_messages arm_neon object {
2257 #ifndef __ARM_NEON__
2268 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2269 # the Loongson vector modes.
2271 proc check_effective_target_mips_loongson { } {
2272 return [check_no_compiler_messages loongson assembly {
2273 #if !defined(__mips_loongson_vector_rev)
2279 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2282 proc check_effective_target_arm_eabi { } {
2283 return [check_no_compiler_messages arm_eabi object {
2284 #ifndef __ARM_EABI__
2292 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2293 # Some multilibs may be incompatible with this option.
2295 proc check_effective_target_arm_iwmmxt_ok { } {
2296 if { [check_effective_target_arm32] } {
2297 return [check_no_compiler_messages arm_iwmmxt_ok object {
2305 # Return 1 if this is a PowerPC target with floating-point registers.
2307 proc check_effective_target_powerpc_fprs { } {
2308 if { [istarget powerpc*-*-*]
2309 || [istarget rs6000-*-*] } {
2310 return [check_no_compiler_messages powerpc_fprs object {
2322 # Return 1 if this is a PowerPC target with hardware double-precision
2325 proc check_effective_target_powerpc_hard_double { } {
2326 if { [istarget powerpc*-*-*]
2327 || [istarget rs6000-*-*] } {
2328 return [check_no_compiler_messages powerpc_hard_double object {
2340 # Return 1 if this is a PowerPC target supporting -maltivec.
2342 proc check_effective_target_powerpc_altivec_ok { } {
2343 if { ([istarget powerpc*-*-*]
2344 && ![istarget powerpc-*-linux*paired*])
2345 || [istarget rs6000-*-*] } {
2346 # AltiVec is not supported on AIX before 5.3.
2347 if { [istarget powerpc*-*-aix4*]
2348 || [istarget powerpc*-*-aix5.1*]
2349 || [istarget powerpc*-*-aix5.2*] } {
2352 return [check_no_compiler_messages powerpc_altivec_ok object {
2360 # Return 1 if this is a PowerPC target supporting -mvsx
2362 proc check_effective_target_powerpc_vsx_ok { } {
2363 if { ([istarget powerpc*-*-*]
2364 && ![istarget powerpc-*-linux*paired*])
2365 || [istarget rs6000-*-*] } {
2366 # AltiVec is not supported on AIX before 5.3.
2367 if { [istarget powerpc*-*-aix4*]
2368 || [istarget powerpc*-*-aix5.1*]
2369 || [istarget powerpc*-*-aix5.2*] } {
2372 return [check_no_compiler_messages powerpc_vsx_ok object {
2375 asm volatile ("xxlor vs0,vs0,vs0");
2377 asm volatile ("xxlor 0,0,0");
2387 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2389 proc check_effective_target_powerpc_ppu_ok { } {
2390 if [check_effective_target_powerpc_altivec_ok] {
2391 return [check_no_compiler_messages cell_asm_available object {
2394 asm volatile ("lvlx v0,v0,v0");
2396 asm volatile ("lvlx 0,0,0");
2406 # Return 1 if this is a PowerPC target that supports SPU.
2408 proc check_effective_target_powerpc_spu { } {
2409 if { [istarget powerpc*-*-linux*] } {
2410 return [check_effective_target_powerpc_altivec_ok]
2416 # Return 1 if this is a PowerPC SPE target. The check includes options
2417 # specified by dg-options for this test, so don't cache the result.
2419 proc check_effective_target_powerpc_spe_nocache { } {
2420 if { [istarget powerpc*-*-*] } {
2421 return [check_no_compiler_messages_nocache powerpc_spe object {
2427 } [current_compiler_flags]]
2433 # Return 1 if this is a PowerPC target with SPE enabled.
2435 proc check_effective_target_powerpc_spe { } {
2436 if { [istarget powerpc*-*-*] } {
2437 return [check_no_compiler_messages powerpc_spe object {
2449 # Return 1 if this is a PowerPC target with Altivec enabled.
2451 proc check_effective_target_powerpc_altivec { } {
2452 if { [istarget powerpc*-*-*] } {
2453 return [check_no_compiler_messages powerpc_altivec object {
2465 # Return 1 if this is a PowerPC 405 target. The check includes options
2466 # specified by dg-options for this test, so don't cache the result.
2468 proc check_effective_target_powerpc_405_nocache { } {
2469 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2470 return [check_no_compiler_messages_nocache powerpc_405 object {
2476 } [current_compiler_flags]]
2482 # Return 1 if this is a SPU target with a toolchain that
2483 # supports automatic overlay generation.
2485 proc check_effective_target_spu_auto_overlay { } {
2486 if { [istarget spu*-*-elf*] } {
2487 return [check_no_compiler_messages spu_auto_overlay executable {
2489 } "-Wl,--auto-overlay" ]
2495 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2496 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2497 # test environment appears to run executables on such a simulator.
2499 proc check_effective_target_ultrasparc_hw { } {
2500 return [check_runtime ultrasparc_hw {
2501 int main() { return 0; }
2502 } "-mcpu=ultrasparc"]
2505 # Return 1 if the test environment supports executing UltraSPARC VIS2
2506 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
2508 proc check_effective_target_ultrasparc_vis2_hw { } {
2509 return [check_runtime ultrasparc_vis2_hw {
2510 int main() { __asm__(".word 0x81b00320"); return 0; }
2511 } "-mcpu=ultrasparc3"]
2514 # Return 1 if the test environment supports executing UltraSPARC VIS3
2515 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
2517 proc check_effective_target_ultrasparc_vis3_hw { } {
2518 return [check_runtime ultrasparc_vis3_hw {
2519 int main() { __asm__(".word 0x81b00220"); return 0; }
2523 # Return 1 if this is a Sparc target with VIS enabled.
2525 proc check_effective_target_sparc_vis { } {
2526 if { [istarget sparc*-*-*] } {
2527 return [check_no_compiler_messages sparc_vis object {
2539 # Return 1 if the target supports hardware vector shift operation.
2541 proc check_effective_target_vect_shift { } {
2542 global et_vect_shift_saved
2544 if [info exists et_vect_shift_saved] {
2545 verbose "check_effective_target_vect_shift: using cached result" 2
2547 set et_vect_shift_saved 0
2548 if { ([istarget powerpc*-*-*]
2549 && ![istarget powerpc-*-linux*paired*])
2550 || [istarget ia64-*-*]
2551 || [istarget i?86-*-*]
2552 || [istarget x86_64-*-*]
2553 || [check_effective_target_arm32]
2554 || ([istarget mips*-*-*]
2555 && [check_effective_target_mips_loongson]) } {
2556 set et_vect_shift_saved 1
2560 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2561 return $et_vect_shift_saved
2564 # Return 1 if the target supports hardware vector shift operation for char.
2566 proc check_effective_target_vect_shift_char { } {
2567 global et_vect_shift_char_saved
2569 if [info exists et_vect_shift_char_saved] {
2570 verbose "check_effective_target_vect_shift_char: using cached result" 2
2572 set et_vect_shift_char_saved 0
2573 if { ([istarget powerpc*-*-*]
2574 && ![istarget powerpc-*-linux*paired*])
2575 || [check_effective_target_arm32] } {
2576 set et_vect_shift_char_saved 1
2580 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2581 return $et_vect_shift_char_saved
2584 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2586 # This can change for different subtargets so do not cache the result.
2588 proc check_effective_target_vect_long { } {
2589 if { [istarget i?86-*-*]
2590 || (([istarget powerpc*-*-*]
2591 && ![istarget powerpc-*-linux*paired*])
2592 && [check_effective_target_ilp32])
2593 || [istarget x86_64-*-*]
2594 || [check_effective_target_arm32]
2595 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2601 verbose "check_effective_target_vect_long: returning $answer" 2
2605 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2607 # This won't change for different subtargets so cache the result.
2609 proc check_effective_target_vect_float { } {
2610 global et_vect_float_saved
2612 if [info exists et_vect_float_saved] {
2613 verbose "check_effective_target_vect_float: using cached result" 2
2615 set et_vect_float_saved 0
2616 if { [istarget i?86-*-*]
2617 || [istarget powerpc*-*-*]
2618 || [istarget spu-*-*]
2619 || [istarget mipsisa64*-*-*]
2620 || [istarget x86_64-*-*]
2621 || [istarget ia64-*-*]
2622 || [check_effective_target_arm32] } {
2623 set et_vect_float_saved 1
2627 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2628 return $et_vect_float_saved
2631 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2633 # This won't change for different subtargets so cache the result.
2635 proc check_effective_target_vect_double { } {
2636 global et_vect_double_saved
2638 if [info exists et_vect_double_saved] {
2639 verbose "check_effective_target_vect_double: using cached result" 2
2641 set et_vect_double_saved 0
2642 if { [istarget i?86-*-*]
2643 || [istarget x86_64-*-*] } {
2644 if { [check_no_compiler_messages vect_double assembly {
2645 #ifdef __tune_atom__
2646 # error No double vectorizer support.
2649 set et_vect_double_saved 1
2651 set et_vect_double_saved 0
2653 } elseif { [istarget spu-*-*] } {
2654 set et_vect_double_saved 1
2658 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2659 return $et_vect_double_saved
2662 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2664 # This won't change for different subtargets so cache the result.
2666 proc check_effective_target_vect_long_long { } {
2667 global et_vect_long_long_saved
2669 if [info exists et_vect_long_long_saved] {
2670 verbose "check_effective_target_vect_long_long: using cached result" 2
2672 set et_vect_long_long_saved 0
2673 if { [istarget i?86-*-*]
2674 || [istarget x86_64-*-*] } {
2675 set et_vect_long_long_saved 1
2679 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2680 return $et_vect_long_long_saved
2684 # Return 1 if the target plus current options does not support a vector
2685 # max instruction on "int", 0 otherwise.
2687 # This won't change for different subtargets so cache the result.
2689 proc check_effective_target_vect_no_int_max { } {
2690 global et_vect_no_int_max_saved
2692 if [info exists et_vect_no_int_max_saved] {
2693 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2695 set et_vect_no_int_max_saved 0
2696 if { [istarget sparc*-*-*]
2697 || [istarget spu-*-*]
2698 || [istarget alpha*-*-*]
2699 || ([istarget mips*-*-*]
2700 && [check_effective_target_mips_loongson]) } {
2701 set et_vect_no_int_max_saved 1
2704 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2705 return $et_vect_no_int_max_saved
2708 # Return 1 if the target plus current options does not support a vector
2709 # add instruction on "int", 0 otherwise.
2711 # This won't change for different subtargets so cache the result.
2713 proc check_effective_target_vect_no_int_add { } {
2714 global et_vect_no_int_add_saved
2716 if [info exists et_vect_no_int_add_saved] {
2717 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2719 set et_vect_no_int_add_saved 0
2720 # Alpha only supports vector add on V8QI and V4HI.
2721 if { [istarget alpha*-*-*] } {
2722 set et_vect_no_int_add_saved 1
2725 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2726 return $et_vect_no_int_add_saved
2729 # Return 1 if the target plus current options does not support vector
2730 # bitwise instructions, 0 otherwise.
2732 # This won't change for different subtargets so cache the result.
2734 proc check_effective_target_vect_no_bitwise { } {
2735 global et_vect_no_bitwise_saved
2737 if [info exists et_vect_no_bitwise_saved] {
2738 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2740 set et_vect_no_bitwise_saved 0
2742 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2743 return $et_vect_no_bitwise_saved
2746 # Return 1 if the target plus current options supports vector permutation,
2749 # This won't change for different subtargets so cache the result.
2751 proc check_effective_target_vect_perm { } {
2754 if [info exists et_vect_perm_saved] {
2755 verbose "check_effective_target_vect_perm: using cached result" 2
2757 set et_vect_perm_saved 0
2758 if { [is-effective-target arm_neon_ok]
2759 || [istarget powerpc*-*-*]
2760 || [istarget spu-*-*]
2761 || [istarget i?86-*-*]
2762 || [istarget x86_64-*-*] } {
2763 set et_vect_perm_saved 1
2766 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2767 return $et_vect_perm_saved
2770 # Return 1 if the target plus current options supports vector permutation
2771 # on byte-sized elements, 0 otherwise.
2773 # This won't change for different subtargets so cache the result.
2775 proc check_effective_target_vect_perm_byte { } {
2776 global et_vect_perm_byte
2778 if [info exists et_vect_perm_byte_saved] {
2779 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2781 set et_vect_perm_byte_saved 0
2782 if { [is-effective-target arm_neon_ok]
2783 || [istarget powerpc*-*-*]
2784 || [istarget spu-*-*] } {
2785 set et_vect_perm_byte_saved 1
2788 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2789 return $et_vect_perm_byte_saved
2792 # Return 1 if the target plus current options supports vector permutation
2793 # on short-sized elements, 0 otherwise.
2795 # This won't change for different subtargets so cache the result.
2797 proc check_effective_target_vect_perm_short { } {
2798 global et_vect_perm_short
2800 if [info exists et_vect_perm_short_saved] {
2801 verbose "check_effective_target_vect_perm_short: using cached result" 2
2803 set et_vect_perm_short_saved 0
2804 if { [is-effective-target arm_neon_ok]
2805 || [istarget powerpc*-*-*]
2806 || [istarget spu-*-*] } {
2807 set et_vect_perm_short_saved 1
2810 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2811 return $et_vect_perm_short_saved
2814 # Return 1 if the target plus current options supports a vector
2815 # widening summation of *short* args into *int* result, 0 otherwise.
2817 # This won't change for different subtargets so cache the result.
2819 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2820 global et_vect_widen_sum_hi_to_si_pattern
2822 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2823 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2825 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2826 if { [istarget powerpc*-*-*]
2827 || [istarget ia64-*-*] } {
2828 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2831 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2832 return $et_vect_widen_sum_hi_to_si_pattern_saved
2835 # Return 1 if the target plus current options supports a vector
2836 # widening summation of *short* args into *int* result, 0 otherwise.
2837 # A target can also support this widening summation if it can support
2838 # promotion (unpacking) from shorts to ints.
2840 # This won't change for different subtargets so cache the result.
2842 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2843 global et_vect_widen_sum_hi_to_si
2845 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2846 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2848 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2849 if { [istarget powerpc*-*-*]
2850 || [istarget ia64-*-*] } {
2851 set et_vect_widen_sum_hi_to_si_saved 1
2854 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2855 return $et_vect_widen_sum_hi_to_si_saved
2858 # Return 1 if the target plus current options supports a vector
2859 # widening summation of *char* args into *short* result, 0 otherwise.
2860 # A target can also support this widening summation if it can support
2861 # promotion (unpacking) from chars to shorts.
2863 # This won't change for different subtargets so cache the result.
2865 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2866 global et_vect_widen_sum_qi_to_hi
2868 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2869 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2871 set et_vect_widen_sum_qi_to_hi_saved 0
2872 if { [check_effective_target_vect_unpack]
2873 || [istarget ia64-*-*] } {
2874 set et_vect_widen_sum_qi_to_hi_saved 1
2877 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2878 return $et_vect_widen_sum_qi_to_hi_saved
2881 # Return 1 if the target plus current options supports a vector
2882 # widening summation of *char* args into *int* result, 0 otherwise.
2884 # This won't change for different subtargets so cache the result.
2886 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2887 global et_vect_widen_sum_qi_to_si
2889 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2890 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2892 set et_vect_widen_sum_qi_to_si_saved 0
2893 if { [istarget powerpc*-*-*] } {
2894 set et_vect_widen_sum_qi_to_si_saved 1
2897 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2898 return $et_vect_widen_sum_qi_to_si_saved
2901 # Return 1 if the target plus current options supports a vector
2902 # widening multiplication of *char* args into *short* result, 0 otherwise.
2903 # A target can also support this widening multplication if it can support
2904 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2905 # multiplication of shorts).
2907 # This won't change for different subtargets so cache the result.
2910 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2911 global et_vect_widen_mult_qi_to_hi
2913 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2914 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2916 if { [check_effective_target_vect_unpack]
2917 && [check_effective_target_vect_short_mult] } {
2918 set et_vect_widen_mult_qi_to_hi_saved 1
2920 set et_vect_widen_mult_qi_to_hi_saved 0
2922 if { [istarget powerpc*-*-*]
2923 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2924 set et_vect_widen_mult_qi_to_hi_saved 1
2927 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2928 return $et_vect_widen_mult_qi_to_hi_saved
2931 # Return 1 if the target plus current options supports a vector
2932 # widening multiplication of *short* args into *int* result, 0 otherwise.
2933 # A target can also support this widening multplication if it can support
2934 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2935 # multiplication of ints).
2937 # This won't change for different subtargets so cache the result.
2940 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2941 global et_vect_widen_mult_hi_to_si
2943 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2944 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2946 if { [check_effective_target_vect_unpack]
2947 && [check_effective_target_vect_int_mult] } {
2948 set et_vect_widen_mult_hi_to_si_saved 1
2950 set et_vect_widen_mult_hi_to_si_saved 0
2952 if { [istarget powerpc*-*-*]
2953 || [istarget spu-*-*]
2954 || [istarget ia64-*-*]
2955 || [istarget i?86-*-*]
2956 || [istarget x86_64-*-*]
2957 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2958 set et_vect_widen_mult_hi_to_si_saved 1
2961 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2962 return $et_vect_widen_mult_hi_to_si_saved
2965 # Return 1 if the target plus current options supports a vector
2966 # widening multiplication of *char* args into *short* result, 0 otherwise.
2968 # This won't change for different subtargets so cache the result.
2970 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
2971 global et_vect_widen_mult_qi_to_hi_pattern
2973 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
2974 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
2976 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
2977 if { [istarget powerpc*-*-*]
2978 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2979 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
2982 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
2983 return $et_vect_widen_mult_qi_to_hi_pattern_saved
2986 # Return 1 if the target plus current options supports a vector
2987 # widening multiplication of *short* args into *int* result, 0 otherwise.
2989 # This won't change for different subtargets so cache the result.
2991 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
2992 global et_vect_widen_mult_hi_to_si_pattern
2994 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
2995 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
2997 set et_vect_widen_mult_hi_to_si_pattern_saved 0
2998 if { [istarget powerpc*-*-*]
2999 || [istarget spu-*-*]
3000 || [istarget ia64-*-*]
3001 || [istarget i?86-*-*]
3002 || [istarget x86_64-*-*]
3003 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3004 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3007 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3008 return $et_vect_widen_mult_hi_to_si_pattern_saved
3011 # Return 1 if the target plus current options supports a vector
3012 # widening shift, 0 otherwise.
3014 # This won't change for different subtargets so cache the result.
3016 proc check_effective_target_vect_widen_shift { } {
3017 global et_vect_widen_shift_saved
3019 if [info exists et_vect_shift_saved] {
3020 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3022 set et_vect_widen_shift_saved 0
3023 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3024 set et_vect_widen_shift_saved 1
3027 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3028 return $et_vect_widen_shift_saved
3031 # Return 1 if the target plus current options supports a vector
3032 # dot-product of signed chars, 0 otherwise.
3034 # This won't change for different subtargets so cache the result.
3036 proc check_effective_target_vect_sdot_qi { } {
3037 global et_vect_sdot_qi
3039 if [info exists et_vect_sdot_qi_saved] {
3040 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3042 set et_vect_sdot_qi_saved 0
3043 if { [istarget ia64-*-*] } {
3044 set et_vect_udot_qi_saved 1
3047 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3048 return $et_vect_sdot_qi_saved
3051 # Return 1 if the target plus current options supports a vector
3052 # dot-product of unsigned chars, 0 otherwise.
3054 # This won't change for different subtargets so cache the result.
3056 proc check_effective_target_vect_udot_qi { } {
3057 global et_vect_udot_qi
3059 if [info exists et_vect_udot_qi_saved] {
3060 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3062 set et_vect_udot_qi_saved 0
3063 if { [istarget powerpc*-*-*]
3064 || [istarget ia64-*-*] } {
3065 set et_vect_udot_qi_saved 1
3068 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3069 return $et_vect_udot_qi_saved
3072 # Return 1 if the target plus current options supports a vector
3073 # dot-product of signed shorts, 0 otherwise.
3075 # This won't change for different subtargets so cache the result.
3077 proc check_effective_target_vect_sdot_hi { } {
3078 global et_vect_sdot_hi
3080 if [info exists et_vect_sdot_hi_saved] {
3081 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3083 set et_vect_sdot_hi_saved 0
3084 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3085 || [istarget ia64-*-*]
3086 || [istarget i?86-*-*]
3087 || [istarget x86_64-*-*] } {
3088 set et_vect_sdot_hi_saved 1
3091 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3092 return $et_vect_sdot_hi_saved
3095 # Return 1 if the target plus current options supports a vector
3096 # dot-product of unsigned shorts, 0 otherwise.
3098 # This won't change for different subtargets so cache the result.
3100 proc check_effective_target_vect_udot_hi { } {
3101 global et_vect_udot_hi
3103 if [info exists et_vect_udot_hi_saved] {
3104 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3106 set et_vect_udot_hi_saved 0
3107 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3108 set et_vect_udot_hi_saved 1
3111 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3112 return $et_vect_udot_hi_saved
3116 # Return 1 if the target plus current options supports a vector
3117 # demotion (packing) of shorts (to chars) and ints (to shorts)
3118 # using modulo arithmetic, 0 otherwise.
3120 # This won't change for different subtargets so cache the result.
3122 proc check_effective_target_vect_pack_trunc { } {
3123 global et_vect_pack_trunc
3125 if [info exists et_vect_pack_trunc_saved] {
3126 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3128 set et_vect_pack_trunc_saved 0
3129 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3130 || [istarget i?86-*-*]
3131 || [istarget x86_64-*-*]
3132 || [istarget spu-*-*]
3133 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3134 && [check_effective_target_arm_little_endian]) } {
3135 set et_vect_pack_trunc_saved 1
3138 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3139 return $et_vect_pack_trunc_saved
3142 # Return 1 if the target plus current options supports a vector
3143 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3145 # This won't change for different subtargets so cache the result.
3147 proc check_effective_target_vect_unpack { } {
3148 global et_vect_unpack
3150 if [info exists et_vect_unpack_saved] {
3151 verbose "check_effective_target_vect_unpack: using cached result" 2
3153 set et_vect_unpack_saved 0
3154 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3155 || [istarget i?86-*-*]
3156 || [istarget x86_64-*-*]
3157 || [istarget spu-*-*]
3158 || [istarget ia64-*-*]
3159 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3160 && [check_effective_target_arm_little_endian]) } {
3161 set et_vect_unpack_saved 1
3164 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3165 return $et_vect_unpack_saved
3168 # Return 1 if the target plus current options does not guarantee
3169 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3171 # This won't change for different subtargets so cache the result.
3173 proc check_effective_target_unaligned_stack { } {
3174 global et_unaligned_stack_saved
3176 if [info exists et_unaligned_stack_saved] {
3177 verbose "check_effective_target_unaligned_stack: using cached result" 2
3179 set et_unaligned_stack_saved 0
3181 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3182 return $et_unaligned_stack_saved
3185 # Return 1 if the target plus current options does not support a vector
3186 # alignment mechanism, 0 otherwise.
3188 # This won't change for different subtargets so cache the result.
3190 proc check_effective_target_vect_no_align { } {
3191 global et_vect_no_align_saved
3193 if [info exists et_vect_no_align_saved] {
3194 verbose "check_effective_target_vect_no_align: using cached result" 2
3196 set et_vect_no_align_saved 0
3197 if { [istarget mipsisa64*-*-*]
3198 || [istarget sparc*-*-*]
3199 || [istarget ia64-*-*]
3200 || [check_effective_target_arm_vect_no_misalign]
3201 || ([istarget mips*-*-*]
3202 && [check_effective_target_mips_loongson]) } {
3203 set et_vect_no_align_saved 1
3206 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3207 return $et_vect_no_align_saved
3210 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3212 # This won't change for different subtargets so cache the result.
3214 proc check_effective_target_vect_hw_misalign { } {
3215 global et_vect_hw_misalign_saved
3217 if [info exists et_vect_hw_misalign_saved] {
3218 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3220 set et_vect_hw_misalign_saved 0
3221 if { ([istarget x86_64-*-*]
3222 || [istarget i?86-*-*]) } {
3223 set et_vect_hw_misalign_saved 1
3226 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3227 return $et_vect_hw_misalign_saved
3231 # Return 1 if arrays are aligned to the vector alignment
3232 # boundary, 0 otherwise.
3234 # This won't change for different subtargets so cache the result.
3236 proc check_effective_target_vect_aligned_arrays { } {
3237 global et_vect_aligned_arrays
3239 if [info exists et_vect_aligned_arrays_saved] {
3240 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3242 set et_vect_aligned_arrays_saved 0
3243 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3244 if { ([is-effective-target lp64]
3245 && ( ![check_avx_available]
3246 || [check_prefer_avx128])) } {
3247 set et_vect_aligned_arrays_saved 1
3250 if [istarget spu-*-*] {
3251 set et_vect_aligned_arrays_saved 1
3254 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3255 return $et_vect_aligned_arrays_saved
3258 # Return 1 if types of size 32 bit or less are naturally aligned
3259 # (aligned to their type-size), 0 otherwise.
3261 # This won't change for different subtargets so cache the result.
3263 proc check_effective_target_natural_alignment_32 { } {
3264 global et_natural_alignment_32
3266 if [info exists et_natural_alignment_32_saved] {
3267 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3269 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3270 set et_natural_alignment_32_saved 1
3271 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3272 set et_natural_alignment_32_saved 0
3275 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3276 return $et_natural_alignment_32_saved
3279 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3280 # type-size), 0 otherwise.
3282 # This won't change for different subtargets so cache the result.
3284 proc check_effective_target_natural_alignment_64 { } {
3285 global et_natural_alignment_64
3287 if [info exists et_natural_alignment_64_saved] {
3288 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3290 set et_natural_alignment_64_saved 0
3291 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3292 || [istarget spu-*-*] } {
3293 set et_natural_alignment_64_saved 1
3296 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3297 return $et_natural_alignment_64_saved
3300 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3302 # This won't change for different subtargets so cache the result.
3304 proc check_effective_target_vector_alignment_reachable { } {
3305 global et_vector_alignment_reachable
3307 if [info exists et_vector_alignment_reachable_saved] {
3308 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3310 if { [check_effective_target_vect_aligned_arrays]
3311 || [check_effective_target_natural_alignment_32] } {
3312 set et_vector_alignment_reachable_saved 1
3314 set et_vector_alignment_reachable_saved 0
3317 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3318 return $et_vector_alignment_reachable_saved
3321 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3323 # This won't change for different subtargets so cache the result.
3325 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3326 global et_vector_alignment_reachable_for_64bit
3328 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3329 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3331 if { [check_effective_target_vect_aligned_arrays]
3332 || [check_effective_target_natural_alignment_64] } {
3333 set et_vector_alignment_reachable_for_64bit_saved 1
3335 set et_vector_alignment_reachable_for_64bit_saved 0
3338 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3339 return $et_vector_alignment_reachable_for_64bit_saved
3342 # Return 1 if the target only requires element alignment for vector accesses
3344 proc check_effective_target_vect_element_align { } {
3345 global et_vect_element_align
3347 if [info exists et_vect_element_align] {
3348 verbose "check_effective_target_vect_element_align: using cached result" 2
3350 set et_vect_element_align 0
3351 if { ([istarget arm*-*-*]
3352 && ![check_effective_target_arm_vect_no_misalign])
3353 || [check_effective_target_vect_hw_misalign] } {
3354 set et_vect_element_align 1
3358 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3359 return $et_vect_element_align
3362 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3364 proc check_effective_target_vect_condition { } {
3365 global et_vect_cond_saved
3367 if [info exists et_vect_cond_saved] {
3368 verbose "check_effective_target_vect_cond: using cached result" 2
3370 set et_vect_cond_saved 0
3371 if { [istarget powerpc*-*-*]
3372 || [istarget ia64-*-*]
3373 || [istarget i?86-*-*]
3374 || [istarget spu-*-*]
3375 || [istarget x86_64-*-*] } {
3376 set et_vect_cond_saved 1
3380 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3381 return $et_vect_cond_saved
3384 # Return 1 if the target supports vector conditional operations where
3385 # the comparison has different type from the lhs, 0 otherwise.
3387 proc check_effective_target_vect_cond_mixed { } {
3388 global et_vect_cond_mixed_saved
3390 if [info exists et_vect_cond_mixed_saved] {
3391 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3393 set et_vect_cond_mixed_saved 0
3394 if { [istarget i?86-*-*]
3395 || [istarget x86_64-*-*]
3396 || [istarget powerpc*-*-*] } {
3397 set et_vect_cond_mixed_saved 1
3401 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3402 return $et_vect_cond_mixed_saved
3405 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3407 proc check_effective_target_vect_char_mult { } {
3408 global et_vect_char_mult_saved
3410 if [info exists et_vect_char_mult_saved] {
3411 verbose "check_effective_target_vect_char_mult: using cached result" 2
3413 set et_vect_char_mult_saved 0
3414 if { [istarget ia64-*-*]
3415 || [istarget i?86-*-*]
3416 || [istarget x86_64-*-*] } {
3417 set et_vect_char_mult_saved 1
3421 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3422 return $et_vect_char_mult_saved
3425 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3427 proc check_effective_target_vect_short_mult { } {
3428 global et_vect_short_mult_saved
3430 if [info exists et_vect_short_mult_saved] {
3431 verbose "check_effective_target_vect_short_mult: using cached result" 2
3433 set et_vect_short_mult_saved 0
3434 if { [istarget ia64-*-*]
3435 || [istarget spu-*-*]
3436 || [istarget i?86-*-*]
3437 || [istarget x86_64-*-*]
3438 || [istarget powerpc*-*-*]
3439 || [check_effective_target_arm32]
3440 || ([istarget mips*-*-*]
3441 && [check_effective_target_mips_loongson]) } {
3442 set et_vect_short_mult_saved 1
3446 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3447 return $et_vect_short_mult_saved
3450 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3452 proc check_effective_target_vect_int_mult { } {
3453 global et_vect_int_mult_saved
3455 if [info exists et_vect_int_mult_saved] {
3456 verbose "check_effective_target_vect_int_mult: using cached result" 2
3458 set et_vect_int_mult_saved 0
3459 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3460 || [istarget spu-*-*]
3461 || [istarget i?86-*-*]
3462 || [istarget x86_64-*-*]
3463 || [istarget ia64-*-*]
3464 || [check_effective_target_arm32] } {
3465 set et_vect_int_mult_saved 1
3469 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3470 return $et_vect_int_mult_saved
3473 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3475 proc check_effective_target_vect_extract_even_odd { } {
3476 global et_vect_extract_even_odd_saved
3478 if [info exists et_vect_extract_even_odd_saved] {
3479 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3481 set et_vect_extract_even_odd_saved 0
3482 if { [istarget powerpc*-*-*]
3483 || [istarget i?86-*-*]
3484 || [istarget x86_64-*-*]
3485 || [istarget ia64-*-*]
3486 || [istarget spu-*-*] } {
3487 set et_vect_extract_even_odd_saved 1
3491 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3492 return $et_vect_extract_even_odd_saved
3495 # Return 1 if the target supports vector interleaving, 0 otherwise.
3497 proc check_effective_target_vect_interleave { } {
3498 global et_vect_interleave_saved
3500 if [info exists et_vect_interleave_saved] {
3501 verbose "check_effective_target_vect_interleave: using cached result" 2
3503 set et_vect_interleave_saved 0
3504 if { [istarget powerpc*-*-*]
3505 || [istarget i?86-*-*]
3506 || [istarget x86_64-*-*]
3507 || [istarget ia64-*-*]
3508 || [istarget spu-*-*] } {
3509 set et_vect_interleave_saved 1
3513 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3514 return $et_vect_interleave_saved
3517 foreach N {2 3 4 8} {
3518 eval [string map [list N $N] {
3519 # Return 1 if the target supports 2-vector interleaving
3520 proc check_effective_target_vect_stridedN { } {
3521 global et_vect_stridedN_saved
3523 if [info exists et_vect_stridedN_saved] {
3524 verbose "check_effective_target_vect_stridedN: using cached result" 2
3526 set et_vect_stridedN_saved 0
3528 && [check_effective_target_vect_interleave]
3529 && [check_effective_target_vect_extract_even_odd] } {
3530 set et_vect_stridedN_saved 1
3532 if { [istarget arm*-*-*] && N >= 2 && N <= 4 } {
3533 set et_vect_stridedN_saved 1
3537 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3538 return $et_vect_stridedN_saved
3543 # Return 1 if the target supports multiple vector sizes
3545 proc check_effective_target_vect_multiple_sizes { } {
3546 global et_vect_multiple_sizes_saved
3548 set et_vect_multiple_sizes_saved 0
3549 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3550 set et_vect_multiple_sizes_saved 1
3552 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3553 if { ([check_avx_available] && ![check_prefer_avx128]) } {
3554 set et_vect_multiple_sizes_saved 1
3558 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
3559 return $et_vect_multiple_sizes_saved
3562 # Return 1 if the target supports vectors of 64 bits.
3564 proc check_effective_target_vect64 { } {
3565 global et_vect64_saved
3567 if [info exists et_vect64_saved] {
3568 verbose "check_effective_target_vect64: using cached result" 2
3570 set et_vect64_saved 0
3571 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3572 set et_vect64_saved 1
3576 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
3577 return $et_vect64_saved
3580 # Return 1 if the target supports vector copysignf calls.
3582 proc check_effective_target_vect_call_copysignf { } {
3583 global et_vect_call_copysignf_saved
3585 if [info exists et_vect_call_copysignf_saved] {
3586 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
3588 set et_vect_call_copysignf_saved 0
3589 if { [istarget i?86-*-*]
3590 || [istarget x86_64-*-*]
3591 || [istarget powerpc*-*-*] } {
3592 set et_vect_call_copysignf_saved 1
3596 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
3597 return $et_vect_call_copysignf_saved
3600 # Return 1 if the target supports vector sqrtf calls.
3602 proc check_effective_target_vect_call_sqrtf { } {
3603 global et_vect_call_sqrtf_saved
3605 if [info exists et_vect_call_sqrtf_saved] {
3606 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
3608 set et_vect_call_sqrtf_saved 0
3609 if { [istarget i?86-*-*]
3610 || [istarget x86_64-*-*]
3611 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
3612 set et_vect_call_sqrtf_saved 1
3616 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
3617 return $et_vect_call_sqrtf_saved
3620 # Return 1 if the target supports vector lrint calls.
3622 proc check_effective_target_vect_call_lrint { } {
3623 set et_vect_call_lrint 0
3624 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
3625 set et_vect_call_lrint 1
3628 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
3629 return $et_vect_call_lrint
3632 # Return 1 if the target supports section-anchors
3634 proc check_effective_target_section_anchors { } {
3635 global et_section_anchors_saved
3637 if [info exists et_section_anchors_saved] {
3638 verbose "check_effective_target_section_anchors: using cached result" 2
3640 set et_section_anchors_saved 0
3641 if { [istarget powerpc*-*-*]
3642 || [istarget arm*-*-*] } {
3643 set et_section_anchors_saved 1
3647 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3648 return $et_section_anchors_saved
3651 # Return 1 if the target supports atomic operations on "int_128" values.
3653 proc check_effective_target_sync_int_128 { } {
3654 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3655 && ![is-effective-target ia32] } {
3662 # Return 1 if the target supports atomic operations on "int_128" values
3663 # and can execute them.
3665 proc check_effective_target_sync_int_128_runtime { } {
3666 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3667 && ![is-effective-target ia32] } {
3668 return [check_cached_effective_target sync_int_128_available {
3669 check_runtime_nocache sync_int_128_available {
3673 unsigned int eax, ebx, ecx, edx;
3674 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3675 return !(ecx & bit_CMPXCHG16B);
3685 # Return 1 if the target supports atomic operations on "long long".
3687 # Note: 32bit x86 targets require -march=pentium in dg-options.
3689 proc check_effective_target_sync_long_long { } {
3690 if { [istarget x86_64-*-*]
3691 || [istarget i?86-*-*])
3692 || [istarget arm*-*-*]
3693 || [istarget alpha*-*-*] } {
3700 # Return 1 if the target supports atomic operations on "long long"
3701 # and can execute them.
3703 # Note: 32bit x86 targets require -march=pentium in dg-options.
3705 proc check_effective_target_sync_long_long_runtime { } {
3706 if { [istarget x86_64-*-*]
3707 || [istarget i?86-*-*] } {
3708 return [check_cached_effective_target sync_long_long_available {
3709 check_runtime_nocache sync_long_long_available {
3713 unsigned int eax, ebx, ecx, edx;
3714 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3715 return !(edx & bit_CMPXCHG8B);
3720 } elseif { [istarget arm*-*-linux-gnueabi] } {
3721 return [check_runtime sync_longlong_runtime {
3727 if (sizeof (long long) != 8)
3730 /* Just check for native; checking for kernel fallback is tricky. */
3731 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
3736 } elseif { [istarget alpha*-*-*] } {
3743 # Return 1 if the target supports atomic operations on "int" and "long".
3745 proc check_effective_target_sync_int_long { } {
3746 global et_sync_int_long_saved
3748 if [info exists et_sync_int_long_saved] {
3749 verbose "check_effective_target_sync_int_long: using cached result" 2
3751 set et_sync_int_long_saved 0
3752 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3753 # load-reserved/store-conditional instructions.
3754 if { [istarget ia64-*-*]
3755 || [istarget i?86-*-*]
3756 || [istarget x86_64-*-*]
3757 || [istarget alpha*-*-*]
3758 || [istarget arm*-*-linux-gnueabi]
3759 || [istarget bfin*-*linux*]
3760 || [istarget hppa*-*linux*]
3761 || [istarget s390*-*-*]
3762 || [istarget powerpc*-*-*]
3763 || [istarget sparc64-*-*]
3764 || [istarget sparcv9-*-*]
3765 || [istarget mips*-*-*] } {
3766 set et_sync_int_long_saved 1
3770 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3771 return $et_sync_int_long_saved
3774 # Return 1 if the target supports atomic operations on "char" and "short".
3776 proc check_effective_target_sync_char_short { } {
3777 global et_sync_char_short_saved
3779 if [info exists et_sync_char_short_saved] {
3780 verbose "check_effective_target_sync_char_short: using cached result" 2
3782 set et_sync_char_short_saved 0
3783 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3784 # load-reserved/store-conditional instructions.
3785 if { [istarget ia64-*-*]
3786 || [istarget i?86-*-*]
3787 || [istarget x86_64-*-*]
3788 || [istarget alpha*-*-*]
3789 || [istarget arm*-*-linux-gnueabi]
3790 || [istarget hppa*-*linux*]
3791 || [istarget s390*-*-*]
3792 || [istarget powerpc*-*-*]
3793 || [istarget sparc64-*-*]
3794 || [istarget sparcv9-*-*]
3795 || [istarget mips*-*-*] } {
3796 set et_sync_char_short_saved 1
3800 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3801 return $et_sync_char_short_saved
3804 # Return 1 if the target uses a ColdFire FPU.
3806 proc check_effective_target_coldfire_fpu { } {
3807 return [check_no_compiler_messages coldfire_fpu assembly {
3814 # Return true if this is a uClibc target.
3816 proc check_effective_target_uclibc {} {
3817 return [check_no_compiler_messages uclibc object {
3818 #include <features.h>
3819 #if !defined (__UCLIBC__)
3825 # Return true if this is a uclibc target and if the uclibc feature
3826 # described by __$feature__ is not present.
3828 proc check_missing_uclibc_feature {feature} {
3829 return [check_no_compiler_messages $feature object "
3830 #include <features.h>
3831 #if !defined (__UCLIBC) || defined (__${feature}__)
3837 # Return true if this is a Newlib target.
3839 proc check_effective_target_newlib {} {
3840 return [check_no_compiler_messages newlib object {
3846 # (a) an error of a few ULP is expected in string to floating-point
3847 # conversion functions; and
3848 # (b) overflow is not always detected correctly by those functions.
3850 proc check_effective_target_lax_strtofp {} {
3851 # By default, assume that all uClibc targets suffer from this.
3852 return [check_effective_target_uclibc]
3855 # Return 1 if this is a target for which wcsftime is a dummy
3856 # function that always returns 0.
3858 proc check_effective_target_dummy_wcsftime {} {
3859 # By default, assume that all uClibc targets suffer from this.
3860 return [check_effective_target_uclibc]
3863 # Return 1 if constructors with initialization priority arguments are
3864 # supposed on this target.
3866 proc check_effective_target_init_priority {} {
3867 return [check_no_compiler_messages init_priority assembly "
3868 void f() __attribute__((constructor (1000)));
3873 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3874 # This can be used with any check_* proc that takes no argument and
3875 # returns only 1 or 0. It could be used with check_* procs that take
3876 # arguments with keywords that pass particular arguments.
3878 proc is-effective-target { arg } {
3880 if { [info procs check_effective_target_${arg}] != [list] } {
3881 set selected [check_effective_target_${arg}]
3884 "vmx_hw" { set selected [check_vmx_hw_available] }
3885 "vsx_hw" { set selected [check_vsx_hw_available] }
3886 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3887 "named_sections" { set selected [check_named_sections_available] }
3888 "gc_sections" { set selected [check_gc_sections_available] }
3889 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3890 default { error "unknown effective target keyword `$arg'" }
3893 verbose "is-effective-target: $arg $selected" 2
3897 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3899 proc is-effective-target-keyword { arg } {
3900 if { [info procs check_effective_target_${arg}] != [list] } {
3903 # These have different names for their check_* procs.
3905 "vmx_hw" { return 1 }
3906 "vsx_hw" { return 1 }
3907 "ppc_recip_hw" { return 1 }
3908 "named_sections" { return 1 }
3909 "gc_sections" { return 1 }
3910 "cxa_atexit" { return 1 }
3911 default { return 0 }
3916 # Return 1 if target default to short enums
3918 proc check_effective_target_short_enums { } {
3919 return [check_no_compiler_messages short_enums assembly {
3921 int s[sizeof (enum foo) == 1 ? 1 : -1];
3925 # Return 1 if target supports merging string constants at link time.
3927 proc check_effective_target_string_merging { } {
3928 return [check_no_messages_and_pattern string_merging \
3929 "rodata\\.str" assembly {
3930 const char *var = "String";
3934 # Return 1 if target has the basic signed and unsigned types in
3935 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3936 # working <stdint.h> for all targets.
3938 proc check_effective_target_stdint_types { } {
3939 return [check_no_compiler_messages stdint_types assembly {
3941 int8_t a; int16_t b; int32_t c; int64_t d;
3942 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3946 # Return 1 if target has the basic signed and unsigned types in
3947 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3948 # these types agree with those in the header, as some systems have
3949 # only <inttypes.h>.
3951 proc check_effective_target_inttypes_types { } {
3952 return [check_no_compiler_messages inttypes_types assembly {
3953 #include <inttypes.h>
3954 int8_t a; int16_t b; int32_t c; int64_t d;
3955 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3959 # Return 1 if programs are intended to be run on a simulator
3960 # (i.e. slowly) rather than hardware (i.e. fast).
3962 proc check_effective_target_simulator { } {
3964 # All "src/sim" simulators set this one.
3965 if [board_info target exists is_simulator] {
3966 return [board_info target is_simulator]
3969 # The "sid" simulators don't set that one, but at least they set
3971 if [board_info target exists slow_simulator] {
3972 return [board_info target slow_simulator]
3978 # Return 1 if the target is a VxWorks kernel.
3980 proc check_effective_target_vxworks_kernel { } {
3981 return [check_no_compiler_messages vxworks_kernel assembly {
3982 #if !defined __vxworks || defined __RTP__
3988 # Return 1 if the target is a VxWorks RTP.
3990 proc check_effective_target_vxworks_rtp { } {
3991 return [check_no_compiler_messages vxworks_rtp assembly {
3992 #if !defined __vxworks || !defined __RTP__
3998 # Return 1 if the target is expected to provide wide character support.
4000 proc check_effective_target_wchar { } {
4001 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4004 return [check_no_compiler_messages wchar assembly {
4009 # Return 1 if the target has <pthread.h>.
4011 proc check_effective_target_pthread_h { } {
4012 return [check_no_compiler_messages pthread_h assembly {
4013 #include <pthread.h>
4017 # Return 1 if the target can truncate a file from a file-descriptor,
4018 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4019 # chsize. We test for a trivially functional truncation; no stubs.
4020 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4021 # different function to be used.
4023 proc check_effective_target_fd_truncate { } {
4025 #define _FILE_OFFSET_BITS 64
4031 FILE *f = fopen ("tst.tmp", "wb");
4033 const char t[] = "test writing more than ten characters";
4037 write (fd, t, sizeof (t) - 1);
4039 if (ftruncate (fd, 10) != 0)
4048 f = fopen ("tst.tmp", "rb");
4049 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4057 if { [check_runtime ftruncate $prog] } {
4061 regsub "ftruncate" $prog "chsize" prog
4062 return [check_runtime chsize $prog]
4065 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4067 proc add_options_for_c99_runtime { flags } {
4068 if { [istarget *-*-solaris2*] } {
4069 return "$flags -std=c99"
4071 if { [istarget mips-sgi-irix6.5*] } {
4072 return "$flags -std=c99"
4074 if { [istarget powerpc-*-darwin*] } {
4075 return "$flags -mmacosx-version-min=10.3"
4080 # Add to FLAGS all the target-specific flags needed to enable
4081 # full IEEE compliance mode.
4083 proc add_options_for_ieee { flags } {
4084 if { [istarget alpha*-*-*]
4085 || [istarget sh*-*-*] } {
4086 return "$flags -mieee"
4088 if { [istarget rx-*-*] } {
4089 return "$flags -mnofpu"
4094 # Add to FLAGS the flags needed to enable functions to bind locally
4095 # when using pic/PIC passes in the testsuite.
4097 proc add_options_for_bind_pic_locally { flags } {
4098 if {[check_no_compiler_messages using_pic2 assembly {
4103 return "$flags -fPIE"
4105 if {[check_no_compiler_messages using_pic1 assembly {
4110 return "$flags -fpie"
4116 # Add to FLAGS the flags needed to enable 64-bit vectors.
4118 proc add_options_for_double_vectors { flags } {
4119 if [is-effective-target arm_neon_ok] {
4120 return "$flags -mvectorize-with-neon-double"
4126 # Return 1 if the target provides a full C99 runtime.
4128 proc check_effective_target_c99_runtime { } {
4129 return [check_cached_effective_target c99_runtime {
4132 set file [open "$srcdir/gcc.dg/builtins-config.h"]
4133 set contents [read $file]
4136 #ifndef HAVE_C99_RUNTIME
4140 check_no_compiler_messages_nocache c99_runtime assembly \
4141 $contents [add_options_for_c99_runtime ""]
4145 # Return 1 if target wchar_t is at least 4 bytes.
4147 proc check_effective_target_4byte_wchar_t { } {
4148 return [check_no_compiler_messages 4byte_wchar_t object {
4149 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
4153 # Return 1 if the target supports automatic stack alignment.
4155 proc check_effective_target_automatic_stack_alignment { } {
4156 # Ordinarily x86 supports automatic stack alignment ...
4157 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
4158 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
4159 # ... except Win64 SEH doesn't. Succeed for Win32 though.
4160 return [check_effective_target_ilp32];
4167 # Return true if we are compiling for AVX target.
4169 proc check_avx_available { } {
4170 if { [check_no_compiler_messages avx_available assembly {
4180 # Return true if 32- and 16-bytes vectors are available.
4182 proc check_effective_target_vect_sizes_32B_16B { } {
4183 return [check_avx_available];
4186 # Return true if 128-bits vectors are preferred even if 256-bits vectors
4189 proc check_prefer_avx128 { } {
4190 if ![check_avx_available] {
4193 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
4194 float a[1024],b[1024],c[1024];
4195 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
4196 } "-O2 -ftree-vectorize"]
4200 # Return 1 if avx instructions can be compiled.
4202 proc check_effective_target_avx { } {
4203 return [check_no_compiler_messages avx object {
4204 void _mm256_zeroall (void)
4206 __builtin_ia32_vzeroall ();
4211 # Return 1 if sse instructions can be compiled.
4212 proc check_effective_target_sse { } {
4213 return [check_no_compiler_messages sse object {
4216 __builtin_ia32_stmxcsr ();
4222 # Return 1 if sse2 instructions can be compiled.
4223 proc check_effective_target_sse2 { } {
4224 return [check_no_compiler_messages sse2 object {
4225 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
4227 __m128i _mm_srli_si128 (__m128i __A, int __N)
4229 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
4234 # Return 1 if F16C instructions can be compiled.
4236 proc check_effective_target_f16c { } {
4237 return [check_no_compiler_messages f16c object {
4238 #include "immintrin.h"
4240 foo (unsigned short val)
4242 return _cvtsh_ss (val);
4247 # Return 1 if C wchar_t type is compatible with char16_t.
4249 proc check_effective_target_wchar_t_char16_t_compatible { } {
4250 return [check_no_compiler_messages wchar_t_char16_t object {
4252 __CHAR16_TYPE__ *p16 = &wc;
4253 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4257 # Return 1 if C wchar_t type is compatible with char32_t.
4259 proc check_effective_target_wchar_t_char32_t_compatible { } {
4260 return [check_no_compiler_messages wchar_t_char32_t object {
4262 __CHAR32_TYPE__ *p32 = &wc;
4263 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4267 # Return 1 if pow10 function exists.
4269 proc check_effective_target_pow10 { } {
4270 return [check_runtime pow10 {
4280 # Return 1 if current options generate DFP instructions, 0 otherwise.
4282 proc check_effective_target_hard_dfp {} {
4283 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
4284 typedef float d64 __attribute__((mode(DD)));
4286 void foo (void) { z = x + y; }
4290 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
4291 # for strchr etc. functions.
4293 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
4294 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
4297 #if !defined(__cplusplus) \
4298 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
4299 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
4300 ISO C++ correct string.h and wchar.h protos not supported.
4307 # Return 1 if GNU as is used.
4309 proc check_effective_target_gas { } {
4310 global use_gas_saved
4313 if {![info exists use_gas_saved]} {
4314 # Check if the as used by gcc is GNU as.
4315 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
4316 # Provide /dev/null as input, otherwise gas times out reading from
4318 set status [remote_exec host "$gcc_as" "-v /dev/null"]
4319 set as_output [lindex $status 1]
4320 if { [ string first "GNU" $as_output ] >= 0 } {
4326 return $use_gas_saved
4329 # Return 1 if GNU ld is used.
4331 proc check_effective_target_gld { } {
4332 global use_gld_saved
4335 if {![info exists use_gld_saved]} {
4336 # Check if the ld used by gcc is GNU ld.
4337 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
4338 set status [remote_exec host "$gcc_ld" "--version"]
4339 set ld_output [lindex $status 1]
4340 if { [ string first "GNU" $ld_output ] >= 0 } {
4346 return $use_gld_saved
4349 # Return 1 if the compiler has been configure with link-time optimization
4352 proc check_effective_target_lto { } {
4354 return [info exists ENABLE_LTO]
4357 # Return 1 if this target supports the -fsplit-stack option, 0
4360 proc check_effective_target_split_stack {} {
4361 return [check_no_compiler_messages split_stack object {
4366 # Return 1 if the language for the compiler under test is C.
4368 proc check_effective_target_c { } {
4370 if [string match $tool "gcc"] {
4376 # Return 1 if the language for the compiler under test is C++.
4378 proc check_effective_target_c++ { } {
4380 if [string match $tool "g++"] {
4386 # Check which language standard is active by checking for the presence of
4387 # one of the C++11 -std flags. This assumes that the default for the
4388 # compiler is C++98, and that there will never be multiple -std= arguments
4389 # on the command line.
4390 proc check_effective_target_c++11 { } {
4391 if ![check_effective_target_c++] {
4394 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4397 proc check_effective_target_c++98 { } {
4398 if ![check_effective_target_c++] {
4401 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4404 # Return 1 if expensive testcases should be run.
4406 proc check_effective_target_run_expensive_tests { } {
4407 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
4413 # Returns 1 if "mempcpy" is available on the target system.
4415 proc check_effective_target_mempcpy {} {
4416 return [check_function_available "mempcpy"]
4419 # Check whether the vectorizer tests are supported by the target and
4420 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
4421 # Set dg-do-what-default to either compile or run, depending on target
4422 # capabilities. Return 1 if vectorizer tests are supported by
4423 # target, 0 otherwise.
4425 proc check_vect_support_and_set_flags { } {
4426 global DEFAULT_VECTCFLAGS
4427 global dg-do-what-default
4429 if [istarget powerpc-*paired*] {
4430 lappend DEFAULT_VECTCFLAGS "-mpaired"
4431 if [check_750cl_hw_available] {
4432 set dg-do-what-default run
4434 set dg-do-what-default compile
4436 } elseif [istarget powerpc*-*-*] {
4437 # Skip targets not supporting -maltivec.
4438 if ![is-effective-target powerpc_altivec_ok] {
4442 lappend DEFAULT_VECTCFLAGS "-maltivec"
4443 if [check_vsx_hw_available] {
4444 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
4447 if [check_vmx_hw_available] {
4448 set dg-do-what-default run
4450 if [is-effective-target ilp32] {
4451 # Specify a cpu that supports VMX for compile-only tests.
4452 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
4454 set dg-do-what-default compile
4456 } elseif { [istarget spu-*-*] } {
4457 set dg-do-what-default run
4458 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4459 lappend DEFAULT_VECTCFLAGS "-msse2"
4460 if { [check_effective_target_sse2_runtime] } {
4461 set dg-do-what-default run
4463 set dg-do-what-default compile
4465 } elseif { [istarget mips*-*-*]
4466 && ([check_effective_target_mpaired_single]
4467 || [check_effective_target_mips_loongson])
4468 && [check_effective_target_nomips16] } {
4469 if { [check_effective_target_mpaired_single] } {
4470 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
4472 set dg-do-what-default run
4473 } elseif [istarget sparc*-*-*] {
4474 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
4475 if [check_effective_target_ultrasparc_hw] {
4476 set dg-do-what-default run
4478 set dg-do-what-default compile
4480 } elseif [istarget alpha*-*-*] {
4481 # Alpha's vectorization capabilities are extremely limited.
4482 # It's more effort than its worth disabling all of the tests
4483 # that it cannot pass. But if you actually want to see what
4484 # does work, command out the return.
4487 lappend DEFAULT_VECTCFLAGS "-mmax"
4488 if [check_alpha_max_hw_available] {
4489 set dg-do-what-default run
4491 set dg-do-what-default compile
4493 } elseif [istarget ia64-*-*] {
4494 set dg-do-what-default run
4495 } elseif [is-effective-target arm_neon_ok] {
4496 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
4497 # NEON does not support denormals, so is not used for vectorization by
4498 # default to avoid loss of precision. We must pass -ffast-math to test
4499 # vectorization of float operations.
4500 lappend DEFAULT_VECTCFLAGS "-ffast-math"
4501 if [is-effective-target arm_neon_hw] {
4502 set dg-do-what-default run
4504 set dg-do-what-default compile
4513 proc check_effective_target_non_strict_align {} {
4514 return [check_no_compiler_messages non_strict_align assembly {
4516 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
4518 void foo(void) { z = (c *) y; }
4522 # Return 1 if the target has <ucontext.h>.
4524 proc check_effective_target_ucontext_h { } {
4525 return [check_no_compiler_messages ucontext_h assembly {
4526 #include <ucontext.h>