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 is a 64-bit MIPS target.
620 proc check_effective_target_mips64 { } {
621 return [check_no_compiler_messages mips64 assembly {
628 # Return true if the target is a MIPS target that does not produce
631 proc check_effective_target_nomips16 { } {
632 return [check_no_compiler_messages nomips16 object {
636 /* A cheap way of testing for -mflip-mips16. */
637 void foo (void) { asm ("addiu $20,$20,1"); }
638 void bar (void) { asm ("addiu $20,$20,1"); }
643 # Add the options needed for MIPS16 function attributes. At the moment,
644 # we don't support MIPS16 PIC.
646 proc add_options_for_mips16_attribute { flags } {
647 return "$flags -mno-abicalls -fno-pic"
650 # Return true if we can force a mode that allows MIPS16 code generation.
651 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
654 proc check_effective_target_mips16_attribute { } {
655 return [check_no_compiler_messages mips16_attribute assembly {
659 #if defined __mips_hard_float \
660 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
661 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
664 } [add_options_for_mips16_attribute ""]]
667 # Return 1 if the current multilib does not generate PIC by default.
669 proc check_effective_target_nonpic { } {
670 return [check_no_compiler_messages nonpic assembly {
677 # Return 1 if the target does not use a status wrapper.
679 proc check_effective_target_unwrapped { } {
680 if { [target_info needs_status_wrapper] != "" \
681 && [target_info needs_status_wrapper] != "0" } {
687 # Return true if iconv is supported on the target. In particular IBM1047.
689 proc check_iconv_available { test_what } {
697 verbose "check_iconv_available compiling testfile $src" 2
698 set f [open $src "w"]
699 # Compile a small test program.
700 puts $f "#include <iconv.h>\n"
701 puts $f "int main (void)\n {\n iconv_t cd; \n"
702 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
703 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
704 puts $f "return 0;\n}"
707 # If the tool configuration file has not set libiconv, try "-liconv"
708 if { ![info exists libiconv] } {
709 set libiconv "-liconv"
711 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
714 if [string match "" $lines] then {
715 # No error messages, everything is OK.
717 set result [${tool}_load "./$exe" "" ""]
718 set status [lindex $result 0]
719 remote_file build delete $exe
721 verbose "check_iconv_available status is <$status>" 2
723 if { $status == "pass" } then {
731 # Return true if named sections are supported on this target.
733 proc check_named_sections_available { } {
734 return [check_no_compiler_messages named_sections assembly {
735 int __attribute__ ((section("whatever"))) foo;
739 # Return 1 if the target supports Fortran real kinds larger than real(8),
742 # When the target name changes, replace the cached result.
744 proc check_effective_target_fortran_large_real { } {
745 global et_fortran_large_real_saved
746 global et_fortran_large_real_target_name
749 if { ![info exists et_fortran_large_real_target_name] } {
750 set et_fortran_large_real_target_name ""
753 # If the target has changed since we set the cached value, clear it.
754 set current_target [current_target_name]
755 if { $current_target != $et_fortran_large_real_target_name } {
756 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
757 set et_fortran_large_real_target_name $current_target
758 if [info exists et_fortran_large_real_saved] {
759 verbose "check_effective_target_fortran_large_real: removing cached result" 2
760 unset et_fortran_large_real_saved
764 if [info exists et_fortran_large_real_saved] {
765 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
767 set et_fortran_large_real_saved 0
769 # Set up, compile, and execute a test program using large real
770 # kinds. Include the current process ID in the file names to
771 # prevent conflicts with invocations for multiple testsuites.
772 set src real[pid].f90
775 set f [open $src "w"]
776 puts $f "integer,parameter :: k = &"
777 puts $f " selected_real_kind (precision (0.0_8) + 1)"
778 puts $f "real(kind=k) :: x"
779 puts $f "x = cos (x);"
783 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
784 set lines [${tool}_target_compile $src $exe executable ""]
787 if [string match "" $lines] then {
788 # No error message, compilation succeeded.
789 remote_file build delete $exe
790 set et_fortran_large_real_saved 1
794 return $et_fortran_large_real_saved
797 # Return 1 if the target supports Fortran integer kinds larger than
798 # integer(8), 0 otherwise.
800 # When the target name changes, replace the cached result.
802 proc check_effective_target_fortran_large_int { } {
803 global et_fortran_large_int_saved
804 global et_fortran_large_int_target_name
807 if { ![info exists et_fortran_large_int_target_name] } {
808 set et_fortran_large_int_target_name ""
811 # If the target has changed since we set the cached value, clear it.
812 set current_target [current_target_name]
813 if { $current_target != $et_fortran_large_int_target_name } {
814 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
815 set et_fortran_large_int_target_name $current_target
816 if [info exists et_fortran_large_int_saved] {
817 verbose "check_effective_target_fortran_large_int: removing cached result" 2
818 unset et_fortran_large_int_saved
822 if [info exists et_fortran_large_int_saved] {
823 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
825 set et_fortran_large_int_saved 0
827 # Set up, compile, and execute a test program using large integer
828 # kinds. Include the current process ID in the file names to
829 # prevent conflicts with invocations for multiple testsuites.
833 set f [open $src "w"]
834 puts $f "integer,parameter :: k = &"
835 puts $f " selected_int_kind (range (0_8) + 1)"
836 puts $f "integer(kind=k) :: i"
840 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
841 set lines [${tool}_target_compile $src $exe executable ""]
844 if [string match "" $lines] then {
845 # No error message, compilation succeeded.
846 remote_file build delete $exe
847 set et_fortran_large_int_saved 1
851 return $et_fortran_large_int_saved
854 # Return 1 if we can statically link libgfortran, 0 otherwise.
856 # When the target name changes, replace the cached result.
858 proc check_effective_target_static_libgfortran { } {
859 global et_static_libgfortran
860 global et_static_libgfortran_target_name
863 if { ![info exists et_static_libgfortran_target_name] } {
864 set et_static_libgfortran_target_name ""
867 # If the target has changed since we set the cached value, clear it.
868 set current_target [current_target_name]
869 if { $current_target != $et_static_libgfortran_target_name } {
870 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
871 set et_static_libgfortran_target_name $current_target
872 if [info exists et_static_libgfortran_saved] {
873 verbose "check_effective_target_static_libgfortran: removing cached result" 2
874 unset et_static_libgfortran_saved
878 if [info exists et_static_libgfortran_saved] {
879 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
881 set et_static_libgfortran_saved 0
883 # Set up, compile, and execute a test program using static linking.
884 # Include the current process ID in the file names to prevent
885 # conflicts with invocations for multiple testsuites.
886 set opts "additional_flags=-static"
887 set src static[pid].f
888 set exe static[pid].x
890 set f [open $src "w"]
891 puts $f " print *, 'test'"
895 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
896 set lines [${tool}_target_compile $src $exe executable "$opts"]
899 if [string match "" $lines] then {
900 # No error message, compilation succeeded.
901 remote_file build delete $exe
902 set et_static_libgfortran_saved 1
906 return $et_static_libgfortran_saved
909 # Return 1 if the target supports executing 750CL paired-single instructions, 0
910 # otherwise. Cache the result.
912 proc check_750cl_hw_available { } {
913 global 750cl_hw_available_saved
916 if [info exists 750cl_hw_available_saved] {
917 verbose "check_hw_available returning saved $750cl_hw_available_saved" 2
919 set 750cl_hw_available_saved 0
921 # If this is not the right target then we can quit.
922 if { ![istarget powerpc-*paired*] } {
923 verbose "check_hw_available returning 0" 2
924 return $750cl_hw_available_saved
927 # Set up, compile, and execute a test program containing paired-single
928 # instructions. Include the current process ID in the file
929 # names to prevent conflicts with invocations for multiple
934 set f [open $src "w"]
935 puts $f "int main() {"
936 puts $f "#ifdef __MACH__"
937 puts $f " asm volatile (\"ps_mul v0,v0,v0\");"
939 puts $f " asm volatile (\"ps_mul 0,0,0\");"
941 puts $f " return 0; }"
944 verbose "check_750cl_hw_available compiling testfile $src" 2
945 set lines [${tool}_target_compile $src $exe executable "-mpaired"]
948 if [string match "" $lines] then {
949 # No error message, compilation succeeded.
950 set result [${tool}_load "./$exe" "" ""]
951 set status [lindex $result 0]
952 remote_file build delete $exe
953 verbose "check_750cl_hw_available testfile status is <$status>" 2
955 if { $status == "pass" } then {
956 set 750cl_hw_available_saved 1
959 verbose "check_750cl_hw_availalble testfile compilation failed" 2
962 return $750cl_hw_available_saved
966 # Return 1 if the target supports executing AltiVec instructions, 0
967 # otherwise. Cache the result.
969 proc check_vmx_hw_available { } {
970 global vmx_hw_available_saved
973 if [info exists vmx_hw_available_saved] {
974 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
976 set vmx_hw_available_saved 0
978 # Some simulators are known to not support VMX instructions.
979 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
980 verbose "check_hw_available returning 0" 2
981 return $vmx_hw_available_saved
984 # Set up, compile, and execute a test program containing VMX
985 # instructions. Include the current process ID in the file
986 # names to prevent conflicts with invocations for multiple
991 set f [open $src "w"]
992 puts $f "int main() {"
993 puts $f "#ifdef __MACH__"
994 puts $f " asm volatile (\"vor v0,v0,v0\");"
996 puts $f " asm volatile (\"vor 0,0,0\");"
998 puts $f " return 0; }"
1001 # Most targets don't require special flags for this test case, but
1003 if { [istarget *-*-darwin*]
1004 || [istarget *-*-aix*] } {
1005 set opts "additional_flags=-maltivec"
1010 verbose "check_vmx_hw_available compiling testfile $src" 2
1011 set lines [${tool}_target_compile $src $exe executable "$opts"]
1014 if [string match "" $lines] then {
1015 # No error message, compilation succeeded.
1016 set result [${tool}_load "./$exe" "" ""]
1017 set status [lindex $result 0]
1018 remote_file build delete $exe
1019 verbose "check_vmx_hw_available testfile status is <$status>" 2
1021 if { $status == "pass" } then {
1022 set vmx_hw_available_saved 1
1025 verbose "check_vmx_hw_availalble testfile compilation failed" 2
1029 return $vmx_hw_available_saved
1032 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1033 # complex float arguments. This affects gfortran tests that call cabsf
1034 # in libm built by an earlier compiler. Return 1 if libm uses the same
1035 # argument passing as the compiler under test, 0 otherwise.
1037 # When the target name changes, replace the cached result.
1039 proc check_effective_target_broken_cplxf_arg { } {
1040 global et_broken_cplxf_arg_saved
1041 global et_broken_cplxf_arg_target_name
1044 # Skip the work for targets known not to be affected.
1045 if { ![istarget powerpc64-*-linux*] } {
1047 } elseif { [is-effective-target ilp32] } {
1051 if { ![info exists et_broken_cplxf_arg_target_name] } {
1052 set et_broken_cplxf_arg_target_name ""
1055 # If the target has changed since we set the cached value, clear it.
1056 set current_target [current_target_name]
1057 if { $current_target != $et_broken_cplxf_arg_target_name } {
1058 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
1059 set et_broken_cplxf_arg_target_name $current_target
1060 if [info exists et_broken_cplxf_arg_saved] {
1061 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
1062 unset et_broken_cplxf_arg_saved
1066 if [info exists et_broken_cplxf_arg_saved] {
1067 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
1069 set et_broken_cplxf_arg_saved 0
1070 # This is only known to affect one target.
1071 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
1072 set et_broken_cplxf_arg_saved 0
1073 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
1074 return $et_broken_cplxf_arg_saved
1077 # Set up, compile, and execute a C test program that calls cabsf.
1078 set src cabsf[pid].c
1079 set exe cabsf[pid].x
1081 set f [open $src "w"]
1082 puts $f "#include <complex.h>"
1083 puts $f "extern void abort (void);"
1084 puts $f "float fabsf (float);"
1085 puts $f "float cabsf (_Complex float);"
1086 puts $f "int main ()"
1088 puts $f " _Complex float cf;"
1090 puts $f " cf = 3 + 4.0fi;"
1091 puts $f " f = cabsf (cf);"
1092 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
1093 puts $f " return 0;"
1097 set lines [${tool}_target_compile $src $exe executable "-lm"]
1100 if [string match "" $lines] {
1101 # No error message, compilation succeeded.
1102 set result [${tool}_load "./$exe" "" ""]
1103 set status [lindex $result 0]
1104 remote_file build delete $exe
1106 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1108 if { $status != "pass" } {
1109 set et_broken_cplxf_arg_saved 1
1112 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1115 return $et_broken_cplxf_arg_saved
1118 proc check_alpha_max_hw_available { } {
1119 global alpha_max_hw_available_saved
1122 if [info exists alpha_max_hw_available_saved] {
1123 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1125 set alpha_max_hw_available_saved 0
1127 # Set up, compile, and execute a test program probing bit 8 of the
1128 # architecture mask, which indicates presence of MAX instructions.
1132 set f [open $src "w"]
1133 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1136 verbose "check_alpha_max_hw_available compiling testfile $src" 2
1137 set lines [${tool}_target_compile $src $exe executable ""]
1140 if [string match "" $lines] then {
1141 # No error message, compilation succeeded.
1142 set result [${tool}_load "./$exe" "" ""]
1143 set status [lindex $result 0]
1144 remote_file build delete $exe
1145 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1147 if { $status == "pass" } then {
1148 set alpha_max_hw_available_saved 1
1151 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1155 return $alpha_max_hw_available_saved
1158 # Returns true iff the FUNCTION is available on the target system.
1159 # (This is essentially a Tcl implementation of Autoconf's
1162 proc check_function_available { function } {
1163 set var "${function}_available_saved"
1167 if {![info exists $var]} {
1170 # Check to make sure.
1171 set src "function[pid].c"
1172 set exe "function[pid].exe"
1174 set f [open $src "w"]
1175 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1176 puts $f "char $function ();\n"
1177 puts $f "int main () { $function (); }"
1180 set lines [${tool}_target_compile $src $exe executable ""]
1184 if {![string match "" $lines]} then {
1186 verbose -log "$function is not available"
1188 verbose -log "$function is available"
1195 # Returns true iff "fork" is available on the target system.
1197 proc check_fork_available {} {
1198 return [check_function_available "fork"]
1201 # Returns true iff "mkfifo" is available on the target system.
1203 proc check_mkfifo_available {} {
1204 if {[istarget *-*-cygwin*]} {
1205 # Cygwin has mkfifo, but support is incomplete.
1209 return [check_function_available "mkfifo"]
1212 # Returns true iff "__cxa_atexit" is used on the target system.
1214 proc check_cxa_atexit_available { } {
1215 global et_cxa_atexit
1216 global et_cxa_atexit_target_name
1219 if { ![info exists et_cxa_atexit_target_name] } {
1220 set et_cxa_atexit_target_name ""
1223 # If the target has changed since we set the cached value, clear it.
1224 set current_target [current_target_name]
1225 if { $current_target != $et_cxa_atexit_target_name } {
1226 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1227 set et_cxa_atexit_target_name $current_target
1228 if [info exists et_cxa_atexit] {
1229 verbose "check_cxa_atexit_available: removing cached result" 2
1234 if [info exists et_cxa_atexit] {
1235 verbose "check_cxa_atexit_available: using cached result" 2
1236 } elseif { [istarget "hppa*-*-hpux10*"] } {
1237 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1242 # Set up, compile, and execute a C++ test program that depends
1243 # on correct ordering of static object destructors. This is
1244 # indicative of the presence and use of __cxa_atexit.
1245 set src cxaatexit[pid].cc
1246 set exe cxaatexit[pid].x
1248 set f [open $src "w"]
1249 puts $f "#include <stdlib.h>"
1250 puts $f "static unsigned int count;"
1253 puts $f " X() { count = 1; }"
1256 puts $f " if (count != 3)"
1258 puts $f " count = 4;"
1263 puts $f " static X x;"
1267 puts $f " Y() { f(); count = 2; }"
1270 puts $f " if (count != 2)"
1272 puts $f " count = 3;"
1276 puts $f "int main()"
1277 puts $f "{ return 0; }"
1280 set lines [${tool}_target_compile $src $exe executable ""]
1283 if [string match "" $lines] {
1284 # No error message, compilation succeeded.
1285 set result [${tool}_load "./$exe" "" ""]
1286 set status [lindex $result 0]
1287 remote_file build delete $exe
1289 verbose "check_cxa_atexit_available: status is <$status>" 2
1291 if { $status == "pass" } {
1295 verbose "check_cxa_atexit_available: compilation failed" 2
1298 return $et_cxa_atexit
1302 # Return 1 if we're generating 32-bit code using default options, 0
1305 proc check_effective_target_ilp32 { } {
1306 return [check_no_compiler_messages ilp32 object {
1307 int dummy[sizeof (int) == 4
1308 && sizeof (void *) == 4
1309 && sizeof (long) == 4 ? 1 : -1];
1313 # Return 1 if we're generating 32-bit or larger integers using default
1314 # options, 0 otherwise.
1316 proc check_effective_target_int32plus { } {
1317 return [check_no_compiler_messages int32plus object {
1318 int dummy[sizeof (int) >= 4 ? 1 : -1];
1322 # Return 1 if we're generating 32-bit or larger pointers using default
1323 # options, 0 otherwise.
1325 proc check_effective_target_ptr32plus { } {
1326 return [check_no_compiler_messages ptr32plus object {
1327 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1331 # Return 1 if we support 32-bit or larger array and structure sizes
1332 # using default options, 0 otherwise.
1334 proc check_effective_target_size32plus { } {
1335 return [check_no_compiler_messages size32plus object {
1340 # Returns 1 if we're generating 16-bit or smaller integers with the
1341 # default options, 0 otherwise.
1343 proc check_effective_target_int16 { } {
1344 return [check_no_compiler_messages int16 object {
1345 int dummy[sizeof (int) < 4 ? 1 : -1];
1349 # Return 1 if we're generating 64-bit code using default options, 0
1352 proc check_effective_target_lp64 { } {
1353 return [check_no_compiler_messages lp64 object {
1354 int dummy[sizeof (int) == 4
1355 && sizeof (void *) == 8
1356 && sizeof (long) == 8 ? 1 : -1];
1360 # Return 1 if the target supports long double larger than double,
1363 proc check_effective_target_large_long_double { } {
1364 return [check_no_compiler_messages large_long_double object {
1365 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1369 # Return 1 if the target supports compiling fixed-point,
1372 proc check_effective_target_fixed_point { } {
1373 return [check_no_compiler_messages fixed_point object {
1374 _Sat _Fract x; _Sat _Accum y;
1378 # Return 1 if the target supports compiling decimal floating point,
1381 proc check_effective_target_dfp_nocache { } {
1382 verbose "check_effective_target_dfp_nocache: compiling source" 2
1383 set ret [string match "" [get_compiler_messages dfp 0 object {
1384 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1386 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1390 proc check_effective_target_dfprt_nocache { } {
1395 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1396 # Set up, compile, and execute a test program containing decimal
1398 set src dfprt[pid].c
1399 set exe dfprt[pid].x
1401 set f [open $src "w"]
1402 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1403 puts $f "int main () { z = x + y; return 0; }"
1406 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1407 set lines [${tool}_target_compile $src $exe executable ""]
1410 if [string match "" $lines] then {
1411 # No error message, compilation succeeded.
1412 set result [${tool}_load "./$exe" "" ""]
1413 set status [lindex $result 0]
1414 remote_file build delete $exe
1415 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1416 if { $status == "pass" } then {
1421 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1424 # Return 1 if the target supports compiling Decimal Floating Point,
1427 # This won't change for different subtargets so cache the result.
1429 proc check_effective_target_dfp { } {
1432 if [info exists et_dfp_saved] {
1433 verbose "check_effective_target_dfp: using cached result" 2
1435 set et_dfp_saved [check_effective_target_dfp_nocache]
1437 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1438 return $et_dfp_saved
1441 # Return 1 if the target supports linking and executing Decimal Floating
1442 # Point, # 0 otherwise.
1444 # This won't change for different subtargets so cache the result.
1446 proc check_effective_target_dfprt { } {
1447 global et_dfprt_saved
1450 if [info exists et_dfprt_saved] {
1451 verbose "check_effective_target_dfprt: using cached result" 2
1453 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1455 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1456 return $et_dfprt_saved
1459 # Return 1 if the target needs a command line argument to enable a SIMD
1462 proc check_effective_target_vect_cmdline_needed { } {
1463 global et_vect_cmdline_needed_saved
1464 global et_vect_cmdline_needed_target_name
1466 if { ![info exists et_vect_cmdline_needed_target_name] } {
1467 set et_vect_cmdline_needed_target_name ""
1470 # If the target has changed since we set the cached value, clear it.
1471 set current_target [current_target_name]
1472 if { $current_target != $et_vect_cmdline_needed_target_name } {
1473 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1474 set et_vect_cmdline_needed_target_name $current_target
1475 if { [info exists et_vect_cmdline_needed_saved] } {
1476 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1477 unset et_vect_cmdline_needed_saved
1481 if [info exists et_vect_cmdline_needed_saved] {
1482 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1484 set et_vect_cmdline_needed_saved 1
1485 if { [istarget ia64-*-*]
1486 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1487 && [check_effective_target_lp64])
1488 || ([istarget powerpc*-*-*]
1489 && ([check_effective_target_powerpc_spe]
1490 || [check_effective_target_powerpc_altivec]))} {
1491 set et_vect_cmdline_needed_saved 0
1495 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1496 return $et_vect_cmdline_needed_saved
1499 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1501 # This won't change for different subtargets so cache the result.
1503 proc check_effective_target_vect_int { } {
1504 global et_vect_int_saved
1506 if [info exists et_vect_int_saved] {
1507 verbose "check_effective_target_vect_int: using cached result" 2
1509 set et_vect_int_saved 0
1510 if { [istarget i?86-*-*]
1511 || ([istarget powerpc*-*-*]
1512 && ![istarget powerpc-*-linux*paired*])
1513 || [istarget spu-*-*]
1514 || [istarget x86_64-*-*]
1515 || [istarget sparc*-*-*]
1516 || [istarget alpha*-*-*]
1517 || [istarget ia64-*-*] } {
1518 set et_vect_int_saved 1
1522 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1523 return $et_vect_int_saved
1526 # Return 1 if the target supports int->float conversion
1529 proc check_effective_target_vect_intfloat_cvt { } {
1530 global et_vect_intfloat_cvt_saved
1532 if [info exists et_vect_intfloat_cvt_saved] {
1533 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1535 set et_vect_intfloat_cvt_saved 0
1536 if { [istarget i?86-*-*]
1537 || ([istarget powerpc*-*-*]
1538 && ![istarget powerpc-*-linux*paired*])
1539 || [istarget x86_64-*-*] } {
1540 set et_vect_intfloat_cvt_saved 1
1544 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1545 return $et_vect_intfloat_cvt_saved
1549 # Return 1 if the target supports float->int conversion
1552 proc check_effective_target_vect_floatint_cvt { } {
1553 global et_vect_floatint_cvt_saved
1555 if [info exists et_vect_floatint_cvt_saved] {
1556 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1558 set et_vect_floatint_cvt_saved 0
1559 if { [istarget i?86-*-*]
1560 || [istarget x86_64-*-*] } {
1561 set et_vect_floatint_cvt_saved 1
1565 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1566 return $et_vect_floatint_cvt_saved
1569 # Return 1 is this is an arm target using 32-bit instructions
1570 proc check_effective_target_arm32 { } {
1571 return [check_no_compiler_messages arm32 assembly {
1572 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1578 # Return 1 if this is an ARM target supporting -mfpu=vfp
1579 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1582 proc check_effective_target_arm_vfp_ok { } {
1583 if { [check_effective_target_arm32] } {
1584 return [check_no_compiler_messages arm_vfp_ok object {
1586 } "-mfpu=vfp -mfloat-abi=softfp"]
1592 # Return 1 if this is an ARM target supporting -mfpu=neon
1593 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1596 proc check_effective_target_arm_neon_ok { } {
1597 if { [check_effective_target_arm32] } {
1598 return [check_no_compiler_messages arm_neon_ok object {
1600 } "-mfpu=neon -mfloat-abi=softfp"]
1606 # Return 1 if the target supports executing NEON instructions, 0
1607 # otherwise. Cache the result.
1609 proc check_effective_target_arm_neon_hw { } {
1610 global arm_neon_hw_available_saved
1613 if [info exists arm_neon_hw_available_saved] {
1614 verbose "check_arm_neon_hw_available returning saved $arm_neon_hw_avail
1617 set arm_neon_hw_available_saved 0
1619 # Set up, compile, and execute a test program containing NEON
1620 # instructions. Include the current process ID in the file
1621 # names to prevent conflicts with invocations for multiple
1626 set f [open $src "w"]
1627 puts $f "int main() {"
1628 puts $f " long long a = 0, b = 1;"
1629 puts $f " asm (\"vorr %P0, %P1, %P2\""
1630 puts $f " : \"=w\" (a)"
1631 puts $f " : \"0\" (a), \"w\" (b));"
1632 puts $f " return (a != 1);"
1636 set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1638 verbose "check_arm_neon_hw_available compiling testfile $src" 2
1639 set lines [${tool}_target_compile $src $exe executable "$opts"]
1642 if [string match "" $lines] then {
1643 # No error message, compilation succeeded.
1644 set result [${tool}_load "./$exe" "" ""]
1645 set status [lindex $result 0]
1646 remote_file build delete $exe
1647 verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1649 if { $status == "pass" } then {
1650 set arm_neon_hw_available_saved 1
1653 verbose "check_arm_neon_hw_available testfile compilation failed" 2
1657 return $arm_neon_hw_available_saved
1660 # Return 1 if this is a PowerPC target with floating-point registers.
1662 proc check_effective_target_powerpc_fprs { } {
1663 if { [istarget powerpc*-*-*]
1664 || [istarget rs6000-*-*] } {
1665 return [check_no_compiler_messages powerpc_fprs object {
1677 # Return 1 if this is a PowerPC target supporting -maltivec.
1679 proc check_effective_target_powerpc_altivec_ok { } {
1680 if { ([istarget powerpc*-*-*]
1681 && ![istarget powerpc-*-linux*paired*])
1682 || [istarget rs6000-*-*] } {
1683 # AltiVec is not supported on AIX before 5.3.
1684 if { [istarget powerpc*-*-aix4*]
1685 || [istarget powerpc*-*-aix5.1*]
1686 || [istarget powerpc*-*-aix5.2*] } {
1689 return [check_no_compiler_messages powerpc_altivec_ok object {
1697 # Return 1 if this is a PowerPC target with SPE enabled.
1699 proc check_effective_target_powerpc_spe { } {
1700 if { [istarget powerpc*-*-*] } {
1701 return [check_no_compiler_messages powerpc_spe object {
1713 # Return 1 if this is a PowerPC target with Altivec enabled.
1715 proc check_effective_target_powerpc_altivec { } {
1716 if { [istarget powerpc*-*-*] } {
1717 return [check_no_compiler_messages powerpc_altivec object {
1729 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1730 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1731 # test environment appears to run executables on such a simulator.
1733 proc check_effective_target_ultrasparc_hw { } {
1734 global et_ultrasparc_hw_saved
1737 if [info exists et_ultrasparc_hw_saved] {
1738 verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1740 set et_ultrasparc_hw_saved 0
1742 # Set up, compile, and execute a simple test program. The
1743 # program will be compiled with -mcpu=ultrasparc to instruct the
1744 # assembler to produce EM_SPARC32PLUS executables.
1745 set src svect[pid].c
1746 set exe svect[pid].x
1748 set f [open $src "w"]
1749 puts $f "int main() { return 0; }"
1752 verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1753 set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1756 if [string match "" $lines] then {
1757 # No error message, compilation succeeded.
1758 set result [${tool}_load "./$exe" "" ""]
1759 set status [lindex $result 0]
1760 remote_file build delete $exe
1761 verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1763 if { $status == "pass" } then {
1764 set et_ultrasparc_hw_saved 1
1767 verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1771 return $et_ultrasparc_hw_saved
1774 # Return 1 if the target supports hardware vector shift operation.
1776 proc check_effective_target_vect_shift { } {
1777 global et_vect_shift_saved
1779 if [info exists et_vect_shift_saved] {
1780 verbose "check_effective_target_vect_shift: using cached result" 2
1782 set et_vect_shift_saved 0
1783 if { ([istarget powerpc*-*-*]
1784 && ![istarget powerpc-*-linux*paired*])
1785 || [istarget ia64-*-*]
1786 || [istarget i?86-*-*]
1787 || [istarget x86_64-*-*] } {
1788 set et_vect_shift_saved 1
1792 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1793 return $et_vect_shift_saved
1796 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1798 # This can change for different subtargets so do not cache the result.
1800 proc check_effective_target_vect_long { } {
1801 if { [istarget i?86-*-*]
1802 || (([istarget powerpc*-*-*]
1803 && ![istarget powerpc-*-linux*paired*])
1804 && [check_effective_target_ilp32])
1805 || [istarget x86_64-*-*]
1806 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1812 verbose "check_effective_target_vect_long: returning $answer" 2
1816 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1818 # This won't change for different subtargets so cache the result.
1820 proc check_effective_target_vect_float { } {
1821 global et_vect_float_saved
1823 if [info exists et_vect_float_saved] {
1824 verbose "check_effective_target_vect_float: using cached result" 2
1826 set et_vect_float_saved 0
1827 if { [istarget i?86-*-*]
1828 || [istarget powerpc*-*-*]
1829 || [istarget spu-*-*]
1830 || [istarget mipsisa64*-*-*]
1831 || [istarget x86_64-*-*]
1832 || [istarget ia64-*-*] } {
1833 set et_vect_float_saved 1
1837 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1838 return $et_vect_float_saved
1841 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1843 # This won't change for different subtargets so cache the result.
1845 proc check_effective_target_vect_double { } {
1846 global et_vect_double_saved
1848 if [info exists et_vect_double_saved] {
1849 verbose "check_effective_target_vect_double: using cached result" 2
1851 set et_vect_double_saved 0
1852 if { [istarget i?86-*-*]
1853 || [istarget x86_64-*-*]
1854 || [istarget spu-*-*] } {
1855 set et_vect_double_saved 1
1859 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1860 return $et_vect_double_saved
1863 # Return 1 if the target plus current options does not support a vector
1864 # max instruction on "int", 0 otherwise.
1866 # This won't change for different subtargets so cache the result.
1868 proc check_effective_target_vect_no_int_max { } {
1869 global et_vect_no_int_max_saved
1871 if [info exists et_vect_no_int_max_saved] {
1872 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1874 set et_vect_no_int_max_saved 0
1875 if { [istarget sparc*-*-*]
1876 || [istarget spu-*-*]
1877 || [istarget alpha*-*-*] } {
1878 set et_vect_no_int_max_saved 1
1881 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1882 return $et_vect_no_int_max_saved
1885 # Return 1 if the target plus current options does not support a vector
1886 # add instruction on "int", 0 otherwise.
1888 # This won't change for different subtargets so cache the result.
1890 proc check_effective_target_vect_no_int_add { } {
1891 global et_vect_no_int_add_saved
1893 if [info exists et_vect_no_int_add_saved] {
1894 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1896 set et_vect_no_int_add_saved 0
1897 # Alpha only supports vector add on V8QI and V4HI.
1898 if { [istarget alpha*-*-*] } {
1899 set et_vect_no_int_add_saved 1
1902 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1903 return $et_vect_no_int_add_saved
1906 # Return 1 if the target plus current options does not support vector
1907 # bitwise instructions, 0 otherwise.
1909 # This won't change for different subtargets so cache the result.
1911 proc check_effective_target_vect_no_bitwise { } {
1912 global et_vect_no_bitwise_saved
1914 if [info exists et_vect_no_bitwise_saved] {
1915 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1917 set et_vect_no_bitwise_saved 0
1919 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1920 return $et_vect_no_bitwise_saved
1923 # Return 1 if the target plus current options supports a vector
1924 # widening summation of *short* args into *int* result, 0 otherwise.
1925 # A target can also support this widening summation if it can support
1926 # promotion (unpacking) from shorts to ints.
1928 # This won't change for different subtargets so cache the result.
1930 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1931 global et_vect_widen_sum_hi_to_si
1933 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1934 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1936 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1937 if { [istarget powerpc*-*-*]
1938 || [istarget ia64-*-*] } {
1939 set et_vect_widen_sum_hi_to_si_saved 1
1942 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1943 return $et_vect_widen_sum_hi_to_si_saved
1946 # Return 1 if the target plus current options supports a vector
1947 # widening summation of *char* args into *short* result, 0 otherwise.
1948 # A target can also support this widening summation if it can support
1949 # promotion (unpacking) from chars to shorts.
1951 # This won't change for different subtargets so cache the result.
1953 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1954 global et_vect_widen_sum_qi_to_hi
1956 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1957 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1959 set et_vect_widen_sum_qi_to_hi_saved 0
1960 if { [check_effective_target_vect_unpack]
1961 || [istarget ia64-*-*] } {
1962 set et_vect_widen_sum_qi_to_hi_saved 1
1965 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1966 return $et_vect_widen_sum_qi_to_hi_saved
1969 # Return 1 if the target plus current options supports a vector
1970 # widening summation of *char* args into *int* result, 0 otherwise.
1972 # This won't change for different subtargets so cache the result.
1974 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1975 global et_vect_widen_sum_qi_to_si
1977 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1978 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1980 set et_vect_widen_sum_qi_to_si_saved 0
1981 if { [istarget powerpc*-*-*] } {
1982 set et_vect_widen_sum_qi_to_si_saved 1
1985 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1986 return $et_vect_widen_sum_qi_to_si_saved
1989 # Return 1 if the target plus current options supports a vector
1990 # widening multiplication of *char* args into *short* result, 0 otherwise.
1991 # A target can also support this widening multplication if it can support
1992 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1993 # multiplication of shorts).
1995 # This won't change for different subtargets so cache the result.
1998 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1999 global et_vect_widen_mult_qi_to_hi
2001 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2002 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2004 if { [check_effective_target_vect_unpack]
2005 && [check_effective_target_vect_short_mult] } {
2006 set et_vect_widen_mult_qi_to_hi_saved 1
2008 set et_vect_widen_mult_qi_to_hi_saved 0
2010 if { [istarget powerpc*-*-*] } {
2011 set et_vect_widen_mult_qi_to_hi_saved 1
2014 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2015 return $et_vect_widen_mult_qi_to_hi_saved
2018 # Return 1 if the target plus current options supports a vector
2019 # widening multiplication of *short* args into *int* result, 0 otherwise.
2020 # A target can also support this widening multplication if it can support
2021 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2022 # multiplication of ints).
2024 # This won't change for different subtargets so cache the result.
2027 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2028 global et_vect_widen_mult_hi_to_si
2030 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2031 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2033 if { [check_effective_target_vect_unpack]
2034 && [check_effective_target_vect_int_mult] } {
2035 set et_vect_widen_mult_hi_to_si_saved 1
2037 set et_vect_widen_mult_hi_to_si_saved 0
2039 if { [istarget powerpc*-*-*]
2040 || [istarget spu-*-*]
2041 || [istarget i?86-*-*]
2042 || [istarget x86_64-*-*] } {
2043 set et_vect_widen_mult_hi_to_si_saved 1
2046 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2047 return $et_vect_widen_mult_hi_to_si_saved
2050 # Return 1 if the target plus current options supports a vector
2051 # dot-product of signed chars, 0 otherwise.
2053 # This won't change for different subtargets so cache the result.
2055 proc check_effective_target_vect_sdot_qi { } {
2056 global et_vect_sdot_qi
2058 if [info exists et_vect_sdot_qi_saved] {
2059 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2061 set et_vect_sdot_qi_saved 0
2063 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2064 return $et_vect_sdot_qi_saved
2067 # Return 1 if the target plus current options supports a vector
2068 # dot-product of unsigned chars, 0 otherwise.
2070 # This won't change for different subtargets so cache the result.
2072 proc check_effective_target_vect_udot_qi { } {
2073 global et_vect_udot_qi
2075 if [info exists et_vect_udot_qi_saved] {
2076 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2078 set et_vect_udot_qi_saved 0
2079 if { [istarget powerpc*-*-*] } {
2080 set et_vect_udot_qi_saved 1
2083 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2084 return $et_vect_udot_qi_saved
2087 # Return 1 if the target plus current options supports a vector
2088 # dot-product of signed shorts, 0 otherwise.
2090 # This won't change for different subtargets so cache the result.
2092 proc check_effective_target_vect_sdot_hi { } {
2093 global et_vect_sdot_hi
2095 if [info exists et_vect_sdot_hi_saved] {
2096 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2098 set et_vect_sdot_hi_saved 0
2099 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2100 || [istarget i?86-*-*]
2101 || [istarget x86_64-*-*] } {
2102 set et_vect_sdot_hi_saved 1
2105 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2106 return $et_vect_sdot_hi_saved
2109 # Return 1 if the target plus current options supports a vector
2110 # dot-product of unsigned shorts, 0 otherwise.
2112 # This won't change for different subtargets so cache the result.
2114 proc check_effective_target_vect_udot_hi { } {
2115 global et_vect_udot_hi
2117 if [info exists et_vect_udot_hi_saved] {
2118 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2120 set et_vect_udot_hi_saved 0
2121 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2122 set et_vect_udot_hi_saved 1
2125 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2126 return $et_vect_udot_hi_saved
2130 # Return 1 if the target plus current options supports a vector
2131 # demotion (packing) of shorts (to chars) and ints (to shorts)
2132 # using modulo arithmetic, 0 otherwise.
2134 # This won't change for different subtargets so cache the result.
2136 proc check_effective_target_vect_pack_trunc { } {
2137 global et_vect_pack_trunc
2139 if [info exists et_vect_pack_trunc_saved] {
2140 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2142 set et_vect_pack_trunc_saved 0
2143 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2144 || [istarget i?86-*-*]
2145 || [istarget x86_64-*-*] } {
2146 set et_vect_pack_trunc_saved 1
2149 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2150 return $et_vect_pack_trunc_saved
2153 # Return 1 if the target plus current options supports a vector
2154 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2156 # This won't change for different subtargets so cache the result.
2158 proc check_effective_target_vect_unpack { } {
2159 global et_vect_unpack
2161 if [info exists et_vect_unpack_saved] {
2162 verbose "check_effective_target_vect_unpack: using cached result" 2
2164 set et_vect_unpack_saved 0
2165 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2166 || [istarget i?86-*-*]
2167 || [istarget x86_64-*-*] } {
2168 set et_vect_unpack_saved 1
2171 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2172 return $et_vect_unpack_saved
2175 # Return 1 if the target plus current options does not guarantee
2176 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2178 # This won't change for different subtargets so cache the result.
2180 proc check_effective_target_unaligned_stack { } {
2181 global et_unaligned_stack_saved
2183 if [info exists et_unaligned_stack_saved] {
2184 verbose "check_effective_target_unaligned_stack: using cached result" 2
2186 set et_unaligned_stack_saved 0
2187 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
2188 && (! [istarget *-*-darwin*] ) } {
2189 set et_unaligned_stack_saved 1
2192 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2193 return $et_unaligned_stack_saved
2196 # Return 1 if the target plus current options does not support a vector
2197 # alignment mechanism, 0 otherwise.
2199 # This won't change for different subtargets so cache the result.
2201 proc check_effective_target_vect_no_align { } {
2202 global et_vect_no_align_saved
2204 if [info exists et_vect_no_align_saved] {
2205 verbose "check_effective_target_vect_no_align: using cached result" 2
2207 set et_vect_no_align_saved 0
2208 if { [istarget mipsisa64*-*-*]
2209 || [istarget sparc*-*-*]
2210 || [istarget ia64-*-*] } {
2211 set et_vect_no_align_saved 1
2214 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2215 return $et_vect_no_align_saved
2218 # Return 1 if arrays are aligned to the vector alignment
2219 # boundary, 0 otherwise.
2221 # This won't change for different subtargets so cache the result.
2223 proc check_effective_target_vect_aligned_arrays { } {
2224 global et_vect_aligned_arrays
2226 if [info exists et_vect_aligned_arrays_saved] {
2227 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2229 set et_vect_aligned_arrays_saved 0
2230 if { (([istarget x86_64-*-*]
2231 || [istarget i?86-*-*]) && [is-effective-target lp64])
2232 || [istarget spu-*-*] } {
2233 set et_vect_aligned_arrays_saved 1
2236 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2237 return $et_vect_aligned_arrays_saved
2240 # Return 1 if types of size 32 bit or less are naturally aligned
2241 # (aligned to their type-size), 0 otherwise.
2243 # This won't change for different subtargets so cache the result.
2245 proc check_effective_target_natural_alignment_32 { } {
2246 global et_natural_alignment_32
2248 if [info exists et_natural_alignment_32_saved] {
2249 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2251 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2252 set et_natural_alignment_32_saved 1
2253 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2254 set et_natural_alignment_32_saved 0
2257 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2258 return $et_natural_alignment_32_saved
2261 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2262 # type-size), 0 otherwise.
2264 # This won't change for different subtargets so cache the result.
2266 proc check_effective_target_natural_alignment_64 { } {
2267 global et_natural_alignment_64
2269 if [info exists et_natural_alignment_64_saved] {
2270 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2272 set et_natural_alignment_64_saved 0
2273 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2274 || [istarget spu-*-*] } {
2275 set et_natural_alignment_64_saved 1
2278 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2279 return $et_natural_alignment_64_saved
2282 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2284 # This won't change for different subtargets so cache the result.
2286 proc check_effective_target_vector_alignment_reachable { } {
2287 global et_vector_alignment_reachable
2289 if [info exists et_vector_alignment_reachable_saved] {
2290 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2292 if { [check_effective_target_vect_aligned_arrays]
2293 || [check_effective_target_natural_alignment_32] } {
2294 set et_vector_alignment_reachable_saved 1
2296 set et_vector_alignment_reachable_saved 0
2299 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2300 return $et_vector_alignment_reachable_saved
2303 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2305 # This won't change for different subtargets so cache the result.
2307 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2308 global et_vector_alignment_reachable_for_64bit
2310 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2311 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2313 if { [check_effective_target_vect_aligned_arrays]
2314 || [check_effective_target_natural_alignment_64] } {
2315 set et_vector_alignment_reachable_for_64bit_saved 1
2317 set et_vector_alignment_reachable_for_64bit_saved 0
2320 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2321 return $et_vector_alignment_reachable_for_64bit_saved
2324 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2326 proc check_effective_target_vect_condition { } {
2327 global et_vect_cond_saved
2329 if [info exists et_vect_cond_saved] {
2330 verbose "check_effective_target_vect_cond: using cached result" 2
2332 set et_vect_cond_saved 0
2333 if { [istarget powerpc*-*-*]
2334 || [istarget ia64-*-*]
2335 || [istarget i?86-*-*]
2336 || [istarget spu-*-*]
2337 || [istarget x86_64-*-*] } {
2338 set et_vect_cond_saved 1
2342 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2343 return $et_vect_cond_saved
2346 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2348 proc check_effective_target_vect_char_mult { } {
2349 global et_vect_char_mult_saved
2351 if [info exists et_vect_char_mult_saved] {
2352 verbose "check_effective_target_vect_char_mult: using cached result" 2
2354 set et_vect_char_mult_saved 0
2355 if { [istarget ia64-*-*]
2356 || [istarget i?86-*-*]
2357 || [istarget x86_64-*-*] } {
2358 set et_vect_char_mult_saved 1
2362 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2363 return $et_vect_char_mult_saved
2366 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2368 proc check_effective_target_vect_short_mult { } {
2369 global et_vect_short_mult_saved
2371 if [info exists et_vect_short_mult_saved] {
2372 verbose "check_effective_target_vect_short_mult: using cached result" 2
2374 set et_vect_short_mult_saved 0
2375 if { [istarget ia64-*-*]
2376 || [istarget i?86-*-*]
2377 || [istarget x86_64-*-*] } {
2378 set et_vect_short_mult_saved 1
2382 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2383 return $et_vect_short_mult_saved
2386 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2388 proc check_effective_target_vect_int_mult { } {
2389 global et_vect_int_mult_saved
2391 if [info exists et_vect_int_mult_saved] {
2392 verbose "check_effective_target_vect_int_mult: using cached result" 2
2394 set et_vect_int_mult_saved 0
2395 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2396 || [istarget spu-*-*]
2397 || [istarget i?86-*-*]
2398 || [istarget x86_64-*-*] } {
2399 set et_vect_int_mult_saved 1
2403 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2404 return $et_vect_int_mult_saved
2407 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2409 proc check_effective_target_vect_extract_even_odd { } {
2410 global et_vect_extract_even_odd_saved
2412 if [info exists et_vect_extract_even_odd_saved] {
2413 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2415 set et_vect_extract_even_odd_saved 0
2416 if { [istarget powerpc*-*-*] } {
2417 set et_vect_extract_even_odd_saved 1
2421 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2422 return $et_vect_extract_even_odd_saved
2425 # Return 1 if the target supports vector interleaving, 0 otherwise.
2427 proc check_effective_target_vect_interleave { } {
2428 global et_vect_interleave_saved
2430 if [info exists et_vect_interleave_saved] {
2431 verbose "check_effective_target_vect_interleave: using cached result" 2
2433 set et_vect_interleave_saved 0
2434 if { [istarget powerpc*-*-*]
2435 || [istarget i?86-*-*]
2436 || [istarget x86_64-*-*] } {
2437 set et_vect_interleave_saved 1
2441 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2442 return $et_vect_interleave_saved
2445 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2446 proc check_effective_target_vect_strided { } {
2447 global et_vect_strided_saved
2449 if [info exists et_vect_strided_saved] {
2450 verbose "check_effective_target_vect_strided: using cached result" 2
2452 set et_vect_strided_saved 0
2453 if { [check_effective_target_vect_interleave]
2454 && [check_effective_target_vect_extract_even_odd] } {
2455 set et_vect_strided_saved 1
2459 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2460 return $et_vect_strided_saved
2463 # Return 1 if the target supports section-anchors
2465 proc check_effective_target_section_anchors { } {
2466 global et_section_anchors_saved
2468 if [info exists et_section_anchors_saved] {
2469 verbose "check_effective_target_section_anchors: using cached result" 2
2471 set et_section_anchors_saved 0
2472 if { [istarget powerpc*-*-*] } {
2473 set et_section_anchors_saved 1
2477 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2478 return $et_section_anchors_saved
2481 # Return 1 if the target supports atomic operations on "int" and "long".
2483 proc check_effective_target_sync_int_long { } {
2484 global et_sync_int_long_saved
2486 if [info exists et_sync_int_long_saved] {
2487 verbose "check_effective_target_sync_int_long: using cached result" 2
2489 set et_sync_int_long_saved 0
2490 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2491 # load-reserved/store-conditional instructions.
2492 if { [istarget ia64-*-*]
2493 || [istarget i?86-*-*]
2494 || [istarget x86_64-*-*]
2495 || [istarget alpha*-*-*]
2496 || [istarget s390*-*-*]
2497 || [istarget powerpc*-*-*]
2498 || [istarget sparc64-*-*]
2499 || [istarget sparcv9-*-*] } {
2500 set et_sync_int_long_saved 1
2504 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2505 return $et_sync_int_long_saved
2508 # Return 1 if the target supports atomic operations on "char" and "short".
2510 proc check_effective_target_sync_char_short { } {
2511 global et_sync_char_short_saved
2513 if [info exists et_sync_char_short_saved] {
2514 verbose "check_effective_target_sync_char_short: using cached result" 2
2516 set et_sync_char_short_saved 0
2517 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2518 # load-reserved/store-conditional instructions.
2519 if { [istarget ia64-*-*]
2520 || [istarget i?86-*-*]
2521 || [istarget x86_64-*-*]
2522 || [istarget alpha*-*-*]
2523 || [istarget s390*-*-*]
2524 || [istarget powerpc*-*-*]
2525 || [istarget sparc64-*-*]
2526 || [istarget sparcv9-*-*] } {
2527 set et_sync_char_short_saved 1
2531 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2532 return $et_sync_char_short_saved
2535 # Return 1 if the target uses a ColdFire FPU.
2537 proc check_effective_target_coldfire_fpu { } {
2538 return [check_no_compiler_messages coldfire_fpu assembly {
2545 # Return true if this is a uClibc target.
2547 proc check_effective_target_uclibc {} {
2548 return [check_no_compiler_messages uclibc object {
2549 #include <features.h>
2550 #if !defined (__UCLIBC__)
2556 # Return true if this is a uclibc target and if the uclibc feature
2557 # described by __$feature__ is not present.
2559 proc check_missing_uclibc_feature {feature} {
2560 return [check_no_compiler_messages $feature object "
2561 #include <features.h>
2562 #if !defined (__UCLIBC) || defined (__${feature}__)
2568 # Return true if this is a Newlib target.
2570 proc check_effective_target_newlib {} {
2571 return [check_no_compiler_messages newlib object {
2577 # (a) an error of a few ULP is expected in string to floating-point
2578 # conversion functions; and
2579 # (b) overflow is not always detected correctly by those functions.
2581 proc check_effective_target_lax_strtofp {} {
2582 # By default, assume that all uClibc targets suffer from this.
2583 return [check_effective_target_uclibc]
2586 # Return 1 if this is a target for which wcsftime is a dummy
2587 # function that always returns 0.
2589 proc check_effective_target_dummy_wcsftime {} {
2590 # By default, assume that all uClibc targets suffer from this.
2591 return [check_effective_target_uclibc]
2594 # Return 1 if constructors with initialization priority arguments are
2595 # supposed on this target.
2597 proc check_effective_target_init_priority {} {
2598 return [check_no_compiler_messages init_priority assembly "
2599 void f() __attribute__((constructor (1000)));
2604 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2605 # This can be used with any check_* proc that takes no argument and
2606 # returns only 1 or 0. It could be used with check_* procs that take
2607 # arguments with keywords that pass particular arguments.
2609 proc is-effective-target { arg } {
2611 if { [info procs check_effective_target_${arg}] != [list] } {
2612 set selected [check_effective_target_${arg}]
2615 "vmx_hw" { set selected [check_vmx_hw_available] }
2616 "named_sections" { set selected [check_named_sections_available] }
2617 "gc_sections" { set selected [check_gc_sections_available] }
2618 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2619 default { error "unknown effective target keyword `$arg'" }
2622 verbose "is-effective-target: $arg $selected" 2
2626 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2628 proc is-effective-target-keyword { arg } {
2629 if { [info procs check_effective_target_${arg}] != [list] } {
2632 # These have different names for their check_* procs.
2634 "vmx_hw" { return 1 }
2635 "named_sections" { return 1 }
2636 "gc_sections" { return 1 }
2637 "cxa_atexit" { return 1 }
2638 default { return 0 }
2643 # Return 1 if target default to short enums
2645 proc check_effective_target_short_enums { } {
2646 return [check_no_compiler_messages short_enums assembly {
2648 int s[sizeof (enum foo) == 1 ? 1 : -1];
2652 # Return 1 if target supports merging string constants at link time.
2654 proc check_effective_target_string_merging { } {
2655 return [check_no_messages_and_pattern string_merging \
2656 "rodata\\.str" assembly {
2657 const char *var = "String";
2661 # Return 1 if target has the basic signed and unsigned types in
2662 # <stdint.h>, 0 otherwise.
2664 proc check_effective_target_stdint_types { } {
2665 return [check_no_compiler_messages stdint_types assembly {
2667 int8_t a; int16_t b; int32_t c; int64_t d;
2668 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2672 # Return 1 if programs are intended to be run on a simulator
2673 # (i.e. slowly) rather than hardware (i.e. fast).
2675 proc check_effective_target_simulator { } {
2677 # All "src/sim" simulators set this one.
2678 if [board_info target exists is_simulator] {
2679 return [board_info target is_simulator]
2682 # The "sid" simulators don't set that one, but at least they set
2684 if [board_info target exists slow_simulator] {
2685 return [board_info target slow_simulator]
2691 # Return 1 if the target is a VxWorks RTP.
2693 proc check_effective_target_vxworks_kernel { } {
2694 return [check_no_compiler_messages vxworks_kernel assembly {
2695 #if !defined __vxworks || defined __RTP__
2701 # Return 1 if the target is expected to provide wide character support.
2703 proc check_effective_target_wchar { } {
2704 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2707 return [check_no_compiler_messages wchar assembly {
2712 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2714 proc add_options_for_c99_runtime { flags } {
2715 if { [istarget *-*-solaris2*] } {
2716 return "$flags -std=c99"
2718 if { [istarget powerpc-*-darwin*] } {
2719 return "$flags -mmacosx-version-min=10.3"
2724 # Return 1 if the target provides a full C99 runtime.
2726 proc check_effective_target_c99_runtime { } {
2727 return [check_cached_effective_target c99_runtime {
2730 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2731 set contents [read $file]
2734 #ifndef HAVE_C99_RUNTIME
2738 string match "" [get_compiler_messages c99_runtime 0 assembly \
2739 $contents [add_options_for_c99_runtime ""]]