1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
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 2 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 this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 some code and return the messages printed by the compiler,
24 # and optionally the contents for assembly files. Either a string or
25 # a list of two strings are returned, depending on WANT_OUTPUT.
27 # BASENAME is a basename to use for temporary files.
28 # WANT_OUTPUT is a flag which is 0 to request returning just the
29 # compiler messages, or 1 to return the messages and the contents
30 # of the assembly file. TYPE should be "assembly" if WANT_OUTPUT
32 # TYPE is the type of compilation to perform (see target_compile).
33 # CONTENTS gives the contents of the input file.
34 # The rest is optional:
35 # OPTIONS: additional compiler options to use.
36 proc get_compiler_messages {basename want_output type contents args} {
39 if { [llength $args] > 0 } {
40 set options [list "additional_flags=[lindex $args 0]"]
45 set src ${basename}[pid].c
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
53 set lines [${tool}_target_compile $src $output $type "$options"]
57 if { $type != "assembly" } {
58 error "WANT_OUTPUT can only be used with assembly output"
59 } elseif { ![string match "" $lines] } {
61 set result [list $lines ""]
64 set chan [open "$output"]
65 while {[gets $chan line] >= 0} {
69 set result [list $lines $text]
75 remote_file build delete $output
79 proc current_target_name { } {
81 if [info exists target_info(target,name)] {
82 set answer $target_info(target,name)
89 # Implement an effective-target check for property PROP by invoking
90 # the compiler and seeing if it prints any messages. Assume that the
91 # property holds if the compiler doesn't print anything. The other
92 # arguments are as for get_compiler_messages, starting with TYPE.
93 proc check_no_compiler_messages {prop args} {
96 set target [current_target_name]
97 if {![info exists et_cache($prop,target)]
98 || $et_cache($prop,target) != $target} {
99 verbose "check_no_compiler_messages $prop: compiling source for $target" 2
100 set et_cache($prop,target) $target
101 set et_cache($prop,value) \
102 [string match "" [eval get_compiler_messages $prop 0 $args]]
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
109 # Similar to check_no_compiler_messages, but also verify that the regular
110 # expression PATTERN matches the compiler's output.
111 proc check_no_messages_and_pattern {prop pattern args} {
114 set target [current_target_name]
115 if {![info exists et_cache($prop,target)]
116 || $et_cache($prop,target) != $target} {
117 verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
118 set et_cache($prop,target) $target
119 set results [eval get_compiler_messages $prop 1 $args]
120 set et_cache($prop,value) \
121 [expr [string match "" [lindex $results 0]] \
122 && [regexp $pattern [lindex $results 1]]]
124 set value $et_cache($prop,value)
125 verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
129 ###############################
130 # proc check_weak_available { }
131 ###############################
133 # weak symbols are only supported in some configs/object formats
134 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
136 proc check_weak_available { } {
137 global target_triplet
140 # All mips targets should support it
142 if { [ string first "mips" $target_cpu ] >= 0 } {
146 # All solaris2 targets should support it
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
158 # Windows targets Cygwin and MingW32 support it
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
164 # HP-UX 10.X doesn't support it
166 if { [istarget "hppa*-*-hpux10*"] } {
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
173 set objformat [gcc_target_object_format]
181 unknown { return -1 }
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
190 # The visibility attribute is only support in some object formats
191 # This proc returns 1 if it is supported, 0 if not.
192 # The argument is the kind of visibility, default/protected/hidden/internal.
194 proc check_visibility_available { what_kind } {
196 global target_triplet
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
203 if [string match "" $what_kind] { set what_kind "hidden" }
205 return [check_no_compiler_messages visibility_available_$what_kind object "
206 void f() __attribute__((visibility(\"$what_kind\")));
211 ###############################
212 # proc check_alias_available { }
213 ###############################
215 # Determine if the target toolchain supports the alias attribute.
217 # Returns 2 if the target supports aliases. Returns 1 if the target
218 # only supports weak aliased. Returns 0 if the target does not
219 # support aliases at all. Returns -1 if support for aliases could not
222 proc check_alias_available { } {
223 global alias_available_saved
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
231 verbose "check_alias_available compiling testfile $src" 2
232 set f [open $src "w"]
233 # Compile a small test program. The definition of "g" is
234 # necessary to keep the Solaris assembler from complaining
236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
239 set lines [${tool}_target_compile $src $obj object ""]
241 remote_file build delete $obj
243 if [string match "" $lines] then {
244 # No error messages, everything is OK.
245 set alias_available_saved 2
247 if [regexp "alias definitions not supported" $lines] {
248 verbose "check_alias_available target does not support aliases" 2
250 set objformat [gcc_target_object_format]
252 if { $objformat == "elf" } {
253 verbose "check_alias_available but target uses ELF format, so it ought to" 2
254 set alias_available_saved -1
256 set alias_available_saved 0
259 if [regexp "only weak aliases are supported" $lines] {
260 verbose "check_alias_available target supports only weak aliases" 2
261 set alias_available_saved 1
263 set alias_available_saved -1
268 verbose "check_alias_available returning $alias_available_saved" 2
271 return $alias_available_saved
274 # Returns true if --gc-sections is supported on the target.
276 proc check_gc_sections_available { } {
277 global gc_sections_available_saved
280 if {![info exists gc_sections_available_saved]} {
281 # Some targets don't support gc-sections despite whatever's
282 # advertised by ld's options.
283 if { [istarget alpha*-*-*]
284 || [istarget ia64-*-*] } {
285 set gc_sections_available_saved 0
289 # elf2flt uses -q (--emit-relocs), which is incompatible with
291 if { [board_info target exists ldflags]
292 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
293 set gc_sections_available_saved 0
297 # VxWorks kernel modules are relocatable objects linked with -r,
298 # while RTP executables are linked with -q (--emit-relocs).
299 # Both of these options are incompatible with --gc-sections.
300 if { [istarget *-*-vxworks*] } {
301 set gc_sections_available_saved 0
305 # Check if the ld used by gcc supports --gc-sections.
306 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
307 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
308 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
309 set ld_output [remote_exec host "$gcc_ld" "--help"]
310 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
311 set gc_sections_available_saved 1
313 set gc_sections_available_saved 0
316 return $gc_sections_available_saved
319 # Return true if profiling is supported on the target.
321 proc check_profiling_available { test_what } {
322 global profiling_available_saved
324 verbose "Profiling argument is <$test_what>" 1
326 # These conditions depend on the argument so examine them before
327 # looking at the cache variable.
329 # Support for -p on solaris2 relies on mcrt1.o which comes with the
330 # vendor compiler. We cannot reliably predict the directory where the
331 # vendor compiler (and thus mcrt1.o) is installed so we can't
332 # necessarily find mcrt1.o even if we have it.
333 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
337 # Support for -p on irix relies on libprof1.a which doesn't appear to
338 # exist on any irix6 system currently posting testsuite results.
339 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
340 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
341 if { [istarget mips*-*-irix*]
342 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
346 # At present, there is no profiling support on NetWare.
347 if { [istarget *-*-netware*] } {
351 # Now examine the cache variable.
352 if {![info exists profiling_available_saved]} {
353 # Some targets don't have any implementation of __bb_init_func or are
354 # missing other needed machinery.
355 if { [istarget mmix-*-*]
356 || [istarget arm*-*-eabi*]
357 || [istarget arm*-*-elf]
358 || [istarget arm*-*-symbianelf*]
359 || [istarget bfin-*-*]
360 || [istarget powerpc-*-eabi*]
361 || [istarget strongarm*-*-elf]
362 || [istarget xscale*-*-elf]
363 || [istarget cris-*-*]
364 || [istarget h8300-*-*]
365 || [istarget m32c-*-elf]
366 || [istarget m68k-*-elf]
367 || [istarget mips*-*-elf]
368 || [istarget xtensa-*-elf]
369 || [istarget *-*-vxworks*]
370 || [istarget *-*-windiss] } {
371 set profiling_available_saved 0
373 set profiling_available_saved 1
377 return $profiling_available_saved
380 # Return 1 if target has packed layout of structure members by
381 # default, 0 otherwise. Note that this is slightly different than
382 # whether the target has "natural alignment": both attributes may be
385 proc check_effective_target_default_packed { } {
386 return [check_no_compiler_messages default_packed assembly {
387 struct x { char a; long b; } c;
388 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
392 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
393 # documentation, where the test also comes from.
395 proc check_effective_target_pcc_bitfield_type_matters { } {
396 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
397 # bitfields, but let's stick to the example code from the docs.
398 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
399 struct foo1 { char x; char :0; char y; };
400 struct foo2 { char x; int :0; char y; };
401 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
405 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
407 # This won't change for different subtargets so cache the result.
409 proc check_effective_target_tls {} {
413 if [info exists et_tls_saved] {
414 verbose "check_effective_target_tls: using cached result" 2
420 verbose "check_effective_target_tls: compiling testfile $src" 2
421 set f [open $src "w"]
422 # Compile a small test program.
423 puts $f "__thread int i;\n"
426 # Test for thread-local data supported by the platform.
427 set comp_output [${tool}_target_compile $src $asm assembly ""]
429 if { [string match "*not supported*" $comp_output] } {
435 if { [string match "*emutls*" $text]} {
441 remove-build-file $asm
443 verbose "check_effective_target_tls: returning $et_tls_saved" 2
447 # Return 1 if TLS executables can run correctly, 0 otherwise.
449 # This won't change for different subtargets so cache the result.
451 proc check_effective_target_tls_runtime {} {
452 global et_tls_runtime_saved
455 if [info exists et_tls_runtime_saved] {
456 verbose "check_effective_target_tls_runtime: using cached result" 2
458 set et_tls_runtime_saved 0
460 set src tls_runtime[pid].c
461 set exe tls_runtime[pid].x
462 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
463 set f [open $src "w"]
464 # Compile a small test program.
465 puts $f "__thread int thr = 0;\n"
466 puts $f "int main(void)\n {\n return thr;\n}"
470 [${tool}_target_compile $src $exe executable ""]
473 if [string match "" $comp_output] then {
474 # No error messages, everything is OK.
476 set result [remote_load target "./$exe" "" ""]
477 set status [lindex $result 0]
478 remote_file build delete $exe
480 verbose "check_effective_target_tls_runtime status is <$status>" 2
482 if { $status == "pass" } {
483 set et_tls_runtime_saved 1
486 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
490 return $et_tls_runtime_saved
493 # Return 1 if compilation with -fopenmp is error-free for trivial
496 proc check_effective_target_fopenmp {} {
497 return [check_no_compiler_messages fopenmp object {
502 # Return 1 if the target supports -fstack-protector
503 proc check_effective_target_fstack_protector {} {
507 set src stack_prot[pid].c
508 set exe stack_prot[pid].x
510 verbose "check_effective_target_fstack_protector compiling testfile $src" 2
512 set f [open $src "w"]
513 # Compile a small test program.
514 puts $f "int main (void)\n { return 0; }\n"
517 set opts "additional_flags=-fstack-protector"
518 set lines [${tool}_target_compile $src $exe executable "$opts" ]
521 if [string match "" $lines] then {
522 # No error messages, everything is OK.
523 set result [${tool}_load "./$exe" "" ""]
524 set status [lindex $result 0]
525 remote_file build delete $exe
526 verbose "check_iconv_available status is <$status>" 2
528 if { $status == "pass" } then {
535 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
536 # for trivial code, 0 otherwise.
538 proc check_effective_target_freorder {} {
539 return [check_no_compiler_messages freorder object {
541 } "-freorder-blocks-and-partition"]
544 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
545 # emitted, 0 otherwise. Whether a shared library can actually be built is
546 # out of scope for this test.
548 proc check_effective_target_fpic { } {
549 # Note that M68K has a multilib that supports -fpic but not
550 # -fPIC, so we need to check both. We test with a program that
551 # requires GOT references.
552 foreach arg {fpic fPIC} {
553 if [check_no_compiler_messages $arg object {
554 extern int foo (void); extern int bar;
555 int baz (void) { return foo () + bar; }
563 # Return true if the target supports -mpaired-single (as used on MIPS).
565 proc check_effective_target_mpaired_single { } {
566 return [check_no_compiler_messages mpaired_single object {
571 # Return 1 if the current multilib does not generate PIC by default.
573 proc check_effective_target_nonpic { } {
574 return [check_no_compiler_messages nonpic assembly {
581 # Return 1 if the target does not use a status wrapper.
583 proc check_effective_target_unwrapped { } {
584 if { [target_info needs_status_wrapper] != "" \
585 && [target_info needs_status_wrapper] != "0" } {
591 # Return true if iconv is supported on the target. In particular IBM1047.
593 proc check_iconv_available { test_what } {
601 verbose "check_iconv_available compiling testfile $src" 2
602 set f [open $src "w"]
603 # Compile a small test program.
604 puts $f "#include <iconv.h>\n"
605 puts $f "int main (void)\n {\n iconv_t cd; \n"
606 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
607 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
608 puts $f "return 0;\n}"
611 # If the tool configuration file has not set libiconv, try "-liconv"
612 if { ![info exists libiconv] } {
613 set libiconv "-liconv"
615 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
618 if [string match "" $lines] then {
619 # No error messages, everything is OK.
621 set result [${tool}_load "./$exe" "" ""]
622 set status [lindex $result 0]
623 remote_file build delete $exe
625 verbose "check_iconv_available status is <$status>" 2
627 if { $status == "pass" } then {
635 # Return true if named sections are supported on this target.
637 proc check_named_sections_available { } {
638 return [check_no_compiler_messages named_sections assembly {
639 int __attribute__ ((section("whatever"))) foo;
643 # Return 1 if the target supports Fortran real kinds larger than real(8),
646 # When the target name changes, replace the cached result.
648 proc check_effective_target_fortran_large_real { } {
649 global et_fortran_large_real_saved
650 global et_fortran_large_real_target_name
653 if { ![info exists et_fortran_large_real_target_name] } {
654 set et_fortran_large_real_target_name ""
657 # If the target has changed since we set the cached value, clear it.
658 set current_target [current_target_name]
659 if { $current_target != $et_fortran_large_real_target_name } {
660 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
661 set et_fortran_large_real_target_name $current_target
662 if [info exists et_fortran_large_real_saved] {
663 verbose "check_effective_target_fortran_large_real: removing cached result" 2
664 unset et_fortran_large_real_saved
668 if [info exists et_fortran_large_real_saved] {
669 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
671 set et_fortran_large_real_saved 0
673 # Set up, compile, and execute a test program using large real
674 # kinds. Include the current process ID in the file names to
675 # prevent conflicts with invocations for multiple testsuites.
676 set src real[pid].f90
679 set f [open $src "w"]
680 puts $f "integer,parameter :: k = &"
681 puts $f " selected_real_kind (precision (0.0_8) + 1)"
682 puts $f "real(kind=k) :: x"
683 puts $f "x = cos (x);"
687 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
688 set lines [${tool}_target_compile $src $exe executable ""]
691 if [string match "" $lines] then {
692 # No error message, compilation succeeded.
693 remote_file build delete $exe
694 set et_fortran_large_real_saved 1
698 return $et_fortran_large_real_saved
701 # Return 1 if the target supports Fortran integer kinds larger than
702 # integer(8), 0 otherwise.
704 # When the target name changes, replace the cached result.
706 proc check_effective_target_fortran_large_int { } {
707 global et_fortran_large_int_saved
708 global et_fortran_large_int_target_name
711 if { ![info exists et_fortran_large_int_target_name] } {
712 set et_fortran_large_int_target_name ""
715 # If the target has changed since we set the cached value, clear it.
716 set current_target [current_target_name]
717 if { $current_target != $et_fortran_large_int_target_name } {
718 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
719 set et_fortran_large_int_target_name $current_target
720 if [info exists et_fortran_large_int_saved] {
721 verbose "check_effective_target_fortran_large_int: removing cached result" 2
722 unset et_fortran_large_int_saved
726 if [info exists et_fortran_large_int_saved] {
727 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
729 set et_fortran_large_int_saved 0
731 # Set up, compile, and execute a test program using large integer
732 # kinds. Include the current process ID in the file names to
733 # prevent conflicts with invocations for multiple testsuites.
737 set f [open $src "w"]
738 puts $f "integer,parameter :: k = &"
739 puts $f " selected_int_kind (range (0_8) + 1)"
740 puts $f "integer(kind=k) :: i"
744 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
745 set lines [${tool}_target_compile $src $exe executable ""]
748 if [string match "" $lines] then {
749 # No error message, compilation succeeded.
750 remote_file build delete $exe
751 set et_fortran_large_int_saved 1
755 return $et_fortran_large_int_saved
758 # Return 1 if we can statically link libgfortran, 0 otherwise.
760 # When the target name changes, replace the cached result.
762 proc check_effective_target_static_libgfortran { } {
763 global et_static_libgfortran
764 global et_static_libgfortran_target_name
767 if { ![info exists et_static_libgfortran_target_name] } {
768 set et_static_libgfortran_target_name ""
771 # If the target has changed since we set the cached value, clear it.
772 set current_target [current_target_name]
773 if { $current_target != $et_static_libgfortran_target_name } {
774 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
775 set et_static_libgfortran_target_name $current_target
776 if [info exists et_static_libgfortran_saved] {
777 verbose "check_effective_target_static_libgfortran: removing cached result" 2
778 unset et_static_libgfortran_saved
782 if [info exists et_static_libgfortran_saved] {
783 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
785 set et_static_libgfortran_saved 0
787 # Set up, compile, and execute a test program using static linking.
788 # Include the current process ID in the file names to prevent
789 # conflicts with invocations for multiple testsuites.
790 set opts "additional_flags=-static"
791 set src static[pid].f
792 set exe static[pid].x
794 set f [open $src "w"]
795 puts $f " print *, 'test'"
799 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
800 set lines [${tool}_target_compile $src $exe executable "$opts"]
803 if [string match "" $lines] then {
804 # No error message, compilation succeeded.
805 remote_file build delete $exe
806 set et_static_libgfortran_saved 1
810 return $et_static_libgfortran_saved
813 # Return 1 if the target supports executing AltiVec instructions, 0
814 # otherwise. Cache the result.
816 proc check_vmx_hw_available { } {
817 global vmx_hw_available_saved
820 if [info exists vmx_hw_available_saved] {
821 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
823 set vmx_hw_available_saved 0
825 # Some simulators are known to not support VMX instructions.
826 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
827 verbose "check_hw_available returning 0" 2
828 return $vmx_hw_available_saved
831 # Set up, compile, and execute a test program containing VMX
832 # instructions. Include the current process ID in the file
833 # names to prevent conflicts with invocations for multiple
838 set f [open $src "w"]
839 puts $f "int main() {"
840 puts $f "#ifdef __MACH__"
841 puts $f " asm volatile (\"vor v0,v0,v0\");"
843 puts $f " asm volatile (\"vor 0,0,0\");"
845 puts $f " return 0; }"
848 # Most targets don't require special flags for this test case, but
850 if [istarget *-*-darwin*] {
851 set opts "additional_flags=-maltivec"
856 verbose "check_vmx_hw_available compiling testfile $src" 2
857 set lines [${tool}_target_compile $src $exe executable "$opts"]
860 if [string match "" $lines] then {
861 # No error message, compilation succeeded.
862 set result [${tool}_load "./$exe" "" ""]
863 set status [lindex $result 0]
864 remote_file build delete $exe
865 verbose "check_vmx_hw_available testfile status is <$status>" 2
867 if { $status == "pass" } then {
868 set vmx_hw_available_saved 1
871 verbose "check_vmx_hw_availalble testfile compilation failed" 2
875 return $vmx_hw_available_saved
878 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
879 # complex float arguments. This affects gfortran tests that call cabsf
880 # in libm built by an earlier compiler. Return 1 if libm uses the same
881 # argument passing as the compiler under test, 0 otherwise.
883 # When the target name changes, replace the cached result.
885 proc check_effective_target_broken_cplxf_arg { } {
886 global et_broken_cplxf_arg_saved
887 global et_broken_cplxf_arg_target_name
890 # Skip the work for targets known not to be affected.
891 if { ![istarget powerpc64-*-linux*] } {
893 } elseif { [is-effective-target ilp32] } {
897 if { ![info exists et_broken_cplxf_arg_target_name] } {
898 set et_broken_cplxf_arg_target_name ""
901 # If the target has changed since we set the cached value, clear it.
902 set current_target [current_target_name]
903 if { $current_target != $et_broken_cplxf_arg_target_name } {
904 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
905 set et_broken_cplxf_arg_target_name $current_target
906 if [info exists et_broken_cplxf_arg_saved] {
907 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
908 unset et_broken_cplxf_arg_saved
912 if [info exists et_broken_cplxf_arg_saved] {
913 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
915 set et_broken_cplxf_arg_saved 0
916 # This is only known to affect one target.
917 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
918 set et_broken_cplxf_arg_saved 0
919 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
920 return $et_broken_cplxf_arg_saved
923 # Set up, compile, and execute a C test program that calls cabsf.
927 set f [open $src "w"]
928 puts $f "#include <complex.h>"
929 puts $f "extern void abort (void);"
930 puts $f "float fabsf (float);"
931 puts $f "float cabsf (_Complex float);"
932 puts $f "int main ()"
934 puts $f " _Complex float cf;"
936 puts $f " cf = 3 + 4.0fi;"
937 puts $f " f = cabsf (cf);"
938 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
943 set lines [${tool}_target_compile $src $exe executable "-lm"]
946 if [string match "" $lines] {
947 # No error message, compilation succeeded.
948 set result [${tool}_load "./$exe" "" ""]
949 set status [lindex $result 0]
950 remote_file build delete $exe
952 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
954 if { $status != "pass" } {
955 set et_broken_cplxf_arg_saved 1
958 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
961 return $et_broken_cplxf_arg_saved
964 proc check_alpha_max_hw_available { } {
965 global alpha_max_hw_available_saved
968 if [info exists alpha_max_hw_available_saved] {
969 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
971 set alpha_max_hw_available_saved 0
973 # Set up, compile, and execute a test program probing bit 8 of the
974 # architecture mask, which indicates presence of MAX instructions.
978 set f [open $src "w"]
979 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
982 verbose "check_alpha_max_hw_available compiling testfile $src" 2
983 set lines [${tool}_target_compile $src $exe executable ""]
986 if [string match "" $lines] then {
987 # No error message, compilation succeeded.
988 set result [${tool}_load "./$exe" "" ""]
989 set status [lindex $result 0]
990 remote_file build delete $exe
991 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
993 if { $status == "pass" } then {
994 set alpha_max_hw_available_saved 1
997 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1001 return $alpha_max_hw_available_saved
1004 # Returns true iff the FUNCTION is available on the target system.
1005 # (This is essentially a Tcl implementation of Autoconf's
1008 proc check_function_available { function } {
1009 set var "${function}_available_saved"
1013 if {![info exists $var]} {
1016 # Check to make sure.
1017 set src "function[pid].c"
1018 set exe "function[pid].exe"
1020 set f [open $src "w"]
1021 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1022 puts $f "char $function ();\n"
1023 puts $f "int main () { $function (); }"
1026 set lines [${tool}_target_compile $src $exe executable ""]
1030 if {![string match "" $lines]} then {
1032 verbose -log "$function is not available"
1034 verbose -log "$function is available"
1041 # Returns true iff "fork" is available on the target system.
1043 proc check_fork_available {} {
1044 return [check_function_available "fork"]
1047 # Returns true iff "mkfifo" is available on the target system.
1049 proc check_mkfifo_available {} {
1050 if {[istarget *-*-cygwin*]} {
1051 # Cygwin has mkfifo, but support is incomplete.
1055 return [check_function_available "mkfifo"]
1058 # Returns true iff "__cxa_atexit" is used on the target system.
1060 proc check_cxa_atexit_available { } {
1061 global et_cxa_atexit
1062 global et_cxa_atexit_target_name
1065 if { ![info exists et_cxa_atexit_target_name] } {
1066 set et_cxa_atexit_target_name ""
1069 # If the target has changed since we set the cached value, clear it.
1070 set current_target [current_target_name]
1071 if { $current_target != $et_cxa_atexit_target_name } {
1072 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1073 set et_cxa_atexit_target_name $current_target
1074 if [info exists et_cxa_atexit] {
1075 verbose "check_cxa_atexit_available: removing cached result" 2
1080 if [info exists et_cxa_atexit] {
1081 verbose "check_cxa_atexit_available: using cached result" 2
1082 } elseif { [istarget "hppa*-*-hpux10*"] } {
1083 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1088 # Set up, compile, and execute a C++ test program that depends
1089 # on correct ordering of static object destructors. This is
1090 # indicative of the presence and use of __cxa_atexit.
1091 set src cxaatexit[pid].cc
1092 set exe cxaatexit[pid].x
1094 set f [open $src "w"]
1095 puts $f "#include <stdlib.h>"
1096 puts $f "static unsigned int count;"
1099 puts $f " X() { count = 1; }"
1102 puts $f " if (count != 3)"
1104 puts $f " count = 4;"
1109 puts $f " static X x;"
1113 puts $f " Y() { f(); count = 2; }"
1116 puts $f " if (count != 2)"
1118 puts $f " count = 3;"
1122 puts $f "int main()"
1123 puts $f "{ return 0; }"
1126 set lines [${tool}_target_compile $src $exe executable ""]
1129 if [string match "" $lines] {
1130 # No error message, compilation succeeded.
1131 set result [${tool}_load "./$exe" "" ""]
1132 set status [lindex $result 0]
1133 remote_file build delete $exe
1135 verbose "check_cxa_atexit_available: status is <$status>" 2
1137 if { $status == "pass" } {
1141 verbose "check_cxa_atexit_available: compilation failed" 2
1144 return $et_cxa_atexit
1148 # Return 1 if we're generating 32-bit code using default options, 0
1151 proc check_effective_target_ilp32 { } {
1152 return [check_no_compiler_messages ilp32 object {
1153 int dummy[sizeof (int) == 4
1154 && sizeof (void *) == 4
1155 && sizeof (long) == 4 ? 1 : -1];
1159 # Return 1 if we're generating 32-bit or larger integers using default
1160 # options, 0 otherwise.
1162 proc check_effective_target_int32plus { } {
1163 return [check_no_compiler_messages int32plus object {
1164 int dummy[sizeof (int) >= 4 ? 1 : -1];
1168 # Return 1 if we're generating 32-bit or larger pointers using default
1169 # options, 0 otherwise.
1171 proc check_effective_target_ptr32plus { } {
1172 return [check_no_compiler_messages ptr32plus object {
1173 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1177 # Return 1 if we support 32-bit or larger array and structure sizes
1178 # using default options, 0 otherwise.
1180 proc check_effective_target_size32plus { } {
1181 return [check_no_compiler_messages size32plus object {
1186 # Returns 1 if we're generating 16-bit or smaller integers with the
1187 # default options, 0 otherwise.
1189 proc check_effective_target_int16 { } {
1190 return [check_no_compiler_messages int16 object {
1191 int dummy[sizeof (int) < 4 ? 1 : -1];
1195 # Return 1 if we're generating 64-bit code using default options, 0
1198 proc check_effective_target_lp64 { } {
1199 return [check_no_compiler_messages lp64 object {
1200 int dummy[sizeof (int) == 4
1201 && sizeof (void *) == 8
1202 && sizeof (long) == 8 ? 1 : -1];
1206 # Return 1 if the target supports long double larger than double,
1209 proc check_effective_target_large_long_double { } {
1210 return [check_no_compiler_messages large_long_double object {
1211 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1216 # Return 1 if the target supports compiling decimal floating point,
1219 proc check_effective_target_dfp_nocache { } {
1220 verbose "check_effective_target_dfp_nocache: compiling source" 2
1221 set ret [string match "" [get_compiler_messages dfp 0 object {
1222 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1224 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1228 proc check_effective_target_dfprt_nocache { } {
1233 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1234 # Set up, compile, and execute a test program containing decimal
1236 set src dfprt[pid].c
1237 set exe dfprt[pid].x
1239 set f [open $src "w"]
1240 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1241 puts $f "int main () { z = x + y; return 0; }"
1244 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1245 set lines [${tool}_target_compile $src $exe executable ""]
1248 if [string match "" $lines] then {
1249 # No error message, compilation succeeded.
1250 set result [${tool}_load "./$exe" "" ""]
1251 set status [lindex $result 0]
1252 remote_file build delete $exe
1253 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1254 if { $status == "pass" } then {
1259 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1262 # Return 1 if the target supports compiling Decimal Floating Point,
1265 # This won't change for different subtargets so cache the result.
1267 proc check_effective_target_dfp { } {
1270 if [info exists et_dfp_saved] {
1271 verbose "check_effective_target_dfp: using cached result" 2
1273 set et_dfp_saved [check_effective_target_dfp_nocache]
1275 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1276 return $et_dfp_saved
1279 # Return 1 if the target supports linking and executing Decimal Floating
1280 # Point, # 0 otherwise.
1282 # This won't change for different subtargets so cache the result.
1284 proc check_effective_target_dfprt { } {
1285 global et_dfprt_saved
1288 if [info exists et_dfprt_saved] {
1289 verbose "check_effective_target_dfprt: using cached result" 2
1291 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1293 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1294 return $et_dfprt_saved
1297 # Return 1 if the target needs a command line argument to enable a SIMD
1300 proc check_effective_target_vect_cmdline_needed { } {
1301 global et_vect_cmdline_needed_saved
1302 global et_vect_cmdline_needed_target_name
1304 if { ![info exists et_vect_cmdline_needed_target_name] } {
1305 set et_vect_cmdline_needed_target_name ""
1308 # If the target has changed since we set the cached value, clear it.
1309 set current_target [current_target_name]
1310 if { $current_target != $et_vect_cmdline_needed_target_name } {
1311 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1312 set et_vect_cmdline_needed_target_name $current_target
1313 if { [info exists et_vect_cmdline_needed_saved] } {
1314 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1315 unset et_vect_cmdline_needed_saved
1319 if [info exists et_vect_cmdline_needed_saved] {
1320 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1322 set et_vect_cmdline_needed_saved 1
1323 if { [istarget ia64-*-*]
1324 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1325 && [check_effective_target_lp64])
1326 || ([istarget powerpc*-*-*]
1327 && ([check_effective_target_powerpc_spe]
1328 || [check_effective_target_powerpc_altivec]))} {
1329 set et_vect_cmdline_needed_saved 0
1333 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1334 return $et_vect_cmdline_needed_saved
1337 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1339 # This won't change for different subtargets so cache the result.
1341 proc check_effective_target_vect_int { } {
1342 global et_vect_int_saved
1344 if [info exists et_vect_int_saved] {
1345 verbose "check_effective_target_vect_int: using cached result" 2
1347 set et_vect_int_saved 0
1348 if { [istarget i?86-*-*]
1349 || [istarget powerpc*-*-*]
1350 || [istarget spu-*-*]
1351 || [istarget x86_64-*-*]
1352 || [istarget sparc*-*-*]
1353 || [istarget alpha*-*-*]
1354 || [istarget ia64-*-*] } {
1355 set et_vect_int_saved 1
1359 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1360 return $et_vect_int_saved
1363 # Return 1 is this is an arm target using 32-bit instructions
1364 proc check_effective_target_arm32 { } {
1365 global et_arm32_saved
1366 global et_arm32_target_name
1367 global compiler_flags
1369 if { ![info exists et_arm32_target_name] } {
1370 set et_arm32_target_name ""
1373 # If the target has changed since we set the cached value, clear it.
1374 set current_target [current_target_name]
1375 if { $current_target != $et_arm32_target_name } {
1376 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1377 set et_arm32_target_name $current_target
1378 if { [info exists et_arm32_saved] } {
1379 verbose "check_effective_target_arm32: removing cached result" 2
1380 unset et_arm32_saved
1384 if [info exists et_arm32_saved] {
1385 verbose "check-effective_target_arm32: using cached result" 2
1387 set et_arm32_saved 0
1388 if { [istarget arm-*-*]
1389 || [istarget strongarm*-*-*]
1390 || [istarget xscale-*-*] } {
1391 if ![string match "*-mthumb *" $compiler_flags] {
1392 set et_arm32_saved 1
1396 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1397 return $et_arm32_saved
1400 # Return 1 if this is an ARM target supporting -mfpu=vfp
1401 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1404 proc check_effective_target_arm_vfp_ok { } {
1405 if { [check_effective_target_arm32] } {
1406 return [check_no_compiler_messages arm_vfp_ok object {
1408 } "-mfpu=vfp -mfloat-abi=softfp"]
1414 # Return 1 if this is a PowerPC target with floating-point registers.
1416 proc check_effective_target_powerpc_fprs { } {
1417 if { [istarget powerpc*-*-*]
1418 || [istarget rs6000-*-*] } {
1419 return [check_no_compiler_messages powerpc_fprs object {
1431 # Return 1 if this is a PowerPC target supporting -maltivec.
1433 proc check_effective_target_powerpc_altivec_ok { } {
1434 if { [istarget powerpc*-*-*]
1435 || [istarget rs6000-*-*] } {
1436 # AltiVec is not supported on Aix.
1437 if { [istarget powerpc*-*-aix*] } {
1440 return [check_no_compiler_messages powerpc_altivec_ok object {
1448 # Return 1 if this is a PowerPC target with SPE enabled.
1450 proc check_effective_target_powerpc_spe { } {
1451 if { [istarget powerpc*-*-*] } {
1452 return [check_no_compiler_messages powerpc_spe object {
1464 # Return 1 if this is a PowerPC target with Altivec enabled.
1466 proc check_effective_target_powerpc_altivec { } {
1467 if { [istarget powerpc*-*-*] } {
1468 return [check_no_compiler_messages powerpc_altivec object {
1480 # Return 1 if the target supports hardware vector shift operation.
1482 proc check_effective_target_vect_shift { } {
1483 global et_vect_shift_saved
1485 if [info exists et_vect_shift_saved] {
1486 verbose "check_effective_target_vect_shift: using cached result" 2
1488 set et_vect_shift_saved 0
1489 if { [istarget powerpc*-*-*]
1490 || [istarget ia64-*-*]
1491 || [istarget i?86-*-*]
1492 || [istarget x86_64-*-*] } {
1493 set et_vect_shift_saved 1
1497 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1498 return $et_vect_shift_saved
1501 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1503 # This can change for different subtargets so do not cache the result.
1505 proc check_effective_target_vect_long { } {
1506 if { [istarget i?86-*-*]
1507 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1508 || [istarget x86_64-*-*]
1509 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1515 verbose "check_effective_target_vect_long: returning $answer" 2
1519 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1521 # This won't change for different subtargets so cache the result.
1523 proc check_effective_target_vect_float { } {
1524 global et_vect_float_saved
1526 if [info exists et_vect_float_saved] {
1527 verbose "check_effective_target_vect_float: using cached result" 2
1529 set et_vect_float_saved 0
1530 if { [istarget i?86-*-*]
1531 || [istarget powerpc*-*-*]
1532 || [istarget spu-*-*]
1533 || [istarget mipsisa64*-*-*]
1534 || [istarget x86_64-*-*]
1535 || [istarget ia64-*-*] } {
1536 set et_vect_float_saved 1
1540 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1541 return $et_vect_float_saved
1544 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1546 # This won't change for different subtargets so cache the result.
1548 proc check_effective_target_vect_double { } {
1549 global et_vect_double_saved
1551 if [info exists et_vect_double_saved] {
1552 verbose "check_effective_target_vect_double: using cached result" 2
1554 set et_vect_double_saved 0
1555 if { [istarget i?86-*-*]
1556 || [istarget x86_64-*-*]
1557 || [istarget spu-*-*] } {
1558 set et_vect_double_saved 1
1562 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1563 return $et_vect_double_saved
1566 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1568 # This won't change for different subtargets so cache the result.
1570 proc check_effective_target_vect_no_compare_double { } {
1571 global et_vect_no_compare_double_saved
1573 if [info exists et_vect_no_compare_double_saved] {
1574 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1576 set et_vect_no_compare_double_saved 0
1577 if { [istarget spu-*-*] } {
1578 set et_vect_no_compare_double_saved 1
1582 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1583 return $et_vect_no_compare_double_saved
1586 # Return 1 if the target plus current options does not support a vector
1587 # max instruction on "int", 0 otherwise.
1589 # This won't change for different subtargets so cache the result.
1591 proc check_effective_target_vect_no_int_max { } {
1592 global et_vect_no_int_max_saved
1594 if [info exists et_vect_no_int_max_saved] {
1595 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1597 set et_vect_no_int_max_saved 0
1598 if { [istarget sparc*-*-*]
1599 || [istarget spu-*-*]
1600 || [istarget alpha*-*-*] } {
1601 set et_vect_no_int_max_saved 1
1604 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1605 return $et_vect_no_int_max_saved
1608 # Return 1 if the target plus current options does not support a vector
1609 # add instruction on "int", 0 otherwise.
1611 # This won't change for different subtargets so cache the result.
1613 proc check_effective_target_vect_no_int_add { } {
1614 global et_vect_no_int_add_saved
1616 if [info exists et_vect_no_int_add_saved] {
1617 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1619 set et_vect_no_int_add_saved 0
1620 # Alpha only supports vector add on V8QI and V4HI.
1621 if { [istarget alpha*-*-*] } {
1622 set et_vect_no_int_add_saved 1
1625 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1626 return $et_vect_no_int_add_saved
1629 # Return 1 if the target plus current options does not support vector
1630 # bitwise instructions, 0 otherwise.
1632 # This won't change for different subtargets so cache the result.
1634 proc check_effective_target_vect_no_bitwise { } {
1635 global et_vect_no_bitwise_saved
1637 if [info exists et_vect_no_bitwise_saved] {
1638 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1640 set et_vect_no_bitwise_saved 0
1642 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1643 return $et_vect_no_bitwise_saved
1646 # Return 1 if the target plus current options supports a vector
1647 # widening summation of *short* args into *int* result, 0 otherwise.
1648 # A target can also support this widening summation if it can support
1649 # promotion (unpacking) from shorts to ints.
1651 # This won't change for different subtargets so cache the result.
1653 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1654 global et_vect_widen_sum_hi_to_si
1656 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1657 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1659 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1660 if { [istarget powerpc*-*-*] } {
1661 set et_vect_widen_sum_hi_to_si_saved 1
1664 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1665 return $et_vect_widen_sum_hi_to_si_saved
1668 # Return 1 if the target plus current options supports a vector
1669 # widening summation of *char* args into *short* result, 0 otherwise.
1670 # A target can also support this widening summation if it can support
1671 # promotion (unpacking) from chars to shorts.
1673 # This won't change for different subtargets so cache the result.
1675 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1676 global et_vect_widen_sum_qi_to_hi
1678 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1679 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1681 set et_vect_widen_sum_qi_to_hi_saved 0
1682 if { [check_effective_target_vect_unpack] } {
1683 set et_vect_widen_sum_qi_to_hi_saved 1
1686 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1687 return $et_vect_widen_sum_qi_to_hi_saved
1690 # Return 1 if the target plus current options supports a vector
1691 # widening summation of *char* args into *int* result, 0 otherwise.
1693 # This won't change for different subtargets so cache the result.
1695 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1696 global et_vect_widen_sum_qi_to_si
1698 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1699 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1701 set et_vect_widen_sum_qi_to_si_saved 0
1702 if { [istarget powerpc*-*-*] } {
1703 set et_vect_widen_sum_qi_to_si_saved 1
1706 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1707 return $et_vect_widen_sum_qi_to_si_saved
1710 # Return 1 if the target plus current options supports a vector
1711 # widening multiplication of *char* args into *short* result, 0 otherwise.
1712 # A target can also support this widening multplication if it can support
1713 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1714 # multiplication of shorts).
1716 # This won't change for different subtargets so cache the result.
1719 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1720 global et_vect_widen_mult_qi_to_hi
1722 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1723 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1725 if { [check_effective_target_vect_unpack]
1726 && [check_effective_target_vect_short_mult] } {
1727 set et_vect_widen_mult_qi_to_hi_saved 1
1729 set et_vect_widen_mult_qi_to_hi_saved 0
1731 if { [istarget powerpc*-*-*] } {
1732 set et_vect_widen_mult_qi_to_hi_saved 1
1735 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1736 return $et_vect_widen_mult_qi_to_hi_saved
1739 # Return 1 if the target plus current options supports a vector
1740 # widening multiplication of *short* args into *int* result, 0 otherwise.
1741 # A target can also support this widening multplication if it can support
1742 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1743 # multiplication of ints).
1745 # This won't change for different subtargets so cache the result.
1748 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1749 global et_vect_widen_mult_hi_to_si
1751 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1752 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1754 if { [check_effective_target_vect_unpack]
1755 && [check_effective_target_vect_int_mult] } {
1756 set et_vect_widen_mult_hi_to_si_saved 1
1758 set et_vect_widen_mult_hi_to_si_saved 0
1760 if { [istarget powerpc*-*-*]
1761 || [istarget spu-*-*]
1762 || [istarget i?86-*-*]
1763 || [istarget x86_64-*-*] } {
1764 set et_vect_widen_mult_hi_to_si_saved 1
1767 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1768 return $et_vect_widen_mult_hi_to_si_saved
1771 # Return 1 if the target plus current options supports a vector
1772 # dot-product of signed chars, 0 otherwise.
1774 # This won't change for different subtargets so cache the result.
1776 proc check_effective_target_vect_sdot_qi { } {
1777 global et_vect_sdot_qi
1779 if [info exists et_vect_sdot_qi_saved] {
1780 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1782 set et_vect_sdot_qi_saved 0
1784 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1785 return $et_vect_sdot_qi_saved
1788 # Return 1 if the target plus current options supports a vector
1789 # dot-product of unsigned chars, 0 otherwise.
1791 # This won't change for different subtargets so cache the result.
1793 proc check_effective_target_vect_udot_qi { } {
1794 global et_vect_udot_qi
1796 if [info exists et_vect_udot_qi_saved] {
1797 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1799 set et_vect_udot_qi_saved 0
1800 if { [istarget powerpc*-*-*] } {
1801 set et_vect_udot_qi_saved 1
1804 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1805 return $et_vect_udot_qi_saved
1808 # Return 1 if the target plus current options supports a vector
1809 # dot-product of signed shorts, 0 otherwise.
1811 # This won't change for different subtargets so cache the result.
1813 proc check_effective_target_vect_sdot_hi { } {
1814 global et_vect_sdot_hi
1816 if [info exists et_vect_sdot_hi_saved] {
1817 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1819 set et_vect_sdot_hi_saved 0
1820 if { [istarget powerpc*-*-*]
1821 || [istarget i?86-*-*]
1822 || [istarget x86_64-*-*] } {
1823 set et_vect_sdot_hi_saved 1
1826 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1827 return $et_vect_sdot_hi_saved
1830 # Return 1 if the target plus current options supports a vector
1831 # dot-product of unsigned shorts, 0 otherwise.
1833 # This won't change for different subtargets so cache the result.
1835 proc check_effective_target_vect_udot_hi { } {
1836 global et_vect_udot_hi
1838 if [info exists et_vect_udot_hi_saved] {
1839 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1841 set et_vect_udot_hi_saved 0
1842 if { [istarget powerpc*-*-*] } {
1843 set et_vect_udot_hi_saved 1
1846 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1847 return $et_vect_udot_hi_saved
1851 # Return 1 if the target plus current options supports a vector
1852 # demotion (packing) of shorts (to chars) and ints (to shorts)
1853 # using modulo arithmetic, 0 otherwise.
1855 # This won't change for different subtargets so cache the result.
1857 proc check_effective_target_vect_pack_mod { } {
1858 global et_vect_pack_mod
1860 if [info exists et_vect_pack_mod_saved] {
1861 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1863 set et_vect_pack_mod_saved 0
1864 if { [istarget powerpc*-*-*]
1865 || [istarget i?86-*-*]
1866 || [istarget x86_64-*-*] } {
1867 set et_vect_pack_mod_saved 1
1870 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1871 return $et_vect_pack_mod_saved
1874 # Return 1 if the target plus current options supports a vector
1875 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1877 # This won't change for different subtargets so cache the result.
1879 proc check_effective_target_vect_unpack { } {
1880 global et_vect_unpack
1882 if [info exists et_vect_unpack_saved] {
1883 verbose "check_effective_target_vect_unpack: using cached result" 2
1885 set et_vect_unpack_saved 0
1886 if { [istarget powerpc*-*-*]
1887 || [istarget i?86-*-*]
1888 || [istarget x86_64-*-*] } {
1889 set et_vect_unpack_saved 1
1892 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1893 return $et_vect_unpack_saved
1896 # Return 1 if the target plus current options does not support a vector
1897 # alignment mechanism, 0 otherwise.
1899 # This won't change for different subtargets so cache the result.
1901 proc check_effective_target_vect_no_align { } {
1902 global et_vect_no_align_saved
1904 if [info exists et_vect_no_align_saved] {
1905 verbose "check_effective_target_vect_no_align: using cached result" 2
1907 set et_vect_no_align_saved 0
1908 if { [istarget mipsisa64*-*-*]
1909 || [istarget sparc*-*-*]
1910 || [istarget ia64-*-*] } {
1911 set et_vect_no_align_saved 1
1914 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1915 return $et_vect_no_align_saved
1918 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1920 proc check_effective_target_vect_condition { } {
1921 global et_vect_cond_saved
1923 if [info exists et_vect_cond_saved] {
1924 verbose "check_effective_target_vect_cond: using cached result" 2
1926 set et_vect_cond_saved 0
1927 if { [istarget powerpc*-*-*]
1928 || [istarget ia64-*-*]
1929 || [istarget i?86-*-*]
1930 || [istarget x86_64-*-*] } {
1931 set et_vect_cond_saved 1
1935 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1936 return $et_vect_cond_saved
1939 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1941 proc check_effective_target_vect_char_mult { } {
1942 global et_vect_char_mult_saved
1944 if [info exists et_vect_char_mult_saved] {
1945 verbose "check_effective_target_vect_char_mult: using cached result" 2
1947 set et_vect_char_mult_saved 0
1948 if { [istarget ia64-*-*]
1949 || [istarget i?86-*-*]
1950 || [istarget x86_64-*-*] } {
1951 set et_vect_char_mult_saved 1
1955 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1956 return $et_vect_char_mult_saved
1959 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1961 proc check_effective_target_vect_short_mult { } {
1962 global et_vect_short_mult_saved
1964 if [info exists et_vect_short_mult_saved] {
1965 verbose "check_effective_target_vect_short_mult: using cached result" 2
1967 set et_vect_short_mult_saved 0
1968 if { [istarget ia64-*-*]
1969 || [istarget i?86-*-*]
1970 || [istarget x86_64-*-*] } {
1971 set et_vect_short_mult_saved 1
1975 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1976 return $et_vect_short_mult_saved
1979 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1981 proc check_effective_target_vect_int_mult { } {
1982 global et_vect_int_mult_saved
1984 if [info exists et_vect_int_mult_saved] {
1985 verbose "check_effective_target_vect_int_mult: using cached result" 2
1987 set et_vect_int_mult_saved 0
1988 if { [istarget powerpc*-*-*]
1989 || [istarget i?86-*-*]
1990 || [istarget x86_64-*-*] } {
1991 set et_vect_int_mult_saved 1
1995 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1996 return $et_vect_int_mult_saved
1999 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2001 proc check_effective_target_vect_extract_even_odd { } {
2002 global et_vect_extract_even_odd_saved
2004 if [info exists et_vect_extract_even_odd_saved] {
2005 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2007 set et_vect_extract_even_odd_saved 0
2008 if { [istarget powerpc*-*-*] } {
2009 set et_vect_extract_even_odd_saved 1
2013 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2014 return $et_vect_extract_even_odd_saved
2017 # Return 1 if the target supports vector interleaving, 0 otherwise.
2019 proc check_effective_target_vect_interleave { } {
2020 global et_vect_interleave_saved
2022 if [info exists et_vect_interleave_saved] {
2023 verbose "check_effective_target_vect_interleave: using cached result" 2
2025 set et_vect_interleave_saved 0
2026 if { [istarget powerpc*-*-*]
2027 || [istarget i?86-*-*]
2028 || [istarget x86_64-*-*] } {
2029 set et_vect_interleave_saved 1
2033 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2034 return $et_vect_interleave_saved
2037 # Return 1 if the target supports section-anchors
2039 proc check_effective_target_section_anchors { } {
2040 global et_section_anchors_saved
2042 if [info exists et_section_anchors_saved] {
2043 verbose "check_effective_target_section_anchors: using cached result" 2
2045 set et_section_anchors_saved 0
2046 if { [istarget powerpc*-*-*] } {
2047 set et_section_anchors_saved 1
2051 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2052 return $et_section_anchors_saved
2055 # Return 1 if the target supports atomic operations on "int" and "long".
2057 proc check_effective_target_sync_int_long { } {
2058 global et_sync_int_long_saved
2060 if [info exists et_sync_int_long_saved] {
2061 verbose "check_effective_target_sync_int_long: using cached result" 2
2063 set et_sync_int_long_saved 0
2064 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2065 # load-reserved/store-conditional instructions.
2066 if { [istarget ia64-*-*]
2067 || [istarget i?86-*-*]
2068 || [istarget x86_64-*-*]
2069 || [istarget alpha*-*-*]
2070 || [istarget s390*-*-*]
2071 || [istarget powerpc*-*-*]
2072 || [istarget sparc64-*-*]
2073 || [istarget sparcv9-*-*] } {
2074 set et_sync_int_long_saved 1
2078 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2079 return $et_sync_int_long_saved
2082 # Return 1 if the target supports atomic operations on "char" and "short".
2084 proc check_effective_target_sync_char_short { } {
2085 global et_sync_char_short_saved
2087 if [info exists et_sync_char_short_saved] {
2088 verbose "check_effective_target_sync_char_short: using cached result" 2
2090 set et_sync_char_short_saved 0
2091 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2092 # load-reserved/store-conditional instructions.
2093 if { [istarget ia64-*-*]
2094 || [istarget i?86-*-*]
2095 || [istarget x86_64-*-*]
2096 || [istarget alpha*-*-*]
2097 || [istarget s390*-*-*]
2098 || [istarget powerpc*-*-*]
2099 || [istarget sparc64-*-*]
2100 || [istarget sparcv9-*-*] } {
2101 set et_sync_char_short_saved 1
2105 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2106 return $et_sync_char_short_saved
2109 # Return 1 if the target uses a ColdFire FPU.
2111 proc check_effective_target_coldfire_fpu { } {
2112 return [check_no_compiler_messages coldfire_fpu assembly {
2119 # Return true if this is a uClibc target.
2121 proc check_effective_target_uclibc {} {
2122 return [check_no_compiler_messages uclibc object {
2123 #include <features.h>
2124 #if !defined (__UCLIBC__)
2130 # Return true if this is a uclibc target and if the uclibc feature
2131 # described by __$feature__ is not present.
2133 proc check_missing_uclibc_feature {feature} {
2134 return [check_no_compiler_messages $feature object "
2135 #include <features.h>
2136 #if !defined (__UCLIBC) || defined (__${feature}__)
2142 # Return true if this is a Newlib target.
2144 proc check_effective_target_newlib {} {
2145 return [check_no_compiler_messages newlib object {
2151 # (a) an error of a few ULP is expected in string to floating-point
2152 # conversion functions; and
2153 # (b) overflow is not always detected correctly by those functions.
2155 proc check_effective_target_lax_strtofp {} {
2156 # By default, assume that all uClibc targets suffer from this.
2157 return [check_effective_target_uclibc]
2160 # Return 1 if this is a target for which wcsftime is a dummy
2161 # function that always returns 0.
2163 proc check_effective_target_dummy_wcsftime {} {
2164 # By default, assume that all uClibc targets suffer from this.
2165 return [check_effective_target_uclibc]
2168 # Return 1 if constructors with initialization priority arguments are
2169 # supposed on this target.
2171 proc check_effective_target_init_priority {} {
2172 return [check_no_compiler_messages init_priority assembly "
2173 void f() __attribute__((constructor (1000)));
2178 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2179 # This can be used with any check_* proc that takes no argument and
2180 # returns only 1 or 0. It could be used with check_* procs that take
2181 # arguments with keywords that pass particular arguments.
2183 proc is-effective-target { arg } {
2185 if { [info procs check_effective_target_${arg}] != [list] } {
2186 set selected [check_effective_target_${arg}]
2189 "vmx_hw" { set selected [check_vmx_hw_available] }
2190 "named_sections" { set selected [check_named_sections_available] }
2191 "gc_sections" { set selected [check_gc_sections_available] }
2192 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2193 default { error "unknown effective target keyword `$arg'" }
2196 verbose "is-effective-target: $arg $selected" 2
2200 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2202 proc is-effective-target-keyword { arg } {
2203 if { [info procs check_effective_target_${arg}] != [list] } {
2206 # These have different names for their check_* procs.
2208 "vmx_hw" { return 1 }
2209 "named_sections" { return 1 }
2210 "gc_sections" { return 1 }
2211 "cxa_atexit" { return 1 }
2212 default { return 0 }
2217 # Return 1 if target default to short enums
2219 proc check_effective_target_short_enums { } {
2220 return [check_no_compiler_messages short_enums assembly {
2222 int s[sizeof (enum foo) == 1 ? 1 : -1];
2226 # Return 1 if target supports merging string constants at link time.
2228 proc check_effective_target_string_merging { } {
2229 return [check_no_messages_and_pattern string_merging \
2230 "rodata\\.str" assembly {
2231 const char *var = "String";
2235 # Return 1 if target has the basic signed and unsigned types in
2236 # <stdint.h>, 0 otherwise.
2238 proc check_effective_target_stdint_types { } {
2239 return [check_no_compiler_messages stdint_types assembly {
2241 int8_t a; int16_t b; int32_t c; int64_t d;
2242 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2246 # Return 1 if programs are intended to be run on a simulator
2247 # (i.e. slowly) rather than hardware (i.e. fast).
2249 proc check_effective_target_simulator { } {
2251 # All "src/sim" simulators set this one.
2252 if [board_info target exists is_simulator] {
2253 return [board_info target is_simulator]
2256 # The "sid" simulators don't set that one, but at least they set
2258 if [board_info target exists slow_simulator] {
2259 return [board_info target slow_simulator]
2265 # Return 1 if the target is a VxWorks RTP.
2267 proc check_effective_target_vxworks_kernel { } {
2268 return [check_no_compiler_messages vxworks_kernel assembly {
2269 #if !defined __vxworks || defined __RTP__
2275 # Return 1 if the target is expected to provide wide character support.
2277 proc check_effective_target_wchar { } {
2278 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2281 return [check_no_compiler_messages wchar assembly {