1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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_weak_override_available { }
255 ###############################
257 # Like check_weak_available, but return 0 if weak symbol definitions
258 # cannot be overridden.
260 proc check_weak_override_available { } {
261 if { [istarget "*-*-mingw*"] } {
264 return [check_weak_available]
267 ###############################
268 # proc check_visibility_available { what_kind }
269 ###############################
271 # The visibility attribute is only support in some object formats
272 # This proc returns 1 if it is supported, 0 if not.
273 # The argument is the kind of visibility, default/protected/hidden/internal.
275 proc check_visibility_available { what_kind } {
277 global target_triplet
279 # On NetWare, support makes no sense.
280 if { [istarget *-*-netware*] } {
284 if [string match "" $what_kind] { set what_kind "hidden" }
286 return [check_no_compiler_messages visibility_available_$what_kind object "
287 void f() __attribute__((visibility(\"$what_kind\")));
292 ###############################
293 # proc check_alias_available { }
294 ###############################
296 # Determine if the target toolchain supports the alias attribute.
298 # Returns 2 if the target supports aliases. Returns 1 if the target
299 # only supports weak aliased. Returns 0 if the target does not
300 # support aliases at all. Returns -1 if support for aliases could not
303 proc check_alias_available { } {
304 global alias_available_saved
307 if [info exists alias_available_saved] {
308 verbose "check_alias_available returning saved $alias_available_saved" 2
312 verbose "check_alias_available compiling testfile $src" 2
313 set f [open $src "w"]
314 # Compile a small test program. The definition of "g" is
315 # necessary to keep the Solaris assembler from complaining
317 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
318 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
320 set lines [${tool}_target_compile $src $obj object ""]
322 remote_file build delete $obj
324 if [string match "" $lines] then {
325 # No error messages, everything is OK.
326 set alias_available_saved 2
328 if [regexp "alias definitions not supported" $lines] {
329 verbose "check_alias_available target does not support aliases" 2
331 set objformat [gcc_target_object_format]
333 if { $objformat == "elf" } {
334 verbose "check_alias_available but target uses ELF format, so it ought to" 2
335 set alias_available_saved -1
337 set alias_available_saved 0
340 if [regexp "only weak aliases are supported" $lines] {
341 verbose "check_alias_available target supports only weak aliases" 2
342 set alias_available_saved 1
344 set alias_available_saved -1
349 verbose "check_alias_available returning $alias_available_saved" 2
352 return $alias_available_saved
355 # Returns true if --gc-sections is supported on the target.
357 proc check_gc_sections_available { } {
358 global gc_sections_available_saved
361 if {![info exists gc_sections_available_saved]} {
362 # Some targets don't support gc-sections despite whatever's
363 # advertised by ld's options.
364 if { [istarget alpha*-*-*]
365 || [istarget ia64-*-*] } {
366 set gc_sections_available_saved 0
370 # elf2flt uses -q (--emit-relocs), which is incompatible with
372 if { [board_info target exists ldflags]
373 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
374 set gc_sections_available_saved 0
378 # VxWorks kernel modules are relocatable objects linked with -r,
379 # while RTP executables are linked with -q (--emit-relocs).
380 # Both of these options are incompatible with --gc-sections.
381 if { [istarget *-*-vxworks*] } {
382 set gc_sections_available_saved 0
386 # Check if the ld used by gcc supports --gc-sections.
387 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
388 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
389 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
390 set ld_output [remote_exec host "$gcc_ld" "--help"]
391 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
392 set gc_sections_available_saved 1
394 set gc_sections_available_saved 0
397 return $gc_sections_available_saved
400 # Return 1 if according to target_info struct and explicit target list
401 # target is supposed to support trampolines.
403 proc check_effective_target_trampolines { } {
404 if [target_info exists no_trampolines] {
407 if { [istarget avr-*-*]
408 || [istarget hppa2.0w-hp-hpux11.23]
409 || [istarget hppa64-hp-hpux11.23] } {
415 # Return 1 if according to target_info struct and explicit target list
416 # target is supposed to keep null pointer checks. This could be due to
417 # use of option fno-delete-null-pointer-checks or hardwired in target.
419 proc check_effective_target_keeps_null_pointer_checks { } {
420 if [target_info exists keeps_null_pointer_checks] {
423 if { [istarget avr-*-*] } {
429 # Return true if profiling is supported on the target.
431 proc check_profiling_available { test_what } {
432 global profiling_available_saved
434 verbose "Profiling argument is <$test_what>" 1
436 # These conditions depend on the argument so examine them before
437 # looking at the cache variable.
439 # Support for -p on solaris2 relies on mcrt1.o which comes with the
440 # vendor compiler. We cannot reliably predict the directory where the
441 # vendor compiler (and thus mcrt1.o) is installed so we can't
442 # necessarily find mcrt1.o even if we have it.
443 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
447 # Support for -p on irix relies on libprof1.a which doesn't appear to
448 # exist on any irix6 system currently posting testsuite results.
449 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
450 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
451 if { [istarget mips*-*-irix*]
452 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
456 # We don't yet support profiling for MIPS16.
457 if { [istarget mips*-*-*]
458 && ![check_effective_target_nomips16]
459 && ([lindex $test_what 1] == "-p"
460 || [lindex $test_what 1] == "-pg") } {
464 # MinGW does not support -p.
465 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
469 # uClibc does not have gcrt1.o.
470 if { [check_effective_target_uclibc]
471 && ([lindex $test_what 1] == "-p"
472 || [lindex $test_what 1] == "-pg") } {
476 # Now examine the cache variable.
477 if {![info exists profiling_available_saved]} {
478 # Some targets don't have any implementation of __bb_init_func or are
479 # missing other needed machinery.
480 if { [istarget mmix-*-*]
481 || [istarget arm*-*-eabi*]
482 || [istarget picochip-*-*]
483 || [istarget *-*-netware*]
484 || [istarget arm*-*-elf]
485 || [istarget arm*-*-symbianelf*]
486 || [istarget avr-*-*]
487 || [istarget bfin-*-*]
488 || [istarget powerpc-*-eabi*]
489 || [istarget cris-*-*]
490 || [istarget crisv32-*-*]
491 || [istarget fido-*-elf]
492 || [istarget h8300-*-*]
493 || [istarget m32c-*-elf]
494 || [istarget m68k-*-elf]
495 || [istarget m68k-*-uclinux*]
496 || [istarget mips*-*-elf*]
497 || [istarget xstormy16-*]
498 || [istarget xtensa*-*-elf]
499 || [istarget *-*-rtems*]
500 || [istarget *-*-vxworks*] } {
501 set profiling_available_saved 0
503 set profiling_available_saved 1
507 return $profiling_available_saved
510 # Check to see if a target is "freestanding". This is as per the definition
511 # in Section 4 of C99 standard. Effectively, it is a target which supports no
512 # extra headers or libraries other than what is considered essential.
513 proc check_effective_target_freestanding { } {
514 if { [istarget picochip-*-*] } then {
521 # Return 1 if target has packed layout of structure members by
522 # default, 0 otherwise. Note that this is slightly different than
523 # whether the target has "natural alignment": both attributes may be
526 proc check_effective_target_default_packed { } {
527 return [check_no_compiler_messages default_packed assembly {
528 struct x { char a; long b; } c;
529 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
533 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
534 # documentation, where the test also comes from.
536 proc check_effective_target_pcc_bitfield_type_matters { } {
537 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
538 # bitfields, but let's stick to the example code from the docs.
539 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
540 struct foo1 { char x; char :0; char y; };
541 struct foo2 { char x; int :0; char y; };
542 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
546 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
548 # This won't change for different subtargets so cache the result.
550 proc check_effective_target_tls {} {
551 return [check_no_compiler_messages tls assembly {
553 int f (void) { return i; }
554 void g (int j) { i = j; }
558 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
560 # This won't change for different subtargets so cache the result.
562 proc check_effective_target_tls_native {} {
563 # VxWorks uses emulated TLS machinery, but with non-standard helper
564 # functions, so we fail to automatically detect it.
565 global target_triplet
566 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
570 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
572 int f (void) { return i; }
573 void g (int j) { i = j; }
577 # Return 1 if TLS executables can run correctly, 0 otherwise.
579 # This won't change for different subtargets so cache the result.
581 proc check_effective_target_tls_runtime {} {
582 return [check_runtime tls_runtime {
583 __thread int thr = 0;
584 int main (void) { return thr; }
588 # Return 1 if compilation with -fgraphite is error-free for trivial
591 proc check_effective_target_fgraphite {} {
592 return [check_no_compiler_messages fgraphite object {
597 # Return 1 if compilation with -fopenmp is error-free for trivial
600 proc check_effective_target_fopenmp {} {
601 return [check_no_compiler_messages fopenmp object {
606 # Return 1 if compilation with -pthread is error-free for trivial
609 proc check_effective_target_pthread {} {
610 return [check_no_compiler_messages pthread object {
615 # Return 1 if the target supports -fstack-protector
616 proc check_effective_target_fstack_protector {} {
617 return [check_runtime fstack_protector {
618 int main (void) { return 0; }
619 } "-fstack-protector"]
622 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
623 # for trivial code, 0 otherwise.
625 proc check_effective_target_freorder {} {
626 return [check_no_compiler_messages freorder object {
628 } "-freorder-blocks-and-partition"]
631 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
632 # emitted, 0 otherwise. Whether a shared library can actually be built is
633 # out of scope for this test.
635 proc check_effective_target_fpic { } {
636 # Note that M68K has a multilib that supports -fpic but not
637 # -fPIC, so we need to check both. We test with a program that
638 # requires GOT references.
639 foreach arg {fpic fPIC} {
640 if [check_no_compiler_messages $arg object {
641 extern int foo (void); extern int bar;
642 int baz (void) { return foo () + bar; }
650 # Return true if the target supports -mpaired-single (as used on MIPS).
652 proc check_effective_target_mpaired_single { } {
653 return [check_no_compiler_messages mpaired_single object {
658 # Return true if the target has access to FPU instructions.
660 proc check_effective_target_hard_float { } {
661 if { [istarget mips*-*-*] } {
662 return [check_no_compiler_messages hard_float assembly {
663 #if (defined __mips_soft_float || defined __mips16)
669 # The generic test equates hard_float with "no call for adding doubles".
670 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
671 double a (double b, double c) { return b + c; }
675 # Return true if the target is a 64-bit MIPS target.
677 proc check_effective_target_mips64 { } {
678 return [check_no_compiler_messages mips64 assembly {
685 # Return true if the target is a MIPS target that does not produce
688 proc check_effective_target_nomips16 { } {
689 return [check_no_compiler_messages nomips16 object {
693 /* A cheap way of testing for -mflip-mips16. */
694 void foo (void) { asm ("addiu $20,$20,1"); }
695 void bar (void) { asm ("addiu $20,$20,1"); }
700 # Add the options needed for MIPS16 function attributes. At the moment,
701 # we don't support MIPS16 PIC.
703 proc add_options_for_mips16_attribute { flags } {
704 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
707 # Return true if we can force a mode that allows MIPS16 code generation.
708 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
711 proc check_effective_target_mips16_attribute { } {
712 return [check_no_compiler_messages mips16_attribute assembly {
716 #if defined __mips_hard_float \
717 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
718 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
721 } [add_options_for_mips16_attribute ""]]
724 # Return 1 if the current multilib does not generate PIC by default.
726 proc check_effective_target_nonpic { } {
727 return [check_no_compiler_messages nonpic assembly {
734 # Return 1 if the target does not use a status wrapper.
736 proc check_effective_target_unwrapped { } {
737 if { [target_info needs_status_wrapper] != "" \
738 && [target_info needs_status_wrapper] != "0" } {
744 # Return true if iconv is supported on the target. In particular IBM1047.
746 proc check_iconv_available { test_what } {
749 # If the tool configuration file has not set libiconv, try "-liconv"
750 if { ![info exists libiconv] } {
751 set libiconv "-liconv"
753 set test_what [lindex $test_what 1]
754 return [check_runtime_nocache $test_what [subst {
760 cd = iconv_open ("$test_what", "UTF-8");
761 if (cd == (iconv_t) -1)
768 # Return true if named sections are supported on this target.
770 proc check_named_sections_available { } {
771 return [check_no_compiler_messages named_sections assembly {
772 int __attribute__ ((section("whatever"))) foo;
776 # Return 1 if the target supports Fortran real kinds larger than real(8),
779 # When the target name changes, replace the cached result.
781 proc check_effective_target_fortran_large_real { } {
782 return [check_no_compiler_messages fortran_large_real executable {
784 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
791 # Return 1 if the target supports Fortran integer kinds larger than
792 # integer(8), 0 otherwise.
794 # When the target name changes, replace the cached result.
796 proc check_effective_target_fortran_large_int { } {
797 return [check_no_compiler_messages fortran_large_int executable {
799 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
805 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
807 # When the target name changes, replace the cached result.
809 proc check_effective_target_fortran_integer_16 { } {
810 return [check_no_compiler_messages fortran_integer_16 executable {
817 # Return 1 if we can statically link libgfortran, 0 otherwise.
819 # When the target name changes, replace the cached result.
821 proc check_effective_target_static_libgfortran { } {
822 return [check_no_compiler_messages static_libgfortran executable {
829 # Return 1 if the target supports executing 750CL paired-single instructions, 0
830 # otherwise. Cache the result.
832 proc check_750cl_hw_available { } {
833 return [check_cached_effective_target 750cl_hw_available {
834 # If this is not the right target then we can skip the test.
835 if { ![istarget powerpc-*paired*] } {
838 check_runtime_nocache 750cl_hw_available {
842 asm volatile ("ps_mul v0,v0,v0");
844 asm volatile ("ps_mul 0,0,0");
853 # Return 1 if the target supports executing SSE2 instructions, 0
854 # otherwise. Cache the result.
856 proc check_sse2_hw_available { } {
857 return [check_cached_effective_target sse2_hw_available {
858 # If this is not the right target then we can skip the test.
859 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
862 check_runtime_nocache sse2_hw_available {
866 unsigned int eax, ebx, ecx, edx = 0;
867 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
868 return !(edx & bit_SSE2);
876 # Return 1 if the target supports executing AltiVec instructions, 0
877 # otherwise. Cache the result.
879 proc check_vmx_hw_available { } {
880 return [check_cached_effective_target vmx_hw_available {
881 # Some simulators are known to not support VMX instructions.
882 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
885 # Most targets don't require special flags for this test case, but
887 if { [istarget *-*-darwin*]
888 || [istarget *-*-aix*] } {
889 set options "-maltivec"
893 check_runtime_nocache vmx_hw_available {
897 asm volatile ("vor v0,v0,v0");
899 asm volatile ("vor 0,0,0");
908 # Return 1 if the target supports executing AltiVec and Cell PPU
909 # instructions, 0 otherwise. Cache the result.
911 proc check_effective_target_cell_hw { } {
912 return [check_cached_effective_target cell_hw_available {
913 # Some simulators are known to not support VMX and PPU instructions.
914 if { [istarget powerpc-*-eabi*] } {
917 # Most targets don't require special flags for this test
918 # case, but Darwin and AIX do.
919 if { [istarget *-*-darwin*]
920 || [istarget *-*-aix*] } {
921 set options "-maltivec -mcpu=cell"
923 set options "-mcpu=cell"
925 check_runtime_nocache cell_hw_available {
929 asm volatile ("vor v0,v0,v0");
930 asm volatile ("lvlx v0,r0,r0");
932 asm volatile ("vor 0,0,0");
933 asm volatile ("lvlx 0,0,0");
942 # Return 1 if the target supports executing 64-bit instructions, 0
943 # otherwise. Cache the result.
945 proc check_effective_target_powerpc64 { } {
946 global powerpc64_available_saved
949 if [info exists powerpc64_available_saved] {
950 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
952 set powerpc64_available_saved 0
954 # Some simulators are known to not support powerpc64 instructions.
955 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
956 verbose "check_effective_target_powerpc64 returning 0" 2
957 return $powerpc64_available_saved
960 # Set up, compile, and execute a test program containing a 64-bit
961 # instruction. Include the current process ID in the file
962 # names to prevent conflicts with invocations for multiple
967 set f [open $src "w"]
968 puts $f "int main() {"
969 puts $f "#ifdef __MACH__"
970 puts $f " asm volatile (\"extsw r0,r0\");"
972 puts $f " asm volatile (\"extsw 0,0\");"
974 puts $f " return 0; }"
977 set opts "additional_flags=-mcpu=G5"
979 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
980 set lines [${tool}_target_compile $src $exe executable "$opts"]
983 if [string match "" $lines] then {
984 # No error message, compilation succeeded.
985 set result [${tool}_load "./$exe" "" ""]
986 set status [lindex $result 0]
987 remote_file build delete $exe
988 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
990 if { $status == "pass" } then {
991 set powerpc64_available_saved 1
994 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
998 return $powerpc64_available_saved
1001 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1002 # complex float arguments. This affects gfortran tests that call cabsf
1003 # in libm built by an earlier compiler. Return 1 if libm uses the same
1004 # argument passing as the compiler under test, 0 otherwise.
1006 # When the target name changes, replace the cached result.
1008 proc check_effective_target_broken_cplxf_arg { } {
1009 return [check_cached_effective_target broken_cplxf_arg {
1010 # Skip the work for targets known not to be affected.
1011 if { ![istarget powerpc64-*-linux*] } {
1013 } elseif { ![is-effective-target lp64] } {
1016 check_runtime_nocache broken_cplxf_arg {
1017 #include <complex.h>
1018 extern void abort (void);
1019 float fabsf (float);
1020 float cabsf (_Complex float);
1027 if (fabsf (f - 5.0) > 0.0001)
1036 proc check_alpha_max_hw_available { } {
1037 return [check_runtime alpha_max_hw_available {
1038 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1042 # Returns true iff the FUNCTION is available on the target system.
1043 # (This is essentially a Tcl implementation of Autoconf's
1046 proc check_function_available { function } {
1047 return [check_no_compiler_messages ${function}_available \
1053 int main () { $function (); }
1057 # Returns true iff "fork" is available on the target system.
1059 proc check_fork_available {} {
1060 return [check_function_available "fork"]
1063 # Returns true iff "mkfifo" is available on the target system.
1065 proc check_mkfifo_available {} {
1066 if {[istarget *-*-cygwin*]} {
1067 # Cygwin has mkfifo, but support is incomplete.
1071 return [check_function_available "mkfifo"]
1074 # Returns true iff "__cxa_atexit" is used on the target system.
1076 proc check_cxa_atexit_available { } {
1077 return [check_cached_effective_target cxa_atexit_available {
1078 if { [istarget "hppa*-*-hpux10*"] } {
1079 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1082 check_runtime_nocache cxa_atexit_available {
1085 static unsigned int count;
1102 Y() { f(); count = 2; }
1111 int main() { return 0; }
1118 # Return 1 if we're generating 32-bit code using default options, 0
1121 proc check_effective_target_ilp32 { } {
1122 return [check_no_compiler_messages ilp32 object {
1123 int dummy[sizeof (int) == 4
1124 && sizeof (void *) == 4
1125 && sizeof (long) == 4 ? 1 : -1];
1129 # Return 1 if we're generating 32-bit or larger integers using default
1130 # options, 0 otherwise.
1132 proc check_effective_target_int32plus { } {
1133 return [check_no_compiler_messages int32plus object {
1134 int dummy[sizeof (int) >= 4 ? 1 : -1];
1138 # Return 1 if we're generating 32-bit or larger pointers using default
1139 # options, 0 otherwise.
1141 proc check_effective_target_ptr32plus { } {
1142 return [check_no_compiler_messages ptr32plus object {
1143 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1147 # Return 1 if we support 32-bit or larger array and structure sizes
1148 # using default options, 0 otherwise.
1150 proc check_effective_target_size32plus { } {
1151 return [check_no_compiler_messages size32plus object {
1156 # Returns 1 if we're generating 16-bit or smaller integers with the
1157 # default options, 0 otherwise.
1159 proc check_effective_target_int16 { } {
1160 return [check_no_compiler_messages int16 object {
1161 int dummy[sizeof (int) < 4 ? 1 : -1];
1165 # Return 1 if we're generating 64-bit code using default options, 0
1168 proc check_effective_target_lp64 { } {
1169 return [check_no_compiler_messages lp64 object {
1170 int dummy[sizeof (int) == 4
1171 && sizeof (void *) == 8
1172 && sizeof (long) == 8 ? 1 : -1];
1176 # Return 1 if we're generating 64-bit code using default llp64 options,
1179 proc check_effective_target_llp64 { } {
1180 return [check_no_compiler_messages llp64 object {
1181 int dummy[sizeof (int) == 4
1182 && sizeof (void *) == 8
1183 && sizeof (long long) == 8
1184 && sizeof (long) == 4 ? 1 : -1];
1188 # Return 1 if the target supports long double larger than double,
1191 proc check_effective_target_large_long_double { } {
1192 return [check_no_compiler_messages large_long_double object {
1193 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1197 # Return 1 if the target supports compiling fixed-point,
1200 proc check_effective_target_fixed_point { } {
1201 return [check_no_compiler_messages fixed_point object {
1202 _Sat _Fract x; _Sat _Accum y;
1206 # Return 1 if the target supports compiling decimal floating point,
1209 proc check_effective_target_dfp_nocache { } {
1210 verbose "check_effective_target_dfp_nocache: compiling source" 2
1211 set ret [check_no_compiler_messages_nocache dfp object {
1212 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1214 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1218 proc check_effective_target_dfprt_nocache { } {
1219 return [check_runtime_nocache dfprt {
1220 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1221 int main () { z = x + y; return 0; }
1225 # Return 1 if the target supports compiling Decimal Floating Point,
1228 # This won't change for different subtargets so cache the result.
1230 proc check_effective_target_dfp { } {
1231 return [check_cached_effective_target dfp {
1232 check_effective_target_dfp_nocache
1236 # Return 1 if the target supports linking and executing Decimal Floating
1237 # Point, # 0 otherwise.
1239 # This won't change for different subtargets so cache the result.
1241 proc check_effective_target_dfprt { } {
1242 return [check_cached_effective_target dfprt {
1243 check_effective_target_dfprt_nocache
1247 # Return 1 if the target needs a command line argument to enable a SIMD
1250 proc check_effective_target_vect_cmdline_needed { } {
1251 global et_vect_cmdline_needed_saved
1252 global et_vect_cmdline_needed_target_name
1254 if { ![info exists et_vect_cmdline_needed_target_name] } {
1255 set et_vect_cmdline_needed_target_name ""
1258 # If the target has changed since we set the cached value, clear it.
1259 set current_target [current_target_name]
1260 if { $current_target != $et_vect_cmdline_needed_target_name } {
1261 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1262 set et_vect_cmdline_needed_target_name $current_target
1263 if { [info exists et_vect_cmdline_needed_saved] } {
1264 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1265 unset et_vect_cmdline_needed_saved
1269 if [info exists et_vect_cmdline_needed_saved] {
1270 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1272 set et_vect_cmdline_needed_saved 1
1273 if { [istarget ia64-*-*]
1274 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1275 && [check_effective_target_lp64])
1276 || ([istarget powerpc*-*-*]
1277 && ([check_effective_target_powerpc_spe]
1278 || [check_effective_target_powerpc_altivec]))
1279 || [istarget spu-*-*]
1280 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1281 set et_vect_cmdline_needed_saved 0
1285 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1286 return $et_vect_cmdline_needed_saved
1289 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1291 # This won't change for different subtargets so cache the result.
1293 proc check_effective_target_vect_int { } {
1294 global et_vect_int_saved
1296 if [info exists et_vect_int_saved] {
1297 verbose "check_effective_target_vect_int: using cached result" 2
1299 set et_vect_int_saved 0
1300 if { [istarget i?86-*-*]
1301 || ([istarget powerpc*-*-*]
1302 && ![istarget powerpc-*-linux*paired*])
1303 || [istarget spu-*-*]
1304 || [istarget x86_64-*-*]
1305 || [istarget sparc*-*-*]
1306 || [istarget alpha*-*-*]
1307 || [istarget ia64-*-*]
1308 || [check_effective_target_arm32] } {
1309 set et_vect_int_saved 1
1313 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1314 return $et_vect_int_saved
1317 # Return 1 if the target supports int->float conversion
1320 proc check_effective_target_vect_intfloat_cvt { } {
1321 global et_vect_intfloat_cvt_saved
1323 if [info exists et_vect_intfloat_cvt_saved] {
1324 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1326 set et_vect_intfloat_cvt_saved 0
1327 if { [istarget i?86-*-*]
1328 || ([istarget powerpc*-*-*]
1329 && ![istarget powerpc-*-linux*paired*])
1330 || [istarget x86_64-*-*] } {
1331 set et_vect_intfloat_cvt_saved 1
1335 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1336 return $et_vect_intfloat_cvt_saved
1340 # Return 1 if the target supports float->int conversion
1343 proc check_effective_target_vect_floatint_cvt { } {
1344 global et_vect_floatint_cvt_saved
1346 if [info exists et_vect_floatint_cvt_saved] {
1347 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1349 set et_vect_floatint_cvt_saved 0
1350 if { [istarget i?86-*-*]
1351 || ([istarget powerpc*-*-*]
1352 && ![istarget powerpc-*-linux*paired*])
1353 || [istarget x86_64-*-*] } {
1354 set et_vect_floatint_cvt_saved 1
1358 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1359 return $et_vect_floatint_cvt_saved
1362 # Return 1 is this is an arm target using 32-bit instructions
1363 proc check_effective_target_arm32 { } {
1364 return [check_no_compiler_messages arm32 assembly {
1365 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1371 # Return 1 if this is an ARM target supporting -mfpu=vfp
1372 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1375 proc check_effective_target_arm_vfp_ok { } {
1376 if { [check_effective_target_arm32] } {
1377 return [check_no_compiler_messages arm_vfp_ok object {
1379 } "-mfpu=vfp -mfloat-abi=softfp"]
1385 # Return 1 if this is an ARM target supporting -mfpu=neon
1386 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1389 proc check_effective_target_arm_neon_ok { } {
1390 if { [check_effective_target_arm32] } {
1391 return [check_no_compiler_messages arm_neon_ok object {
1393 } "-mfpu=neon -mfloat-abi=softfp"]
1399 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1402 proc check_effective_target_arm_thumb1_ok { } {
1403 return [check_no_compiler_messages arm_thumb1_ok assembly {
1404 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1410 # Return 1 if the target supports executing NEON instructions, 0
1411 # otherwise. Cache the result.
1413 proc check_effective_target_arm_neon_hw { } {
1414 return [check_runtime arm_neon_hw_available {
1418 long long a = 0, b = 1;
1419 asm ("vorr %P0, %P1, %P2"
1421 : "0" (a), "w" (b));
1424 } "-mfpu=neon -mfloat-abi=softfp"]
1427 # Return 1 if this is a ARM target with NEON enabled.
1429 proc check_effective_target_arm_neon { } {
1430 if { [check_effective_target_arm32] } {
1431 return [check_no_compiler_messages arm_neon object {
1432 #ifndef __ARM_NEON__
1443 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1444 # the Loongson vector modes.
1446 proc check_effective_target_mips_loongson { } {
1447 return [check_no_compiler_messages loongson assembly {
1448 #if !defined(__mips_loongson_vector_rev)
1454 # Return 1 if this is a PowerPC target with floating-point registers.
1456 proc check_effective_target_powerpc_fprs { } {
1457 if { [istarget powerpc*-*-*]
1458 || [istarget rs6000-*-*] } {
1459 return [check_no_compiler_messages powerpc_fprs object {
1471 # Return 1 if this is a PowerPC target with hardware double-precision
1474 proc check_effective_target_powerpc_hard_double { } {
1475 if { [istarget powerpc*-*-*]
1476 || [istarget rs6000-*-*] } {
1477 return [check_no_compiler_messages powerpc_hard_double object {
1489 # Return 1 if this is a PowerPC target supporting -maltivec.
1491 proc check_effective_target_powerpc_altivec_ok { } {
1492 if { ([istarget powerpc*-*-*]
1493 && ![istarget powerpc-*-linux*paired*])
1494 || [istarget rs6000-*-*] } {
1495 # AltiVec is not supported on AIX before 5.3.
1496 if { [istarget powerpc*-*-aix4*]
1497 || [istarget powerpc*-*-aix5.1*]
1498 || [istarget powerpc*-*-aix5.2*] } {
1501 return [check_no_compiler_messages powerpc_altivec_ok object {
1509 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1511 proc check_effective_target_powerpc_ppu_ok { } {
1512 if [check_effective_target_powerpc_altivec_ok] {
1513 return [check_no_compiler_messages cell_asm_available object {
1516 asm volatile ("lvlx v0,v0,v0");
1518 asm volatile ("lvlx 0,0,0");
1528 # Return 1 if this is a PowerPC target that supports SPU.
1530 proc check_effective_target_powerpc_spu { } {
1531 if [istarget powerpc*-*-linux*] {
1532 return [check_effective_target_powerpc_altivec_ok]
1538 # Return 1 if this is a PowerPC SPE target. The check includes options
1539 # specified by dg-options for this test, so don't cache the result.
1541 proc check_effective_target_powerpc_spe_nocache { } {
1542 if { [istarget powerpc*-*-*] } {
1543 return [check_no_compiler_messages_nocache powerpc_spe object {
1549 } [current_compiler_flags]]
1555 # Return 1 if this is a PowerPC target with SPE enabled.
1557 proc check_effective_target_powerpc_spe { } {
1558 if { [istarget powerpc*-*-*] } {
1559 return [check_no_compiler_messages powerpc_spe object {
1571 # Return 1 if this is a PowerPC target with Altivec enabled.
1573 proc check_effective_target_powerpc_altivec { } {
1574 if { [istarget powerpc*-*-*] } {
1575 return [check_no_compiler_messages powerpc_altivec object {
1587 # Return 1 if this is a PowerPC 405 target. The check includes options
1588 # specified by dg-options for this test, so don't cache the result.
1590 proc check_effective_target_powerpc_405_nocache { } {
1591 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
1592 return [check_no_compiler_messages_nocache powerpc_405 object {
1598 } [current_compiler_flags]]
1604 # Return 1 if this is a SPU target with a toolchain that
1605 # supports automatic overlay generation.
1607 proc check_effective_target_spu_auto_overlay { } {
1608 if { [istarget spu*-*-elf*] } {
1609 return [check_no_compiler_messages spu_auto_overlay executable {
1611 } "-Wl,--auto-overlay" ]
1617 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1618 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1619 # test environment appears to run executables on such a simulator.
1621 proc check_effective_target_ultrasparc_hw { } {
1622 return [check_runtime ultrasparc_hw {
1623 int main() { return 0; }
1624 } "-mcpu=ultrasparc"]
1627 # Return 1 if the target supports hardware vector shift operation.
1629 proc check_effective_target_vect_shift { } {
1630 global et_vect_shift_saved
1632 if [info exists et_vect_shift_saved] {
1633 verbose "check_effective_target_vect_shift: using cached result" 2
1635 set et_vect_shift_saved 0
1636 if { ([istarget powerpc*-*-*]
1637 && ![istarget powerpc-*-linux*paired*])
1638 || [istarget ia64-*-*]
1639 || [istarget i?86-*-*]
1640 || [istarget x86_64-*-*]
1641 || [check_effective_target_arm32] } {
1642 set et_vect_shift_saved 1
1646 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1647 return $et_vect_shift_saved
1650 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1652 # This can change for different subtargets so do not cache the result.
1654 proc check_effective_target_vect_long { } {
1655 if { [istarget i?86-*-*]
1656 || (([istarget powerpc*-*-*]
1657 && ![istarget powerpc-*-linux*paired*])
1658 && [check_effective_target_ilp32])
1659 || [istarget x86_64-*-*]
1660 || [check_effective_target_arm32]
1661 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1667 verbose "check_effective_target_vect_long: returning $answer" 2
1671 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1673 # This won't change for different subtargets so cache the result.
1675 proc check_effective_target_vect_float { } {
1676 global et_vect_float_saved
1678 if [info exists et_vect_float_saved] {
1679 verbose "check_effective_target_vect_float: using cached result" 2
1681 set et_vect_float_saved 0
1682 if { [istarget i?86-*-*]
1683 || [istarget powerpc*-*-*]
1684 || [istarget spu-*-*]
1685 || [istarget mipsisa64*-*-*]
1686 || [istarget x86_64-*-*]
1687 || [istarget ia64-*-*]
1688 || [check_effective_target_arm32] } {
1689 set et_vect_float_saved 1
1693 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1694 return $et_vect_float_saved
1697 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1699 # This won't change for different subtargets so cache the result.
1701 proc check_effective_target_vect_double { } {
1702 global et_vect_double_saved
1704 if [info exists et_vect_double_saved] {
1705 verbose "check_effective_target_vect_double: using cached result" 2
1707 set et_vect_double_saved 0
1708 if { [istarget i?86-*-*]
1709 || [istarget x86_64-*-*]
1710 || [istarget spu-*-*] } {
1711 set et_vect_double_saved 1
1715 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1716 return $et_vect_double_saved
1719 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
1721 # This won't change for different subtargets so cache the result.
1723 proc check_effective_target_vect_long_long { } {
1724 global et_vect_long_long_saved
1726 if [info exists et_vect_long_long_saved] {
1727 verbose "check_effective_target_vect_long_long: using cached result" 2
1729 set et_vect_long_long_saved 0
1730 if { [istarget i?86-*-*]
1731 || [istarget x86_64-*-*] } {
1732 set et_vect_long_long_saved 1
1736 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
1737 return $et_vect_long_long_saved
1741 # Return 1 if the target plus current options does not support a vector
1742 # max instruction on "int", 0 otherwise.
1744 # This won't change for different subtargets so cache the result.
1746 proc check_effective_target_vect_no_int_max { } {
1747 global et_vect_no_int_max_saved
1749 if [info exists et_vect_no_int_max_saved] {
1750 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1752 set et_vect_no_int_max_saved 0
1753 if { [istarget sparc*-*-*]
1754 || [istarget spu-*-*]
1755 || [istarget alpha*-*-*] } {
1756 set et_vect_no_int_max_saved 1
1759 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1760 return $et_vect_no_int_max_saved
1763 # Return 1 if the target plus current options does not support a vector
1764 # add instruction on "int", 0 otherwise.
1766 # This won't change for different subtargets so cache the result.
1768 proc check_effective_target_vect_no_int_add { } {
1769 global et_vect_no_int_add_saved
1771 if [info exists et_vect_no_int_add_saved] {
1772 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1774 set et_vect_no_int_add_saved 0
1775 # Alpha only supports vector add on V8QI and V4HI.
1776 if { [istarget alpha*-*-*] } {
1777 set et_vect_no_int_add_saved 1
1780 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1781 return $et_vect_no_int_add_saved
1784 # Return 1 if the target plus current options does not support vector
1785 # bitwise instructions, 0 otherwise.
1787 # This won't change for different subtargets so cache the result.
1789 proc check_effective_target_vect_no_bitwise { } {
1790 global et_vect_no_bitwise_saved
1792 if [info exists et_vect_no_bitwise_saved] {
1793 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1795 set et_vect_no_bitwise_saved 0
1797 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1798 return $et_vect_no_bitwise_saved
1801 # Return 1 if the target plus current options supports vector permutation,
1804 # This won't change for different subtargets so cache the result.
1806 proc check_effective_target_vect_perm { } {
1809 if [info exists et_vect_perm_saved] {
1810 verbose "check_effective_target_vect_perm: using cached result" 2
1812 set et_vect_perm_saved 0
1813 if { [istarget powerpc*-*-*]
1814 || [istarget spu-*-*] } {
1815 set et_vect_perm_saved 1
1818 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
1819 return $et_vect_perm_saved
1823 # Return 1 if the target plus current options supports a vector
1824 # widening summation of *short* args into *int* result, 0 otherwise.
1825 # A target can also support this widening summation if it can support
1826 # promotion (unpacking) from shorts to ints.
1828 # This won't change for different subtargets so cache the result.
1830 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1831 global et_vect_widen_sum_hi_to_si
1833 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1834 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1836 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1837 if { [istarget powerpc*-*-*]
1838 || [istarget ia64-*-*] } {
1839 set et_vect_widen_sum_hi_to_si_saved 1
1842 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1843 return $et_vect_widen_sum_hi_to_si_saved
1846 # Return 1 if the target plus current options supports a vector
1847 # widening summation of *char* args into *short* result, 0 otherwise.
1848 # A target can also support this widening summation if it can support
1849 # promotion (unpacking) from chars to shorts.
1851 # This won't change for different subtargets so cache the result.
1853 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1854 global et_vect_widen_sum_qi_to_hi
1856 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1857 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1859 set et_vect_widen_sum_qi_to_hi_saved 0
1860 if { [check_effective_target_vect_unpack]
1861 || [istarget ia64-*-*] } {
1862 set et_vect_widen_sum_qi_to_hi_saved 1
1865 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1866 return $et_vect_widen_sum_qi_to_hi_saved
1869 # Return 1 if the target plus current options supports a vector
1870 # widening summation of *char* args into *int* result, 0 otherwise.
1872 # This won't change for different subtargets so cache the result.
1874 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1875 global et_vect_widen_sum_qi_to_si
1877 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1878 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1880 set et_vect_widen_sum_qi_to_si_saved 0
1881 if { [istarget powerpc*-*-*] } {
1882 set et_vect_widen_sum_qi_to_si_saved 1
1885 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1886 return $et_vect_widen_sum_qi_to_si_saved
1889 # Return 1 if the target plus current options supports a vector
1890 # widening multiplication of *char* args into *short* result, 0 otherwise.
1891 # A target can also support this widening multplication if it can support
1892 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1893 # multiplication of shorts).
1895 # This won't change for different subtargets so cache the result.
1898 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1899 global et_vect_widen_mult_qi_to_hi
1901 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1902 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1904 if { [check_effective_target_vect_unpack]
1905 && [check_effective_target_vect_short_mult] } {
1906 set et_vect_widen_mult_qi_to_hi_saved 1
1908 set et_vect_widen_mult_qi_to_hi_saved 0
1910 if { [istarget powerpc*-*-*] } {
1911 set et_vect_widen_mult_qi_to_hi_saved 1
1914 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1915 return $et_vect_widen_mult_qi_to_hi_saved
1918 # Return 1 if the target plus current options supports a vector
1919 # widening multiplication of *short* args into *int* result, 0 otherwise.
1920 # A target can also support this widening multplication if it can support
1921 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1922 # multiplication of ints).
1924 # This won't change for different subtargets so cache the result.
1927 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1928 global et_vect_widen_mult_hi_to_si
1930 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1931 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1933 if { [check_effective_target_vect_unpack]
1934 && [check_effective_target_vect_int_mult] } {
1935 set et_vect_widen_mult_hi_to_si_saved 1
1937 set et_vect_widen_mult_hi_to_si_saved 0
1939 if { [istarget powerpc*-*-*]
1940 || [istarget spu-*-*]
1941 || [istarget i?86-*-*]
1942 || [istarget x86_64-*-*] } {
1943 set et_vect_widen_mult_hi_to_si_saved 1
1946 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1947 return $et_vect_widen_mult_hi_to_si_saved
1950 # Return 1 if the target plus current options supports a vector
1951 # dot-product of signed chars, 0 otherwise.
1953 # This won't change for different subtargets so cache the result.
1955 proc check_effective_target_vect_sdot_qi { } {
1956 global et_vect_sdot_qi
1958 if [info exists et_vect_sdot_qi_saved] {
1959 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1961 set et_vect_sdot_qi_saved 0
1963 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1964 return $et_vect_sdot_qi_saved
1967 # Return 1 if the target plus current options supports a vector
1968 # dot-product of unsigned chars, 0 otherwise.
1970 # This won't change for different subtargets so cache the result.
1972 proc check_effective_target_vect_udot_qi { } {
1973 global et_vect_udot_qi
1975 if [info exists et_vect_udot_qi_saved] {
1976 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1978 set et_vect_udot_qi_saved 0
1979 if { [istarget powerpc*-*-*] } {
1980 set et_vect_udot_qi_saved 1
1983 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1984 return $et_vect_udot_qi_saved
1987 # Return 1 if the target plus current options supports a vector
1988 # dot-product of signed shorts, 0 otherwise.
1990 # This won't change for different subtargets so cache the result.
1992 proc check_effective_target_vect_sdot_hi { } {
1993 global et_vect_sdot_hi
1995 if [info exists et_vect_sdot_hi_saved] {
1996 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1998 set et_vect_sdot_hi_saved 0
1999 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2000 || [istarget i?86-*-*]
2001 || [istarget x86_64-*-*] } {
2002 set et_vect_sdot_hi_saved 1
2005 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2006 return $et_vect_sdot_hi_saved
2009 # Return 1 if the target plus current options supports a vector
2010 # dot-product of unsigned shorts, 0 otherwise.
2012 # This won't change for different subtargets so cache the result.
2014 proc check_effective_target_vect_udot_hi { } {
2015 global et_vect_udot_hi
2017 if [info exists et_vect_udot_hi_saved] {
2018 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2020 set et_vect_udot_hi_saved 0
2021 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2022 set et_vect_udot_hi_saved 1
2025 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2026 return $et_vect_udot_hi_saved
2030 # Return 1 if the target plus current options supports a vector
2031 # demotion (packing) of shorts (to chars) and ints (to shorts)
2032 # using modulo arithmetic, 0 otherwise.
2034 # This won't change for different subtargets so cache the result.
2036 proc check_effective_target_vect_pack_trunc { } {
2037 global et_vect_pack_trunc
2039 if [info exists et_vect_pack_trunc_saved] {
2040 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2042 set et_vect_pack_trunc_saved 0
2043 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2044 || [istarget i?86-*-*]
2045 || [istarget x86_64-*-*]
2046 || [istarget spu-*-*] } {
2047 set et_vect_pack_trunc_saved 1
2050 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2051 return $et_vect_pack_trunc_saved
2054 # Return 1 if the target plus current options supports a vector
2055 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2057 # This won't change for different subtargets so cache the result.
2059 proc check_effective_target_vect_unpack { } {
2060 global et_vect_unpack
2062 if [info exists et_vect_unpack_saved] {
2063 verbose "check_effective_target_vect_unpack: using cached result" 2
2065 set et_vect_unpack_saved 0
2066 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2067 || [istarget i?86-*-*]
2068 || [istarget x86_64-*-*]
2069 || [istarget spu-*-*] } {
2070 set et_vect_unpack_saved 1
2073 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2074 return $et_vect_unpack_saved
2077 # Return 1 if the target plus current options does not guarantee
2078 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2080 # This won't change for different subtargets so cache the result.
2082 proc check_effective_target_unaligned_stack { } {
2083 global et_unaligned_stack_saved
2085 if [info exists et_unaligned_stack_saved] {
2086 verbose "check_effective_target_unaligned_stack: using cached result" 2
2088 set et_unaligned_stack_saved 0
2090 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2091 return $et_unaligned_stack_saved
2094 # Return 1 if the target plus current options does not support a vector
2095 # alignment mechanism, 0 otherwise.
2097 # This won't change for different subtargets so cache the result.
2099 proc check_effective_target_vect_no_align { } {
2100 global et_vect_no_align_saved
2102 if [info exists et_vect_no_align_saved] {
2103 verbose "check_effective_target_vect_no_align: using cached result" 2
2105 set et_vect_no_align_saved 0
2106 if { [istarget mipsisa64*-*-*]
2107 || [istarget sparc*-*-*]
2108 || [istarget ia64-*-*]
2109 || [check_effective_target_arm32] } {
2110 set et_vect_no_align_saved 1
2113 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2114 return $et_vect_no_align_saved
2117 # Return 1 if arrays are aligned to the vector alignment
2118 # boundary, 0 otherwise.
2120 # This won't change for different subtargets so cache the result.
2122 proc check_effective_target_vect_aligned_arrays { } {
2123 global et_vect_aligned_arrays
2125 if [info exists et_vect_aligned_arrays_saved] {
2126 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2128 set et_vect_aligned_arrays_saved 0
2129 if { (([istarget x86_64-*-*]
2130 || [istarget i?86-*-*]) && [is-effective-target lp64])
2131 || [istarget spu-*-*] } {
2132 set et_vect_aligned_arrays_saved 1
2135 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2136 return $et_vect_aligned_arrays_saved
2139 # Return 1 if types of size 32 bit or less are naturally aligned
2140 # (aligned to their type-size), 0 otherwise.
2142 # This won't change for different subtargets so cache the result.
2144 proc check_effective_target_natural_alignment_32 { } {
2145 global et_natural_alignment_32
2147 if [info exists et_natural_alignment_32_saved] {
2148 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2150 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2151 set et_natural_alignment_32_saved 1
2152 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2153 set et_natural_alignment_32_saved 0
2156 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2157 return $et_natural_alignment_32_saved
2160 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2161 # type-size), 0 otherwise.
2163 # This won't change for different subtargets so cache the result.
2165 proc check_effective_target_natural_alignment_64 { } {
2166 global et_natural_alignment_64
2168 if [info exists et_natural_alignment_64_saved] {
2169 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2171 set et_natural_alignment_64_saved 0
2172 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2173 || [istarget spu-*-*] } {
2174 set et_natural_alignment_64_saved 1
2177 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2178 return $et_natural_alignment_64_saved
2181 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2183 # This won't change for different subtargets so cache the result.
2185 proc check_effective_target_vector_alignment_reachable { } {
2186 global et_vector_alignment_reachable
2188 if [info exists et_vector_alignment_reachable_saved] {
2189 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2191 if { [check_effective_target_vect_aligned_arrays]
2192 || [check_effective_target_natural_alignment_32] } {
2193 set et_vector_alignment_reachable_saved 1
2195 set et_vector_alignment_reachable_saved 0
2198 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2199 return $et_vector_alignment_reachable_saved
2202 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2204 # This won't change for different subtargets so cache the result.
2206 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2207 global et_vector_alignment_reachable_for_64bit
2209 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2210 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2212 if { [check_effective_target_vect_aligned_arrays]
2213 || [check_effective_target_natural_alignment_64] } {
2214 set et_vector_alignment_reachable_for_64bit_saved 1
2216 set et_vector_alignment_reachable_for_64bit_saved 0
2219 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2220 return $et_vector_alignment_reachable_for_64bit_saved
2223 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2225 proc check_effective_target_vect_condition { } {
2226 global et_vect_cond_saved
2228 if [info exists et_vect_cond_saved] {
2229 verbose "check_effective_target_vect_cond: using cached result" 2
2231 set et_vect_cond_saved 0
2232 if { [istarget powerpc*-*-*]
2233 || [istarget ia64-*-*]
2234 || [istarget i?86-*-*]
2235 || [istarget spu-*-*]
2236 || [istarget x86_64-*-*] } {
2237 set et_vect_cond_saved 1
2241 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2242 return $et_vect_cond_saved
2245 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2247 proc check_effective_target_vect_char_mult { } {
2248 global et_vect_char_mult_saved
2250 if [info exists et_vect_char_mult_saved] {
2251 verbose "check_effective_target_vect_char_mult: using cached result" 2
2253 set et_vect_char_mult_saved 0
2254 if { [istarget ia64-*-*]
2255 || [istarget i?86-*-*]
2256 || [istarget x86_64-*-*] } {
2257 set et_vect_char_mult_saved 1
2261 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2262 return $et_vect_char_mult_saved
2265 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2267 proc check_effective_target_vect_short_mult { } {
2268 global et_vect_short_mult_saved
2270 if [info exists et_vect_short_mult_saved] {
2271 verbose "check_effective_target_vect_short_mult: using cached result" 2
2273 set et_vect_short_mult_saved 0
2274 if { [istarget ia64-*-*]
2275 || [istarget spu-*-*]
2276 || [istarget i?86-*-*]
2277 || [istarget x86_64-*-*]
2278 || [istarget powerpc*-*-*] } {
2279 set et_vect_short_mult_saved 1
2283 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2284 return $et_vect_short_mult_saved
2287 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2289 proc check_effective_target_vect_int_mult { } {
2290 global et_vect_int_mult_saved
2292 if [info exists et_vect_int_mult_saved] {
2293 verbose "check_effective_target_vect_int_mult: using cached result" 2
2295 set et_vect_int_mult_saved 0
2296 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2297 || [istarget spu-*-*]
2298 || [istarget i?86-*-*]
2299 || [istarget x86_64-*-*]
2300 || [check_effective_target_arm32] } {
2301 set et_vect_int_mult_saved 1
2305 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2306 return $et_vect_int_mult_saved
2309 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2311 proc check_effective_target_vect_extract_even_odd { } {
2312 global et_vect_extract_even_odd_saved
2314 if [info exists et_vect_extract_even_odd_saved] {
2315 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2317 set et_vect_extract_even_odd_saved 0
2318 if { [istarget powerpc*-*-*]
2319 || [istarget spu-*-*] } {
2320 set et_vect_extract_even_odd_saved 1
2324 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2325 return $et_vect_extract_even_odd_saved
2328 # Return 1 if the target supports vector even/odd elements extraction of
2329 # vectors with SImode elements or larger, 0 otherwise.
2331 proc check_effective_target_vect_extract_even_odd_wide { } {
2332 global et_vect_extract_even_odd_wide_saved
2334 if [info exists et_vect_extract_even_odd_wide_saved] {
2335 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2337 set et_vect_extract_even_odd_wide_saved 0
2338 if { [istarget powerpc*-*-*]
2339 || [istarget i?86-*-*]
2340 || [istarget x86_64-*-*]
2341 || [istarget spu-*-*] } {
2342 set et_vect_extract_even_odd_wide_saved 1
2346 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2347 return $et_vect_extract_even_odd_wide_saved
2350 # Return 1 if the target supports vector interleaving, 0 otherwise.
2352 proc check_effective_target_vect_interleave { } {
2353 global et_vect_interleave_saved
2355 if [info exists et_vect_interleave_saved] {
2356 verbose "check_effective_target_vect_interleave: using cached result" 2
2358 set et_vect_interleave_saved 0
2359 if { [istarget powerpc*-*-*]
2360 || [istarget i?86-*-*]
2361 || [istarget x86_64-*-*]
2362 || [istarget spu-*-*] } {
2363 set et_vect_interleave_saved 1
2367 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2368 return $et_vect_interleave_saved
2371 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2372 proc check_effective_target_vect_strided { } {
2373 global et_vect_strided_saved
2375 if [info exists et_vect_strided_saved] {
2376 verbose "check_effective_target_vect_strided: using cached result" 2
2378 set et_vect_strided_saved 0
2379 if { [check_effective_target_vect_interleave]
2380 && [check_effective_target_vect_extract_even_odd] } {
2381 set et_vect_strided_saved 1
2385 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2386 return $et_vect_strided_saved
2389 # Return 1 if the target supports vector interleaving and extract even/odd
2390 # for wide element types, 0 otherwise.
2391 proc check_effective_target_vect_strided_wide { } {
2392 global et_vect_strided_wide_saved
2394 if [info exists et_vect_strided_wide_saved] {
2395 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2397 set et_vect_strided_wide_saved 0
2398 if { [check_effective_target_vect_interleave]
2399 && [check_effective_target_vect_extract_even_odd_wide] } {
2400 set et_vect_strided_wide_saved 1
2404 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2405 return $et_vect_strided_wide_saved
2408 # Return 1 if the target supports section-anchors
2410 proc check_effective_target_section_anchors { } {
2411 global et_section_anchors_saved
2413 if [info exists et_section_anchors_saved] {
2414 verbose "check_effective_target_section_anchors: using cached result" 2
2416 set et_section_anchors_saved 0
2417 if { [istarget powerpc*-*-*] } {
2418 set et_section_anchors_saved 1
2422 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2423 return $et_section_anchors_saved
2426 # Return 1 if the target supports atomic operations on "int" and "long".
2428 proc check_effective_target_sync_int_long { } {
2429 global et_sync_int_long_saved
2431 if [info exists et_sync_int_long_saved] {
2432 verbose "check_effective_target_sync_int_long: using cached result" 2
2434 set et_sync_int_long_saved 0
2435 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2436 # load-reserved/store-conditional instructions.
2437 if { [istarget ia64-*-*]
2438 || [istarget i?86-*-*]
2439 || [istarget x86_64-*-*]
2440 || [istarget alpha*-*-*]
2441 || [istarget s390*-*-*]
2442 || [istarget powerpc*-*-*]
2443 || [istarget sparc64-*-*]
2444 || [istarget sparcv9-*-*]
2445 || [istarget mips*-*-*] } {
2446 set et_sync_int_long_saved 1
2450 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2451 return $et_sync_int_long_saved
2454 # Return 1 if the target supports atomic operations on "char" and "short".
2456 proc check_effective_target_sync_char_short { } {
2457 global et_sync_char_short_saved
2459 if [info exists et_sync_char_short_saved] {
2460 verbose "check_effective_target_sync_char_short: using cached result" 2
2462 set et_sync_char_short_saved 0
2463 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2464 # load-reserved/store-conditional instructions.
2465 if { [istarget ia64-*-*]
2466 || [istarget i?86-*-*]
2467 || [istarget x86_64-*-*]
2468 || [istarget alpha*-*-*]
2469 || [istarget s390*-*-*]
2470 || [istarget powerpc*-*-*]
2471 || [istarget sparc64-*-*]
2472 || [istarget sparcv9-*-*]
2473 || [istarget mips*-*-*] } {
2474 set et_sync_char_short_saved 1
2478 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2479 return $et_sync_char_short_saved
2482 # Return 1 if the target uses a ColdFire FPU.
2484 proc check_effective_target_coldfire_fpu { } {
2485 return [check_no_compiler_messages coldfire_fpu assembly {
2492 # Return true if this is a uClibc target.
2494 proc check_effective_target_uclibc {} {
2495 return [check_no_compiler_messages uclibc object {
2496 #include <features.h>
2497 #if !defined (__UCLIBC__)
2503 # Return true if this is a uclibc target and if the uclibc feature
2504 # described by __$feature__ is not present.
2506 proc check_missing_uclibc_feature {feature} {
2507 return [check_no_compiler_messages $feature object "
2508 #include <features.h>
2509 #if !defined (__UCLIBC) || defined (__${feature}__)
2515 # Return true if this is a Newlib target.
2517 proc check_effective_target_newlib {} {
2518 return [check_no_compiler_messages newlib object {
2524 # (a) an error of a few ULP is expected in string to floating-point
2525 # conversion functions; and
2526 # (b) overflow is not always detected correctly by those functions.
2528 proc check_effective_target_lax_strtofp {} {
2529 # By default, assume that all uClibc targets suffer from this.
2530 return [check_effective_target_uclibc]
2533 # Return 1 if this is a target for which wcsftime is a dummy
2534 # function that always returns 0.
2536 proc check_effective_target_dummy_wcsftime {} {
2537 # By default, assume that all uClibc targets suffer from this.
2538 return [check_effective_target_uclibc]
2541 # Return 1 if constructors with initialization priority arguments are
2542 # supposed on this target.
2544 proc check_effective_target_init_priority {} {
2545 return [check_no_compiler_messages init_priority assembly "
2546 void f() __attribute__((constructor (1000)));
2551 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2552 # This can be used with any check_* proc that takes no argument and
2553 # returns only 1 or 0. It could be used with check_* procs that take
2554 # arguments with keywords that pass particular arguments.
2556 proc is-effective-target { arg } {
2558 if { [info procs check_effective_target_${arg}] != [list] } {
2559 set selected [check_effective_target_${arg}]
2562 "vmx_hw" { set selected [check_vmx_hw_available] }
2563 "named_sections" { set selected [check_named_sections_available] }
2564 "gc_sections" { set selected [check_gc_sections_available] }
2565 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2566 default { error "unknown effective target keyword `$arg'" }
2569 verbose "is-effective-target: $arg $selected" 2
2573 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2575 proc is-effective-target-keyword { arg } {
2576 if { [info procs check_effective_target_${arg}] != [list] } {
2579 # These have different names for their check_* procs.
2581 "vmx_hw" { return 1 }
2582 "named_sections" { return 1 }
2583 "gc_sections" { return 1 }
2584 "cxa_atexit" { return 1 }
2585 default { return 0 }
2590 # Return 1 if target default to short enums
2592 proc check_effective_target_short_enums { } {
2593 return [check_no_compiler_messages short_enums assembly {
2595 int s[sizeof (enum foo) == 1 ? 1 : -1];
2599 # Return 1 if target supports merging string constants at link time.
2601 proc check_effective_target_string_merging { } {
2602 return [check_no_messages_and_pattern string_merging \
2603 "rodata\\.str" assembly {
2604 const char *var = "String";
2608 # Return 1 if target has the basic signed and unsigned types in
2609 # <stdint.h>, 0 otherwise.
2611 proc check_effective_target_stdint_types { } {
2612 return [check_no_compiler_messages stdint_types assembly {
2614 int8_t a; int16_t b; int32_t c; int64_t d;
2615 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2619 # Return 1 if programs are intended to be run on a simulator
2620 # (i.e. slowly) rather than hardware (i.e. fast).
2622 proc check_effective_target_simulator { } {
2624 # All "src/sim" simulators set this one.
2625 if [board_info target exists is_simulator] {
2626 return [board_info target is_simulator]
2629 # The "sid" simulators don't set that one, but at least they set
2631 if [board_info target exists slow_simulator] {
2632 return [board_info target slow_simulator]
2638 # Return 1 if the target is a VxWorks kernel.
2640 proc check_effective_target_vxworks_kernel { } {
2641 return [check_no_compiler_messages vxworks_kernel assembly {
2642 #if !defined __vxworks || defined __RTP__
2648 # Return 1 if the target is a VxWorks RTP.
2650 proc check_effective_target_vxworks_rtp { } {
2651 return [check_no_compiler_messages vxworks_rtp assembly {
2652 #if !defined __vxworks || !defined __RTP__
2658 # Return 1 if the target is expected to provide wide character support.
2660 proc check_effective_target_wchar { } {
2661 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2664 return [check_no_compiler_messages wchar assembly {
2669 # Return 1 if the target has <pthread.h>.
2671 proc check_effective_target_pthread_h { } {
2672 return [check_no_compiler_messages pthread_h assembly {
2673 #include <pthread.h>
2677 # Return 1 if the target can truncate a file from a file-descriptor,
2678 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2679 # chsize. We test for a trivially functional truncation; no stubs.
2680 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2681 # different function to be used.
2683 proc check_effective_target_fd_truncate { } {
2685 #define _FILE_OFFSET_BITS 64
2691 FILE *f = fopen ("tst.tmp", "wb");
2693 const char t[] = "test writing more than ten characters";
2696 write (fd, t, sizeof (t) - 1);
2698 if (ftruncate (fd, 10) != 0)
2701 f = fopen ("tst.tmp", "rb");
2702 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2708 if { [check_runtime ftruncate $prog] } {
2712 regsub "ftruncate" $prog "chsize" prog
2713 return [check_runtime chsize $prog]
2716 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2718 proc add_options_for_c99_runtime { flags } {
2719 if { [istarget *-*-solaris2*] } {
2720 return "$flags -std=c99"
2722 if { [istarget powerpc-*-darwin*] } {
2723 return "$flags -mmacosx-version-min=10.3"
2728 # Return 1 if the target provides a full C99 runtime.
2730 proc check_effective_target_c99_runtime { } {
2731 return [check_cached_effective_target c99_runtime {
2734 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2735 set contents [read $file]
2738 #ifndef HAVE_C99_RUNTIME
2742 check_no_compiler_messages_nocache c99_runtime assembly \
2743 $contents [add_options_for_c99_runtime ""]
2747 # Return 1 if target wchar_t is at least 4 bytes.
2749 proc check_effective_target_4byte_wchar_t { } {
2750 return [check_no_compiler_messages 4byte_wchar_t object {
2751 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
2755 # Return 1 if the target supports automatic stack alignment.
2757 proc check_effective_target_automatic_stack_alignment { } {
2758 if { [istarget i?86*-*-*]
2759 || [istarget x86_64-*-*] } then {
2766 # Return 1 if avx instructions can be compiled.
2768 proc check_effective_target_avx { } {
2769 return [check_no_compiler_messages avx object {
2770 void _mm256_zeroall (void)
2772 __builtin_ia32_vzeroall ();
2777 # Return 1 if C wchar_t type is compatible with char16_t.
2779 proc check_effective_target_wchar_t_char16_t_compatible { } {
2780 return [check_no_compiler_messages wchar_t_char16_t object {
2782 __CHAR16_TYPE__ *p16 = &wc;
2783 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2787 # Return 1 if C wchar_t type is compatible with char32_t.
2789 proc check_effective_target_wchar_t_char32_t_compatible { } {
2790 return [check_no_compiler_messages wchar_t_char32_t object {
2792 __CHAR32_TYPE__ *p32 = &wc;
2793 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2797 # Return 1 if pow10 function exists.
2799 proc check_effective_target_pow10 { } {
2800 return [check_runtime pow10 {
2810 # Return 1 if current options generate DFP instructions, 0 otherwise.
2812 proc check_effective_target_hard_dfp {} {
2813 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
2815 void foo (void) { z = x + y; }
2819 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
2820 # for strchr etc. functions.
2822 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
2823 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
2826 #if !defined(__cplusplus) \
2827 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
2828 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
2829 ISO C++ correct string.h and wchar.h protos not supported.