1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2 # 2011 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.
33 # Otherwise, code should contain:
35 # "! Fortran" for Fortran code,
37 # "// ObjC++" for ObjC++
39 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
40 # allow for ObjC/ObjC++ specific flags.
41 proc check_compile {basename type contents args} {
43 verbose "check_compile tool: $tool for $basename"
45 if { [llength $args] > 0 } {
46 set options [list "additional_flags=[lindex $args 0]"]
50 switch -glob -- $contents {
51 "*! Fortran*" { set src ${basename}[pid].f90 }
52 "*// C++*" { set src ${basename}[pid].cc }
53 "*// ObjC++*" { set src ${basename}[pid].mm }
54 "*/* ObjC*" { set src ${basename}[pid].m }
55 "*// Go*" { set src ${basename}[pid].go }
58 "objc" { set src ${basename}[pid].m }
59 "obj-c++" { set src ${basename}[pid].mm }
60 default { set src ${basename}[pid].c }
65 set compile_type $type
67 assembly { set output ${basename}[pid].s }
68 object { set output ${basename}[pid].o }
69 executable { set output ${basename}[pid].exe }
71 set output ${basename}[pid].s
72 lappend options "additional_flags=-fdump-$type"
73 set compile_type assembly
79 set lines [${tool}_target_compile $src $output $compile_type "$options"]
82 set scan_output $output
83 # Don't try folding this into the switch above; calling "glob" before the
84 # file is created won't work.
85 if [regexp "rtl-(.*)" $type dummy rtl_type] {
86 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
90 return [list $lines $scan_output]
93 proc current_target_name { } {
95 if [info exists target_info(target,name)] {
96 set answer $target_info(target,name)
103 # Implement an effective-target check for property PROP by invoking
104 # the Tcl command ARGS and seeing if it returns true.
106 proc check_cached_effective_target { prop args } {
109 set target [current_target_name]
110 if {![info exists et_cache($prop,target)]
111 || $et_cache($prop,target) != $target} {
112 verbose "check_cached_effective_target $prop: checking $target" 2
113 set et_cache($prop,target) $target
114 set et_cache($prop,value) [uplevel eval $args]
116 set value $et_cache($prop,value)
117 verbose "check_cached_effective_target $prop: returning $value for $target" 2
121 # Like check_compile, but delete the output file and return true if the
122 # compiler printed no messages.
123 proc check_no_compiler_messages_nocache {args} {
124 set result [eval check_compile $args]
125 set lines [lindex $result 0]
126 set output [lindex $result 1]
127 remote_file build delete $output
128 return [string match "" $lines]
131 # Like check_no_compiler_messages_nocache, but cache the result.
132 # PROP is the property we're checking, and doubles as a prefix for
133 # temporary filenames.
134 proc check_no_compiler_messages {prop args} {
135 return [check_cached_effective_target $prop {
136 eval [list check_no_compiler_messages_nocache $prop] $args
140 # Like check_compile, but return true if the compiler printed no
141 # messages and if the contents of the output file satisfy PATTERN.
142 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
143 # don't match regular expression REGEXP, otherwise they satisfy it
144 # if they do match regular expression PATTERN. (PATTERN can start
145 # with something like "[!]" if the regular expression needs to match
146 # "!" as the first character.)
148 # Delete the output file before returning. The other arguments are
149 # as for check_compile.
150 proc check_no_messages_and_pattern_nocache {basename pattern args} {
153 set result [eval [list check_compile $basename] $args]
154 set lines [lindex $result 0]
155 set output [lindex $result 1]
158 if { [string match "" $lines] } {
159 set chan [open "$output"]
160 set invert [regexp {^!(.*)} $pattern dummy pattern]
161 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
165 remote_file build delete $output
169 # Like check_no_messages_and_pattern_nocache, but cache the result.
170 # PROP is the property we're checking, and doubles as a prefix for
171 # temporary filenames.
172 proc check_no_messages_and_pattern {prop pattern args} {
173 return [check_cached_effective_target $prop {
174 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
178 # Try to compile and run an executable from code CONTENTS. Return true
179 # if the compiler reports no messages and if execution "passes" in the
180 # usual DejaGNU sense. The arguments are as for check_compile, with
181 # TYPE implicitly being "executable".
182 proc check_runtime_nocache {basename contents args} {
185 set result [eval [list check_compile $basename executable $contents] $args]
186 set lines [lindex $result 0]
187 set output [lindex $result 1]
190 if { [string match "" $lines] } {
191 # No error messages, everything is OK.
192 set result [remote_load target "./$output" "" ""]
193 set status [lindex $result 0]
194 verbose "check_runtime_nocache $basename: status is <$status>" 2
195 if { $status == "pass" } {
199 remote_file build delete $output
203 # Like check_runtime_nocache, but cache the result. PROP is the
204 # property we're checking, and doubles as a prefix for temporary
206 proc check_runtime {prop args} {
209 return [check_cached_effective_target $prop {
210 eval [list check_runtime_nocache $prop] $args
214 ###############################
215 # proc check_weak_available { }
216 ###############################
218 # weak symbols are only supported in some configs/object formats
219 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
221 proc check_weak_available { } {
222 global target_triplet
225 # All mips targets should support it
227 if { [ string first "mips" $target_cpu ] >= 0 } {
231 # All solaris2 targets should support it
233 if { [regexp ".*-solaris2.*" $target_triplet] } {
237 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
239 if { [regexp "alpha.*osf.*" $target_triplet] } {
243 # Windows targets Cygwin and MingW32 support it
245 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
249 # HP-UX 10.X doesn't support it
251 if { [istarget "hppa*-*-hpux10*"] } {
255 # ELF and ECOFF support it. a.out does with gas/gld but may also with
256 # other linkers, so we should try it
258 set objformat [gcc_target_object_format]
266 unknown { return -1 }
271 ###############################
272 # proc check_weak_override_available { }
273 ###############################
275 # Like check_weak_available, but return 0 if weak symbol definitions
276 # cannot be overridden.
278 proc check_weak_override_available { } {
279 if { [istarget "*-*-mingw*"] } {
282 return [check_weak_available]
285 ###############################
286 # proc check_visibility_available { what_kind }
287 ###############################
289 # The visibility attribute is only support in some object formats
290 # This proc returns 1 if it is supported, 0 if not.
291 # The argument is the kind of visibility, default/protected/hidden/internal.
293 proc check_visibility_available { what_kind } {
295 global target_triplet
297 # On NetWare, support makes no sense.
298 if { [istarget *-*-netware*] } {
302 if [string match "" $what_kind] { set what_kind "hidden" }
304 return [check_no_compiler_messages visibility_available_$what_kind object "
305 void f() __attribute__((visibility(\"$what_kind\")));
310 ###############################
311 # proc check_alias_available { }
312 ###############################
314 # Determine if the target toolchain supports the alias attribute.
316 # Returns 2 if the target supports aliases. Returns 1 if the target
317 # only supports weak aliased. Returns 0 if the target does not
318 # support aliases at all. Returns -1 if support for aliases could not
321 proc check_alias_available { } {
322 global alias_available_saved
325 if [info exists alias_available_saved] {
326 verbose "check_alias_available returning saved $alias_available_saved" 2
330 verbose "check_alias_available compiling testfile $src" 2
331 set f [open $src "w"]
332 # Compile a small test program. The definition of "g" is
333 # necessary to keep the Solaris assembler from complaining
335 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
336 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
338 set lines [${tool}_target_compile $src $obj object ""]
340 remote_file build delete $obj
342 if [string match "" $lines] then {
343 # No error messages, everything is OK.
344 set alias_available_saved 2
346 if [regexp "alias definitions not supported" $lines] {
347 verbose "check_alias_available target does not support aliases" 2
349 set objformat [gcc_target_object_format]
351 if { $objformat == "elf" } {
352 verbose "check_alias_available but target uses ELF format, so it ought to" 2
353 set alias_available_saved -1
355 set alias_available_saved 0
358 if [regexp "only weak aliases are supported" $lines] {
359 verbose "check_alias_available target supports only weak aliases" 2
360 set alias_available_saved 1
362 set alias_available_saved -1
367 verbose "check_alias_available returning $alias_available_saved" 2
370 return $alias_available_saved
373 ###############################
374 # proc check_ifunc_available { }
375 ###############################
377 # Determine if the target toolchain supports the ifunc attribute.
379 # Returns 1 if the target supports ifunc. Returns 0 if the target
380 # does not support ifunc.
382 proc check_ifunc_available { } {
383 global ifunc_available_saved
386 if [info exists ifunc_available_saved] {
387 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
391 verbose "check_ifunc_available compiling testfile $src" 2
392 set f [open $src "w"]
394 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
395 puts $f "void g() {}"
396 puts $f "void f() __attribute__((ifunc(\"g\")));"
398 set lines [${tool}_target_compile $src $obj object ""]
400 remote_file build delete $obj
402 if [string match "" $lines] then {
403 set ifunc_available_saved 1
405 set ifunc_available_saved 0
408 verbose "check_ifunc_available returning $ifunc_available_saved" 2
411 return $ifunc_available_saved
414 # Returns true if --gc-sections is supported on the target.
416 proc check_gc_sections_available { } {
417 global gc_sections_available_saved
420 if {![info exists gc_sections_available_saved]} {
421 # Some targets don't support gc-sections despite whatever's
422 # advertised by ld's options.
423 if { [istarget alpha*-*-*]
424 || [istarget ia64-*-*] } {
425 set gc_sections_available_saved 0
429 # elf2flt uses -q (--emit-relocs), which is incompatible with
431 if { [board_info target exists ldflags]
432 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
433 set gc_sections_available_saved 0
437 # VxWorks kernel modules are relocatable objects linked with -r,
438 # while RTP executables are linked with -q (--emit-relocs).
439 # Both of these options are incompatible with --gc-sections.
440 if { [istarget *-*-vxworks*] } {
441 set gc_sections_available_saved 0
445 # Check if the ld used by gcc supports --gc-sections.
446 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
447 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
448 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
449 set ld_output [remote_exec host "$gcc_ld" "--help"]
450 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
451 set gc_sections_available_saved 1
453 set gc_sections_available_saved 0
456 return $gc_sections_available_saved
459 # Return 1 if according to target_info struct and explicit target list
460 # target is supposed to support trampolines.
462 proc check_effective_target_trampolines { } {
463 if [target_info exists no_trampolines] {
466 if { [istarget avr-*-*]
467 || [istarget hppa2.0w-hp-hpux11.23]
468 || [istarget hppa64-hp-hpux11.23] } {
474 # Return 1 if according to target_info struct and explicit target list
475 # target is supposed to keep null pointer checks. This could be due to
476 # use of option fno-delete-null-pointer-checks or hardwired in target.
478 proc check_effective_target_keeps_null_pointer_checks { } {
479 if [target_info exists keeps_null_pointer_checks] {
482 if { [istarget avr-*-*] } {
488 # Return true if profiling is supported on the target.
490 proc check_profiling_available { test_what } {
491 global profiling_available_saved
493 verbose "Profiling argument is <$test_what>" 1
495 # These conditions depend on the argument so examine them before
496 # looking at the cache variable.
498 # Support for -p on solaris2 relies on mcrt1.o which comes with the
499 # vendor compiler. We cannot reliably predict the directory where the
500 # vendor compiler (and thus mcrt1.o) is installed so we can't
501 # necessarily find mcrt1.o even if we have it.
502 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
506 # Support for -p on irix relies on libprof1.a which doesn't appear to
507 # exist on any irix6 system currently posting testsuite results.
508 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
509 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
510 if { [istarget mips*-*-irix*]
511 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
515 # We don't yet support profiling for MIPS16.
516 if { [istarget mips*-*-*]
517 && ![check_effective_target_nomips16]
518 && ([lindex $test_what 1] == "-p"
519 || [lindex $test_what 1] == "-pg") } {
523 # MinGW does not support -p.
524 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
528 # cygwin does not support -p.
529 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
533 # uClibc does not have gcrt1.o.
534 if { [check_effective_target_uclibc]
535 && ([lindex $test_what 1] == "-p"
536 || [lindex $test_what 1] == "-pg") } {
540 # Now examine the cache variable.
541 if {![info exists profiling_available_saved]} {
542 # Some targets don't have any implementation of __bb_init_func or are
543 # missing other needed machinery.
544 if { [istarget mmix-*-*]
545 || [istarget arm*-*-eabi*]
546 || [istarget picochip-*-*]
547 || [istarget *-*-netware*]
548 || [istarget arm*-*-elf]
549 || [istarget arm*-*-symbianelf*]
550 || [istarget avr-*-*]
551 || [istarget bfin-*-*]
552 || [istarget powerpc-*-eabi*]
553 || [istarget powerpc-*-elf]
554 || [istarget cris-*-*]
555 || [istarget crisv32-*-*]
556 || [istarget fido-*-elf]
557 || [istarget h8300-*-*]
558 || [istarget lm32-*-*]
559 || [istarget m32c-*-elf]
560 || [istarget m68k-*-elf]
561 || [istarget m68k-*-uclinux*]
562 || [istarget mep-*-elf]
563 || [istarget mips*-*-elf*]
564 || [istarget moxie-*-elf*]
566 || [istarget xstormy16-*]
567 || [istarget xtensa*-*-elf]
568 || [istarget *-*-rtems*]
569 || [istarget *-*-vxworks*] } {
570 set profiling_available_saved 0
572 set profiling_available_saved 1
576 return $profiling_available_saved
579 # Check to see if a target is "freestanding". This is as per the definition
580 # in Section 4 of C99 standard. Effectively, it is a target which supports no
581 # extra headers or libraries other than what is considered essential.
582 proc check_effective_target_freestanding { } {
583 if { [istarget picochip-*-*] } then {
590 # Return 1 if target has packed layout of structure members by
591 # default, 0 otherwise. Note that this is slightly different than
592 # whether the target has "natural alignment": both attributes may be
595 proc check_effective_target_default_packed { } {
596 return [check_no_compiler_messages default_packed assembly {
597 struct x { char a; long b; } c;
598 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
602 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
603 # documentation, where the test also comes from.
605 proc check_effective_target_pcc_bitfield_type_matters { } {
606 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
607 # bitfields, but let's stick to the example code from the docs.
608 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
609 struct foo1 { char x; char :0; char y; };
610 struct foo2 { char x; int :0; char y; };
611 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
615 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
617 proc add_options_for_tls { flags } {
618 # Tru64 UNIX uses emutls, which relies on a couple of pthread functions
619 # which only live in libpthread, so always pass -pthread for TLS.
620 if { [istarget *-*-osf*] } {
621 return "$flags -pthread"
623 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
624 # libthread, so always pass -pthread for native TLS.
625 # Need to duplicate native TLS check from
626 # check_effective_target_tls_native to avoid recursion.
627 if { [istarget *-*-solaris2.\[89\]*] &&
628 [check_no_messages_and_pattern tls_native "!emutls" assembly {
630 int f (void) { return i; }
631 void g (int j) { i = j; }
633 return "$flags -pthread"
638 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
640 proc check_effective_target_tls {} {
641 return [check_no_compiler_messages tls assembly {
643 int f (void) { return i; }
644 void g (int j) { i = j; }
648 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
650 proc check_effective_target_tls_native {} {
651 # VxWorks uses emulated TLS machinery, but with non-standard helper
652 # functions, so we fail to automatically detect it.
653 global target_triplet
654 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
658 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
660 int f (void) { return i; }
661 void g (int j) { i = j; }
665 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
667 proc check_effective_target_tls_emulated {} {
668 # VxWorks uses emulated TLS machinery, but with non-standard helper
669 # functions, so we fail to automatically detect it.
670 global target_triplet
671 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
675 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
677 int f (void) { return i; }
678 void g (int j) { i = j; }
682 # Return 1 if TLS executables can run correctly, 0 otherwise.
684 proc check_effective_target_tls_runtime {} {
685 return [check_runtime tls_runtime {
686 __thread int thr = 0;
687 int main (void) { return thr; }
691 # Return 1 if -ffunction-sections is supported, 0 otherwise.
693 proc check_effective_target_function_sections {} {
694 # Darwin has its own scheme and silently accepts -ffunction-sections.
695 global target_triplet
696 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
700 return [check_no_compiler_messages functionsections assembly {
702 } "-ffunction-sections"]
705 # Return 1 if compilation with -fgraphite is error-free for trivial
708 proc check_effective_target_fgraphite {} {
709 return [check_no_compiler_messages fgraphite object {
714 # Return 1 if compilation with -fopenmp is error-free for trivial
717 proc check_effective_target_fopenmp {} {
718 return [check_no_compiler_messages fopenmp object {
723 # Return 1 if compilation with -pthread is error-free for trivial
726 proc check_effective_target_pthread {} {
727 return [check_no_compiler_messages pthread object {
732 # Return 1 if compilation with -mpe-aligned-commons is error-free
733 # for trivial code, 0 otherwise.
735 proc check_effective_target_pe_aligned_commons {} {
736 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
737 return [check_no_compiler_messages pe_aligned_commons object {
739 } "-mpe-aligned-commons"]
744 # Return 1 if the target supports -static
745 proc check_effective_target_static {} {
746 return [check_no_compiler_messages static executable {
747 int main (void) { return 0; }
751 # Return 1 if the target supports -fstack-protector
752 proc check_effective_target_fstack_protector {} {
753 return [check_runtime fstack_protector {
754 int main (void) { return 0; }
755 } "-fstack-protector"]
758 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
759 # for trivial code, 0 otherwise.
761 proc check_effective_target_freorder {} {
762 return [check_no_compiler_messages freorder object {
764 } "-freorder-blocks-and-partition"]
767 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
768 # emitted, 0 otherwise. Whether a shared library can actually be built is
769 # out of scope for this test.
771 proc check_effective_target_fpic { } {
772 # Note that M68K has a multilib that supports -fpic but not
773 # -fPIC, so we need to check both. We test with a program that
774 # requires GOT references.
775 foreach arg {fpic fPIC} {
776 if [check_no_compiler_messages $arg object {
777 extern int foo (void); extern int bar;
778 int baz (void) { return foo () + bar; }
786 # Return true if the target supports -mpaired-single (as used on MIPS).
788 proc check_effective_target_mpaired_single { } {
789 return [check_no_compiler_messages mpaired_single object {
794 # Return true if the target has access to FPU instructions.
796 proc check_effective_target_hard_float { } {
797 if { [istarget mips*-*-*] } {
798 return [check_no_compiler_messages hard_float assembly {
799 #if (defined __mips_soft_float || defined __mips16)
805 # This proc is actually checking the availabilty of FPU
806 # support for doubles, so on the RX we must fail if the
807 # 64-bit double multilib has been selected.
808 if { [istarget rx-*-*] } {
810 # return [check_no_compiler_messages hard_float assembly {
811 #if defined __RX_64_BIT_DOUBLES__
817 # The generic test equates hard_float with "no call for adding doubles".
818 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
819 double a (double b, double c) { return b + c; }
823 # Return true if the target is a 64-bit MIPS target.
825 proc check_effective_target_mips64 { } {
826 return [check_no_compiler_messages mips64 assembly {
833 # Return true if the target is a MIPS target that does not produce
836 proc check_effective_target_nomips16 { } {
837 return [check_no_compiler_messages nomips16 object {
841 /* A cheap way of testing for -mflip-mips16. */
842 void foo (void) { asm ("addiu $20,$20,1"); }
843 void bar (void) { asm ("addiu $20,$20,1"); }
848 # Add the options needed for MIPS16 function attributes. At the moment,
849 # we don't support MIPS16 PIC.
851 proc add_options_for_mips16_attribute { flags } {
852 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
855 # Return true if we can force a mode that allows MIPS16 code generation.
856 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
859 proc check_effective_target_mips16_attribute { } {
860 return [check_no_compiler_messages mips16_attribute assembly {
864 #if defined __mips_hard_float \
865 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
866 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
869 } [add_options_for_mips16_attribute ""]]
872 # Return 1 if the target supports long double larger than double when
873 # using the new ABI, 0 otherwise.
875 proc check_effective_target_mips_newabi_large_long_double { } {
876 return [check_no_compiler_messages mips_newabi_large_long_double object {
877 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
881 # Return 1 if the current multilib does not generate PIC by default.
883 proc check_effective_target_nonpic { } {
884 return [check_no_compiler_messages nonpic assembly {
891 # Return 1 if the target does not use a status wrapper.
893 proc check_effective_target_unwrapped { } {
894 if { [target_info needs_status_wrapper] != "" \
895 && [target_info needs_status_wrapper] != "0" } {
901 # Return true if iconv is supported on the target. In particular IBM1047.
903 proc check_iconv_available { test_what } {
906 # If the tool configuration file has not set libiconv, try "-liconv"
907 if { ![info exists libiconv] } {
908 set libiconv "-liconv"
910 set test_what [lindex $test_what 1]
911 return [check_runtime_nocache $test_what [subst {
917 cd = iconv_open ("$test_what", "UTF-8");
918 if (cd == (iconv_t) -1)
925 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
927 proc check_ascii_locale_available { } {
928 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
929 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
936 # Return true if named sections are supported on this target.
938 proc check_named_sections_available { } {
939 return [check_no_compiler_messages named_sections assembly {
940 int __attribute__ ((section("whatever"))) foo;
944 # Return 1 if the target supports Fortran real kinds larger than real(8),
947 # When the target name changes, replace the cached result.
949 proc check_effective_target_fortran_large_real { } {
950 return [check_no_compiler_messages fortran_large_real executable {
952 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
959 # Return 1 if the target supports Fortran integer kinds larger than
960 # integer(8), 0 otherwise.
962 # When the target name changes, replace the cached result.
964 proc check_effective_target_fortran_large_int { } {
965 return [check_no_compiler_messages fortran_large_int executable {
967 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
973 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
975 # When the target name changes, replace the cached result.
977 proc check_effective_target_fortran_integer_16 { } {
978 return [check_no_compiler_messages fortran_integer_16 executable {
985 # Return 1 if we can statically link libgfortran, 0 otherwise.
987 # When the target name changes, replace the cached result.
989 proc check_effective_target_static_libgfortran { } {
990 return [check_no_compiler_messages static_libgfortran executable {
997 proc check_linker_plugin_available { } {
998 return [check_no_compiler_messages_nocache linker_plugin executable {
999 int main() { return 0; }
1000 } "-flto -fuse-linker-plugin"]
1003 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1004 # otherwise. Cache the result.
1006 proc check_750cl_hw_available { } {
1007 return [check_cached_effective_target 750cl_hw_available {
1008 # If this is not the right target then we can skip the test.
1009 if { ![istarget powerpc-*paired*] } {
1012 check_runtime_nocache 750cl_hw_available {
1016 asm volatile ("ps_mul v0,v0,v0");
1018 asm volatile ("ps_mul 0,0,0");
1027 # Return 1 if the target OS supports running SSE executables, 0
1028 # otherwise. Cache the result.
1030 proc check_sse_os_support_available { } {
1031 return [check_cached_effective_target sse_os_support_available {
1032 # If this is not the right target then we can skip the test.
1033 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1035 } elseif { [istarget i?86-*-solaris2*] } {
1036 # The Solaris 2 kernel doesn't save and restore SSE registers
1037 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1038 check_runtime_nocache sse_os_support_available {
1041 __asm__ volatile ("movss %xmm2,%xmm1");
1051 # Return 1 if the target supports executing SSE instructions, 0
1052 # otherwise. Cache the result.
1054 proc check_sse_hw_available { } {
1055 return [check_cached_effective_target sse_hw_available {
1056 # If this is not the right target then we can skip the test.
1057 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1060 check_runtime_nocache sse_hw_available {
1064 unsigned int eax, ebx, ecx, edx;
1065 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1066 return !(edx & bit_SSE);
1074 # Return 1 if the target supports executing SSE2 instructions, 0
1075 # otherwise. Cache the result.
1077 proc check_sse2_hw_available { } {
1078 return [check_cached_effective_target sse2_hw_available {
1079 # If this is not the right target then we can skip the test.
1080 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1083 check_runtime_nocache sse2_hw_available {
1087 unsigned int eax, ebx, ecx, edx;
1088 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1089 return !(edx & bit_SSE2);
1097 # Return 1 if the target supports executing AVX instructions, 0
1098 # otherwise. Cache the result.
1100 proc check_avx_hw_available { } {
1101 return [check_cached_effective_target avx_hw_available {
1102 # If this is not the right target then we can skip the test.
1103 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1106 check_runtime_nocache avx_hw_available {
1110 unsigned int eax, ebx, ecx, edx;
1111 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1112 return ((ecx & (bit_AVX | bit_OSXSAVE))
1113 != (bit_AVX | bit_OSXSAVE));
1121 # Return 1 if the target supports running SSE executables, 0 otherwise.
1123 proc check_effective_target_sse_runtime { } {
1124 if { [check_effective_target_sse]
1125 && [check_sse_hw_available]
1126 && [check_sse_os_support_available] } {
1132 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1134 proc check_effective_target_sse2_runtime { } {
1135 if { [check_effective_target_sse2]
1136 && [check_sse2_hw_available]
1137 && [check_sse_os_support_available] } {
1143 # Return 1 if the target supports running AVX executables, 0 otherwise.
1145 proc check_effective_target_avx_runtime { } {
1146 if { [check_effective_target_avx]
1147 && [check_avx_hw_available] } {
1153 # Return 1 if the target supports executing VSX instructions, 0
1154 # otherwise. Cache the result.
1156 proc check_vsx_hw_available { } {
1157 return [check_cached_effective_target vsx_hw_available {
1158 # Some simulators are known to not support VSX instructions.
1159 # For now, disable on Darwin
1160 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1164 check_runtime_nocache vsx_hw_available {
1168 asm volatile ("xxlor vs0,vs0,vs0");
1170 asm volatile ("xxlor 0,0,0");
1179 # Return 1 if the target supports executing AltiVec instructions, 0
1180 # otherwise. Cache the result.
1182 proc check_vmx_hw_available { } {
1183 return [check_cached_effective_target vmx_hw_available {
1184 # Some simulators are known to not support VMX instructions.
1185 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1188 # Most targets don't require special flags for this test case, but
1189 # Darwin does. Just to be sure, make sure VSX is not enabled for
1190 # the altivec tests.
1191 if { [istarget *-*-darwin*]
1192 || [istarget *-*-aix*] } {
1193 set options "-maltivec -mno-vsx"
1195 set options "-mno-vsx"
1197 check_runtime_nocache vmx_hw_available {
1201 asm volatile ("vor v0,v0,v0");
1203 asm volatile ("vor 0,0,0");
1212 proc check_ppc_recip_hw_available { } {
1213 return [check_cached_effective_target ppc_recip_hw_available {
1214 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1215 # For now, disable on Darwin
1216 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1219 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1220 check_runtime_nocache ppc_recip_hw_available {
1221 volatile double d_recip, d_rsqrt, d_four = 4.0;
1222 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1225 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1226 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1227 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1228 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1236 # Return 1 if the target supports executing AltiVec and Cell PPU
1237 # instructions, 0 otherwise. Cache the result.
1239 proc check_effective_target_cell_hw { } {
1240 return [check_cached_effective_target cell_hw_available {
1241 # Some simulators are known to not support VMX and PPU instructions.
1242 if { [istarget powerpc-*-eabi*] } {
1245 # Most targets don't require special flags for this test
1246 # case, but Darwin and AIX do.
1247 if { [istarget *-*-darwin*]
1248 || [istarget *-*-aix*] } {
1249 set options "-maltivec -mcpu=cell"
1251 set options "-mcpu=cell"
1253 check_runtime_nocache cell_hw_available {
1257 asm volatile ("vor v0,v0,v0");
1258 asm volatile ("lvlx v0,r0,r0");
1260 asm volatile ("vor 0,0,0");
1261 asm volatile ("lvlx 0,0,0");
1270 # Return 1 if the target supports executing 64-bit instructions, 0
1271 # otherwise. Cache the result.
1273 proc check_effective_target_powerpc64 { } {
1274 global powerpc64_available_saved
1277 if [info exists powerpc64_available_saved] {
1278 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1280 set powerpc64_available_saved 0
1282 # Some simulators are known to not support powerpc64 instructions.
1283 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1284 verbose "check_effective_target_powerpc64 returning 0" 2
1285 return $powerpc64_available_saved
1288 # Set up, compile, and execute a test program containing a 64-bit
1289 # instruction. Include the current process ID in the file
1290 # names to prevent conflicts with invocations for multiple
1295 set f [open $src "w"]
1296 puts $f "int main() {"
1297 puts $f "#ifdef __MACH__"
1298 puts $f " asm volatile (\"extsw r0,r0\");"
1300 puts $f " asm volatile (\"extsw 0,0\");"
1302 puts $f " return 0; }"
1305 set opts "additional_flags=-mcpu=G5"
1307 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1308 set lines [${tool}_target_compile $src $exe executable "$opts"]
1311 if [string match "" $lines] then {
1312 # No error message, compilation succeeded.
1313 set result [${tool}_load "./$exe" "" ""]
1314 set status [lindex $result 0]
1315 remote_file build delete $exe
1316 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1318 if { $status == "pass" } then {
1319 set powerpc64_available_saved 1
1322 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1326 return $powerpc64_available_saved
1329 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1330 # complex float arguments. This affects gfortran tests that call cabsf
1331 # in libm built by an earlier compiler. Return 1 if libm uses the same
1332 # argument passing as the compiler under test, 0 otherwise.
1334 # When the target name changes, replace the cached result.
1336 proc check_effective_target_broken_cplxf_arg { } {
1337 return [check_cached_effective_target broken_cplxf_arg {
1338 # Skip the work for targets known not to be affected.
1339 if { ![istarget powerpc64-*-linux*] } {
1341 } elseif { ![is-effective-target lp64] } {
1344 check_runtime_nocache broken_cplxf_arg {
1345 #include <complex.h>
1346 extern void abort (void);
1347 float fabsf (float);
1348 float cabsf (_Complex float);
1355 if (fabsf (f - 5.0) > 0.0001)
1364 proc check_alpha_max_hw_available { } {
1365 return [check_runtime alpha_max_hw_available {
1366 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1370 # Returns true iff the FUNCTION is available on the target system.
1371 # (This is essentially a Tcl implementation of Autoconf's
1374 proc check_function_available { function } {
1375 return [check_no_compiler_messages ${function}_available \
1381 int main () { $function (); }
1385 # Returns true iff "fork" is available on the target system.
1387 proc check_fork_available {} {
1388 return [check_function_available "fork"]
1391 # Returns true iff "mkfifo" is available on the target system.
1393 proc check_mkfifo_available {} {
1394 if {[istarget *-*-cygwin*]} {
1395 # Cygwin has mkfifo, but support is incomplete.
1399 return [check_function_available "mkfifo"]
1402 # Returns true iff "__cxa_atexit" is used on the target system.
1404 proc check_cxa_atexit_available { } {
1405 return [check_cached_effective_target cxa_atexit_available {
1406 if { [istarget "hppa*-*-hpux10*"] } {
1407 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1409 } elseif { [istarget "*-*-vxworks"] } {
1410 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1413 check_runtime_nocache cxa_atexit_available {
1416 static unsigned int count;
1433 Y() { f(); count = 2; }
1442 int main() { return 0; }
1448 proc check_effective_target_objc2 { } {
1449 return [check_no_compiler_messages objc2 object {
1458 proc check_effective_target_next_runtime { } {
1459 return [check_no_compiler_messages objc2 object {
1460 #ifdef __NEXT_RUNTIME__
1468 # Return 1 if we're generating 32-bit code using default options, 0
1471 proc check_effective_target_ilp32 { } {
1472 return [check_no_compiler_messages ilp32 object {
1473 int dummy[sizeof (int) == 4
1474 && sizeof (void *) == 4
1475 && sizeof (long) == 4 ? 1 : -1];
1479 # Return 1 if we're generating 32-bit or larger integers using default
1480 # options, 0 otherwise.
1482 proc check_effective_target_int32plus { } {
1483 return [check_no_compiler_messages int32plus object {
1484 int dummy[sizeof (int) >= 4 ? 1 : -1];
1488 # Return 1 if we're generating 32-bit or larger pointers using default
1489 # options, 0 otherwise.
1491 proc check_effective_target_ptr32plus { } {
1492 return [check_no_compiler_messages ptr32plus object {
1493 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1497 # Return 1 if we support 32-bit or larger array and structure sizes
1498 # using default options, 0 otherwise.
1500 proc check_effective_target_size32plus { } {
1501 return [check_no_compiler_messages size32plus object {
1506 # Returns 1 if we're generating 16-bit or smaller integers with the
1507 # default options, 0 otherwise.
1509 proc check_effective_target_int16 { } {
1510 return [check_no_compiler_messages int16 object {
1511 int dummy[sizeof (int) < 4 ? 1 : -1];
1515 # Return 1 if we're generating 64-bit code using default options, 0
1518 proc check_effective_target_lp64 { } {
1519 return [check_no_compiler_messages lp64 object {
1520 int dummy[sizeof (int) == 4
1521 && sizeof (void *) == 8
1522 && sizeof (long) == 8 ? 1 : -1];
1526 # Return 1 if we're generating 64-bit code using default llp64 options,
1529 proc check_effective_target_llp64 { } {
1530 return [check_no_compiler_messages llp64 object {
1531 int dummy[sizeof (int) == 4
1532 && sizeof (void *) == 8
1533 && sizeof (long long) == 8
1534 && sizeof (long) == 4 ? 1 : -1];
1538 # Return 1 if the target supports long double larger than double,
1541 proc check_effective_target_large_long_double { } {
1542 return [check_no_compiler_messages large_long_double object {
1543 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1547 # Return 1 if the target supports double larger than float,
1550 proc check_effective_target_large_double { } {
1551 return [check_no_compiler_messages large_double object {
1552 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1556 # Return 1 if the target supports double of 64 bits,
1559 proc check_effective_target_double64 { } {
1560 return [check_no_compiler_messages double64 object {
1561 int dummy[sizeof(double) == 8 ? 1 : -1];
1565 # Return 1 if the target supports double of at least 64 bits,
1568 proc check_effective_target_double64plus { } {
1569 return [check_no_compiler_messages double64plus object {
1570 int dummy[sizeof(double) >= 8 ? 1 : -1];
1574 # Return 1 if the target supports compiling fixed-point,
1577 proc check_effective_target_fixed_point { } {
1578 return [check_no_compiler_messages fixed_point object {
1579 _Sat _Fract x; _Sat _Accum y;
1583 # Return 1 if the target supports compiling decimal floating point,
1586 proc check_effective_target_dfp_nocache { } {
1587 verbose "check_effective_target_dfp_nocache: compiling source" 2
1588 set ret [check_no_compiler_messages_nocache dfp object {
1589 float x __attribute__((mode(DD)));
1591 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1595 proc check_effective_target_dfprt_nocache { } {
1596 return [check_runtime_nocache dfprt {
1597 typedef float d64 __attribute__((mode(DD)));
1598 d64 x = 1.2df, y = 2.3dd, z;
1599 int main () { z = x + y; return 0; }
1603 # Return 1 if the target supports compiling Decimal Floating Point,
1606 # This won't change for different subtargets so cache the result.
1608 proc check_effective_target_dfp { } {
1609 return [check_cached_effective_target dfp {
1610 check_effective_target_dfp_nocache
1614 # Return 1 if the target supports linking and executing Decimal Floating
1615 # Point, 0 otherwise.
1617 # This won't change for different subtargets so cache the result.
1619 proc check_effective_target_dfprt { } {
1620 return [check_cached_effective_target dfprt {
1621 check_effective_target_dfprt_nocache
1625 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1627 proc check_effective_target_ucn_nocache { } {
1628 # -std=c99 is only valid for C
1629 if [check_effective_target_c] {
1630 set ucnopts "-std=c99"
1632 append ucnopts " -fextended-identifiers"
1633 verbose "check_effective_target_ucn_nocache: compiling source" 2
1634 set ret [check_no_compiler_messages_nocache ucn object {
1637 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1641 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1643 # This won't change for different subtargets, so cache the result.
1645 proc check_effective_target_ucn { } {
1646 return [check_cached_effective_target ucn {
1647 check_effective_target_ucn_nocache
1651 # Return 1 if the target needs a command line argument to enable a SIMD
1654 proc check_effective_target_vect_cmdline_needed { } {
1655 global et_vect_cmdline_needed_saved
1656 global et_vect_cmdline_needed_target_name
1658 if { ![info exists et_vect_cmdline_needed_target_name] } {
1659 set et_vect_cmdline_needed_target_name ""
1662 # If the target has changed since we set the cached value, clear it.
1663 set current_target [current_target_name]
1664 if { $current_target != $et_vect_cmdline_needed_target_name } {
1665 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1666 set et_vect_cmdline_needed_target_name $current_target
1667 if { [info exists et_vect_cmdline_needed_saved] } {
1668 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1669 unset et_vect_cmdline_needed_saved
1673 if [info exists et_vect_cmdline_needed_saved] {
1674 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1676 set et_vect_cmdline_needed_saved 1
1677 if { [istarget alpha*-*-*]
1678 || [istarget ia64-*-*]
1679 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1680 && [check_effective_target_lp64])
1681 || ([istarget powerpc*-*-*]
1682 && ([check_effective_target_powerpc_spe]
1683 || [check_effective_target_powerpc_altivec]))
1684 || [istarget spu-*-*]
1685 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1686 set et_vect_cmdline_needed_saved 0
1690 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1691 return $et_vect_cmdline_needed_saved
1694 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1696 # This won't change for different subtargets so cache the result.
1698 proc check_effective_target_vect_int { } {
1699 global et_vect_int_saved
1701 if [info exists et_vect_int_saved] {
1702 verbose "check_effective_target_vect_int: using cached result" 2
1704 set et_vect_int_saved 0
1705 if { [istarget i?86-*-*]
1706 || ([istarget powerpc*-*-*]
1707 && ![istarget powerpc-*-linux*paired*])
1708 || [istarget spu-*-*]
1709 || [istarget x86_64-*-*]
1710 || [istarget sparc*-*-*]
1711 || [istarget alpha*-*-*]
1712 || [istarget ia64-*-*]
1713 || [check_effective_target_arm32]
1714 || ([istarget mips*-*-*]
1715 && [check_effective_target_mips_loongson]) } {
1716 set et_vect_int_saved 1
1720 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1721 return $et_vect_int_saved
1724 # Return 1 if the target supports signed int->float conversion
1727 proc check_effective_target_vect_intfloat_cvt { } {
1728 global et_vect_intfloat_cvt_saved
1730 if [info exists et_vect_intfloat_cvt_saved] {
1731 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1733 set et_vect_intfloat_cvt_saved 0
1734 if { [istarget i?86-*-*]
1735 || ([istarget powerpc*-*-*]
1736 && ![istarget powerpc-*-linux*paired*])
1737 || [istarget x86_64-*-*] } {
1738 set et_vect_intfloat_cvt_saved 1
1742 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1743 return $et_vect_intfloat_cvt_saved
1746 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1748 proc check_effective_target_int128 { } {
1749 return [check_no_compiler_messages int128 object {
1751 #ifndef __SIZEOF_INT128__
1760 # Return 1 if the target supports unsigned int->float conversion
1763 proc check_effective_target_vect_uintfloat_cvt { } {
1764 global et_vect_uintfloat_cvt_saved
1766 if [info exists et_vect_uintfloat_cvt_saved] {
1767 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1769 set et_vect_uintfloat_cvt_saved 0
1770 if { [istarget i?86-*-*]
1771 || ([istarget powerpc*-*-*]
1772 && ![istarget powerpc-*-linux*paired*])
1773 || [istarget x86_64-*-*] } {
1774 set et_vect_uintfloat_cvt_saved 1
1778 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1779 return $et_vect_uintfloat_cvt_saved
1783 # Return 1 if the target supports signed float->int conversion
1786 proc check_effective_target_vect_floatint_cvt { } {
1787 global et_vect_floatint_cvt_saved
1789 if [info exists et_vect_floatint_cvt_saved] {
1790 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1792 set et_vect_floatint_cvt_saved 0
1793 if { [istarget i?86-*-*]
1794 || ([istarget powerpc*-*-*]
1795 && ![istarget powerpc-*-linux*paired*])
1796 || [istarget x86_64-*-*] } {
1797 set et_vect_floatint_cvt_saved 1
1801 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1802 return $et_vect_floatint_cvt_saved
1805 # Return 1 if the target supports unsigned float->int conversion
1808 proc check_effective_target_vect_floatuint_cvt { } {
1809 global et_vect_floatuint_cvt_saved
1811 if [info exists et_vect_floatuint_cvt_saved] {
1812 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1814 set et_vect_floatuint_cvt_saved 0
1815 if { ([istarget powerpc*-*-*]
1816 && ![istarget powerpc-*-linux*paired*]) } {
1817 set et_vect_floatuint_cvt_saved 1
1821 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1822 return $et_vect_floatuint_cvt_saved
1825 # Return 1 is this is an arm target using 32-bit instructions
1826 proc check_effective_target_arm32 { } {
1827 return [check_no_compiler_messages arm32 assembly {
1828 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1834 # Return 1 if this is an ARM target that only supports aligned vector accesses
1835 proc check_effective_target_arm_vect_no_misalign { } {
1836 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1837 #if !defined(__arm__) \
1838 || (defined(__ARMEL__) \
1839 && (!defined(__thumb__) || defined(__thumb2__)))
1846 # Return 1 if this is an ARM target supporting -mfpu=vfp
1847 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1850 proc check_effective_target_arm_vfp_ok { } {
1851 if { [check_effective_target_arm32] } {
1852 return [check_no_compiler_messages arm_vfp_ok object {
1854 } "-mfpu=vfp -mfloat-abi=softfp"]
1860 # Return 1 if this is an ARM target supporting -mfpu=vfp
1861 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1864 proc check_effective_target_arm_hard_vfp_ok { } {
1865 if { [check_effective_target_arm32] } {
1866 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1867 int main() { return 0;}
1868 } "-mfpu=vfp -mfloat-abi=hard"]
1874 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1875 # or -mfloat-abi=hard, but if one is already specified by the
1876 # multilib, use it. Similarly, if a -mfpu option already enables
1877 # NEON, do not add -mfpu=neon.
1879 proc add_options_for_arm_neon { flags } {
1880 if { ! [check_effective_target_arm_neon_ok] } {
1883 global et_arm_neon_flags
1884 return "$flags $et_arm_neon_flags"
1887 # Return 1 if this is an ARM target supporting -mfpu=neon
1888 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1889 # incompatible with these options. Also set et_arm_neon_flags to the
1890 # best options to add.
1892 proc check_effective_target_arm_neon_ok_nocache { } {
1893 global et_arm_neon_flags
1894 set et_arm_neon_flags ""
1895 if { [check_effective_target_arm32] } {
1896 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1897 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1898 #include "arm_neon.h"
1901 set et_arm_neon_flags $flags
1910 proc check_effective_target_arm_neon_ok { } {
1911 return [check_cached_effective_target arm_neon_ok \
1912 check_effective_target_arm_neon_ok_nocache]
1915 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1916 # or -mfloat-abi=hard, but if one is already specified by the
1919 proc add_options_for_arm_neon_fp16 { flags } {
1920 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1923 global et_arm_neon_fp16_flags
1924 return "$flags $et_arm_neon_fp16_flags"
1927 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1928 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1929 # incompatible with these options. Also set et_arm_neon_flags to the
1930 # best options to add.
1932 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1933 global et_arm_neon_fp16_flags
1934 set et_arm_neon_fp16_flags ""
1935 if { [check_effective_target_arm32] } {
1936 # Always add -mfpu=neon-fp16, since there is no preprocessor
1937 # macro for FP16 support.
1938 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1939 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1940 #include "arm_neon.h"
1943 set et_arm_neon_fp16_flags $flags
1952 proc check_effective_target_arm_neon_fp16_ok { } {
1953 return [check_cached_effective_target arm_neon_fp16_ok \
1954 check_effective_target_arm_neon_fp16_ok_nocache]
1957 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1960 proc check_effective_target_arm_thumb1_ok { } {
1961 return [check_no_compiler_messages arm_thumb1_ok assembly {
1962 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1968 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1971 proc check_effective_target_arm_thumb2_ok { } {
1972 return [check_no_compiler_messages arm_thumb2_ok assembly {
1973 #if !defined(__thumb2__)
1979 # Return 1 if the target supports executing NEON instructions, 0
1980 # otherwise. Cache the result.
1982 proc check_effective_target_arm_neon_hw { } {
1983 return [check_runtime arm_neon_hw_available {
1987 long long a = 0, b = 1;
1988 asm ("vorr %P0, %P1, %P2"
1990 : "0" (a), "w" (b));
1993 } [add_options_for_arm_neon ""]]
1996 # Return 1 if this is a ARM target with NEON enabled.
1998 proc check_effective_target_arm_neon { } {
1999 if { [check_effective_target_arm32] } {
2000 return [check_no_compiler_messages arm_neon object {
2001 #ifndef __ARM_NEON__
2012 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2013 # the Loongson vector modes.
2015 proc check_effective_target_mips_loongson { } {
2016 return [check_no_compiler_messages loongson assembly {
2017 #if !defined(__mips_loongson_vector_rev)
2023 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2026 proc check_effective_target_arm_eabi { } {
2027 return [check_no_compiler_messages arm_eabi object {
2028 #ifndef __ARM_EABI__
2036 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2037 # Some multilibs may be incompatible with this option.
2039 proc check_effective_target_arm_iwmmxt_ok { } {
2040 if { [check_effective_target_arm32] } {
2041 return [check_no_compiler_messages arm_iwmmxt_ok object {
2049 # Return 1 if this is a PowerPC target with floating-point registers.
2051 proc check_effective_target_powerpc_fprs { } {
2052 if { [istarget powerpc*-*-*]
2053 || [istarget rs6000-*-*] } {
2054 return [check_no_compiler_messages powerpc_fprs object {
2066 # Return 1 if this is a PowerPC target with hardware double-precision
2069 proc check_effective_target_powerpc_hard_double { } {
2070 if { [istarget powerpc*-*-*]
2071 || [istarget rs6000-*-*] } {
2072 return [check_no_compiler_messages powerpc_hard_double object {
2084 # Return 1 if this is a PowerPC target supporting -maltivec.
2086 proc check_effective_target_powerpc_altivec_ok { } {
2087 if { ([istarget powerpc*-*-*]
2088 && ![istarget powerpc-*-linux*paired*])
2089 || [istarget rs6000-*-*] } {
2090 # AltiVec is not supported on AIX before 5.3.
2091 if { [istarget powerpc*-*-aix4*]
2092 || [istarget powerpc*-*-aix5.1*]
2093 || [istarget powerpc*-*-aix5.2*] } {
2096 return [check_no_compiler_messages powerpc_altivec_ok object {
2104 # Return 1 if this is a PowerPC target supporting -mvsx
2106 proc check_effective_target_powerpc_vsx_ok { } {
2107 if { ([istarget powerpc*-*-*]
2108 && ![istarget powerpc-*-linux*paired*])
2109 || [istarget rs6000-*-*] } {
2110 # AltiVec is not supported on AIX before 5.3.
2111 if { [istarget powerpc*-*-aix4*]
2112 || [istarget powerpc*-*-aix5.1*]
2113 || [istarget powerpc*-*-aix5.2*] } {
2116 return [check_no_compiler_messages powerpc_vsx_ok object {
2119 asm volatile ("xxlor vs0,vs0,vs0");
2121 asm volatile ("xxlor 0,0,0");
2131 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2133 proc check_effective_target_powerpc_ppu_ok { } {
2134 if [check_effective_target_powerpc_altivec_ok] {
2135 return [check_no_compiler_messages cell_asm_available object {
2138 asm volatile ("lvlx v0,v0,v0");
2140 asm volatile ("lvlx 0,0,0");
2150 # Return 1 if this is a PowerPC target that supports SPU.
2152 proc check_effective_target_powerpc_spu { } {
2153 if [istarget powerpc*-*-linux*] {
2154 return [check_effective_target_powerpc_altivec_ok]
2160 # Return 1 if this is a PowerPC SPE target. The check includes options
2161 # specified by dg-options for this test, so don't cache the result.
2163 proc check_effective_target_powerpc_spe_nocache { } {
2164 if { [istarget powerpc*-*-*] } {
2165 return [check_no_compiler_messages_nocache powerpc_spe object {
2171 } [current_compiler_flags]]
2177 # Return 1 if this is a PowerPC target with SPE enabled.
2179 proc check_effective_target_powerpc_spe { } {
2180 if { [istarget powerpc*-*-*] } {
2181 return [check_no_compiler_messages powerpc_spe object {
2193 # Return 1 if this is a PowerPC target with Altivec enabled.
2195 proc check_effective_target_powerpc_altivec { } {
2196 if { [istarget powerpc*-*-*] } {
2197 return [check_no_compiler_messages powerpc_altivec object {
2209 # Return 1 if this is a PowerPC 405 target. The check includes options
2210 # specified by dg-options for this test, so don't cache the result.
2212 proc check_effective_target_powerpc_405_nocache { } {
2213 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2214 return [check_no_compiler_messages_nocache powerpc_405 object {
2220 } [current_compiler_flags]]
2226 # Return 1 if this is a SPU target with a toolchain that
2227 # supports automatic overlay generation.
2229 proc check_effective_target_spu_auto_overlay { } {
2230 if { [istarget spu*-*-elf*] } {
2231 return [check_no_compiler_messages spu_auto_overlay executable {
2233 } "-Wl,--auto-overlay" ]
2239 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2240 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2241 # test environment appears to run executables on such a simulator.
2243 proc check_effective_target_ultrasparc_hw { } {
2244 return [check_runtime ultrasparc_hw {
2245 int main() { return 0; }
2246 } "-mcpu=ultrasparc"]
2249 # Return 1 if the target supports hardware vector shift operation.
2251 proc check_effective_target_vect_shift { } {
2252 global et_vect_shift_saved
2254 if [info exists et_vect_shift_saved] {
2255 verbose "check_effective_target_vect_shift: using cached result" 2
2257 set et_vect_shift_saved 0
2258 if { ([istarget powerpc*-*-*]
2259 && ![istarget powerpc-*-linux*paired*])
2260 || [istarget ia64-*-*]
2261 || [istarget i?86-*-*]
2262 || [istarget x86_64-*-*]
2263 || [check_effective_target_arm32]
2264 || ([istarget mips*-*-*]
2265 && [check_effective_target_mips_loongson]) } {
2266 set et_vect_shift_saved 1
2270 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2271 return $et_vect_shift_saved
2274 # Return 1 if the target supports hardware vector shift operation with
2275 # scalar shift argument.
2277 proc check_effective_target_vect_shift_scalar { } {
2278 global et_vect_shift_scalar_saved
2280 if [info exists et_vect_shift_scalar_saved] {
2281 verbose "check_effective_target_vect_shift_scalar: using cached result" 2
2283 set et_vect_shift_scalar_saved 0
2284 if { [istarget x86_64-*-*]
2285 || [istarget i?86-*-*] } {
2286 set et_vect_shift_scalar_saved 1
2290 verbose "check_effective_target_vect_shift_scalar: returning $et_vect_shift_scalar_saved" 2
2291 return $et_vect_shift_scalar_saved
2295 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2297 # This can change for different subtargets so do not cache the result.
2299 proc check_effective_target_vect_long { } {
2300 if { [istarget i?86-*-*]
2301 || (([istarget powerpc*-*-*]
2302 && ![istarget powerpc-*-linux*paired*])
2303 && [check_effective_target_ilp32])
2304 || [istarget x86_64-*-*]
2305 || [check_effective_target_arm32]
2306 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2312 verbose "check_effective_target_vect_long: returning $answer" 2
2316 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2318 # This won't change for different subtargets so cache the result.
2320 proc check_effective_target_vect_float { } {
2321 global et_vect_float_saved
2323 if [info exists et_vect_float_saved] {
2324 verbose "check_effective_target_vect_float: using cached result" 2
2326 set et_vect_float_saved 0
2327 if { [istarget i?86-*-*]
2328 || [istarget powerpc*-*-*]
2329 || [istarget spu-*-*]
2330 || [istarget mipsisa64*-*-*]
2331 || [istarget x86_64-*-*]
2332 || [istarget ia64-*-*]
2333 || [check_effective_target_arm32] } {
2334 set et_vect_float_saved 1
2338 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2339 return $et_vect_float_saved
2342 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2344 # This won't change for different subtargets so cache the result.
2346 proc check_effective_target_vect_double { } {
2347 global et_vect_double_saved
2349 if [info exists et_vect_double_saved] {
2350 verbose "check_effective_target_vect_double: using cached result" 2
2352 set et_vect_double_saved 0
2353 if { [istarget i?86-*-*]
2354 || [istarget x86_64-*-*] } {
2355 if { [check_no_compiler_messages vect_double assembly {
2356 #ifdef __tune_atom__
2357 # error No double vectorizer support.
2360 set et_vect_double_saved 1
2362 set et_vect_double_saved 0
2364 } elseif { [istarget spu-*-*] } {
2365 set et_vect_double_saved 1
2369 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2370 return $et_vect_double_saved
2373 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2375 # This won't change for different subtargets so cache the result.
2377 proc check_effective_target_vect_long_long { } {
2378 global et_vect_long_long_saved
2380 if [info exists et_vect_long_long_saved] {
2381 verbose "check_effective_target_vect_long_long: using cached result" 2
2383 set et_vect_long_long_saved 0
2384 if { [istarget i?86-*-*]
2385 || [istarget x86_64-*-*] } {
2386 set et_vect_long_long_saved 1
2390 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2391 return $et_vect_long_long_saved
2395 # Return 1 if the target plus current options does not support a vector
2396 # max instruction on "int", 0 otherwise.
2398 # This won't change for different subtargets so cache the result.
2400 proc check_effective_target_vect_no_int_max { } {
2401 global et_vect_no_int_max_saved
2403 if [info exists et_vect_no_int_max_saved] {
2404 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2406 set et_vect_no_int_max_saved 0
2407 if { [istarget sparc*-*-*]
2408 || [istarget spu-*-*]
2409 || [istarget alpha*-*-*]
2410 || ([istarget mips*-*-*]
2411 && [check_effective_target_mips_loongson]) } {
2412 set et_vect_no_int_max_saved 1
2415 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2416 return $et_vect_no_int_max_saved
2419 # Return 1 if the target plus current options does not support a vector
2420 # add instruction on "int", 0 otherwise.
2422 # This won't change for different subtargets so cache the result.
2424 proc check_effective_target_vect_no_int_add { } {
2425 global et_vect_no_int_add_saved
2427 if [info exists et_vect_no_int_add_saved] {
2428 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2430 set et_vect_no_int_add_saved 0
2431 # Alpha only supports vector add on V8QI and V4HI.
2432 if { [istarget alpha*-*-*] } {
2433 set et_vect_no_int_add_saved 1
2436 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2437 return $et_vect_no_int_add_saved
2440 # Return 1 if the target plus current options does not support vector
2441 # bitwise instructions, 0 otherwise.
2443 # This won't change for different subtargets so cache the result.
2445 proc check_effective_target_vect_no_bitwise { } {
2446 global et_vect_no_bitwise_saved
2448 if [info exists et_vect_no_bitwise_saved] {
2449 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2451 set et_vect_no_bitwise_saved 0
2453 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2454 return $et_vect_no_bitwise_saved
2457 # Return 1 if the target plus current options supports vector permutation,
2460 # This won't change for different subtargets so cache the result.
2462 proc check_effective_target_vect_perm { } {
2465 if [info exists et_vect_perm_saved] {
2466 verbose "check_effective_target_vect_perm: using cached result" 2
2468 set et_vect_perm_saved 0
2469 if { [istarget powerpc*-*-*]
2470 || [istarget spu-*-*]
2471 || [istarget i?86-*-*]
2472 || [istarget x86_64-*-*] } {
2473 set et_vect_perm_saved 1
2476 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2477 return $et_vect_perm_saved
2480 # Return 1 if the target plus current options supports vector permutation
2481 # on byte-sized elements, 0 otherwise.
2483 # This won't change for different subtargets so cache the result.
2485 proc check_effective_target_vect_perm_byte { } {
2486 global et_vect_perm_byte
2488 if [info exists et_vect_perm_byte_saved] {
2489 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2491 set et_vect_perm_byte_saved 0
2492 if { [istarget powerpc*-*-*]
2493 || [istarget spu-*-*] } {
2494 set et_vect_perm_byte_saved 1
2497 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2498 return $et_vect_perm_byte_saved
2501 # Return 1 if the target plus current options supports vector permutation
2502 # on short-sized elements, 0 otherwise.
2504 # This won't change for different subtargets so cache the result.
2506 proc check_effective_target_vect_perm_short { } {
2507 global et_vect_perm_short
2509 if [info exists et_vect_perm_short_saved] {
2510 verbose "check_effective_target_vect_perm_short: using cached result" 2
2512 set et_vect_perm_short_saved 0
2513 if { [istarget powerpc*-*-*]
2514 || [istarget spu-*-*] } {
2515 set et_vect_perm_short_saved 1
2518 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2519 return $et_vect_perm_short_saved
2522 # Return 1 if the target plus current options supports a vector
2523 # widening summation of *short* args into *int* result, 0 otherwise.
2525 # This won't change for different subtargets so cache the result.
2527 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2528 global et_vect_widen_sum_hi_to_si_pattern
2530 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2531 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2533 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2534 if { [istarget powerpc*-*-*]
2535 || [istarget ia64-*-*] } {
2536 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2539 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2540 return $et_vect_widen_sum_hi_to_si_pattern_saved
2543 # Return 1 if the target plus current options supports a vector
2544 # widening summation of *short* args into *int* result, 0 otherwise.
2545 # A target can also support this widening summation if it can support
2546 # promotion (unpacking) from shorts to ints.
2548 # This won't change for different subtargets so cache the result.
2550 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2551 global et_vect_widen_sum_hi_to_si
2553 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2554 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2556 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2557 if { [istarget powerpc*-*-*]
2558 || [istarget ia64-*-*] } {
2559 set et_vect_widen_sum_hi_to_si_saved 1
2562 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2563 return $et_vect_widen_sum_hi_to_si_saved
2566 # Return 1 if the target plus current options supports a vector
2567 # widening summation of *char* args into *short* result, 0 otherwise.
2568 # A target can also support this widening summation if it can support
2569 # promotion (unpacking) from chars to shorts.
2571 # This won't change for different subtargets so cache the result.
2573 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2574 global et_vect_widen_sum_qi_to_hi
2576 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2577 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2579 set et_vect_widen_sum_qi_to_hi_saved 0
2580 if { [check_effective_target_vect_unpack]
2581 || [istarget ia64-*-*] } {
2582 set et_vect_widen_sum_qi_to_hi_saved 1
2585 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2586 return $et_vect_widen_sum_qi_to_hi_saved
2589 # Return 1 if the target plus current options supports a vector
2590 # widening summation of *char* args into *int* result, 0 otherwise.
2592 # This won't change for different subtargets so cache the result.
2594 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2595 global et_vect_widen_sum_qi_to_si
2597 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2598 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2600 set et_vect_widen_sum_qi_to_si_saved 0
2601 if { [istarget powerpc*-*-*] } {
2602 set et_vect_widen_sum_qi_to_si_saved 1
2605 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2606 return $et_vect_widen_sum_qi_to_si_saved
2609 # Return 1 if the target plus current options supports a vector
2610 # widening multiplication of *char* args into *short* result, 0 otherwise.
2611 # A target can also support this widening multplication if it can support
2612 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2613 # multiplication of shorts).
2615 # This won't change for different subtargets so cache the result.
2618 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2619 global et_vect_widen_mult_qi_to_hi
2621 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2622 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2624 if { [check_effective_target_vect_unpack]
2625 && [check_effective_target_vect_short_mult] } {
2626 set et_vect_widen_mult_qi_to_hi_saved 1
2628 set et_vect_widen_mult_qi_to_hi_saved 0
2630 if { [istarget powerpc*-*-*] } {
2631 set et_vect_widen_mult_qi_to_hi_saved 1
2634 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2635 return $et_vect_widen_mult_qi_to_hi_saved
2638 # Return 1 if the target plus current options supports a vector
2639 # widening multiplication of *short* args into *int* result, 0 otherwise.
2640 # A target can also support this widening multplication if it can support
2641 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2642 # multiplication of ints).
2644 # This won't change for different subtargets so cache the result.
2647 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2648 global et_vect_widen_mult_hi_to_si
2650 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2651 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2653 if { [check_effective_target_vect_unpack]
2654 && [check_effective_target_vect_int_mult] } {
2655 set et_vect_widen_mult_hi_to_si_saved 1
2657 set et_vect_widen_mult_hi_to_si_saved 0
2659 if { [istarget powerpc*-*-*]
2660 || [istarget spu-*-*]
2661 || [istarget ia64-*-*]
2662 || [istarget i?86-*-*]
2663 || [istarget x86_64-*-*] } {
2664 set et_vect_widen_mult_hi_to_si_saved 1
2667 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2668 return $et_vect_widen_mult_hi_to_si_saved
2671 # Return 1 if the target plus current options supports a vector
2672 # dot-product of signed chars, 0 otherwise.
2674 # This won't change for different subtargets so cache the result.
2676 proc check_effective_target_vect_sdot_qi { } {
2677 global et_vect_sdot_qi
2679 if [info exists et_vect_sdot_qi_saved] {
2680 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2682 set et_vect_sdot_qi_saved 0
2683 if { [istarget ia64-*-*] } {
2684 set et_vect_udot_qi_saved 1
2687 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2688 return $et_vect_sdot_qi_saved
2691 # Return 1 if the target plus current options supports a vector
2692 # dot-product of unsigned chars, 0 otherwise.
2694 # This won't change for different subtargets so cache the result.
2696 proc check_effective_target_vect_udot_qi { } {
2697 global et_vect_udot_qi
2699 if [info exists et_vect_udot_qi_saved] {
2700 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2702 set et_vect_udot_qi_saved 0
2703 if { [istarget powerpc*-*-*]
2704 || [istarget ia64-*-*] } {
2705 set et_vect_udot_qi_saved 1
2708 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2709 return $et_vect_udot_qi_saved
2712 # Return 1 if the target plus current options supports a vector
2713 # dot-product of signed shorts, 0 otherwise.
2715 # This won't change for different subtargets so cache the result.
2717 proc check_effective_target_vect_sdot_hi { } {
2718 global et_vect_sdot_hi
2720 if [info exists et_vect_sdot_hi_saved] {
2721 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2723 set et_vect_sdot_hi_saved 0
2724 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2725 || [istarget ia64-*-*]
2726 || [istarget i?86-*-*]
2727 || [istarget x86_64-*-*] } {
2728 set et_vect_sdot_hi_saved 1
2731 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2732 return $et_vect_sdot_hi_saved
2735 # Return 1 if the target plus current options supports a vector
2736 # dot-product of unsigned shorts, 0 otherwise.
2738 # This won't change for different subtargets so cache the result.
2740 proc check_effective_target_vect_udot_hi { } {
2741 global et_vect_udot_hi
2743 if [info exists et_vect_udot_hi_saved] {
2744 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2746 set et_vect_udot_hi_saved 0
2747 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2748 set et_vect_udot_hi_saved 1
2751 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2752 return $et_vect_udot_hi_saved
2756 # Return 1 if the target plus current options supports a vector
2757 # demotion (packing) of shorts (to chars) and ints (to shorts)
2758 # using modulo arithmetic, 0 otherwise.
2760 # This won't change for different subtargets so cache the result.
2762 proc check_effective_target_vect_pack_trunc { } {
2763 global et_vect_pack_trunc
2765 if [info exists et_vect_pack_trunc_saved] {
2766 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2768 set et_vect_pack_trunc_saved 0
2769 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2770 || [istarget i?86-*-*]
2771 || [istarget x86_64-*-*]
2772 || [istarget spu-*-*]
2773 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2774 set et_vect_pack_trunc_saved 1
2777 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2778 return $et_vect_pack_trunc_saved
2781 # Return 1 if the target plus current options supports a vector
2782 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2784 # This won't change for different subtargets so cache the result.
2786 proc check_effective_target_vect_unpack { } {
2787 global et_vect_unpack
2789 if [info exists et_vect_unpack_saved] {
2790 verbose "check_effective_target_vect_unpack: using cached result" 2
2792 set et_vect_unpack_saved 0
2793 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2794 || [istarget i?86-*-*]
2795 || [istarget x86_64-*-*]
2796 || [istarget spu-*-*]
2797 || [istarget ia64-*-*]
2798 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2799 set et_vect_unpack_saved 1
2802 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2803 return $et_vect_unpack_saved
2806 # Return 1 if the target plus current options does not guarantee
2807 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2809 # This won't change for different subtargets so cache the result.
2811 proc check_effective_target_unaligned_stack { } {
2812 global et_unaligned_stack_saved
2814 if [info exists et_unaligned_stack_saved] {
2815 verbose "check_effective_target_unaligned_stack: using cached result" 2
2817 set et_unaligned_stack_saved 0
2819 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2820 return $et_unaligned_stack_saved
2823 # Return 1 if the target plus current options does not support a vector
2824 # alignment mechanism, 0 otherwise.
2826 # This won't change for different subtargets so cache the result.
2828 proc check_effective_target_vect_no_align { } {
2829 global et_vect_no_align_saved
2831 if [info exists et_vect_no_align_saved] {
2832 verbose "check_effective_target_vect_no_align: using cached result" 2
2834 set et_vect_no_align_saved 0
2835 if { [istarget mipsisa64*-*-*]
2836 || [istarget sparc*-*-*]
2837 || [istarget ia64-*-*]
2838 || [check_effective_target_arm_vect_no_misalign]
2839 || ([istarget mips*-*-*]
2840 && [check_effective_target_mips_loongson]) } {
2841 set et_vect_no_align_saved 1
2844 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2845 return $et_vect_no_align_saved
2848 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2850 # This won't change for different subtargets so cache the result.
2852 proc check_effective_target_vect_hw_misalign { } {
2853 global et_vect_hw_misalign_saved
2855 if [info exists et_vect_hw_misalign_saved] {
2856 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2858 set et_vect_hw_misalign_saved 0
2859 if { ([istarget x86_64-*-*]
2860 || [istarget i?86-*-*]) } {
2861 set et_vect_hw_misalign_saved 1
2864 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2865 return $et_vect_hw_misalign_saved
2869 # Return 1 if arrays are aligned to the vector alignment
2870 # boundary, 0 otherwise.
2872 # This won't change for different subtargets so cache the result.
2874 proc check_effective_target_vect_aligned_arrays { } {
2875 global et_vect_aligned_arrays
2877 if [info exists et_vect_aligned_arrays_saved] {
2878 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2880 set et_vect_aligned_arrays_saved 0
2881 if { (([istarget x86_64-*-*]
2882 || [istarget i?86-*-*]) && [is-effective-target lp64])
2883 || [istarget spu-*-*] } {
2884 set et_vect_aligned_arrays_saved 1
2887 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2888 return $et_vect_aligned_arrays_saved
2891 # Return 1 if types of size 32 bit or less are naturally aligned
2892 # (aligned to their type-size), 0 otherwise.
2894 # This won't change for different subtargets so cache the result.
2896 proc check_effective_target_natural_alignment_32 { } {
2897 global et_natural_alignment_32
2899 if [info exists et_natural_alignment_32_saved] {
2900 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2902 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2903 set et_natural_alignment_32_saved 1
2904 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2905 set et_natural_alignment_32_saved 0
2908 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2909 return $et_natural_alignment_32_saved
2912 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2913 # type-size), 0 otherwise.
2915 # This won't change for different subtargets so cache the result.
2917 proc check_effective_target_natural_alignment_64 { } {
2918 global et_natural_alignment_64
2920 if [info exists et_natural_alignment_64_saved] {
2921 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2923 set et_natural_alignment_64_saved 0
2924 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2925 || [istarget spu-*-*] } {
2926 set et_natural_alignment_64_saved 1
2929 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2930 return $et_natural_alignment_64_saved
2933 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2935 # This won't change for different subtargets so cache the result.
2937 proc check_effective_target_vector_alignment_reachable { } {
2938 global et_vector_alignment_reachable
2940 if [info exists et_vector_alignment_reachable_saved] {
2941 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2943 if { [check_effective_target_vect_aligned_arrays]
2944 || [check_effective_target_natural_alignment_32] } {
2945 set et_vector_alignment_reachable_saved 1
2947 set et_vector_alignment_reachable_saved 0
2950 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2951 return $et_vector_alignment_reachable_saved
2954 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2956 # This won't change for different subtargets so cache the result.
2958 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2959 global et_vector_alignment_reachable_for_64bit
2961 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2962 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2964 if { [check_effective_target_vect_aligned_arrays]
2965 || [check_effective_target_natural_alignment_64] } {
2966 set et_vector_alignment_reachable_for_64bit_saved 1
2968 set et_vector_alignment_reachable_for_64bit_saved 0
2971 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2972 return $et_vector_alignment_reachable_for_64bit_saved
2975 # Return 1 if the target only requires element alignment for vector accesses
2977 proc check_effective_target_vect_element_align { } {
2978 global et_vect_element_align
2980 if [info exists et_vect_element_align] {
2981 verbose "check_effective_target_vect_element_align: using cached result" 2
2983 set et_vect_element_align 0
2984 if { [istarget arm*-*-*]
2985 || [check_effective_target_vect_hw_misalign] } {
2986 set et_vect_element_align 1
2990 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
2991 return $et_vect_element_align
2994 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2996 proc check_effective_target_vect_condition { } {
2997 global et_vect_cond_saved
2999 if [info exists et_vect_cond_saved] {
3000 verbose "check_effective_target_vect_cond: using cached result" 2
3002 set et_vect_cond_saved 0
3003 if { [istarget powerpc*-*-*]
3004 || [istarget ia64-*-*]
3005 || [istarget i?86-*-*]
3006 || [istarget spu-*-*]
3007 || [istarget x86_64-*-*] } {
3008 set et_vect_cond_saved 1
3012 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3013 return $et_vect_cond_saved
3016 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3018 proc check_effective_target_vect_char_mult { } {
3019 global et_vect_char_mult_saved
3021 if [info exists et_vect_char_mult_saved] {
3022 verbose "check_effective_target_vect_char_mult: using cached result" 2
3024 set et_vect_char_mult_saved 0
3025 if { [istarget ia64-*-*]
3026 || [istarget i?86-*-*]
3027 || [istarget x86_64-*-*] } {
3028 set et_vect_char_mult_saved 1
3032 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3033 return $et_vect_char_mult_saved
3036 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3038 proc check_effective_target_vect_short_mult { } {
3039 global et_vect_short_mult_saved
3041 if [info exists et_vect_short_mult_saved] {
3042 verbose "check_effective_target_vect_short_mult: using cached result" 2
3044 set et_vect_short_mult_saved 0
3045 if { [istarget ia64-*-*]
3046 || [istarget spu-*-*]
3047 || [istarget i?86-*-*]
3048 || [istarget x86_64-*-*]
3049 || [istarget powerpc*-*-*]
3050 || [check_effective_target_arm32]
3051 || ([istarget mips*-*-*]
3052 && [check_effective_target_mips_loongson]) } {
3053 set et_vect_short_mult_saved 1
3057 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3058 return $et_vect_short_mult_saved
3061 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3063 proc check_effective_target_vect_int_mult { } {
3064 global et_vect_int_mult_saved
3066 if [info exists et_vect_int_mult_saved] {
3067 verbose "check_effective_target_vect_int_mult: using cached result" 2
3069 set et_vect_int_mult_saved 0
3070 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3071 || [istarget spu-*-*]
3072 || [istarget i?86-*-*]
3073 || [istarget x86_64-*-*]
3074 || [istarget ia64-*-*]
3075 || [check_effective_target_arm32] } {
3076 set et_vect_int_mult_saved 1
3080 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3081 return $et_vect_int_mult_saved
3084 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3086 proc check_effective_target_vect_extract_even_odd { } {
3087 global et_vect_extract_even_odd_saved
3089 if [info exists et_vect_extract_even_odd_saved] {
3090 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3092 set et_vect_extract_even_odd_saved 0
3093 if { [istarget powerpc*-*-*]
3094 || [istarget i?86-*-*]
3095 || [istarget x86_64-*-*]
3096 || [istarget ia64-*-*]
3097 || [istarget spu-*-*] } {
3098 set et_vect_extract_even_odd_saved 1
3102 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3103 return $et_vect_extract_even_odd_saved
3106 # Return 1 if the target supports vector even/odd elements extraction of
3107 # vectors with SImode elements or larger, 0 otherwise.
3109 proc check_effective_target_vect_extract_even_odd_wide { } {
3110 global et_vect_extract_even_odd_wide_saved
3112 if [info exists et_vect_extract_even_odd_wide_saved] {
3113 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
3115 set et_vect_extract_even_odd_wide_saved 0
3116 if { [istarget powerpc*-*-*]
3117 || [istarget i?86-*-*]
3118 || [istarget x86_64-*-*]
3119 || [istarget ia64-*-*]
3120 || [istarget spu-*-*] } {
3121 set et_vect_extract_even_odd_wide_saved 1
3125 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
3126 return $et_vect_extract_even_odd_wide_saved
3129 # Return 1 if the target supports vector interleaving, 0 otherwise.
3131 proc check_effective_target_vect_interleave { } {
3132 global et_vect_interleave_saved
3134 if [info exists et_vect_interleave_saved] {
3135 verbose "check_effective_target_vect_interleave: using cached result" 2
3137 set et_vect_interleave_saved 0
3138 if { [istarget powerpc*-*-*]
3139 || [istarget i?86-*-*]
3140 || [istarget x86_64-*-*]
3141 || [istarget ia64-*-*]
3142 || [istarget spu-*-*] } {
3143 set et_vect_interleave_saved 1
3147 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3148 return $et_vect_interleave_saved
3151 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
3152 proc check_effective_target_vect_strided { } {
3153 global et_vect_strided_saved
3155 if [info exists et_vect_strided_saved] {
3156 verbose "check_effective_target_vect_strided: using cached result" 2
3158 set et_vect_strided_saved 0
3159 if { [check_effective_target_vect_interleave]
3160 && [check_effective_target_vect_extract_even_odd] } {
3161 set et_vect_strided_saved 1
3165 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
3166 return $et_vect_strided_saved
3169 # Return 1 if the target supports vector interleaving and extract even/odd
3170 # for wide element types, 0 otherwise.
3171 proc check_effective_target_vect_strided_wide { } {
3172 global et_vect_strided_wide_saved
3174 if [info exists et_vect_strided_wide_saved] {
3175 verbose "check_effective_target_vect_strided_wide: using cached result" 2
3177 set et_vect_strided_wide_saved 0
3178 if { [check_effective_target_vect_interleave]
3179 && [check_effective_target_vect_extract_even_odd_wide] } {
3180 set et_vect_strided_wide_saved 1
3184 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
3185 return $et_vect_strided_wide_saved
3188 # Return 1 if the target supports section-anchors
3190 proc check_effective_target_section_anchors { } {
3191 global et_section_anchors_saved
3193 if [info exists et_section_anchors_saved] {
3194 verbose "check_effective_target_section_anchors: using cached result" 2
3196 set et_section_anchors_saved 0
3197 if { [istarget powerpc*-*-*]
3198 || [istarget arm*-*-*] } {
3199 set et_section_anchors_saved 1
3203 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3204 return $et_section_anchors_saved
3207 # Return 1 if the target supports atomic operations on "int" and "long".
3209 proc check_effective_target_sync_int_long { } {
3210 global et_sync_int_long_saved
3212 if [info exists et_sync_int_long_saved] {
3213 verbose "check_effective_target_sync_int_long: using cached result" 2
3215 set et_sync_int_long_saved 0
3216 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3217 # load-reserved/store-conditional instructions.
3218 if { [istarget ia64-*-*]
3219 || [istarget i?86-*-*]
3220 || [istarget x86_64-*-*]
3221 || [istarget alpha*-*-*]
3222 || [istarget arm*-*-linux-gnueabi]
3223 || [istarget bfin*-*linux*]
3224 || [istarget hppa*-*linux*]
3225 || [istarget s390*-*-*]
3226 || [istarget powerpc*-*-*]
3227 || [istarget sparc64-*-*]
3228 || [istarget sparcv9-*-*]
3229 || [istarget mips*-*-*] } {
3230 set et_sync_int_long_saved 1
3234 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3235 return $et_sync_int_long_saved
3238 # Return 1 if the target supports atomic operations on "char" and "short".
3240 proc check_effective_target_sync_char_short { } {
3241 global et_sync_char_short_saved
3243 if [info exists et_sync_char_short_saved] {
3244 verbose "check_effective_target_sync_char_short: using cached result" 2
3246 set et_sync_char_short_saved 0
3247 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3248 # load-reserved/store-conditional instructions.
3249 if { [istarget ia64-*-*]
3250 || [istarget i?86-*-*]
3251 || [istarget x86_64-*-*]
3252 || [istarget alpha*-*-*]
3253 || [istarget arm*-*-linux-gnueabi]
3254 || [istarget hppa*-*linux*]
3255 || [istarget s390*-*-*]
3256 || [istarget powerpc*-*-*]
3257 || [istarget sparc64-*-*]
3258 || [istarget sparcv9-*-*]
3259 || [istarget mips*-*-*] } {
3260 set et_sync_char_short_saved 1
3264 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3265 return $et_sync_char_short_saved
3268 # Return 1 if the target uses a ColdFire FPU.
3270 proc check_effective_target_coldfire_fpu { } {
3271 return [check_no_compiler_messages coldfire_fpu assembly {
3278 # Return true if this is a uClibc target.
3280 proc check_effective_target_uclibc {} {
3281 return [check_no_compiler_messages uclibc object {
3282 #include <features.h>
3283 #if !defined (__UCLIBC__)
3289 # Return true if this is a uclibc target and if the uclibc feature
3290 # described by __$feature__ is not present.
3292 proc check_missing_uclibc_feature {feature} {
3293 return [check_no_compiler_messages $feature object "
3294 #include <features.h>
3295 #if !defined (__UCLIBC) || defined (__${feature}__)
3301 # Return true if this is a Newlib target.
3303 proc check_effective_target_newlib {} {
3304 return [check_no_compiler_messages newlib object {
3310 # (a) an error of a few ULP is expected in string to floating-point
3311 # conversion functions; and
3312 # (b) overflow is not always detected correctly by those functions.
3314 proc check_effective_target_lax_strtofp {} {
3315 # By default, assume that all uClibc targets suffer from this.
3316 return [check_effective_target_uclibc]
3319 # Return 1 if this is a target for which wcsftime is a dummy
3320 # function that always returns 0.
3322 proc check_effective_target_dummy_wcsftime {} {
3323 # By default, assume that all uClibc targets suffer from this.
3324 return [check_effective_target_uclibc]
3327 # Return 1 if constructors with initialization priority arguments are
3328 # supposed on this target.
3330 proc check_effective_target_init_priority {} {
3331 return [check_no_compiler_messages init_priority assembly "
3332 void f() __attribute__((constructor (1000)));
3337 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3338 # This can be used with any check_* proc that takes no argument and
3339 # returns only 1 or 0. It could be used with check_* procs that take
3340 # arguments with keywords that pass particular arguments.
3342 proc is-effective-target { arg } {
3344 if { [info procs check_effective_target_${arg}] != [list] } {
3345 set selected [check_effective_target_${arg}]
3348 "vmx_hw" { set selected [check_vmx_hw_available] }
3349 "vsx_hw" { set selected [check_vsx_hw_available] }
3350 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3351 "named_sections" { set selected [check_named_sections_available] }
3352 "gc_sections" { set selected [check_gc_sections_available] }
3353 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3354 default { error "unknown effective target keyword `$arg'" }
3357 verbose "is-effective-target: $arg $selected" 2
3361 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3363 proc is-effective-target-keyword { arg } {
3364 if { [info procs check_effective_target_${arg}] != [list] } {
3367 # These have different names for their check_* procs.
3369 "vmx_hw" { return 1 }
3370 "vsx_hw" { return 1 }
3371 "ppc_recip_hw" { return 1 }
3372 "named_sections" { return 1 }
3373 "gc_sections" { return 1 }
3374 "cxa_atexit" { return 1 }
3375 default { return 0 }
3380 # Return 1 if target default to short enums
3382 proc check_effective_target_short_enums { } {
3383 return [check_no_compiler_messages short_enums assembly {
3385 int s[sizeof (enum foo) == 1 ? 1 : -1];
3389 # Return 1 if target supports merging string constants at link time.
3391 proc check_effective_target_string_merging { } {
3392 return [check_no_messages_and_pattern string_merging \
3393 "rodata\\.str" assembly {
3394 const char *var = "String";
3398 # Return 1 if target has the basic signed and unsigned types in
3399 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3400 # working <stdint.h> for all targets.
3402 proc check_effective_target_stdint_types { } {
3403 return [check_no_compiler_messages stdint_types assembly {
3405 int8_t a; int16_t b; int32_t c; int64_t d;
3406 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3410 # Return 1 if target has the basic signed and unsigned types in
3411 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3412 # these types agree with those in the header, as some systems have
3413 # only <inttypes.h>.
3415 proc check_effective_target_inttypes_types { } {
3416 return [check_no_compiler_messages inttypes_types assembly {
3417 #include <inttypes.h>
3418 int8_t a; int16_t b; int32_t c; int64_t d;
3419 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3423 # Return 1 if programs are intended to be run on a simulator
3424 # (i.e. slowly) rather than hardware (i.e. fast).
3426 proc check_effective_target_simulator { } {
3428 # All "src/sim" simulators set this one.
3429 if [board_info target exists is_simulator] {
3430 return [board_info target is_simulator]
3433 # The "sid" simulators don't set that one, but at least they set
3435 if [board_info target exists slow_simulator] {
3436 return [board_info target slow_simulator]
3442 # Return 1 if the target is a VxWorks kernel.
3444 proc check_effective_target_vxworks_kernel { } {
3445 return [check_no_compiler_messages vxworks_kernel assembly {
3446 #if !defined __vxworks || defined __RTP__
3452 # Return 1 if the target is a VxWorks RTP.
3454 proc check_effective_target_vxworks_rtp { } {
3455 return [check_no_compiler_messages vxworks_rtp assembly {
3456 #if !defined __vxworks || !defined __RTP__
3462 # Return 1 if the target is expected to provide wide character support.
3464 proc check_effective_target_wchar { } {
3465 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3468 return [check_no_compiler_messages wchar assembly {
3473 # Return 1 if the target has <pthread.h>.
3475 proc check_effective_target_pthread_h { } {
3476 return [check_no_compiler_messages pthread_h assembly {
3477 #include <pthread.h>
3481 # Return 1 if the target can truncate a file from a file-descriptor,
3482 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3483 # chsize. We test for a trivially functional truncation; no stubs.
3484 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3485 # different function to be used.
3487 proc check_effective_target_fd_truncate { } {
3489 #define _FILE_OFFSET_BITS 64
3495 FILE *f = fopen ("tst.tmp", "wb");
3497 const char t[] = "test writing more than ten characters";
3500 write (fd, t, sizeof (t) - 1);
3502 if (ftruncate (fd, 10) != 0)
3505 f = fopen ("tst.tmp", "rb");
3506 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3512 if { [check_runtime ftruncate $prog] } {
3516 regsub "ftruncate" $prog "chsize" prog
3517 return [check_runtime chsize $prog]
3520 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3522 proc add_options_for_c99_runtime { flags } {
3523 if { [istarget *-*-solaris2*] } {
3524 return "$flags -std=c99"
3526 if { [istarget mips-sgi-irix6.5*] } {
3527 return "$flags -std=c99"
3529 if { [istarget powerpc-*-darwin*] } {
3530 return "$flags -mmacosx-version-min=10.3"
3535 # Add to FLAGS all the target-specific flags needed to enable
3536 # full IEEE compliance mode.
3538 proc add_options_for_ieee { flags } {
3539 if { [istarget "alpha*-*-*"]
3540 || [istarget "sh*-*-*"] } {
3541 return "$flags -mieee"
3546 # Add to FLAGS the flags needed to enable functions to bind locally
3547 # when using pic/PIC passes in the testsuite.
3549 proc add_options_for_bind_pic_locally { flags } {
3550 if {[check_no_compiler_messages using_pic2 assembly {
3555 return "$flags -fPIE"
3557 if {[check_no_compiler_messages using_pic1 assembly {
3562 return "$flags -fpie"
3568 # Add to FLAGS the flags needed to enable 128-bit vectors.
3570 proc add_options_for_quad_vectors { flags } {
3571 if [is-effective-target arm_neon_ok] {
3572 return "$flags -mvectorize-with-neon-quad"
3578 # Return 1 if the target provides a full C99 runtime.
3580 proc check_effective_target_c99_runtime { } {
3581 return [check_cached_effective_target c99_runtime {
3584 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3585 set contents [read $file]
3588 #ifndef HAVE_C99_RUNTIME
3592 check_no_compiler_messages_nocache c99_runtime assembly \
3593 $contents [add_options_for_c99_runtime ""]
3597 # Return 1 if target wchar_t is at least 4 bytes.
3599 proc check_effective_target_4byte_wchar_t { } {
3600 return [check_no_compiler_messages 4byte_wchar_t object {
3601 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3605 # Return 1 if the target supports automatic stack alignment.
3607 proc check_effective_target_automatic_stack_alignment { } {
3608 # Ordinarily x86 supports automatic stack alignment ...
3609 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
3610 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
3611 # ... except Win64 SEH doesn't. Succeed for Win32 though.
3612 return [check_effective_target_ilp32];
3619 # Return 1 if avx instructions can be compiled.
3621 proc check_effective_target_avx { } {
3622 return [check_no_compiler_messages avx object {
3623 void _mm256_zeroall (void)
3625 __builtin_ia32_vzeroall ();
3630 # Return 1 if sse instructions can be compiled.
3631 proc check_effective_target_sse { } {
3632 return [check_no_compiler_messages sse object {
3635 __builtin_ia32_stmxcsr ();
3641 # Return 1 if sse2 instructions can be compiled.
3642 proc check_effective_target_sse2 { } {
3643 return [check_no_compiler_messages sse2 object {
3644 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3646 __m128i _mm_srli_si128 (__m128i __A, int __N)
3648 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3653 # Return 1 if F16C instructions can be compiled.
3655 proc check_effective_target_f16c { } {
3656 return [check_no_compiler_messages f16c object {
3657 #include "immintrin.h"
3659 foo (unsigned short val)
3661 return _cvtsh_ss (val);
3666 # Return 1 if C wchar_t type is compatible with char16_t.
3668 proc check_effective_target_wchar_t_char16_t_compatible { } {
3669 return [check_no_compiler_messages wchar_t_char16_t object {
3671 __CHAR16_TYPE__ *p16 = &wc;
3672 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3676 # Return 1 if C wchar_t type is compatible with char32_t.
3678 proc check_effective_target_wchar_t_char32_t_compatible { } {
3679 return [check_no_compiler_messages wchar_t_char32_t object {
3681 __CHAR32_TYPE__ *p32 = &wc;
3682 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3686 # Return 1 if pow10 function exists.
3688 proc check_effective_target_pow10 { } {
3689 return [check_runtime pow10 {
3699 # Return 1 if current options generate DFP instructions, 0 otherwise.
3701 proc check_effective_target_hard_dfp {} {
3702 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3703 typedef float d64 __attribute__((mode(DD)));
3705 void foo (void) { z = x + y; }
3709 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3710 # for strchr etc. functions.
3712 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3713 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3716 #if !defined(__cplusplus) \
3717 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3718 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3719 ISO C++ correct string.h and wchar.h protos not supported.
3726 # Return 1 if GNU as is used.
3728 proc check_effective_target_gas { } {
3729 global use_gas_saved
3732 if {![info exists use_gas_saved]} {
3733 # Check if the as used by gcc is GNU as.
3734 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3735 # Provide /dev/null as input, otherwise gas times out reading from
3737 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3738 set as_output [lindex $status 1]
3739 if { [ string first "GNU" $as_output ] >= 0 } {
3745 return $use_gas_saved
3748 # Return 1 if the compiler has been configure with link-time optimization
3751 proc check_effective_target_lto { } {
3753 return [info exists ENABLE_LTO]
3756 # Return 1 if this target supports the -fsplit-stack option, 0
3759 proc check_effective_target_split_stack {} {
3760 return [check_no_compiler_messages split_stack object {
3765 # Return 1 if the language for the compiler under test is C.
3767 proc check_effective_target_c { } {
3769 if [string match $tool "gcc"] {
3775 # Return 1 if the language for the compiler under test is C++.
3777 proc check_effective_target_c++ { } {
3779 if [string match $tool "g++"] {
3785 # Return 1 if expensive testcases should be run.
3787 proc check_effective_target_run_expensive_tests { } {
3788 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
3794 # Returns 1 if "mempcpy" is available on the target system.
3796 proc check_effective_target_mempcpy {} {
3797 return [check_function_available "mempcpy"]
3800 # Check whether the vectorizer tests are supported by the target and
3801 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
3802 # Set dg-do-what-default to either compile or run, depending on target
3803 # capabilities. Return 1 if vectorizer tests are supported by
3804 # target, 0 otherwise.
3806 proc check_vect_support_and_set_flags { } {
3807 global DEFAULT_VECTCFLAGS
3808 global dg-do-what-default
3810 if [istarget "powerpc-*paired*"] {
3811 lappend DEFAULT_VECTCFLAGS "-mpaired"
3812 if [check_750cl_hw_available] {
3813 set dg-do-what-default run
3815 set dg-do-what-default compile
3817 } elseif [istarget "powerpc*-*-*"] {
3818 # Skip targets not supporting -maltivec.
3819 if ![is-effective-target powerpc_altivec_ok] {
3823 lappend DEFAULT_VECTCFLAGS "-maltivec"
3824 if [check_vsx_hw_available] {
3825 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
3828 if [check_vmx_hw_available] {
3829 set dg-do-what-default run
3831 if [is-effective-target ilp32] {
3832 # Specify a cpu that supports VMX for compile-only tests.
3833 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
3835 set dg-do-what-default compile
3837 } elseif { [istarget "spu-*-*"] } {
3838 set dg-do-what-default run
3839 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
3840 lappend DEFAULT_VECTCFLAGS "-msse2"
3841 if { [check_effective_target_sse2_runtime] } {
3842 set dg-do-what-default run
3844 set dg-do-what-default compile
3846 } elseif { [istarget "mips*-*-*"]
3847 && ([check_effective_target_mpaired_single]
3848 || [check_effective_target_mips_loongson])
3849 && [check_effective_target_nomips16] } {
3850 if { [check_effective_target_mpaired_single] } {
3851 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
3853 set dg-do-what-default run
3854 } elseif [istarget "sparc*-*-*"] {
3855 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
3856 if [check_effective_target_ultrasparc_hw] {
3857 set dg-do-what-default run
3859 set dg-do-what-default compile