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 proc check_effective_target_tls {} {
549 return [check_no_compiler_messages tls assembly {
551 int f (void) { return i; }
552 void g (int j) { i = j; }
556 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
558 proc check_effective_target_tls_native {} {
559 # VxWorks uses emulated TLS machinery, but with non-standard helper
560 # functions, so we fail to automatically detect it.
561 global target_triplet
562 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
566 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
568 int f (void) { return i; }
569 void g (int j) { i = j; }
573 # Return 1 if TLS executables can run correctly, 0 otherwise.
575 proc check_effective_target_tls_runtime {} {
576 return [check_runtime tls_runtime {
577 __thread int thr = 0;
578 int main (void) { return thr; }
582 # Return 1 if compilation with -fgraphite is error-free for trivial
585 proc check_effective_target_fgraphite {} {
586 return [check_no_compiler_messages fgraphite object {
591 # Return 1 if compilation with -fopenmp is error-free for trivial
594 proc check_effective_target_fopenmp {} {
595 return [check_no_compiler_messages fopenmp object {
600 # Return 1 if compilation with -pthread is error-free for trivial
603 proc check_effective_target_pthread {} {
604 return [check_no_compiler_messages pthread object {
609 # Return 1 if the target supports -fstack-protector
610 proc check_effective_target_fstack_protector {} {
611 return [check_runtime fstack_protector {
612 int main (void) { return 0; }
613 } "-fstack-protector"]
616 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
617 # for trivial code, 0 otherwise.
619 proc check_effective_target_freorder {} {
620 return [check_no_compiler_messages freorder object {
622 } "-freorder-blocks-and-partition"]
625 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
626 # emitted, 0 otherwise. Whether a shared library can actually be built is
627 # out of scope for this test.
629 proc check_effective_target_fpic { } {
630 # Note that M68K has a multilib that supports -fpic but not
631 # -fPIC, so we need to check both. We test with a program that
632 # requires GOT references.
633 foreach arg {fpic fPIC} {
634 if [check_no_compiler_messages $arg object {
635 extern int foo (void); extern int bar;
636 int baz (void) { return foo () + bar; }
644 # Return true if the target supports -mpaired-single (as used on MIPS).
646 proc check_effective_target_mpaired_single { } {
647 return [check_no_compiler_messages mpaired_single object {
652 # Return true if the target has access to FPU instructions.
654 proc check_effective_target_hard_float { } {
655 if { [istarget mips*-*-*] } {
656 return [check_no_compiler_messages hard_float assembly {
657 #if (defined __mips_soft_float || defined __mips16)
663 # The generic test equates hard_float with "no call for adding doubles".
664 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
665 double a (double b, double c) { return b + c; }
669 # Return true if the target is a 64-bit MIPS target.
671 proc check_effective_target_mips64 { } {
672 return [check_no_compiler_messages mips64 assembly {
679 # Return true if the target is a MIPS target that does not produce
682 proc check_effective_target_nomips16 { } {
683 return [check_no_compiler_messages nomips16 object {
687 /* A cheap way of testing for -mflip-mips16. */
688 void foo (void) { asm ("addiu $20,$20,1"); }
689 void bar (void) { asm ("addiu $20,$20,1"); }
694 # Add the options needed for MIPS16 function attributes. At the moment,
695 # we don't support MIPS16 PIC.
697 proc add_options_for_mips16_attribute { flags } {
698 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
701 # Return true if we can force a mode that allows MIPS16 code generation.
702 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
705 proc check_effective_target_mips16_attribute { } {
706 return [check_no_compiler_messages mips16_attribute assembly {
710 #if defined __mips_hard_float \
711 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
712 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
715 } [add_options_for_mips16_attribute ""]]
718 # Return 1 if the current multilib does not generate PIC by default.
720 proc check_effective_target_nonpic { } {
721 return [check_no_compiler_messages nonpic assembly {
728 # Return 1 if the target does not use a status wrapper.
730 proc check_effective_target_unwrapped { } {
731 if { [target_info needs_status_wrapper] != "" \
732 && [target_info needs_status_wrapper] != "0" } {
738 # Return true if iconv is supported on the target. In particular IBM1047.
740 proc check_iconv_available { test_what } {
743 # If the tool configuration file has not set libiconv, try "-liconv"
744 if { ![info exists libiconv] } {
745 set libiconv "-liconv"
747 set test_what [lindex $test_what 1]
748 return [check_runtime_nocache $test_what [subst {
754 cd = iconv_open ("$test_what", "UTF-8");
755 if (cd == (iconv_t) -1)
762 # Return true if named sections are supported on this target.
764 proc check_named_sections_available { } {
765 return [check_no_compiler_messages named_sections assembly {
766 int __attribute__ ((section("whatever"))) foo;
770 # Return 1 if the target supports Fortran real kinds larger than real(8),
773 # When the target name changes, replace the cached result.
775 proc check_effective_target_fortran_large_real { } {
776 return [check_no_compiler_messages fortran_large_real executable {
778 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
785 # Return 1 if the target supports Fortran integer kinds larger than
786 # integer(8), 0 otherwise.
788 # When the target name changes, replace the cached result.
790 proc check_effective_target_fortran_large_int { } {
791 return [check_no_compiler_messages fortran_large_int executable {
793 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
799 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
801 # When the target name changes, replace the cached result.
803 proc check_effective_target_fortran_integer_16 { } {
804 return [check_no_compiler_messages fortran_integer_16 executable {
811 # Return 1 if we can statically link libgfortran, 0 otherwise.
813 # When the target name changes, replace the cached result.
815 proc check_effective_target_static_libgfortran { } {
816 return [check_no_compiler_messages static_libgfortran executable {
823 # Return 1 if the target supports executing 750CL paired-single instructions, 0
824 # otherwise. Cache the result.
826 proc check_750cl_hw_available { } {
827 return [check_cached_effective_target 750cl_hw_available {
828 # If this is not the right target then we can skip the test.
829 if { ![istarget powerpc-*paired*] } {
832 check_runtime_nocache 750cl_hw_available {
836 asm volatile ("ps_mul v0,v0,v0");
838 asm volatile ("ps_mul 0,0,0");
847 # Return 1 if the target supports executing SSE2 instructions, 0
848 # otherwise. Cache the result.
850 proc check_sse2_hw_available { } {
851 return [check_cached_effective_target sse2_hw_available {
852 # If this is not the right target then we can skip the test.
853 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
856 check_runtime_nocache sse2_hw_available {
860 unsigned int eax, ebx, ecx, edx = 0;
861 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
862 return !(edx & bit_SSE2);
870 # Return 1 if the target supports executing AltiVec instructions, 0
871 # otherwise. Cache the result.
873 proc check_vmx_hw_available { } {
874 return [check_cached_effective_target vmx_hw_available {
875 # Some simulators are known to not support VMX instructions.
876 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
879 # Most targets don't require special flags for this test case, but
881 if { [istarget *-*-darwin*]
882 || [istarget *-*-aix*] } {
883 set options "-maltivec"
887 check_runtime_nocache vmx_hw_available {
891 asm volatile ("vor v0,v0,v0");
893 asm volatile ("vor 0,0,0");
902 # Return 1 if the target supports executing AltiVec and Cell PPU
903 # instructions, 0 otherwise. Cache the result.
905 proc check_effective_target_cell_hw { } {
906 return [check_cached_effective_target cell_hw_available {
907 # Some simulators are known to not support VMX and PPU instructions.
908 if { [istarget powerpc-*-eabi*] } {
911 # Most targets don't require special flags for this test
912 # case, but Darwin and AIX do.
913 if { [istarget *-*-darwin*]
914 || [istarget *-*-aix*] } {
915 set options "-maltivec -mcpu=cell"
917 set options "-mcpu=cell"
919 check_runtime_nocache cell_hw_available {
923 asm volatile ("vor v0,v0,v0");
924 asm volatile ("lvlx v0,r0,r0");
926 asm volatile ("vor 0,0,0");
927 asm volatile ("lvlx 0,0,0");
936 # Return 1 if the target supports executing 64-bit instructions, 0
937 # otherwise. Cache the result.
939 proc check_effective_target_powerpc64 { } {
940 global powerpc64_available_saved
943 if [info exists powerpc64_available_saved] {
944 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
946 set powerpc64_available_saved 0
948 # Some simulators are known to not support powerpc64 instructions.
949 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
950 verbose "check_effective_target_powerpc64 returning 0" 2
951 return $powerpc64_available_saved
954 # Set up, compile, and execute a test program containing a 64-bit
955 # instruction. Include the current process ID in the file
956 # names to prevent conflicts with invocations for multiple
961 set f [open $src "w"]
962 puts $f "int main() {"
963 puts $f "#ifdef __MACH__"
964 puts $f " asm volatile (\"extsw r0,r0\");"
966 puts $f " asm volatile (\"extsw 0,0\");"
968 puts $f " return 0; }"
971 set opts "additional_flags=-mcpu=G5"
973 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
974 set lines [${tool}_target_compile $src $exe executable "$opts"]
977 if [string match "" $lines] then {
978 # No error message, compilation succeeded.
979 set result [${tool}_load "./$exe" "" ""]
980 set status [lindex $result 0]
981 remote_file build delete $exe
982 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
984 if { $status == "pass" } then {
985 set powerpc64_available_saved 1
988 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
992 return $powerpc64_available_saved
995 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
996 # complex float arguments. This affects gfortran tests that call cabsf
997 # in libm built by an earlier compiler. Return 1 if libm uses the same
998 # argument passing as the compiler under test, 0 otherwise.
1000 # When the target name changes, replace the cached result.
1002 proc check_effective_target_broken_cplxf_arg { } {
1003 return [check_cached_effective_target broken_cplxf_arg {
1004 # Skip the work for targets known not to be affected.
1005 if { ![istarget powerpc64-*-linux*] } {
1007 } elseif { ![is-effective-target lp64] } {
1010 check_runtime_nocache broken_cplxf_arg {
1011 #include <complex.h>
1012 extern void abort (void);
1013 float fabsf (float);
1014 float cabsf (_Complex float);
1021 if (fabsf (f - 5.0) > 0.0001)
1030 proc check_alpha_max_hw_available { } {
1031 return [check_runtime alpha_max_hw_available {
1032 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1036 # Returns true iff the FUNCTION is available on the target system.
1037 # (This is essentially a Tcl implementation of Autoconf's
1040 proc check_function_available { function } {
1041 return [check_no_compiler_messages ${function}_available \
1047 int main () { $function (); }
1051 # Returns true iff "fork" is available on the target system.
1053 proc check_fork_available {} {
1054 return [check_function_available "fork"]
1057 # Returns true iff "mkfifo" is available on the target system.
1059 proc check_mkfifo_available {} {
1060 if {[istarget *-*-cygwin*]} {
1061 # Cygwin has mkfifo, but support is incomplete.
1065 return [check_function_available "mkfifo"]
1068 # Returns true iff "__cxa_atexit" is used on the target system.
1070 proc check_cxa_atexit_available { } {
1071 return [check_cached_effective_target cxa_atexit_available {
1072 if { [istarget "hppa*-*-hpux10*"] } {
1073 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1075 } elseif { [istarget "*-*-vxworks"] } {
1076 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1079 check_runtime_nocache cxa_atexit_available {
1082 static unsigned int count;
1099 Y() { f(); count = 2; }
1108 int main() { return 0; }
1115 # Return 1 if we're generating 32-bit code using default options, 0
1118 proc check_effective_target_ilp32 { } {
1119 return [check_no_compiler_messages ilp32 object {
1120 int dummy[sizeof (int) == 4
1121 && sizeof (void *) == 4
1122 && sizeof (long) == 4 ? 1 : -1];
1126 # Return 1 if we're generating 32-bit or larger integers using default
1127 # options, 0 otherwise.
1129 proc check_effective_target_int32plus { } {
1130 return [check_no_compiler_messages int32plus object {
1131 int dummy[sizeof (int) >= 4 ? 1 : -1];
1135 # Return 1 if we're generating 32-bit or larger pointers using default
1136 # options, 0 otherwise.
1138 proc check_effective_target_ptr32plus { } {
1139 return [check_no_compiler_messages ptr32plus object {
1140 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1144 # Return 1 if we support 32-bit or larger array and structure sizes
1145 # using default options, 0 otherwise.
1147 proc check_effective_target_size32plus { } {
1148 return [check_no_compiler_messages size32plus object {
1153 # Returns 1 if we're generating 16-bit or smaller integers with the
1154 # default options, 0 otherwise.
1156 proc check_effective_target_int16 { } {
1157 return [check_no_compiler_messages int16 object {
1158 int dummy[sizeof (int) < 4 ? 1 : -1];
1162 # Return 1 if we're generating 64-bit code using default options, 0
1165 proc check_effective_target_lp64 { } {
1166 return [check_no_compiler_messages lp64 object {
1167 int dummy[sizeof (int) == 4
1168 && sizeof (void *) == 8
1169 && sizeof (long) == 8 ? 1 : -1];
1173 # Return 1 if we're generating 64-bit code using default llp64 options,
1176 proc check_effective_target_llp64 { } {
1177 return [check_no_compiler_messages llp64 object {
1178 int dummy[sizeof (int) == 4
1179 && sizeof (void *) == 8
1180 && sizeof (long long) == 8
1181 && sizeof (long) == 4 ? 1 : -1];
1185 # Return 1 if the target supports long double larger than double,
1188 proc check_effective_target_large_long_double { } {
1189 return [check_no_compiler_messages large_long_double object {
1190 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1194 # Return 1 if the target supports double larger than float,
1197 proc check_effective_target_large_double { } {
1198 return [check_no_compiler_messages large_double object {
1199 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1203 # Return 1 if the target supports double of 64 bits,
1206 proc check_effective_target_double64 { } {
1207 return [check_no_compiler_messages double64 object {
1208 int dummy[sizeof(double) == 8 ? 1 : -1];
1212 # Return 1 if the target supports double of at least 64 bits,
1215 proc check_effective_target_double64plus { } {
1216 return [check_no_compiler_messages double64plus object {
1217 int dummy[sizeof(double) >= 8 ? 1 : -1];
1221 # Return 1 if the target supports compiling fixed-point,
1224 proc check_effective_target_fixed_point { } {
1225 return [check_no_compiler_messages fixed_point object {
1226 _Sat _Fract x; _Sat _Accum y;
1230 # Return 1 if the target supports compiling decimal floating point,
1233 proc check_effective_target_dfp_nocache { } {
1234 verbose "check_effective_target_dfp_nocache: compiling source" 2
1235 set ret [check_no_compiler_messages_nocache dfp object {
1236 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1238 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1242 proc check_effective_target_dfprt_nocache { } {
1243 return [check_runtime_nocache dfprt {
1244 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1245 int main () { z = x + y; return 0; }
1249 # Return 1 if the target supports compiling Decimal Floating Point,
1252 # This won't change for different subtargets so cache the result.
1254 proc check_effective_target_dfp { } {
1255 return [check_cached_effective_target dfp {
1256 check_effective_target_dfp_nocache
1260 # Return 1 if the target supports linking and executing Decimal Floating
1261 # Point, # 0 otherwise.
1263 # This won't change for different subtargets so cache the result.
1265 proc check_effective_target_dfprt { } {
1266 return [check_cached_effective_target dfprt {
1267 check_effective_target_dfprt_nocache
1271 # Return 1 if the target needs a command line argument to enable a SIMD
1274 proc check_effective_target_vect_cmdline_needed { } {
1275 global et_vect_cmdline_needed_saved
1276 global et_vect_cmdline_needed_target_name
1278 if { ![info exists et_vect_cmdline_needed_target_name] } {
1279 set et_vect_cmdline_needed_target_name ""
1282 # If the target has changed since we set the cached value, clear it.
1283 set current_target [current_target_name]
1284 if { $current_target != $et_vect_cmdline_needed_target_name } {
1285 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1286 set et_vect_cmdline_needed_target_name $current_target
1287 if { [info exists et_vect_cmdline_needed_saved] } {
1288 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1289 unset et_vect_cmdline_needed_saved
1293 if [info exists et_vect_cmdline_needed_saved] {
1294 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1296 set et_vect_cmdline_needed_saved 1
1297 if { [istarget ia64-*-*]
1298 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1299 && [check_effective_target_lp64])
1300 || ([istarget powerpc*-*-*]
1301 && ([check_effective_target_powerpc_spe]
1302 || [check_effective_target_powerpc_altivec]))
1303 || [istarget spu-*-*]
1304 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1305 set et_vect_cmdline_needed_saved 0
1309 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1310 return $et_vect_cmdline_needed_saved
1313 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1315 # This won't change for different subtargets so cache the result.
1317 proc check_effective_target_vect_int { } {
1318 global et_vect_int_saved
1320 if [info exists et_vect_int_saved] {
1321 verbose "check_effective_target_vect_int: using cached result" 2
1323 set et_vect_int_saved 0
1324 if { [istarget i?86-*-*]
1325 || ([istarget powerpc*-*-*]
1326 && ![istarget powerpc-*-linux*paired*])
1327 || [istarget spu-*-*]
1328 || [istarget x86_64-*-*]
1329 || [istarget sparc*-*-*]
1330 || [istarget alpha*-*-*]
1331 || [istarget ia64-*-*]
1332 || [check_effective_target_arm32] } {
1333 set et_vect_int_saved 1
1337 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1338 return $et_vect_int_saved
1341 # Return 1 if the target supports signed int->float conversion
1344 proc check_effective_target_vect_intfloat_cvt { } {
1345 global et_vect_intfloat_cvt_saved
1347 if [info exists et_vect_intfloat_cvt_saved] {
1348 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1350 set et_vect_intfloat_cvt_saved 0
1351 if { [istarget i?86-*-*]
1352 || ([istarget powerpc*-*-*]
1353 && ![istarget powerpc-*-linux*paired*])
1354 || [istarget x86_64-*-*] } {
1355 set et_vect_intfloat_cvt_saved 1
1359 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1360 return $et_vect_intfloat_cvt_saved
1364 # Return 1 if the target supports unsigned int->float conversion
1367 proc check_effective_target_vect_uintfloat_cvt { } {
1368 global et_vect_uintfloat_cvt_saved
1370 if [info exists et_vect_uintfloat_cvt_saved] {
1371 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1373 set et_vect_uintfloat_cvt_saved 0
1374 if { ([istarget powerpc*-*-*]
1375 && ![istarget powerpc-*-linux*paired*]) } {
1376 set et_vect_uintfloat_cvt_saved 1
1380 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1381 return $et_vect_uintfloat_cvt_saved
1385 # Return 1 if the target supports signed float->int conversion
1388 proc check_effective_target_vect_floatint_cvt { } {
1389 global et_vect_floatint_cvt_saved
1391 if [info exists et_vect_floatint_cvt_saved] {
1392 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1394 set et_vect_floatint_cvt_saved 0
1395 if { [istarget i?86-*-*]
1396 || ([istarget powerpc*-*-*]
1397 && ![istarget powerpc-*-linux*paired*])
1398 || [istarget x86_64-*-*] } {
1399 set et_vect_floatint_cvt_saved 1
1403 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1404 return $et_vect_floatint_cvt_saved
1407 # Return 1 if the target supports unsigned float->int conversion
1410 proc check_effective_target_vect_floatuint_cvt { } {
1411 global et_vect_floatuint_cvt_saved
1413 if [info exists et_vect_floatuint_cvt_saved] {
1414 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1416 set et_vect_floatuint_cvt_saved 0
1417 if { ([istarget powerpc*-*-*]
1418 && ![istarget powerpc-*-linux*paired*]) } {
1419 set et_vect_floatuint_cvt_saved 1
1423 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1424 return $et_vect_floatuint_cvt_saved
1427 # Return 1 is this is an arm target using 32-bit instructions
1428 proc check_effective_target_arm32 { } {
1429 return [check_no_compiler_messages arm32 assembly {
1430 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1436 # Return 1 if this is an ARM target supporting -mfpu=vfp
1437 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1440 proc check_effective_target_arm_vfp_ok { } {
1441 if { [check_effective_target_arm32] } {
1442 return [check_no_compiler_messages arm_vfp_ok object {
1444 } "-mfpu=vfp -mfloat-abi=softfp"]
1450 # Return 1 if this is an ARM target supporting -mfpu=neon
1451 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1454 proc check_effective_target_arm_neon_ok { } {
1455 if { [check_effective_target_arm32] } {
1456 return [check_no_compiler_messages arm_neon_ok object {
1458 } "-mfpu=neon -mfloat-abi=softfp"]
1464 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1467 proc check_effective_target_arm_thumb1_ok { } {
1468 return [check_no_compiler_messages arm_thumb1_ok assembly {
1469 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1475 # Return 1 if the target supports executing NEON instructions, 0
1476 # otherwise. Cache the result.
1478 proc check_effective_target_arm_neon_hw { } {
1479 return [check_runtime arm_neon_hw_available {
1483 long long a = 0, b = 1;
1484 asm ("vorr %P0, %P1, %P2"
1486 : "0" (a), "w" (b));
1489 } "-mfpu=neon -mfloat-abi=softfp"]
1492 # Return 1 if this is a ARM target with NEON enabled.
1494 proc check_effective_target_arm_neon { } {
1495 if { [check_effective_target_arm32] } {
1496 return [check_no_compiler_messages arm_neon object {
1497 #ifndef __ARM_NEON__
1508 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1509 # the Loongson vector modes.
1511 proc check_effective_target_mips_loongson { } {
1512 return [check_no_compiler_messages loongson assembly {
1513 #if !defined(__mips_loongson_vector_rev)
1519 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1522 proc check_effective_target_arm_eabi { } {
1523 return [check_no_compiler_messages arm_eabi object {
1524 #ifndef __ARM_EABI__
1532 # Return 1 if this is a PowerPC target with floating-point registers.
1534 proc check_effective_target_powerpc_fprs { } {
1535 if { [istarget powerpc*-*-*]
1536 || [istarget rs6000-*-*] } {
1537 return [check_no_compiler_messages powerpc_fprs object {
1549 # Return 1 if this is a PowerPC target with hardware double-precision
1552 proc check_effective_target_powerpc_hard_double { } {
1553 if { [istarget powerpc*-*-*]
1554 || [istarget rs6000-*-*] } {
1555 return [check_no_compiler_messages powerpc_hard_double object {
1567 # Return 1 if this is a PowerPC target supporting -maltivec.
1569 proc check_effective_target_powerpc_altivec_ok { } {
1570 if { ([istarget powerpc*-*-*]
1571 && ![istarget powerpc-*-linux*paired*])
1572 || [istarget rs6000-*-*] } {
1573 # AltiVec is not supported on AIX before 5.3.
1574 if { [istarget powerpc*-*-aix4*]
1575 || [istarget powerpc*-*-aix5.1*]
1576 || [istarget powerpc*-*-aix5.2*] } {
1579 return [check_no_compiler_messages powerpc_altivec_ok object {
1587 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1589 proc check_effective_target_powerpc_ppu_ok { } {
1590 if [check_effective_target_powerpc_altivec_ok] {
1591 return [check_no_compiler_messages cell_asm_available object {
1594 asm volatile ("lvlx v0,v0,v0");
1596 asm volatile ("lvlx 0,0,0");
1606 # Return 1 if this is a PowerPC target that supports SPU.
1608 proc check_effective_target_powerpc_spu { } {
1609 if [istarget powerpc*-*-linux*] {
1610 return [check_effective_target_powerpc_altivec_ok]
1616 # Return 1 if this is a PowerPC SPE target. The check includes options
1617 # specified by dg-options for this test, so don't cache the result.
1619 proc check_effective_target_powerpc_spe_nocache { } {
1620 if { [istarget powerpc*-*-*] } {
1621 return [check_no_compiler_messages_nocache powerpc_spe object {
1627 } [current_compiler_flags]]
1633 # Return 1 if this is a PowerPC target with SPE enabled.
1635 proc check_effective_target_powerpc_spe { } {
1636 if { [istarget powerpc*-*-*] } {
1637 return [check_no_compiler_messages powerpc_spe object {
1649 # Return 1 if this is a PowerPC target with Altivec enabled.
1651 proc check_effective_target_powerpc_altivec { } {
1652 if { [istarget powerpc*-*-*] } {
1653 return [check_no_compiler_messages powerpc_altivec object {
1665 # Return 1 if this is a PowerPC 405 target. The check includes options
1666 # specified by dg-options for this test, so don't cache the result.
1668 proc check_effective_target_powerpc_405_nocache { } {
1669 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
1670 return [check_no_compiler_messages_nocache powerpc_405 object {
1676 } [current_compiler_flags]]
1682 # Return 1 if this is a SPU target with a toolchain that
1683 # supports automatic overlay generation.
1685 proc check_effective_target_spu_auto_overlay { } {
1686 if { [istarget spu*-*-elf*] } {
1687 return [check_no_compiler_messages spu_auto_overlay executable {
1689 } "-Wl,--auto-overlay" ]
1695 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1696 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1697 # test environment appears to run executables on such a simulator.
1699 proc check_effective_target_ultrasparc_hw { } {
1700 return [check_runtime ultrasparc_hw {
1701 int main() { return 0; }
1702 } "-mcpu=ultrasparc"]
1705 # Return 1 if the target supports hardware vector shift operation.
1707 proc check_effective_target_vect_shift { } {
1708 global et_vect_shift_saved
1710 if [info exists et_vect_shift_saved] {
1711 verbose "check_effective_target_vect_shift: using cached result" 2
1713 set et_vect_shift_saved 0
1714 if { ([istarget powerpc*-*-*]
1715 && ![istarget powerpc-*-linux*paired*])
1716 || [istarget ia64-*-*]
1717 || [istarget i?86-*-*]
1718 || [istarget x86_64-*-*]
1719 || [check_effective_target_arm32] } {
1720 set et_vect_shift_saved 1
1724 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1725 return $et_vect_shift_saved
1728 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1730 # This can change for different subtargets so do not cache the result.
1732 proc check_effective_target_vect_long { } {
1733 if { [istarget i?86-*-*]
1734 || (([istarget powerpc*-*-*]
1735 && ![istarget powerpc-*-linux*paired*])
1736 && [check_effective_target_ilp32])
1737 || [istarget x86_64-*-*]
1738 || [check_effective_target_arm32]
1739 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1745 verbose "check_effective_target_vect_long: returning $answer" 2
1749 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1751 # This won't change for different subtargets so cache the result.
1753 proc check_effective_target_vect_float { } {
1754 global et_vect_float_saved
1756 if [info exists et_vect_float_saved] {
1757 verbose "check_effective_target_vect_float: using cached result" 2
1759 set et_vect_float_saved 0
1760 if { [istarget i?86-*-*]
1761 || [istarget powerpc*-*-*]
1762 || [istarget spu-*-*]
1763 || [istarget mipsisa64*-*-*]
1764 || [istarget x86_64-*-*]
1765 || [istarget ia64-*-*]
1766 || [check_effective_target_arm32] } {
1767 set et_vect_float_saved 1
1771 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1772 return $et_vect_float_saved
1775 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1777 # This won't change for different subtargets so cache the result.
1779 proc check_effective_target_vect_double { } {
1780 global et_vect_double_saved
1782 if [info exists et_vect_double_saved] {
1783 verbose "check_effective_target_vect_double: using cached result" 2
1785 set et_vect_double_saved 0
1786 if { [istarget i?86-*-*]
1787 || [istarget x86_64-*-*]
1788 || [istarget spu-*-*] } {
1789 set et_vect_double_saved 1
1793 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1794 return $et_vect_double_saved
1797 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
1799 # This won't change for different subtargets so cache the result.
1801 proc check_effective_target_vect_long_long { } {
1802 global et_vect_long_long_saved
1804 if [info exists et_vect_long_long_saved] {
1805 verbose "check_effective_target_vect_long_long: using cached result" 2
1807 set et_vect_long_long_saved 0
1808 if { [istarget i?86-*-*]
1809 || [istarget x86_64-*-*] } {
1810 set et_vect_long_long_saved 1
1814 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
1815 return $et_vect_long_long_saved
1819 # Return 1 if the target plus current options does not support a vector
1820 # max instruction on "int", 0 otherwise.
1822 # This won't change for different subtargets so cache the result.
1824 proc check_effective_target_vect_no_int_max { } {
1825 global et_vect_no_int_max_saved
1827 if [info exists et_vect_no_int_max_saved] {
1828 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1830 set et_vect_no_int_max_saved 0
1831 if { [istarget sparc*-*-*]
1832 || [istarget spu-*-*]
1833 || [istarget alpha*-*-*] } {
1834 set et_vect_no_int_max_saved 1
1837 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1838 return $et_vect_no_int_max_saved
1841 # Return 1 if the target plus current options does not support a vector
1842 # add instruction on "int", 0 otherwise.
1844 # This won't change for different subtargets so cache the result.
1846 proc check_effective_target_vect_no_int_add { } {
1847 global et_vect_no_int_add_saved
1849 if [info exists et_vect_no_int_add_saved] {
1850 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1852 set et_vect_no_int_add_saved 0
1853 # Alpha only supports vector add on V8QI and V4HI.
1854 if { [istarget alpha*-*-*] } {
1855 set et_vect_no_int_add_saved 1
1858 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1859 return $et_vect_no_int_add_saved
1862 # Return 1 if the target plus current options does not support vector
1863 # bitwise instructions, 0 otherwise.
1865 # This won't change for different subtargets so cache the result.
1867 proc check_effective_target_vect_no_bitwise { } {
1868 global et_vect_no_bitwise_saved
1870 if [info exists et_vect_no_bitwise_saved] {
1871 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1873 set et_vect_no_bitwise_saved 0
1875 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1876 return $et_vect_no_bitwise_saved
1879 # Return 1 if the target plus current options supports vector permutation,
1882 # This won't change for different subtargets so cache the result.
1884 proc check_effective_target_vect_perm { } {
1887 if [info exists et_vect_perm_saved] {
1888 verbose "check_effective_target_vect_perm: using cached result" 2
1890 set et_vect_perm_saved 0
1891 if { [istarget powerpc*-*-*]
1892 || [istarget spu-*-*] } {
1893 set et_vect_perm_saved 1
1896 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
1897 return $et_vect_perm_saved
1901 # Return 1 if the target plus current options supports a vector
1902 # widening summation of *short* args into *int* result, 0 otherwise.
1903 # A target can also support this widening summation if it can support
1904 # promotion (unpacking) from shorts to ints.
1906 # This won't change for different subtargets so cache the result.
1908 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1909 global et_vect_widen_sum_hi_to_si
1911 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1912 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1914 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1915 if { [istarget powerpc*-*-*]
1916 || [istarget ia64-*-*] } {
1917 set et_vect_widen_sum_hi_to_si_saved 1
1920 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1921 return $et_vect_widen_sum_hi_to_si_saved
1924 # Return 1 if the target plus current options supports a vector
1925 # widening summation of *char* args into *short* result, 0 otherwise.
1926 # A target can also support this widening summation if it can support
1927 # promotion (unpacking) from chars to shorts.
1929 # This won't change for different subtargets so cache the result.
1931 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1932 global et_vect_widen_sum_qi_to_hi
1934 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1935 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1937 set et_vect_widen_sum_qi_to_hi_saved 0
1938 if { [check_effective_target_vect_unpack]
1939 || [istarget ia64-*-*] } {
1940 set et_vect_widen_sum_qi_to_hi_saved 1
1943 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1944 return $et_vect_widen_sum_qi_to_hi_saved
1947 # Return 1 if the target plus current options supports a vector
1948 # widening summation of *char* args into *int* result, 0 otherwise.
1950 # This won't change for different subtargets so cache the result.
1952 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1953 global et_vect_widen_sum_qi_to_si
1955 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1956 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1958 set et_vect_widen_sum_qi_to_si_saved 0
1959 if { [istarget powerpc*-*-*] } {
1960 set et_vect_widen_sum_qi_to_si_saved 1
1963 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1964 return $et_vect_widen_sum_qi_to_si_saved
1967 # Return 1 if the target plus current options supports a vector
1968 # widening multiplication of *char* args into *short* result, 0 otherwise.
1969 # A target can also support this widening multplication if it can support
1970 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1971 # multiplication of shorts).
1973 # This won't change for different subtargets so cache the result.
1976 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1977 global et_vect_widen_mult_qi_to_hi
1979 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1980 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1982 if { [check_effective_target_vect_unpack]
1983 && [check_effective_target_vect_short_mult] } {
1984 set et_vect_widen_mult_qi_to_hi_saved 1
1986 set et_vect_widen_mult_qi_to_hi_saved 0
1988 if { [istarget powerpc*-*-*] } {
1989 set et_vect_widen_mult_qi_to_hi_saved 1
1992 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1993 return $et_vect_widen_mult_qi_to_hi_saved
1996 # Return 1 if the target plus current options supports a vector
1997 # widening multiplication of *short* args into *int* result, 0 otherwise.
1998 # A target can also support this widening multplication if it can support
1999 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2000 # multiplication of ints).
2002 # This won't change for different subtargets so cache the result.
2005 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2006 global et_vect_widen_mult_hi_to_si
2008 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2009 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2011 if { [check_effective_target_vect_unpack]
2012 && [check_effective_target_vect_int_mult] } {
2013 set et_vect_widen_mult_hi_to_si_saved 1
2015 set et_vect_widen_mult_hi_to_si_saved 0
2017 if { [istarget powerpc*-*-*]
2018 || [istarget spu-*-*]
2019 || [istarget i?86-*-*]
2020 || [istarget x86_64-*-*] } {
2021 set et_vect_widen_mult_hi_to_si_saved 1
2024 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2025 return $et_vect_widen_mult_hi_to_si_saved
2028 # Return 1 if the target plus current options supports a vector
2029 # dot-product of signed chars, 0 otherwise.
2031 # This won't change for different subtargets so cache the result.
2033 proc check_effective_target_vect_sdot_qi { } {
2034 global et_vect_sdot_qi
2036 if [info exists et_vect_sdot_qi_saved] {
2037 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2039 set et_vect_sdot_qi_saved 0
2041 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2042 return $et_vect_sdot_qi_saved
2045 # Return 1 if the target plus current options supports a vector
2046 # dot-product of unsigned chars, 0 otherwise.
2048 # This won't change for different subtargets so cache the result.
2050 proc check_effective_target_vect_udot_qi { } {
2051 global et_vect_udot_qi
2053 if [info exists et_vect_udot_qi_saved] {
2054 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2056 set et_vect_udot_qi_saved 0
2057 if { [istarget powerpc*-*-*] } {
2058 set et_vect_udot_qi_saved 1
2061 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2062 return $et_vect_udot_qi_saved
2065 # Return 1 if the target plus current options supports a vector
2066 # dot-product of signed shorts, 0 otherwise.
2068 # This won't change for different subtargets so cache the result.
2070 proc check_effective_target_vect_sdot_hi { } {
2071 global et_vect_sdot_hi
2073 if [info exists et_vect_sdot_hi_saved] {
2074 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2076 set et_vect_sdot_hi_saved 0
2077 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2078 || [istarget i?86-*-*]
2079 || [istarget x86_64-*-*] } {
2080 set et_vect_sdot_hi_saved 1
2083 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2084 return $et_vect_sdot_hi_saved
2087 # Return 1 if the target plus current options supports a vector
2088 # dot-product of unsigned shorts, 0 otherwise.
2090 # This won't change for different subtargets so cache the result.
2092 proc check_effective_target_vect_udot_hi { } {
2093 global et_vect_udot_hi
2095 if [info exists et_vect_udot_hi_saved] {
2096 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2098 set et_vect_udot_hi_saved 0
2099 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2100 set et_vect_udot_hi_saved 1
2103 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2104 return $et_vect_udot_hi_saved
2108 # Return 1 if the target plus current options supports a vector
2109 # demotion (packing) of shorts (to chars) and ints (to shorts)
2110 # using modulo arithmetic, 0 otherwise.
2112 # This won't change for different subtargets so cache the result.
2114 proc check_effective_target_vect_pack_trunc { } {
2115 global et_vect_pack_trunc
2117 if [info exists et_vect_pack_trunc_saved] {
2118 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2120 set et_vect_pack_trunc_saved 0
2121 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2122 || [istarget i?86-*-*]
2123 || [istarget x86_64-*-*]
2124 || [istarget spu-*-*] } {
2125 set et_vect_pack_trunc_saved 1
2128 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2129 return $et_vect_pack_trunc_saved
2132 # Return 1 if the target plus current options supports a vector
2133 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2135 # This won't change for different subtargets so cache the result.
2137 proc check_effective_target_vect_unpack { } {
2138 global et_vect_unpack
2140 if [info exists et_vect_unpack_saved] {
2141 verbose "check_effective_target_vect_unpack: using cached result" 2
2143 set et_vect_unpack_saved 0
2144 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2145 || [istarget i?86-*-*]
2146 || [istarget x86_64-*-*]
2147 || [istarget spu-*-*] } {
2148 set et_vect_unpack_saved 1
2151 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2152 return $et_vect_unpack_saved
2155 # Return 1 if the target plus current options does not guarantee
2156 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2158 # This won't change for different subtargets so cache the result.
2160 proc check_effective_target_unaligned_stack { } {
2161 global et_unaligned_stack_saved
2163 if [info exists et_unaligned_stack_saved] {
2164 verbose "check_effective_target_unaligned_stack: using cached result" 2
2166 set et_unaligned_stack_saved 0
2168 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2169 return $et_unaligned_stack_saved
2172 # Return 1 if the target plus current options does not support a vector
2173 # alignment mechanism, 0 otherwise.
2175 # This won't change for different subtargets so cache the result.
2177 proc check_effective_target_vect_no_align { } {
2178 global et_vect_no_align_saved
2180 if [info exists et_vect_no_align_saved] {
2181 verbose "check_effective_target_vect_no_align: using cached result" 2
2183 set et_vect_no_align_saved 0
2184 if { [istarget mipsisa64*-*-*]
2185 || [istarget sparc*-*-*]
2186 || [istarget ia64-*-*]
2187 || [check_effective_target_arm32] } {
2188 set et_vect_no_align_saved 1
2191 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2192 return $et_vect_no_align_saved
2195 # Return 1 if arrays are aligned to the vector alignment
2196 # boundary, 0 otherwise.
2198 # This won't change for different subtargets so cache the result.
2200 proc check_effective_target_vect_aligned_arrays { } {
2201 global et_vect_aligned_arrays
2203 if [info exists et_vect_aligned_arrays_saved] {
2204 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2206 set et_vect_aligned_arrays_saved 0
2207 if { (([istarget x86_64-*-*]
2208 || [istarget i?86-*-*]) && [is-effective-target lp64])
2209 || [istarget spu-*-*] } {
2210 set et_vect_aligned_arrays_saved 1
2213 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2214 return $et_vect_aligned_arrays_saved
2217 # Return 1 if types of size 32 bit or less are naturally aligned
2218 # (aligned to their type-size), 0 otherwise.
2220 # This won't change for different subtargets so cache the result.
2222 proc check_effective_target_natural_alignment_32 { } {
2223 global et_natural_alignment_32
2225 if [info exists et_natural_alignment_32_saved] {
2226 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2228 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2229 set et_natural_alignment_32_saved 1
2230 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2231 set et_natural_alignment_32_saved 0
2234 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2235 return $et_natural_alignment_32_saved
2238 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2239 # type-size), 0 otherwise.
2241 # This won't change for different subtargets so cache the result.
2243 proc check_effective_target_natural_alignment_64 { } {
2244 global et_natural_alignment_64
2246 if [info exists et_natural_alignment_64_saved] {
2247 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2249 set et_natural_alignment_64_saved 0
2250 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2251 || [istarget spu-*-*] } {
2252 set et_natural_alignment_64_saved 1
2255 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2256 return $et_natural_alignment_64_saved
2259 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2261 # This won't change for different subtargets so cache the result.
2263 proc check_effective_target_vector_alignment_reachable { } {
2264 global et_vector_alignment_reachable
2266 if [info exists et_vector_alignment_reachable_saved] {
2267 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2269 if { [check_effective_target_vect_aligned_arrays]
2270 || [check_effective_target_natural_alignment_32] } {
2271 set et_vector_alignment_reachable_saved 1
2273 set et_vector_alignment_reachable_saved 0
2276 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2277 return $et_vector_alignment_reachable_saved
2280 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2282 # This won't change for different subtargets so cache the result.
2284 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2285 global et_vector_alignment_reachable_for_64bit
2287 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2288 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2290 if { [check_effective_target_vect_aligned_arrays]
2291 || [check_effective_target_natural_alignment_64] } {
2292 set et_vector_alignment_reachable_for_64bit_saved 1
2294 set et_vector_alignment_reachable_for_64bit_saved 0
2297 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2298 return $et_vector_alignment_reachable_for_64bit_saved
2301 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2303 proc check_effective_target_vect_condition { } {
2304 global et_vect_cond_saved
2306 if [info exists et_vect_cond_saved] {
2307 verbose "check_effective_target_vect_cond: using cached result" 2
2309 set et_vect_cond_saved 0
2310 if { [istarget powerpc*-*-*]
2311 || [istarget ia64-*-*]
2312 || [istarget i?86-*-*]
2313 || [istarget spu-*-*]
2314 || [istarget x86_64-*-*] } {
2315 set et_vect_cond_saved 1
2319 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2320 return $et_vect_cond_saved
2323 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2325 proc check_effective_target_vect_char_mult { } {
2326 global et_vect_char_mult_saved
2328 if [info exists et_vect_char_mult_saved] {
2329 verbose "check_effective_target_vect_char_mult: using cached result" 2
2331 set et_vect_char_mult_saved 0
2332 if { [istarget ia64-*-*]
2333 || [istarget i?86-*-*]
2334 || [istarget x86_64-*-*] } {
2335 set et_vect_char_mult_saved 1
2339 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2340 return $et_vect_char_mult_saved
2343 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2345 proc check_effective_target_vect_short_mult { } {
2346 global et_vect_short_mult_saved
2348 if [info exists et_vect_short_mult_saved] {
2349 verbose "check_effective_target_vect_short_mult: using cached result" 2
2351 set et_vect_short_mult_saved 0
2352 if { [istarget ia64-*-*]
2353 || [istarget spu-*-*]
2354 || [istarget i?86-*-*]
2355 || [istarget x86_64-*-*]
2356 || [istarget powerpc*-*-*]
2357 || [check_effective_target_arm32] } {
2358 set et_vect_short_mult_saved 1
2362 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2363 return $et_vect_short_mult_saved
2366 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2368 proc check_effective_target_vect_int_mult { } {
2369 global et_vect_int_mult_saved
2371 if [info exists et_vect_int_mult_saved] {
2372 verbose "check_effective_target_vect_int_mult: using cached result" 2
2374 set et_vect_int_mult_saved 0
2375 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2376 || [istarget spu-*-*]
2377 || [istarget i?86-*-*]
2378 || [istarget x86_64-*-*]
2379 || [check_effective_target_arm32] } {
2380 set et_vect_int_mult_saved 1
2384 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2385 return $et_vect_int_mult_saved
2388 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2390 proc check_effective_target_vect_extract_even_odd { } {
2391 global et_vect_extract_even_odd_saved
2393 if [info exists et_vect_extract_even_odd_saved] {
2394 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2396 set et_vect_extract_even_odd_saved 0
2397 if { [istarget powerpc*-*-*]
2398 || [istarget spu-*-*] } {
2399 set et_vect_extract_even_odd_saved 1
2403 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2404 return $et_vect_extract_even_odd_saved
2407 # Return 1 if the target supports vector even/odd elements extraction of
2408 # vectors with SImode elements or larger, 0 otherwise.
2410 proc check_effective_target_vect_extract_even_odd_wide { } {
2411 global et_vect_extract_even_odd_wide_saved
2413 if [info exists et_vect_extract_even_odd_wide_saved] {
2414 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2416 set et_vect_extract_even_odd_wide_saved 0
2417 if { [istarget powerpc*-*-*]
2418 || [istarget i?86-*-*]
2419 || [istarget x86_64-*-*]
2420 || [istarget spu-*-*] } {
2421 set et_vect_extract_even_odd_wide_saved 1
2425 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2426 return $et_vect_extract_even_odd_wide_saved
2429 # Return 1 if the target supports vector interleaving, 0 otherwise.
2431 proc check_effective_target_vect_interleave { } {
2432 global et_vect_interleave_saved
2434 if [info exists et_vect_interleave_saved] {
2435 verbose "check_effective_target_vect_interleave: using cached result" 2
2437 set et_vect_interleave_saved 0
2438 if { [istarget powerpc*-*-*]
2439 || [istarget i?86-*-*]
2440 || [istarget x86_64-*-*]
2441 || [istarget spu-*-*] } {
2442 set et_vect_interleave_saved 1
2446 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2447 return $et_vect_interleave_saved
2450 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2451 proc check_effective_target_vect_strided { } {
2452 global et_vect_strided_saved
2454 if [info exists et_vect_strided_saved] {
2455 verbose "check_effective_target_vect_strided: using cached result" 2
2457 set et_vect_strided_saved 0
2458 if { [check_effective_target_vect_interleave]
2459 && [check_effective_target_vect_extract_even_odd] } {
2460 set et_vect_strided_saved 1
2464 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2465 return $et_vect_strided_saved
2468 # Return 1 if the target supports vector interleaving and extract even/odd
2469 # for wide element types, 0 otherwise.
2470 proc check_effective_target_vect_strided_wide { } {
2471 global et_vect_strided_wide_saved
2473 if [info exists et_vect_strided_wide_saved] {
2474 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2476 set et_vect_strided_wide_saved 0
2477 if { [check_effective_target_vect_interleave]
2478 && [check_effective_target_vect_extract_even_odd_wide] } {
2479 set et_vect_strided_wide_saved 1
2483 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2484 return $et_vect_strided_wide_saved
2487 # Return 1 if the target supports section-anchors
2489 proc check_effective_target_section_anchors { } {
2490 global et_section_anchors_saved
2492 if [info exists et_section_anchors_saved] {
2493 verbose "check_effective_target_section_anchors: using cached result" 2
2495 set et_section_anchors_saved 0
2496 if { [istarget powerpc*-*-*] } {
2497 set et_section_anchors_saved 1
2501 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2502 return $et_section_anchors_saved
2505 # Return 1 if the target supports atomic operations on "int" and "long".
2507 proc check_effective_target_sync_int_long { } {
2508 global et_sync_int_long_saved
2510 if [info exists et_sync_int_long_saved] {
2511 verbose "check_effective_target_sync_int_long: using cached result" 2
2513 set et_sync_int_long_saved 0
2514 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2515 # load-reserved/store-conditional instructions.
2516 if { [istarget ia64-*-*]
2517 || [istarget i?86-*-*]
2518 || [istarget x86_64-*-*]
2519 || [istarget alpha*-*-*]
2520 || [istarget s390*-*-*]
2521 || [istarget powerpc*-*-*]
2522 || [istarget sparc64-*-*]
2523 || [istarget sparcv9-*-*]
2524 || [istarget mips*-*-*] } {
2525 set et_sync_int_long_saved 1
2529 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2530 return $et_sync_int_long_saved
2533 # Return 1 if the target supports atomic operations on "char" and "short".
2535 proc check_effective_target_sync_char_short { } {
2536 global et_sync_char_short_saved
2538 if [info exists et_sync_char_short_saved] {
2539 verbose "check_effective_target_sync_char_short: using cached result" 2
2541 set et_sync_char_short_saved 0
2542 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2543 # load-reserved/store-conditional instructions.
2544 if { [istarget ia64-*-*]
2545 || [istarget i?86-*-*]
2546 || [istarget x86_64-*-*]
2547 || [istarget alpha*-*-*]
2548 || [istarget s390*-*-*]
2549 || [istarget powerpc*-*-*]
2550 || [istarget sparc64-*-*]
2551 || [istarget sparcv9-*-*]
2552 || [istarget mips*-*-*] } {
2553 set et_sync_char_short_saved 1
2557 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2558 return $et_sync_char_short_saved
2561 # Return 1 if the target uses a ColdFire FPU.
2563 proc check_effective_target_coldfire_fpu { } {
2564 return [check_no_compiler_messages coldfire_fpu assembly {
2571 # Return true if this is a uClibc target.
2573 proc check_effective_target_uclibc {} {
2574 return [check_no_compiler_messages uclibc object {
2575 #include <features.h>
2576 #if !defined (__UCLIBC__)
2582 # Return true if this is a uclibc target and if the uclibc feature
2583 # described by __$feature__ is not present.
2585 proc check_missing_uclibc_feature {feature} {
2586 return [check_no_compiler_messages $feature object "
2587 #include <features.h>
2588 #if !defined (__UCLIBC) || defined (__${feature}__)
2594 # Return true if this is a Newlib target.
2596 proc check_effective_target_newlib {} {
2597 return [check_no_compiler_messages newlib object {
2603 # (a) an error of a few ULP is expected in string to floating-point
2604 # conversion functions; and
2605 # (b) overflow is not always detected correctly by those functions.
2607 proc check_effective_target_lax_strtofp {} {
2608 # By default, assume that all uClibc targets suffer from this.
2609 return [check_effective_target_uclibc]
2612 # Return 1 if this is a target for which wcsftime is a dummy
2613 # function that always returns 0.
2615 proc check_effective_target_dummy_wcsftime {} {
2616 # By default, assume that all uClibc targets suffer from this.
2617 return [check_effective_target_uclibc]
2620 # Return 1 if constructors with initialization priority arguments are
2621 # supposed on this target.
2623 proc check_effective_target_init_priority {} {
2624 return [check_no_compiler_messages init_priority assembly "
2625 void f() __attribute__((constructor (1000)));
2630 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2631 # This can be used with any check_* proc that takes no argument and
2632 # returns only 1 or 0. It could be used with check_* procs that take
2633 # arguments with keywords that pass particular arguments.
2635 proc is-effective-target { arg } {
2637 if { [info procs check_effective_target_${arg}] != [list] } {
2638 set selected [check_effective_target_${arg}]
2641 "vmx_hw" { set selected [check_vmx_hw_available] }
2642 "named_sections" { set selected [check_named_sections_available] }
2643 "gc_sections" { set selected [check_gc_sections_available] }
2644 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2645 default { error "unknown effective target keyword `$arg'" }
2648 verbose "is-effective-target: $arg $selected" 2
2652 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2654 proc is-effective-target-keyword { arg } {
2655 if { [info procs check_effective_target_${arg}] != [list] } {
2658 # These have different names for their check_* procs.
2660 "vmx_hw" { return 1 }
2661 "named_sections" { return 1 }
2662 "gc_sections" { return 1 }
2663 "cxa_atexit" { return 1 }
2664 default { return 0 }
2669 # Return 1 if target default to short enums
2671 proc check_effective_target_short_enums { } {
2672 return [check_no_compiler_messages short_enums assembly {
2674 int s[sizeof (enum foo) == 1 ? 1 : -1];
2678 # Return 1 if target supports merging string constants at link time.
2680 proc check_effective_target_string_merging { } {
2681 return [check_no_messages_and_pattern string_merging \
2682 "rodata\\.str" assembly {
2683 const char *var = "String";
2687 # Return 1 if target has the basic signed and unsigned types in
2688 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
2689 # working <stdint.h> for all targets.
2691 proc check_effective_target_stdint_types { } {
2692 return [check_no_compiler_messages stdint_types assembly {
2694 int8_t a; int16_t b; int32_t c; int64_t d;
2695 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2699 # Return 1 if target has the basic signed and unsigned types in
2700 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
2701 # these types agree with those in the header, as some systems have
2702 # only <inttypes.h>.
2704 proc check_effective_target_inttypes_types { } {
2705 return [check_no_compiler_messages inttypes_types assembly {
2706 #include <inttypes.h>
2707 int8_t a; int16_t b; int32_t c; int64_t d;
2708 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2712 # Return 1 if programs are intended to be run on a simulator
2713 # (i.e. slowly) rather than hardware (i.e. fast).
2715 proc check_effective_target_simulator { } {
2717 # All "src/sim" simulators set this one.
2718 if [board_info target exists is_simulator] {
2719 return [board_info target is_simulator]
2722 # The "sid" simulators don't set that one, but at least they set
2724 if [board_info target exists slow_simulator] {
2725 return [board_info target slow_simulator]
2731 # Return 1 if the target is a VxWorks kernel.
2733 proc check_effective_target_vxworks_kernel { } {
2734 return [check_no_compiler_messages vxworks_kernel assembly {
2735 #if !defined __vxworks || defined __RTP__
2741 # Return 1 if the target is a VxWorks RTP.
2743 proc check_effective_target_vxworks_rtp { } {
2744 return [check_no_compiler_messages vxworks_rtp assembly {
2745 #if !defined __vxworks || !defined __RTP__
2751 # Return 1 if the target is expected to provide wide character support.
2753 proc check_effective_target_wchar { } {
2754 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2757 return [check_no_compiler_messages wchar assembly {
2762 # Return 1 if the target has <pthread.h>.
2764 proc check_effective_target_pthread_h { } {
2765 return [check_no_compiler_messages pthread_h assembly {
2766 #include <pthread.h>
2770 # Return 1 if the target can truncate a file from a file-descriptor,
2771 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2772 # chsize. We test for a trivially functional truncation; no stubs.
2773 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2774 # different function to be used.
2776 proc check_effective_target_fd_truncate { } {
2778 #define _FILE_OFFSET_BITS 64
2784 FILE *f = fopen ("tst.tmp", "wb");
2786 const char t[] = "test writing more than ten characters";
2789 write (fd, t, sizeof (t) - 1);
2791 if (ftruncate (fd, 10) != 0)
2794 f = fopen ("tst.tmp", "rb");
2795 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2801 if { [check_runtime ftruncate $prog] } {
2805 regsub "ftruncate" $prog "chsize" prog
2806 return [check_runtime chsize $prog]
2809 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2811 proc add_options_for_c99_runtime { flags } {
2812 if { [istarget *-*-solaris2*] } {
2813 return "$flags -std=c99"
2815 if { [istarget powerpc-*-darwin*] } {
2816 return "$flags -mmacosx-version-min=10.3"
2821 # Return 1 if the target provides a full C99 runtime.
2823 proc check_effective_target_c99_runtime { } {
2824 return [check_cached_effective_target c99_runtime {
2827 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2828 set contents [read $file]
2831 #ifndef HAVE_C99_RUNTIME
2835 check_no_compiler_messages_nocache c99_runtime assembly \
2836 $contents [add_options_for_c99_runtime ""]
2840 # Return 1 if target wchar_t is at least 4 bytes.
2842 proc check_effective_target_4byte_wchar_t { } {
2843 return [check_no_compiler_messages 4byte_wchar_t object {
2844 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
2848 # Return 1 if the target supports automatic stack alignment.
2850 proc check_effective_target_automatic_stack_alignment { } {
2851 if { [istarget i?86*-*-*]
2852 || [istarget x86_64-*-*] } then {
2859 # Return 1 if avx instructions can be compiled.
2861 proc check_effective_target_avx { } {
2862 return [check_no_compiler_messages avx object {
2863 void _mm256_zeroall (void)
2865 __builtin_ia32_vzeroall ();
2870 # Return 1 if C wchar_t type is compatible with char16_t.
2872 proc check_effective_target_wchar_t_char16_t_compatible { } {
2873 return [check_no_compiler_messages wchar_t_char16_t object {
2875 __CHAR16_TYPE__ *p16 = &wc;
2876 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2880 # Return 1 if C wchar_t type is compatible with char32_t.
2882 proc check_effective_target_wchar_t_char32_t_compatible { } {
2883 return [check_no_compiler_messages wchar_t_char32_t object {
2885 __CHAR32_TYPE__ *p32 = &wc;
2886 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2890 # Return 1 if pow10 function exists.
2892 proc check_effective_target_pow10 { } {
2893 return [check_runtime pow10 {
2903 # Return 1 if current options generate DFP instructions, 0 otherwise.
2905 proc check_effective_target_hard_dfp {} {
2906 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
2908 void foo (void) { z = x + y; }
2912 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
2913 # for strchr etc. functions.
2915 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
2916 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
2919 #if !defined(__cplusplus) \
2920 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
2921 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
2922 ISO C++ correct string.h and wchar.h protos not supported.