1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 # 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 # and "// ObjC++" for ObjC++
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
42 verbose "check_compile tool: $tool for $basename"
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
49 switch -glob -- $contents {
50 "*! Fortran*" { set src ${basename}[pid].f90 }
51 "*// C++*" { set src ${basename}[pid].cc }
52 "*// ObjC++*" { set src ${basename}[pid].mm }
53 "*/* ObjC*" { set src ${basename}[pid].m }
56 "objc" { set src ${basename}[pid].m }
57 "obj-c++" { set src ${basename}[pid].mm }
58 default { set src ${basename}[pid].c }
63 set compile_type $type
65 assembly { set output ${basename}[pid].s }
66 object { set output ${basename}[pid].o }
67 executable { set output ${basename}[pid].exe }
69 set output ${basename}[pid].s
70 lappend options "additional_flags=-fdump-$type"
71 set compile_type assembly
77 set lines [${tool}_target_compile $src $output $compile_type "$options"]
80 set scan_output $output
81 # Don't try folding this into the switch above; calling "glob" before the
82 # file is created won't work.
83 if [regexp "rtl-(.*)" $type dummy rtl_type] {
84 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
88 return [list $lines $scan_output]
91 proc current_target_name { } {
93 if [info exists target_info(target,name)] {
94 set answer $target_info(target,name)
101 # Implement an effective-target check for property PROP by invoking
102 # the Tcl command ARGS and seeing if it returns true.
104 proc check_cached_effective_target { prop args } {
107 set target [current_target_name]
108 if {![info exists et_cache($prop,target)]
109 || $et_cache($prop,target) != $target} {
110 verbose "check_cached_effective_target $prop: checking $target" 2
111 set et_cache($prop,target) $target
112 set et_cache($prop,value) [uplevel eval $args]
114 set value $et_cache($prop,value)
115 verbose "check_cached_effective_target $prop: returning $value for $target" 2
119 # Like check_compile, but delete the output file and return true if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache {args} {
122 set result [eval check_compile $args]
123 set lines [lindex $result 0]
124 set output [lindex $result 1]
125 remote_file build delete $output
126 return [string match "" $lines]
129 # Like check_no_compiler_messages_nocache, but cache the result.
130 # PROP is the property we're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133 return [check_cached_effective_target $prop {
134 eval [list check_no_compiler_messages_nocache $prop] $args
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP, otherwise they satisfy it
142 # if they do match regular expression PATTERN. (PATTERN can start
143 # with something like "[!]" if the regular expression needs to match
144 # "!" as the first character.)
146 # Delete the output file before returning. The other arguments are
147 # as for check_compile.
148 proc check_no_messages_and_pattern_nocache {basename pattern args} {
151 set result [eval [list check_compile $basename] $args]
152 set lines [lindex $result 0]
153 set output [lindex $result 1]
156 if { [string match "" $lines] } {
157 set chan [open "$output"]
158 set invert [regexp {^!(.*)} $pattern dummy pattern]
159 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
163 remote_file build delete $output
167 # Like check_no_messages_and_pattern_nocache, but cache the result.
168 # PROP is the property we're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171 return [check_cached_effective_target $prop {
172 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
176 # Try to compile and run an executable from code CONTENTS. Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense. The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
183 set result [eval [list check_compile $basename executable $contents] $args]
184 set lines [lindex $result 0]
185 set output [lindex $result 1]
188 if { [string match "" $lines] } {
189 # No error messages, everything is OK.
190 set result [remote_load target "./$output" "" ""]
191 set status [lindex $result 0]
192 verbose "check_runtime_nocache $basename: status is <$status>" 2
193 if { $status == "pass" } {
197 remote_file build delete $output
201 # Like check_runtime_nocache, but cache the result. PROP is the
202 # property we're checking, and doubles as a prefix for temporary
204 proc check_runtime {prop args} {
207 return [check_cached_effective_target $prop {
208 eval [list check_runtime_nocache $prop] $args
212 ###############################
213 # proc check_weak_available { }
214 ###############################
216 # weak symbols are only supported in some configs/object formats
217 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
219 proc check_weak_available { } {
220 global target_triplet
223 # All mips targets should support it
225 if { [ string first "mips" $target_cpu ] >= 0 } {
229 # All solaris2 targets should support it
231 if { [regexp ".*-solaris2.*" $target_triplet] } {
235 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
237 if { [regexp "alpha.*osf.*" $target_triplet] } {
241 # Windows targets Cygwin and MingW32 support it
243 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
247 # HP-UX 10.X doesn't support it
249 if { [istarget "hppa*-*-hpux10*"] } {
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
256 set objformat [gcc_target_object_format]
264 unknown { return -1 }
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
276 proc check_weak_override_available { } {
277 if { [istarget "*-*-mingw*"] } {
280 return [check_weak_available]
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
291 proc check_visibility_available { what_kind } {
293 global target_triplet
295 # On NetWare, support makes no sense.
296 if { [istarget *-*-netware*] } {
300 if [string match "" $what_kind] { set what_kind "hidden" }
302 return [check_no_compiler_messages visibility_available_$what_kind object "
303 void f() __attribute__((visibility(\"$what_kind\")));
308 ###############################
309 # proc check_alias_available { }
310 ###############################
312 # Determine if the target toolchain supports the alias attribute.
314 # Returns 2 if the target supports aliases. Returns 1 if the target
315 # only supports weak aliased. Returns 0 if the target does not
316 # support aliases at all. Returns -1 if support for aliases could not
319 proc check_alias_available { } {
320 global alias_available_saved
323 if [info exists alias_available_saved] {
324 verbose "check_alias_available returning saved $alias_available_saved" 2
328 verbose "check_alias_available compiling testfile $src" 2
329 set f [open $src "w"]
330 # Compile a small test program. The definition of "g" is
331 # necessary to keep the Solaris assembler from complaining
333 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
336 set lines [${tool}_target_compile $src $obj object ""]
338 remote_file build delete $obj
340 if [string match "" $lines] then {
341 # No error messages, everything is OK.
342 set alias_available_saved 2
344 if [regexp "alias definitions not supported" $lines] {
345 verbose "check_alias_available target does not support aliases" 2
347 set objformat [gcc_target_object_format]
349 if { $objformat == "elf" } {
350 verbose "check_alias_available but target uses ELF format, so it ought to" 2
351 set alias_available_saved -1
353 set alias_available_saved 0
356 if [regexp "only weak aliases are supported" $lines] {
357 verbose "check_alias_available target supports only weak aliases" 2
358 set alias_available_saved 1
360 set alias_available_saved -1
365 verbose "check_alias_available returning $alias_available_saved" 2
368 return $alias_available_saved
371 ###############################
372 # proc check_ifunc_available { }
373 ###############################
375 # Determine if the target toolchain supports the ifunc attribute.
377 # Returns 1 if the target supports ifunc. Returns 0 if the target
378 # does not support ifunc.
380 proc check_ifunc_available { } {
381 global ifunc_available_saved
384 if [info exists ifunc_available_saved] {
385 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
389 verbose "check_ifunc_available compiling testfile $src" 2
390 set f [open $src "w"]
392 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
393 puts $f "void g() {}"
394 puts $f "void f() __attribute__((ifunc(\"g\")));"
396 set lines [${tool}_target_compile $src $obj object ""]
398 remote_file build delete $obj
400 if [string match "" $lines] then {
401 set ifunc_available_saved 1
403 set ifunc_available_saved 0
406 verbose "check_ifunc_available returning $ifunc_available_saved" 2
409 return $ifunc_available_saved
412 # Returns true if --gc-sections is supported on the target.
414 proc check_gc_sections_available { } {
415 global gc_sections_available_saved
418 if {![info exists gc_sections_available_saved]} {
419 # Some targets don't support gc-sections despite whatever's
420 # advertised by ld's options.
421 if { [istarget alpha*-*-*]
422 || [istarget ia64-*-*] } {
423 set gc_sections_available_saved 0
427 # elf2flt uses -q (--emit-relocs), which is incompatible with
429 if { [board_info target exists ldflags]
430 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
431 set gc_sections_available_saved 0
435 # VxWorks kernel modules are relocatable objects linked with -r,
436 # while RTP executables are linked with -q (--emit-relocs).
437 # Both of these options are incompatible with --gc-sections.
438 if { [istarget *-*-vxworks*] } {
439 set gc_sections_available_saved 0
443 # Check if the ld used by gcc supports --gc-sections.
444 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
445 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
446 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
447 set ld_output [remote_exec host "$gcc_ld" "--help"]
448 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
449 set gc_sections_available_saved 1
451 set gc_sections_available_saved 0
454 return $gc_sections_available_saved
457 # Return 1 if according to target_info struct and explicit target list
458 # target is supposed to support trampolines.
460 proc check_effective_target_trampolines { } {
461 if [target_info exists no_trampolines] {
464 if { [istarget avr-*-*]
465 || [istarget hppa2.0w-hp-hpux11.23]
466 || [istarget hppa64-hp-hpux11.23] } {
472 # Return 1 if according to target_info struct and explicit target list
473 # target is supposed to keep null pointer checks. This could be due to
474 # use of option fno-delete-null-pointer-checks or hardwired in target.
476 proc check_effective_target_keeps_null_pointer_checks { } {
477 if [target_info exists keeps_null_pointer_checks] {
480 if { [istarget avr-*-*] } {
486 # Return true if profiling is supported on the target.
488 proc check_profiling_available { test_what } {
489 global profiling_available_saved
491 verbose "Profiling argument is <$test_what>" 1
493 # These conditions depend on the argument so examine them before
494 # looking at the cache variable.
496 # Support for -p on solaris2 relies on mcrt1.o which comes with the
497 # vendor compiler. We cannot reliably predict the directory where the
498 # vendor compiler (and thus mcrt1.o) is installed so we can't
499 # necessarily find mcrt1.o even if we have it.
500 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
504 # Support for -p on irix relies on libprof1.a which doesn't appear to
505 # exist on any irix6 system currently posting testsuite results.
506 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
507 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
508 if { [istarget mips*-*-irix*]
509 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
513 # We don't yet support profiling for MIPS16.
514 if { [istarget mips*-*-*]
515 && ![check_effective_target_nomips16]
516 && ([lindex $test_what 1] == "-p"
517 || [lindex $test_what 1] == "-pg") } {
521 # MinGW does not support -p.
522 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
526 # cygwin does not support -p.
527 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
531 # uClibc does not have gcrt1.o.
532 if { [check_effective_target_uclibc]
533 && ([lindex $test_what 1] == "-p"
534 || [lindex $test_what 1] == "-pg") } {
538 # Now examine the cache variable.
539 if {![info exists profiling_available_saved]} {
540 # Some targets don't have any implementation of __bb_init_func or are
541 # missing other needed machinery.
542 if { [istarget mmix-*-*]
543 || [istarget arm*-*-eabi*]
544 || [istarget picochip-*-*]
545 || [istarget *-*-netware*]
546 || [istarget arm*-*-elf]
547 || [istarget arm*-*-symbianelf*]
548 || [istarget avr-*-*]
549 || [istarget bfin-*-*]
550 || [istarget powerpc-*-eabi*]
551 || [istarget powerpc-*-elf]
552 || [istarget cris-*-*]
553 || [istarget crisv32-*-*]
554 || [istarget fido-*-elf]
555 || [istarget h8300-*-*]
556 || [istarget lm32-*-*]
557 || [istarget m32c-*-elf]
558 || [istarget m68k-*-elf]
559 || [istarget m68k-*-uclinux*]
560 || [istarget mep-*-elf]
561 || [istarget mips*-*-elf*]
562 || [istarget moxie-*-elf*]
564 || [istarget xstormy16-*]
565 || [istarget xtensa*-*-elf]
566 || [istarget *-*-rtems*]
567 || [istarget *-*-vxworks*] } {
568 set profiling_available_saved 0
570 set profiling_available_saved 1
574 return $profiling_available_saved
577 # Check to see if a target is "freestanding". This is as per the definition
578 # in Section 4 of C99 standard. Effectively, it is a target which supports no
579 # extra headers or libraries other than what is considered essential.
580 proc check_effective_target_freestanding { } {
581 if { [istarget picochip-*-*] } then {
588 # Return 1 if target has packed layout of structure members by
589 # default, 0 otherwise. Note that this is slightly different than
590 # whether the target has "natural alignment": both attributes may be
593 proc check_effective_target_default_packed { } {
594 return [check_no_compiler_messages default_packed assembly {
595 struct x { char a; long b; } c;
596 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
600 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
601 # documentation, where the test also comes from.
603 proc check_effective_target_pcc_bitfield_type_matters { } {
604 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
605 # bitfields, but let's stick to the example code from the docs.
606 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
607 struct foo1 { char x; char :0; char y; };
608 struct foo2 { char x; int :0; char y; };
609 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
613 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
615 proc add_options_for_tls { flags } {
616 # Tru64 UNIX uses emutls, which relies on a couple of pthread functions
617 # which only live in libpthread, so always pass -pthread for TLS.
618 if { [istarget *-*-osf*] } {
619 return "$flags -pthread"
621 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
622 # libthread, so always pass -pthread for native TLS.
623 # Need to duplicate native TLS check from
624 # check_effective_target_tls_native to avoid recursion.
625 if { [istarget *-*-solaris2.\[89\]*] &&
626 [check_no_messages_and_pattern tls_native "!emutls" assembly {
628 int f (void) { return i; }
629 void g (int j) { i = j; }
631 return "$flags -pthread"
636 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
638 proc check_effective_target_tls {} {
639 return [check_no_compiler_messages tls assembly {
641 int f (void) { return i; }
642 void g (int j) { i = j; }
646 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
648 proc check_effective_target_tls_native {} {
649 # VxWorks uses emulated TLS machinery, but with non-standard helper
650 # functions, so we fail to automatically detect it.
651 global target_triplet
652 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
656 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
658 int f (void) { return i; }
659 void g (int j) { i = j; }
663 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
665 proc check_effective_target_tls_emulated {} {
666 # VxWorks uses emulated TLS machinery, but with non-standard helper
667 # functions, so we fail to automatically detect it.
668 global target_triplet
669 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
673 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
675 int f (void) { return i; }
676 void g (int j) { i = j; }
680 # Return 1 if TLS executables can run correctly, 0 otherwise.
682 proc check_effective_target_tls_runtime {} {
683 return [check_runtime tls_runtime {
684 __thread int thr = 0;
685 int main (void) { return thr; }
689 # Return 1 if -ffunction-sections is supported, 0 otherwise.
691 proc check_effective_target_function_sections {} {
692 # Darwin has its own scheme and silently accepts -ffunction-sections.
693 global target_triplet
694 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
698 return [check_no_compiler_messages functionsections assembly {
700 } "-ffunction-sections"]
703 # Return 1 if compilation with -fgraphite is error-free for trivial
706 proc check_effective_target_fgraphite {} {
707 return [check_no_compiler_messages fgraphite object {
712 # Return 1 if compilation with -fopenmp is error-free for trivial
715 proc check_effective_target_fopenmp {} {
716 return [check_no_compiler_messages fopenmp object {
721 # Return 1 if compilation with -pthread is error-free for trivial
724 proc check_effective_target_pthread {} {
725 return [check_no_compiler_messages pthread object {
730 # Return 1 if compilation with -mpe-aligned-commons is error-free
731 # for trivial code, 0 otherwise.
733 proc check_effective_target_pe_aligned_commons {} {
734 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
735 return [check_no_compiler_messages pe_aligned_commons object {
737 } "-mpe-aligned-commons"]
742 # Return 1 if the target supports -static
743 proc check_effective_target_static {} {
744 return [check_no_compiler_messages static executable {
745 int main (void) { return 0; }
749 # Return 1 if the target supports -fstack-protector
750 proc check_effective_target_fstack_protector {} {
751 return [check_runtime fstack_protector {
752 int main (void) { return 0; }
753 } "-fstack-protector"]
756 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
757 # for trivial code, 0 otherwise.
759 proc check_effective_target_freorder {} {
760 return [check_no_compiler_messages freorder object {
762 } "-freorder-blocks-and-partition"]
765 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
766 # emitted, 0 otherwise. Whether a shared library can actually be built is
767 # out of scope for this test.
769 proc check_effective_target_fpic { } {
770 # Note that M68K has a multilib that supports -fpic but not
771 # -fPIC, so we need to check both. We test with a program that
772 # requires GOT references.
773 foreach arg {fpic fPIC} {
774 if [check_no_compiler_messages $arg object {
775 extern int foo (void); extern int bar;
776 int baz (void) { return foo () + bar; }
784 # Return true if the target supports -mpaired-single (as used on MIPS).
786 proc check_effective_target_mpaired_single { } {
787 return [check_no_compiler_messages mpaired_single object {
792 # Return true if the target has access to FPU instructions.
794 proc check_effective_target_hard_float { } {
795 if { [istarget mips*-*-*] } {
796 return [check_no_compiler_messages hard_float assembly {
797 #if (defined __mips_soft_float || defined __mips16)
803 # This proc is actually checking the availabilty of FPU
804 # support for doubles, so on the RX we must fail if the
805 # 64-bit double multilib has been selected.
806 if { [istarget rx-*-*] } {
808 # return [check_no_compiler_messages hard_float assembly {
809 #if defined __RX_64_BIT_DOUBLES__
815 # The generic test equates hard_float with "no call for adding doubles".
816 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
817 double a (double b, double c) { return b + c; }
821 # Return true if the target is a 64-bit MIPS target.
823 proc check_effective_target_mips64 { } {
824 return [check_no_compiler_messages mips64 assembly {
831 # Return true if the target is a MIPS target that does not produce
834 proc check_effective_target_nomips16 { } {
835 return [check_no_compiler_messages nomips16 object {
839 /* A cheap way of testing for -mflip-mips16. */
840 void foo (void) { asm ("addiu $20,$20,1"); }
841 void bar (void) { asm ("addiu $20,$20,1"); }
846 # Add the options needed for MIPS16 function attributes. At the moment,
847 # we don't support MIPS16 PIC.
849 proc add_options_for_mips16_attribute { flags } {
850 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
853 # Return true if we can force a mode that allows MIPS16 code generation.
854 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
857 proc check_effective_target_mips16_attribute { } {
858 return [check_no_compiler_messages mips16_attribute assembly {
862 #if defined __mips_hard_float \
863 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
864 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
867 } [add_options_for_mips16_attribute ""]]
870 # Return 1 if the target supports long double larger than double when
871 # using the new ABI, 0 otherwise.
873 proc check_effective_target_mips_newabi_large_long_double { } {
874 return [check_no_compiler_messages mips_newabi_large_long_double object {
875 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
879 # Return 1 if the current multilib does not generate PIC by default.
881 proc check_effective_target_nonpic { } {
882 return [check_no_compiler_messages nonpic assembly {
889 # Return 1 if the target does not use a status wrapper.
891 proc check_effective_target_unwrapped { } {
892 if { [target_info needs_status_wrapper] != "" \
893 && [target_info needs_status_wrapper] != "0" } {
899 # Return true if iconv is supported on the target. In particular IBM1047.
901 proc check_iconv_available { test_what } {
904 # If the tool configuration file has not set libiconv, try "-liconv"
905 if { ![info exists libiconv] } {
906 set libiconv "-liconv"
908 set test_what [lindex $test_what 1]
909 return [check_runtime_nocache $test_what [subst {
915 cd = iconv_open ("$test_what", "UTF-8");
916 if (cd == (iconv_t) -1)
923 # Return true if named sections are supported on this target.
925 proc check_named_sections_available { } {
926 return [check_no_compiler_messages named_sections assembly {
927 int __attribute__ ((section("whatever"))) foo;
931 # Return 1 if the target supports Fortran real kinds larger than real(8),
934 # When the target name changes, replace the cached result.
936 proc check_effective_target_fortran_large_real { } {
937 return [check_no_compiler_messages fortran_large_real executable {
939 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
946 # Return 1 if the target supports Fortran integer kinds larger than
947 # integer(8), 0 otherwise.
949 # When the target name changes, replace the cached result.
951 proc check_effective_target_fortran_large_int { } {
952 return [check_no_compiler_messages fortran_large_int executable {
954 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
960 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
962 # When the target name changes, replace the cached result.
964 proc check_effective_target_fortran_integer_16 { } {
965 return [check_no_compiler_messages fortran_integer_16 executable {
972 # Return 1 if we can statically link libgfortran, 0 otherwise.
974 # When the target name changes, replace the cached result.
976 proc check_effective_target_static_libgfortran { } {
977 return [check_no_compiler_messages static_libgfortran executable {
984 proc check_linker_plugin_available { } {
985 return [check_no_compiler_messages_nocache linker_plugin executable {
986 int main() { return 0; }
987 } "-flto -fuse-linker-plugin"]
990 # Return 1 if the target supports executing 750CL paired-single instructions, 0
991 # otherwise. Cache the result.
993 proc check_750cl_hw_available { } {
994 return [check_cached_effective_target 750cl_hw_available {
995 # If this is not the right target then we can skip the test.
996 if { ![istarget powerpc-*paired*] } {
999 check_runtime_nocache 750cl_hw_available {
1003 asm volatile ("ps_mul v0,v0,v0");
1005 asm volatile ("ps_mul 0,0,0");
1014 # Return 1 if the target OS supports running SSE executables, 0
1015 # otherwise. Cache the result.
1017 proc check_sse_os_support_available { } {
1018 return [check_cached_effective_target sse_os_support_available {
1019 # If this is not the right target then we can skip the test.
1020 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1022 } elseif { [istarget i?86-*-solaris2*] } {
1023 # The Solaris 2 kernel doesn't save and restore SSE registers
1024 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1025 check_runtime_nocache sse_os_support_available {
1028 __asm__ volatile ("movss %xmm2,%xmm1");
1038 # Return 1 if the target supports executing SSE instructions, 0
1039 # otherwise. Cache the result.
1041 proc check_sse_hw_available { } {
1042 return [check_cached_effective_target sse_hw_available {
1043 # If this is not the right target then we can skip the test.
1044 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1047 check_runtime_nocache sse_hw_available {
1051 unsigned int eax, ebx, ecx, edx;
1052 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1053 return !(edx & bit_SSE);
1061 # Return 1 if the target supports executing SSE2 instructions, 0
1062 # otherwise. Cache the result.
1064 proc check_sse2_hw_available { } {
1065 return [check_cached_effective_target sse2_hw_available {
1066 # If this is not the right target then we can skip the test.
1067 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1070 check_runtime_nocache sse2_hw_available {
1074 unsigned int eax, ebx, ecx, edx;
1075 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1076 return !(edx & bit_SSE2);
1084 # Return 1 if the target supports executing AVX instructions, 0
1085 # otherwise. Cache the result.
1087 proc check_avx_hw_available { } {
1088 return [check_cached_effective_target avx_hw_available {
1089 # If this is not the right target then we can skip the test.
1090 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1093 check_runtime_nocache avx_hw_available {
1097 unsigned int eax, ebx, ecx, edx;
1098 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1099 return ((ecx & (bit_AVX | bit_OSXSAVE))
1100 != (bit_AVX | bit_OSXSAVE));
1108 # Return 1 if the target supports running SSE executables, 0 otherwise.
1110 proc check_effective_target_sse_runtime { } {
1111 if { [check_effective_target_sse]
1112 && [check_sse_hw_available]
1113 && [check_sse_os_support_available] } {
1119 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1121 proc check_effective_target_sse2_runtime { } {
1122 if { [check_effective_target_sse2]
1123 && [check_sse2_hw_available]
1124 && [check_sse_os_support_available] } {
1130 # Return 1 if the target supports running AVX executables, 0 otherwise.
1132 proc check_effective_target_avx_runtime { } {
1133 if { [check_effective_target_avx]
1134 && [check_avx_hw_available] } {
1140 # Return 1 if the target supports executing VSX instructions, 0
1141 # otherwise. Cache the result.
1143 proc check_vsx_hw_available { } {
1144 return [check_cached_effective_target vsx_hw_available {
1145 # Some simulators are known to not support VSX instructions.
1146 # For now, disable on Darwin
1147 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1151 check_runtime_nocache vsx_hw_available {
1155 asm volatile ("xxlor vs0,vs0,vs0");
1157 asm volatile ("xxlor 0,0,0");
1166 # Return 1 if the target supports executing AltiVec instructions, 0
1167 # otherwise. Cache the result.
1169 proc check_vmx_hw_available { } {
1170 return [check_cached_effective_target vmx_hw_available {
1171 # Some simulators are known to not support VMX instructions.
1172 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1175 # Most targets don't require special flags for this test case, but
1176 # Darwin does. Just to be sure, make sure VSX is not enabled for
1177 # the altivec tests.
1178 if { [istarget *-*-darwin*]
1179 || [istarget *-*-aix*] } {
1180 set options "-maltivec -mno-vsx"
1182 set options "-mno-vsx"
1184 check_runtime_nocache vmx_hw_available {
1188 asm volatile ("vor v0,v0,v0");
1190 asm volatile ("vor 0,0,0");
1199 proc check_ppc_recip_hw_available { } {
1200 return [check_cached_effective_target ppc_recip_hw_available {
1201 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1202 # For now, disable on Darwin
1203 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1206 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1207 check_runtime_nocache ppc_recip_hw_available {
1208 volatile double d_recip, d_rsqrt, d_four = 4.0;
1209 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1212 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1213 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1214 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1215 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1223 # Return 1 if the target supports executing AltiVec and Cell PPU
1224 # instructions, 0 otherwise. Cache the result.
1226 proc check_effective_target_cell_hw { } {
1227 return [check_cached_effective_target cell_hw_available {
1228 # Some simulators are known to not support VMX and PPU instructions.
1229 if { [istarget powerpc-*-eabi*] } {
1232 # Most targets don't require special flags for this test
1233 # case, but Darwin and AIX do.
1234 if { [istarget *-*-darwin*]
1235 || [istarget *-*-aix*] } {
1236 set options "-maltivec -mcpu=cell"
1238 set options "-mcpu=cell"
1240 check_runtime_nocache cell_hw_available {
1244 asm volatile ("vor v0,v0,v0");
1245 asm volatile ("lvlx v0,r0,r0");
1247 asm volatile ("vor 0,0,0");
1248 asm volatile ("lvlx 0,0,0");
1257 # Return 1 if the target supports executing 64-bit instructions, 0
1258 # otherwise. Cache the result.
1260 proc check_effective_target_powerpc64 { } {
1261 global powerpc64_available_saved
1264 if [info exists powerpc64_available_saved] {
1265 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1267 set powerpc64_available_saved 0
1269 # Some simulators are known to not support powerpc64 instructions.
1270 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1271 verbose "check_effective_target_powerpc64 returning 0" 2
1272 return $powerpc64_available_saved
1275 # Set up, compile, and execute a test program containing a 64-bit
1276 # instruction. Include the current process ID in the file
1277 # names to prevent conflicts with invocations for multiple
1282 set f [open $src "w"]
1283 puts $f "int main() {"
1284 puts $f "#ifdef __MACH__"
1285 puts $f " asm volatile (\"extsw r0,r0\");"
1287 puts $f " asm volatile (\"extsw 0,0\");"
1289 puts $f " return 0; }"
1292 set opts "additional_flags=-mcpu=G5"
1294 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1295 set lines [${tool}_target_compile $src $exe executable "$opts"]
1298 if [string match "" $lines] then {
1299 # No error message, compilation succeeded.
1300 set result [${tool}_load "./$exe" "" ""]
1301 set status [lindex $result 0]
1302 remote_file build delete $exe
1303 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1305 if { $status == "pass" } then {
1306 set powerpc64_available_saved 1
1309 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1313 return $powerpc64_available_saved
1316 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1317 # complex float arguments. This affects gfortran tests that call cabsf
1318 # in libm built by an earlier compiler. Return 1 if libm uses the same
1319 # argument passing as the compiler under test, 0 otherwise.
1321 # When the target name changes, replace the cached result.
1323 proc check_effective_target_broken_cplxf_arg { } {
1324 return [check_cached_effective_target broken_cplxf_arg {
1325 # Skip the work for targets known not to be affected.
1326 if { ![istarget powerpc64-*-linux*] } {
1328 } elseif { ![is-effective-target lp64] } {
1331 check_runtime_nocache broken_cplxf_arg {
1332 #include <complex.h>
1333 extern void abort (void);
1334 float fabsf (float);
1335 float cabsf (_Complex float);
1342 if (fabsf (f - 5.0) > 0.0001)
1351 proc check_alpha_max_hw_available { } {
1352 return [check_runtime alpha_max_hw_available {
1353 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1357 # Returns true iff the FUNCTION is available on the target system.
1358 # (This is essentially a Tcl implementation of Autoconf's
1361 proc check_function_available { function } {
1362 return [check_no_compiler_messages ${function}_available \
1368 int main () { $function (); }
1372 # Returns true iff "fork" is available on the target system.
1374 proc check_fork_available {} {
1375 return [check_function_available "fork"]
1378 # Returns true iff "mkfifo" is available on the target system.
1380 proc check_mkfifo_available {} {
1381 if {[istarget *-*-cygwin*]} {
1382 # Cygwin has mkfifo, but support is incomplete.
1386 return [check_function_available "mkfifo"]
1389 # Returns true iff "__cxa_atexit" is used on the target system.
1391 proc check_cxa_atexit_available { } {
1392 return [check_cached_effective_target cxa_atexit_available {
1393 if { [istarget "hppa*-*-hpux10*"] } {
1394 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1396 } elseif { [istarget "*-*-vxworks"] } {
1397 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1400 check_runtime_nocache cxa_atexit_available {
1403 static unsigned int count;
1420 Y() { f(); count = 2; }
1429 int main() { return 0; }
1435 proc check_effective_target_objc2 { } {
1436 return [check_no_compiler_messages objc2 object {
1445 proc check_effective_target_next_runtime { } {
1446 return [check_no_compiler_messages objc2 object {
1447 #ifdef __NEXT_RUNTIME__
1455 # Return 1 if we're generating 32-bit code using default options, 0
1458 proc check_effective_target_ilp32 { } {
1459 return [check_no_compiler_messages ilp32 object {
1460 int dummy[sizeof (int) == 4
1461 && sizeof (void *) == 4
1462 && sizeof (long) == 4 ? 1 : -1];
1466 # Return 1 if we're generating 32-bit or larger integers using default
1467 # options, 0 otherwise.
1469 proc check_effective_target_int32plus { } {
1470 return [check_no_compiler_messages int32plus object {
1471 int dummy[sizeof (int) >= 4 ? 1 : -1];
1475 # Return 1 if we're generating 32-bit or larger pointers using default
1476 # options, 0 otherwise.
1478 proc check_effective_target_ptr32plus { } {
1479 return [check_no_compiler_messages ptr32plus object {
1480 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1484 # Return 1 if we support 32-bit or larger array and structure sizes
1485 # using default options, 0 otherwise.
1487 proc check_effective_target_size32plus { } {
1488 return [check_no_compiler_messages size32plus object {
1493 # Returns 1 if we're generating 16-bit or smaller integers with the
1494 # default options, 0 otherwise.
1496 proc check_effective_target_int16 { } {
1497 return [check_no_compiler_messages int16 object {
1498 int dummy[sizeof (int) < 4 ? 1 : -1];
1502 # Return 1 if we're generating 64-bit code using default options, 0
1505 proc check_effective_target_lp64 { } {
1506 return [check_no_compiler_messages lp64 object {
1507 int dummy[sizeof (int) == 4
1508 && sizeof (void *) == 8
1509 && sizeof (long) == 8 ? 1 : -1];
1513 # Return 1 if we're generating 64-bit code using default llp64 options,
1516 proc check_effective_target_llp64 { } {
1517 return [check_no_compiler_messages llp64 object {
1518 int dummy[sizeof (int) == 4
1519 && sizeof (void *) == 8
1520 && sizeof (long long) == 8
1521 && sizeof (long) == 4 ? 1 : -1];
1525 # Return 1 if the target supports long double larger than double,
1528 proc check_effective_target_large_long_double { } {
1529 return [check_no_compiler_messages large_long_double object {
1530 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1534 # Return 1 if the target supports double larger than float,
1537 proc check_effective_target_large_double { } {
1538 return [check_no_compiler_messages large_double object {
1539 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1543 # Return 1 if the target supports double of 64 bits,
1546 proc check_effective_target_double64 { } {
1547 return [check_no_compiler_messages double64 object {
1548 int dummy[sizeof(double) == 8 ? 1 : -1];
1552 # Return 1 if the target supports double of at least 64 bits,
1555 proc check_effective_target_double64plus { } {
1556 return [check_no_compiler_messages double64plus object {
1557 int dummy[sizeof(double) >= 8 ? 1 : -1];
1561 # Return 1 if the target supports compiling fixed-point,
1564 proc check_effective_target_fixed_point { } {
1565 return [check_no_compiler_messages fixed_point object {
1566 _Sat _Fract x; _Sat _Accum y;
1570 # Return 1 if the target supports compiling decimal floating point,
1573 proc check_effective_target_dfp_nocache { } {
1574 verbose "check_effective_target_dfp_nocache: compiling source" 2
1575 set ret [check_no_compiler_messages_nocache dfp object {
1576 float x __attribute__((mode(DD)));
1578 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1582 proc check_effective_target_dfprt_nocache { } {
1583 return [check_runtime_nocache dfprt {
1584 typedef float d64 __attribute__((mode(DD)));
1585 d64 x = 1.2df, y = 2.3dd, z;
1586 int main () { z = x + y; return 0; }
1590 # Return 1 if the target supports compiling Decimal Floating Point,
1593 # This won't change for different subtargets so cache the result.
1595 proc check_effective_target_dfp { } {
1596 return [check_cached_effective_target dfp {
1597 check_effective_target_dfp_nocache
1601 # Return 1 if the target supports linking and executing Decimal Floating
1602 # Point, 0 otherwise.
1604 # This won't change for different subtargets so cache the result.
1606 proc check_effective_target_dfprt { } {
1607 return [check_cached_effective_target dfprt {
1608 check_effective_target_dfprt_nocache
1612 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1614 proc check_effective_target_ucn_nocache { } {
1615 # -std=c99 is only valid for C
1616 if [check_effective_target_c] {
1617 set ucnopts "-std=c99"
1619 append ucnopts " -fextended-identifiers"
1620 verbose "check_effective_target_ucn_nocache: compiling source" 2
1621 set ret [check_no_compiler_messages_nocache ucn object {
1624 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1628 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1630 # This won't change for different subtargets, so cache the result.
1632 proc check_effective_target_ucn { } {
1633 return [check_cached_effective_target ucn {
1634 check_effective_target_ucn_nocache
1638 # Return 1 if the target needs a command line argument to enable a SIMD
1641 proc check_effective_target_vect_cmdline_needed { } {
1642 global et_vect_cmdline_needed_saved
1643 global et_vect_cmdline_needed_target_name
1645 if { ![info exists et_vect_cmdline_needed_target_name] } {
1646 set et_vect_cmdline_needed_target_name ""
1649 # If the target has changed since we set the cached value, clear it.
1650 set current_target [current_target_name]
1651 if { $current_target != $et_vect_cmdline_needed_target_name } {
1652 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1653 set et_vect_cmdline_needed_target_name $current_target
1654 if { [info exists et_vect_cmdline_needed_saved] } {
1655 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1656 unset et_vect_cmdline_needed_saved
1660 if [info exists et_vect_cmdline_needed_saved] {
1661 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1663 set et_vect_cmdline_needed_saved 1
1664 if { [istarget alpha*-*-*]
1665 || [istarget ia64-*-*]
1666 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1667 && [check_effective_target_lp64])
1668 || ([istarget powerpc*-*-*]
1669 && ([check_effective_target_powerpc_spe]
1670 || [check_effective_target_powerpc_altivec]))
1671 || [istarget spu-*-*]
1672 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1673 set et_vect_cmdline_needed_saved 0
1677 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1678 return $et_vect_cmdline_needed_saved
1681 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1683 # This won't change for different subtargets so cache the result.
1685 proc check_effective_target_vect_int { } {
1686 global et_vect_int_saved
1688 if [info exists et_vect_int_saved] {
1689 verbose "check_effective_target_vect_int: using cached result" 2
1691 set et_vect_int_saved 0
1692 if { [istarget i?86-*-*]
1693 || ([istarget powerpc*-*-*]
1694 && ![istarget powerpc-*-linux*paired*])
1695 || [istarget spu-*-*]
1696 || [istarget x86_64-*-*]
1697 || [istarget sparc*-*-*]
1698 || [istarget alpha*-*-*]
1699 || [istarget ia64-*-*]
1700 || [check_effective_target_arm32]
1701 || ([istarget mips*-*-*]
1702 && [check_effective_target_mips_loongson]) } {
1703 set et_vect_int_saved 1
1707 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1708 return $et_vect_int_saved
1711 # Return 1 if the target supports signed int->float conversion
1714 proc check_effective_target_vect_intfloat_cvt { } {
1715 global et_vect_intfloat_cvt_saved
1717 if [info exists et_vect_intfloat_cvt_saved] {
1718 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1720 set et_vect_intfloat_cvt_saved 0
1721 if { [istarget i?86-*-*]
1722 || ([istarget powerpc*-*-*]
1723 && ![istarget powerpc-*-linux*paired*])
1724 || [istarget x86_64-*-*] } {
1725 set et_vect_intfloat_cvt_saved 1
1729 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1730 return $et_vect_intfloat_cvt_saved
1733 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1735 proc check_effective_target_int128 { } {
1736 return [check_no_compiler_messages int128 object {
1738 #ifndef __SIZEOF_INT128__
1747 # Return 1 if the target supports unsigned int->float conversion
1750 proc check_effective_target_vect_uintfloat_cvt { } {
1751 global et_vect_uintfloat_cvt_saved
1753 if [info exists et_vect_uintfloat_cvt_saved] {
1754 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1756 set et_vect_uintfloat_cvt_saved 0
1757 if { [istarget i?86-*-*]
1758 || ([istarget powerpc*-*-*]
1759 && ![istarget powerpc-*-linux*paired*])
1760 || [istarget x86_64-*-*] } {
1761 set et_vect_uintfloat_cvt_saved 1
1765 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1766 return $et_vect_uintfloat_cvt_saved
1770 # Return 1 if the target supports signed float->int conversion
1773 proc check_effective_target_vect_floatint_cvt { } {
1774 global et_vect_floatint_cvt_saved
1776 if [info exists et_vect_floatint_cvt_saved] {
1777 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1779 set et_vect_floatint_cvt_saved 0
1780 if { [istarget i?86-*-*]
1781 || ([istarget powerpc*-*-*]
1782 && ![istarget powerpc-*-linux*paired*])
1783 || [istarget x86_64-*-*] } {
1784 set et_vect_floatint_cvt_saved 1
1788 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1789 return $et_vect_floatint_cvt_saved
1792 # Return 1 if the target supports unsigned float->int conversion
1795 proc check_effective_target_vect_floatuint_cvt { } {
1796 global et_vect_floatuint_cvt_saved
1798 if [info exists et_vect_floatuint_cvt_saved] {
1799 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1801 set et_vect_floatuint_cvt_saved 0
1802 if { ([istarget powerpc*-*-*]
1803 && ![istarget powerpc-*-linux*paired*]) } {
1804 set et_vect_floatuint_cvt_saved 1
1808 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1809 return $et_vect_floatuint_cvt_saved
1812 # Return 1 is this is an arm target using 32-bit instructions
1813 proc check_effective_target_arm32 { } {
1814 return [check_no_compiler_messages arm32 assembly {
1815 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1821 # Return 1 if this is an ARM target that only supports aligned vector accesses
1822 proc check_effective_target_arm_vect_no_misalign { } {
1823 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1824 #if !defined(__arm__) \
1825 || (defined(__ARMEL__) \
1826 && (!defined(__thumb__) || defined(__thumb2__)))
1833 # Return 1 if this is an ARM target supporting -mfpu=vfp
1834 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1837 proc check_effective_target_arm_vfp_ok { } {
1838 if { [check_effective_target_arm32] } {
1839 return [check_no_compiler_messages arm_vfp_ok object {
1841 } "-mfpu=vfp -mfloat-abi=softfp"]
1847 # Return 1 if this is an ARM target supporting -mfpu=vfp
1848 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1851 proc check_effective_target_arm_hard_vfp_ok { } {
1852 if { [check_effective_target_arm32] } {
1853 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1854 int main() { return 0;}
1855 } "-mfpu=vfp -mfloat-abi=hard"]
1861 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1862 # or -mfloat-abi=hard, but if one is already specified by the
1863 # multilib, use it. Similarly, if a -mfpu option already enables
1864 # NEON, do not add -mfpu=neon.
1866 proc add_options_for_arm_neon { flags } {
1867 if { ! [check_effective_target_arm_neon_ok] } {
1870 global et_arm_neon_flags
1871 return "$flags $et_arm_neon_flags"
1874 # Return 1 if this is an ARM target supporting -mfpu=neon
1875 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1876 # incompatible with these options. Also set et_arm_neon_flags to the
1877 # best options to add.
1879 proc check_effective_target_arm_neon_ok_nocache { } {
1880 global et_arm_neon_flags
1881 set et_arm_neon_flags ""
1882 if { [check_effective_target_arm32] } {
1883 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1884 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1885 #include "arm_neon.h"
1888 set et_arm_neon_flags $flags
1897 proc check_effective_target_arm_neon_ok { } {
1898 return [check_cached_effective_target arm_neon_ok \
1899 check_effective_target_arm_neon_ok_nocache]
1902 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1903 # or -mfloat-abi=hard, but if one is already specified by the
1906 proc add_options_for_arm_neon_fp16 { flags } {
1907 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1910 global et_arm_neon_fp16_flags
1911 return "$flags $et_arm_neon_fp16_flags"
1914 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1915 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1916 # incompatible with these options. Also set et_arm_neon_flags to the
1917 # best options to add.
1919 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1920 global et_arm_neon_fp16_flags
1921 set et_arm_neon_fp16_flags ""
1922 if { [check_effective_target_arm32] } {
1923 # Always add -mfpu=neon-fp16, since there is no preprocessor
1924 # macro for FP16 support.
1925 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1926 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1927 #include "arm_neon.h"
1930 set et_arm_neon_fp16_flags $flags
1939 proc check_effective_target_arm_neon_fp16_ok { } {
1940 return [check_cached_effective_target arm_neon_fp16_ok \
1941 check_effective_target_arm_neon_fp16_ok_nocache]
1944 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1947 proc check_effective_target_arm_thumb1_ok { } {
1948 return [check_no_compiler_messages arm_thumb1_ok assembly {
1949 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1955 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1958 proc check_effective_target_arm_thumb2_ok { } {
1959 return [check_no_compiler_messages arm_thumb2_ok assembly {
1960 #if !defined(__thumb2__)
1966 # Return 1 if the target supports executing NEON instructions, 0
1967 # otherwise. Cache the result.
1969 proc check_effective_target_arm_neon_hw { } {
1970 return [check_runtime arm_neon_hw_available {
1974 long long a = 0, b = 1;
1975 asm ("vorr %P0, %P1, %P2"
1977 : "0" (a), "w" (b));
1980 } [add_options_for_arm_neon ""]]
1983 # Return 1 if this is a ARM target with NEON enabled.
1985 proc check_effective_target_arm_neon { } {
1986 if { [check_effective_target_arm32] } {
1987 return [check_no_compiler_messages arm_neon object {
1988 #ifndef __ARM_NEON__
1999 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2000 # the Loongson vector modes.
2002 proc check_effective_target_mips_loongson { } {
2003 return [check_no_compiler_messages loongson assembly {
2004 #if !defined(__mips_loongson_vector_rev)
2010 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2013 proc check_effective_target_arm_eabi { } {
2014 return [check_no_compiler_messages arm_eabi object {
2015 #ifndef __ARM_EABI__
2023 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2024 # Some multilibs may be incompatible with this option.
2026 proc check_effective_target_arm_iwmmxt_ok { } {
2027 if { [check_effective_target_arm32] } {
2028 return [check_no_compiler_messages arm_iwmmxt_ok object {
2036 # Return 1 if this is a PowerPC target with floating-point registers.
2038 proc check_effective_target_powerpc_fprs { } {
2039 if { [istarget powerpc*-*-*]
2040 || [istarget rs6000-*-*] } {
2041 return [check_no_compiler_messages powerpc_fprs object {
2053 # Return 1 if this is a PowerPC target with hardware double-precision
2056 proc check_effective_target_powerpc_hard_double { } {
2057 if { [istarget powerpc*-*-*]
2058 || [istarget rs6000-*-*] } {
2059 return [check_no_compiler_messages powerpc_hard_double object {
2071 # Return 1 if this is a PowerPC target supporting -maltivec.
2073 proc check_effective_target_powerpc_altivec_ok { } {
2074 if { ([istarget powerpc*-*-*]
2075 && ![istarget powerpc-*-linux*paired*])
2076 || [istarget rs6000-*-*] } {
2077 # AltiVec is not supported on AIX before 5.3.
2078 if { [istarget powerpc*-*-aix4*]
2079 || [istarget powerpc*-*-aix5.1*]
2080 || [istarget powerpc*-*-aix5.2*] } {
2083 return [check_no_compiler_messages powerpc_altivec_ok object {
2091 # Return 1 if this is a PowerPC target supporting -mvsx
2093 proc check_effective_target_powerpc_vsx_ok { } {
2094 if { ([istarget powerpc*-*-*]
2095 && ![istarget powerpc-*-linux*paired*])
2096 || [istarget rs6000-*-*] } {
2097 # AltiVec is not supported on AIX before 5.3.
2098 if { [istarget powerpc*-*-aix4*]
2099 || [istarget powerpc*-*-aix5.1*]
2100 || [istarget powerpc*-*-aix5.2*] } {
2103 return [check_no_compiler_messages powerpc_vsx_ok object {
2106 asm volatile ("xxlor vs0,vs0,vs0");
2108 asm volatile ("xxlor 0,0,0");
2118 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2120 proc check_effective_target_powerpc_ppu_ok { } {
2121 if [check_effective_target_powerpc_altivec_ok] {
2122 return [check_no_compiler_messages cell_asm_available object {
2125 asm volatile ("lvlx v0,v0,v0");
2127 asm volatile ("lvlx 0,0,0");
2137 # Return 1 if this is a PowerPC target that supports SPU.
2139 proc check_effective_target_powerpc_spu { } {
2140 if [istarget powerpc*-*-linux*] {
2141 return [check_effective_target_powerpc_altivec_ok]
2147 # Return 1 if this is a PowerPC SPE target. The check includes options
2148 # specified by dg-options for this test, so don't cache the result.
2150 proc check_effective_target_powerpc_spe_nocache { } {
2151 if { [istarget powerpc*-*-*] } {
2152 return [check_no_compiler_messages_nocache powerpc_spe object {
2158 } [current_compiler_flags]]
2164 # Return 1 if this is a PowerPC target with SPE enabled.
2166 proc check_effective_target_powerpc_spe { } {
2167 if { [istarget powerpc*-*-*] } {
2168 return [check_no_compiler_messages powerpc_spe object {
2180 # Return 1 if this is a PowerPC target with Altivec enabled.
2182 proc check_effective_target_powerpc_altivec { } {
2183 if { [istarget powerpc*-*-*] } {
2184 return [check_no_compiler_messages powerpc_altivec object {
2196 # Return 1 if this is a PowerPC 405 target. The check includes options
2197 # specified by dg-options for this test, so don't cache the result.
2199 proc check_effective_target_powerpc_405_nocache { } {
2200 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2201 return [check_no_compiler_messages_nocache powerpc_405 object {
2207 } [current_compiler_flags]]
2213 # Return 1 if this is a SPU target with a toolchain that
2214 # supports automatic overlay generation.
2216 proc check_effective_target_spu_auto_overlay { } {
2217 if { [istarget spu*-*-elf*] } {
2218 return [check_no_compiler_messages spu_auto_overlay executable {
2220 } "-Wl,--auto-overlay" ]
2226 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2227 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2228 # test environment appears to run executables on such a simulator.
2230 proc check_effective_target_ultrasparc_hw { } {
2231 return [check_runtime ultrasparc_hw {
2232 int main() { return 0; }
2233 } "-mcpu=ultrasparc"]
2236 # Return 1 if the target supports hardware vector shift operation.
2238 proc check_effective_target_vect_shift { } {
2239 global et_vect_shift_saved
2241 if [info exists et_vect_shift_saved] {
2242 verbose "check_effective_target_vect_shift: using cached result" 2
2244 set et_vect_shift_saved 0
2245 if { ([istarget powerpc*-*-*]
2246 && ![istarget powerpc-*-linux*paired*])
2247 || [istarget ia64-*-*]
2248 || [istarget i?86-*-*]
2249 || [istarget x86_64-*-*]
2250 || [check_effective_target_arm32]
2251 || ([istarget mips*-*-*]
2252 && [check_effective_target_mips_loongson]) } {
2253 set et_vect_shift_saved 1
2257 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2258 return $et_vect_shift_saved
2261 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2263 # This can change for different subtargets so do not cache the result.
2265 proc check_effective_target_vect_long { } {
2266 if { [istarget i?86-*-*]
2267 || (([istarget powerpc*-*-*]
2268 && ![istarget powerpc-*-linux*paired*])
2269 && [check_effective_target_ilp32])
2270 || [istarget x86_64-*-*]
2271 || [check_effective_target_arm32]
2272 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2278 verbose "check_effective_target_vect_long: returning $answer" 2
2282 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2284 # This won't change for different subtargets so cache the result.
2286 proc check_effective_target_vect_float { } {
2287 global et_vect_float_saved
2289 if [info exists et_vect_float_saved] {
2290 verbose "check_effective_target_vect_float: using cached result" 2
2292 set et_vect_float_saved 0
2293 if { [istarget i?86-*-*]
2294 || [istarget powerpc*-*-*]
2295 || [istarget spu-*-*]
2296 || [istarget mipsisa64*-*-*]
2297 || [istarget x86_64-*-*]
2298 || [istarget ia64-*-*]
2299 || [check_effective_target_arm32] } {
2300 set et_vect_float_saved 1
2304 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2305 return $et_vect_float_saved
2308 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2310 # This won't change for different subtargets so cache the result.
2312 proc check_effective_target_vect_double { } {
2313 global et_vect_double_saved
2315 if [info exists et_vect_double_saved] {
2316 verbose "check_effective_target_vect_double: using cached result" 2
2318 set et_vect_double_saved 0
2319 if { [istarget i?86-*-*]
2320 || [istarget x86_64-*-*] } {
2321 if { [check_no_compiler_messages vect_double assembly {
2322 #ifdef __tune_atom__
2323 # error No double vectorizer support.
2326 set et_vect_double_saved 1
2328 set et_vect_double_saved 0
2330 } elseif { [istarget spu-*-*] } {
2331 set et_vect_double_saved 1
2335 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2336 return $et_vect_double_saved
2339 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2341 # This won't change for different subtargets so cache the result.
2343 proc check_effective_target_vect_long_long { } {
2344 global et_vect_long_long_saved
2346 if [info exists et_vect_long_long_saved] {
2347 verbose "check_effective_target_vect_long_long: using cached result" 2
2349 set et_vect_long_long_saved 0
2350 if { [istarget i?86-*-*]
2351 || [istarget x86_64-*-*] } {
2352 set et_vect_long_long_saved 1
2356 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2357 return $et_vect_long_long_saved
2361 # Return 1 if the target plus current options does not support a vector
2362 # max instruction on "int", 0 otherwise.
2364 # This won't change for different subtargets so cache the result.
2366 proc check_effective_target_vect_no_int_max { } {
2367 global et_vect_no_int_max_saved
2369 if [info exists et_vect_no_int_max_saved] {
2370 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2372 set et_vect_no_int_max_saved 0
2373 if { [istarget sparc*-*-*]
2374 || [istarget spu-*-*]
2375 || [istarget alpha*-*-*]
2376 || ([istarget mips*-*-*]
2377 && [check_effective_target_mips_loongson]) } {
2378 set et_vect_no_int_max_saved 1
2381 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2382 return $et_vect_no_int_max_saved
2385 # Return 1 if the target plus current options does not support a vector
2386 # add instruction on "int", 0 otherwise.
2388 # This won't change for different subtargets so cache the result.
2390 proc check_effective_target_vect_no_int_add { } {
2391 global et_vect_no_int_add_saved
2393 if [info exists et_vect_no_int_add_saved] {
2394 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2396 set et_vect_no_int_add_saved 0
2397 # Alpha only supports vector add on V8QI and V4HI.
2398 if { [istarget alpha*-*-*] } {
2399 set et_vect_no_int_add_saved 1
2402 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2403 return $et_vect_no_int_add_saved
2406 # Return 1 if the target plus current options does not support vector
2407 # bitwise instructions, 0 otherwise.
2409 # This won't change for different subtargets so cache the result.
2411 proc check_effective_target_vect_no_bitwise { } {
2412 global et_vect_no_bitwise_saved
2414 if [info exists et_vect_no_bitwise_saved] {
2415 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2417 set et_vect_no_bitwise_saved 0
2419 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2420 return $et_vect_no_bitwise_saved
2423 # Return 1 if the target plus current options supports vector permutation,
2426 # This won't change for different subtargets so cache the result.
2428 proc check_effective_target_vect_perm { } {
2431 if [info exists et_vect_perm_saved] {
2432 verbose "check_effective_target_vect_perm: using cached result" 2
2434 set et_vect_perm_saved 0
2435 if { [istarget powerpc*-*-*]
2436 || [istarget spu-*-*]
2437 || [istarget i?86-*-*]
2438 || [istarget x86_64-*-*] } {
2439 set et_vect_perm_saved 1
2442 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2443 return $et_vect_perm_saved
2446 # Return 1 if the target plus current options supports vector permutation
2447 # on byte-sized elements, 0 otherwise.
2449 # This won't change for different subtargets so cache the result.
2451 proc check_effective_target_vect_perm_byte { } {
2452 global et_vect_perm_byte
2454 if [info exists et_vect_perm_byte_saved] {
2455 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2457 set et_vect_perm_byte_saved 0
2458 if { [istarget powerpc*-*-*]
2459 || [istarget spu-*-*] } {
2460 set et_vect_perm_byte_saved 1
2463 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2464 return $et_vect_perm_byte_saved
2467 # Return 1 if the target plus current options supports vector permutation
2468 # on short-sized elements, 0 otherwise.
2470 # This won't change for different subtargets so cache the result.
2472 proc check_effective_target_vect_perm_short { } {
2473 global et_vect_perm_short
2475 if [info exists et_vect_perm_short_saved] {
2476 verbose "check_effective_target_vect_perm_short: using cached result" 2
2478 set et_vect_perm_short_saved 0
2479 if { [istarget powerpc*-*-*]
2480 || [istarget spu-*-*] } {
2481 set et_vect_perm_short_saved 1
2484 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2485 return $et_vect_perm_short_saved
2488 # Return 1 if the target plus current options supports a vector
2489 # widening summation of *short* args into *int* result, 0 otherwise.
2491 # This won't change for different subtargets so cache the result.
2493 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2494 global et_vect_widen_sum_hi_to_si_pattern
2496 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2497 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2499 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2500 if { [istarget powerpc*-*-*] } {
2501 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2504 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2505 return $et_vect_widen_sum_hi_to_si_pattern_saved
2508 # Return 1 if the target plus current options supports a vector
2509 # widening summation of *short* args into *int* result, 0 otherwise.
2510 # A target can also support this widening summation if it can support
2511 # promotion (unpacking) from shorts to ints.
2513 # This won't change for different subtargets so cache the result.
2515 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2516 global et_vect_widen_sum_hi_to_si
2518 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2519 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2521 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2522 if { [istarget powerpc*-*-*]
2523 || [istarget ia64-*-*] } {
2524 set et_vect_widen_sum_hi_to_si_saved 1
2527 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2528 return $et_vect_widen_sum_hi_to_si_saved
2531 # Return 1 if the target plus current options supports a vector
2532 # widening summation of *char* args into *short* result, 0 otherwise.
2533 # A target can also support this widening summation if it can support
2534 # promotion (unpacking) from chars to shorts.
2536 # This won't change for different subtargets so cache the result.
2538 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2539 global et_vect_widen_sum_qi_to_hi
2541 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2542 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2544 set et_vect_widen_sum_qi_to_hi_saved 0
2545 if { [check_effective_target_vect_unpack]
2546 || [istarget ia64-*-*] } {
2547 set et_vect_widen_sum_qi_to_hi_saved 1
2550 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2551 return $et_vect_widen_sum_qi_to_hi_saved
2554 # Return 1 if the target plus current options supports a vector
2555 # widening summation of *char* args into *int* result, 0 otherwise.
2557 # This won't change for different subtargets so cache the result.
2559 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2560 global et_vect_widen_sum_qi_to_si
2562 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2563 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2565 set et_vect_widen_sum_qi_to_si_saved 0
2566 if { [istarget powerpc*-*-*] } {
2567 set et_vect_widen_sum_qi_to_si_saved 1
2570 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2571 return $et_vect_widen_sum_qi_to_si_saved
2574 # Return 1 if the target plus current options supports a vector
2575 # widening multiplication of *char* args into *short* result, 0 otherwise.
2576 # A target can also support this widening multplication if it can support
2577 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2578 # multiplication of shorts).
2580 # This won't change for different subtargets so cache the result.
2583 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2584 global et_vect_widen_mult_qi_to_hi
2586 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2587 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2589 if { [check_effective_target_vect_unpack]
2590 && [check_effective_target_vect_short_mult] } {
2591 set et_vect_widen_mult_qi_to_hi_saved 1
2593 set et_vect_widen_mult_qi_to_hi_saved 0
2595 if { [istarget powerpc*-*-*] } {
2596 set et_vect_widen_mult_qi_to_hi_saved 1
2599 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2600 return $et_vect_widen_mult_qi_to_hi_saved
2603 # Return 1 if the target plus current options supports a vector
2604 # widening multiplication of *short* args into *int* result, 0 otherwise.
2605 # A target can also support this widening multplication if it can support
2606 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2607 # multiplication of ints).
2609 # This won't change for different subtargets so cache the result.
2612 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2613 global et_vect_widen_mult_hi_to_si
2615 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2616 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2618 if { [check_effective_target_vect_unpack]
2619 && [check_effective_target_vect_int_mult] } {
2620 set et_vect_widen_mult_hi_to_si_saved 1
2622 set et_vect_widen_mult_hi_to_si_saved 0
2624 if { [istarget powerpc*-*-*]
2625 || [istarget spu-*-*]
2626 || [istarget i?86-*-*]
2627 || [istarget x86_64-*-*] } {
2628 set et_vect_widen_mult_hi_to_si_saved 1
2631 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2632 return $et_vect_widen_mult_hi_to_si_saved
2635 # Return 1 if the target plus current options supports a vector
2636 # dot-product of signed chars, 0 otherwise.
2638 # This won't change for different subtargets so cache the result.
2640 proc check_effective_target_vect_sdot_qi { } {
2641 global et_vect_sdot_qi
2643 if [info exists et_vect_sdot_qi_saved] {
2644 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2646 set et_vect_sdot_qi_saved 0
2648 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2649 return $et_vect_sdot_qi_saved
2652 # Return 1 if the target plus current options supports a vector
2653 # dot-product of unsigned chars, 0 otherwise.
2655 # This won't change for different subtargets so cache the result.
2657 proc check_effective_target_vect_udot_qi { } {
2658 global et_vect_udot_qi
2660 if [info exists et_vect_udot_qi_saved] {
2661 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2663 set et_vect_udot_qi_saved 0
2664 if { [istarget powerpc*-*-*] } {
2665 set et_vect_udot_qi_saved 1
2668 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2669 return $et_vect_udot_qi_saved
2672 # Return 1 if the target plus current options supports a vector
2673 # dot-product of signed shorts, 0 otherwise.
2675 # This won't change for different subtargets so cache the result.
2677 proc check_effective_target_vect_sdot_hi { } {
2678 global et_vect_sdot_hi
2680 if [info exists et_vect_sdot_hi_saved] {
2681 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2683 set et_vect_sdot_hi_saved 0
2684 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2685 || [istarget i?86-*-*]
2686 || [istarget x86_64-*-*] } {
2687 set et_vect_sdot_hi_saved 1
2690 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2691 return $et_vect_sdot_hi_saved
2694 # Return 1 if the target plus current options supports a vector
2695 # dot-product of unsigned shorts, 0 otherwise.
2697 # This won't change for different subtargets so cache the result.
2699 proc check_effective_target_vect_udot_hi { } {
2700 global et_vect_udot_hi
2702 if [info exists et_vect_udot_hi_saved] {
2703 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2705 set et_vect_udot_hi_saved 0
2706 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2707 set et_vect_udot_hi_saved 1
2710 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2711 return $et_vect_udot_hi_saved
2715 # Return 1 if the target plus current options supports a vector
2716 # demotion (packing) of shorts (to chars) and ints (to shorts)
2717 # using modulo arithmetic, 0 otherwise.
2719 # This won't change for different subtargets so cache the result.
2721 proc check_effective_target_vect_pack_trunc { } {
2722 global et_vect_pack_trunc
2724 if [info exists et_vect_pack_trunc_saved] {
2725 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2727 set et_vect_pack_trunc_saved 0
2728 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2729 || [istarget i?86-*-*]
2730 || [istarget x86_64-*-*]
2731 || [istarget spu-*-*]
2732 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2733 set et_vect_pack_trunc_saved 1
2736 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2737 return $et_vect_pack_trunc_saved
2740 # Return 1 if the target plus current options supports a vector
2741 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2743 # This won't change for different subtargets so cache the result.
2745 proc check_effective_target_vect_unpack { } {
2746 global et_vect_unpack
2748 if [info exists et_vect_unpack_saved] {
2749 verbose "check_effective_target_vect_unpack: using cached result" 2
2751 set et_vect_unpack_saved 0
2752 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2753 || [istarget i?86-*-*]
2754 || [istarget x86_64-*-*]
2755 || [istarget spu-*-*]
2756 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2757 set et_vect_unpack_saved 1
2760 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2761 return $et_vect_unpack_saved
2764 # Return 1 if the target plus current options does not guarantee
2765 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2767 # This won't change for different subtargets so cache the result.
2769 proc check_effective_target_unaligned_stack { } {
2770 global et_unaligned_stack_saved
2772 if [info exists et_unaligned_stack_saved] {
2773 verbose "check_effective_target_unaligned_stack: using cached result" 2
2775 set et_unaligned_stack_saved 0
2777 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2778 return $et_unaligned_stack_saved
2781 # Return 1 if the target plus current options does not support a vector
2782 # alignment mechanism, 0 otherwise.
2784 # This won't change for different subtargets so cache the result.
2786 proc check_effective_target_vect_no_align { } {
2787 global et_vect_no_align_saved
2789 if [info exists et_vect_no_align_saved] {
2790 verbose "check_effective_target_vect_no_align: using cached result" 2
2792 set et_vect_no_align_saved 0
2793 if { [istarget mipsisa64*-*-*]
2794 || [istarget sparc*-*-*]
2795 || [istarget ia64-*-*]
2796 || [check_effective_target_arm_vect_no_misalign]
2797 || ([istarget mips*-*-*]
2798 && [check_effective_target_mips_loongson]) } {
2799 set et_vect_no_align_saved 1
2802 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2803 return $et_vect_no_align_saved
2806 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2808 # This won't change for different subtargets so cache the result.
2810 proc check_effective_target_vect_hw_misalign { } {
2811 global et_vect_hw_misalign_saved
2813 if [info exists et_vect_hw_misalign_saved] {
2814 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2816 set et_vect_hw_misalign_saved 0
2817 if { ([istarget x86_64-*-*]
2818 || [istarget i?86-*-*]) } {
2819 set et_vect_hw_misalign_saved 1
2822 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2823 return $et_vect_hw_misalign_saved
2827 # Return 1 if arrays are aligned to the vector alignment
2828 # boundary, 0 otherwise.
2830 # This won't change for different subtargets so cache the result.
2832 proc check_effective_target_vect_aligned_arrays { } {
2833 global et_vect_aligned_arrays
2835 if [info exists et_vect_aligned_arrays_saved] {
2836 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2838 set et_vect_aligned_arrays_saved 0
2839 if { (([istarget x86_64-*-*]
2840 || [istarget i?86-*-*]) && [is-effective-target lp64])
2841 || [istarget spu-*-*] } {
2842 set et_vect_aligned_arrays_saved 1
2845 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2846 return $et_vect_aligned_arrays_saved
2849 # Return 1 if types of size 32 bit or less are naturally aligned
2850 # (aligned to their type-size), 0 otherwise.
2852 # This won't change for different subtargets so cache the result.
2854 proc check_effective_target_natural_alignment_32 { } {
2855 global et_natural_alignment_32
2857 if [info exists et_natural_alignment_32_saved] {
2858 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2860 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2861 set et_natural_alignment_32_saved 1
2862 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2863 set et_natural_alignment_32_saved 0
2866 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2867 return $et_natural_alignment_32_saved
2870 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2871 # type-size), 0 otherwise.
2873 # This won't change for different subtargets so cache the result.
2875 proc check_effective_target_natural_alignment_64 { } {
2876 global et_natural_alignment_64
2878 if [info exists et_natural_alignment_64_saved] {
2879 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2881 set et_natural_alignment_64_saved 0
2882 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2883 || [istarget spu-*-*] } {
2884 set et_natural_alignment_64_saved 1
2887 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2888 return $et_natural_alignment_64_saved
2891 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2893 # This won't change for different subtargets so cache the result.
2895 proc check_effective_target_vector_alignment_reachable { } {
2896 global et_vector_alignment_reachable
2898 if [info exists et_vector_alignment_reachable_saved] {
2899 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2901 if { [check_effective_target_vect_aligned_arrays]
2902 || [check_effective_target_natural_alignment_32] } {
2903 set et_vector_alignment_reachable_saved 1
2905 set et_vector_alignment_reachable_saved 0
2908 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2909 return $et_vector_alignment_reachable_saved
2912 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2914 # This won't change for different subtargets so cache the result.
2916 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2917 global et_vector_alignment_reachable_for_64bit
2919 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2920 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2922 if { [check_effective_target_vect_aligned_arrays]
2923 || [check_effective_target_natural_alignment_64] } {
2924 set et_vector_alignment_reachable_for_64bit_saved 1
2926 set et_vector_alignment_reachable_for_64bit_saved 0
2929 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2930 return $et_vector_alignment_reachable_for_64bit_saved
2933 # Return 1 if the target only requires element alignment for vector accesses
2935 proc check_effective_target_vect_element_align { } {
2936 global et_vect_element_align
2938 if [info exists et_vect_element_align] {
2939 verbose "check_effective_target_vect_element_align: using cached result" 2
2941 set et_vect_element_align 0
2942 if { [istarget arm*-*-*]
2943 || [check_effective_target_vect_hw_misalign] } {
2944 set et_vect_element_align 1
2948 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
2949 return $et_vect_element_align
2952 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2954 proc check_effective_target_vect_condition { } {
2955 global et_vect_cond_saved
2957 if [info exists et_vect_cond_saved] {
2958 verbose "check_effective_target_vect_cond: using cached result" 2
2960 set et_vect_cond_saved 0
2961 if { [istarget powerpc*-*-*]
2962 || [istarget ia64-*-*]
2963 || [istarget i?86-*-*]
2964 || [istarget spu-*-*]
2965 || [istarget x86_64-*-*] } {
2966 set et_vect_cond_saved 1
2970 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2971 return $et_vect_cond_saved
2974 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2976 proc check_effective_target_vect_char_mult { } {
2977 global et_vect_char_mult_saved
2979 if [info exists et_vect_char_mult_saved] {
2980 verbose "check_effective_target_vect_char_mult: using cached result" 2
2982 set et_vect_char_mult_saved 0
2983 if { [istarget ia64-*-*]
2984 || [istarget i?86-*-*]
2985 || [istarget x86_64-*-*] } {
2986 set et_vect_char_mult_saved 1
2990 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2991 return $et_vect_char_mult_saved
2994 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2996 proc check_effective_target_vect_short_mult { } {
2997 global et_vect_short_mult_saved
2999 if [info exists et_vect_short_mult_saved] {
3000 verbose "check_effective_target_vect_short_mult: using cached result" 2
3002 set et_vect_short_mult_saved 0
3003 if { [istarget ia64-*-*]
3004 || [istarget spu-*-*]
3005 || [istarget i?86-*-*]
3006 || [istarget x86_64-*-*]
3007 || [istarget powerpc*-*-*]
3008 || [check_effective_target_arm32]
3009 || ([istarget mips*-*-*]
3010 && [check_effective_target_mips_loongson]) } {
3011 set et_vect_short_mult_saved 1
3015 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3016 return $et_vect_short_mult_saved
3019 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3021 proc check_effective_target_vect_int_mult { } {
3022 global et_vect_int_mult_saved
3024 if [info exists et_vect_int_mult_saved] {
3025 verbose "check_effective_target_vect_int_mult: using cached result" 2
3027 set et_vect_int_mult_saved 0
3028 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3029 || [istarget spu-*-*]
3030 || [istarget i?86-*-*]
3031 || [istarget x86_64-*-*]
3032 || [check_effective_target_arm32] } {
3033 set et_vect_int_mult_saved 1
3037 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3038 return $et_vect_int_mult_saved
3041 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3043 proc check_effective_target_vect_extract_even_odd { } {
3044 global et_vect_extract_even_odd_saved
3046 if [info exists et_vect_extract_even_odd_saved] {
3047 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3049 set et_vect_extract_even_odd_saved 0
3050 if { [istarget powerpc*-*-*]
3051 || [istarget i?86-*-*]
3052 || [istarget x86_64-*-*]
3053 || [istarget spu-*-*] } {
3054 set et_vect_extract_even_odd_saved 1
3058 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3059 return $et_vect_extract_even_odd_saved
3062 # Return 1 if the target supports vector even/odd elements extraction of
3063 # vectors with SImode elements or larger, 0 otherwise.
3065 proc check_effective_target_vect_extract_even_odd_wide { } {
3066 global et_vect_extract_even_odd_wide_saved
3068 if [info exists et_vect_extract_even_odd_wide_saved] {
3069 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
3071 set et_vect_extract_even_odd_wide_saved 0
3072 if { [istarget powerpc*-*-*]
3073 || [istarget i?86-*-*]
3074 || [istarget x86_64-*-*]
3075 || [istarget spu-*-*] } {
3076 set et_vect_extract_even_odd_wide_saved 1
3080 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
3081 return $et_vect_extract_even_odd_wide_saved
3084 # Return 1 if the target supports vector interleaving, 0 otherwise.
3086 proc check_effective_target_vect_interleave { } {
3087 global et_vect_interleave_saved
3089 if [info exists et_vect_interleave_saved] {
3090 verbose "check_effective_target_vect_interleave: using cached result" 2
3092 set et_vect_interleave_saved 0
3093 if { [istarget powerpc*-*-*]
3094 || [istarget i?86-*-*]
3095 || [istarget x86_64-*-*]
3096 || [istarget spu-*-*] } {
3097 set et_vect_interleave_saved 1
3101 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3102 return $et_vect_interleave_saved
3105 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
3106 proc check_effective_target_vect_strided { } {
3107 global et_vect_strided_saved
3109 if [info exists et_vect_strided_saved] {
3110 verbose "check_effective_target_vect_strided: using cached result" 2
3112 set et_vect_strided_saved 0
3113 if { [check_effective_target_vect_interleave]
3114 && [check_effective_target_vect_extract_even_odd] } {
3115 set et_vect_strided_saved 1
3119 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
3120 return $et_vect_strided_saved
3123 # Return 1 if the target supports vector interleaving and extract even/odd
3124 # for wide element types, 0 otherwise.
3125 proc check_effective_target_vect_strided_wide { } {
3126 global et_vect_strided_wide_saved
3128 if [info exists et_vect_strided_wide_saved] {
3129 verbose "check_effective_target_vect_strided_wide: using cached result" 2
3131 set et_vect_strided_wide_saved 0
3132 if { [check_effective_target_vect_interleave]
3133 && [check_effective_target_vect_extract_even_odd_wide] } {
3134 set et_vect_strided_wide_saved 1
3138 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
3139 return $et_vect_strided_wide_saved
3142 # Return 1 if the target supports section-anchors
3144 proc check_effective_target_section_anchors { } {
3145 global et_section_anchors_saved
3147 if [info exists et_section_anchors_saved] {
3148 verbose "check_effective_target_section_anchors: using cached result" 2
3150 set et_section_anchors_saved 0
3151 if { [istarget powerpc*-*-*]
3152 || [istarget arm*-*-*] } {
3153 set et_section_anchors_saved 1
3157 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3158 return $et_section_anchors_saved
3161 # Return 1 if the target supports atomic operations on "int" and "long".
3163 proc check_effective_target_sync_int_long { } {
3164 global et_sync_int_long_saved
3166 if [info exists et_sync_int_long_saved] {
3167 verbose "check_effective_target_sync_int_long: using cached result" 2
3169 set et_sync_int_long_saved 0
3170 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3171 # load-reserved/store-conditional instructions.
3172 if { [istarget ia64-*-*]
3173 || [istarget i?86-*-*]
3174 || [istarget x86_64-*-*]
3175 || [istarget alpha*-*-*]
3176 || [istarget arm*-*-linux-gnueabi]
3177 || [istarget bfin*-*linux*]
3178 || [istarget hppa*-*linux*]
3179 || [istarget s390*-*-*]
3180 || [istarget powerpc*-*-*]
3181 || [istarget sparc64-*-*]
3182 || [istarget sparcv9-*-*]
3183 || [istarget mips*-*-*] } {
3184 set et_sync_int_long_saved 1
3188 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3189 return $et_sync_int_long_saved
3192 # Return 1 if the target supports atomic operations on "char" and "short".
3194 proc check_effective_target_sync_char_short { } {
3195 global et_sync_char_short_saved
3197 if [info exists et_sync_char_short_saved] {
3198 verbose "check_effective_target_sync_char_short: using cached result" 2
3200 set et_sync_char_short_saved 0
3201 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3202 # load-reserved/store-conditional instructions.
3203 if { [istarget ia64-*-*]
3204 || [istarget i?86-*-*]
3205 || [istarget x86_64-*-*]
3206 || [istarget alpha*-*-*]
3207 || [istarget arm*-*-linux-gnueabi]
3208 || [istarget hppa*-*linux*]
3209 || [istarget s390*-*-*]
3210 || [istarget powerpc*-*-*]
3211 || [istarget sparc64-*-*]
3212 || [istarget sparcv9-*-*]
3213 || [istarget mips*-*-*] } {
3214 set et_sync_char_short_saved 1
3218 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3219 return $et_sync_char_short_saved
3222 # Return 1 if the target uses a ColdFire FPU.
3224 proc check_effective_target_coldfire_fpu { } {
3225 return [check_no_compiler_messages coldfire_fpu assembly {
3232 # Return true if this is a uClibc target.
3234 proc check_effective_target_uclibc {} {
3235 return [check_no_compiler_messages uclibc object {
3236 #include <features.h>
3237 #if !defined (__UCLIBC__)
3243 # Return true if this is a uclibc target and if the uclibc feature
3244 # described by __$feature__ is not present.
3246 proc check_missing_uclibc_feature {feature} {
3247 return [check_no_compiler_messages $feature object "
3248 #include <features.h>
3249 #if !defined (__UCLIBC) || defined (__${feature}__)
3255 # Return true if this is a Newlib target.
3257 proc check_effective_target_newlib {} {
3258 return [check_no_compiler_messages newlib object {
3264 # (a) an error of a few ULP is expected in string to floating-point
3265 # conversion functions; and
3266 # (b) overflow is not always detected correctly by those functions.
3268 proc check_effective_target_lax_strtofp {} {
3269 # By default, assume that all uClibc targets suffer from this.
3270 return [check_effective_target_uclibc]
3273 # Return 1 if this is a target for which wcsftime is a dummy
3274 # function that always returns 0.
3276 proc check_effective_target_dummy_wcsftime {} {
3277 # By default, assume that all uClibc targets suffer from this.
3278 return [check_effective_target_uclibc]
3281 # Return 1 if constructors with initialization priority arguments are
3282 # supposed on this target.
3284 proc check_effective_target_init_priority {} {
3285 return [check_no_compiler_messages init_priority assembly "
3286 void f() __attribute__((constructor (1000)));
3291 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3292 # This can be used with any check_* proc that takes no argument and
3293 # returns only 1 or 0. It could be used with check_* procs that take
3294 # arguments with keywords that pass particular arguments.
3296 proc is-effective-target { arg } {
3298 if { [info procs check_effective_target_${arg}] != [list] } {
3299 set selected [check_effective_target_${arg}]
3302 "vmx_hw" { set selected [check_vmx_hw_available] }
3303 "vsx_hw" { set selected [check_vsx_hw_available] }
3304 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3305 "named_sections" { set selected [check_named_sections_available] }
3306 "gc_sections" { set selected [check_gc_sections_available] }
3307 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3308 default { error "unknown effective target keyword `$arg'" }
3311 verbose "is-effective-target: $arg $selected" 2
3315 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3317 proc is-effective-target-keyword { arg } {
3318 if { [info procs check_effective_target_${arg}] != [list] } {
3321 # These have different names for their check_* procs.
3323 "vmx_hw" { return 1 }
3324 "vsx_hw" { return 1 }
3325 "ppc_recip_hw" { return 1 }
3326 "named_sections" { return 1 }
3327 "gc_sections" { return 1 }
3328 "cxa_atexit" { return 1 }
3329 default { return 0 }
3334 # Return 1 if target default to short enums
3336 proc check_effective_target_short_enums { } {
3337 return [check_no_compiler_messages short_enums assembly {
3339 int s[sizeof (enum foo) == 1 ? 1 : -1];
3343 # Return 1 if target supports merging string constants at link time.
3345 proc check_effective_target_string_merging { } {
3346 return [check_no_messages_and_pattern string_merging \
3347 "rodata\\.str" assembly {
3348 const char *var = "String";
3352 # Return 1 if target has the basic signed and unsigned types in
3353 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3354 # working <stdint.h> for all targets.
3356 proc check_effective_target_stdint_types { } {
3357 return [check_no_compiler_messages stdint_types assembly {
3359 int8_t a; int16_t b; int32_t c; int64_t d;
3360 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3364 # Return 1 if target has the basic signed and unsigned types in
3365 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3366 # these types agree with those in the header, as some systems have
3367 # only <inttypes.h>.
3369 proc check_effective_target_inttypes_types { } {
3370 return [check_no_compiler_messages inttypes_types assembly {
3371 #include <inttypes.h>
3372 int8_t a; int16_t b; int32_t c; int64_t d;
3373 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3377 # Return 1 if programs are intended to be run on a simulator
3378 # (i.e. slowly) rather than hardware (i.e. fast).
3380 proc check_effective_target_simulator { } {
3382 # All "src/sim" simulators set this one.
3383 if [board_info target exists is_simulator] {
3384 return [board_info target is_simulator]
3387 # The "sid" simulators don't set that one, but at least they set
3389 if [board_info target exists slow_simulator] {
3390 return [board_info target slow_simulator]
3396 # Return 1 if the target is a VxWorks kernel.
3398 proc check_effective_target_vxworks_kernel { } {
3399 return [check_no_compiler_messages vxworks_kernel assembly {
3400 #if !defined __vxworks || defined __RTP__
3406 # Return 1 if the target is a VxWorks RTP.
3408 proc check_effective_target_vxworks_rtp { } {
3409 return [check_no_compiler_messages vxworks_rtp assembly {
3410 #if !defined __vxworks || !defined __RTP__
3416 # Return 1 if the target is expected to provide wide character support.
3418 proc check_effective_target_wchar { } {
3419 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3422 return [check_no_compiler_messages wchar assembly {
3427 # Return 1 if the target has <pthread.h>.
3429 proc check_effective_target_pthread_h { } {
3430 return [check_no_compiler_messages pthread_h assembly {
3431 #include <pthread.h>
3435 # Return 1 if the target can truncate a file from a file-descriptor,
3436 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3437 # chsize. We test for a trivially functional truncation; no stubs.
3438 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3439 # different function to be used.
3441 proc check_effective_target_fd_truncate { } {
3443 #define _FILE_OFFSET_BITS 64
3449 FILE *f = fopen ("tst.tmp", "wb");
3451 const char t[] = "test writing more than ten characters";
3454 write (fd, t, sizeof (t) - 1);
3456 if (ftruncate (fd, 10) != 0)
3459 f = fopen ("tst.tmp", "rb");
3460 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3466 if { [check_runtime ftruncate $prog] } {
3470 regsub "ftruncate" $prog "chsize" prog
3471 return [check_runtime chsize $prog]
3474 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3476 proc add_options_for_c99_runtime { flags } {
3477 if { [istarget *-*-solaris2*] } {
3478 return "$flags -std=c99"
3480 if { [istarget powerpc-*-darwin*] } {
3481 return "$flags -mmacosx-version-min=10.3"
3486 # Add to FLAGS all the target-specific flags needed to enable
3487 # full IEEE compliance mode.
3489 proc add_options_for_ieee { flags } {
3490 if { [istarget "alpha*-*-*"]
3491 || [istarget "sh*-*-*"] } {
3492 return "$flags -mieee"
3497 # Add to FLAGS the flags needed to enable functions to bind locally
3498 # when using pic/PIC passes in the testsuite.
3500 proc add_options_for_bind_pic_locally { flags } {
3501 if {[check_no_compiler_messages using_pic2 assembly {
3506 return "$flags -fPIE"
3508 if {[check_no_compiler_messages using_pic1 assembly {
3513 return "$flags -fpie"
3519 # Add to FLAGS the flags needed to enable 128-bit vectors.
3521 proc add_options_for_quad_vectors { flags } {
3522 if [is-effective-target arm_neon_ok] {
3523 return "$flags -mvectorize-with-neon-quad"
3529 # Return 1 if the target provides a full C99 runtime.
3531 proc check_effective_target_c99_runtime { } {
3532 return [check_cached_effective_target c99_runtime {
3535 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3536 set contents [read $file]
3539 #ifndef HAVE_C99_RUNTIME
3543 check_no_compiler_messages_nocache c99_runtime assembly \
3544 $contents [add_options_for_c99_runtime ""]
3548 # Return 1 if target wchar_t is at least 4 bytes.
3550 proc check_effective_target_4byte_wchar_t { } {
3551 return [check_no_compiler_messages 4byte_wchar_t object {
3552 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3556 # Return 1 if the target supports automatic stack alignment.
3558 proc check_effective_target_automatic_stack_alignment { } {
3559 # Ordinarily x86 supports automatic stack alignment ...
3560 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
3561 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
3562 # ... except Win64 SEH doesn't. Succeed for Win32 though.
3563 return [check_effective_target_ilp32];
3570 # Return 1 if avx instructions can be compiled.
3572 proc check_effective_target_avx { } {
3573 return [check_no_compiler_messages avx object {
3574 void _mm256_zeroall (void)
3576 __builtin_ia32_vzeroall ();
3581 # Return 1 if sse instructions can be compiled.
3582 proc check_effective_target_sse { } {
3583 return [check_no_compiler_messages sse object {
3586 __builtin_ia32_stmxcsr ();
3592 # Return 1 if sse2 instructions can be compiled.
3593 proc check_effective_target_sse2 { } {
3594 return [check_no_compiler_messages sse2 object {
3595 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3597 __m128i _mm_srli_si128 (__m128i __A, int __N)
3599 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3604 # Return 1 if F16C instructions can be compiled.
3606 proc check_effective_target_f16c { } {
3607 return [check_no_compiler_messages f16c object {
3608 #include "immintrin.h"
3610 foo (unsigned short val)
3612 return _cvtsh_ss (val);
3617 # Return 1 if C wchar_t type is compatible with char16_t.
3619 proc check_effective_target_wchar_t_char16_t_compatible { } {
3620 return [check_no_compiler_messages wchar_t_char16_t object {
3622 __CHAR16_TYPE__ *p16 = &wc;
3623 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3627 # Return 1 if C wchar_t type is compatible with char32_t.
3629 proc check_effective_target_wchar_t_char32_t_compatible { } {
3630 return [check_no_compiler_messages wchar_t_char32_t object {
3632 __CHAR32_TYPE__ *p32 = &wc;
3633 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3637 # Return 1 if pow10 function exists.
3639 proc check_effective_target_pow10 { } {
3640 return [check_runtime pow10 {
3650 # Return 1 if current options generate DFP instructions, 0 otherwise.
3652 proc check_effective_target_hard_dfp {} {
3653 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3654 typedef float d64 __attribute__((mode(DD)));
3656 void foo (void) { z = x + y; }
3660 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3661 # for strchr etc. functions.
3663 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3664 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3667 #if !defined(__cplusplus) \
3668 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3669 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3670 ISO C++ correct string.h and wchar.h protos not supported.
3677 # Return 1 if GNU as is used.
3679 proc check_effective_target_gas { } {
3680 global use_gas_saved
3683 if {![info exists use_gas_saved]} {
3684 # Check if the as used by gcc is GNU as.
3685 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3686 # Provide /dev/null as input, otherwise gas times out reading from
3688 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3689 set as_output [lindex $status 1]
3690 if { [ string first "GNU" $as_output ] >= 0 } {
3696 return $use_gas_saved
3699 # Return 1 if the compiler has been configure with link-time optimization
3702 proc check_effective_target_lto { } {
3704 return [info exists ENABLE_LTO]
3707 # Return 1 if this target supports the -fsplit-stack option, 0
3710 proc check_effective_target_split_stack {} {
3711 return [check_no_compiler_messages split_stack object {
3716 # Return 1 if the language for the compiler under test is C.
3718 proc check_effective_target_c { } {
3720 if [string match $tool "gcc"] {
3726 # Return 1 if the language for the compiler under test is C++.
3728 proc check_effective_target_c++ { } {
3730 if [string match $tool "g++"] {
3736 # Return 1 if expensive testcases should be run.
3738 proc check_effective_target_run_expensive_tests { } {
3739 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
3745 # Returns 1 if "mempcpy" is available on the target system.
3747 proc check_effective_target_mempcpy {} {
3748 return [check_function_available "mempcpy"]