1 # Copyright (C) 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # This file defines procs for determining features supported by the target.
22 # Try to compile some code and return the messages printed by the compiler.
24 # BASENAME is a basename to use for temporary files.
25 # TYPE is the type of compilation to perform (see target_compile).
26 # CONTENTS gives the contents of the input file.
27 # The rest is optional:
28 # OPTIONS: additional compiler options to use.
29 proc get_compiler_messages {basename type contents args} {
32 if { [llength $args] > 0 } {
33 set options "additional_flags=[lindex $args 0]"
38 set src ${basename}[pid].c
40 assembly { set output ${basename}[pid].s }
41 object { set output ${basename}[pid].o }
46 set lines [${tool}_target_compile $src $output $type "$options"]
48 remote_file build delete $output
53 proc current_target_name { } {
55 if [info exists target_info(target,name)] {
56 set answer $target_info(target,name)
63 ###############################
64 # proc check_weak_available { }
65 ###############################
67 # weak symbols are only supported in some configs/object formats
68 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
70 proc check_weak_available { } {
74 # All mips targets should support it
76 if { [ string first "mips" $target_cpu ] >= 0 } {
80 # All solaris2 targets should support it
82 if { [regexp ".*-solaris2.*" $target_triplet] } {
86 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
88 if { [regexp "alpha.*osf.*" $target_triplet] } {
92 # Windows targets Cygwin and MingW32 support it
94 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
98 # HP-UX 10.X doesn't support it
100 if { [regexp "hppa.*hpux10" $target_triplet] } {
104 # ELF and ECOFF support it. a.out does with gas/gld but may also with
105 # other linkers, so we should try it
107 set objformat [gcc_target_object_format]
115 unknown { return -1 }
120 ###############################
121 # proc check_visibility_available { what_kind }
122 ###############################
124 # The visibility attribute is only support in some object formats
125 # This proc returns 1 if it is supported, 0 if not.
126 # The argument is the kind of visibility, default/protected/hidden/internal.
128 proc check_visibility_available { what_kind } {
129 global visibility_available_saved
131 global target_triplet
133 # On NetWare, support makes no sense.
134 if { [string match "*-*-netware*" $target_triplet] } {
138 if [string match "" $what_kind] { set what_kind "hidden" }
140 if { [info exists visibility_available_saved] } {
141 verbose "Saved result is <$visibility_available_saved>" 1
142 if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
144 } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
149 set lines [get_compiler_messages visibility object "
150 void f() __attribute__((visibility(\"$what_kind\")));
153 if [string match "" $lines] then {
155 lappend visibility_available_saved $what_kind
158 lappend visibility_available_saved "!$what_kind"
163 ###############################
164 # proc check_alias_available { }
165 ###############################
167 # Determine if the target toolchain supports the alias attribute.
169 # Returns 2 if the target supports aliases. Returns 1 if the target
170 # only supports weak aliased. Returns 0 if the target does not
171 # support aliases at all. Returns -1 if support for aliases could not
174 proc check_alias_available { } {
175 global alias_available_saved
178 if [info exists alias_available_saved] {
179 verbose "check_alias_available returning saved $alias_available_saved" 2
183 verbose "check_alias_available compiling testfile $src" 2
184 set f [open $src "w"]
185 # Compile a small test program. The definition of "g" is
186 # necessary to keep the Solaris assembler from complaining
188 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
189 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
191 set lines [${tool}_target_compile $src $obj object ""]
193 remote_file build delete $obj
195 if [string match "" $lines] then {
196 # No error messages, everything is OK.
197 set alias_available_saved 2
199 if [regexp "alias definitions not supported" $lines] {
200 verbose "check_alias_available target does not support aliases" 2
202 set objformat [gcc_target_object_format]
204 if { $objformat == "elf" } {
205 verbose "check_alias_available but target uses ELF format, so it ought to" 2
206 set alias_available_saved -1
208 set alias_available_saved 0
211 if [regexp "only weak aliases are supported" $lines] {
212 verbose "check_alias_available target supports only weak aliases" 2
213 set alias_available_saved 1
215 set alias_available_saved -1
220 verbose "check_alias_available returning $alias_available_saved" 2
223 return $alias_available_saved
226 # Returns true if --gc-sections is supported on the target.
228 proc check_gc_sections_available { } {
229 global gc_sections_available_saved
232 if {![info exists gc_sections_available_saved]} {
233 # Some targets don't support gc-sections despite whatever's
234 # advertised by ld's options.
235 if { [istarget alpha*-*-*]
236 || [istarget ia64-*-*] } {
237 set gc_sections_available_saved 0
241 # Check if the ld used by gcc supports --gc-sections.
242 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
243 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
244 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
245 set ld_output [remote_exec host "$gcc_ld" "--help"]
246 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
247 set gc_sections_available_saved 1
249 set gc_sections_available_saved 0
252 return $gc_sections_available_saved
255 # Return true if profiling is supported on the target.
257 proc check_profiling_available { test_what } {
258 global profiling_available_saved
260 verbose "Profiling argument is <$test_what>" 1
262 # These conditions depend on the argument so examine them before
263 # looking at the cache variable.
265 # Support for -p on solaris2 relies on mcrt1.o which comes with the
266 # vendor compiler. We cannot reliably predict the directory where the
267 # vendor compiler (and thus mcrt1.o) is installed so we can't
268 # necessarily find mcrt1.o even if we have it.
269 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
273 # Support for -p on irix relies on libprof1.a which doesn't appear to
274 # exist on any irix6 system currently posting testsuite results.
275 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
276 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
277 if { [istarget mips*-*-irix*]
278 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
282 # Now examine the cache variable.
283 if {![info exists profiling_available_saved]} {
284 # Some targets don't have any implementation of __bb_init_func or are
285 # missing other needed machinery.
286 if { [istarget mmix-*-*]
287 || [istarget arm*-*-eabi*]
288 || [istarget arm*-*-elf]
289 || [istarget arm*-*-symbianelf*]
290 || [istarget powerpc-*-eabi*]
291 || [istarget strongarm*-*-elf]
292 || [istarget xscale*-*-elf]
293 || [istarget cris-*-*]
294 || [istarget h8300-*-*]
295 || [istarget mips*-*-elf]
296 || [istarget xtensa-*-elf]
297 || [istarget *-*-windiss] } {
298 set profiling_available_saved 0
300 set profiling_available_saved 1
304 return $profiling_available_saved
307 # Return 1 if target has packed layout of structure members by
308 # default, 0 otherwise. Note that this is slightly different than
309 # whether the target has "natural alignment": both attributes may be
312 proc check_effective_target_default_packed { } {
313 global et_default_packed_saved
314 global et_default_packed_target_name
316 if { ![info exists et_default_packed_target_name] } {
317 set et_default_packed_target_name ""
320 # If the target has changed since we set the cached value, clear it.
321 set current_target [current_target_name]
322 if { $current_target != $et_default_packed_target_name } {
323 verbose "check_effective_target_default_packed: `$et_default_packed_target_name'" 2
324 set et_default_packed_target_name $current_target
325 if [info exists et_default_packed_saved] {
326 verbose "check_effective_target_default_packed: removing cached result" 2
327 unset et_default_packed_saved
331 if [info exists et_default_packed_saved] {
332 verbose "check_effective_target_default_packed: using cached result" 2
334 verbose "check_effective_target_default_packed: compiling source" 2
336 set et_default_packed_saved \
337 [string match "" [get_compiler_messages default_packed assembly {
338 struct x { char a; long b; } c;
339 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
343 verbose "check_effective_target_default_packed: returning $et_default_packed_saved" 2
344 return $et_default_packed_saved
347 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
348 # documentation, where the test also comes from.
350 proc check_effective_target_pcc_bitfield_type_matters { } {
351 global et_pcc_bitfield_type_matters_saved
352 global et_pcc_bitfield_type_matters_target_name
354 if { ![info exists et_pcc_bitfield_type_matters_target_name] } {
355 set et_pcc_bitfield_type_matters_target_name ""
358 # If the target has changed since we set the cached value, clear it.
359 set current_target [current_target_name]
360 if { $current_target != $et_pcc_bitfield_type_matters_target_name } {
361 verbose "check_effective_target_pcc_bitfield_type_matters: `$et_pcc_bitfield_type_matters_target_name'" 2
362 set et_pcc_bitfield_type_matters_target_name $current_target
363 if [info exists et_pcc_bitfield_type_matters_saved] {
364 verbose "check_effective_target_pcc_bitfield_type_matters: removing cached result" 2
365 unset et_pcc_bitfield_type_matters_saved
369 if [info exists et_pcc_bitfield_type_matters_saved] {
370 verbose "check_effective_target_pcc_bitfield_type_matters: using cached result" 2
372 verbose "check_effective_target_pcc_bitfield_type_matters: compiling source" 2
374 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
375 # bitfields, but let's stick to the example code from the docs.
376 set et_pcc_bitfield_type_matters_saved \
377 [string match "" [get_compiler_messages pcc_bitfield_type_matters assembly {
378 struct foo1 { char x; char :0; char y; };
379 struct foo2 { char x; int :0; char y; };
380 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
383 verbose "check_effective_target_pcc_bitfield_type_matters: returning $et_pcc_bitfield_type_matters_saved" 2
384 return $et_pcc_bitfield_type_matters_saved
387 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
388 # emitted, 0 otherwise. Whether a shared library can actually be built is
389 # out of scope for this test.
391 # When the target name changes, replace the cached result.
393 proc check_effective_target_fpic { } {
395 global et_fpic_target_name
397 if { ![info exists et_fpic_target_name] } {
398 set et_fpic_target_name ""
401 # If the target has changed since we set the cached value, clear it.
402 set current_target [current_target_name]
403 if { $current_target != $et_fpic_target_name } {
404 verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
405 set et_fpic_target_name $current_target
406 if [info exists et_fpic_saved] {
407 verbose "check_effective_target_fpic: removing cached result" 2
412 if [info exists et_fpic_saved] {
413 verbose "check_effective_target_fpic: using cached result" 2
415 verbose "check_effective_target_fpic: compiling source" 2
417 # Note that M68K has a multilib that supports -fpic but not
418 # -fPIC, so we need to check both. We test with a program that
419 # requires GOT references.
420 set et_fpic_saved [string match "" [get_compiler_messages fpic object {
421 extern int foo (void); extern int bar;
422 int baz (void) { return foo () + bar; }
425 if { $et_fpic_saved != 0 } {
426 set et_fpic_saved [string match "" [get_compiler_messages fpic object {
427 extern int foo (void); extern int bar;
428 int baz (void) { return foo () + bar; }
432 verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
433 return $et_fpic_saved
436 # Return true if iconv is supported on the target. In particular IBM1047.
438 proc check_iconv_available { test_what } {
446 verbose "check_iconv_available compiling testfile $src" 2
447 set f [open $src "w"]
448 # Compile a small test program.
449 puts $f "#include <iconv.h>\n"
450 puts $f "int main (void)\n {\n iconv_t cd; \n"
451 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
452 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
453 puts $f "return 0;\n}"
456 # If the tool configuration file has not set libiconv, try "-liconv"
457 if { ![info exists libiconv] } {
458 set libiconv "-liconv"
460 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
463 if [string match "" $lines] then {
464 # No error messages, everything is OK.
466 set result [${tool}_load "./$exe" "" ""]
467 set status [lindex $result 0]
468 remote_file build delete $exe
470 verbose "check_iconv_available status is <$status>" 2
472 if { $status == "pass" } then {
480 # Return true if named sections are supported on this target.
481 # This proc does not cache results, because the answer may vary
482 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
484 proc check_named_sections_available { } {
485 verbose "check_named_sections_available: compiling source" 2
486 set answer [string match "" [get_compiler_messages named object {
487 int __attribute__ ((section("whatever"))) foo;
489 verbose "check_named_sections_available: returning $answer" 2
493 # Return 1 if the target supports Fortran real kinds larger than real(8),
496 # When the target name changes, replace the cached result.
498 proc check_effective_target_fortran_large_real { } {
499 global et_fortran_large_real_saved
500 global et_fortran_large_real_target_name
503 if { ![info exists et_fortran_large_real_target_name] } {
504 set et_fortran_large_real_target_name ""
507 # If the target has changed since we set the cached value, clear it.
508 set current_target [current_target_name]
509 if { $current_target != $et_fortran_large_real_target_name } {
510 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
511 set et_fortran_large_real_target_name $current_target
512 if [info exists et_fortran_large_real_saved] {
513 verbose "check_effective_target_fortran_large_real: removing cached result" 2
514 unset et_fortran_large_real_saved
518 if [info exists et_fortran_large_real_saved] {
519 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
521 set et_fortran_large_real_saved 0
523 # Set up, compile, and execute a test program using large real
524 # kinds. Include the current process ID in the file names to
525 # prevent conflicts with invocations for multiple testsuites.
526 set src real[pid].f90
529 set f [open $src "w"]
530 puts $f "integer,parameter :: k = &"
531 puts $f " selected_real_kind (precision (0.0_8) + 1)"
532 puts $f "real(kind=k) :: x"
536 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
537 set lines [${tool}_target_compile $src $exe executable ""]
540 if [string match "" $lines] then {
541 # No error message, compilation succeeded.
542 set et_fortran_large_real_saved 1
546 return $et_fortran_large_real_saved
549 # Return 1 if the target supports Fortran integer kinds larger than
550 # integer(8), 0 otherwise.
552 # When the target name changes, replace the cached result.
554 proc check_effective_target_fortran_large_int { } {
555 global et_fortran_large_int_saved
556 global et_fortran_large_int_target_name
559 if { ![info exists et_fortran_large_int_target_name] } {
560 set et_fortran_large_int_target_name ""
563 # If the target has changed since we set the cached value, clear it.
564 set current_target [current_target_name]
565 if { $current_target != $et_fortran_large_int_target_name } {
566 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
567 set et_fortran_large_int_target_name $current_target
568 if [info exists et_fortran_large_int_saved] {
569 verbose "check_effective_target_fortran_large_int: removing cached result" 2
570 unset et_fortran_large_int_saved
574 if [info exists et_fortran_large_int_saved] {
575 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
577 set et_fortran_large_int_saved 0
579 # Set up, compile, and execute a test program using large integer
580 # kinds. Include the current process ID in the file names to
581 # prevent conflicts with invocations for multiple testsuites.
585 set f [open $src "w"]
586 puts $f "integer,parameter :: k = &"
587 puts $f " selected_int_kind (range (0_8) + 1)"
588 puts $f "integer(kind=k) :: i"
592 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
593 set lines [${tool}_target_compile $src $exe executable ""]
596 if [string match "" $lines] then {
597 # No error message, compilation succeeded.
598 set et_fortran_large_int_saved 1
602 return $et_fortran_large_int_saved
605 # Return 1 if we can statically link libgfortran, 0 otherwise.
607 # When the target name changes, replace the cached result.
609 proc check_effective_target_static_libgfortran { } {
610 global et_static_libgfortran
611 global et_static_libgfortran_target_name
614 if { ![info exists et_static_libgfortran_target_name] } {
615 set et_static_libgfortran_target_name ""
618 # If the target has changed since we set the cached value, clear it.
619 set current_target [current_target_name]
620 if { $current_target != $et_static_libgfortran_target_name } {
621 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
622 set et_static_libgfortran_target_name $current_target
623 if [info exists et_static_libgfortran_saved] {
624 verbose "check_effective_target_static_libgfortran: removing cached result" 2
625 unset et_static_libgfortran_saved
629 if [info exists et_static_libgfortran_saved] {
630 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
632 set et_static_libgfortran_saved 0
634 # Set up, compile, and execute a test program using static linking.
635 # Include the current process ID in the file names to prevent
636 # conflicts with invocations for multiple testsuites.
637 set opts "additional_flags=-static"
638 set src static[pid].f
639 set exe static[pid].x
641 set f [open $src "w"]
642 puts $f " print *, 'test'"
646 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
647 set lines [${tool}_target_compile $src $exe executable "$opts"]
650 if [string match "" $lines] then {
651 # No error message, compilation succeeded.
652 set et_static_libgfortran_saved 1
656 return $et_static_libgfortran_saved
659 # Return 1 if the target supports executing AltiVec instructions, 0
660 # otherwise. Cache the result.
662 proc check_vmx_hw_available { } {
663 global vmx_hw_available_saved
666 if [info exists vmx_hw_available_saved] {
667 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
669 set vmx_hw_available_saved 0
671 # Some simulators are known to not support VMX instructions.
672 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
673 verbose "check_hw_available returning 0" 2
674 return $vmx_hw_available_saved
677 # Set up, compile, and execute a test program containing VMX
678 # instructions. Include the current process ID in the file
679 # names to prevent conflicts with invocations for multiple
684 set f [open $src "w"]
685 puts $f "int main() {"
686 puts $f "#ifdef __MACH__"
687 puts $f " asm volatile (\"vor v0,v0,v0\");"
689 puts $f " asm volatile (\"vor 0,0,0\");"
691 puts $f " return 0; }"
694 # Most targets don't require special flags for this test case, but
696 if [istarget *-*-darwin*] {
697 set opts "additional_flags=-maltivec"
702 verbose "check_vmx_hw_available compiling testfile $src" 2
703 set lines [${tool}_target_compile $src $exe executable "$opts"]
706 if [string match "" $lines] then {
707 # No error message, compilation succeeded.
708 set result [${tool}_load "./$exe" "" ""]
709 set status [lindex $result 0]
710 remote_file build delete $exe
711 verbose "check_vmx_hw_available testfile status is <$status>" 2
713 if { $status == "pass" } then {
714 set vmx_hw_available_saved 1
717 verbose "check_vmx_hw_availalble testfile compilation failed" 2
721 return $vmx_hw_available_saved
724 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
725 # complex float arguments. This affects gfortran tests that call cabsf
726 # in libm built by an earlier compiler. Return 1 if libm uses the same
727 # argument passing as the compiler under test, 0 otherwise.
729 # When the target name changes, replace the cached result.
731 proc check_effective_target_broken_cplxf_arg { } {
732 global et_broken_cplxf_arg_saved
733 global et_broken_cplxf_arg_target_name
736 # Skip the work for targets known not to be affected.
737 if { ![istarget powerpc64-*-linux*] } {
739 } elseif { [is-effective-target ilp32] } {
743 if { ![info exists et_broken_cplxf_arg_target_name] } {
744 set et_broken_cplxf_arg_target_name ""
747 # If the target has changed since we set the cached value, clear it.
748 set current_target [current_target_name]
749 if { $current_target != $et_broken_cplxf_arg_target_name } {
750 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
751 set et_broken_cplxf_arg_target_name $current_target
752 if [info exists et_broken_cplxf_arg_saved] {
753 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
754 unset et_broken_cplxf_arg_saved
758 if [info exists et_broken_cplxf_arg_saved] {
759 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
761 set et_broken_cplxf_arg_saved 0
762 # This is only known to affect one target.
763 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
764 set et_broken_cplxf_arg_saved 0
765 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
766 return $et_broken_cplxf_arg_saved
769 # Set up, compile, and execute a C test program that calls cabsf.
773 set f [open $src "w"]
774 puts $f "#include <complex.h>"
775 puts $f "extern void abort (void);"
776 puts $f "float fabsf (float);"
777 puts $f "float cabsf (_Complex float);"
778 puts $f "int main ()"
780 puts $f " _Complex float cf;"
782 puts $f " cf = 3 + 4.0fi;"
783 puts $f " f = cabsf (cf);"
784 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
789 set lines [${tool}_target_compile $src $exe executable "-lm"]
792 if [string match "" $lines] {
793 # No error message, compilation succeeded.
794 set result [${tool}_load "./$exe" "" ""]
795 set status [lindex $result 0]
796 remote_file build delete $exe
798 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
800 if { $status != "pass" } {
801 set et_broken_cplxf_arg_saved 1
804 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
807 return $et_broken_cplxf_arg_saved
810 proc check_alpha_max_hw_available { } {
811 global alpha_max_hw_available_saved
814 if [info exists alpha_max_hw_available_saved] {
815 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
817 set alpha_max_hw_available_saved 0
819 # Set up, compile, and execute a test program probing bit 8 of the
820 # architecture mask, which indicates presence of MAX instructions.
824 set f [open $src "w"]
825 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
828 verbose "check_alpha_max_hw_available compiling testfile $src" 2
829 set lines [${tool}_target_compile $src $exe executable ""]
832 if [string match "" $lines] then {
833 # No error message, compilation succeeded.
834 set result [${tool}_load "./$exe" "" ""]
835 set status [lindex $result 0]
836 remote_file build delete $exe
837 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
839 if { $status == "pass" } then {
840 set alpha_max_hw_available_saved 1
843 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
847 return $alpha_max_hw_available_saved
850 # Returns true iff the FUNCTION is available on the target system.
851 # (This is essentially a Tcl implementation of Autoconf's
854 proc check_function_available { function } {
855 set var "${function}_available_saved"
859 if {![info exists $var]} {
862 # Check to make sure.
863 set src "function[pid].c"
864 set exe "function[pid].exe"
866 set f [open $src "w"]
867 puts $f "int main () { $function (); }"
870 set lines [${tool}_target_compile $src $exe executable ""]
874 if {![string match "" $lines]} then {
876 verbose -log "$function is not available"
878 verbose -log "$function is available"
885 # Returns true iff "fork" is available on the target system.
887 proc check_fork_available {} {
888 return [check_function_available "fork"]
891 # Returns true iff "mkfifo" is available on the target system.
893 proc check_mkfifo_available {} {
894 if {[istarget *-*-cygwin*]} {
895 # Cygwin has mkfifo, but support is incomplete.
899 return [check_function_available "mkfifo"]
902 # Return 1 if we're generating 32-bit code using default options, 0
905 # When the target name changes, replace the cached result.
907 proc check_effective_target_ilp32 { } {
908 global et_ilp32_saved
909 global et_ilp32_target_name
911 if { ![info exists et_ilp32_target_name] } {
912 set et_ilp32_target_name ""
915 # If the target has changed since we set the cached value, clear it.
916 set current_target [current_target_name]
917 if { $current_target != $et_ilp32_target_name } {
918 verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
919 set et_ilp32_target_name $current_target
920 if { [info exists et_ilp32_saved] } {
921 verbose "check_effective_target_ilp32: removing cached result" 2
926 if [info exists et_ilp32_saved] {
927 verbose "check-effective_target_ilp32: using cached result" 2
929 verbose "check_effective_target_ilp32: compiling source" 2
930 set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
931 int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
934 verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
935 return $et_ilp32_saved
938 # Return 1 if we're generating 64-bit code using default options, 0
941 # When the target name changes, replace the cached result.
943 proc check_effective_target_lp64 { } {
945 global et_lp64_target_name
947 if { ![info exists et_lp64_target_name] } {
948 set et_lp64_target_name ""
951 # If the target has changed since we set the cached value, clear it.
952 set current_target [current_target_name]
953 if { $current_target != $et_lp64_target_name } {
954 verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
955 set et_lp64_target_name $current_target
956 if [info exists et_lp64_saved] {
957 verbose "check_effective_target_lp64: removing cached result" 2
962 if [info exists et_lp64_saved] {
963 verbose "check_effective_target_lp64: using cached result" 2
965 verbose "check_effective_target_lp64: compiling source" 2
966 set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
967 int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
970 verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
971 return $et_lp64_saved
974 # Return 1 if the target needs a command line argument to enable a SIMD
977 # This won't change for different subtargets so cache the result.
979 proc check_effective_target_vect_cmdline_needed { } {
980 global et_vect_cmdline_needed_saved
982 if [info exists et_vect_cmdline_needed_saved] {
983 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
985 set et_vect_cmdline_needed_saved 1
986 if { [istarget ia64-*-*]
987 || [istarget x86_64-*-*] } {
988 set et_vect_cmdline_needed_saved 0
992 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
993 return $et_vect_cmdline_needed_saved
996 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
998 # This won't change for different subtargets so cache the result.
1000 proc check_effective_target_vect_int { } {
1001 global et_vect_int_saved
1003 if [info exists et_vect_int_saved] {
1004 verbose "check_effective_target_vect_int: using cached result" 2
1006 set et_vect_int_saved 0
1007 if { [istarget i?86-*-*]
1008 || [istarget powerpc*-*-*]
1009 || [istarget x86_64-*-*]
1010 || [istarget sparc*-*-*]
1011 || [istarget alpha*-*-*]
1012 || [istarget ia64-*-*] } {
1013 set et_vect_int_saved 1
1017 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1018 return $et_vect_int_saved
1021 # Return 1 is this is an arm target using 32-bit instructions
1022 proc check_effective_target_arm32 { } {
1023 global et_arm32_saved
1024 global et_arm32_target_name
1025 global compiler_flags
1027 if { ![info exists et_arm32_target_name] } {
1028 set et_arm32_target_name ""
1031 # If the target has changed since we set the cached value, clear it.
1032 set current_target [current_target_name]
1033 if { $current_target != $et_arm32_target_name } {
1034 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1035 set et_arm32_target_name $current_target
1036 if { [info exists et_arm32_saved] } {
1037 verbose "check_effective_target_arm32: removing cached result" 2
1038 unset et_arm32_saved
1042 if [info exists et_arm32_saved] {
1043 verbose "check-effective_target_arm32: using cached result" 2
1045 set et_arm32_saved 0
1046 if { [istarget arm-*-*]
1047 || [istarget strongarm*-*-*]
1048 || [istarget xscale-*-*] } {
1049 if ![string match "*-mthumb *" $compiler_flags] {
1050 set et_arm32_saved 1
1054 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1055 return $et_arm32_saved
1058 # Return 1 if the target supports hardware vector shift operation.
1060 proc check_effective_target_vect_shift { } {
1061 global et_vect_shift_saved
1063 if [info exists et_vect_shift_saved] {
1064 verbose "check_effective_target_vect_shift: using cached result" 2
1066 set et_vect_shift_saved 0
1067 if { [istarget powerpc*-*-*]
1068 || [istarget ia64-*-*]
1069 || [istarget i?86-*-*]
1070 || [istarget x86_64-*-*] } {
1071 set et_vect_shift_saved 1
1075 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1076 return $et_vect_shift_saved
1079 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1081 # This can change for different subtargets so do not cache the result.
1083 proc check_effective_target_vect_long { } {
1084 if { [istarget i?86-*-*]
1085 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1086 || [istarget x86_64-*-*]
1087 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1093 verbose "check_effective_target_vect_long: returning $answer" 2
1097 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1099 # This won't change for different subtargets so cache the result.
1101 proc check_effective_target_vect_float { } {
1102 global et_vect_float_saved
1104 if [info exists et_vect_float_saved] {
1105 verbose "check_effective_target_vect_float: using cached result" 2
1107 set et_vect_float_saved 0
1108 if { [istarget i?86-*-*]
1109 || [istarget powerpc*-*-*]
1110 || [istarget mipsisa64*-*-*]
1111 || [istarget x86_64-*-*]
1112 || [istarget ia64-*-*] } {
1113 set et_vect_float_saved 1
1117 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1118 return $et_vect_float_saved
1121 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1123 # This won't change for different subtargets so cache the result.
1125 proc check_effective_target_vect_double { } {
1126 global et_vect_double_saved
1128 if [info exists et_vect_double_saved] {
1129 verbose "check_effective_target_vect_double: using cached result" 2
1131 set et_vect_double_saved 0
1132 if { [istarget i?86-*-*]
1133 || [istarget x86_64-*-*] } {
1134 set et_vect_double_saved 1
1138 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1139 return $et_vect_double_saved
1142 # Return 1 if the target plus current options does not support a vector
1143 # max instruction on "int", 0 otherwise.
1145 # This won't change for different subtargets so cache the result.
1147 proc check_effective_target_vect_no_int_max { } {
1148 global et_vect_no_int_max_saved
1150 if [info exists et_vect_no_int_max_saved] {
1151 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1153 set et_vect_no_int_max_saved 0
1154 if { [istarget sparc*-*-*]
1155 || [istarget alpha*-*-*] } {
1156 set et_vect_no_int_max_saved 1
1159 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1160 return $et_vect_no_int_max_saved
1163 # Return 1 if the target plus current options does not support a vector
1164 # add instruction on "int", 0 otherwise.
1166 # This won't change for different subtargets so cache the result.
1168 proc check_effective_target_vect_no_int_add { } {
1169 global et_vect_no_int_add_saved
1171 if [info exists et_vect_no_int_add_saved] {
1172 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1174 set et_vect_no_int_add_saved 0
1175 # Alpha only supports vector add on V8QI and V4HI.
1176 if { [istarget alpha*-*-*] } {
1177 set et_vect_no_int_add_saved 1
1180 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1181 return $et_vect_no_int_add_saved
1184 # Return 1 if the target plus current options does not support vector
1185 # bitwise instructions, 0 otherwise.
1187 # This won't change for different subtargets so cache the result.
1189 proc check_effective_target_vect_no_bitwise { } {
1190 global et_vect_no_bitwise_saved
1192 if [info exists et_vect_no_bitwise_saved] {
1193 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1195 set et_vect_no_bitwise_saved 0
1197 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1198 return $et_vect_no_bitwise_saved
1201 # Return 1 if the target plus current options does not support a vector
1202 # alignment mechanism, 0 otherwise.
1204 # This won't change for different subtargets so cache the result.
1206 proc check_effective_target_vect_no_align { } {
1207 global et_vect_no_align_saved
1209 if [info exists et_vect_no_align_saved] {
1210 verbose "check_effective_target_vect_no_align: using cached result" 2
1212 set et_vect_no_align_saved 0
1213 if { [istarget mipsisa64*-*-*]
1214 || [istarget sparc*-*-*]
1215 || [istarget ia64-*-*] } {
1216 set et_vect_no_align_saved 1
1219 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1220 return $et_vect_no_align_saved
1223 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1225 proc check_effective_target_vect_condition { } {
1226 global et_vect_cond_saved
1228 if [info exists et_vect_cond_saved] {
1229 verbose "check_effective_target_vect_cond: using cached result" 2
1231 set et_vect_cond_saved 0
1232 if { [istarget powerpc*-*-*]
1233 || [istarget ia64-*-*]
1234 || [istarget i?86-*-*]
1235 || [istarget x86_64-*-*] } {
1236 set et_vect_cond_saved 1
1240 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1241 return $et_vect_cond_saved
1244 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1246 proc check_effective_target_vect_int_mult { } {
1247 global et_vect_int_mult_saved
1249 if [info exists et_vect_int_mult_saved] {
1250 verbose "check_effective_target_vect_int_mult: using cached result" 2
1252 set et_vect_int_mult_saved 0
1253 if { [istarget powerpc*-*-*]
1254 || [istarget i?86-*-*]
1255 || [istarget x86_64-*-*] } {
1256 set et_vect_int_mult_saved 1
1260 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1261 return $et_vect_int_mult_saved
1264 # Return 1 if the target supports atomic operations on "int" and "long".
1266 proc check_effective_target_sync_int_long { } {
1267 global et_sync_int_long_saved
1269 if [info exists et_sync_int_long_saved] {
1270 verbose "check_effective_target_sync_int_long: using cached result" 2
1272 set et_sync_int_long_saved 0
1273 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1274 # load-reserved/store-conditional instructions.
1275 if { [istarget ia64-*-*]
1276 || [istarget i?86-*-*]
1277 || [istarget x86_64-*-*]
1278 || [istarget alpha*-*-*]
1279 || [istarget s390*-*-*]
1280 || [istarget powerpc*-*-*] } {
1281 set et_sync_int_long_saved 1
1285 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1286 return $et_sync_int_long_saved
1289 # Return 1 if the target supports atomic operations on "char" and "short".
1291 proc check_effective_target_sync_char_short { } {
1292 global et_sync_char_short_saved
1294 if [info exists et_sync_char_short_saved] {
1295 verbose "check_effective_target_sync_char_short: using cached result" 2
1297 set et_sync_char_short_saved 0
1298 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1299 # load-reserved/store-conditional instructions.
1300 if { [istarget ia64-*-*]
1301 || [istarget i?86-*-*]
1302 || [istarget x86_64-*-*]
1303 || [istarget alpha*-*-*]
1304 || [istarget powerpc*-*-*] } {
1305 set et_sync_char_short_saved 1
1309 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1310 return $et_sync_char_short_saved
1313 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1314 # This can be used with any check_* proc that takes no argument and
1315 # returns only 1 or 0. It could be used with check_* procs that take
1316 # arguments with keywords that pass particular arguments.
1318 proc is-effective-target { arg } {
1320 if { [info procs check_effective_target_${arg}] != [list] } {
1321 set selected [check_effective_target_${arg}]
1324 "vmx_hw" { set selected [check_vmx_hw_available] }
1325 "named_sections" { set selected [check_named_sections_available] }
1326 "gc_sections" { set selected [check_gc_sections_available] }
1327 default { error "unknown effective target keyword `$arg'" }
1330 verbose "is-effective-target: $arg $selected" 2
1334 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1336 proc is-effective-target-keyword { arg } {
1337 if { [info procs check_effective_target_${arg}] != [list] } {
1340 # These have different names for their check_* procs.
1342 "vmx_hw" { return 1 }
1343 "named_sections" { return 1 }
1344 "gc_sections" { return 1 }
1345 default { return 0 }