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 # VxWorks kernel modules are relocatable objects linked with -r,
290 # while RTP executables are linked with -q (--emit-relocs).
291 # Both of these options are incompatible with --gc-sections.
292 if { [istarget *-*-vxworks*] } {
293 set gc_sections_available_saved 0
297 # Check if the ld used by gcc supports --gc-sections.
298 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
299 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
300 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
301 set ld_output [remote_exec host "$gcc_ld" "--help"]
302 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
303 set gc_sections_available_saved 1
305 set gc_sections_available_saved 0
308 return $gc_sections_available_saved
311 # Return true if profiling is supported on the target.
313 proc check_profiling_available { test_what } {
314 global profiling_available_saved
316 verbose "Profiling argument is <$test_what>" 1
318 # These conditions depend on the argument so examine them before
319 # looking at the cache variable.
321 # Support for -p on solaris2 relies on mcrt1.o which comes with the
322 # vendor compiler. We cannot reliably predict the directory where the
323 # vendor compiler (and thus mcrt1.o) is installed so we can't
324 # necessarily find mcrt1.o even if we have it.
325 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
329 # Support for -p on irix relies on libprof1.a which doesn't appear to
330 # exist on any irix6 system currently posting testsuite results.
331 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
332 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
333 if { [istarget mips*-*-irix*]
334 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
338 # At present, there is no profiling support on NetWare.
339 if { [istarget *-*-netware*] } {
343 # Now examine the cache variable.
344 if {![info exists profiling_available_saved]} {
345 # Some targets don't have any implementation of __bb_init_func or are
346 # missing other needed machinery.
347 if { [istarget mmix-*-*]
348 || [istarget arm*-*-eabi*]
349 || [istarget arm*-*-elf]
350 || [istarget arm*-*-symbianelf*]
351 || [istarget bfin-*-*]
352 || [istarget powerpc-*-eabi*]
353 || [istarget strongarm*-*-elf]
354 || [istarget xscale*-*-elf]
355 || [istarget cris-*-*]
356 || [istarget h8300-*-*]
357 || [istarget m32c-*-elf]
358 || [istarget m68k-*-elf]
359 || [istarget mips*-*-elf]
360 || [istarget xtensa-*-elf]
361 || [istarget *-*-vxworks*]
362 || [istarget *-*-windiss] } {
363 set profiling_available_saved 0
365 set profiling_available_saved 1
369 return $profiling_available_saved
372 # Return 1 if target has packed layout of structure members by
373 # default, 0 otherwise. Note that this is slightly different than
374 # whether the target has "natural alignment": both attributes may be
377 proc check_effective_target_default_packed { } {
378 return [check_no_compiler_messages default_packed assembly {
379 struct x { char a; long b; } c;
380 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
384 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
385 # documentation, where the test also comes from.
387 proc check_effective_target_pcc_bitfield_type_matters { } {
388 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
389 # bitfields, but let's stick to the example code from the docs.
390 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
391 struct foo1 { char x; char :0; char y; };
392 struct foo2 { char x; int :0; char y; };
393 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
397 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
399 # This won't change for different subtargets so cache the result.
401 proc check_effective_target_tls {} {
405 if [info exists et_tls_saved] {
406 verbose "check_effective_target_tls: using cached result" 2
412 verbose "check_effective_target_tls: compiling testfile $src" 2
413 set f [open $src "w"]
414 # Compile a small test program.
415 puts $f "__thread int i;\n"
418 # Test for thread-local data supported by the platform.
419 set comp_output [${tool}_target_compile $src $asm assembly ""]
421 if { [string match "*not supported*" $comp_output] } {
427 if { [string match "*emutls*" $text]} {
433 remove-build-file $asm
435 verbose "check_effective_target_tls: returning $et_tls_saved" 2
439 # Return 1 if TLS executables can run correctly, 0 otherwise.
441 # This won't change for different subtargets so cache the result.
443 proc check_effective_target_tls_runtime {} {
444 global et_tls_runtime_saved
447 if [info exists et_tls_runtime_saved] {
448 verbose "check_effective_target_tls_runtime: using cached result" 2
450 set et_tls_runtime_saved 0
452 set src tls_runtime[pid].c
453 set exe tls_runtime[pid].x
454 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
455 set f [open $src "w"]
456 # Compile a small test program.
457 puts $f "__thread int thr = 0;\n"
458 puts $f "int main(void)\n {\n return thr;\n}"
462 [${tool}_target_compile $src $exe executable ""]
465 if [string match "" $comp_output] then {
466 # No error messages, everything is OK.
468 set result [remote_load target "./$exe" "" ""]
469 set status [lindex $result 0]
470 remote_file build delete $exe
472 verbose "check_effective_target_tls_runtime status is <$status>" 2
474 if { $status == "pass" } {
475 set et_tls_runtime_saved 1
478 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
482 return $et_tls_runtime_saved
485 # Return 1 if compilation with -fopenmp is error-free for trivial
488 proc check_effective_target_fopenmp {} {
489 return [check_no_compiler_messages fopenmp object {
494 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
495 # for trivial code, 0 otherwise.
497 proc check_effective_target_freorder {} {
498 return [check_no_compiler_messages freorder object {
500 } "-freorder-blocks-and-partition"]
503 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
504 # emitted, 0 otherwise. Whether a shared library can actually be built is
505 # out of scope for this test.
507 proc check_effective_target_fpic { } {
508 # Note that M68K has a multilib that supports -fpic but not
509 # -fPIC, so we need to check both. We test with a program that
510 # requires GOT references.
511 foreach arg {fpic fPIC} {
512 if [check_no_compiler_messages $arg object {
513 extern int foo (void); extern int bar;
514 int baz (void) { return foo () + bar; }
522 # Return true if the target supports -mpaired-single (as used on MIPS).
524 proc check_effective_target_mpaired_single { } {
525 return [check_no_compiler_messages mpaired_single object {
530 # Return 1 if the current multilib does not generate PIC by default.
532 proc check_effective_target_nonpic { } {
533 return [check_no_compiler_messages nonpic assembly {
540 # Return 1 if the target does not use a status wrapper.
542 proc check_effective_target_unwrapped { } {
543 if { [target_info needs_status_wrapper] != "" \
544 && [target_info needs_status_wrapper] != "0" } {
550 # Return true if iconv is supported on the target. In particular IBM1047.
552 proc check_iconv_available { test_what } {
560 verbose "check_iconv_available compiling testfile $src" 2
561 set f [open $src "w"]
562 # Compile a small test program.
563 puts $f "#include <iconv.h>\n"
564 puts $f "int main (void)\n {\n iconv_t cd; \n"
565 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
566 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
567 puts $f "return 0;\n}"
570 # If the tool configuration file has not set libiconv, try "-liconv"
571 if { ![info exists libiconv] } {
572 set libiconv "-liconv"
574 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
577 if [string match "" $lines] then {
578 # No error messages, everything is OK.
580 set result [${tool}_load "./$exe" "" ""]
581 set status [lindex $result 0]
582 remote_file build delete $exe
584 verbose "check_iconv_available status is <$status>" 2
586 if { $status == "pass" } then {
594 # Return true if named sections are supported on this target.
596 proc check_named_sections_available { } {
597 return [check_no_compiler_messages named_sections assembly {
598 int __attribute__ ((section("whatever"))) foo;
602 # Return 1 if the target supports Fortran real kinds larger than real(8),
605 # When the target name changes, replace the cached result.
607 proc check_effective_target_fortran_large_real { } {
608 global et_fortran_large_real_saved
609 global et_fortran_large_real_target_name
612 if { ![info exists et_fortran_large_real_target_name] } {
613 set et_fortran_large_real_target_name ""
616 # If the target has changed since we set the cached value, clear it.
617 set current_target [current_target_name]
618 if { $current_target != $et_fortran_large_real_target_name } {
619 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
620 set et_fortran_large_real_target_name $current_target
621 if [info exists et_fortran_large_real_saved] {
622 verbose "check_effective_target_fortran_large_real: removing cached result" 2
623 unset et_fortran_large_real_saved
627 if [info exists et_fortran_large_real_saved] {
628 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
630 set et_fortran_large_real_saved 0
632 # Set up, compile, and execute a test program using large real
633 # kinds. Include the current process ID in the file names to
634 # prevent conflicts with invocations for multiple testsuites.
635 set src real[pid].f90
638 set f [open $src "w"]
639 puts $f "integer,parameter :: k = &"
640 puts $f " selected_real_kind (precision (0.0_8) + 1)"
641 puts $f "real(kind=k) :: x"
642 puts $f "x = cos (x);"
646 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
647 set lines [${tool}_target_compile $src $exe executable ""]
650 if [string match "" $lines] then {
651 # No error message, compilation succeeded.
652 set et_fortran_large_real_saved 1
656 return $et_fortran_large_real_saved
659 # Return 1 if the target supports Fortran integer kinds larger than
660 # integer(8), 0 otherwise.
662 # When the target name changes, replace the cached result.
664 proc check_effective_target_fortran_large_int { } {
665 global et_fortran_large_int_saved
666 global et_fortran_large_int_target_name
669 if { ![info exists et_fortran_large_int_target_name] } {
670 set et_fortran_large_int_target_name ""
673 # If the target has changed since we set the cached value, clear it.
674 set current_target [current_target_name]
675 if { $current_target != $et_fortran_large_int_target_name } {
676 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
677 set et_fortran_large_int_target_name $current_target
678 if [info exists et_fortran_large_int_saved] {
679 verbose "check_effective_target_fortran_large_int: removing cached result" 2
680 unset et_fortran_large_int_saved
684 if [info exists et_fortran_large_int_saved] {
685 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
687 set et_fortran_large_int_saved 0
689 # Set up, compile, and execute a test program using large integer
690 # kinds. Include the current process ID in the file names to
691 # prevent conflicts with invocations for multiple testsuites.
695 set f [open $src "w"]
696 puts $f "integer,parameter :: k = &"
697 puts $f " selected_int_kind (range (0_8) + 1)"
698 puts $f "integer(kind=k) :: i"
702 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
703 set lines [${tool}_target_compile $src $exe executable ""]
706 if [string match "" $lines] then {
707 # No error message, compilation succeeded.
708 set et_fortran_large_int_saved 1
712 return $et_fortran_large_int_saved
715 # Return 1 if we can statically link libgfortran, 0 otherwise.
717 # When the target name changes, replace the cached result.
719 proc check_effective_target_static_libgfortran { } {
720 global et_static_libgfortran
721 global et_static_libgfortran_target_name
724 if { ![info exists et_static_libgfortran_target_name] } {
725 set et_static_libgfortran_target_name ""
728 # If the target has changed since we set the cached value, clear it.
729 set current_target [current_target_name]
730 if { $current_target != $et_static_libgfortran_target_name } {
731 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
732 set et_static_libgfortran_target_name $current_target
733 if [info exists et_static_libgfortran_saved] {
734 verbose "check_effective_target_static_libgfortran: removing cached result" 2
735 unset et_static_libgfortran_saved
739 if [info exists et_static_libgfortran_saved] {
740 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
742 set et_static_libgfortran_saved 0
744 # Set up, compile, and execute a test program using static linking.
745 # Include the current process ID in the file names to prevent
746 # conflicts with invocations for multiple testsuites.
747 set opts "additional_flags=-static"
748 set src static[pid].f
749 set exe static[pid].x
751 set f [open $src "w"]
752 puts $f " print *, 'test'"
756 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
757 set lines [${tool}_target_compile $src $exe executable "$opts"]
760 if [string match "" $lines] then {
761 # No error message, compilation succeeded.
762 set et_static_libgfortran_saved 1
766 return $et_static_libgfortran_saved
769 # Return 1 if the target supports executing AltiVec instructions, 0
770 # otherwise. Cache the result.
772 proc check_vmx_hw_available { } {
773 global vmx_hw_available_saved
776 if [info exists vmx_hw_available_saved] {
777 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
779 set vmx_hw_available_saved 0
781 # Some simulators are known to not support VMX instructions.
782 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
783 verbose "check_hw_available returning 0" 2
784 return $vmx_hw_available_saved
787 # Set up, compile, and execute a test program containing VMX
788 # instructions. Include the current process ID in the file
789 # names to prevent conflicts with invocations for multiple
794 set f [open $src "w"]
795 puts $f "int main() {"
796 puts $f "#ifdef __MACH__"
797 puts $f " asm volatile (\"vor v0,v0,v0\");"
799 puts $f " asm volatile (\"vor 0,0,0\");"
801 puts $f " return 0; }"
804 # Most targets don't require special flags for this test case, but
806 if [istarget *-*-darwin*] {
807 set opts "additional_flags=-maltivec"
812 verbose "check_vmx_hw_available compiling testfile $src" 2
813 set lines [${tool}_target_compile $src $exe executable "$opts"]
816 if [string match "" $lines] then {
817 # No error message, compilation succeeded.
818 set result [${tool}_load "./$exe" "" ""]
819 set status [lindex $result 0]
820 remote_file build delete $exe
821 verbose "check_vmx_hw_available testfile status is <$status>" 2
823 if { $status == "pass" } then {
824 set vmx_hw_available_saved 1
827 verbose "check_vmx_hw_availalble testfile compilation failed" 2
831 return $vmx_hw_available_saved
834 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
835 # complex float arguments. This affects gfortran tests that call cabsf
836 # in libm built by an earlier compiler. Return 1 if libm uses the same
837 # argument passing as the compiler under test, 0 otherwise.
839 # When the target name changes, replace the cached result.
841 proc check_effective_target_broken_cplxf_arg { } {
842 global et_broken_cplxf_arg_saved
843 global et_broken_cplxf_arg_target_name
846 # Skip the work for targets known not to be affected.
847 if { ![istarget powerpc64-*-linux*] } {
849 } elseif { [is-effective-target ilp32] } {
853 if { ![info exists et_broken_cplxf_arg_target_name] } {
854 set et_broken_cplxf_arg_target_name ""
857 # If the target has changed since we set the cached value, clear it.
858 set current_target [current_target_name]
859 if { $current_target != $et_broken_cplxf_arg_target_name } {
860 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
861 set et_broken_cplxf_arg_target_name $current_target
862 if [info exists et_broken_cplxf_arg_saved] {
863 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
864 unset et_broken_cplxf_arg_saved
868 if [info exists et_broken_cplxf_arg_saved] {
869 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
871 set et_broken_cplxf_arg_saved 0
872 # This is only known to affect one target.
873 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
874 set et_broken_cplxf_arg_saved 0
875 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
876 return $et_broken_cplxf_arg_saved
879 # Set up, compile, and execute a C test program that calls cabsf.
883 set f [open $src "w"]
884 puts $f "#include <complex.h>"
885 puts $f "extern void abort (void);"
886 puts $f "float fabsf (float);"
887 puts $f "float cabsf (_Complex float);"
888 puts $f "int main ()"
890 puts $f " _Complex float cf;"
892 puts $f " cf = 3 + 4.0fi;"
893 puts $f " f = cabsf (cf);"
894 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
899 set lines [${tool}_target_compile $src $exe executable "-lm"]
902 if [string match "" $lines] {
903 # No error message, compilation succeeded.
904 set result [${tool}_load "./$exe" "" ""]
905 set status [lindex $result 0]
906 remote_file build delete $exe
908 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
910 if { $status != "pass" } {
911 set et_broken_cplxf_arg_saved 1
914 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
917 return $et_broken_cplxf_arg_saved
920 proc check_alpha_max_hw_available { } {
921 global alpha_max_hw_available_saved
924 if [info exists alpha_max_hw_available_saved] {
925 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
927 set alpha_max_hw_available_saved 0
929 # Set up, compile, and execute a test program probing bit 8 of the
930 # architecture mask, which indicates presence of MAX instructions.
934 set f [open $src "w"]
935 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
938 verbose "check_alpha_max_hw_available compiling testfile $src" 2
939 set lines [${tool}_target_compile $src $exe executable ""]
942 if [string match "" $lines] then {
943 # No error message, compilation succeeded.
944 set result [${tool}_load "./$exe" "" ""]
945 set status [lindex $result 0]
946 remote_file build delete $exe
947 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
949 if { $status == "pass" } then {
950 set alpha_max_hw_available_saved 1
953 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
957 return $alpha_max_hw_available_saved
960 # Returns true iff the FUNCTION is available on the target system.
961 # (This is essentially a Tcl implementation of Autoconf's
964 proc check_function_available { function } {
965 set var "${function}_available_saved"
969 if {![info exists $var]} {
972 # Check to make sure.
973 set src "function[pid].c"
974 set exe "function[pid].exe"
976 set f [open $src "w"]
977 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
978 puts $f "char $function ();\n"
979 puts $f "int main () { $function (); }"
982 set lines [${tool}_target_compile $src $exe executable ""]
986 if {![string match "" $lines]} then {
988 verbose -log "$function is not available"
990 verbose -log "$function is available"
997 # Returns true iff "fork" is available on the target system.
999 proc check_fork_available {} {
1000 return [check_function_available "fork"]
1003 # Returns true iff "mkfifo" is available on the target system.
1005 proc check_mkfifo_available {} {
1006 if {[istarget *-*-cygwin*]} {
1007 # Cygwin has mkfifo, but support is incomplete.
1011 return [check_function_available "mkfifo"]
1014 # Returns true iff "__cxa_atexit" is used on the target system.
1016 proc check_cxa_atexit_available { } {
1017 global et_cxa_atexit
1018 global et_cxa_atexit_target_name
1021 if { ![info exists et_cxa_atexit_target_name] } {
1022 set et_cxa_atexit_target_name ""
1025 # If the target has changed since we set the cached value, clear it.
1026 set current_target [current_target_name]
1027 if { $current_target != $et_cxa_atexit_target_name } {
1028 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1029 set et_cxa_atexit_target_name $current_target
1030 if [info exists et_cxa_atexit] {
1031 verbose "check_cxa_atexit_available: removing cached result" 2
1036 if [info exists et_cxa_atexit] {
1037 verbose "check_cxa_atexit_available: using cached result" 2
1038 } elseif { [istarget "hppa*-*-hpux10*"] } {
1039 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1044 # Set up, compile, and execute a C++ test program that depends
1045 # on correct ordering of static object destructors. This is
1046 # indicative of the presence and use of __cxa_atexit.
1047 set src cxaatexit[pid].cc
1048 set exe cxaatexit[pid].x
1050 set f [open $src "w"]
1051 puts $f "#include <stdlib.h>"
1052 puts $f "static unsigned int count;"
1055 puts $f " X() { count = 1; }"
1058 puts $f " if (count != 3)"
1060 puts $f " count = 4;"
1065 puts $f " static X x;"
1069 puts $f " Y() { f(); count = 2; }"
1072 puts $f " if (count != 2)"
1074 puts $f " count = 3;"
1078 puts $f "int main()"
1079 puts $f "{ return 0; }"
1082 set lines [${tool}_target_compile $src $exe executable ""]
1085 if [string match "" $lines] {
1086 # No error message, compilation succeeded.
1087 set result [${tool}_load "./$exe" "" ""]
1088 set status [lindex $result 0]
1089 remote_file build delete $exe
1091 verbose "check_cxa_atexit_available: status is <$status>" 2
1093 if { $status == "pass" } {
1097 verbose "check_cxa_atexit_available: compilation failed" 2
1100 return $et_cxa_atexit
1104 # Return 1 if we're generating 32-bit code using default options, 0
1107 proc check_effective_target_ilp32 { } {
1108 return [check_no_compiler_messages ilp32 object {
1109 int dummy[sizeof (int) == 4
1110 && sizeof (void *) == 4
1111 && sizeof (long) == 4 ? 1 : -1];
1115 # Return 1 if we're generating 32-bit or larger integers using default
1116 # options, 0 otherwise.
1118 proc check_effective_target_int32plus { } {
1119 return [check_no_compiler_messages int32plus object {
1120 int dummy[sizeof (int) >= 4 ? 1 : -1];
1124 # Return 1 if we're generating 32-bit or larger pointers using default
1125 # options, 0 otherwise.
1127 proc check_effective_target_ptr32plus { } {
1128 return [check_no_compiler_messages ptr32plus object {
1129 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1133 # Return 1 if we support 32-bit or larger array and structure sizes
1134 # using default options, 0 otherwise.
1136 proc check_effective_target_size32plus { } {
1137 return [check_no_compiler_messages size32plus object {
1142 # Returns 1 if we're generating 16-bit or smaller integers with the
1143 # default options, 0 otherwise.
1145 proc check_effective_target_int16 { } {
1146 return [check_no_compiler_messages int16 object {
1147 int dummy[sizeof (int) < 4 ? 1 : -1];
1151 # Return 1 if we're generating 64-bit code using default options, 0
1154 proc check_effective_target_lp64 { } {
1155 return [check_no_compiler_messages lp64 object {
1156 int dummy[sizeof (int) == 4
1157 && sizeof (void *) == 8
1158 && sizeof (long) == 8 ? 1 : -1];
1162 # Return 1 if the target supports long double larger than double,
1165 proc check_effective_target_large_long_double { } {
1166 return [check_no_compiler_messages large_long_double object {
1167 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1172 # Return 1 if the target supports compiling decimal floating point,
1175 proc check_effective_target_dfp_nocache { } {
1176 verbose "check_effective_target_dfp_nocache: compiling source" 2
1177 set ret [string match "" [get_compiler_messages dfp 0 object {
1178 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1180 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1184 proc check_effective_target_dfprt_nocache { } {
1189 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1190 # Set up, compile, and execute a test program containing decimal
1192 set src dfprt[pid].c
1193 set exe dfprt[pid].x
1195 set f [open $src "w"]
1196 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1197 puts $f "int main () { z = x + y; return 0; }"
1200 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1201 set lines [${tool}_target_compile $src $exe executable ""]
1204 if [string match "" $lines] then {
1205 # No error message, compilation succeeded.
1206 set result [${tool}_load "./$exe" "" ""]
1207 set status [lindex $result 0]
1208 remote_file build delete $exe
1209 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1210 if { $status == "pass" } then {
1215 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1218 # Return 1 if the target supports compiling Decimal Floating Point,
1221 # This won't change for different subtargets so cache the result.
1223 proc check_effective_target_dfp { } {
1226 if [info exists et_dfp_saved] {
1227 verbose "check_effective_target_dfp: using cached result" 2
1229 set et_dfp_saved [check_effective_target_dfp_nocache]
1231 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1232 return $et_dfp_saved
1235 # Return 1 if the target supports linking and executing Decimal Floating
1236 # Point, # 0 otherwise.
1238 # This won't change for different subtargets so cache the result.
1240 proc check_effective_target_dfprt { } {
1241 global et_dfprt_saved
1244 if [info exists et_dfprt_saved] {
1245 verbose "check_effective_target_dfprt: using cached result" 2
1247 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1249 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1250 return $et_dfprt_saved
1253 # Return 1 if the target needs a command line argument to enable a SIMD
1256 proc check_effective_target_vect_cmdline_needed { } {
1257 global et_vect_cmdline_needed_saved
1258 global et_vect_cmdline_needed_target_name
1260 if { ![info exists et_vect_cmdline_needed_target_name] } {
1261 set et_vect_cmdline_needed_target_name ""
1264 # If the target has changed since we set the cached value, clear it.
1265 set current_target [current_target_name]
1266 if { $current_target != $et_vect_cmdline_needed_target_name } {
1267 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1268 set et_vect_cmdline_needed_target_name $current_target
1269 if { [info exists et_vect_cmdline_needed_saved] } {
1270 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1271 unset et_vect_cmdline_needed_saved
1275 if [info exists et_vect_cmdline_needed_saved] {
1276 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1278 set et_vect_cmdline_needed_saved 1
1279 if { [istarget ia64-*-*]
1280 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1281 && [check_effective_target_lp64])
1282 || ([istarget powerpc*-*-*]
1283 && ([check_effective_target_powerpc_spe]
1284 || [check_effective_target_powerpc_altivec]))} {
1285 set et_vect_cmdline_needed_saved 0
1289 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1290 return $et_vect_cmdline_needed_saved
1293 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1295 # This won't change for different subtargets so cache the result.
1297 proc check_effective_target_vect_int { } {
1298 global et_vect_int_saved
1300 if [info exists et_vect_int_saved] {
1301 verbose "check_effective_target_vect_int: using cached result" 2
1303 set et_vect_int_saved 0
1304 if { [istarget i?86-*-*]
1305 || [istarget powerpc*-*-*]
1306 || [istarget spu-*-*]
1307 || [istarget x86_64-*-*]
1308 || [istarget sparc*-*-*]
1309 || [istarget alpha*-*-*]
1310 || [istarget ia64-*-*] } {
1311 set et_vect_int_saved 1
1315 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1316 return $et_vect_int_saved
1319 # Return 1 is this is an arm target using 32-bit instructions
1320 proc check_effective_target_arm32 { } {
1321 global et_arm32_saved
1322 global et_arm32_target_name
1323 global compiler_flags
1325 if { ![info exists et_arm32_target_name] } {
1326 set et_arm32_target_name ""
1329 # If the target has changed since we set the cached value, clear it.
1330 set current_target [current_target_name]
1331 if { $current_target != $et_arm32_target_name } {
1332 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1333 set et_arm32_target_name $current_target
1334 if { [info exists et_arm32_saved] } {
1335 verbose "check_effective_target_arm32: removing cached result" 2
1336 unset et_arm32_saved
1340 if [info exists et_arm32_saved] {
1341 verbose "check-effective_target_arm32: using cached result" 2
1343 set et_arm32_saved 0
1344 if { [istarget arm-*-*]
1345 || [istarget strongarm*-*-*]
1346 || [istarget xscale-*-*] } {
1347 if ![string match "*-mthumb *" $compiler_flags] {
1348 set et_arm32_saved 1
1352 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1353 return $et_arm32_saved
1356 # Return 1 if this is an ARM target supporting -mfpu=vfp
1357 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1360 proc check_effective_target_arm_vfp_ok { } {
1361 if { [check_effective_target_arm32] } {
1362 return [check_no_compiler_messages arm_vfp_ok object {
1364 } "-mfpu=vfp -mfloat-abi=softfp"]
1370 # Return 1 if this is a PowerPC target with floating-point registers.
1372 proc check_effective_target_powerpc_fprs { } {
1373 if { [istarget powerpc*-*-*]
1374 || [istarget rs6000-*-*] } {
1375 return [check_no_compiler_messages powerpc_fprs object {
1387 # Return 1 if this is a PowerPC target supporting -maltivec.
1389 proc check_effective_target_powerpc_altivec_ok { } {
1390 if { [istarget powerpc*-*-*]
1391 || [istarget rs6000-*-*] } {
1392 # AltiVec is not supported on Aix.
1393 if { [istarget powerpc*-*-aix*] } {
1396 return [check_no_compiler_messages powerpc_altivec_ok object {
1404 # Return 1 if this is a PowerPC target with SPE enabled.
1406 proc check_effective_target_powerpc_spe { } {
1407 if { [istarget powerpc*-*-*] } {
1408 return [check_no_compiler_messages powerpc_spe object {
1420 # Return 1 if this is a PowerPC target with Altivec enabled.
1422 proc check_effective_target_powerpc_altivec { } {
1423 if { [istarget powerpc*-*-*] } {
1424 return [check_no_compiler_messages powerpc_altivec object {
1436 # Return 1 if the target supports hardware vector shift operation.
1438 proc check_effective_target_vect_shift { } {
1439 global et_vect_shift_saved
1441 if [info exists et_vect_shift_saved] {
1442 verbose "check_effective_target_vect_shift: using cached result" 2
1444 set et_vect_shift_saved 0
1445 if { [istarget powerpc*-*-*]
1446 || [istarget ia64-*-*]
1447 || [istarget i?86-*-*]
1448 || [istarget x86_64-*-*] } {
1449 set et_vect_shift_saved 1
1453 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1454 return $et_vect_shift_saved
1457 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1459 # This can change for different subtargets so do not cache the result.
1461 proc check_effective_target_vect_long { } {
1462 if { [istarget i?86-*-*]
1463 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1464 || [istarget x86_64-*-*]
1465 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1471 verbose "check_effective_target_vect_long: returning $answer" 2
1475 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1477 # This won't change for different subtargets so cache the result.
1479 proc check_effective_target_vect_float { } {
1480 global et_vect_float_saved
1482 if [info exists et_vect_float_saved] {
1483 verbose "check_effective_target_vect_float: using cached result" 2
1485 set et_vect_float_saved 0
1486 if { [istarget i?86-*-*]
1487 || [istarget powerpc*-*-*]
1488 || [istarget spu-*-*]
1489 || [istarget mipsisa64*-*-*]
1490 || [istarget x86_64-*-*]
1491 || [istarget ia64-*-*] } {
1492 set et_vect_float_saved 1
1496 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1497 return $et_vect_float_saved
1500 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1502 # This won't change for different subtargets so cache the result.
1504 proc check_effective_target_vect_double { } {
1505 global et_vect_double_saved
1507 if [info exists et_vect_double_saved] {
1508 verbose "check_effective_target_vect_double: using cached result" 2
1510 set et_vect_double_saved 0
1511 if { [istarget i?86-*-*]
1512 || [istarget x86_64-*-*]
1513 || [istarget spu-*-*] } {
1514 set et_vect_double_saved 1
1518 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1519 return $et_vect_double_saved
1522 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1524 # This won't change for different subtargets so cache the result.
1526 proc check_effective_target_vect_no_compare_double { } {
1527 global et_vect_no_compare_double_saved
1529 if [info exists et_vect_no_compare_double_saved] {
1530 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1532 set et_vect_no_compare_double_saved 0
1533 if { [istarget spu-*-*] } {
1534 set et_vect_no_compare_double_saved 1
1538 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1539 return $et_vect_no_compare_double_saved
1542 # Return 1 if the target plus current options does not support a vector
1543 # max instruction on "int", 0 otherwise.
1545 # This won't change for different subtargets so cache the result.
1547 proc check_effective_target_vect_no_int_max { } {
1548 global et_vect_no_int_max_saved
1550 if [info exists et_vect_no_int_max_saved] {
1551 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1553 set et_vect_no_int_max_saved 0
1554 if { [istarget sparc*-*-*]
1555 || [istarget spu-*-*]
1556 || [istarget alpha*-*-*] } {
1557 set et_vect_no_int_max_saved 1
1560 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1561 return $et_vect_no_int_max_saved
1564 # Return 1 if the target plus current options does not support a vector
1565 # add instruction on "int", 0 otherwise.
1567 # This won't change for different subtargets so cache the result.
1569 proc check_effective_target_vect_no_int_add { } {
1570 global et_vect_no_int_add_saved
1572 if [info exists et_vect_no_int_add_saved] {
1573 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1575 set et_vect_no_int_add_saved 0
1576 # Alpha only supports vector add on V8QI and V4HI.
1577 if { [istarget alpha*-*-*] } {
1578 set et_vect_no_int_add_saved 1
1581 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1582 return $et_vect_no_int_add_saved
1585 # Return 1 if the target plus current options does not support vector
1586 # bitwise instructions, 0 otherwise.
1588 # This won't change for different subtargets so cache the result.
1590 proc check_effective_target_vect_no_bitwise { } {
1591 global et_vect_no_bitwise_saved
1593 if [info exists et_vect_no_bitwise_saved] {
1594 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1596 set et_vect_no_bitwise_saved 0
1598 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1599 return $et_vect_no_bitwise_saved
1602 # Return 1 if the target plus current options supports a vector
1603 # widening summation of *short* args into *int* result, 0 otherwise.
1604 # A target can also support this widening summation if it can support
1605 # promotion (unpacking) from shorts to ints.
1607 # This won't change for different subtargets so cache the result.
1609 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1610 global et_vect_widen_sum_hi_to_si
1612 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1613 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1615 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1616 if { [istarget powerpc*-*-*] } {
1617 set et_vect_widen_sum_hi_to_si_saved 1
1620 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1621 return $et_vect_widen_sum_hi_to_si_saved
1624 # Return 1 if the target plus current options supports a vector
1625 # widening summation of *char* args into *short* result, 0 otherwise.
1626 # A target can also support this widening summation if it can support
1627 # promotion (unpacking) from chars to shorts.
1629 # This won't change for different subtargets so cache the result.
1631 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1632 global et_vect_widen_sum_qi_to_hi
1634 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1635 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1637 set et_vect_widen_sum_qi_to_hi_saved 0
1638 if { [check_effective_target_vect_unpack] } {
1639 set et_vect_widen_sum_qi_to_hi_saved 1
1642 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1643 return $et_vect_widen_sum_qi_to_hi_saved
1646 # Return 1 if the target plus current options supports a vector
1647 # widening summation of *char* args into *int* result, 0 otherwise.
1649 # This won't change for different subtargets so cache the result.
1651 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1652 global et_vect_widen_sum_qi_to_si
1654 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1655 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1657 set et_vect_widen_sum_qi_to_si_saved 0
1658 if { [istarget powerpc*-*-*] } {
1659 set et_vect_widen_sum_qi_to_si_saved 1
1662 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1663 return $et_vect_widen_sum_qi_to_si_saved
1666 # Return 1 if the target plus current options supports a vector
1667 # widening multiplication of *char* args into *short* result, 0 otherwise.
1668 # A target can also support this widening multplication if it can support
1669 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1670 # multiplication of shorts).
1672 # This won't change for different subtargets so cache the result.
1675 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1676 global et_vect_widen_mult_qi_to_hi
1678 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1679 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1681 if { [check_effective_target_vect_unpack]
1682 && [check_effective_target_vect_short_mult] } {
1683 set et_vect_widen_mult_qi_to_hi_saved 1
1685 set et_vect_widen_mult_qi_to_hi_saved 0
1687 if { [istarget powerpc*-*-*] } {
1688 set et_vect_widen_mult_qi_to_hi_saved 1
1691 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1692 return $et_vect_widen_mult_qi_to_hi_saved
1695 # Return 1 if the target plus current options supports a vector
1696 # widening multiplication of *short* args into *int* result, 0 otherwise.
1697 # A target can also support this widening multplication if it can support
1698 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1699 # multiplication of ints).
1701 # This won't change for different subtargets so cache the result.
1704 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1705 global et_vect_widen_mult_hi_to_si
1707 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1708 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1710 if { [check_effective_target_vect_unpack]
1711 && [check_effective_target_vect_int_mult] } {
1712 set et_vect_widen_mult_hi_to_si_saved 1
1714 set et_vect_widen_mult_hi_to_si_saved 0
1716 if { [istarget powerpc*-*-*]
1717 || [istarget spu-*-*]
1718 || [istarget i?86-*-*]
1719 || [istarget x86_64-*-*] } {
1720 set et_vect_widen_mult_hi_to_si_saved 1
1723 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1724 return $et_vect_widen_mult_hi_to_si_saved
1727 # Return 1 if the target plus current options supports a vector
1728 # dot-product of signed chars, 0 otherwise.
1730 # This won't change for different subtargets so cache the result.
1732 proc check_effective_target_vect_sdot_qi { } {
1733 global et_vect_sdot_qi
1735 if [info exists et_vect_sdot_qi_saved] {
1736 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1738 set et_vect_sdot_qi_saved 0
1740 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1741 return $et_vect_sdot_qi_saved
1744 # Return 1 if the target plus current options supports a vector
1745 # dot-product of unsigned chars, 0 otherwise.
1747 # This won't change for different subtargets so cache the result.
1749 proc check_effective_target_vect_udot_qi { } {
1750 global et_vect_udot_qi
1752 if [info exists et_vect_udot_qi_saved] {
1753 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1755 set et_vect_udot_qi_saved 0
1756 if { [istarget powerpc*-*-*] } {
1757 set et_vect_udot_qi_saved 1
1760 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1761 return $et_vect_udot_qi_saved
1764 # Return 1 if the target plus current options supports a vector
1765 # dot-product of signed shorts, 0 otherwise.
1767 # This won't change for different subtargets so cache the result.
1769 proc check_effective_target_vect_sdot_hi { } {
1770 global et_vect_sdot_hi
1772 if [info exists et_vect_sdot_hi_saved] {
1773 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1775 set et_vect_sdot_hi_saved 0
1776 if { [istarget powerpc*-*-*]
1777 || [istarget i?86-*-*]
1778 || [istarget x86_64-*-*] } {
1779 set et_vect_sdot_hi_saved 1
1782 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1783 return $et_vect_sdot_hi_saved
1786 # Return 1 if the target plus current options supports a vector
1787 # dot-product of unsigned shorts, 0 otherwise.
1789 # This won't change for different subtargets so cache the result.
1791 proc check_effective_target_vect_udot_hi { } {
1792 global et_vect_udot_hi
1794 if [info exists et_vect_udot_hi_saved] {
1795 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1797 set et_vect_udot_hi_saved 0
1798 if { [istarget powerpc*-*-*] } {
1799 set et_vect_udot_hi_saved 1
1802 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1803 return $et_vect_udot_hi_saved
1807 # Return 1 if the target plus current options supports a vector
1808 # demotion (packing) of shorts (to chars) and ints (to shorts)
1809 # using modulo arithmetic, 0 otherwise.
1811 # This won't change for different subtargets so cache the result.
1813 proc check_effective_target_vect_pack_mod { } {
1814 global et_vect_pack_mod
1816 if [info exists et_vect_pack_mod_saved] {
1817 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1819 set et_vect_pack_mod_saved 0
1820 if { [istarget powerpc*-*-*]
1821 || [istarget i?86-*-*]
1822 || [istarget x86_64-*-*] } {
1823 set et_vect_pack_mod_saved 1
1826 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1827 return $et_vect_pack_mod_saved
1830 # Return 1 if the target plus current options supports a vector
1831 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1833 # This won't change for different subtargets so cache the result.
1835 proc check_effective_target_vect_unpack { } {
1836 global et_vect_unpack
1838 if [info exists et_vect_unpack_saved] {
1839 verbose "check_effective_target_vect_unpack: using cached result" 2
1841 set et_vect_unpack_saved 0
1842 if { [istarget powerpc*-*-*]
1843 || [istarget i?86-*-*]
1844 || [istarget x86_64-*-*] } {
1845 set et_vect_unpack_saved 1
1848 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1849 return $et_vect_unpack_saved
1852 # Return 1 if the target plus current options does not support a vector
1853 # alignment mechanism, 0 otherwise.
1855 # This won't change for different subtargets so cache the result.
1857 proc check_effective_target_vect_no_align { } {
1858 global et_vect_no_align_saved
1860 if [info exists et_vect_no_align_saved] {
1861 verbose "check_effective_target_vect_no_align: using cached result" 2
1863 set et_vect_no_align_saved 0
1864 if { [istarget mipsisa64*-*-*]
1865 || [istarget sparc*-*-*]
1866 || [istarget ia64-*-*] } {
1867 set et_vect_no_align_saved 1
1870 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1871 return $et_vect_no_align_saved
1874 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1876 proc check_effective_target_vect_condition { } {
1877 global et_vect_cond_saved
1879 if [info exists et_vect_cond_saved] {
1880 verbose "check_effective_target_vect_cond: using cached result" 2
1882 set et_vect_cond_saved 0
1883 if { [istarget powerpc*-*-*]
1884 || [istarget ia64-*-*]
1885 || [istarget i?86-*-*]
1886 || [istarget x86_64-*-*] } {
1887 set et_vect_cond_saved 1
1891 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1892 return $et_vect_cond_saved
1895 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1897 proc check_effective_target_vect_char_mult { } {
1898 global et_vect_char_mult_saved
1900 if [info exists et_vect_char_mult_saved] {
1901 verbose "check_effective_target_vect_char_mult: using cached result" 2
1903 set et_vect_char_mult_saved 0
1904 if { [istarget ia64-*-*]
1905 || [istarget i?86-*-*]
1906 || [istarget x86_64-*-*] } {
1907 set et_vect_char_mult_saved 1
1911 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1912 return $et_vect_char_mult_saved
1915 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1917 proc check_effective_target_vect_short_mult { } {
1918 global et_vect_short_mult_saved
1920 if [info exists et_vect_short_mult_saved] {
1921 verbose "check_effective_target_vect_short_mult: using cached result" 2
1923 set et_vect_short_mult_saved 0
1924 if { [istarget ia64-*-*]
1925 || [istarget i?86-*-*]
1926 || [istarget x86_64-*-*] } {
1927 set et_vect_short_mult_saved 1
1931 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1932 return $et_vect_short_mult_saved
1935 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1937 proc check_effective_target_vect_int_mult { } {
1938 global et_vect_int_mult_saved
1940 if [info exists et_vect_int_mult_saved] {
1941 verbose "check_effective_target_vect_int_mult: using cached result" 2
1943 set et_vect_int_mult_saved 0
1944 if { [istarget powerpc*-*-*]
1945 || [istarget i?86-*-*]
1946 || [istarget x86_64-*-*] } {
1947 set et_vect_int_mult_saved 1
1951 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1952 return $et_vect_int_mult_saved
1955 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1957 proc check_effective_target_vect_extract_even_odd { } {
1958 global et_vect_extract_even_odd_saved
1960 if [info exists et_vect_extract_even_odd_saved] {
1961 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1963 set et_vect_extract_even_odd_saved 0
1964 if { [istarget powerpc*-*-*] } {
1965 set et_vect_extract_even_odd_saved 1
1969 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1970 return $et_vect_extract_even_odd_saved
1973 # Return 1 if the target supports vector interleaving, 0 otherwise.
1975 proc check_effective_target_vect_interleave { } {
1976 global et_vect_interleave_saved
1978 if [info exists et_vect_interleave_saved] {
1979 verbose "check_effective_target_vect_interleave: using cached result" 2
1981 set et_vect_interleave_saved 0
1982 if { [istarget powerpc*-*-*]
1983 || [istarget i?86-*-*]
1984 || [istarget x86_64-*-*] } {
1985 set et_vect_interleave_saved 1
1989 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1990 return $et_vect_interleave_saved
1993 # Return 1 if the target supports section-anchors
1995 proc check_effective_target_section_anchors { } {
1996 global et_section_anchors_saved
1998 if [info exists et_section_anchors_saved] {
1999 verbose "check_effective_target_section_anchors: using cached result" 2
2001 set et_section_anchors_saved 0
2002 if { [istarget powerpc*-*-*] } {
2003 set et_section_anchors_saved 1
2007 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2008 return $et_section_anchors_saved
2011 # Return 1 if the target supports atomic operations on "int" and "long".
2013 proc check_effective_target_sync_int_long { } {
2014 global et_sync_int_long_saved
2016 if [info exists et_sync_int_long_saved] {
2017 verbose "check_effective_target_sync_int_long: using cached result" 2
2019 set et_sync_int_long_saved 0
2020 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2021 # load-reserved/store-conditional instructions.
2022 if { [istarget ia64-*-*]
2023 || [istarget i?86-*-*]
2024 || [istarget x86_64-*-*]
2025 || [istarget alpha*-*-*]
2026 || [istarget s390*-*-*]
2027 || [istarget powerpc*-*-*]
2028 || [istarget sparc64-*-*]
2029 || [istarget sparcv9-*-*] } {
2030 set et_sync_int_long_saved 1
2034 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2035 return $et_sync_int_long_saved
2038 # Return 1 if the target supports atomic operations on "char" and "short".
2040 proc check_effective_target_sync_char_short { } {
2041 global et_sync_char_short_saved
2043 if [info exists et_sync_char_short_saved] {
2044 verbose "check_effective_target_sync_char_short: using cached result" 2
2046 set et_sync_char_short_saved 0
2047 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2048 # load-reserved/store-conditional instructions.
2049 if { [istarget ia64-*-*]
2050 || [istarget i?86-*-*]
2051 || [istarget x86_64-*-*]
2052 || [istarget alpha*-*-*]
2053 || [istarget s390*-*-*]
2054 || [istarget powerpc*-*-*]
2055 || [istarget sparc64-*-*]
2056 || [istarget sparcv9-*-*] } {
2057 set et_sync_char_short_saved 1
2061 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2062 return $et_sync_char_short_saved
2065 # Return 1 if the target uses a ColdFire FPU.
2067 proc check_effective_target_coldfire_fpu { } {
2068 return [check_no_compiler_messages coldfire_fpu assembly {
2075 # Return true if this is a uClibc target.
2077 proc check_effective_target_uclibc {} {
2078 return [check_no_compiler_messages uclibc object {
2079 #include <features.h>
2080 #if !defined (__UCLIBC__)
2086 # Return true if this is a uclibc target and if the uclibc feature
2087 # described by __$feature__ is not present.
2089 proc check_missing_uclibc_feature {feature} {
2090 return [check_no_compiler_messages $feature object "
2091 #include <features.h>
2092 #if !defined (__UCLIBC) || defined (__${feature}__)
2098 # Return true if this is a Newlib target.
2100 proc check_effective_target_newlib {} {
2101 return [check_no_compiler_messages newlib object {
2107 # (a) an error of a few ULP is expected in string to floating-point
2108 # conversion functions; and
2109 # (b) overflow is not always detected correctly by those functions.
2111 proc check_effective_target_lax_strtofp {} {
2112 # By default, assume that all uClibc targets suffer from this.
2113 return [check_effective_target_uclibc]
2116 # Return 1 if this is a target for which wcsftime is a dummy
2117 # function that always returns 0.
2119 proc check_effective_target_dummy_wcsftime {} {
2120 # By default, assume that all uClibc targets suffer from this.
2121 return [check_effective_target_uclibc]
2124 # Return 1 if constructors with initialization priority arguments are
2125 # supposed on this target.
2127 proc check_effective_target_init_priority {} {
2128 return [check_no_compiler_messages init_priority assembly "
2129 void f() __attribute__((constructor (1000)));
2134 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2135 # This can be used with any check_* proc that takes no argument and
2136 # returns only 1 or 0. It could be used with check_* procs that take
2137 # arguments with keywords that pass particular arguments.
2139 proc is-effective-target { arg } {
2141 if { [info procs check_effective_target_${arg}] != [list] } {
2142 set selected [check_effective_target_${arg}]
2145 "vmx_hw" { set selected [check_vmx_hw_available] }
2146 "named_sections" { set selected [check_named_sections_available] }
2147 "gc_sections" { set selected [check_gc_sections_available] }
2148 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2149 default { error "unknown effective target keyword `$arg'" }
2152 verbose "is-effective-target: $arg $selected" 2
2156 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2158 proc is-effective-target-keyword { arg } {
2159 if { [info procs check_effective_target_${arg}] != [list] } {
2162 # These have different names for their check_* procs.
2164 "vmx_hw" { return 1 }
2165 "named_sections" { return 1 }
2166 "gc_sections" { return 1 }
2167 "cxa_atexit" { return 1 }
2168 default { return 0 }
2173 # Return 1 if target default to short enums
2175 proc check_effective_target_short_enums { } {
2176 return [check_no_compiler_messages short_enums assembly {
2178 int s[sizeof (enum foo) == 1 ? 1 : -1];
2182 # Return 1 if target supports merging string constants at link time.
2184 proc check_effective_target_string_merging { } {
2185 return [check_no_messages_and_pattern string_merging \
2186 "rodata\\.str" assembly {
2187 const char *var = "String";
2191 # Return 1 if target has the basic signed and unsigned types in
2192 # <stdint.h>, 0 otherwise.
2194 proc check_effective_target_stdint_types { } {
2195 return [check_no_compiler_messages stdint_types assembly {
2197 int8_t a; int16_t b; int32_t c; int64_t d;
2198 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2202 # Return 1 if programs are intended to be run on a simulator
2203 # (i.e. slowly) rather than hardware (i.e. fast).
2205 proc check_effective_target_simulator { } {
2207 # All "src/sim" simulators set this one.
2208 if [board_info target exists is_simulator] {
2209 return [board_info target is_simulator]
2212 # The "sid" simulators don't set that one, but at least they set
2214 if [board_info target exists slow_simulator] {
2215 return [board_info target slow_simulator]
2221 # Return 1 if the target is a VxWorks RTP.
2223 proc check_effective_target_vxworks_kernel { } {
2224 return [check_no_compiler_messages vxworks_kernel assembly {
2225 #if !defined __vxworks || defined __RTP__
2231 # Return 1 if the target is expected to provide wide character support.
2233 proc check_effective_target_wchar { } {
2234 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2237 return [check_no_compiler_messages wchar assembly {