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 true if the target is a MIPS target that has access
894 # to the LL and SC instructions.
896 proc check_effective_target_mips_llsc { } {
897 if { ![istarget mips*-*-*] } {
900 # Assume that these instructions are always implemented for
901 # non-elf* targets, via emulation if necessary.
902 if { ![istarget *-*-elf*] } {
905 # Otherwise assume LL/SC support for everything but MIPS I.
906 return [check_no_compiler_messages mips_llsc assembly {
913 # Return true if the target is a MIPS target that uses in-place relocations.
915 proc check_effective_target_mips_rel { } {
916 if { ![istarget mips*-*-*] } {
919 return [check_no_compiler_messages mips_rel object {
920 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
921 || (defined _ABI64 && _MIPS_SIM == _ABI64)
927 # Return 1 if the current multilib does not generate PIC by default.
929 proc check_effective_target_nonpic { } {
930 return [check_no_compiler_messages nonpic assembly {
937 # Return 1 if the target does not use a status wrapper.
939 proc check_effective_target_unwrapped { } {
940 if { [target_info needs_status_wrapper] != "" \
941 && [target_info needs_status_wrapper] != "0" } {
947 # Return true if iconv is supported on the target. In particular IBM1047.
949 proc check_iconv_available { test_what } {
952 # If the tool configuration file has not set libiconv, try "-liconv"
953 if { ![info exists libiconv] } {
954 set libiconv "-liconv"
956 set test_what [lindex $test_what 1]
957 return [check_runtime_nocache $test_what [subst {
963 cd = iconv_open ("$test_what", "UTF-8");
964 if (cd == (iconv_t) -1)
971 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
973 proc check_ascii_locale_available { } {
974 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
975 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
982 # Return true if named sections are supported on this target.
984 proc check_named_sections_available { } {
985 return [check_no_compiler_messages named_sections assembly {
986 int __attribute__ ((section("whatever"))) foo;
990 # Return 1 if the target supports Fortran real kinds larger than real(8),
993 # When the target name changes, replace the cached result.
995 proc check_effective_target_fortran_large_real { } {
996 return [check_no_compiler_messages fortran_large_real executable {
998 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1005 # Return 1 if the target supports Fortran real kind real(16),
1006 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1007 # this checks for Real(16) only; the other returned real(10) if
1008 # both real(10) and real(16) are available.
1010 # When the target name changes, replace the cached result.
1012 proc check_effective_target_fortran_real_16 { } {
1013 return [check_no_compiler_messages fortran_real_16 executable {
1022 # Return 1 if the target supports SQRT for the largest floating-point
1023 # type. (Some targets lack the libm support for this FP type.)
1024 # On most targets, this check effectively checks either whether sqrtl is
1025 # available or on __float128 systems whether libquadmath is installed,
1026 # which provides sqrtq.
1028 # When the target name changes, replace the cached result.
1030 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1031 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1033 use iso_fortran_env, only: real_kinds
1034 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1035 real(kind=maxFP), volatile :: x
1043 # Return 1 if the target supports Fortran integer kinds larger than
1044 # integer(8), 0 otherwise.
1046 # When the target name changes, replace the cached result.
1048 proc check_effective_target_fortran_large_int { } {
1049 return [check_no_compiler_messages fortran_large_int executable {
1051 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1052 integer(kind=k) :: i
1057 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1059 # When the target name changes, replace the cached result.
1061 proc check_effective_target_fortran_integer_16 { } {
1062 return [check_no_compiler_messages fortran_integer_16 executable {
1069 # Return 1 if we can statically link libgfortran, 0 otherwise.
1071 # When the target name changes, replace the cached result.
1073 proc check_effective_target_static_libgfortran { } {
1074 return [check_no_compiler_messages static_libgfortran executable {
1081 proc check_linker_plugin_available { } {
1082 return [check_no_compiler_messages_nocache linker_plugin executable {
1083 int main() { return 0; }
1084 } "-flto -fuse-linker-plugin"]
1087 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1088 # otherwise. Cache the result.
1090 proc check_750cl_hw_available { } {
1091 return [check_cached_effective_target 750cl_hw_available {
1092 # If this is not the right target then we can skip the test.
1093 if { ![istarget powerpc-*paired*] } {
1096 check_runtime_nocache 750cl_hw_available {
1100 asm volatile ("ps_mul v0,v0,v0");
1102 asm volatile ("ps_mul 0,0,0");
1111 # Return 1 if the target OS supports running SSE executables, 0
1112 # otherwise. Cache the result.
1114 proc check_sse_os_support_available { } {
1115 return [check_cached_effective_target sse_os_support_available {
1116 # If this is not the right target then we can skip the test.
1117 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1119 } elseif { [istarget i?86-*-solaris2*] } {
1120 # The Solaris 2 kernel doesn't save and restore SSE registers
1121 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1122 check_runtime_nocache sse_os_support_available {
1125 asm volatile ("movaps %xmm0,%xmm0");
1135 # Return 1 if the target OS supports running AVX executables, 0
1136 # otherwise. Cache the result.
1138 proc check_avx_os_support_available { } {
1139 return [check_cached_effective_target avx_os_support_available {
1140 # If this is not the right target then we can skip the test.
1141 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1144 # Check that OS has AVX and SSE saving enabled.
1145 check_runtime_nocache avx_os_support_available {
1148 unsigned int eax, edx;
1150 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1151 return (eax & 6) != 6;
1158 # Return 1 if the target supports executing SSE instructions, 0
1159 # otherwise. Cache the result.
1161 proc check_sse_hw_available { } {
1162 return [check_cached_effective_target sse_hw_available {
1163 # If this is not the right target then we can skip the test.
1164 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1167 check_runtime_nocache sse_hw_available {
1171 unsigned int eax, ebx, ecx, edx;
1172 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1173 return !(edx & bit_SSE);
1181 # Return 1 if the target supports executing SSE2 instructions, 0
1182 # otherwise. Cache the result.
1184 proc check_sse2_hw_available { } {
1185 return [check_cached_effective_target sse2_hw_available {
1186 # If this is not the right target then we can skip the test.
1187 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1190 check_runtime_nocache sse2_hw_available {
1194 unsigned int eax, ebx, ecx, edx;
1195 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1196 return !(edx & bit_SSE2);
1204 # Return 1 if the target supports executing AVX instructions, 0
1205 # otherwise. Cache the result.
1207 proc check_avx_hw_available { } {
1208 return [check_cached_effective_target avx_hw_available {
1209 # If this is not the right target then we can skip the test.
1210 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1213 check_runtime_nocache avx_hw_available {
1217 unsigned int eax, ebx, ecx, edx;
1218 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1219 return ((ecx & (bit_AVX | bit_OSXSAVE))
1220 != (bit_AVX | bit_OSXSAVE));
1228 # Return 1 if the target supports running SSE executables, 0 otherwise.
1230 proc check_effective_target_sse_runtime { } {
1231 if { [check_effective_target_sse]
1232 && [check_sse_hw_available]
1233 && [check_sse_os_support_available] } {
1239 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1241 proc check_effective_target_sse2_runtime { } {
1242 if { [check_effective_target_sse2]
1243 && [check_sse2_hw_available]
1244 && [check_sse_os_support_available] } {
1250 # Return 1 if the target supports running AVX executables, 0 otherwise.
1252 proc check_effective_target_avx_runtime { } {
1253 if { [check_effective_target_avx]
1254 && [check_avx_hw_available]
1255 && [check_avx_os_support_available] } {
1261 # Return 1 if the target supports executing VSX instructions, 0
1262 # otherwise. Cache the result.
1264 proc check_vsx_hw_available { } {
1265 return [check_cached_effective_target vsx_hw_available {
1266 # Some simulators are known to not support VSX instructions.
1267 # For now, disable on Darwin
1268 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1272 check_runtime_nocache vsx_hw_available {
1276 asm volatile ("xxlor vs0,vs0,vs0");
1278 asm volatile ("xxlor 0,0,0");
1287 # Return 1 if the target supports executing AltiVec instructions, 0
1288 # otherwise. Cache the result.
1290 proc check_vmx_hw_available { } {
1291 return [check_cached_effective_target vmx_hw_available {
1292 # Some simulators are known to not support VMX instructions.
1293 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1296 # Most targets don't require special flags for this test case, but
1297 # Darwin does. Just to be sure, make sure VSX is not enabled for
1298 # the altivec tests.
1299 if { [istarget *-*-darwin*]
1300 || [istarget *-*-aix*] } {
1301 set options "-maltivec -mno-vsx"
1303 set options "-mno-vsx"
1305 check_runtime_nocache vmx_hw_available {
1309 asm volatile ("vor v0,v0,v0");
1311 asm volatile ("vor 0,0,0");
1320 proc check_ppc_recip_hw_available { } {
1321 return [check_cached_effective_target ppc_recip_hw_available {
1322 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1323 # For now, disable on Darwin
1324 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1327 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1328 check_runtime_nocache ppc_recip_hw_available {
1329 volatile double d_recip, d_rsqrt, d_four = 4.0;
1330 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1333 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1334 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1335 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1336 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1344 # Return 1 if the target supports executing AltiVec and Cell PPU
1345 # instructions, 0 otherwise. Cache the result.
1347 proc check_effective_target_cell_hw { } {
1348 return [check_cached_effective_target cell_hw_available {
1349 # Some simulators are known to not support VMX and PPU instructions.
1350 if { [istarget powerpc-*-eabi*] } {
1353 # Most targets don't require special flags for this test
1354 # case, but Darwin and AIX do.
1355 if { [istarget *-*-darwin*]
1356 || [istarget *-*-aix*] } {
1357 set options "-maltivec -mcpu=cell"
1359 set options "-mcpu=cell"
1361 check_runtime_nocache cell_hw_available {
1365 asm volatile ("vor v0,v0,v0");
1366 asm volatile ("lvlx v0,r0,r0");
1368 asm volatile ("vor 0,0,0");
1369 asm volatile ("lvlx 0,0,0");
1378 # Return 1 if the target supports executing 64-bit instructions, 0
1379 # otherwise. Cache the result.
1381 proc check_effective_target_powerpc64 { } {
1382 global powerpc64_available_saved
1385 if [info exists powerpc64_available_saved] {
1386 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1388 set powerpc64_available_saved 0
1390 # Some simulators are known to not support powerpc64 instructions.
1391 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1392 verbose "check_effective_target_powerpc64 returning 0" 2
1393 return $powerpc64_available_saved
1396 # Set up, compile, and execute a test program containing a 64-bit
1397 # instruction. Include the current process ID in the file
1398 # names to prevent conflicts with invocations for multiple
1403 set f [open $src "w"]
1404 puts $f "int main() {"
1405 puts $f "#ifdef __MACH__"
1406 puts $f " asm volatile (\"extsw r0,r0\");"
1408 puts $f " asm volatile (\"extsw 0,0\");"
1410 puts $f " return 0; }"
1413 set opts "additional_flags=-mcpu=G5"
1415 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1416 set lines [${tool}_target_compile $src $exe executable "$opts"]
1419 if [string match "" $lines] then {
1420 # No error message, compilation succeeded.
1421 set result [${tool}_load "./$exe" "" ""]
1422 set status [lindex $result 0]
1423 remote_file build delete $exe
1424 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1426 if { $status == "pass" } then {
1427 set powerpc64_available_saved 1
1430 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1434 return $powerpc64_available_saved
1437 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1438 # complex float arguments. This affects gfortran tests that call cabsf
1439 # in libm built by an earlier compiler. Return 1 if libm uses the same
1440 # argument passing as the compiler under test, 0 otherwise.
1442 # When the target name changes, replace the cached result.
1444 proc check_effective_target_broken_cplxf_arg { } {
1445 return [check_cached_effective_target broken_cplxf_arg {
1446 # Skip the work for targets known not to be affected.
1447 if { ![istarget powerpc64-*-linux*] } {
1449 } elseif { ![is-effective-target lp64] } {
1452 check_runtime_nocache broken_cplxf_arg {
1453 #include <complex.h>
1454 extern void abort (void);
1455 float fabsf (float);
1456 float cabsf (_Complex float);
1463 if (fabsf (f - 5.0) > 0.0001)
1472 # Return 1 is this is a TI C6X target supporting C67X instructions
1473 proc check_effective_target_ti_c67x { } {
1474 return [check_no_compiler_messages ti_c67x assembly {
1475 #if !defined(_TMS320C6700)
1481 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1482 proc check_effective_target_ti_c64xp { } {
1483 return [check_no_compiler_messages ti_c64xp assembly {
1484 #if !defined(_TMS320C6400_PLUS)
1491 proc check_alpha_max_hw_available { } {
1492 return [check_runtime alpha_max_hw_available {
1493 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1497 # Returns true iff the FUNCTION is available on the target system.
1498 # (This is essentially a Tcl implementation of Autoconf's
1501 proc check_function_available { function } {
1502 return [check_no_compiler_messages ${function}_available \
1508 int main () { $function (); }
1512 # Returns true iff "fork" is available on the target system.
1514 proc check_fork_available {} {
1515 return [check_function_available "fork"]
1518 # Returns true iff "mkfifo" is available on the target system.
1520 proc check_mkfifo_available {} {
1521 if { [istarget *-*-cygwin*] } {
1522 # Cygwin has mkfifo, but support is incomplete.
1526 return [check_function_available "mkfifo"]
1529 # Returns true iff "__cxa_atexit" is used on the target system.
1531 proc check_cxa_atexit_available { } {
1532 return [check_cached_effective_target cxa_atexit_available {
1533 if { [istarget hppa*-*-hpux10*] } {
1534 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1536 } elseif { [istarget *-*-vxworks] } {
1537 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1540 check_runtime_nocache cxa_atexit_available {
1543 static unsigned int count;
1560 Y() { f(); count = 2; }
1569 int main() { return 0; }
1575 proc check_effective_target_objc2 { } {
1576 return [check_no_compiler_messages objc2 object {
1585 proc check_effective_target_next_runtime { } {
1586 return [check_no_compiler_messages objc2 object {
1587 #ifdef __NEXT_RUNTIME__
1595 # Return 1 if we're generating 32-bit code using default options, 0
1598 proc check_effective_target_ilp32 { } {
1599 return [check_no_compiler_messages ilp32 object {
1600 int dummy[sizeof (int) == 4
1601 && sizeof (void *) == 4
1602 && sizeof (long) == 4 ? 1 : -1];
1606 # Return 1 if we're generating ia32 code using default options, 0
1609 proc check_effective_target_ia32 { } {
1610 return [check_no_compiler_messages ia32 object {
1611 int dummy[sizeof (int) == 4
1612 && sizeof (void *) == 4
1613 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1617 # Return 1 if we're generating x32 code using default options, 0
1620 proc check_effective_target_x32 { } {
1621 return [check_no_compiler_messages x32 object {
1622 int dummy[sizeof (int) == 4
1623 && sizeof (void *) == 4
1624 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1628 # Return 1 if we're generating 32-bit or larger integers using default
1629 # options, 0 otherwise.
1631 proc check_effective_target_int32plus { } {
1632 return [check_no_compiler_messages int32plus object {
1633 int dummy[sizeof (int) >= 4 ? 1 : -1];
1637 # Return 1 if we're generating 32-bit or larger pointers using default
1638 # options, 0 otherwise.
1640 proc check_effective_target_ptr32plus { } {
1641 return [check_no_compiler_messages ptr32plus object {
1642 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1646 # Return 1 if we support 32-bit or larger array and structure sizes
1647 # using default options, 0 otherwise.
1649 proc check_effective_target_size32plus { } {
1650 return [check_no_compiler_messages size32plus object {
1655 # Returns 1 if we're generating 16-bit or smaller integers with the
1656 # default options, 0 otherwise.
1658 proc check_effective_target_int16 { } {
1659 return [check_no_compiler_messages int16 object {
1660 int dummy[sizeof (int) < 4 ? 1 : -1];
1664 # Return 1 if we're generating 64-bit code using default options, 0
1667 proc check_effective_target_lp64 { } {
1668 return [check_no_compiler_messages lp64 object {
1669 int dummy[sizeof (int) == 4
1670 && sizeof (void *) == 8
1671 && sizeof (long) == 8 ? 1 : -1];
1675 # Return 1 if we're generating 64-bit code using default llp64 options,
1678 proc check_effective_target_llp64 { } {
1679 return [check_no_compiler_messages llp64 object {
1680 int dummy[sizeof (int) == 4
1681 && sizeof (void *) == 8
1682 && sizeof (long long) == 8
1683 && sizeof (long) == 4 ? 1 : -1];
1687 # Return 1 if the target supports long double larger than double,
1690 proc check_effective_target_large_long_double { } {
1691 return [check_no_compiler_messages large_long_double object {
1692 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1696 # Return 1 if the target supports double larger than float,
1699 proc check_effective_target_large_double { } {
1700 return [check_no_compiler_messages large_double object {
1701 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1705 # Return 1 if the target supports double of 64 bits,
1708 proc check_effective_target_double64 { } {
1709 return [check_no_compiler_messages double64 object {
1710 int dummy[sizeof(double) == 8 ? 1 : -1];
1714 # Return 1 if the target supports double of at least 64 bits,
1717 proc check_effective_target_double64plus { } {
1718 return [check_no_compiler_messages double64plus object {
1719 int dummy[sizeof(double) >= 8 ? 1 : -1];
1723 # Return 1 if the target supports compiling fixed-point,
1726 proc check_effective_target_fixed_point { } {
1727 return [check_no_compiler_messages fixed_point object {
1728 _Sat _Fract x; _Sat _Accum y;
1732 # Return 1 if the target supports compiling decimal floating point,
1735 proc check_effective_target_dfp_nocache { } {
1736 verbose "check_effective_target_dfp_nocache: compiling source" 2
1737 set ret [check_no_compiler_messages_nocache dfp object {
1738 float x __attribute__((mode(DD)));
1740 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1744 proc check_effective_target_dfprt_nocache { } {
1745 return [check_runtime_nocache dfprt {
1746 typedef float d64 __attribute__((mode(DD)));
1747 d64 x = 1.2df, y = 2.3dd, z;
1748 int main () { z = x + y; return 0; }
1752 # Return 1 if the target supports compiling Decimal Floating Point,
1755 # This won't change for different subtargets so cache the result.
1757 proc check_effective_target_dfp { } {
1758 return [check_cached_effective_target dfp {
1759 check_effective_target_dfp_nocache
1763 # Return 1 if the target supports linking and executing Decimal Floating
1764 # Point, 0 otherwise.
1766 # This won't change for different subtargets so cache the result.
1768 proc check_effective_target_dfprt { } {
1769 return [check_cached_effective_target dfprt {
1770 check_effective_target_dfprt_nocache
1774 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1776 proc check_effective_target_ucn_nocache { } {
1777 # -std=c99 is only valid for C
1778 if [check_effective_target_c] {
1779 set ucnopts "-std=c99"
1781 append ucnopts " -fextended-identifiers"
1782 verbose "check_effective_target_ucn_nocache: compiling source" 2
1783 set ret [check_no_compiler_messages_nocache ucn object {
1786 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1790 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1792 # This won't change for different subtargets, so cache the result.
1794 proc check_effective_target_ucn { } {
1795 return [check_cached_effective_target ucn {
1796 check_effective_target_ucn_nocache
1800 # Return 1 if the target needs a command line argument to enable a SIMD
1803 proc check_effective_target_vect_cmdline_needed { } {
1804 global et_vect_cmdline_needed_saved
1805 global et_vect_cmdline_needed_target_name
1807 if { ![info exists et_vect_cmdline_needed_target_name] } {
1808 set et_vect_cmdline_needed_target_name ""
1811 # If the target has changed since we set the cached value, clear it.
1812 set current_target [current_target_name]
1813 if { $current_target != $et_vect_cmdline_needed_target_name } {
1814 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1815 set et_vect_cmdline_needed_target_name $current_target
1816 if { [info exists et_vect_cmdline_needed_saved] } {
1817 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1818 unset et_vect_cmdline_needed_saved
1822 if [info exists et_vect_cmdline_needed_saved] {
1823 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1825 set et_vect_cmdline_needed_saved 1
1826 if { [istarget alpha*-*-*]
1827 || [istarget ia64-*-*]
1828 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1829 && ([check_effective_target_x32]
1830 || [check_effective_target_lp64]))
1831 || ([istarget powerpc*-*-*]
1832 && ([check_effective_target_powerpc_spe]
1833 || [check_effective_target_powerpc_altivec]))
1834 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1835 || [istarget spu-*-*]
1836 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1837 set et_vect_cmdline_needed_saved 0
1841 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1842 return $et_vect_cmdline_needed_saved
1845 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1847 # This won't change for different subtargets so cache the result.
1849 proc check_effective_target_vect_int { } {
1850 global et_vect_int_saved
1852 if [info exists et_vect_int_saved] {
1853 verbose "check_effective_target_vect_int: using cached result" 2
1855 set et_vect_int_saved 0
1856 if { [istarget i?86-*-*]
1857 || ([istarget powerpc*-*-*]
1858 && ![istarget powerpc-*-linux*paired*])
1859 || [istarget spu-*-*]
1860 || [istarget x86_64-*-*]
1861 || [istarget sparc*-*-*]
1862 || [istarget alpha*-*-*]
1863 || [istarget ia64-*-*]
1864 || [check_effective_target_arm32]
1865 || ([istarget mips*-*-*]
1866 && [check_effective_target_mips_loongson]) } {
1867 set et_vect_int_saved 1
1871 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1872 return $et_vect_int_saved
1875 # Return 1 if the target supports signed int->float conversion
1878 proc check_effective_target_vect_intfloat_cvt { } {
1879 global et_vect_intfloat_cvt_saved
1881 if [info exists et_vect_intfloat_cvt_saved] {
1882 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1884 set et_vect_intfloat_cvt_saved 0
1885 if { [istarget i?86-*-*]
1886 || ([istarget powerpc*-*-*]
1887 && ![istarget powerpc-*-linux*paired*])
1888 || [istarget x86_64-*-*]
1889 || ([istarget arm*-*-*]
1890 && [check_effective_target_arm_neon_ok])} {
1891 set et_vect_intfloat_cvt_saved 1
1895 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1896 return $et_vect_intfloat_cvt_saved
1899 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1901 proc check_effective_target_int128 { } {
1902 return [check_no_compiler_messages int128 object {
1904 #ifndef __SIZEOF_INT128__
1913 # Return 1 if the target supports unsigned int->float conversion
1916 proc check_effective_target_vect_uintfloat_cvt { } {
1917 global et_vect_uintfloat_cvt_saved
1919 if [info exists et_vect_uintfloat_cvt_saved] {
1920 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1922 set et_vect_uintfloat_cvt_saved 0
1923 if { [istarget i?86-*-*]
1924 || ([istarget powerpc*-*-*]
1925 && ![istarget powerpc-*-linux*paired*])
1926 || [istarget x86_64-*-*]
1927 || ([istarget arm*-*-*]
1928 && [check_effective_target_arm_neon_ok])} {
1929 set et_vect_uintfloat_cvt_saved 1
1933 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1934 return $et_vect_uintfloat_cvt_saved
1938 # Return 1 if the target supports signed float->int conversion
1941 proc check_effective_target_vect_floatint_cvt { } {
1942 global et_vect_floatint_cvt_saved
1944 if [info exists et_vect_floatint_cvt_saved] {
1945 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1947 set et_vect_floatint_cvt_saved 0
1948 if { [istarget i?86-*-*]
1949 || ([istarget powerpc*-*-*]
1950 && ![istarget powerpc-*-linux*paired*])
1951 || [istarget x86_64-*-*]
1952 || ([istarget arm*-*-*]
1953 && [check_effective_target_arm_neon_ok])} {
1954 set et_vect_floatint_cvt_saved 1
1958 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1959 return $et_vect_floatint_cvt_saved
1962 # Return 1 if the target supports unsigned float->int conversion
1965 proc check_effective_target_vect_floatuint_cvt { } {
1966 global et_vect_floatuint_cvt_saved
1968 if [info exists et_vect_floatuint_cvt_saved] {
1969 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1971 set et_vect_floatuint_cvt_saved 0
1972 if { ([istarget powerpc*-*-*]
1973 && ![istarget powerpc-*-linux*paired*])
1974 || ([istarget arm*-*-*]
1975 && [check_effective_target_arm_neon_ok])} {
1976 set et_vect_floatuint_cvt_saved 1
1980 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1981 return $et_vect_floatuint_cvt_saved
1984 # Return 1 is this is an arm target using 32-bit instructions
1985 proc check_effective_target_arm32 { } {
1986 return [check_no_compiler_messages arm32 assembly {
1987 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1993 # Return 1 is this is an arm target not using Thumb
1994 proc check_effective_target_arm_nothumb { } {
1995 return [check_no_compiler_messages arm_nothumb assembly {
1996 #if (defined(__thumb__) || defined(__thumb2__))
2002 # Return 1 if this is a little-endian ARM target
2003 proc check_effective_target_arm_little_endian { } {
2004 return [check_no_compiler_messages arm_little_endian assembly {
2005 #if !defined(__arm__) || !defined(__ARMEL__)
2011 # Return 1 if this is an ARM target that only supports aligned vector accesses
2012 proc check_effective_target_arm_vect_no_misalign { } {
2013 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2014 #if !defined(__arm__) \
2015 || (defined(__ARMEL__) \
2016 && (!defined(__thumb__) || defined(__thumb2__)))
2023 # Return 1 if this is an ARM target supporting -mfpu=vfp
2024 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2027 proc check_effective_target_arm_vfp_ok { } {
2028 if { [check_effective_target_arm32] } {
2029 return [check_no_compiler_messages arm_vfp_ok object {
2031 } "-mfpu=vfp -mfloat-abi=softfp"]
2037 # Return 1 if this is an ARM target supporting -mfpu=vfp
2038 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2041 proc check_effective_target_arm_hard_vfp_ok { } {
2042 if { [check_effective_target_arm32] } {
2043 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2044 int main() { return 0;}
2045 } "-mfpu=vfp -mfloat-abi=hard"]
2051 # Return 1 if this is an ARM target that supports DSP multiply with
2052 # current multilib flags.
2054 proc check_effective_target_arm_dsp { } {
2055 return [check_no_compiler_messages arm_dsp assembly {
2056 #ifndef __ARM_FEATURE_DSP
2063 # Return 1 if this is an ARM target that supports unaligned word/halfword
2064 # load/store instructions.
2066 proc check_effective_target_arm_unaligned { } {
2067 return [check_no_compiler_messages arm_unaligned assembly {
2068 #ifndef __ARM_FEATURE_UNALIGNED
2069 #error no unaligned support
2075 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2076 # or -mfloat-abi=hard, but if one is already specified by the
2077 # multilib, use it. Similarly, if a -mfpu option already enables
2078 # NEON, do not add -mfpu=neon.
2080 proc add_options_for_arm_neon { flags } {
2081 if { ! [check_effective_target_arm_neon_ok] } {
2084 global et_arm_neon_flags
2085 return "$flags $et_arm_neon_flags"
2088 # Return 1 if this is an ARM target supporting -mfpu=neon
2089 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2090 # incompatible with these options. Also set et_arm_neon_flags to the
2091 # best options to add.
2093 proc check_effective_target_arm_neon_ok_nocache { } {
2094 global et_arm_neon_flags
2095 set et_arm_neon_flags ""
2096 if { [check_effective_target_arm32] } {
2097 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2098 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2099 #include "arm_neon.h"
2102 set et_arm_neon_flags $flags
2111 proc check_effective_target_arm_neon_ok { } {
2112 return [check_cached_effective_target arm_neon_ok \
2113 check_effective_target_arm_neon_ok_nocache]
2116 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2117 # or -mfloat-abi=hard, but if one is already specified by the
2120 proc add_options_for_arm_fp16 { flags } {
2121 if { ! [check_effective_target_arm_fp16_ok] } {
2124 global et_arm_fp16_flags
2125 return "$flags $et_arm_fp16_flags"
2128 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2129 # Skip multilibs that are incompatible with these options and set
2130 # et_arm_fp16_flags to the best options to add.
2132 proc check_effective_target_arm_fp16_ok_nocache { } {
2133 global et_arm_fp16_flags
2134 set et_arm_fp16_flags ""
2135 if { ! [check_effective_target_arm32] } {
2138 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2139 # Multilib flags would override -mfpu.
2142 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2143 # Must generate floating-point instructions.
2146 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2147 # The existing -mfpu value is OK; use it, but add softfp.
2148 set et_arm_fp16_flags "-mfloat-abi=softfp"
2151 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2152 # macro to check for this support.
2153 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2154 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2157 set et_arm_fp16_flags "$flags"
2164 proc check_effective_target_arm_fp16_ok { } {
2165 return [check_cached_effective_target arm_fp16_ok \
2166 check_effective_target_arm_fp16_ok_nocache]
2169 # Creates a series of routines that return 1 if the given architecture
2170 # can be selected and a routine to give the flags to select that architecture
2171 # Note: Extra flags may be added to disable options from newer compilers
2172 # (Thumb in particular - but others may be added in the future)
2173 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2174 # /* { dg-add-options arm_arch_v5 } */
2175 foreach { armfunc armflag armdef } { v5 "-march=armv5 -marm" __ARM_ARCH_5__
2176 v6 "-march=armv6" __ARM_ARCH_6__
2177 v6k "-march=armv6k" __ARM_ARCH_6K__
2178 v7a "-march=armv7-a" __ARM_ARCH_7A__ } {
2179 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2180 proc check_effective_target_arm_arch_FUNC_ok { } {
2181 if { [ string match "*-marm*" "FLAG" ] &&
2182 ![check_effective_target_arm_arm_ok] } {
2185 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2192 proc add_options_for_arm_arch_FUNC { flags } {
2193 return "$flags FLAG"
2198 # Return 1 if this is an ARM target where -marm causes ARM to be
2201 proc check_effective_target_arm_arm_ok { } {
2202 return [check_no_compiler_messages arm_arm_ok assembly {
2203 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2210 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2213 proc check_effective_target_arm_thumb1_ok { } {
2214 return [check_no_compiler_messages arm_thumb1_ok assembly {
2215 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2221 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2224 proc check_effective_target_arm_thumb2_ok { } {
2225 return [check_no_compiler_messages arm_thumb2_ok assembly {
2226 #if !defined(__thumb2__)
2232 # Return 1 if this is an ARM target where Thumb-1 is used without options
2233 # added by the test.
2235 proc check_effective_target_arm_thumb1 { } {
2236 return [check_no_compiler_messages arm_thumb1 assembly {
2237 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2244 # Return 1 if this is an ARM target where Thumb-2 is used without options
2245 # added by the test.
2247 proc check_effective_target_arm_thumb2 { } {
2248 return [check_no_compiler_messages arm_thumb2 assembly {
2249 #if !defined(__thumb2__)
2256 # Return 1 if this is an ARM cortex-M profile cpu
2258 proc check_effective_target_arm_cortex_m { } {
2259 return [check_no_compiler_messages arm_cortex_m assembly {
2260 #if !defined(__ARM_ARCH_7M__) \
2261 && !defined (__ARM_ARCH_7EM__) \
2262 && !defined (__ARM_ARCH_6M__)
2269 # Return 1 if the target supports executing NEON instructions, 0
2270 # otherwise. Cache the result.
2272 proc check_effective_target_arm_neon_hw { } {
2273 return [check_runtime arm_neon_hw_available {
2277 long long a = 0, b = 1;
2278 asm ("vorr %P0, %P1, %P2"
2280 : "0" (a), "w" (b));
2283 } [add_options_for_arm_neon ""]]
2286 # Return 1 if this is a ARM target with NEON enabled.
2288 proc check_effective_target_arm_neon { } {
2289 if { [check_effective_target_arm32] } {
2290 return [check_no_compiler_messages arm_neon object {
2291 #ifndef __ARM_NEON__
2302 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2303 # the Loongson vector modes.
2305 proc check_effective_target_mips_loongson { } {
2306 return [check_no_compiler_messages loongson assembly {
2307 #if !defined(__mips_loongson_vector_rev)
2313 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2316 proc check_effective_target_arm_eabi { } {
2317 return [check_no_compiler_messages arm_eabi object {
2318 #ifndef __ARM_EABI__
2326 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2327 # Some multilibs may be incompatible with this option.
2329 proc check_effective_target_arm_iwmmxt_ok { } {
2330 if { [check_effective_target_arm32] } {
2331 return [check_no_compiler_messages arm_iwmmxt_ok object {
2339 # Return 1 if this is a PowerPC target with floating-point registers.
2341 proc check_effective_target_powerpc_fprs { } {
2342 if { [istarget powerpc*-*-*]
2343 || [istarget rs6000-*-*] } {
2344 return [check_no_compiler_messages powerpc_fprs object {
2356 # Return 1 if this is a PowerPC target with hardware double-precision
2359 proc check_effective_target_powerpc_hard_double { } {
2360 if { [istarget powerpc*-*-*]
2361 || [istarget rs6000-*-*] } {
2362 return [check_no_compiler_messages powerpc_hard_double object {
2374 # Return 1 if this is a PowerPC target supporting -maltivec.
2376 proc check_effective_target_powerpc_altivec_ok { } {
2377 if { ([istarget powerpc*-*-*]
2378 && ![istarget powerpc-*-linux*paired*])
2379 || [istarget rs6000-*-*] } {
2380 # AltiVec is not supported on AIX before 5.3.
2381 if { [istarget powerpc*-*-aix4*]
2382 || [istarget powerpc*-*-aix5.1*]
2383 || [istarget powerpc*-*-aix5.2*] } {
2386 return [check_no_compiler_messages powerpc_altivec_ok object {
2394 # Return 1 if this is a PowerPC target supporting -mvsx
2396 proc check_effective_target_powerpc_vsx_ok { } {
2397 if { ([istarget powerpc*-*-*]
2398 && ![istarget powerpc-*-linux*paired*])
2399 || [istarget rs6000-*-*] } {
2400 # AltiVec is not supported on AIX before 5.3.
2401 if { [istarget powerpc*-*-aix4*]
2402 || [istarget powerpc*-*-aix5.1*]
2403 || [istarget powerpc*-*-aix5.2*] } {
2406 return [check_no_compiler_messages powerpc_vsx_ok object {
2409 asm volatile ("xxlor vs0,vs0,vs0");
2411 asm volatile ("xxlor 0,0,0");
2421 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2423 proc check_effective_target_powerpc_ppu_ok { } {
2424 if [check_effective_target_powerpc_altivec_ok] {
2425 return [check_no_compiler_messages cell_asm_available object {
2428 asm volatile ("lvlx v0,v0,v0");
2430 asm volatile ("lvlx 0,0,0");
2440 # Return 1 if this is a PowerPC target that supports SPU.
2442 proc check_effective_target_powerpc_spu { } {
2443 if { [istarget powerpc*-*-linux*] } {
2444 return [check_effective_target_powerpc_altivec_ok]
2450 # Return 1 if this is a PowerPC SPE target. The check includes options
2451 # specified by dg-options for this test, so don't cache the result.
2453 proc check_effective_target_powerpc_spe_nocache { } {
2454 if { [istarget powerpc*-*-*] } {
2455 return [check_no_compiler_messages_nocache powerpc_spe object {
2461 } [current_compiler_flags]]
2467 # Return 1 if this is a PowerPC target with SPE enabled.
2469 proc check_effective_target_powerpc_spe { } {
2470 if { [istarget powerpc*-*-*] } {
2471 return [check_no_compiler_messages powerpc_spe object {
2483 # Return 1 if this is a PowerPC target with Altivec enabled.
2485 proc check_effective_target_powerpc_altivec { } {
2486 if { [istarget powerpc*-*-*] } {
2487 return [check_no_compiler_messages powerpc_altivec object {
2499 # Return 1 if this is a PowerPC 405 target. The check includes options
2500 # specified by dg-options for this test, so don't cache the result.
2502 proc check_effective_target_powerpc_405_nocache { } {
2503 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2504 return [check_no_compiler_messages_nocache powerpc_405 object {
2510 } [current_compiler_flags]]
2516 # Return 1 if this is a SPU target with a toolchain that
2517 # supports automatic overlay generation.
2519 proc check_effective_target_spu_auto_overlay { } {
2520 if { [istarget spu*-*-elf*] } {
2521 return [check_no_compiler_messages spu_auto_overlay executable {
2523 } "-Wl,--auto-overlay" ]
2529 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2530 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2531 # test environment appears to run executables on such a simulator.
2533 proc check_effective_target_ultrasparc_hw { } {
2534 return [check_runtime ultrasparc_hw {
2535 int main() { return 0; }
2536 } "-mcpu=ultrasparc"]
2539 # Return 1 if the test environment supports executing UltraSPARC VIS2
2540 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
2542 proc check_effective_target_ultrasparc_vis2_hw { } {
2543 return [check_runtime ultrasparc_vis2_hw {
2544 int main() { __asm__(".word 0x81b00320"); return 0; }
2545 } "-mcpu=ultrasparc3"]
2548 # Return 1 if the test environment supports executing UltraSPARC VIS3
2549 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
2551 proc check_effective_target_ultrasparc_vis3_hw { } {
2552 return [check_runtime ultrasparc_vis3_hw {
2553 int main() { __asm__(".word 0x81b00220"); return 0; }
2557 # Return 1 if this is a Sparc target with VIS enabled.
2559 proc check_effective_target_sparc_vis { } {
2560 if { [istarget sparc*-*-*] } {
2561 return [check_no_compiler_messages sparc_vis object {
2573 # Return 1 if the target supports hardware vector shift operation.
2575 proc check_effective_target_vect_shift { } {
2576 global et_vect_shift_saved
2578 if [info exists et_vect_shift_saved] {
2579 verbose "check_effective_target_vect_shift: using cached result" 2
2581 set et_vect_shift_saved 0
2582 if { ([istarget powerpc*-*-*]
2583 && ![istarget powerpc-*-linux*paired*])
2584 || [istarget ia64-*-*]
2585 || [istarget i?86-*-*]
2586 || [istarget x86_64-*-*]
2587 || [check_effective_target_arm32]
2588 || ([istarget mips*-*-*]
2589 && [check_effective_target_mips_loongson]) } {
2590 set et_vect_shift_saved 1
2594 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2595 return $et_vect_shift_saved
2598 # Return 1 if the target supports hardware vector shift operation for char.
2600 proc check_effective_target_vect_shift_char { } {
2601 global et_vect_shift_char_saved
2603 if [info exists et_vect_shift_char_saved] {
2604 verbose "check_effective_target_vect_shift_char: using cached result" 2
2606 set et_vect_shift_char_saved 0
2607 if { ([istarget powerpc*-*-*]
2608 && ![istarget powerpc-*-linux*paired*])
2609 || [check_effective_target_arm32] } {
2610 set et_vect_shift_char_saved 1
2614 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2615 return $et_vect_shift_char_saved
2618 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2620 # This can change for different subtargets so do not cache the result.
2622 proc check_effective_target_vect_long { } {
2623 if { [istarget i?86-*-*]
2624 || (([istarget powerpc*-*-*]
2625 && ![istarget powerpc-*-linux*paired*])
2626 && [check_effective_target_ilp32])
2627 || [istarget x86_64-*-*]
2628 || [check_effective_target_arm32]
2629 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2635 verbose "check_effective_target_vect_long: returning $answer" 2
2639 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2641 # This won't change for different subtargets so cache the result.
2643 proc check_effective_target_vect_float { } {
2644 global et_vect_float_saved
2646 if [info exists et_vect_float_saved] {
2647 verbose "check_effective_target_vect_float: using cached result" 2
2649 set et_vect_float_saved 0
2650 if { [istarget i?86-*-*]
2651 || [istarget powerpc*-*-*]
2652 || [istarget spu-*-*]
2653 || [istarget mipsisa64*-*-*]
2654 || [istarget x86_64-*-*]
2655 || [istarget ia64-*-*]
2656 || [check_effective_target_arm32] } {
2657 set et_vect_float_saved 1
2661 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2662 return $et_vect_float_saved
2665 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2667 # This won't change for different subtargets so cache the result.
2669 proc check_effective_target_vect_double { } {
2670 global et_vect_double_saved
2672 if [info exists et_vect_double_saved] {
2673 verbose "check_effective_target_vect_double: using cached result" 2
2675 set et_vect_double_saved 0
2676 if { [istarget i?86-*-*]
2677 || [istarget x86_64-*-*] } {
2678 if { [check_no_compiler_messages vect_double assembly {
2679 #ifdef __tune_atom__
2680 # error No double vectorizer support.
2683 set et_vect_double_saved 1
2685 set et_vect_double_saved 0
2687 } elseif { [istarget spu-*-*] } {
2688 set et_vect_double_saved 1
2692 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2693 return $et_vect_double_saved
2696 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2698 # This won't change for different subtargets so cache the result.
2700 proc check_effective_target_vect_long_long { } {
2701 global et_vect_long_long_saved
2703 if [info exists et_vect_long_long_saved] {
2704 verbose "check_effective_target_vect_long_long: using cached result" 2
2706 set et_vect_long_long_saved 0
2707 if { [istarget i?86-*-*]
2708 || [istarget x86_64-*-*] } {
2709 set et_vect_long_long_saved 1
2713 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2714 return $et_vect_long_long_saved
2718 # Return 1 if the target plus current options does not support a vector
2719 # max instruction on "int", 0 otherwise.
2721 # This won't change for different subtargets so cache the result.
2723 proc check_effective_target_vect_no_int_max { } {
2724 global et_vect_no_int_max_saved
2726 if [info exists et_vect_no_int_max_saved] {
2727 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2729 set et_vect_no_int_max_saved 0
2730 if { [istarget sparc*-*-*]
2731 || [istarget spu-*-*]
2732 || [istarget alpha*-*-*]
2733 || ([istarget mips*-*-*]
2734 && [check_effective_target_mips_loongson]) } {
2735 set et_vect_no_int_max_saved 1
2738 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2739 return $et_vect_no_int_max_saved
2742 # Return 1 if the target plus current options does not support a vector
2743 # add instruction on "int", 0 otherwise.
2745 # This won't change for different subtargets so cache the result.
2747 proc check_effective_target_vect_no_int_add { } {
2748 global et_vect_no_int_add_saved
2750 if [info exists et_vect_no_int_add_saved] {
2751 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2753 set et_vect_no_int_add_saved 0
2754 # Alpha only supports vector add on V8QI and V4HI.
2755 if { [istarget alpha*-*-*] } {
2756 set et_vect_no_int_add_saved 1
2759 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2760 return $et_vect_no_int_add_saved
2763 # Return 1 if the target plus current options does not support vector
2764 # bitwise instructions, 0 otherwise.
2766 # This won't change for different subtargets so cache the result.
2768 proc check_effective_target_vect_no_bitwise { } {
2769 global et_vect_no_bitwise_saved
2771 if [info exists et_vect_no_bitwise_saved] {
2772 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2774 set et_vect_no_bitwise_saved 0
2776 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2777 return $et_vect_no_bitwise_saved
2780 # Return 1 if the target plus current options supports vector permutation,
2783 # This won't change for different subtargets so cache the result.
2785 proc check_effective_target_vect_perm { } {
2788 if [info exists et_vect_perm_saved] {
2789 verbose "check_effective_target_vect_perm: using cached result" 2
2791 set et_vect_perm_saved 0
2792 if { [is-effective-target arm_neon_ok]
2793 || [istarget powerpc*-*-*]
2794 || [istarget spu-*-*]
2795 || [istarget i?86-*-*]
2796 || [istarget x86_64-*-*]
2797 || ([istarget mips*-*-*]
2798 && [check_effective_target_mpaired_single]) } {
2799 set et_vect_perm_saved 1
2802 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2803 return $et_vect_perm_saved
2806 # Return 1 if the target plus current options supports vector permutation
2807 # on byte-sized elements, 0 otherwise.
2809 # This won't change for different subtargets so cache the result.
2811 proc check_effective_target_vect_perm_byte { } {
2812 global et_vect_perm_byte
2814 if [info exists et_vect_perm_byte_saved] {
2815 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2817 set et_vect_perm_byte_saved 0
2818 if { [is-effective-target arm_neon_ok]
2819 || [istarget powerpc*-*-*]
2820 || [istarget spu-*-*] } {
2821 set et_vect_perm_byte_saved 1
2824 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2825 return $et_vect_perm_byte_saved
2828 # Return 1 if the target plus current options supports vector permutation
2829 # on short-sized elements, 0 otherwise.
2831 # This won't change for different subtargets so cache the result.
2833 proc check_effective_target_vect_perm_short { } {
2834 global et_vect_perm_short
2836 if [info exists et_vect_perm_short_saved] {
2837 verbose "check_effective_target_vect_perm_short: using cached result" 2
2839 set et_vect_perm_short_saved 0
2840 if { [is-effective-target arm_neon_ok]
2841 || [istarget powerpc*-*-*]
2842 || [istarget spu-*-*] } {
2843 set et_vect_perm_short_saved 1
2846 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2847 return $et_vect_perm_short_saved
2850 # Return 1 if the target plus current options supports a vector
2851 # widening summation of *short* args into *int* result, 0 otherwise.
2853 # This won't change for different subtargets so cache the result.
2855 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2856 global et_vect_widen_sum_hi_to_si_pattern
2858 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2859 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2861 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2862 if { [istarget powerpc*-*-*]
2863 || [istarget ia64-*-*] } {
2864 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2867 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2868 return $et_vect_widen_sum_hi_to_si_pattern_saved
2871 # Return 1 if the target plus current options supports a vector
2872 # widening summation of *short* args into *int* result, 0 otherwise.
2873 # A target can also support this widening summation if it can support
2874 # promotion (unpacking) from shorts to ints.
2876 # This won't change for different subtargets so cache the result.
2878 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2879 global et_vect_widen_sum_hi_to_si
2881 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2882 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2884 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2885 if { [istarget powerpc*-*-*]
2886 || [istarget ia64-*-*] } {
2887 set et_vect_widen_sum_hi_to_si_saved 1
2890 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2891 return $et_vect_widen_sum_hi_to_si_saved
2894 # Return 1 if the target plus current options supports a vector
2895 # widening summation of *char* args into *short* result, 0 otherwise.
2896 # A target can also support this widening summation if it can support
2897 # promotion (unpacking) from chars to shorts.
2899 # This won't change for different subtargets so cache the result.
2901 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2902 global et_vect_widen_sum_qi_to_hi
2904 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2905 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2907 set et_vect_widen_sum_qi_to_hi_saved 0
2908 if { [check_effective_target_vect_unpack]
2909 || [istarget ia64-*-*] } {
2910 set et_vect_widen_sum_qi_to_hi_saved 1
2913 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2914 return $et_vect_widen_sum_qi_to_hi_saved
2917 # Return 1 if the target plus current options supports a vector
2918 # widening summation of *char* args into *int* result, 0 otherwise.
2920 # This won't change for different subtargets so cache the result.
2922 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2923 global et_vect_widen_sum_qi_to_si
2925 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2926 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2928 set et_vect_widen_sum_qi_to_si_saved 0
2929 if { [istarget powerpc*-*-*] } {
2930 set et_vect_widen_sum_qi_to_si_saved 1
2933 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2934 return $et_vect_widen_sum_qi_to_si_saved
2937 # Return 1 if the target plus current options supports a vector
2938 # widening multiplication of *char* args into *short* result, 0 otherwise.
2939 # A target can also support this widening multplication if it can support
2940 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2941 # multiplication of shorts).
2943 # This won't change for different subtargets so cache the result.
2946 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2947 global et_vect_widen_mult_qi_to_hi
2949 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2950 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2952 if { [check_effective_target_vect_unpack]
2953 && [check_effective_target_vect_short_mult] } {
2954 set et_vect_widen_mult_qi_to_hi_saved 1
2956 set et_vect_widen_mult_qi_to_hi_saved 0
2958 if { [istarget powerpc*-*-*]
2959 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2960 set et_vect_widen_mult_qi_to_hi_saved 1
2963 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2964 return $et_vect_widen_mult_qi_to_hi_saved
2967 # Return 1 if the target plus current options supports a vector
2968 # widening multiplication of *short* args into *int* result, 0 otherwise.
2969 # A target can also support this widening multplication if it can support
2970 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2971 # multiplication of ints).
2973 # This won't change for different subtargets so cache the result.
2976 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2977 global et_vect_widen_mult_hi_to_si
2979 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2980 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2982 if { [check_effective_target_vect_unpack]
2983 && [check_effective_target_vect_int_mult] } {
2984 set et_vect_widen_mult_hi_to_si_saved 1
2986 set et_vect_widen_mult_hi_to_si_saved 0
2988 if { [istarget powerpc*-*-*]
2989 || [istarget spu-*-*]
2990 || [istarget ia64-*-*]
2991 || [istarget i?86-*-*]
2992 || [istarget x86_64-*-*]
2993 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2994 set et_vect_widen_mult_hi_to_si_saved 1
2997 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2998 return $et_vect_widen_mult_hi_to_si_saved
3001 # Return 1 if the target plus current options supports a vector
3002 # widening multiplication of *char* args into *short* result, 0 otherwise.
3004 # This won't change for different subtargets so cache the result.
3006 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3007 global et_vect_widen_mult_qi_to_hi_pattern
3009 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3010 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3012 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3013 if { [istarget powerpc*-*-*]
3014 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3015 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3018 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3019 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3022 # Return 1 if the target plus current options supports a vector
3023 # widening multiplication of *short* args into *int* result, 0 otherwise.
3025 # This won't change for different subtargets so cache the result.
3027 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3028 global et_vect_widen_mult_hi_to_si_pattern
3030 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3031 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3033 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3034 if { [istarget powerpc*-*-*]
3035 || [istarget spu-*-*]
3036 || [istarget ia64-*-*]
3037 || [istarget i?86-*-*]
3038 || [istarget x86_64-*-*]
3039 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3040 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3043 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3044 return $et_vect_widen_mult_hi_to_si_pattern_saved
3047 # Return 1 if the target plus current options supports a vector
3048 # widening shift, 0 otherwise.
3050 # This won't change for different subtargets so cache the result.
3052 proc check_effective_target_vect_widen_shift { } {
3053 global et_vect_widen_shift_saved
3055 if [info exists et_vect_shift_saved] {
3056 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3058 set et_vect_widen_shift_saved 0
3059 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3060 set et_vect_widen_shift_saved 1
3063 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3064 return $et_vect_widen_shift_saved
3067 # Return 1 if the target plus current options supports a vector
3068 # dot-product of signed chars, 0 otherwise.
3070 # This won't change for different subtargets so cache the result.
3072 proc check_effective_target_vect_sdot_qi { } {
3073 global et_vect_sdot_qi
3075 if [info exists et_vect_sdot_qi_saved] {
3076 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3078 set et_vect_sdot_qi_saved 0
3079 if { [istarget ia64-*-*] } {
3080 set et_vect_udot_qi_saved 1
3083 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3084 return $et_vect_sdot_qi_saved
3087 # Return 1 if the target plus current options supports a vector
3088 # dot-product of unsigned chars, 0 otherwise.
3090 # This won't change for different subtargets so cache the result.
3092 proc check_effective_target_vect_udot_qi { } {
3093 global et_vect_udot_qi
3095 if [info exists et_vect_udot_qi_saved] {
3096 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3098 set et_vect_udot_qi_saved 0
3099 if { [istarget powerpc*-*-*]
3100 || [istarget ia64-*-*] } {
3101 set et_vect_udot_qi_saved 1
3104 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3105 return $et_vect_udot_qi_saved
3108 # Return 1 if the target plus current options supports a vector
3109 # dot-product of signed shorts, 0 otherwise.
3111 # This won't change for different subtargets so cache the result.
3113 proc check_effective_target_vect_sdot_hi { } {
3114 global et_vect_sdot_hi
3116 if [info exists et_vect_sdot_hi_saved] {
3117 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3119 set et_vect_sdot_hi_saved 0
3120 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3121 || [istarget ia64-*-*]
3122 || [istarget i?86-*-*]
3123 || [istarget x86_64-*-*] } {
3124 set et_vect_sdot_hi_saved 1
3127 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3128 return $et_vect_sdot_hi_saved
3131 # Return 1 if the target plus current options supports a vector
3132 # dot-product of unsigned shorts, 0 otherwise.
3134 # This won't change for different subtargets so cache the result.
3136 proc check_effective_target_vect_udot_hi { } {
3137 global et_vect_udot_hi
3139 if [info exists et_vect_udot_hi_saved] {
3140 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3142 set et_vect_udot_hi_saved 0
3143 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3144 set et_vect_udot_hi_saved 1
3147 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3148 return $et_vect_udot_hi_saved
3152 # Return 1 if the target plus current options supports a vector
3153 # demotion (packing) of shorts (to chars) and ints (to shorts)
3154 # using modulo arithmetic, 0 otherwise.
3156 # This won't change for different subtargets so cache the result.
3158 proc check_effective_target_vect_pack_trunc { } {
3159 global et_vect_pack_trunc
3161 if [info exists et_vect_pack_trunc_saved] {
3162 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3164 set et_vect_pack_trunc_saved 0
3165 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3166 || [istarget i?86-*-*]
3167 || [istarget x86_64-*-*]
3168 || [istarget spu-*-*]
3169 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3170 && [check_effective_target_arm_little_endian]) } {
3171 set et_vect_pack_trunc_saved 1
3174 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3175 return $et_vect_pack_trunc_saved
3178 # Return 1 if the target plus current options supports a vector
3179 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3181 # This won't change for different subtargets so cache the result.
3183 proc check_effective_target_vect_unpack { } {
3184 global et_vect_unpack
3186 if [info exists et_vect_unpack_saved] {
3187 verbose "check_effective_target_vect_unpack: using cached result" 2
3189 set et_vect_unpack_saved 0
3190 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3191 || [istarget i?86-*-*]
3192 || [istarget x86_64-*-*]
3193 || [istarget spu-*-*]
3194 || [istarget ia64-*-*]
3195 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3196 && [check_effective_target_arm_little_endian]) } {
3197 set et_vect_unpack_saved 1
3200 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3201 return $et_vect_unpack_saved
3204 # Return 1 if the target plus current options does not guarantee
3205 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3207 # This won't change for different subtargets so cache the result.
3209 proc check_effective_target_unaligned_stack { } {
3210 global et_unaligned_stack_saved
3212 if [info exists et_unaligned_stack_saved] {
3213 verbose "check_effective_target_unaligned_stack: using cached result" 2
3215 set et_unaligned_stack_saved 0
3217 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3218 return $et_unaligned_stack_saved
3221 # Return 1 if the target plus current options does not support a vector
3222 # alignment mechanism, 0 otherwise.
3224 # This won't change for different subtargets so cache the result.
3226 proc check_effective_target_vect_no_align { } {
3227 global et_vect_no_align_saved
3229 if [info exists et_vect_no_align_saved] {
3230 verbose "check_effective_target_vect_no_align: using cached result" 2
3232 set et_vect_no_align_saved 0
3233 if { [istarget mipsisa64*-*-*]
3234 || [istarget sparc*-*-*]
3235 || [istarget ia64-*-*]
3236 || [check_effective_target_arm_vect_no_misalign]
3237 || ([istarget mips*-*-*]
3238 && [check_effective_target_mips_loongson]) } {
3239 set et_vect_no_align_saved 1
3242 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3243 return $et_vect_no_align_saved
3246 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3248 # This won't change for different subtargets so cache the result.
3250 proc check_effective_target_vect_hw_misalign { } {
3251 global et_vect_hw_misalign_saved
3253 if [info exists et_vect_hw_misalign_saved] {
3254 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3256 set et_vect_hw_misalign_saved 0
3257 if { ([istarget x86_64-*-*]
3258 || [istarget i?86-*-*]) } {
3259 set et_vect_hw_misalign_saved 1
3262 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3263 return $et_vect_hw_misalign_saved
3267 # Return 1 if arrays are aligned to the vector alignment
3268 # boundary, 0 otherwise.
3270 # This won't change for different subtargets so cache the result.
3272 proc check_effective_target_vect_aligned_arrays { } {
3273 global et_vect_aligned_arrays
3275 if [info exists et_vect_aligned_arrays_saved] {
3276 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3278 set et_vect_aligned_arrays_saved 0
3279 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3280 if { ([is-effective-target lp64]
3281 && ( ![check_avx_available]
3282 || [check_prefer_avx128])) } {
3283 set et_vect_aligned_arrays_saved 1
3286 if [istarget spu-*-*] {
3287 set et_vect_aligned_arrays_saved 1
3290 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3291 return $et_vect_aligned_arrays_saved
3294 # Return 1 if types of size 32 bit or less are naturally aligned
3295 # (aligned to their type-size), 0 otherwise.
3297 # This won't change for different subtargets so cache the result.
3299 proc check_effective_target_natural_alignment_32 { } {
3300 global et_natural_alignment_32
3302 if [info exists et_natural_alignment_32_saved] {
3303 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3305 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3306 set et_natural_alignment_32_saved 1
3307 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3308 set et_natural_alignment_32_saved 0
3311 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3312 return $et_natural_alignment_32_saved
3315 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3316 # type-size), 0 otherwise.
3318 # This won't change for different subtargets so cache the result.
3320 proc check_effective_target_natural_alignment_64 { } {
3321 global et_natural_alignment_64
3323 if [info exists et_natural_alignment_64_saved] {
3324 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3326 set et_natural_alignment_64_saved 0
3327 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3328 || [istarget spu-*-*] } {
3329 set et_natural_alignment_64_saved 1
3332 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3333 return $et_natural_alignment_64_saved
3336 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3338 # This won't change for different subtargets so cache the result.
3340 proc check_effective_target_vector_alignment_reachable { } {
3341 global et_vector_alignment_reachable
3343 if [info exists et_vector_alignment_reachable_saved] {
3344 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3346 if { [check_effective_target_vect_aligned_arrays]
3347 || [check_effective_target_natural_alignment_32] } {
3348 set et_vector_alignment_reachable_saved 1
3350 set et_vector_alignment_reachable_saved 0
3353 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3354 return $et_vector_alignment_reachable_saved
3357 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3359 # This won't change for different subtargets so cache the result.
3361 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3362 global et_vector_alignment_reachable_for_64bit
3364 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3365 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3367 if { [check_effective_target_vect_aligned_arrays]
3368 || [check_effective_target_natural_alignment_64] } {
3369 set et_vector_alignment_reachable_for_64bit_saved 1
3371 set et_vector_alignment_reachable_for_64bit_saved 0
3374 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3375 return $et_vector_alignment_reachable_for_64bit_saved
3378 # Return 1 if the target only requires element alignment for vector accesses
3380 proc check_effective_target_vect_element_align { } {
3381 global et_vect_element_align
3383 if [info exists et_vect_element_align] {
3384 verbose "check_effective_target_vect_element_align: using cached result" 2
3386 set et_vect_element_align 0
3387 if { ([istarget arm*-*-*]
3388 && ![check_effective_target_arm_vect_no_misalign])
3389 || [check_effective_target_vect_hw_misalign] } {
3390 set et_vect_element_align 1
3394 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3395 return $et_vect_element_align
3398 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3400 proc check_effective_target_vect_condition { } {
3401 global et_vect_cond_saved
3403 if [info exists et_vect_cond_saved] {
3404 verbose "check_effective_target_vect_cond: using cached result" 2
3406 set et_vect_cond_saved 0
3407 if { [istarget powerpc*-*-*]
3408 || [istarget ia64-*-*]
3409 || [istarget i?86-*-*]
3410 || [istarget spu-*-*]
3411 || [istarget x86_64-*-*] } {
3412 set et_vect_cond_saved 1
3416 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3417 return $et_vect_cond_saved
3420 # Return 1 if the target supports vector conditional operations where
3421 # the comparison has different type from the lhs, 0 otherwise.
3423 proc check_effective_target_vect_cond_mixed { } {
3424 global et_vect_cond_mixed_saved
3426 if [info exists et_vect_cond_mixed_saved] {
3427 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3429 set et_vect_cond_mixed_saved 0
3430 if { [istarget i?86-*-*]
3431 || [istarget x86_64-*-*]
3432 || [istarget powerpc*-*-*] } {
3433 set et_vect_cond_mixed_saved 1
3437 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3438 return $et_vect_cond_mixed_saved
3441 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3443 proc check_effective_target_vect_char_mult { } {
3444 global et_vect_char_mult_saved
3446 if [info exists et_vect_char_mult_saved] {
3447 verbose "check_effective_target_vect_char_mult: using cached result" 2
3449 set et_vect_char_mult_saved 0
3450 if { [istarget ia64-*-*]
3451 || [istarget i?86-*-*]
3452 || [istarget x86_64-*-*] } {
3453 set et_vect_char_mult_saved 1
3457 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3458 return $et_vect_char_mult_saved
3461 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3463 proc check_effective_target_vect_short_mult { } {
3464 global et_vect_short_mult_saved
3466 if [info exists et_vect_short_mult_saved] {
3467 verbose "check_effective_target_vect_short_mult: using cached result" 2
3469 set et_vect_short_mult_saved 0
3470 if { [istarget ia64-*-*]
3471 || [istarget spu-*-*]
3472 || [istarget i?86-*-*]
3473 || [istarget x86_64-*-*]
3474 || [istarget powerpc*-*-*]
3475 || [check_effective_target_arm32]
3476 || ([istarget mips*-*-*]
3477 && [check_effective_target_mips_loongson]) } {
3478 set et_vect_short_mult_saved 1
3482 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3483 return $et_vect_short_mult_saved
3486 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3488 proc check_effective_target_vect_int_mult { } {
3489 global et_vect_int_mult_saved
3491 if [info exists et_vect_int_mult_saved] {
3492 verbose "check_effective_target_vect_int_mult: using cached result" 2
3494 set et_vect_int_mult_saved 0
3495 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3496 || [istarget spu-*-*]
3497 || [istarget i?86-*-*]
3498 || [istarget x86_64-*-*]
3499 || [istarget ia64-*-*]
3500 || [check_effective_target_arm32] } {
3501 set et_vect_int_mult_saved 1
3505 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3506 return $et_vect_int_mult_saved
3509 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3511 proc check_effective_target_vect_extract_even_odd { } {
3512 global et_vect_extract_even_odd_saved
3514 if [info exists et_vect_extract_even_odd_saved] {
3515 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3517 set et_vect_extract_even_odd_saved 0
3518 if { [istarget powerpc*-*-*]
3519 || [is-effective-target arm_neon_ok]
3520 || [istarget i?86-*-*]
3521 || [istarget x86_64-*-*]
3522 || [istarget ia64-*-*]
3523 || [istarget spu-*-*]
3524 || ([istarget mips*-*-*]
3525 && [check_effective_target_mpaired_single]) } {
3526 set et_vect_extract_even_odd_saved 1
3530 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3531 return $et_vect_extract_even_odd_saved
3534 # Return 1 if the target supports vector interleaving, 0 otherwise.
3536 proc check_effective_target_vect_interleave { } {
3537 global et_vect_interleave_saved
3539 if [info exists et_vect_interleave_saved] {
3540 verbose "check_effective_target_vect_interleave: using cached result" 2
3542 set et_vect_interleave_saved 0
3543 if { [istarget powerpc*-*-*]
3544 || [is-effective-target arm_neon_ok]
3545 || [istarget i?86-*-*]
3546 || [istarget x86_64-*-*]
3547 || [istarget ia64-*-*]
3548 || [istarget spu-*-*]
3549 || ([istarget mips*-*-*]
3550 && [check_effective_target_mpaired_single]) } {
3551 set et_vect_interleave_saved 1
3555 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3556 return $et_vect_interleave_saved
3559 foreach N {2 3 4 8} {
3560 eval [string map [list N $N] {
3561 # Return 1 if the target supports 2-vector interleaving
3562 proc check_effective_target_vect_stridedN { } {
3563 global et_vect_stridedN_saved
3565 if [info exists et_vect_stridedN_saved] {
3566 verbose "check_effective_target_vect_stridedN: using cached result" 2
3568 set et_vect_stridedN_saved 0
3570 && [check_effective_target_vect_interleave]
3571 && [check_effective_target_vect_extract_even_odd] } {
3572 set et_vect_stridedN_saved 1
3574 if { [istarget arm*-*-*] && N >= 2 && N <= 4 } {
3575 set et_vect_stridedN_saved 1
3579 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3580 return $et_vect_stridedN_saved
3585 # Return 1 if the target supports multiple vector sizes
3587 proc check_effective_target_vect_multiple_sizes { } {
3588 global et_vect_multiple_sizes_saved
3590 set et_vect_multiple_sizes_saved 0
3591 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3592 set et_vect_multiple_sizes_saved 1
3594 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3595 if { ([check_avx_available] && ![check_prefer_avx128]) } {
3596 set et_vect_multiple_sizes_saved 1
3600 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
3601 return $et_vect_multiple_sizes_saved
3604 # Return 1 if the target supports vectors of 64 bits.
3606 proc check_effective_target_vect64 { } {
3607 global et_vect64_saved
3609 if [info exists et_vect64_saved] {
3610 verbose "check_effective_target_vect64: using cached result" 2
3612 set et_vect64_saved 0
3613 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3614 set et_vect64_saved 1
3618 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
3619 return $et_vect64_saved
3622 # Return 1 if the target supports vector copysignf calls.
3624 proc check_effective_target_vect_call_copysignf { } {
3625 global et_vect_call_copysignf_saved
3627 if [info exists et_vect_call_copysignf_saved] {
3628 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
3630 set et_vect_call_copysignf_saved 0
3631 if { [istarget i?86-*-*]
3632 || [istarget x86_64-*-*]
3633 || [istarget powerpc*-*-*] } {
3634 set et_vect_call_copysignf_saved 1
3638 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
3639 return $et_vect_call_copysignf_saved
3642 # Return 1 if the target supports vector sqrtf calls.
3644 proc check_effective_target_vect_call_sqrtf { } {
3645 global et_vect_call_sqrtf_saved
3647 if [info exists et_vect_call_sqrtf_saved] {
3648 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
3650 set et_vect_call_sqrtf_saved 0
3651 if { [istarget i?86-*-*]
3652 || [istarget x86_64-*-*]
3653 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
3654 set et_vect_call_sqrtf_saved 1
3658 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
3659 return $et_vect_call_sqrtf_saved
3662 # Return 1 if the target supports vector lrint calls.
3664 proc check_effective_target_vect_call_lrint { } {
3665 set et_vect_call_lrint 0
3666 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
3667 set et_vect_call_lrint 1
3670 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
3671 return $et_vect_call_lrint
3674 # Return 1 if the target supports section-anchors
3676 proc check_effective_target_section_anchors { } {
3677 global et_section_anchors_saved
3679 if [info exists et_section_anchors_saved] {
3680 verbose "check_effective_target_section_anchors: using cached result" 2
3682 set et_section_anchors_saved 0
3683 if { [istarget powerpc*-*-*]
3684 || [istarget arm*-*-*] } {
3685 set et_section_anchors_saved 1
3689 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3690 return $et_section_anchors_saved
3693 # Return 1 if the target supports atomic operations on "int_128" values.
3695 proc check_effective_target_sync_int_128 { } {
3696 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3697 && ![is-effective-target ia32] } {
3704 # Return 1 if the target supports atomic operations on "int_128" values
3705 # and can execute them.
3707 proc check_effective_target_sync_int_128_runtime { } {
3708 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3709 && ![is-effective-target ia32] } {
3710 return [check_cached_effective_target sync_int_128_available {
3711 check_runtime_nocache sync_int_128_available {
3715 unsigned int eax, ebx, ecx, edx;
3716 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3717 return !(ecx & bit_CMPXCHG16B);
3727 # Return 1 if the target supports atomic operations on "long long".
3729 # Note: 32bit x86 targets require -march=pentium in dg-options.
3731 proc check_effective_target_sync_long_long { } {
3732 if { [istarget x86_64-*-*]
3733 || [istarget i?86-*-*])
3734 || [istarget arm*-*-*]
3735 || [istarget alpha*-*-*] } {
3742 # Return 1 if the target supports atomic operations on "long long"
3743 # and can execute them.
3745 # Note: 32bit x86 targets require -march=pentium in dg-options.
3747 proc check_effective_target_sync_long_long_runtime { } {
3748 if { [istarget x86_64-*-*]
3749 || [istarget i?86-*-*] } {
3750 return [check_cached_effective_target sync_long_long_available {
3751 check_runtime_nocache sync_long_long_available {
3755 unsigned int eax, ebx, ecx, edx;
3756 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3757 return !(edx & bit_CMPXCHG8B);
3762 } elseif { [istarget arm*-*-linux-gnueabi] } {
3763 return [check_runtime sync_longlong_runtime {
3769 if (sizeof (long long) != 8)
3772 /* Just check for native; checking for kernel fallback is tricky. */
3773 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
3778 } elseif { [istarget alpha*-*-*] } {
3785 # Return 1 if the target supports atomic operations on "int" and "long".
3787 proc check_effective_target_sync_int_long { } {
3788 global et_sync_int_long_saved
3790 if [info exists et_sync_int_long_saved] {
3791 verbose "check_effective_target_sync_int_long: using cached result" 2
3793 set et_sync_int_long_saved 0
3794 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3795 # load-reserved/store-conditional instructions.
3796 if { [istarget ia64-*-*]
3797 || [istarget i?86-*-*]
3798 || [istarget x86_64-*-*]
3799 || [istarget alpha*-*-*]
3800 || [istarget arm*-*-linux-gnueabi]
3801 || [istarget bfin*-*linux*]
3802 || [istarget hppa*-*linux*]
3803 || [istarget s390*-*-*]
3804 || [istarget powerpc*-*-*]
3805 || [istarget sparc64-*-*]
3806 || [istarget sparcv9-*-*]
3807 || [check_effective_target_mips_llsc] } {
3808 set et_sync_int_long_saved 1
3812 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3813 return $et_sync_int_long_saved
3816 # Return 1 if the target supports atomic operations on "char" and "short".
3818 proc check_effective_target_sync_char_short { } {
3819 global et_sync_char_short_saved
3821 if [info exists et_sync_char_short_saved] {
3822 verbose "check_effective_target_sync_char_short: using cached result" 2
3824 set et_sync_char_short_saved 0
3825 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3826 # load-reserved/store-conditional instructions.
3827 if { [istarget ia64-*-*]
3828 || [istarget i?86-*-*]
3829 || [istarget x86_64-*-*]
3830 || [istarget alpha*-*-*]
3831 || [istarget arm*-*-linux-gnueabi]
3832 || [istarget hppa*-*linux*]
3833 || [istarget s390*-*-*]
3834 || [istarget powerpc*-*-*]
3835 || [istarget sparc64-*-*]
3836 || [istarget sparcv9-*-*]
3837 || [check_effective_target_mips_llsc] } {
3838 set et_sync_char_short_saved 1
3842 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3843 return $et_sync_char_short_saved
3846 # Return 1 if the target uses a ColdFire FPU.
3848 proc check_effective_target_coldfire_fpu { } {
3849 return [check_no_compiler_messages coldfire_fpu assembly {
3856 # Return true if this is a uClibc target.
3858 proc check_effective_target_uclibc {} {
3859 return [check_no_compiler_messages uclibc object {
3860 #include <features.h>
3861 #if !defined (__UCLIBC__)
3867 # Return true if this is a uclibc target and if the uclibc feature
3868 # described by __$feature__ is not present.
3870 proc check_missing_uclibc_feature {feature} {
3871 return [check_no_compiler_messages $feature object "
3872 #include <features.h>
3873 #if !defined (__UCLIBC) || defined (__${feature}__)
3879 # Return true if this is a Newlib target.
3881 proc check_effective_target_newlib {} {
3882 return [check_no_compiler_messages newlib object {
3888 # (a) an error of a few ULP is expected in string to floating-point
3889 # conversion functions; and
3890 # (b) overflow is not always detected correctly by those functions.
3892 proc check_effective_target_lax_strtofp {} {
3893 # By default, assume that all uClibc targets suffer from this.
3894 return [check_effective_target_uclibc]
3897 # Return 1 if this is a target for which wcsftime is a dummy
3898 # function that always returns 0.
3900 proc check_effective_target_dummy_wcsftime {} {
3901 # By default, assume that all uClibc targets suffer from this.
3902 return [check_effective_target_uclibc]
3905 # Return 1 if constructors with initialization priority arguments are
3906 # supposed on this target.
3908 proc check_effective_target_init_priority {} {
3909 return [check_no_compiler_messages init_priority assembly "
3910 void f() __attribute__((constructor (1000)));
3915 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3916 # This can be used with any check_* proc that takes no argument and
3917 # returns only 1 or 0. It could be used with check_* procs that take
3918 # arguments with keywords that pass particular arguments.
3920 proc is-effective-target { arg } {
3922 if { [info procs check_effective_target_${arg}] != [list] } {
3923 set selected [check_effective_target_${arg}]
3926 "vmx_hw" { set selected [check_vmx_hw_available] }
3927 "vsx_hw" { set selected [check_vsx_hw_available] }
3928 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3929 "named_sections" { set selected [check_named_sections_available] }
3930 "gc_sections" { set selected [check_gc_sections_available] }
3931 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3932 default { error "unknown effective target keyword `$arg'" }
3935 verbose "is-effective-target: $arg $selected" 2
3939 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3941 proc is-effective-target-keyword { arg } {
3942 if { [info procs check_effective_target_${arg}] != [list] } {
3945 # These have different names for their check_* procs.
3947 "vmx_hw" { return 1 }
3948 "vsx_hw" { return 1 }
3949 "ppc_recip_hw" { return 1 }
3950 "named_sections" { return 1 }
3951 "gc_sections" { return 1 }
3952 "cxa_atexit" { return 1 }
3953 default { return 0 }
3958 # Return 1 if target default to short enums
3960 proc check_effective_target_short_enums { } {
3961 return [check_no_compiler_messages short_enums assembly {
3963 int s[sizeof (enum foo) == 1 ? 1 : -1];
3967 # Return 1 if target supports merging string constants at link time.
3969 proc check_effective_target_string_merging { } {
3970 return [check_no_messages_and_pattern string_merging \
3971 "rodata\\.str" assembly {
3972 const char *var = "String";
3976 # Return 1 if target has the basic signed and unsigned types in
3977 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3978 # working <stdint.h> for all targets.
3980 proc check_effective_target_stdint_types { } {
3981 return [check_no_compiler_messages stdint_types assembly {
3983 int8_t a; int16_t b; int32_t c; int64_t d;
3984 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3988 # Return 1 if target has the basic signed and unsigned types in
3989 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3990 # these types agree with those in the header, as some systems have
3991 # only <inttypes.h>.
3993 proc check_effective_target_inttypes_types { } {
3994 return [check_no_compiler_messages inttypes_types assembly {
3995 #include <inttypes.h>
3996 int8_t a; int16_t b; int32_t c; int64_t d;
3997 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4001 # Return 1 if programs are intended to be run on a simulator
4002 # (i.e. slowly) rather than hardware (i.e. fast).
4004 proc check_effective_target_simulator { } {
4006 # All "src/sim" simulators set this one.
4007 if [board_info target exists is_simulator] {
4008 return [board_info target is_simulator]
4011 # The "sid" simulators don't set that one, but at least they set
4013 if [board_info target exists slow_simulator] {
4014 return [board_info target slow_simulator]
4020 # Return 1 if the target is a VxWorks kernel.
4022 proc check_effective_target_vxworks_kernel { } {
4023 return [check_no_compiler_messages vxworks_kernel assembly {
4024 #if !defined __vxworks || defined __RTP__
4030 # Return 1 if the target is a VxWorks RTP.
4032 proc check_effective_target_vxworks_rtp { } {
4033 return [check_no_compiler_messages vxworks_rtp assembly {
4034 #if !defined __vxworks || !defined __RTP__
4040 # Return 1 if the target is expected to provide wide character support.
4042 proc check_effective_target_wchar { } {
4043 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4046 return [check_no_compiler_messages wchar assembly {
4051 # Return 1 if the target has <pthread.h>.
4053 proc check_effective_target_pthread_h { } {
4054 return [check_no_compiler_messages pthread_h assembly {
4055 #include <pthread.h>
4059 # Return 1 if the target can truncate a file from a file-descriptor,
4060 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4061 # chsize. We test for a trivially functional truncation; no stubs.
4062 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4063 # different function to be used.
4065 proc check_effective_target_fd_truncate { } {
4067 #define _FILE_OFFSET_BITS 64
4073 FILE *f = fopen ("tst.tmp", "wb");
4075 const char t[] = "test writing more than ten characters";
4079 write (fd, t, sizeof (t) - 1);
4081 if (ftruncate (fd, 10) != 0)
4090 f = fopen ("tst.tmp", "rb");
4091 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4099 if { [check_runtime ftruncate $prog] } {
4103 regsub "ftruncate" $prog "chsize" prog
4104 return [check_runtime chsize $prog]
4107 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4109 proc add_options_for_c99_runtime { flags } {
4110 if { [istarget *-*-solaris2*] } {
4111 return "$flags -std=c99"
4113 if { [istarget mips-sgi-irix6.5*] } {
4114 return "$flags -std=c99"
4116 if { [istarget powerpc-*-darwin*] } {
4117 return "$flags -mmacosx-version-min=10.3"
4122 # Add to FLAGS all the target-specific flags needed to enable
4123 # full IEEE compliance mode.
4125 proc add_options_for_ieee { flags } {
4126 if { [istarget alpha*-*-*]
4127 || [istarget sh*-*-*] } {
4128 return "$flags -mieee"
4130 if { [istarget rx-*-*] } {
4131 return "$flags -mnofpu"
4136 # Add to FLAGS the flags needed to enable functions to bind locally
4137 # when using pic/PIC passes in the testsuite.
4139 proc add_options_for_bind_pic_locally { flags } {
4140 if {[check_no_compiler_messages using_pic2 assembly {
4145 return "$flags -fPIE"
4147 if {[check_no_compiler_messages using_pic1 assembly {
4152 return "$flags -fpie"
4158 # Add to FLAGS the flags needed to enable 64-bit vectors.
4160 proc add_options_for_double_vectors { flags } {
4161 if [is-effective-target arm_neon_ok] {
4162 return "$flags -mvectorize-with-neon-double"
4168 # Return 1 if the target provides a full C99 runtime.
4170 proc check_effective_target_c99_runtime { } {
4171 return [check_cached_effective_target c99_runtime {
4174 set file [open "$srcdir/gcc.dg/builtins-config.h"]
4175 set contents [read $file]
4178 #ifndef HAVE_C99_RUNTIME
4182 check_no_compiler_messages_nocache c99_runtime assembly \
4183 $contents [add_options_for_c99_runtime ""]
4187 # Return 1 if target wchar_t is at least 4 bytes.
4189 proc check_effective_target_4byte_wchar_t { } {
4190 return [check_no_compiler_messages 4byte_wchar_t object {
4191 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
4195 # Return 1 if the target supports automatic stack alignment.
4197 proc check_effective_target_automatic_stack_alignment { } {
4198 # Ordinarily x86 supports automatic stack alignment ...
4199 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
4200 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
4201 # ... except Win64 SEH doesn't. Succeed for Win32 though.
4202 return [check_effective_target_ilp32];
4209 # Return true if we are compiling for AVX target.
4211 proc check_avx_available { } {
4212 if { [check_no_compiler_messages avx_available assembly {
4222 # Return true if 32- and 16-bytes vectors are available.
4224 proc check_effective_target_vect_sizes_32B_16B { } {
4225 return [check_avx_available];
4228 # Return true if 128-bits vectors are preferred even if 256-bits vectors
4231 proc check_prefer_avx128 { } {
4232 if ![check_avx_available] {
4235 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
4236 float a[1024],b[1024],c[1024];
4237 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
4238 } "-O2 -ftree-vectorize"]
4242 # Return 1 if avx instructions can be compiled.
4244 proc check_effective_target_avx { } {
4245 return [check_no_compiler_messages avx object {
4246 void _mm256_zeroall (void)
4248 __builtin_ia32_vzeroall ();
4253 # Return 1 if sse instructions can be compiled.
4254 proc check_effective_target_sse { } {
4255 return [check_no_compiler_messages sse object {
4258 __builtin_ia32_stmxcsr ();
4264 # Return 1 if sse2 instructions can be compiled.
4265 proc check_effective_target_sse2 { } {
4266 return [check_no_compiler_messages sse2 object {
4267 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
4269 __m128i _mm_srli_si128 (__m128i __A, int __N)
4271 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
4276 # Return 1 if F16C instructions can be compiled.
4278 proc check_effective_target_f16c { } {
4279 return [check_no_compiler_messages f16c object {
4280 #include "immintrin.h"
4282 foo (unsigned short val)
4284 return _cvtsh_ss (val);
4289 # Return 1 if C wchar_t type is compatible with char16_t.
4291 proc check_effective_target_wchar_t_char16_t_compatible { } {
4292 return [check_no_compiler_messages wchar_t_char16_t object {
4294 __CHAR16_TYPE__ *p16 = &wc;
4295 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4299 # Return 1 if C wchar_t type is compatible with char32_t.
4301 proc check_effective_target_wchar_t_char32_t_compatible { } {
4302 return [check_no_compiler_messages wchar_t_char32_t object {
4304 __CHAR32_TYPE__ *p32 = &wc;
4305 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4309 # Return 1 if pow10 function exists.
4311 proc check_effective_target_pow10 { } {
4312 return [check_runtime pow10 {
4322 # Return 1 if current options generate DFP instructions, 0 otherwise.
4324 proc check_effective_target_hard_dfp {} {
4325 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
4326 typedef float d64 __attribute__((mode(DD)));
4328 void foo (void) { z = x + y; }
4332 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
4333 # for strchr etc. functions.
4335 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
4336 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
4339 #if !defined(__cplusplus) \
4340 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
4341 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
4342 ISO C++ correct string.h and wchar.h protos not supported.
4349 # Return 1 if GNU as is used.
4351 proc check_effective_target_gas { } {
4352 global use_gas_saved
4355 if {![info exists use_gas_saved]} {
4356 # Check if the as used by gcc is GNU as.
4357 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
4358 # Provide /dev/null as input, otherwise gas times out reading from
4360 set status [remote_exec host "$gcc_as" "-v /dev/null"]
4361 set as_output [lindex $status 1]
4362 if { [ string first "GNU" $as_output ] >= 0 } {
4368 return $use_gas_saved
4371 # Return 1 if GNU ld is used.
4373 proc check_effective_target_gld { } {
4374 global use_gld_saved
4377 if {![info exists use_gld_saved]} {
4378 # Check if the ld used by gcc is GNU ld.
4379 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
4380 set status [remote_exec host "$gcc_ld" "--version"]
4381 set ld_output [lindex $status 1]
4382 if { [ string first "GNU" $ld_output ] >= 0 } {
4388 return $use_gld_saved
4391 # Return 1 if the compiler has been configure with link-time optimization
4394 proc check_effective_target_lto { } {
4396 return [info exists ENABLE_LTO]
4399 # Return 1 if this target supports the -fsplit-stack option, 0
4402 proc check_effective_target_split_stack {} {
4403 return [check_no_compiler_messages split_stack object {
4408 # Return 1 if the language for the compiler under test is C.
4410 proc check_effective_target_c { } {
4412 if [string match $tool "gcc"] {
4418 # Return 1 if the language for the compiler under test is C++.
4420 proc check_effective_target_c++ { } {
4422 if [string match $tool "g++"] {
4428 # Check which language standard is active by checking for the presence of
4429 # one of the C++11 -std flags. This assumes that the default for the
4430 # compiler is C++98, and that there will never be multiple -std= arguments
4431 # on the command line.
4432 proc check_effective_target_c++11 { } {
4433 if ![check_effective_target_c++] {
4436 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4439 proc check_effective_target_c++98 { } {
4440 if ![check_effective_target_c++] {
4443 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4446 # Return 1 if expensive testcases should be run.
4448 proc check_effective_target_run_expensive_tests { } {
4449 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
4455 # Returns 1 if "mempcpy" is available on the target system.
4457 proc check_effective_target_mempcpy {} {
4458 return [check_function_available "mempcpy"]
4461 # Check whether the vectorizer tests are supported by the target and
4462 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
4463 # Set dg-do-what-default to either compile or run, depending on target
4464 # capabilities. Return 1 if vectorizer tests are supported by
4465 # target, 0 otherwise.
4467 proc check_vect_support_and_set_flags { } {
4468 global DEFAULT_VECTCFLAGS
4469 global dg-do-what-default
4471 if [istarget powerpc-*paired*] {
4472 lappend DEFAULT_VECTCFLAGS "-mpaired"
4473 if [check_750cl_hw_available] {
4474 set dg-do-what-default run
4476 set dg-do-what-default compile
4478 } elseif [istarget powerpc*-*-*] {
4479 # Skip targets not supporting -maltivec.
4480 if ![is-effective-target powerpc_altivec_ok] {
4484 lappend DEFAULT_VECTCFLAGS "-maltivec"
4485 if [check_vsx_hw_available] {
4486 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
4489 if [check_vmx_hw_available] {
4490 set dg-do-what-default run
4492 if [is-effective-target ilp32] {
4493 # Specify a cpu that supports VMX for compile-only tests.
4494 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
4496 set dg-do-what-default compile
4498 } elseif { [istarget spu-*-*] } {
4499 set dg-do-what-default run
4500 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4501 lappend DEFAULT_VECTCFLAGS "-msse2"
4502 if { [check_effective_target_sse2_runtime] } {
4503 set dg-do-what-default run
4505 set dg-do-what-default compile
4507 } elseif { [istarget mips*-*-*]
4508 && ([check_effective_target_mpaired_single]
4509 || [check_effective_target_mips_loongson])
4510 && [check_effective_target_nomips16] } {
4511 if { [check_effective_target_mpaired_single] } {
4512 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
4514 set dg-do-what-default run
4515 } elseif [istarget sparc*-*-*] {
4516 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
4517 if [check_effective_target_ultrasparc_hw] {
4518 set dg-do-what-default run
4520 set dg-do-what-default compile
4522 } elseif [istarget alpha*-*-*] {
4523 # Alpha's vectorization capabilities are extremely limited.
4524 # It's more effort than its worth disabling all of the tests
4525 # that it cannot pass. But if you actually want to see what
4526 # does work, command out the return.
4529 lappend DEFAULT_VECTCFLAGS "-mmax"
4530 if [check_alpha_max_hw_available] {
4531 set dg-do-what-default run
4533 set dg-do-what-default compile
4535 } elseif [istarget ia64-*-*] {
4536 set dg-do-what-default run
4537 } elseif [is-effective-target arm_neon_ok] {
4538 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
4539 # NEON does not support denormals, so is not used for vectorization by
4540 # default to avoid loss of precision. We must pass -ffast-math to test
4541 # vectorization of float operations.
4542 lappend DEFAULT_VECTCFLAGS "-ffast-math"
4543 if [is-effective-target arm_neon_hw] {
4544 set dg-do-what-default run
4546 set dg-do-what-default compile
4555 proc check_effective_target_non_strict_align {} {
4556 return [check_no_compiler_messages non_strict_align assembly {
4558 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
4560 void foo(void) { z = (c *) y; }
4564 # Return 1 if the target has <ucontext.h>.
4566 proc check_effective_target_ucontext_h { } {
4567 return [check_no_compiler_messages ucontext_h assembly {
4568 #include <ucontext.h>