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 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
23 # Try to compile 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 Tcl command ARGS and seeing if it returns true.
92 proc check_cached_effective_target { prop args } {
95 set target [current_target_name]
96 if {![info exists et_cache($prop,target)]
97 || $et_cache($prop,target) != $target} {
98 verbose "check_cached_effective_target $prop: checking $target" 2
99 set et_cache($prop,target) $target
100 set et_cache($prop,value) [uplevel eval $args]
102 set value $et_cache($prop,value)
103 verbose "check_cached_effective_target $prop: returning $value for $target" 2
107 # Implement an effective-target check for property PROP by invoking
108 # the compiler and seeing if it prints any messages. Assume that the
109 # property holds if the compiler doesn't print anything. The other
110 # arguments are as for get_compiler_messages, starting with TYPE.
111 proc check_no_compiler_messages {prop args} {
112 return [check_cached_effective_target $prop {
113 string match "" [eval get_compiler_messages $prop 0 $args]
117 # Similar to check_no_compiler_messages, but also verify that the regular
118 # expression PATTERN matches the compiler's output.
119 proc check_no_messages_and_pattern {prop pattern args} {
120 return [check_cached_effective_target $prop {
121 set results [eval get_compiler_messages $prop 1 $args]
122 expr { [string match "" [lindex $results 0]]
123 && [regexp $pattern [lindex $results 1]] }
127 ###############################
128 # proc check_weak_available { }
129 ###############################
131 # weak symbols are only supported in some configs/object formats
132 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
134 proc check_weak_available { } {
135 global target_triplet
138 # All mips targets should support it
140 if { [ string first "mips" $target_cpu ] >= 0 } {
144 # All solaris2 targets should support it
146 if { [regexp ".*-solaris2.*" $target_triplet] } {
150 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
152 if { [regexp "alpha.*osf.*" $target_triplet] } {
156 # Windows targets Cygwin and MingW32 support it
158 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
162 # HP-UX 10.X doesn't support it
164 if { [istarget "hppa*-*-hpux10*"] } {
168 # ELF and ECOFF support it. a.out does with gas/gld but may also with
169 # other linkers, so we should try it
171 set objformat [gcc_target_object_format]
179 unknown { return -1 }
184 ###############################
185 # proc check_visibility_available { what_kind }
186 ###############################
188 # The visibility attribute is only support in some object formats
189 # This proc returns 1 if it is supported, 0 if not.
190 # The argument is the kind of visibility, default/protected/hidden/internal.
192 proc check_visibility_available { what_kind } {
194 global target_triplet
196 # On NetWare, support makes no sense.
197 if { [istarget *-*-netware*] } {
201 if [string match "" $what_kind] { set what_kind "hidden" }
203 return [check_no_compiler_messages visibility_available_$what_kind object "
204 void f() __attribute__((visibility(\"$what_kind\")));
209 ###############################
210 # proc check_alias_available { }
211 ###############################
213 # Determine if the target toolchain supports the alias attribute.
215 # Returns 2 if the target supports aliases. Returns 1 if the target
216 # only supports weak aliased. Returns 0 if the target does not
217 # support aliases at all. Returns -1 if support for aliases could not
220 proc check_alias_available { } {
221 global alias_available_saved
224 if [info exists alias_available_saved] {
225 verbose "check_alias_available returning saved $alias_available_saved" 2
229 verbose "check_alias_available compiling testfile $src" 2
230 set f [open $src "w"]
231 # Compile a small test program. The definition of "g" is
232 # necessary to keep the Solaris assembler from complaining
234 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
235 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
237 set lines [${tool}_target_compile $src $obj object ""]
239 remote_file build delete $obj
241 if [string match "" $lines] then {
242 # No error messages, everything is OK.
243 set alias_available_saved 2
245 if [regexp "alias definitions not supported" $lines] {
246 verbose "check_alias_available target does not support aliases" 2
248 set objformat [gcc_target_object_format]
250 if { $objformat == "elf" } {
251 verbose "check_alias_available but target uses ELF format, so it ought to" 2
252 set alias_available_saved -1
254 set alias_available_saved 0
257 if [regexp "only weak aliases are supported" $lines] {
258 verbose "check_alias_available target supports only weak aliases" 2
259 set alias_available_saved 1
261 set alias_available_saved -1
266 verbose "check_alias_available returning $alias_available_saved" 2
269 return $alias_available_saved
272 # Returns true if --gc-sections is supported on the target.
274 proc check_gc_sections_available { } {
275 global gc_sections_available_saved
278 if {![info exists gc_sections_available_saved]} {
279 # Some targets don't support gc-sections despite whatever's
280 # advertised by ld's options.
281 if { [istarget alpha*-*-*]
282 || [istarget ia64-*-*] } {
283 set gc_sections_available_saved 0
287 # elf2flt uses -q (--emit-relocs), which is incompatible with
289 if { [board_info target exists ldflags]
290 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
291 set gc_sections_available_saved 0
295 # VxWorks kernel modules are relocatable objects linked with -r,
296 # while RTP executables are linked with -q (--emit-relocs).
297 # Both of these options are incompatible with --gc-sections.
298 if { [istarget *-*-vxworks*] } {
299 set gc_sections_available_saved 0
303 # Check if the ld used by gcc supports --gc-sections.
304 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
305 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
306 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
307 set ld_output [remote_exec host "$gcc_ld" "--help"]
308 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
309 set gc_sections_available_saved 1
311 set gc_sections_available_saved 0
314 return $gc_sections_available_saved
317 # Return true if profiling is supported on the target.
319 proc check_profiling_available { test_what } {
320 global profiling_available_saved
322 verbose "Profiling argument is <$test_what>" 1
324 # These conditions depend on the argument so examine them before
325 # looking at the cache variable.
327 # Support for -p on solaris2 relies on mcrt1.o which comes with the
328 # vendor compiler. We cannot reliably predict the directory where the
329 # vendor compiler (and thus mcrt1.o) is installed so we can't
330 # necessarily find mcrt1.o even if we have it.
331 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
335 # Support for -p on irix relies on libprof1.a which doesn't appear to
336 # exist on any irix6 system currently posting testsuite results.
337 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
338 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
339 if { [istarget mips*-*-irix*]
340 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
344 # At present, there is no profiling support on NetWare.
345 if { [istarget *-*-netware*] } {
349 # uClibc does not have gcrt1.o.
350 if { [check_effective_target_uclibc]
351 && ([lindex $test_what 1] == "-p"
352 || [lindex $test_what 1] == "-pg") } {
356 # Now examine the cache variable.
357 if {![info exists profiling_available_saved]} {
358 # Some targets don't have any implementation of __bb_init_func or are
359 # missing other needed machinery.
360 if { [istarget mmix-*-*]
361 || [istarget arm*-*-eabi*]
362 || [istarget arm*-*-elf]
363 || [istarget arm*-*-symbianelf*]
364 || [istarget bfin-*-*]
365 || [istarget powerpc-*-eabi*]
366 || [istarget strongarm*-*-elf]
367 || [istarget xscale*-*-elf]
368 || [istarget cris-*-*]
369 || [istarget fido-*-elf]
370 || [istarget h8300-*-*]
371 || [istarget m32c-*-elf]
372 || [istarget m68k-*-elf]
373 || [istarget m68k-*-uclinux*]
374 || [istarget mips*-*-elf*]
375 || [istarget xtensa-*-elf]
376 || [istarget *-*-vxworks*]
377 || [istarget *-*-windiss] } {
378 set profiling_available_saved 0
380 set profiling_available_saved 1
384 return $profiling_available_saved
387 # Return 1 if target has packed layout of structure members by
388 # default, 0 otherwise. Note that this is slightly different than
389 # whether the target has "natural alignment": both attributes may be
392 proc check_effective_target_default_packed { } {
393 return [check_no_compiler_messages default_packed assembly {
394 struct x { char a; long b; } c;
395 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
399 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
400 # documentation, where the test also comes from.
402 proc check_effective_target_pcc_bitfield_type_matters { } {
403 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
404 # bitfields, but let's stick to the example code from the docs.
405 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
406 struct foo1 { char x; char :0; char y; };
407 struct foo2 { char x; int :0; char y; };
408 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
412 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
414 # This won't change for different subtargets so cache the result.
416 proc check_effective_target_tls {} {
420 if [info exists et_tls_saved] {
421 verbose "check_effective_target_tls: using cached result" 2
427 verbose "check_effective_target_tls: compiling testfile $src" 2
428 set f [open $src "w"]
429 # Compile a small test program. Make sure that we test accesses
430 # as well as declarations.
431 puts $f "__thread int i;\n"
432 puts $f "int f (void) { return i; }\n"
433 puts $f "void g (int j) { i = j; }\n"
436 # Test for thread-local data supported by the platform.
438 [${tool}_target_compile $src $asm assembly ""]
440 if { [string match "" $comp_output] } {
441 # No error messages, everything is OK.
444 remove-build-file $asm
446 verbose "check_effective_target_tls: returning $et_tls_saved" 2
450 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
452 # This won't change for different subtargets so cache the result.
454 proc check_effective_target_tls_native {} {
455 global et_tls_native_saved
458 if [info exists et_tls_saved] {
459 verbose "check_effective_target_tls_native: using cached result" 2
461 set et_tls_native_saved 0
465 verbose "check_effective_target_tls_native: compiling testfile $src" 2
466 set f [open $src "w"]
467 # Compile a small test program. Make sure that we test accesses
468 # as well as declarations.
469 puts $f "__thread int i;\n"
470 puts $f "int f (void) { return i; }\n"
471 puts $f "void g (int j) { i = j; }\n"
474 # Test for thread-local data supported by the platform.
475 set comp_output [${tool}_target_compile $src $asm assembly ""]
477 if { [string match "" $comp_output] } {
478 # No error messages, everything is OK.
482 if { [string match "*emutls*" $text]} {
483 set et_tls_native_saved 0
485 set et_tls_native_saved 1
488 remove-build-file $asm
490 verbose "check_effective_target_tls_native: returning $et_tls_native_saved" 2
491 return $et_tls_native_saved
494 # Return 1 if TLS executables can run correctly, 0 otherwise.
496 # This won't change for different subtargets so cache the result.
498 proc check_effective_target_tls_runtime {} {
499 global et_tls_runtime_saved
502 if [info exists et_tls_runtime_saved] {
503 verbose "check_effective_target_tls_runtime: using cached result" 2
505 set et_tls_runtime_saved 0
507 set src tls_runtime[pid].c
508 set exe tls_runtime[pid].x
509 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
510 set f [open $src "w"]
511 # Compile a small test program.
512 puts $f "__thread int thr = 0;\n"
513 puts $f "int main(void)\n {\n return thr;\n}"
517 [${tool}_target_compile $src $exe executable ""]
520 if [string match "" $comp_output] then {
521 # No error messages, everything is OK.
523 set result [remote_load target "./$exe" "" ""]
524 set status [lindex $result 0]
525 remote_file build delete $exe
527 verbose "check_effective_target_tls_runtime status is <$status>" 2
529 if { $status == "pass" } {
530 set et_tls_runtime_saved 1
533 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
537 return $et_tls_runtime_saved
540 # Return 1 if compilation with -fopenmp is error-free for trivial
543 proc check_effective_target_fopenmp {} {
544 return [check_no_compiler_messages fopenmp object {
549 # Return 1 if the target supports -fstack-protector
550 proc check_effective_target_fstack_protector {} {
554 set src stack_prot[pid].c
555 set exe stack_prot[pid].x
557 verbose "check_effective_target_fstack_protector compiling testfile $src" 2
559 set f [open $src "w"]
560 # Compile a small test program.
561 puts $f "int main (void)\n { return 0; }\n"
564 set opts "additional_flags=-fstack-protector"
565 set lines [${tool}_target_compile $src $exe executable "$opts" ]
568 if [string match "" $lines] then {
569 # No error messages, everything is OK.
570 set result [${tool}_load "./$exe" "" ""]
571 set status [lindex $result 0]
572 remote_file build delete $exe
573 verbose "check_iconv_available status is <$status>" 2
575 if { $status == "pass" } then {
582 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
583 # for trivial code, 0 otherwise.
585 proc check_effective_target_freorder {} {
586 return [check_no_compiler_messages freorder object {
588 } "-freorder-blocks-and-partition"]
591 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
592 # emitted, 0 otherwise. Whether a shared library can actually be built is
593 # out of scope for this test.
595 proc check_effective_target_fpic { } {
596 # Note that M68K has a multilib that supports -fpic but not
597 # -fPIC, so we need to check both. We test with a program that
598 # requires GOT references.
599 foreach arg {fpic fPIC} {
600 if [check_no_compiler_messages $arg object {
601 extern int foo (void); extern int bar;
602 int baz (void) { return foo () + bar; }
610 # Return true if the target supports -mpaired-single (as used on MIPS).
612 proc check_effective_target_mpaired_single { } {
613 return [check_no_compiler_messages mpaired_single object {
618 # Return true if the target has access to FPU instructions.
620 proc check_effective_target_hard_float { } {
621 return [check_no_compiler_messages hard_float assembly {
622 #if ((defined __mips \
623 && (defined __mips_soft_float || defined __mips16)) \
624 || (defined __xtensa__ && defined __XTENSA_SOFT_FLOAT__))
630 # Return true if the target is a 64-bit MIPS target.
632 proc check_effective_target_mips64 { } {
633 return [check_no_compiler_messages mips64 assembly {
640 # Return true if the target is a MIPS target that does not produce
643 proc check_effective_target_nomips16 { } {
644 return [check_no_compiler_messages nomips16 object {
648 /* A cheap way of testing for -mflip-mips16. */
649 void foo (void) { asm ("addiu $20,$20,1"); }
650 void bar (void) { asm ("addiu $20,$20,1"); }
655 # Add the options needed for MIPS16 function attributes. At the moment,
656 # we don't support MIPS16 PIC.
658 proc add_options_for_mips16_attribute { flags } {
659 return "$flags -mno-abicalls -fno-pic"
662 # Return true if we can force a mode that allows MIPS16 code generation.
663 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
666 proc check_effective_target_mips16_attribute { } {
667 return [check_no_compiler_messages mips16_attribute assembly {
671 #if defined __mips_hard_float \
672 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
673 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
676 } [add_options_for_mips16_attribute ""]]
679 # Return 1 if the current multilib does not generate PIC by default.
681 proc check_effective_target_nonpic { } {
682 return [check_no_compiler_messages nonpic assembly {
689 # Return 1 if the target does not use a status wrapper.
691 proc check_effective_target_unwrapped { } {
692 if { [target_info needs_status_wrapper] != "" \
693 && [target_info needs_status_wrapper] != "0" } {
699 # Return true if iconv is supported on the target. In particular IBM1047.
701 proc check_iconv_available { test_what } {
709 verbose "check_iconv_available compiling testfile $src" 2
710 set f [open $src "w"]
711 # Compile a small test program.
712 puts $f "#include <iconv.h>\n"
713 puts $f "int main (void)\n {\n iconv_t cd; \n"
714 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
715 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
716 puts $f "return 0;\n}"
719 # If the tool configuration file has not set libiconv, try "-liconv"
720 if { ![info exists libiconv] } {
721 set libiconv "-liconv"
723 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
726 if [string match "" $lines] then {
727 # No error messages, everything is OK.
729 set result [${tool}_load "./$exe" "" ""]
730 set status [lindex $result 0]
731 remote_file build delete $exe
733 verbose "check_iconv_available status is <$status>" 2
735 if { $status == "pass" } then {
743 # Return true if named sections are supported on this target.
745 proc check_named_sections_available { } {
746 return [check_no_compiler_messages named_sections assembly {
747 int __attribute__ ((section("whatever"))) foo;
751 # Return 1 if the target supports Fortran real kinds larger than real(8),
754 # When the target name changes, replace the cached result.
756 proc check_effective_target_fortran_large_real { } {
757 global et_fortran_large_real_saved
758 global et_fortran_large_real_target_name
761 if { ![info exists et_fortran_large_real_target_name] } {
762 set et_fortran_large_real_target_name ""
765 # If the target has changed since we set the cached value, clear it.
766 set current_target [current_target_name]
767 if { $current_target != $et_fortran_large_real_target_name } {
768 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
769 set et_fortran_large_real_target_name $current_target
770 if [info exists et_fortran_large_real_saved] {
771 verbose "check_effective_target_fortran_large_real: removing cached result" 2
772 unset et_fortran_large_real_saved
776 if [info exists et_fortran_large_real_saved] {
777 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
779 set et_fortran_large_real_saved 0
781 # Set up, compile, and execute a test program using large real
782 # kinds. Include the current process ID in the file names to
783 # prevent conflicts with invocations for multiple testsuites.
784 set src real[pid].f90
787 set f [open $src "w"]
788 puts $f "integer,parameter :: k = &"
789 puts $f " selected_real_kind (precision (0.0_8) + 1)"
790 puts $f "real(kind=k) :: x"
791 puts $f "x = cos (x);"
795 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
796 set lines [${tool}_target_compile $src $exe executable ""]
799 if [string match "" $lines] then {
800 # No error message, compilation succeeded.
801 remote_file build delete $exe
802 set et_fortran_large_real_saved 1
806 return $et_fortran_large_real_saved
809 # Return 1 if the target supports Fortran integer kinds larger than
810 # integer(8), 0 otherwise.
812 # When the target name changes, replace the cached result.
814 proc check_effective_target_fortran_large_int { } {
815 global et_fortran_large_int_saved
816 global et_fortran_large_int_target_name
819 if { ![info exists et_fortran_large_int_target_name] } {
820 set et_fortran_large_int_target_name ""
823 # If the target has changed since we set the cached value, clear it.
824 set current_target [current_target_name]
825 if { $current_target != $et_fortran_large_int_target_name } {
826 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
827 set et_fortran_large_int_target_name $current_target
828 if [info exists et_fortran_large_int_saved] {
829 verbose "check_effective_target_fortran_large_int: removing cached result" 2
830 unset et_fortran_large_int_saved
834 if [info exists et_fortran_large_int_saved] {
835 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
837 set et_fortran_large_int_saved 0
839 # Set up, compile, and execute a test program using large integer
840 # kinds. Include the current process ID in the file names to
841 # prevent conflicts with invocations for multiple testsuites.
845 set f [open $src "w"]
846 puts $f "integer,parameter :: k = &"
847 puts $f " selected_int_kind (range (0_8) + 1)"
848 puts $f "integer(kind=k) :: i"
852 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
853 set lines [${tool}_target_compile $src $exe executable ""]
856 if [string match "" $lines] then {
857 # No error message, compilation succeeded.
858 remote_file build delete $exe
859 set et_fortran_large_int_saved 1
863 return $et_fortran_large_int_saved
866 # Return 1 if we can statically link libgfortran, 0 otherwise.
868 # When the target name changes, replace the cached result.
870 proc check_effective_target_static_libgfortran { } {
871 global et_static_libgfortran
872 global et_static_libgfortran_target_name
875 if { ![info exists et_static_libgfortran_target_name] } {
876 set et_static_libgfortran_target_name ""
879 # If the target has changed since we set the cached value, clear it.
880 set current_target [current_target_name]
881 if { $current_target != $et_static_libgfortran_target_name } {
882 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
883 set et_static_libgfortran_target_name $current_target
884 if [info exists et_static_libgfortran_saved] {
885 verbose "check_effective_target_static_libgfortran: removing cached result" 2
886 unset et_static_libgfortran_saved
890 if [info exists et_static_libgfortran_saved] {
891 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
893 set et_static_libgfortran_saved 0
895 # Set up, compile, and execute a test program using static linking.
896 # Include the current process ID in the file names to prevent
897 # conflicts with invocations for multiple testsuites.
898 set opts "additional_flags=-static"
899 set src static[pid].f
900 set exe static[pid].x
902 set f [open $src "w"]
903 puts $f " print *, 'test'"
907 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
908 set lines [${tool}_target_compile $src $exe executable "$opts"]
911 if [string match "" $lines] then {
912 # No error message, compilation succeeded.
913 remote_file build delete $exe
914 set et_static_libgfortran_saved 1
918 return $et_static_libgfortran_saved
921 # Return 1 if the target supports executing 750CL paired-single instructions, 0
922 # otherwise. Cache the result.
924 proc check_750cl_hw_available { } {
925 global 750cl_hw_available_saved
928 if [info exists 750cl_hw_available_saved] {
929 verbose "check_hw_available returning saved $750cl_hw_available_saved" 2
931 set 750cl_hw_available_saved 0
933 # If this is not the right target then we can quit.
934 if { ![istarget powerpc-*paired*] } {
935 verbose "check_hw_available returning 0" 2
936 return $750cl_hw_available_saved
939 # Set up, compile, and execute a test program containing paired-single
940 # instructions. Include the current process ID in the file
941 # names to prevent conflicts with invocations for multiple
946 set f [open $src "w"]
947 puts $f "int main() {"
948 puts $f "#ifdef __MACH__"
949 puts $f " asm volatile (\"ps_mul v0,v0,v0\");"
951 puts $f " asm volatile (\"ps_mul 0,0,0\");"
953 puts $f " return 0; }"
956 verbose "check_750cl_hw_available compiling testfile $src" 2
957 set lines [${tool}_target_compile $src $exe executable "-mpaired"]
960 if [string match "" $lines] then {
961 # No error message, compilation succeeded.
962 set result [${tool}_load "./$exe" "" ""]
963 set status [lindex $result 0]
964 remote_file build delete $exe
965 verbose "check_750cl_hw_available testfile status is <$status>" 2
967 if { $status == "pass" } then {
968 set 750cl_hw_available_saved 1
971 verbose "check_750cl_hw_availalble testfile compilation failed" 2
974 return $750cl_hw_available_saved
978 # Return 1 if the target supports executing AltiVec instructions, 0
979 # otherwise. Cache the result.
981 proc check_vmx_hw_available { } {
982 global vmx_hw_available_saved
985 if [info exists vmx_hw_available_saved] {
986 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
988 set vmx_hw_available_saved 0
990 # Some simulators are known to not support VMX instructions.
991 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
992 verbose "check_hw_available returning 0" 2
993 return $vmx_hw_available_saved
996 # Set up, compile, and execute a test program containing VMX
997 # instructions. Include the current process ID in the file
998 # names to prevent conflicts with invocations for multiple
1003 set f [open $src "w"]
1004 puts $f "int main() {"
1005 puts $f "#ifdef __MACH__"
1006 puts $f " asm volatile (\"vor v0,v0,v0\");"
1008 puts $f " asm volatile (\"vor 0,0,0\");"
1010 puts $f " return 0; }"
1013 # Most targets don't require special flags for this test case, but
1015 if { [istarget *-*-darwin*]
1016 || [istarget *-*-aix*] } {
1017 set opts "additional_flags=-maltivec"
1022 verbose "check_vmx_hw_available compiling testfile $src" 2
1023 set lines [${tool}_target_compile $src $exe executable "$opts"]
1026 if [string match "" $lines] then {
1027 # No error message, compilation succeeded.
1028 set result [${tool}_load "./$exe" "" ""]
1029 set status [lindex $result 0]
1030 remote_file build delete $exe
1031 verbose "check_vmx_hw_available testfile status is <$status>" 2
1033 if { $status == "pass" } then {
1034 set vmx_hw_available_saved 1
1037 verbose "check_vmx_hw_availalble testfile compilation failed" 2
1041 return $vmx_hw_available_saved
1044 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1045 # complex float arguments. This affects gfortran tests that call cabsf
1046 # in libm built by an earlier compiler. Return 1 if libm uses the same
1047 # argument passing as the compiler under test, 0 otherwise.
1049 # When the target name changes, replace the cached result.
1051 proc check_effective_target_broken_cplxf_arg { } {
1052 global et_broken_cplxf_arg_saved
1053 global et_broken_cplxf_arg_target_name
1056 # Skip the work for targets known not to be affected.
1057 if { ![istarget powerpc64-*-linux*] } {
1059 } elseif { [is-effective-target ilp32] } {
1063 if { ![info exists et_broken_cplxf_arg_target_name] } {
1064 set et_broken_cplxf_arg_target_name ""
1067 # If the target has changed since we set the cached value, clear it.
1068 set current_target [current_target_name]
1069 if { $current_target != $et_broken_cplxf_arg_target_name } {
1070 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
1071 set et_broken_cplxf_arg_target_name $current_target
1072 if [info exists et_broken_cplxf_arg_saved] {
1073 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
1074 unset et_broken_cplxf_arg_saved
1078 if [info exists et_broken_cplxf_arg_saved] {
1079 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
1081 set et_broken_cplxf_arg_saved 0
1082 # This is only known to affect one target.
1083 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
1084 set et_broken_cplxf_arg_saved 0
1085 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
1086 return $et_broken_cplxf_arg_saved
1089 # Set up, compile, and execute a C test program that calls cabsf.
1090 set src cabsf[pid].c
1091 set exe cabsf[pid].x
1093 set f [open $src "w"]
1094 puts $f "#include <complex.h>"
1095 puts $f "extern void abort (void);"
1096 puts $f "float fabsf (float);"
1097 puts $f "float cabsf (_Complex float);"
1098 puts $f "int main ()"
1100 puts $f " _Complex float cf;"
1102 puts $f " cf = 3 + 4.0fi;"
1103 puts $f " f = cabsf (cf);"
1104 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
1105 puts $f " return 0;"
1109 set lines [${tool}_target_compile $src $exe executable "-lm"]
1112 if [string match "" $lines] {
1113 # No error message, compilation succeeded.
1114 set result [${tool}_load "./$exe" "" ""]
1115 set status [lindex $result 0]
1116 remote_file build delete $exe
1118 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1120 if { $status != "pass" } {
1121 set et_broken_cplxf_arg_saved 1
1124 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1127 return $et_broken_cplxf_arg_saved
1130 proc check_alpha_max_hw_available { } {
1131 global alpha_max_hw_available_saved
1134 if [info exists alpha_max_hw_available_saved] {
1135 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1137 set alpha_max_hw_available_saved 0
1139 # Set up, compile, and execute a test program probing bit 8 of the
1140 # architecture mask, which indicates presence of MAX instructions.
1144 set f [open $src "w"]
1145 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1148 verbose "check_alpha_max_hw_available compiling testfile $src" 2
1149 set lines [${tool}_target_compile $src $exe executable ""]
1152 if [string match "" $lines] then {
1153 # No error message, compilation succeeded.
1154 set result [${tool}_load "./$exe" "" ""]
1155 set status [lindex $result 0]
1156 remote_file build delete $exe
1157 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1159 if { $status == "pass" } then {
1160 set alpha_max_hw_available_saved 1
1163 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1167 return $alpha_max_hw_available_saved
1170 # Returns true iff the FUNCTION is available on the target system.
1171 # (This is essentially a Tcl implementation of Autoconf's
1174 proc check_function_available { function } {
1175 set var "${function}_available_saved"
1179 if {![info exists $var]} {
1182 # Check to make sure.
1183 set src "function[pid].c"
1184 set exe "function[pid].exe"
1186 set f [open $src "w"]
1187 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1188 puts $f "char $function ();\n"
1189 puts $f "int main () { $function (); }"
1192 set lines [${tool}_target_compile $src $exe executable ""]
1196 if {![string match "" $lines]} then {
1198 verbose -log "$function is not available"
1200 verbose -log "$function is available"
1207 # Returns true iff "fork" is available on the target system.
1209 proc check_fork_available {} {
1210 return [check_function_available "fork"]
1213 # Returns true iff "mkfifo" is available on the target system.
1215 proc check_mkfifo_available {} {
1216 if {[istarget *-*-cygwin*]} {
1217 # Cygwin has mkfifo, but support is incomplete.
1221 return [check_function_available "mkfifo"]
1224 # Returns true iff "__cxa_atexit" is used on the target system.
1226 proc check_cxa_atexit_available { } {
1227 global et_cxa_atexit
1228 global et_cxa_atexit_target_name
1231 if { ![info exists et_cxa_atexit_target_name] } {
1232 set et_cxa_atexit_target_name ""
1235 # If the target has changed since we set the cached value, clear it.
1236 set current_target [current_target_name]
1237 if { $current_target != $et_cxa_atexit_target_name } {
1238 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1239 set et_cxa_atexit_target_name $current_target
1240 if [info exists et_cxa_atexit] {
1241 verbose "check_cxa_atexit_available: removing cached result" 2
1246 if [info exists et_cxa_atexit] {
1247 verbose "check_cxa_atexit_available: using cached result" 2
1248 } elseif { [istarget "hppa*-*-hpux10*"] } {
1249 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1254 # Set up, compile, and execute a C++ test program that depends
1255 # on correct ordering of static object destructors. This is
1256 # indicative of the presence and use of __cxa_atexit.
1257 set src cxaatexit[pid].cc
1258 set exe cxaatexit[pid].x
1260 set f [open $src "w"]
1261 puts $f "#include <stdlib.h>"
1262 puts $f "static unsigned int count;"
1265 puts $f " X() { count = 1; }"
1268 puts $f " if (count != 3)"
1270 puts $f " count = 4;"
1275 puts $f " static X x;"
1279 puts $f " Y() { f(); count = 2; }"
1282 puts $f " if (count != 2)"
1284 puts $f " count = 3;"
1288 puts $f "int main()"
1289 puts $f "{ return 0; }"
1292 set lines [${tool}_target_compile $src $exe executable ""]
1295 if [string match "" $lines] {
1296 # No error message, compilation succeeded.
1297 set result [${tool}_load "./$exe" "" ""]
1298 set status [lindex $result 0]
1299 remote_file build delete $exe
1301 verbose "check_cxa_atexit_available: status is <$status>" 2
1303 if { $status == "pass" } {
1307 verbose "check_cxa_atexit_available: compilation failed" 2
1310 return $et_cxa_atexit
1314 # Return 1 if we're generating 32-bit code using default options, 0
1317 proc check_effective_target_ilp32 { } {
1318 return [check_no_compiler_messages ilp32 object {
1319 int dummy[sizeof (int) == 4
1320 && sizeof (void *) == 4
1321 && sizeof (long) == 4 ? 1 : -1];
1325 # Return 1 if we're generating 32-bit or larger integers using default
1326 # options, 0 otherwise.
1328 proc check_effective_target_int32plus { } {
1329 return [check_no_compiler_messages int32plus object {
1330 int dummy[sizeof (int) >= 4 ? 1 : -1];
1334 # Return 1 if we're generating 32-bit or larger pointers using default
1335 # options, 0 otherwise.
1337 proc check_effective_target_ptr32plus { } {
1338 return [check_no_compiler_messages ptr32plus object {
1339 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1343 # Return 1 if we support 32-bit or larger array and structure sizes
1344 # using default options, 0 otherwise.
1346 proc check_effective_target_size32plus { } {
1347 return [check_no_compiler_messages size32plus object {
1352 # Returns 1 if we're generating 16-bit or smaller integers with the
1353 # default options, 0 otherwise.
1355 proc check_effective_target_int16 { } {
1356 return [check_no_compiler_messages int16 object {
1357 int dummy[sizeof (int) < 4 ? 1 : -1];
1361 # Return 1 if we're generating 64-bit code using default options, 0
1364 proc check_effective_target_lp64 { } {
1365 return [check_no_compiler_messages lp64 object {
1366 int dummy[sizeof (int) == 4
1367 && sizeof (void *) == 8
1368 && sizeof (long) == 8 ? 1 : -1];
1372 # Return 1 if the target supports long double larger than double,
1375 proc check_effective_target_large_long_double { } {
1376 return [check_no_compiler_messages large_long_double object {
1377 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1381 # Return 1 if the target supports compiling fixed-point,
1384 proc check_effective_target_fixed_point { } {
1385 return [check_no_compiler_messages fixed_point object {
1386 _Sat _Fract x; _Sat _Accum y;
1390 # Return 1 if the target supports compiling decimal floating point,
1393 proc check_effective_target_dfp_nocache { } {
1394 verbose "check_effective_target_dfp_nocache: compiling source" 2
1395 set ret [string match "" [get_compiler_messages dfp 0 object {
1396 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1398 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1402 proc check_effective_target_dfprt_nocache { } {
1407 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1408 # Set up, compile, and execute a test program containing decimal
1410 set src dfprt[pid].c
1411 set exe dfprt[pid].x
1413 set f [open $src "w"]
1414 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1415 puts $f "int main () { z = x + y; return 0; }"
1418 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1419 set lines [${tool}_target_compile $src $exe executable ""]
1422 if [string match "" $lines] then {
1423 # No error message, compilation succeeded.
1424 set result [${tool}_load "./$exe" "" ""]
1425 set status [lindex $result 0]
1426 remote_file build delete $exe
1427 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1428 if { $status == "pass" } then {
1433 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1436 # Return 1 if the target supports compiling Decimal Floating Point,
1439 # This won't change for different subtargets so cache the result.
1441 proc check_effective_target_dfp { } {
1444 if [info exists et_dfp_saved] {
1445 verbose "check_effective_target_dfp: using cached result" 2
1447 set et_dfp_saved [check_effective_target_dfp_nocache]
1449 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1450 return $et_dfp_saved
1453 # Return 1 if the target supports linking and executing Decimal Floating
1454 # Point, # 0 otherwise.
1456 # This won't change for different subtargets so cache the result.
1458 proc check_effective_target_dfprt { } {
1459 global et_dfprt_saved
1462 if [info exists et_dfprt_saved] {
1463 verbose "check_effective_target_dfprt: using cached result" 2
1465 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1467 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1468 return $et_dfprt_saved
1471 # Return 1 if the target needs a command line argument to enable a SIMD
1474 proc check_effective_target_vect_cmdline_needed { } {
1475 global et_vect_cmdline_needed_saved
1476 global et_vect_cmdline_needed_target_name
1478 if { ![info exists et_vect_cmdline_needed_target_name] } {
1479 set et_vect_cmdline_needed_target_name ""
1482 # If the target has changed since we set the cached value, clear it.
1483 set current_target [current_target_name]
1484 if { $current_target != $et_vect_cmdline_needed_target_name } {
1485 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1486 set et_vect_cmdline_needed_target_name $current_target
1487 if { [info exists et_vect_cmdline_needed_saved] } {
1488 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1489 unset et_vect_cmdline_needed_saved
1493 if [info exists et_vect_cmdline_needed_saved] {
1494 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1496 set et_vect_cmdline_needed_saved 1
1497 if { [istarget ia64-*-*]
1498 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1499 && [check_effective_target_lp64])
1500 || ([istarget powerpc*-*-*]
1501 && ([check_effective_target_powerpc_spe]
1502 || [check_effective_target_powerpc_altivec]))} {
1503 set et_vect_cmdline_needed_saved 0
1507 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1508 return $et_vect_cmdline_needed_saved
1511 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1513 # This won't change for different subtargets so cache the result.
1515 proc check_effective_target_vect_int { } {
1516 global et_vect_int_saved
1518 if [info exists et_vect_int_saved] {
1519 verbose "check_effective_target_vect_int: using cached result" 2
1521 set et_vect_int_saved 0
1522 if { [istarget i?86-*-*]
1523 || ([istarget powerpc*-*-*]
1524 && ![istarget powerpc-*-linux*paired*])
1525 || [istarget spu-*-*]
1526 || [istarget x86_64-*-*]
1527 || [istarget sparc*-*-*]
1528 || [istarget alpha*-*-*]
1529 || [istarget ia64-*-*] } {
1530 set et_vect_int_saved 1
1534 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1535 return $et_vect_int_saved
1538 # Return 1 if the target supports int->float conversion
1541 proc check_effective_target_vect_intfloat_cvt { } {
1542 global et_vect_intfloat_cvt_saved
1544 if [info exists et_vect_intfloat_cvt_saved] {
1545 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1547 set et_vect_intfloat_cvt_saved 0
1548 if { [istarget i?86-*-*]
1549 || ([istarget powerpc*-*-*]
1550 && ![istarget powerpc-*-linux*paired*])
1551 || [istarget x86_64-*-*] } {
1552 set et_vect_intfloat_cvt_saved 1
1556 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1557 return $et_vect_intfloat_cvt_saved
1561 # Return 1 if the target supports float->int conversion
1564 proc check_effective_target_vect_floatint_cvt { } {
1565 global et_vect_floatint_cvt_saved
1567 if [info exists et_vect_floatint_cvt_saved] {
1568 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1570 set et_vect_floatint_cvt_saved 0
1571 if { [istarget i?86-*-*]
1572 || [istarget x86_64-*-*] } {
1573 set et_vect_floatint_cvt_saved 1
1577 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1578 return $et_vect_floatint_cvt_saved
1581 # Return 1 is this is an arm target using 32-bit instructions
1582 proc check_effective_target_arm32 { } {
1583 return [check_no_compiler_messages arm32 assembly {
1584 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1590 # Return 1 if this is an ARM target supporting -mfpu=vfp
1591 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1594 proc check_effective_target_arm_vfp_ok { } {
1595 if { [check_effective_target_arm32] } {
1596 return [check_no_compiler_messages arm_vfp_ok object {
1598 } "-mfpu=vfp -mfloat-abi=softfp"]
1604 # Return 1 if this is an ARM target supporting -mfpu=neon
1605 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1608 proc check_effective_target_arm_neon_ok { } {
1609 if { [check_effective_target_arm32] } {
1610 return [check_no_compiler_messages arm_neon_ok object {
1612 } "-mfpu=neon -mfloat-abi=softfp"]
1618 # Return 1 if the target supports executing NEON instructions, 0
1619 # otherwise. Cache the result.
1621 proc check_effective_target_arm_neon_hw { } {
1622 global arm_neon_hw_available_saved
1625 if [info exists arm_neon_hw_available_saved] {
1626 verbose "check_arm_neon_hw_available returning saved $arm_neon_hw_avail
1629 set arm_neon_hw_available_saved 0
1631 # Set up, compile, and execute a test program containing NEON
1632 # instructions. Include the current process ID in the file
1633 # names to prevent conflicts with invocations for multiple
1638 set f [open $src "w"]
1639 puts $f "int main() {"
1640 puts $f " long long a = 0, b = 1;"
1641 puts $f " asm (\"vorr %P0, %P1, %P2\""
1642 puts $f " : \"=w\" (a)"
1643 puts $f " : \"0\" (a), \"w\" (b));"
1644 puts $f " return (a != 1);"
1648 set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1650 verbose "check_arm_neon_hw_available compiling testfile $src" 2
1651 set lines [${tool}_target_compile $src $exe executable "$opts"]
1654 if [string match "" $lines] then {
1655 # No error message, compilation succeeded.
1656 set result [${tool}_load "./$exe" "" ""]
1657 set status [lindex $result 0]
1658 remote_file build delete $exe
1659 verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1661 if { $status == "pass" } then {
1662 set arm_neon_hw_available_saved 1
1665 verbose "check_arm_neon_hw_available testfile compilation failed" 2
1669 return $arm_neon_hw_available_saved
1672 # Return 1 if this is a PowerPC target with floating-point registers.
1674 proc check_effective_target_powerpc_fprs { } {
1675 if { [istarget powerpc*-*-*]
1676 || [istarget rs6000-*-*] } {
1677 return [check_no_compiler_messages powerpc_fprs object {
1689 # Return 1 if this is a PowerPC target supporting -maltivec.
1691 proc check_effective_target_powerpc_altivec_ok { } {
1692 if { ([istarget powerpc*-*-*]
1693 && ![istarget powerpc-*-linux*paired*])
1694 || [istarget rs6000-*-*] } {
1695 # AltiVec is not supported on AIX before 5.3.
1696 if { [istarget powerpc*-*-aix4*]
1697 || [istarget powerpc*-*-aix5.1*]
1698 || [istarget powerpc*-*-aix5.2*] } {
1701 return [check_no_compiler_messages powerpc_altivec_ok object {
1709 # Return 1 if this is a PowerPC target with SPE enabled.
1711 proc check_effective_target_powerpc_spe { } {
1712 if { [istarget powerpc*-*-*] } {
1713 return [check_no_compiler_messages powerpc_spe object {
1725 # Return 1 if this is a PowerPC target with Altivec enabled.
1727 proc check_effective_target_powerpc_altivec { } {
1728 if { [istarget powerpc*-*-*] } {
1729 return [check_no_compiler_messages powerpc_altivec object {
1741 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1742 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1743 # test environment appears to run executables on such a simulator.
1745 proc check_effective_target_ultrasparc_hw { } {
1746 global et_ultrasparc_hw_saved
1749 if [info exists et_ultrasparc_hw_saved] {
1750 verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1752 set et_ultrasparc_hw_saved 0
1754 # Set up, compile, and execute a simple test program. The
1755 # program will be compiled with -mcpu=ultrasparc to instruct the
1756 # assembler to produce EM_SPARC32PLUS executables.
1757 set src svect[pid].c
1758 set exe svect[pid].x
1760 set f [open $src "w"]
1761 puts $f "int main() { return 0; }"
1764 verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1765 set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1768 if [string match "" $lines] then {
1769 # No error message, compilation succeeded.
1770 set result [${tool}_load "./$exe" "" ""]
1771 set status [lindex $result 0]
1772 remote_file build delete $exe
1773 verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1775 if { $status == "pass" } then {
1776 set et_ultrasparc_hw_saved 1
1779 verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1783 return $et_ultrasparc_hw_saved
1786 # Return 1 if the target supports hardware vector shift operation.
1788 proc check_effective_target_vect_shift { } {
1789 global et_vect_shift_saved
1791 if [info exists et_vect_shift_saved] {
1792 verbose "check_effective_target_vect_shift: using cached result" 2
1794 set et_vect_shift_saved 0
1795 if { ([istarget powerpc*-*-*]
1796 && ![istarget powerpc-*-linux*paired*])
1797 || [istarget ia64-*-*]
1798 || [istarget i?86-*-*]
1799 || [istarget x86_64-*-*] } {
1800 set et_vect_shift_saved 1
1804 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1805 return $et_vect_shift_saved
1808 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1810 # This can change for different subtargets so do not cache the result.
1812 proc check_effective_target_vect_long { } {
1813 if { [istarget i?86-*-*]
1814 || (([istarget powerpc*-*-*]
1815 && ![istarget powerpc-*-linux*paired*])
1816 && [check_effective_target_ilp32])
1817 || [istarget x86_64-*-*]
1818 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1824 verbose "check_effective_target_vect_long: returning $answer" 2
1828 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1830 # This won't change for different subtargets so cache the result.
1832 proc check_effective_target_vect_float { } {
1833 global et_vect_float_saved
1835 if [info exists et_vect_float_saved] {
1836 verbose "check_effective_target_vect_float: using cached result" 2
1838 set et_vect_float_saved 0
1839 if { [istarget i?86-*-*]
1840 || [istarget powerpc*-*-*]
1841 || [istarget spu-*-*]
1842 || [istarget mipsisa64*-*-*]
1843 || [istarget x86_64-*-*]
1844 || [istarget ia64-*-*] } {
1845 set et_vect_float_saved 1
1849 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1850 return $et_vect_float_saved
1853 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1855 # This won't change for different subtargets so cache the result.
1857 proc check_effective_target_vect_double { } {
1858 global et_vect_double_saved
1860 if [info exists et_vect_double_saved] {
1861 verbose "check_effective_target_vect_double: using cached result" 2
1863 set et_vect_double_saved 0
1864 if { [istarget i?86-*-*]
1865 || [istarget x86_64-*-*]
1866 || [istarget spu-*-*] } {
1867 set et_vect_double_saved 1
1871 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1872 return $et_vect_double_saved
1875 # Return 1 if the target plus current options does not support a vector
1876 # max instruction on "int", 0 otherwise.
1878 # This won't change for different subtargets so cache the result.
1880 proc check_effective_target_vect_no_int_max { } {
1881 global et_vect_no_int_max_saved
1883 if [info exists et_vect_no_int_max_saved] {
1884 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1886 set et_vect_no_int_max_saved 0
1887 if { [istarget sparc*-*-*]
1888 || [istarget spu-*-*]
1889 || [istarget alpha*-*-*] } {
1890 set et_vect_no_int_max_saved 1
1893 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1894 return $et_vect_no_int_max_saved
1897 # Return 1 if the target plus current options does not support a vector
1898 # add instruction on "int", 0 otherwise.
1900 # This won't change for different subtargets so cache the result.
1902 proc check_effective_target_vect_no_int_add { } {
1903 global et_vect_no_int_add_saved
1905 if [info exists et_vect_no_int_add_saved] {
1906 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1908 set et_vect_no_int_add_saved 0
1909 # Alpha only supports vector add on V8QI and V4HI.
1910 if { [istarget alpha*-*-*] } {
1911 set et_vect_no_int_add_saved 1
1914 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1915 return $et_vect_no_int_add_saved
1918 # Return 1 if the target plus current options does not support vector
1919 # bitwise instructions, 0 otherwise.
1921 # This won't change for different subtargets so cache the result.
1923 proc check_effective_target_vect_no_bitwise { } {
1924 global et_vect_no_bitwise_saved
1926 if [info exists et_vect_no_bitwise_saved] {
1927 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1929 set et_vect_no_bitwise_saved 0
1931 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1932 return $et_vect_no_bitwise_saved
1935 # Return 1 if the target plus current options supports a vector
1936 # widening summation of *short* args into *int* result, 0 otherwise.
1937 # A target can also support this widening summation if it can support
1938 # promotion (unpacking) from shorts to ints.
1940 # This won't change for different subtargets so cache the result.
1942 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1943 global et_vect_widen_sum_hi_to_si
1945 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1946 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1948 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1949 if { [istarget powerpc*-*-*]
1950 || [istarget ia64-*-*] } {
1951 set et_vect_widen_sum_hi_to_si_saved 1
1954 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1955 return $et_vect_widen_sum_hi_to_si_saved
1958 # Return 1 if the target plus current options supports a vector
1959 # widening summation of *char* args into *short* result, 0 otherwise.
1960 # A target can also support this widening summation if it can support
1961 # promotion (unpacking) from chars to shorts.
1963 # This won't change for different subtargets so cache the result.
1965 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1966 global et_vect_widen_sum_qi_to_hi
1968 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1969 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1971 set et_vect_widen_sum_qi_to_hi_saved 0
1972 if { [check_effective_target_vect_unpack]
1973 || [istarget ia64-*-*] } {
1974 set et_vect_widen_sum_qi_to_hi_saved 1
1977 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1978 return $et_vect_widen_sum_qi_to_hi_saved
1981 # Return 1 if the target plus current options supports a vector
1982 # widening summation of *char* args into *int* result, 0 otherwise.
1984 # This won't change for different subtargets so cache the result.
1986 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1987 global et_vect_widen_sum_qi_to_si
1989 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1990 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1992 set et_vect_widen_sum_qi_to_si_saved 0
1993 if { [istarget powerpc*-*-*] } {
1994 set et_vect_widen_sum_qi_to_si_saved 1
1997 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1998 return $et_vect_widen_sum_qi_to_si_saved
2001 # Return 1 if the target plus current options supports a vector
2002 # widening multiplication of *char* args into *short* result, 0 otherwise.
2003 # A target can also support this widening multplication if it can support
2004 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2005 # multiplication of shorts).
2007 # This won't change for different subtargets so cache the result.
2010 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2011 global et_vect_widen_mult_qi_to_hi
2013 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2014 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2016 if { [check_effective_target_vect_unpack]
2017 && [check_effective_target_vect_short_mult] } {
2018 set et_vect_widen_mult_qi_to_hi_saved 1
2020 set et_vect_widen_mult_qi_to_hi_saved 0
2022 if { [istarget powerpc*-*-*] } {
2023 set et_vect_widen_mult_qi_to_hi_saved 1
2026 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2027 return $et_vect_widen_mult_qi_to_hi_saved
2030 # Return 1 if the target plus current options supports a vector
2031 # widening multiplication of *short* args into *int* result, 0 otherwise.
2032 # A target can also support this widening multplication if it can support
2033 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2034 # multiplication of ints).
2036 # This won't change for different subtargets so cache the result.
2039 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2040 global et_vect_widen_mult_hi_to_si
2042 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2043 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2045 if { [check_effective_target_vect_unpack]
2046 && [check_effective_target_vect_int_mult] } {
2047 set et_vect_widen_mult_hi_to_si_saved 1
2049 set et_vect_widen_mult_hi_to_si_saved 0
2051 if { [istarget powerpc*-*-*]
2052 || [istarget spu-*-*]
2053 || [istarget i?86-*-*]
2054 || [istarget x86_64-*-*] } {
2055 set et_vect_widen_mult_hi_to_si_saved 1
2058 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2059 return $et_vect_widen_mult_hi_to_si_saved
2062 # Return 1 if the target plus current options supports a vector
2063 # dot-product of signed chars, 0 otherwise.
2065 # This won't change for different subtargets so cache the result.
2067 proc check_effective_target_vect_sdot_qi { } {
2068 global et_vect_sdot_qi
2070 if [info exists et_vect_sdot_qi_saved] {
2071 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2073 set et_vect_sdot_qi_saved 0
2075 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2076 return $et_vect_sdot_qi_saved
2079 # Return 1 if the target plus current options supports a vector
2080 # dot-product of unsigned chars, 0 otherwise.
2082 # This won't change for different subtargets so cache the result.
2084 proc check_effective_target_vect_udot_qi { } {
2085 global et_vect_udot_qi
2087 if [info exists et_vect_udot_qi_saved] {
2088 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2090 set et_vect_udot_qi_saved 0
2091 if { [istarget powerpc*-*-*] } {
2092 set et_vect_udot_qi_saved 1
2095 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2096 return $et_vect_udot_qi_saved
2099 # Return 1 if the target plus current options supports a vector
2100 # dot-product of signed shorts, 0 otherwise.
2102 # This won't change for different subtargets so cache the result.
2104 proc check_effective_target_vect_sdot_hi { } {
2105 global et_vect_sdot_hi
2107 if [info exists et_vect_sdot_hi_saved] {
2108 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2110 set et_vect_sdot_hi_saved 0
2111 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2112 || [istarget i?86-*-*]
2113 || [istarget x86_64-*-*] } {
2114 set et_vect_sdot_hi_saved 1
2117 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2118 return $et_vect_sdot_hi_saved
2121 # Return 1 if the target plus current options supports a vector
2122 # dot-product of unsigned shorts, 0 otherwise.
2124 # This won't change for different subtargets so cache the result.
2126 proc check_effective_target_vect_udot_hi { } {
2127 global et_vect_udot_hi
2129 if [info exists et_vect_udot_hi_saved] {
2130 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2132 set et_vect_udot_hi_saved 0
2133 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2134 set et_vect_udot_hi_saved 1
2137 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2138 return $et_vect_udot_hi_saved
2142 # Return 1 if the target plus current options supports a vector
2143 # demotion (packing) of shorts (to chars) and ints (to shorts)
2144 # using modulo arithmetic, 0 otherwise.
2146 # This won't change for different subtargets so cache the result.
2148 proc check_effective_target_vect_pack_trunc { } {
2149 global et_vect_pack_trunc
2151 if [info exists et_vect_pack_trunc_saved] {
2152 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2154 set et_vect_pack_trunc_saved 0
2155 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2156 || [istarget i?86-*-*]
2157 || [istarget x86_64-*-*] } {
2158 set et_vect_pack_trunc_saved 1
2161 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2162 return $et_vect_pack_trunc_saved
2165 # Return 1 if the target plus current options supports a vector
2166 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2168 # This won't change for different subtargets so cache the result.
2170 proc check_effective_target_vect_unpack { } {
2171 global et_vect_unpack
2173 if [info exists et_vect_unpack_saved] {
2174 verbose "check_effective_target_vect_unpack: using cached result" 2
2176 set et_vect_unpack_saved 0
2177 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2178 || [istarget i?86-*-*]
2179 || [istarget x86_64-*-*] } {
2180 set et_vect_unpack_saved 1
2183 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2184 return $et_vect_unpack_saved
2187 # Return 1 if the target plus current options does not guarantee
2188 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2190 # This won't change for different subtargets so cache the result.
2192 proc check_effective_target_unaligned_stack { } {
2193 global et_unaligned_stack_saved
2195 if [info exists et_unaligned_stack_saved] {
2196 verbose "check_effective_target_unaligned_stack: using cached result" 2
2198 set et_unaligned_stack_saved 0
2199 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
2200 && (! [istarget *-*-darwin*] ) } {
2201 set et_unaligned_stack_saved 1
2204 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2205 return $et_unaligned_stack_saved
2208 # Return 1 if the target plus current options does not support a vector
2209 # alignment mechanism, 0 otherwise.
2211 # This won't change for different subtargets so cache the result.
2213 proc check_effective_target_vect_no_align { } {
2214 global et_vect_no_align_saved
2216 if [info exists et_vect_no_align_saved] {
2217 verbose "check_effective_target_vect_no_align: using cached result" 2
2219 set et_vect_no_align_saved 0
2220 if { [istarget mipsisa64*-*-*]
2221 || [istarget sparc*-*-*]
2222 || [istarget ia64-*-*] } {
2223 set et_vect_no_align_saved 1
2226 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2227 return $et_vect_no_align_saved
2230 # Return 1 if arrays are aligned to the vector alignment
2231 # boundary, 0 otherwise.
2233 # This won't change for different subtargets so cache the result.
2235 proc check_effective_target_vect_aligned_arrays { } {
2236 global et_vect_aligned_arrays
2238 if [info exists et_vect_aligned_arrays_saved] {
2239 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2241 set et_vect_aligned_arrays_saved 0
2242 if { (([istarget x86_64-*-*]
2243 || [istarget i?86-*-*]) && [is-effective-target lp64])
2244 || [istarget spu-*-*] } {
2245 set et_vect_aligned_arrays_saved 1
2248 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2249 return $et_vect_aligned_arrays_saved
2252 # Return 1 if types of size 32 bit or less are naturally aligned
2253 # (aligned to their type-size), 0 otherwise.
2255 # This won't change for different subtargets so cache the result.
2257 proc check_effective_target_natural_alignment_32 { } {
2258 global et_natural_alignment_32
2260 if [info exists et_natural_alignment_32_saved] {
2261 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2263 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2264 set et_natural_alignment_32_saved 1
2265 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2266 set et_natural_alignment_32_saved 0
2269 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2270 return $et_natural_alignment_32_saved
2273 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2274 # type-size), 0 otherwise.
2276 # This won't change for different subtargets so cache the result.
2278 proc check_effective_target_natural_alignment_64 { } {
2279 global et_natural_alignment_64
2281 if [info exists et_natural_alignment_64_saved] {
2282 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2284 set et_natural_alignment_64_saved 0
2285 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2286 || [istarget spu-*-*] } {
2287 set et_natural_alignment_64_saved 1
2290 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2291 return $et_natural_alignment_64_saved
2294 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2296 # This won't change for different subtargets so cache the result.
2298 proc check_effective_target_vector_alignment_reachable { } {
2299 global et_vector_alignment_reachable
2301 if [info exists et_vector_alignment_reachable_saved] {
2302 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2304 if { [check_effective_target_vect_aligned_arrays]
2305 || [check_effective_target_natural_alignment_32] } {
2306 set et_vector_alignment_reachable_saved 1
2308 set et_vector_alignment_reachable_saved 0
2311 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2312 return $et_vector_alignment_reachable_saved
2315 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2317 # This won't change for different subtargets so cache the result.
2319 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2320 global et_vector_alignment_reachable_for_64bit
2322 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2323 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2325 if { [check_effective_target_vect_aligned_arrays]
2326 || [check_effective_target_natural_alignment_64] } {
2327 set et_vector_alignment_reachable_for_64bit_saved 1
2329 set et_vector_alignment_reachable_for_64bit_saved 0
2332 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2333 return $et_vector_alignment_reachable_for_64bit_saved
2336 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2338 proc check_effective_target_vect_condition { } {
2339 global et_vect_cond_saved
2341 if [info exists et_vect_cond_saved] {
2342 verbose "check_effective_target_vect_cond: using cached result" 2
2344 set et_vect_cond_saved 0
2345 if { [istarget powerpc*-*-*]
2346 || [istarget ia64-*-*]
2347 || [istarget i?86-*-*]
2348 || [istarget spu-*-*]
2349 || [istarget x86_64-*-*] } {
2350 set et_vect_cond_saved 1
2354 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2355 return $et_vect_cond_saved
2358 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2360 proc check_effective_target_vect_char_mult { } {
2361 global et_vect_char_mult_saved
2363 if [info exists et_vect_char_mult_saved] {
2364 verbose "check_effective_target_vect_char_mult: using cached result" 2
2366 set et_vect_char_mult_saved 0
2367 if { [istarget ia64-*-*]
2368 || [istarget i?86-*-*]
2369 || [istarget x86_64-*-*] } {
2370 set et_vect_char_mult_saved 1
2374 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2375 return $et_vect_char_mult_saved
2378 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2380 proc check_effective_target_vect_short_mult { } {
2381 global et_vect_short_mult_saved
2383 if [info exists et_vect_short_mult_saved] {
2384 verbose "check_effective_target_vect_short_mult: using cached result" 2
2386 set et_vect_short_mult_saved 0
2387 if { [istarget ia64-*-*]
2388 || [istarget i?86-*-*]
2389 || [istarget x86_64-*-*] } {
2390 set et_vect_short_mult_saved 1
2394 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2395 return $et_vect_short_mult_saved
2398 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2400 proc check_effective_target_vect_int_mult { } {
2401 global et_vect_int_mult_saved
2403 if [info exists et_vect_int_mult_saved] {
2404 verbose "check_effective_target_vect_int_mult: using cached result" 2
2406 set et_vect_int_mult_saved 0
2407 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2408 || [istarget spu-*-*]
2409 || [istarget i?86-*-*]
2410 || [istarget x86_64-*-*] } {
2411 set et_vect_int_mult_saved 1
2415 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2416 return $et_vect_int_mult_saved
2419 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2421 proc check_effective_target_vect_extract_even_odd { } {
2422 global et_vect_extract_even_odd_saved
2424 if [info exists et_vect_extract_even_odd_saved] {
2425 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2427 set et_vect_extract_even_odd_saved 0
2428 if { [istarget powerpc*-*-*] } {
2429 set et_vect_extract_even_odd_saved 1
2433 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2434 return $et_vect_extract_even_odd_saved
2437 # Return 1 if the target supports vector interleaving, 0 otherwise.
2439 proc check_effective_target_vect_interleave { } {
2440 global et_vect_interleave_saved
2442 if [info exists et_vect_interleave_saved] {
2443 verbose "check_effective_target_vect_interleave: using cached result" 2
2445 set et_vect_interleave_saved 0
2446 if { [istarget powerpc*-*-*]
2447 || [istarget i?86-*-*]
2448 || [istarget x86_64-*-*] } {
2449 set et_vect_interleave_saved 1
2453 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2454 return $et_vect_interleave_saved
2457 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2458 proc check_effective_target_vect_strided { } {
2459 global et_vect_strided_saved
2461 if [info exists et_vect_strided_saved] {
2462 verbose "check_effective_target_vect_strided: using cached result" 2
2464 set et_vect_strided_saved 0
2465 if { [check_effective_target_vect_interleave]
2466 && [check_effective_target_vect_extract_even_odd] } {
2467 set et_vect_strided_saved 1
2471 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2472 return $et_vect_strided_saved
2475 # Return 1 if the target supports section-anchors
2477 proc check_effective_target_section_anchors { } {
2478 global et_section_anchors_saved
2480 if [info exists et_section_anchors_saved] {
2481 verbose "check_effective_target_section_anchors: using cached result" 2
2483 set et_section_anchors_saved 0
2484 if { [istarget powerpc*-*-*] } {
2485 set et_section_anchors_saved 1
2489 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2490 return $et_section_anchors_saved
2493 # Return 1 if the target supports atomic operations on "int" and "long".
2495 proc check_effective_target_sync_int_long { } {
2496 global et_sync_int_long_saved
2498 if [info exists et_sync_int_long_saved] {
2499 verbose "check_effective_target_sync_int_long: using cached result" 2
2501 set et_sync_int_long_saved 0
2502 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2503 # load-reserved/store-conditional instructions.
2504 if { [istarget ia64-*-*]
2505 || [istarget i?86-*-*]
2506 || [istarget x86_64-*-*]
2507 || [istarget alpha*-*-*]
2508 || [istarget s390*-*-*]
2509 || [istarget powerpc*-*-*]
2510 || [istarget sparc64-*-*]
2511 || [istarget sparcv9-*-*] } {
2512 set et_sync_int_long_saved 1
2516 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2517 return $et_sync_int_long_saved
2520 # Return 1 if the target supports atomic operations on "char" and "short".
2522 proc check_effective_target_sync_char_short { } {
2523 global et_sync_char_short_saved
2525 if [info exists et_sync_char_short_saved] {
2526 verbose "check_effective_target_sync_char_short: using cached result" 2
2528 set et_sync_char_short_saved 0
2529 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2530 # load-reserved/store-conditional instructions.
2531 if { [istarget ia64-*-*]
2532 || [istarget i?86-*-*]
2533 || [istarget x86_64-*-*]
2534 || [istarget alpha*-*-*]
2535 || [istarget s390*-*-*]
2536 || [istarget powerpc*-*-*]
2537 || [istarget sparc64-*-*]
2538 || [istarget sparcv9-*-*] } {
2539 set et_sync_char_short_saved 1
2543 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2544 return $et_sync_char_short_saved
2547 # Return 1 if the target uses a ColdFire FPU.
2549 proc check_effective_target_coldfire_fpu { } {
2550 return [check_no_compiler_messages coldfire_fpu assembly {
2557 # Return true if this is a uClibc target.
2559 proc check_effective_target_uclibc {} {
2560 return [check_no_compiler_messages uclibc object {
2561 #include <features.h>
2562 #if !defined (__UCLIBC__)
2568 # Return true if this is a uclibc target and if the uclibc feature
2569 # described by __$feature__ is not present.
2571 proc check_missing_uclibc_feature {feature} {
2572 return [check_no_compiler_messages $feature object "
2573 #include <features.h>
2574 #if !defined (__UCLIBC) || defined (__${feature}__)
2580 # Return true if this is a Newlib target.
2582 proc check_effective_target_newlib {} {
2583 return [check_no_compiler_messages newlib object {
2589 # (a) an error of a few ULP is expected in string to floating-point
2590 # conversion functions; and
2591 # (b) overflow is not always detected correctly by those functions.
2593 proc check_effective_target_lax_strtofp {} {
2594 # By default, assume that all uClibc targets suffer from this.
2595 return [check_effective_target_uclibc]
2598 # Return 1 if this is a target for which wcsftime is a dummy
2599 # function that always returns 0.
2601 proc check_effective_target_dummy_wcsftime {} {
2602 # By default, assume that all uClibc targets suffer from this.
2603 return [check_effective_target_uclibc]
2606 # Return 1 if constructors with initialization priority arguments are
2607 # supposed on this target.
2609 proc check_effective_target_init_priority {} {
2610 return [check_no_compiler_messages init_priority assembly "
2611 void f() __attribute__((constructor (1000)));
2616 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2617 # This can be used with any check_* proc that takes no argument and
2618 # returns only 1 or 0. It could be used with check_* procs that take
2619 # arguments with keywords that pass particular arguments.
2621 proc is-effective-target { arg } {
2623 if { [info procs check_effective_target_${arg}] != [list] } {
2624 set selected [check_effective_target_${arg}]
2627 "vmx_hw" { set selected [check_vmx_hw_available] }
2628 "named_sections" { set selected [check_named_sections_available] }
2629 "gc_sections" { set selected [check_gc_sections_available] }
2630 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2631 default { error "unknown effective target keyword `$arg'" }
2634 verbose "is-effective-target: $arg $selected" 2
2638 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2640 proc is-effective-target-keyword { arg } {
2641 if { [info procs check_effective_target_${arg}] != [list] } {
2644 # These have different names for their check_* procs.
2646 "vmx_hw" { return 1 }
2647 "named_sections" { return 1 }
2648 "gc_sections" { return 1 }
2649 "cxa_atexit" { return 1 }
2650 default { return 0 }
2655 # Return 1 if target default to short enums
2657 proc check_effective_target_short_enums { } {
2658 return [check_no_compiler_messages short_enums assembly {
2660 int s[sizeof (enum foo) == 1 ? 1 : -1];
2664 # Return 1 if target supports merging string constants at link time.
2666 proc check_effective_target_string_merging { } {
2667 return [check_no_messages_and_pattern string_merging \
2668 "rodata\\.str" assembly {
2669 const char *var = "String";
2673 # Return 1 if target has the basic signed and unsigned types in
2674 # <stdint.h>, 0 otherwise.
2676 proc check_effective_target_stdint_types { } {
2677 return [check_no_compiler_messages stdint_types assembly {
2679 int8_t a; int16_t b; int32_t c; int64_t d;
2680 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2684 # Return 1 if programs are intended to be run on a simulator
2685 # (i.e. slowly) rather than hardware (i.e. fast).
2687 proc check_effective_target_simulator { } {
2689 # All "src/sim" simulators set this one.
2690 if [board_info target exists is_simulator] {
2691 return [board_info target is_simulator]
2694 # The "sid" simulators don't set that one, but at least they set
2696 if [board_info target exists slow_simulator] {
2697 return [board_info target slow_simulator]
2703 # Return 1 if the target is a VxWorks RTP.
2705 proc check_effective_target_vxworks_kernel { } {
2706 return [check_no_compiler_messages vxworks_kernel assembly {
2707 #if !defined __vxworks || defined __RTP__
2713 # Return 1 if the target is expected to provide wide character support.
2715 proc check_effective_target_wchar { } {
2716 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2719 return [check_no_compiler_messages wchar assembly {
2724 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2726 proc add_options_for_c99_runtime { flags } {
2727 if { [istarget *-*-solaris2*] } {
2728 return "$flags -std=c99"
2730 if { [istarget powerpc-*-darwin*] } {
2731 return "$flags -mmacosx-version-min=10.3"
2736 # Return 1 if the target provides a full C99 runtime.
2738 proc check_effective_target_c99_runtime { } {
2739 return [check_cached_effective_target c99_runtime {
2742 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2743 set contents [read $file]
2746 #ifndef HAVE_C99_RUNTIME
2750 string match "" [get_compiler_messages c99_runtime 0 assembly \
2751 $contents [add_options_for_c99_runtime ""]]