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 the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code. C++ code should contain
33 # "// C++" and Fortran code should contain "! Fortran".
34 proc check_compile {basename type contents args} {
37 if { [llength $args] > 0 } {
38 set options [list "additional_flags=[lindex $args 0]"]
42 switch -glob -- $contents {
43 "*! Fortran*" { set src ${basename}[pid].f90 }
44 "*// C++*" { set src ${basename}[pid].cc }
45 default { set src ${basename}[pid].c }
47 set compile_type $type
49 assembly { set output ${basename}[pid].s }
50 object { set output ${basename}[pid].o }
51 executable { set output ${basename}[pid].exe }
53 set output ${basename}[pid].s
54 lappend options "additional_flags=-fdump-$type"
55 set compile_type assembly
61 set lines [${tool}_target_compile $src $output $compile_type "$options"]
64 set scan_output $output
65 # Don't try folding this into the switch above; calling "glob" before the
66 # file is created won't work.
67 if [regexp "rtl-(.*)" $type dummy rtl_type] {
68 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
72 return [list $lines $scan_output]
75 proc current_target_name { } {
77 if [info exists target_info(target,name)] {
78 set answer $target_info(target,name)
85 # Implement an effective-target check for property PROP by invoking
86 # the Tcl command ARGS and seeing if it returns true.
88 proc check_cached_effective_target { prop args } {
91 set target [current_target_name]
92 if {![info exists et_cache($prop,target)]
93 || $et_cache($prop,target) != $target} {
94 verbose "check_cached_effective_target $prop: checking $target" 2
95 set et_cache($prop,target) $target
96 set et_cache($prop,value) [uplevel eval $args]
98 set value $et_cache($prop,value)
99 verbose "check_cached_effective_target $prop: returning $value for $target" 2
103 # Like check_compile, but delete the output file and return true if the
104 # compiler printed no messages.
105 proc check_no_compiler_messages_nocache {args} {
106 set result [eval check_compile $args]
107 set lines [lindex $result 0]
108 set output [lindex $result 1]
109 remote_file build delete $output
110 return [string match "" $lines]
113 # Like check_no_compiler_messages_nocache, but cache the result.
114 # PROP is the property we're checking, and doubles as a prefix for
115 # temporary filenames.
116 proc check_no_compiler_messages {prop args} {
117 return [check_cached_effective_target $prop {
118 eval [list check_no_compiler_messages_nocache $prop] $args
122 # Like check_compile, but return true if the compiler printed no
123 # messages and if the contents of the output file satisfy PATTERN.
124 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
125 # don't match regular expression REGEXP, otherwise they satisfy it
126 # if they do match regular expression PATTERN. (PATTERN can start
127 # with something like "[!]" if the regular expression needs to match
128 # "!" as the first character.)
130 # Delete the output file before returning. The other arguments are
131 # as for check_compile.
132 proc check_no_messages_and_pattern_nocache {basename pattern args} {
135 set result [eval [list check_compile $basename] $args]
136 set lines [lindex $result 0]
137 set output [lindex $result 1]
140 if { [string match "" $lines] } {
141 set chan [open "$output"]
142 set invert [regexp {^!(.*)} $pattern dummy pattern]
143 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
147 remote_file build delete $output
151 # Like check_no_messages_and_pattern_nocache, but cache the result.
152 # PROP is the property we're checking, and doubles as a prefix for
153 # temporary filenames.
154 proc check_no_messages_and_pattern {prop pattern args} {
155 return [check_cached_effective_target $prop {
156 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
160 # Try to compile and run an executable from code CONTENTS. Return true
161 # if the compiler reports no messages and if execution "passes" in the
162 # usual DejaGNU sense. The arguments are as for check_compile, with
163 # TYPE implicitly being "executable".
164 proc check_runtime_nocache {basename contents args} {
167 set result [eval [list check_compile $basename executable $contents] $args]
168 set lines [lindex $result 0]
169 set output [lindex $result 1]
172 if { [string match "" $lines] } {
173 # No error messages, everything is OK.
174 set result [remote_load target "./$output" "" ""]
175 set status [lindex $result 0]
176 verbose "check_runtime_nocache $basename: status is <$status>" 2
177 if { $status == "pass" } {
181 remote_file build delete $output
185 # Like check_runtime_nocache, but cache the result. PROP is the
186 # property we're checking, and doubles as a prefix for temporary
188 proc check_runtime {prop args} {
191 return [check_cached_effective_target $prop {
192 eval [list check_runtime_nocache $prop] $args
196 ###############################
197 # proc check_weak_available { }
198 ###############################
200 # weak symbols are only supported in some configs/object formats
201 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
203 proc check_weak_available { } {
204 global target_triplet
207 # All mips targets should support it
209 if { [ string first "mips" $target_cpu ] >= 0 } {
213 # All solaris2 targets should support it
215 if { [regexp ".*-solaris2.*" $target_triplet] } {
219 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
221 if { [regexp "alpha.*osf.*" $target_triplet] } {
225 # Windows targets Cygwin and MingW32 support it
227 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
231 # HP-UX 10.X doesn't support it
233 if { [istarget "hppa*-*-hpux10*"] } {
237 # ELF and ECOFF support it. a.out does with gas/gld but may also with
238 # other linkers, so we should try it
240 set objformat [gcc_target_object_format]
248 unknown { return -1 }
253 ###############################
254 # proc check_visibility_available { what_kind }
255 ###############################
257 # The visibility attribute is only support in some object formats
258 # This proc returns 1 if it is supported, 0 if not.
259 # The argument is the kind of visibility, default/protected/hidden/internal.
261 proc check_visibility_available { what_kind } {
263 global target_triplet
265 # On NetWare, support makes no sense.
266 if { [istarget *-*-netware*] } {
270 if [string match "" $what_kind] { set what_kind "hidden" }
272 return [check_no_compiler_messages visibility_available_$what_kind object "
273 void f() __attribute__((visibility(\"$what_kind\")));
278 ###############################
279 # proc check_alias_available { }
280 ###############################
282 # Determine if the target toolchain supports the alias attribute.
284 # Returns 2 if the target supports aliases. Returns 1 if the target
285 # only supports weak aliased. Returns 0 if the target does not
286 # support aliases at all. Returns -1 if support for aliases could not
289 proc check_alias_available { } {
290 global alias_available_saved
293 if [info exists alias_available_saved] {
294 verbose "check_alias_available returning saved $alias_available_saved" 2
298 verbose "check_alias_available compiling testfile $src" 2
299 set f [open $src "w"]
300 # Compile a small test program. The definition of "g" is
301 # necessary to keep the Solaris assembler from complaining
303 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
304 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
306 set lines [${tool}_target_compile $src $obj object ""]
308 remote_file build delete $obj
310 if [string match "" $lines] then {
311 # No error messages, everything is OK.
312 set alias_available_saved 2
314 if [regexp "alias definitions not supported" $lines] {
315 verbose "check_alias_available target does not support aliases" 2
317 set objformat [gcc_target_object_format]
319 if { $objformat == "elf" } {
320 verbose "check_alias_available but target uses ELF format, so it ought to" 2
321 set alias_available_saved -1
323 set alias_available_saved 0
326 if [regexp "only weak aliases are supported" $lines] {
327 verbose "check_alias_available target supports only weak aliases" 2
328 set alias_available_saved 1
330 set alias_available_saved -1
335 verbose "check_alias_available returning $alias_available_saved" 2
338 return $alias_available_saved
341 # Returns true if --gc-sections is supported on the target.
343 proc check_gc_sections_available { } {
344 global gc_sections_available_saved
347 if {![info exists gc_sections_available_saved]} {
348 # Some targets don't support gc-sections despite whatever's
349 # advertised by ld's options.
350 if { [istarget alpha*-*-*]
351 || [istarget ia64-*-*] } {
352 set gc_sections_available_saved 0
356 # elf2flt uses -q (--emit-relocs), which is incompatible with
358 if { [board_info target exists ldflags]
359 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
360 set gc_sections_available_saved 0
364 # VxWorks kernel modules are relocatable objects linked with -r,
365 # while RTP executables are linked with -q (--emit-relocs).
366 # Both of these options are incompatible with --gc-sections.
367 if { [istarget *-*-vxworks*] } {
368 set gc_sections_available_saved 0
372 # Check if the ld used by gcc supports --gc-sections.
373 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
374 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
375 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
376 set ld_output [remote_exec host "$gcc_ld" "--help"]
377 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
378 set gc_sections_available_saved 1
380 set gc_sections_available_saved 0
383 return $gc_sections_available_saved
386 # Return true if profiling is supported on the target.
388 proc check_profiling_available { test_what } {
389 global profiling_available_saved
391 verbose "Profiling argument is <$test_what>" 1
393 # These conditions depend on the argument so examine them before
394 # looking at the cache variable.
396 # Support for -p on solaris2 relies on mcrt1.o which comes with the
397 # vendor compiler. We cannot reliably predict the directory where the
398 # vendor compiler (and thus mcrt1.o) is installed so we can't
399 # necessarily find mcrt1.o even if we have it.
400 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
404 # Support for -p on irix relies on libprof1.a which doesn't appear to
405 # exist on any irix6 system currently posting testsuite results.
406 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
407 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
408 if { [istarget mips*-*-irix*]
409 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
413 # MinGW does not support -p.
414 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
418 # At present, there is no profiling support on NetWare.
419 if { [istarget *-*-netware*] } {
423 # uClibc does not have gcrt1.o.
424 if { [check_effective_target_uclibc]
425 && ([lindex $test_what 1] == "-p"
426 || [lindex $test_what 1] == "-pg") } {
430 # Now examine the cache variable.
431 if {![info exists profiling_available_saved]} {
432 # Some targets don't have any implementation of __bb_init_func or are
433 # missing other needed machinery.
434 if { [istarget mmix-*-*]
435 || [istarget arm*-*-eabi*]
436 || [istarget arm*-*-elf]
437 || [istarget arm*-*-symbianelf*]
438 || [istarget bfin-*-*]
439 || [istarget powerpc-*-eabi*]
440 || [istarget strongarm*-*-elf]
441 || [istarget xscale*-*-elf]
442 || [istarget cris-*-*]
443 || [istarget crisv32-*-*]
444 || [istarget fido-*-elf]
445 || [istarget h8300-*-*]
446 || [istarget m32c-*-elf]
447 || [istarget m68k-*-elf]
448 || [istarget m68k-*-uclinux*]
449 || [istarget mips*-*-elf*]
450 || [istarget xstormy16-*]
451 || [istarget xtensa-*-elf]
452 || [istarget *-*-vxworks*]
453 || [istarget *-*-windiss] } {
454 set profiling_available_saved 0
456 set profiling_available_saved 1
460 return $profiling_available_saved
463 # Return 1 if target has packed layout of structure members by
464 # default, 0 otherwise. Note that this is slightly different than
465 # whether the target has "natural alignment": both attributes may be
468 proc check_effective_target_default_packed { } {
469 return [check_no_compiler_messages default_packed assembly {
470 struct x { char a; long b; } c;
471 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
475 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
476 # documentation, where the test also comes from.
478 proc check_effective_target_pcc_bitfield_type_matters { } {
479 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
480 # bitfields, but let's stick to the example code from the docs.
481 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
482 struct foo1 { char x; char :0; char y; };
483 struct foo2 { char x; int :0; char y; };
484 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
488 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
490 # This won't change for different subtargets so cache the result.
492 proc check_effective_target_tls {} {
493 return [check_no_compiler_messages tls assembly {
495 int f (void) { return i; }
496 void g (int j) { i = j; }
500 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
502 # This won't change for different subtargets so cache the result.
504 proc check_effective_target_tls_native {} {
505 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
507 int f (void) { return i; }
508 void g (int j) { i = j; }
512 # Return 1 if TLS executables can run correctly, 0 otherwise.
514 # This won't change for different subtargets so cache the result.
516 proc check_effective_target_tls_runtime {} {
517 return [check_runtime tls_runtime {
518 __thread int thr = 0;
519 int main (void) { return thr; }
523 # Return 1 if compilation with -fopenmp is error-free for trivial
526 proc check_effective_target_fopenmp {} {
527 return [check_no_compiler_messages fopenmp object {
532 # Return 1 if compilation with -pthread is error-free for trivial
535 proc check_effective_target_pthread {} {
536 return [check_no_compiler_messages pthread object {
541 # Return 1 if the target supports -fstack-protector
542 proc check_effective_target_fstack_protector {} {
543 return [check_runtime fstack_protector {
544 int main (void) { return 0; }
545 } "-fstack-protector"]
548 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
549 # for trivial code, 0 otherwise.
551 proc check_effective_target_freorder {} {
552 return [check_no_compiler_messages freorder object {
554 } "-freorder-blocks-and-partition"]
557 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
558 # emitted, 0 otherwise. Whether a shared library can actually be built is
559 # out of scope for this test.
561 proc check_effective_target_fpic { } {
562 # Note that M68K has a multilib that supports -fpic but not
563 # -fPIC, so we need to check both. We test with a program that
564 # requires GOT references.
565 foreach arg {fpic fPIC} {
566 if [check_no_compiler_messages $arg object {
567 extern int foo (void); extern int bar;
568 int baz (void) { return foo () + bar; }
576 # Return true if the target supports -mpaired-single (as used on MIPS).
578 proc check_effective_target_mpaired_single { } {
579 return [check_no_compiler_messages mpaired_single object {
584 # Return true if the target has access to FPU instructions.
586 proc check_effective_target_hard_float { } {
587 if { [istarget mips*-*-*] } {
588 return [check_no_compiler_messages hard_float assembly {
589 #if (defined __mips_soft_float || defined __mips16)
595 # The generic test equates hard_float with "no call for adding doubles".
596 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
597 double a (double b, double c) { return b + c; }
601 # Return true if the target is a 64-bit MIPS target.
603 proc check_effective_target_mips64 { } {
604 return [check_no_compiler_messages mips64 assembly {
611 # Return true if the target is a MIPS target that does not produce
614 proc check_effective_target_nomips16 { } {
615 return [check_no_compiler_messages nomips16 object {
619 /* A cheap way of testing for -mflip-mips16. */
620 void foo (void) { asm ("addiu $20,$20,1"); }
621 void bar (void) { asm ("addiu $20,$20,1"); }
626 # Add the options needed for MIPS16 function attributes. At the moment,
627 # we don't support MIPS16 PIC.
629 proc add_options_for_mips16_attribute { flags } {
630 return "$flags -mno-abicalls -fno-pic"
633 # Return true if we can force a mode that allows MIPS16 code generation.
634 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
637 proc check_effective_target_mips16_attribute { } {
638 return [check_no_compiler_messages mips16_attribute assembly {
642 #if defined __mips_hard_float \
643 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
644 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
647 } [add_options_for_mips16_attribute ""]]
650 # Return 1 if the current multilib does not generate PIC by default.
652 proc check_effective_target_nonpic { } {
653 return [check_no_compiler_messages nonpic assembly {
660 # Return 1 if the target does not use a status wrapper.
662 proc check_effective_target_unwrapped { } {
663 if { [target_info needs_status_wrapper] != "" \
664 && [target_info needs_status_wrapper] != "0" } {
670 # Return true if iconv is supported on the target. In particular IBM1047.
672 proc check_iconv_available { test_what } {
675 # If the tool configuration file has not set libiconv, try "-liconv"
676 if { ![info exists libiconv] } {
677 set libiconv "-liconv"
679 set test_what [lindex $test_what 1]
680 return [check_runtime_nocache $test_what [subst {
686 cd = iconv_open ("$test_what", "UTF-8");
687 if (cd == (iconv_t) -1)
694 # Return true if named sections are supported on this target.
696 proc check_named_sections_available { } {
697 return [check_no_compiler_messages named_sections assembly {
698 int __attribute__ ((section("whatever"))) foo;
702 # Return 1 if the target supports Fortran real kinds larger than real(8),
705 # When the target name changes, replace the cached result.
707 proc check_effective_target_fortran_large_real { } {
708 return [check_no_compiler_messages fortran_large_real executable {
710 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
717 # Return 1 if the target supports Fortran integer kinds larger than
718 # integer(8), 0 otherwise.
720 # When the target name changes, replace the cached result.
722 proc check_effective_target_fortran_large_int { } {
723 return [check_no_compiler_messages fortran_large_int executable {
725 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
731 # Return 1 if we can statically link libgfortran, 0 otherwise.
733 # When the target name changes, replace the cached result.
735 proc check_effective_target_static_libgfortran { } {
736 return [check_no_compiler_messages static_libgfortran executable {
743 # Return 1 if the target supports executing 750CL paired-single instructions, 0
744 # otherwise. Cache the result.
746 proc check_750cl_hw_available { } {
747 return [check_cached_effective_target 750cl_hw_available {
748 # If this is not the right target then we can skip the test.
749 if { ![istarget powerpc-*paired*] } {
752 check_runtime_nocache 750cl_hw_available {
756 asm volatile ("ps_mul v0,v0,v0");
758 asm volatile ("ps_mul 0,0,0");
767 # Return 1 if the target supports executing AltiVec instructions, 0
768 # otherwise. Cache the result.
770 proc check_vmx_hw_available { } {
771 return [check_cached_effective_target vmx_hw_available {
772 # Some simulators are known to not support VMX instructions.
773 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
776 # Most targets don't require special flags for this test case, but
778 if { [istarget *-*-darwin*]
779 || [istarget *-*-aix*] } {
780 set options "-maltivec"
784 check_runtime_nocache vmx_hw_available {
788 asm volatile ("vor v0,v0,v0");
790 asm volatile ("vor 0,0,0");
799 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
800 # complex float arguments. This affects gfortran tests that call cabsf
801 # in libm built by an earlier compiler. Return 1 if libm uses the same
802 # argument passing as the compiler under test, 0 otherwise.
804 # When the target name changes, replace the cached result.
806 proc check_effective_target_broken_cplxf_arg { } {
807 return [check_cached_effective_target broken_cplxf_arg {
808 # Skip the work for targets known not to be affected.
809 if { ![istarget powerpc64-*-linux*] } {
811 } elseif { ![is-effective-target lp64] } {
814 check_runtime_nocache broken_cplxf_arg {
816 extern void abort (void);
818 float cabsf (_Complex float);
825 if (fabsf (f - 5.0) > 0.0001)
834 proc check_alpha_max_hw_available { } {
835 return [check_runtime alpha_max_hw_available {
836 int main() { return __builtin_alpha_amask(1<<8) != 0; }
840 # Returns true iff the FUNCTION is available on the target system.
841 # (This is essentially a Tcl implementation of Autoconf's
844 proc check_function_available { function } {
845 return [check_no_compiler_messages ${function}_available \
851 int main () { $function (); }
855 # Returns true iff "fork" is available on the target system.
857 proc check_fork_available {} {
858 return [check_function_available "fork"]
861 # Returns true iff "mkfifo" is available on the target system.
863 proc check_mkfifo_available {} {
864 if {[istarget *-*-cygwin*]} {
865 # Cygwin has mkfifo, but support is incomplete.
869 return [check_function_available "mkfifo"]
872 # Returns true iff "__cxa_atexit" is used on the target system.
874 proc check_cxa_atexit_available { } {
875 return [check_cached_effective_target cxa_atexit_available {
876 if { [istarget "hppa*-*-hpux10*"] } {
877 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
880 check_runtime_nocache cxa_atexit_available {
883 static unsigned int count;
900 Y() { f(); count = 2; }
909 int main() { return 0; }
916 # Return 1 if we're generating 32-bit code using default options, 0
919 proc check_effective_target_ilp32 { } {
920 return [check_no_compiler_messages ilp32 object {
921 int dummy[sizeof (int) == 4
922 && sizeof (void *) == 4
923 && sizeof (long) == 4 ? 1 : -1];
927 # Return 1 if we're generating 32-bit or larger integers using default
928 # options, 0 otherwise.
930 proc check_effective_target_int32plus { } {
931 return [check_no_compiler_messages int32plus object {
932 int dummy[sizeof (int) >= 4 ? 1 : -1];
936 # Return 1 if we're generating 32-bit or larger pointers using default
937 # options, 0 otherwise.
939 proc check_effective_target_ptr32plus { } {
940 return [check_no_compiler_messages ptr32plus object {
941 int dummy[sizeof (void *) >= 4 ? 1 : -1];
945 # Return 1 if we support 32-bit or larger array and structure sizes
946 # using default options, 0 otherwise.
948 proc check_effective_target_size32plus { } {
949 return [check_no_compiler_messages size32plus object {
954 # Returns 1 if we're generating 16-bit or smaller integers with the
955 # default options, 0 otherwise.
957 proc check_effective_target_int16 { } {
958 return [check_no_compiler_messages int16 object {
959 int dummy[sizeof (int) < 4 ? 1 : -1];
963 # Return 1 if we're generating 64-bit code using default options, 0
966 proc check_effective_target_lp64 { } {
967 return [check_no_compiler_messages lp64 object {
968 int dummy[sizeof (int) == 4
969 && sizeof (void *) == 8
970 && sizeof (long) == 8 ? 1 : -1];
974 # Return 1 if the target supports long double larger than double,
977 proc check_effective_target_large_long_double { } {
978 return [check_no_compiler_messages large_long_double object {
979 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
983 # Return 1 if the target supports compiling fixed-point,
986 proc check_effective_target_fixed_point { } {
987 return [check_no_compiler_messages fixed_point object {
988 _Sat _Fract x; _Sat _Accum y;
992 # Return 1 if the target supports compiling decimal floating point,
995 proc check_effective_target_dfp_nocache { } {
996 verbose "check_effective_target_dfp_nocache: compiling source" 2
997 set ret [check_no_compiler_messages_nocache dfp object {
998 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1000 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1004 proc check_effective_target_dfprt_nocache { } {
1005 return [check_runtime_nocache dfprt {
1006 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1007 int main () { z = x + y; return 0; }
1011 # Return 1 if the target supports compiling Decimal Floating Point,
1014 # This won't change for different subtargets so cache the result.
1016 proc check_effective_target_dfp { } {
1017 return [check_cached_effective_target dfp {
1018 check_effective_target_dfp_nocache
1022 # Return 1 if the target supports linking and executing Decimal Floating
1023 # Point, # 0 otherwise.
1025 # This won't change for different subtargets so cache the result.
1027 proc check_effective_target_dfprt { } {
1028 return [check_cached_effective_target dfprt {
1029 check_effective_target_dfprt_nocache
1033 # Return 1 if the target needs a command line argument to enable a SIMD
1036 proc check_effective_target_vect_cmdline_needed { } {
1037 global et_vect_cmdline_needed_saved
1038 global et_vect_cmdline_needed_target_name
1040 if { ![info exists et_vect_cmdline_needed_target_name] } {
1041 set et_vect_cmdline_needed_target_name ""
1044 # If the target has changed since we set the cached value, clear it.
1045 set current_target [current_target_name]
1046 if { $current_target != $et_vect_cmdline_needed_target_name } {
1047 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1048 set et_vect_cmdline_needed_target_name $current_target
1049 if { [info exists et_vect_cmdline_needed_saved] } {
1050 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1051 unset et_vect_cmdline_needed_saved
1055 if [info exists et_vect_cmdline_needed_saved] {
1056 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1058 set et_vect_cmdline_needed_saved 1
1059 if { [istarget ia64-*-*]
1060 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1061 && [check_effective_target_lp64])
1062 || ([istarget powerpc*-*-*]
1063 && ([check_effective_target_powerpc_spe]
1064 || [check_effective_target_powerpc_altivec]))} {
1065 set et_vect_cmdline_needed_saved 0
1069 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1070 return $et_vect_cmdline_needed_saved
1073 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1075 # This won't change for different subtargets so cache the result.
1077 proc check_effective_target_vect_int { } {
1078 global et_vect_int_saved
1080 if [info exists et_vect_int_saved] {
1081 verbose "check_effective_target_vect_int: using cached result" 2
1083 set et_vect_int_saved 0
1084 if { [istarget i?86-*-*]
1085 || ([istarget powerpc*-*-*]
1086 && ![istarget powerpc-*-linux*paired*])
1087 || [istarget spu-*-*]
1088 || [istarget x86_64-*-*]
1089 || [istarget sparc*-*-*]
1090 || [istarget alpha*-*-*]
1091 || [istarget ia64-*-*] } {
1092 set et_vect_int_saved 1
1096 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1097 return $et_vect_int_saved
1100 # Return 1 if the target supports int->float conversion
1103 proc check_effective_target_vect_intfloat_cvt { } {
1104 global et_vect_intfloat_cvt_saved
1106 if [info exists et_vect_intfloat_cvt_saved] {
1107 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1109 set et_vect_intfloat_cvt_saved 0
1110 if { [istarget i?86-*-*]
1111 || ([istarget powerpc*-*-*]
1112 && ![istarget powerpc-*-linux*paired*])
1113 || [istarget x86_64-*-*] } {
1114 set et_vect_intfloat_cvt_saved 1
1118 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1119 return $et_vect_intfloat_cvt_saved
1123 # Return 1 if the target supports float->int conversion
1126 proc check_effective_target_vect_floatint_cvt { } {
1127 global et_vect_floatint_cvt_saved
1129 if [info exists et_vect_floatint_cvt_saved] {
1130 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1132 set et_vect_floatint_cvt_saved 0
1133 if { [istarget i?86-*-*]
1134 || [istarget x86_64-*-*] } {
1135 set et_vect_floatint_cvt_saved 1
1139 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1140 return $et_vect_floatint_cvt_saved
1143 # Return 1 is this is an arm target using 32-bit instructions
1144 proc check_effective_target_arm32 { } {
1145 return [check_no_compiler_messages arm32 assembly {
1146 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1152 # Return 1 if this is an ARM target supporting -mfpu=vfp
1153 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1156 proc check_effective_target_arm_vfp_ok { } {
1157 if { [check_effective_target_arm32] } {
1158 return [check_no_compiler_messages arm_vfp_ok object {
1160 } "-mfpu=vfp -mfloat-abi=softfp"]
1166 # Return 1 if this is an ARM target supporting -mfpu=neon
1167 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1170 proc check_effective_target_arm_neon_ok { } {
1171 if { [check_effective_target_arm32] } {
1172 return [check_no_compiler_messages arm_neon_ok object {
1174 } "-mfpu=neon -mfloat-abi=softfp"]
1180 # Return 1 if the target supports executing NEON instructions, 0
1181 # otherwise. Cache the result.
1183 proc check_effective_target_arm_neon_hw { } {
1184 return [check_runtime arm_neon_hw_available {
1188 long long a = 0, b = 1;
1189 asm ("vorr %P0, %P1, %P2"
1191 : "0" (a), "w" (b));
1194 } "-mfpu=neon -mfloat-abi=softfp"]
1197 # Return 1 if this is a PowerPC target with floating-point registers.
1199 proc check_effective_target_powerpc_fprs { } {
1200 if { [istarget powerpc*-*-*]
1201 || [istarget rs6000-*-*] } {
1202 return [check_no_compiler_messages powerpc_fprs object {
1214 # Return 1 if this is a PowerPC target supporting -maltivec.
1216 proc check_effective_target_powerpc_altivec_ok { } {
1217 if { ([istarget powerpc*-*-*]
1218 && ![istarget powerpc-*-linux*paired*])
1219 || [istarget rs6000-*-*] } {
1220 # AltiVec is not supported on AIX before 5.3.
1221 if { [istarget powerpc*-*-aix4*]
1222 || [istarget powerpc*-*-aix5.1*]
1223 || [istarget powerpc*-*-aix5.2*] } {
1226 return [check_no_compiler_messages powerpc_altivec_ok object {
1234 # Return 1 if this is a PowerPC target that supports SPU.
1236 proc check_effective_target_powerpc_spu { } {
1237 return [istarget powerpc*-*-linux*]
1240 # Return 1 if this is a PowerPC target with SPE enabled.
1242 proc check_effective_target_powerpc_spe { } {
1243 if { [istarget powerpc*-*-*] } {
1244 return [check_no_compiler_messages powerpc_spe object {
1256 # Return 1 if this is a PowerPC target with Altivec enabled.
1258 proc check_effective_target_powerpc_altivec { } {
1259 if { [istarget powerpc*-*-*] } {
1260 return [check_no_compiler_messages powerpc_altivec object {
1272 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1273 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1274 # test environment appears to run executables on such a simulator.
1276 proc check_effective_target_ultrasparc_hw { } {
1277 return [check_runtime ultrasparc_hw {
1278 int main() { return 0; }
1279 } "-mcpu=ultrasparc"]
1282 # Return 1 if the target supports hardware vector shift operation.
1284 proc check_effective_target_vect_shift { } {
1285 global et_vect_shift_saved
1287 if [info exists et_vect_shift_saved] {
1288 verbose "check_effective_target_vect_shift: using cached result" 2
1290 set et_vect_shift_saved 0
1291 if { ([istarget powerpc*-*-*]
1292 && ![istarget powerpc-*-linux*paired*])
1293 || [istarget ia64-*-*]
1294 || [istarget i?86-*-*]
1295 || [istarget x86_64-*-*] } {
1296 set et_vect_shift_saved 1
1300 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1301 return $et_vect_shift_saved
1304 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1306 # This can change for different subtargets so do not cache the result.
1308 proc check_effective_target_vect_long { } {
1309 if { [istarget i?86-*-*]
1310 || (([istarget powerpc*-*-*]
1311 && ![istarget powerpc-*-linux*paired*])
1312 && [check_effective_target_ilp32])
1313 || [istarget x86_64-*-*]
1314 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1320 verbose "check_effective_target_vect_long: returning $answer" 2
1324 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1326 # This won't change for different subtargets so cache the result.
1328 proc check_effective_target_vect_float { } {
1329 global et_vect_float_saved
1331 if [info exists et_vect_float_saved] {
1332 verbose "check_effective_target_vect_float: using cached result" 2
1334 set et_vect_float_saved 0
1335 if { [istarget i?86-*-*]
1336 || [istarget powerpc*-*-*]
1337 || [istarget spu-*-*]
1338 || [istarget mipsisa64*-*-*]
1339 || [istarget x86_64-*-*]
1340 || [istarget ia64-*-*] } {
1341 set et_vect_float_saved 1
1345 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1346 return $et_vect_float_saved
1349 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1351 # This won't change for different subtargets so cache the result.
1353 proc check_effective_target_vect_double { } {
1354 global et_vect_double_saved
1356 if [info exists et_vect_double_saved] {
1357 verbose "check_effective_target_vect_double: using cached result" 2
1359 set et_vect_double_saved 0
1360 if { [istarget i?86-*-*]
1361 || [istarget x86_64-*-*]
1362 || [istarget spu-*-*] } {
1363 set et_vect_double_saved 1
1367 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1368 return $et_vect_double_saved
1371 # Return 1 if the target plus current options does not support a vector
1372 # max instruction on "int", 0 otherwise.
1374 # This won't change for different subtargets so cache the result.
1376 proc check_effective_target_vect_no_int_max { } {
1377 global et_vect_no_int_max_saved
1379 if [info exists et_vect_no_int_max_saved] {
1380 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1382 set et_vect_no_int_max_saved 0
1383 if { [istarget sparc*-*-*]
1384 || [istarget spu-*-*]
1385 || [istarget alpha*-*-*] } {
1386 set et_vect_no_int_max_saved 1
1389 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1390 return $et_vect_no_int_max_saved
1393 # Return 1 if the target plus current options does not support a vector
1394 # add instruction on "int", 0 otherwise.
1396 # This won't change for different subtargets so cache the result.
1398 proc check_effective_target_vect_no_int_add { } {
1399 global et_vect_no_int_add_saved
1401 if [info exists et_vect_no_int_add_saved] {
1402 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1404 set et_vect_no_int_add_saved 0
1405 # Alpha only supports vector add on V8QI and V4HI.
1406 if { [istarget alpha*-*-*] } {
1407 set et_vect_no_int_add_saved 1
1410 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1411 return $et_vect_no_int_add_saved
1414 # Return 1 if the target plus current options does not support vector
1415 # bitwise instructions, 0 otherwise.
1417 # This won't change for different subtargets so cache the result.
1419 proc check_effective_target_vect_no_bitwise { } {
1420 global et_vect_no_bitwise_saved
1422 if [info exists et_vect_no_bitwise_saved] {
1423 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1425 set et_vect_no_bitwise_saved 0
1427 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1428 return $et_vect_no_bitwise_saved
1431 # Return 1 if the target plus current options supports a vector
1432 # widening summation of *short* args into *int* result, 0 otherwise.
1433 # A target can also support this widening summation if it can support
1434 # promotion (unpacking) from shorts to ints.
1436 # This won't change for different subtargets so cache the result.
1438 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1439 global et_vect_widen_sum_hi_to_si
1441 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1442 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1444 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1445 if { [istarget powerpc*-*-*]
1446 || [istarget ia64-*-*] } {
1447 set et_vect_widen_sum_hi_to_si_saved 1
1450 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1451 return $et_vect_widen_sum_hi_to_si_saved
1454 # Return 1 if the target plus current options supports a vector
1455 # widening summation of *char* args into *short* result, 0 otherwise.
1456 # A target can also support this widening summation if it can support
1457 # promotion (unpacking) from chars to shorts.
1459 # This won't change for different subtargets so cache the result.
1461 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1462 global et_vect_widen_sum_qi_to_hi
1464 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1465 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1467 set et_vect_widen_sum_qi_to_hi_saved 0
1468 if { [check_effective_target_vect_unpack]
1469 || [istarget ia64-*-*] } {
1470 set et_vect_widen_sum_qi_to_hi_saved 1
1473 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1474 return $et_vect_widen_sum_qi_to_hi_saved
1477 # Return 1 if the target plus current options supports a vector
1478 # widening summation of *char* args into *int* result, 0 otherwise.
1480 # This won't change for different subtargets so cache the result.
1482 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1483 global et_vect_widen_sum_qi_to_si
1485 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1486 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1488 set et_vect_widen_sum_qi_to_si_saved 0
1489 if { [istarget powerpc*-*-*] } {
1490 set et_vect_widen_sum_qi_to_si_saved 1
1493 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1494 return $et_vect_widen_sum_qi_to_si_saved
1497 # Return 1 if the target plus current options supports a vector
1498 # widening multiplication of *char* args into *short* result, 0 otherwise.
1499 # A target can also support this widening multplication if it can support
1500 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1501 # multiplication of shorts).
1503 # This won't change for different subtargets so cache the result.
1506 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1507 global et_vect_widen_mult_qi_to_hi
1509 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1510 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1512 if { [check_effective_target_vect_unpack]
1513 && [check_effective_target_vect_short_mult] } {
1514 set et_vect_widen_mult_qi_to_hi_saved 1
1516 set et_vect_widen_mult_qi_to_hi_saved 0
1518 if { [istarget powerpc*-*-*] } {
1519 set et_vect_widen_mult_qi_to_hi_saved 1
1522 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1523 return $et_vect_widen_mult_qi_to_hi_saved
1526 # Return 1 if the target plus current options supports a vector
1527 # widening multiplication of *short* args into *int* result, 0 otherwise.
1528 # A target can also support this widening multplication if it can support
1529 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1530 # multiplication of ints).
1532 # This won't change for different subtargets so cache the result.
1535 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1536 global et_vect_widen_mult_hi_to_si
1538 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1539 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1541 if { [check_effective_target_vect_unpack]
1542 && [check_effective_target_vect_int_mult] } {
1543 set et_vect_widen_mult_hi_to_si_saved 1
1545 set et_vect_widen_mult_hi_to_si_saved 0
1547 if { [istarget powerpc*-*-*]
1548 || [istarget spu-*-*]
1549 || [istarget i?86-*-*]
1550 || [istarget x86_64-*-*] } {
1551 set et_vect_widen_mult_hi_to_si_saved 1
1554 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1555 return $et_vect_widen_mult_hi_to_si_saved
1558 # Return 1 if the target plus current options supports a vector
1559 # dot-product of signed chars, 0 otherwise.
1561 # This won't change for different subtargets so cache the result.
1563 proc check_effective_target_vect_sdot_qi { } {
1564 global et_vect_sdot_qi
1566 if [info exists et_vect_sdot_qi_saved] {
1567 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1569 set et_vect_sdot_qi_saved 0
1571 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1572 return $et_vect_sdot_qi_saved
1575 # Return 1 if the target plus current options supports a vector
1576 # dot-product of unsigned chars, 0 otherwise.
1578 # This won't change for different subtargets so cache the result.
1580 proc check_effective_target_vect_udot_qi { } {
1581 global et_vect_udot_qi
1583 if [info exists et_vect_udot_qi_saved] {
1584 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1586 set et_vect_udot_qi_saved 0
1587 if { [istarget powerpc*-*-*] } {
1588 set et_vect_udot_qi_saved 1
1591 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1592 return $et_vect_udot_qi_saved
1595 # Return 1 if the target plus current options supports a vector
1596 # dot-product of signed shorts, 0 otherwise.
1598 # This won't change for different subtargets so cache the result.
1600 proc check_effective_target_vect_sdot_hi { } {
1601 global et_vect_sdot_hi
1603 if [info exists et_vect_sdot_hi_saved] {
1604 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1606 set et_vect_sdot_hi_saved 0
1607 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1608 || [istarget i?86-*-*]
1609 || [istarget x86_64-*-*] } {
1610 set et_vect_sdot_hi_saved 1
1613 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1614 return $et_vect_sdot_hi_saved
1617 # Return 1 if the target plus current options supports a vector
1618 # dot-product of unsigned shorts, 0 otherwise.
1620 # This won't change for different subtargets so cache the result.
1622 proc check_effective_target_vect_udot_hi { } {
1623 global et_vect_udot_hi
1625 if [info exists et_vect_udot_hi_saved] {
1626 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1628 set et_vect_udot_hi_saved 0
1629 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1630 set et_vect_udot_hi_saved 1
1633 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1634 return $et_vect_udot_hi_saved
1638 # Return 1 if the target plus current options supports a vector
1639 # demotion (packing) of shorts (to chars) and ints (to shorts)
1640 # using modulo arithmetic, 0 otherwise.
1642 # This won't change for different subtargets so cache the result.
1644 proc check_effective_target_vect_pack_trunc { } {
1645 global et_vect_pack_trunc
1647 if [info exists et_vect_pack_trunc_saved] {
1648 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1650 set et_vect_pack_trunc_saved 0
1651 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1652 || [istarget i?86-*-*]
1653 || [istarget x86_64-*-*] } {
1654 set et_vect_pack_trunc_saved 1
1657 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1658 return $et_vect_pack_trunc_saved
1661 # Return 1 if the target plus current options supports a vector
1662 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1664 # This won't change for different subtargets so cache the result.
1666 proc check_effective_target_vect_unpack { } {
1667 global et_vect_unpack
1669 if [info exists et_vect_unpack_saved] {
1670 verbose "check_effective_target_vect_unpack: using cached result" 2
1672 set et_vect_unpack_saved 0
1673 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1674 || [istarget i?86-*-*]
1675 || [istarget x86_64-*-*]
1676 || [istarget spu-*-*] } {
1677 set et_vect_unpack_saved 1
1680 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1681 return $et_vect_unpack_saved
1684 # Return 1 if the target plus current options does not guarantee
1685 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1687 # This won't change for different subtargets so cache the result.
1689 proc check_effective_target_unaligned_stack { } {
1690 global et_unaligned_stack_saved
1692 if [info exists et_unaligned_stack_saved] {
1693 verbose "check_effective_target_unaligned_stack: using cached result" 2
1695 set et_unaligned_stack_saved 0
1696 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
1697 && (! [istarget *-*-darwin*] ) } {
1698 set et_unaligned_stack_saved 1
1701 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1702 return $et_unaligned_stack_saved
1705 # Return 1 if the target plus current options does not support a vector
1706 # alignment mechanism, 0 otherwise.
1708 # This won't change for different subtargets so cache the result.
1710 proc check_effective_target_vect_no_align { } {
1711 global et_vect_no_align_saved
1713 if [info exists et_vect_no_align_saved] {
1714 verbose "check_effective_target_vect_no_align: using cached result" 2
1716 set et_vect_no_align_saved 0
1717 if { [istarget mipsisa64*-*-*]
1718 || [istarget sparc*-*-*]
1719 || [istarget ia64-*-*] } {
1720 set et_vect_no_align_saved 1
1723 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1724 return $et_vect_no_align_saved
1727 # Return 1 if arrays are aligned to the vector alignment
1728 # boundary, 0 otherwise.
1730 # This won't change for different subtargets so cache the result.
1732 proc check_effective_target_vect_aligned_arrays { } {
1733 global et_vect_aligned_arrays
1735 if [info exists et_vect_aligned_arrays_saved] {
1736 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1738 set et_vect_aligned_arrays_saved 0
1739 if { (([istarget x86_64-*-*]
1740 || [istarget i?86-*-*]) && [is-effective-target lp64])
1741 || [istarget spu-*-*] } {
1742 set et_vect_aligned_arrays_saved 1
1745 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1746 return $et_vect_aligned_arrays_saved
1749 # Return 1 if types of size 32 bit or less are naturally aligned
1750 # (aligned to their type-size), 0 otherwise.
1752 # This won't change for different subtargets so cache the result.
1754 proc check_effective_target_natural_alignment_32 { } {
1755 global et_natural_alignment_32
1757 if [info exists et_natural_alignment_32_saved] {
1758 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1760 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
1761 set et_natural_alignment_32_saved 1
1762 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
1763 set et_natural_alignment_32_saved 0
1766 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
1767 return $et_natural_alignment_32_saved
1770 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
1771 # type-size), 0 otherwise.
1773 # This won't change for different subtargets so cache the result.
1775 proc check_effective_target_natural_alignment_64 { } {
1776 global et_natural_alignment_64
1778 if [info exists et_natural_alignment_64_saved] {
1779 verbose "check_effective_target_natural_alignment_64: using cached result" 2
1781 set et_natural_alignment_64_saved 0
1782 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
1783 || [istarget spu-*-*] } {
1784 set et_natural_alignment_64_saved 1
1787 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
1788 return $et_natural_alignment_64_saved
1791 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
1793 # This won't change for different subtargets so cache the result.
1795 proc check_effective_target_vector_alignment_reachable { } {
1796 global et_vector_alignment_reachable
1798 if [info exists et_vector_alignment_reachable_saved] {
1799 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
1801 if { [check_effective_target_vect_aligned_arrays]
1802 || [check_effective_target_natural_alignment_32] } {
1803 set et_vector_alignment_reachable_saved 1
1805 set et_vector_alignment_reachable_saved 0
1808 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
1809 return $et_vector_alignment_reachable_saved
1812 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
1814 # This won't change for different subtargets so cache the result.
1816 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
1817 global et_vector_alignment_reachable_for_64bit
1819 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
1820 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
1822 if { [check_effective_target_vect_aligned_arrays]
1823 || [check_effective_target_natural_alignment_64] } {
1824 set et_vector_alignment_reachable_for_64bit_saved 1
1826 set et_vector_alignment_reachable_for_64bit_saved 0
1829 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
1830 return $et_vector_alignment_reachable_for_64bit_saved
1833 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1835 proc check_effective_target_vect_condition { } {
1836 global et_vect_cond_saved
1838 if [info exists et_vect_cond_saved] {
1839 verbose "check_effective_target_vect_cond: using cached result" 2
1841 set et_vect_cond_saved 0
1842 if { [istarget powerpc*-*-*]
1843 || [istarget ia64-*-*]
1844 || [istarget i?86-*-*]
1845 || [istarget spu-*-*]
1846 || [istarget x86_64-*-*] } {
1847 set et_vect_cond_saved 1
1851 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1852 return $et_vect_cond_saved
1855 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1857 proc check_effective_target_vect_char_mult { } {
1858 global et_vect_char_mult_saved
1860 if [info exists et_vect_char_mult_saved] {
1861 verbose "check_effective_target_vect_char_mult: using cached result" 2
1863 set et_vect_char_mult_saved 0
1864 if { [istarget ia64-*-*]
1865 || [istarget i?86-*-*]
1866 || [istarget x86_64-*-*] } {
1867 set et_vect_char_mult_saved 1
1871 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1872 return $et_vect_char_mult_saved
1875 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1877 proc check_effective_target_vect_short_mult { } {
1878 global et_vect_short_mult_saved
1880 if [info exists et_vect_short_mult_saved] {
1881 verbose "check_effective_target_vect_short_mult: using cached result" 2
1883 set et_vect_short_mult_saved 0
1884 if { [istarget ia64-*-*]
1885 || [istarget spu-*-*]
1886 || [istarget i?86-*-*]
1887 || [istarget x86_64-*-*] } {
1888 set et_vect_short_mult_saved 1
1892 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1893 return $et_vect_short_mult_saved
1896 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1898 proc check_effective_target_vect_int_mult { } {
1899 global et_vect_int_mult_saved
1901 if [info exists et_vect_int_mult_saved] {
1902 verbose "check_effective_target_vect_int_mult: using cached result" 2
1904 set et_vect_int_mult_saved 0
1905 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1906 || [istarget spu-*-*]
1907 || [istarget i?86-*-*]
1908 || [istarget x86_64-*-*] } {
1909 set et_vect_int_mult_saved 1
1913 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1914 return $et_vect_int_mult_saved
1917 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1919 proc check_effective_target_vect_extract_even_odd { } {
1920 global et_vect_extract_even_odd_saved
1922 if [info exists et_vect_extract_even_odd_saved] {
1923 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1925 set et_vect_extract_even_odd_saved 0
1926 if { [istarget powerpc*-*-*] } {
1927 set et_vect_extract_even_odd_saved 1
1931 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1932 return $et_vect_extract_even_odd_saved
1935 # Return 1 if the target supports vector interleaving, 0 otherwise.
1937 proc check_effective_target_vect_interleave { } {
1938 global et_vect_interleave_saved
1940 if [info exists et_vect_interleave_saved] {
1941 verbose "check_effective_target_vect_interleave: using cached result" 2
1943 set et_vect_interleave_saved 0
1944 if { [istarget powerpc*-*-*]
1945 || [istarget i?86-*-*]
1946 || [istarget x86_64-*-*] } {
1947 set et_vect_interleave_saved 1
1951 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1952 return $et_vect_interleave_saved
1955 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
1956 proc check_effective_target_vect_strided { } {
1957 global et_vect_strided_saved
1959 if [info exists et_vect_strided_saved] {
1960 verbose "check_effective_target_vect_strided: using cached result" 2
1962 set et_vect_strided_saved 0
1963 if { [check_effective_target_vect_interleave]
1964 && [check_effective_target_vect_extract_even_odd] } {
1965 set et_vect_strided_saved 1
1969 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
1970 return $et_vect_strided_saved
1973 # Return 1 if the target supports section-anchors
1975 proc check_effective_target_section_anchors { } {
1976 global et_section_anchors_saved
1978 if [info exists et_section_anchors_saved] {
1979 verbose "check_effective_target_section_anchors: using cached result" 2
1981 set et_section_anchors_saved 0
1982 if { [istarget powerpc*-*-*] } {
1983 set et_section_anchors_saved 1
1987 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1988 return $et_section_anchors_saved
1991 # Return 1 if the target supports atomic operations on "int" and "long".
1993 proc check_effective_target_sync_int_long { } {
1994 global et_sync_int_long_saved
1996 if [info exists et_sync_int_long_saved] {
1997 verbose "check_effective_target_sync_int_long: using cached result" 2
1999 set et_sync_int_long_saved 0
2000 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2001 # load-reserved/store-conditional instructions.
2002 if { [istarget ia64-*-*]
2003 || [istarget i?86-*-*]
2004 || [istarget x86_64-*-*]
2005 || [istarget alpha*-*-*]
2006 || [istarget s390*-*-*]
2007 || [istarget powerpc*-*-*]
2008 || [istarget sparc64-*-*]
2009 || [istarget sparcv9-*-*] } {
2010 set et_sync_int_long_saved 1
2014 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2015 return $et_sync_int_long_saved
2018 # Return 1 if the target supports atomic operations on "char" and "short".
2020 proc check_effective_target_sync_char_short { } {
2021 global et_sync_char_short_saved
2023 if [info exists et_sync_char_short_saved] {
2024 verbose "check_effective_target_sync_char_short: using cached result" 2
2026 set et_sync_char_short_saved 0
2027 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2028 # load-reserved/store-conditional instructions.
2029 if { [istarget ia64-*-*]
2030 || [istarget i?86-*-*]
2031 || [istarget x86_64-*-*]
2032 || [istarget alpha*-*-*]
2033 || [istarget s390*-*-*]
2034 || [istarget powerpc*-*-*]
2035 || [istarget sparc64-*-*]
2036 || [istarget sparcv9-*-*] } {
2037 set et_sync_char_short_saved 1
2041 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2042 return $et_sync_char_short_saved
2045 # Return 1 if the target uses a ColdFire FPU.
2047 proc check_effective_target_coldfire_fpu { } {
2048 return [check_no_compiler_messages coldfire_fpu assembly {
2055 # Return true if this is a uClibc target.
2057 proc check_effective_target_uclibc {} {
2058 return [check_no_compiler_messages uclibc object {
2059 #include <features.h>
2060 #if !defined (__UCLIBC__)
2066 # Return true if this is a uclibc target and if the uclibc feature
2067 # described by __$feature__ is not present.
2069 proc check_missing_uclibc_feature {feature} {
2070 return [check_no_compiler_messages $feature object "
2071 #include <features.h>
2072 #if !defined (__UCLIBC) || defined (__${feature}__)
2078 # Return true if this is a Newlib target.
2080 proc check_effective_target_newlib {} {
2081 return [check_no_compiler_messages newlib object {
2087 # (a) an error of a few ULP is expected in string to floating-point
2088 # conversion functions; and
2089 # (b) overflow is not always detected correctly by those functions.
2091 proc check_effective_target_lax_strtofp {} {
2092 # By default, assume that all uClibc targets suffer from this.
2093 return [check_effective_target_uclibc]
2096 # Return 1 if this is a target for which wcsftime is a dummy
2097 # function that always returns 0.
2099 proc check_effective_target_dummy_wcsftime {} {
2100 # By default, assume that all uClibc targets suffer from this.
2101 return [check_effective_target_uclibc]
2104 # Return 1 if constructors with initialization priority arguments are
2105 # supposed on this target.
2107 proc check_effective_target_init_priority {} {
2108 return [check_no_compiler_messages init_priority assembly "
2109 void f() __attribute__((constructor (1000)));
2114 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2115 # This can be used with any check_* proc that takes no argument and
2116 # returns only 1 or 0. It could be used with check_* procs that take
2117 # arguments with keywords that pass particular arguments.
2119 proc is-effective-target { arg } {
2121 if { [info procs check_effective_target_${arg}] != [list] } {
2122 set selected [check_effective_target_${arg}]
2125 "vmx_hw" { set selected [check_vmx_hw_available] }
2126 "named_sections" { set selected [check_named_sections_available] }
2127 "gc_sections" { set selected [check_gc_sections_available] }
2128 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2129 default { error "unknown effective target keyword `$arg'" }
2132 verbose "is-effective-target: $arg $selected" 2
2136 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2138 proc is-effective-target-keyword { arg } {
2139 if { [info procs check_effective_target_${arg}] != [list] } {
2142 # These have different names for their check_* procs.
2144 "vmx_hw" { return 1 }
2145 "named_sections" { return 1 }
2146 "gc_sections" { return 1 }
2147 "cxa_atexit" { return 1 }
2148 default { return 0 }
2153 # Return 1 if target default to short enums
2155 proc check_effective_target_short_enums { } {
2156 return [check_no_compiler_messages short_enums assembly {
2158 int s[sizeof (enum foo) == 1 ? 1 : -1];
2162 # Return 1 if target supports merging string constants at link time.
2164 proc check_effective_target_string_merging { } {
2165 return [check_no_messages_and_pattern string_merging \
2166 "rodata\\.str" assembly {
2167 const char *var = "String";
2171 # Return 1 if target has the basic signed and unsigned types in
2172 # <stdint.h>, 0 otherwise.
2174 proc check_effective_target_stdint_types { } {
2175 return [check_no_compiler_messages stdint_types assembly {
2177 int8_t a; int16_t b; int32_t c; int64_t d;
2178 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2182 # Return 1 if programs are intended to be run on a simulator
2183 # (i.e. slowly) rather than hardware (i.e. fast).
2185 proc check_effective_target_simulator { } {
2187 # All "src/sim" simulators set this one.
2188 if [board_info target exists is_simulator] {
2189 return [board_info target is_simulator]
2192 # The "sid" simulators don't set that one, but at least they set
2194 if [board_info target exists slow_simulator] {
2195 return [board_info target slow_simulator]
2201 # Return 1 if the target is a VxWorks RTP.
2203 proc check_effective_target_vxworks_kernel { } {
2204 return [check_no_compiler_messages vxworks_kernel assembly {
2205 #if !defined __vxworks || defined __RTP__
2211 # Return 1 if the target is expected to provide wide character support.
2213 proc check_effective_target_wchar { } {
2214 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2217 return [check_no_compiler_messages wchar assembly {
2222 # Return 1 if the target has <pthread.h>.
2224 proc check_effective_target_pthread_h { } {
2225 return [check_no_compiler_messages pthread_h assembly {
2226 #include <pthread.h>
2230 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2232 proc add_options_for_c99_runtime { flags } {
2233 if { [istarget *-*-solaris2*] } {
2234 return "$flags -std=c99"
2236 if { [istarget powerpc-*-darwin*] } {
2237 return "$flags -mmacosx-version-min=10.3"
2242 # Return 1 if the target provides a full C99 runtime.
2244 proc check_effective_target_c99_runtime { } {
2245 return [check_cached_effective_target c99_runtime {
2248 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2249 set contents [read $file]
2252 #ifndef HAVE_C99_RUNTIME
2256 check_no_compiler_messages_nocache c99_runtime assembly \
2257 $contents [add_options_for_c99_runtime ""]