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 { } {
224 # All mips targets should support it
226 if { [ string first "mips" $target_cpu ] >= 0 } {
230 # All solaris2 targets should support it
232 if { [istarget *-*-solaris2*] } {
236 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
238 if { [istarget alpha*-dec-osf*] } {
242 # Windows targets Cygwin and MingW32 support it
244 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
248 # HP-UX 10.X doesn't support it
250 if { [istarget hppa*-*-hpux10*] } {
254 # ELF and ECOFF support it. a.out does with gas/gld but may also with
255 # other linkers, so we should try it
257 set objformat [gcc_target_object_format]
265 unknown { return -1 }
270 ###############################
271 # proc check_weak_override_available { }
272 ###############################
274 # Like check_weak_available, but return 0 if weak symbol definitions
275 # cannot be overridden.
277 proc check_weak_override_available { } {
278 if { [istarget *-*-mingw*] } {
281 return [check_weak_available]
284 ###############################
285 # proc check_visibility_available { what_kind }
286 ###############################
288 # The visibility attribute is only support in some object formats
289 # This proc returns 1 if it is supported, 0 if not.
290 # The argument is the kind of visibility, default/protected/hidden/internal.
292 proc check_visibility_available { what_kind } {
293 if [string match "" $what_kind] { set what_kind "hidden" }
295 return [check_no_compiler_messages visibility_available_$what_kind object "
296 void f() __attribute__((visibility(\"$what_kind\")));
301 ###############################
302 # proc check_alias_available { }
303 ###############################
305 # Determine if the target toolchain supports the alias attribute.
307 # Returns 2 if the target supports aliases. Returns 1 if the target
308 # only supports weak aliased. Returns 0 if the target does not
309 # support aliases at all. Returns -1 if support for aliases could not
312 proc check_alias_available { } {
313 global alias_available_saved
316 if [info exists alias_available_saved] {
317 verbose "check_alias_available returning saved $alias_available_saved" 2
321 verbose "check_alias_available compiling testfile $src" 2
322 set f [open $src "w"]
323 # Compile a small test program. The definition of "g" is
324 # necessary to keep the Solaris assembler from complaining
326 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
327 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
329 set lines [${tool}_target_compile $src $obj object ""]
331 remote_file build delete $obj
333 if [string match "" $lines] then {
334 # No error messages, everything is OK.
335 set alias_available_saved 2
337 if [regexp "alias definitions not supported" $lines] {
338 verbose "check_alias_available target does not support aliases" 2
340 set objformat [gcc_target_object_format]
342 if { $objformat == "elf" } {
343 verbose "check_alias_available but target uses ELF format, so it ought to" 2
344 set alias_available_saved -1
346 set alias_available_saved 0
349 if [regexp "only weak aliases are supported" $lines] {
350 verbose "check_alias_available target supports only weak aliases" 2
351 set alias_available_saved 1
353 set alias_available_saved -1
358 verbose "check_alias_available returning $alias_available_saved" 2
361 return $alias_available_saved
364 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
366 proc check_ifunc_available { } {
367 return [check_no_compiler_messages ifunc_available object {
372 void f() __attribute__((ifunc("g")));
376 # Returns true if --gc-sections is supported on the target.
378 proc check_gc_sections_available { } {
379 global gc_sections_available_saved
382 if {![info exists gc_sections_available_saved]} {
383 # Some targets don't support gc-sections despite whatever's
384 # advertised by ld's options.
385 if { [istarget alpha*-*-*]
386 || [istarget ia64-*-*] } {
387 set gc_sections_available_saved 0
391 # elf2flt uses -q (--emit-relocs), which is incompatible with
393 if { [board_info target exists ldflags]
394 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
395 set gc_sections_available_saved 0
399 # VxWorks kernel modules are relocatable objects linked with -r,
400 # while RTP executables are linked with -q (--emit-relocs).
401 # Both of these options are incompatible with --gc-sections.
402 if { [istarget *-*-vxworks*] } {
403 set gc_sections_available_saved 0
407 # Check if the ld used by gcc supports --gc-sections.
408 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
409 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
410 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
411 set ld_output [remote_exec host "$gcc_ld" "--help"]
412 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
413 set gc_sections_available_saved 1
415 set gc_sections_available_saved 0
418 return $gc_sections_available_saved
421 # Return 1 if according to target_info struct and explicit target list
422 # target is supposed to support trampolines.
424 proc check_effective_target_trampolines { } {
425 if [target_info exists no_trampolines] {
428 if { [istarget avr-*-*]
429 || [istarget hppa2.0w-hp-hpux11.23]
430 || [istarget hppa64-hp-hpux11.23] } {
436 # Return 1 if according to target_info struct and explicit target list
437 # target is supposed to keep null pointer checks. This could be due to
438 # use of option fno-delete-null-pointer-checks or hardwired in target.
440 proc check_effective_target_keeps_null_pointer_checks { } {
441 if [target_info exists keeps_null_pointer_checks] {
444 if { [istarget avr-*-*] } {
450 # Return true if profiling is supported on the target.
452 proc check_profiling_available { test_what } {
453 global profiling_available_saved
455 verbose "Profiling argument is <$test_what>" 1
457 # These conditions depend on the argument so examine them before
458 # looking at the cache variable.
460 # Tree profiling requires TLS runtime support.
461 if { $test_what == "-fprofile-generate" } {
462 if { ![check_effective_target_tls_runtime] } {
467 # Support for -p on solaris2 relies on mcrt1.o which comes with the
468 # vendor compiler. We cannot reliably predict the directory where the
469 # vendor compiler (and thus mcrt1.o) is installed so we can't
470 # necessarily find mcrt1.o even if we have it.
471 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
475 # Support for -p on irix relies on libprof1.a which doesn't appear to
476 # exist on any irix6 system currently posting testsuite results.
477 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
478 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
479 if { [istarget mips*-*-irix*]
480 && ($test_what == "-p" || $test_what == "-pg") } {
484 # We don't yet support profiling for MIPS16.
485 if { [istarget mips*-*-*]
486 && ![check_effective_target_nomips16]
487 && ($test_what == "-p" || $test_what == "-pg") } {
491 # MinGW does not support -p.
492 if { [istarget *-*-mingw*] && $test_what == "-p" } {
496 # cygwin does not support -p.
497 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
501 # uClibc does not have gcrt1.o.
502 if { [check_effective_target_uclibc]
503 && ($test_what == "-p" || $test_what == "-pg") } {
507 # Now examine the cache variable.
508 if {![info exists profiling_available_saved]} {
509 # Some targets don't have any implementation of __bb_init_func or are
510 # missing other needed machinery.
511 if { [istarget am3*-*-linux*]
512 || [istarget arm*-*-eabi*]
513 || [istarget arm*-*-elf]
514 || [istarget arm*-*-symbianelf*]
515 || [istarget avr-*-*]
516 || [istarget bfin-*-*]
517 || [istarget cris-*-*]
518 || [istarget crisv32-*-*]
519 || [istarget fido-*-elf]
520 || [istarget h8300-*-*]
521 || [istarget lm32-*-*]
522 || [istarget m32c-*-elf]
523 || [istarget m68k-*-elf]
524 || [istarget m68k-*-uclinux*]
525 || [istarget mep-*-elf]
526 || [istarget mips*-*-elf*]
527 || [istarget mmix-*-*]
528 || [istarget mn10300-*-elf*]
529 || [istarget moxie-*-elf*]
530 || [istarget picochip-*-*]
531 || [istarget powerpc-*-eabi*]
532 || [istarget powerpc-*-elf]
534 || [istarget tic6x-*-elf]
535 || [istarget xstormy16-*]
536 || [istarget xtensa*-*-elf]
537 || [istarget *-*-rtems*]
538 || [istarget *-*-vxworks*] } {
539 set profiling_available_saved 0
541 set profiling_available_saved 1
545 return $profiling_available_saved
548 # Check to see if a target is "freestanding". This is as per the definition
549 # in Section 4 of C99 standard. Effectively, it is a target which supports no
550 # extra headers or libraries other than what is considered essential.
551 proc check_effective_target_freestanding { } {
552 if { [istarget picochip-*-*] } then {
559 # Return 1 if target has packed layout of structure members by
560 # default, 0 otherwise. Note that this is slightly different than
561 # whether the target has "natural alignment": both attributes may be
564 proc check_effective_target_default_packed { } {
565 return [check_no_compiler_messages default_packed assembly {
566 struct x { char a; long b; } c;
567 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
571 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
572 # documentation, where the test also comes from.
574 proc check_effective_target_pcc_bitfield_type_matters { } {
575 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
576 # bitfields, but let's stick to the example code from the docs.
577 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
578 struct foo1 { char x; char :0; char y; };
579 struct foo2 { char x; int :0; char y; };
580 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
584 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
586 proc add_options_for_tls { flags } {
587 # Tru64 UNIX uses emutls, which relies on a couple of pthread functions
588 # which only live in libpthread, so always pass -pthread for TLS.
589 if { [istarget alpha*-dec-osf*] } {
590 return "$flags -pthread"
592 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
593 # libthread, so always pass -pthread for native TLS.
594 # Need to duplicate native TLS check from
595 # check_effective_target_tls_native to avoid recursion.
596 if { [istarget *-*-solaris2.\[89\]*] &&
597 [check_no_messages_and_pattern tls_native "!emutls" assembly {
599 int f (void) { return i; }
600 void g (int j) { i = j; }
602 return "$flags -pthread"
607 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
609 proc check_effective_target_tls {} {
610 return [check_no_compiler_messages tls assembly {
612 int f (void) { return i; }
613 void g (int j) { i = j; }
617 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
619 proc check_effective_target_tls_native {} {
620 # VxWorks uses emulated TLS machinery, but with non-standard helper
621 # functions, so we fail to automatically detect it.
622 if { [istarget *-*-vxworks*] } {
626 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
628 int f (void) { return i; }
629 void g (int j) { i = j; }
633 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
635 proc check_effective_target_tls_emulated {} {
636 # VxWorks uses emulated TLS machinery, but with non-standard helper
637 # functions, so we fail to automatically detect it.
638 if { [istarget *-*-vxworks*] } {
642 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
644 int f (void) { return i; }
645 void g (int j) { i = j; }
649 # Return 1 if TLS executables can run correctly, 0 otherwise.
651 proc check_effective_target_tls_runtime {} {
652 return [check_runtime tls_runtime {
653 __thread int thr = 0;
654 int main (void) { return thr; }
655 } [add_options_for_tls ""]]
658 # Return 1 if -ffunction-sections is supported, 0 otherwise.
660 proc check_effective_target_function_sections {} {
661 # Darwin has its own scheme and silently accepts -ffunction-sections.
662 if { [istarget *-*-darwin*] } {
666 return [check_no_compiler_messages functionsections assembly {
668 } "-ffunction-sections"]
671 # Return 1 if instruction scheduling is available, 0 otherwise.
673 proc check_effective_target_scheduling {} {
674 return [check_no_compiler_messages scheduling object {
676 } "-fschedule-insns"]
679 # Return 1 if compilation with -fgraphite is error-free for trivial
682 proc check_effective_target_fgraphite {} {
683 return [check_no_compiler_messages fgraphite object {
688 # Return 1 if compilation with -fopenmp is error-free for trivial
691 proc check_effective_target_fopenmp {} {
692 return [check_no_compiler_messages fopenmp object {
697 # Return 1 if the target supports mmap, 0 otherwise.
699 proc check_effective_target_mmap {} {
700 return [check_function_available "mmap"]
703 # Return 1 if compilation with -pthread is error-free for trivial
706 proc check_effective_target_pthread {} {
707 return [check_no_compiler_messages pthread object {
712 # Return 1 if compilation with -mpe-aligned-commons is error-free
713 # for trivial code, 0 otherwise.
715 proc check_effective_target_pe_aligned_commons {} {
716 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
717 return [check_no_compiler_messages pe_aligned_commons object {
719 } "-mpe-aligned-commons"]
724 # Return 1 if the target supports -static
725 proc check_effective_target_static {} {
726 return [check_no_compiler_messages static executable {
727 int main (void) { return 0; }
731 # Return 1 if the target supports -fstack-protector
732 proc check_effective_target_fstack_protector {} {
733 return [check_runtime fstack_protector {
734 int main (void) { return 0; }
735 } "-fstack-protector"]
738 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
739 # for trivial code, 0 otherwise.
741 proc check_effective_target_freorder {} {
742 return [check_no_compiler_messages freorder object {
744 } "-freorder-blocks-and-partition"]
747 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
748 # emitted, 0 otherwise. Whether a shared library can actually be built is
749 # out of scope for this test.
751 proc check_effective_target_fpic { } {
752 # Note that M68K has a multilib that supports -fpic but not
753 # -fPIC, so we need to check both. We test with a program that
754 # requires GOT references.
755 foreach arg {fpic fPIC} {
756 if [check_no_compiler_messages $arg object {
757 extern int foo (void); extern int bar;
758 int baz (void) { return foo () + bar; }
766 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
768 proc check_effective_target_pie { } {
769 if { [istarget *-*-darwin\[912\]*]
770 || [istarget *-*-linux*] } {
776 # Return true if the target supports -mpaired-single (as used on MIPS).
778 proc check_effective_target_mpaired_single { } {
779 return [check_no_compiler_messages mpaired_single object {
784 # Return true if the target has access to FPU instructions.
786 proc check_effective_target_hard_float { } {
787 if { [istarget mips*-*-*] } {
788 return [check_no_compiler_messages hard_float assembly {
789 #if (defined __mips_soft_float || defined __mips16)
795 # This proc is actually checking the availabilty of FPU
796 # support for doubles, so on the RX we must fail if the
797 # 64-bit double multilib has been selected.
798 if { [istarget rx-*-*] } {
800 # return [check_no_compiler_messages hard_float assembly {
801 #if defined __RX_64_BIT_DOUBLES__
807 # The generic test equates hard_float with "no call for adding doubles".
808 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
809 double a (double b, double c) { return b + c; }
813 # Return true if the target is a 64-bit MIPS target.
815 proc check_effective_target_mips64 { } {
816 return [check_no_compiler_messages mips64 assembly {
823 # Return true if the target is a MIPS target that does not produce
826 proc check_effective_target_nomips16 { } {
827 return [check_no_compiler_messages nomips16 object {
831 /* A cheap way of testing for -mflip-mips16. */
832 void foo (void) { asm ("addiu $20,$20,1"); }
833 void bar (void) { asm ("addiu $20,$20,1"); }
838 # Add the options needed for MIPS16 function attributes. At the moment,
839 # we don't support MIPS16 PIC.
841 proc add_options_for_mips16_attribute { flags } {
842 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
845 # Return true if we can force a mode that allows MIPS16 code generation.
846 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
849 proc check_effective_target_mips16_attribute { } {
850 return [check_no_compiler_messages mips16_attribute assembly {
854 #if defined __mips_hard_float \
855 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
856 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
859 } [add_options_for_mips16_attribute ""]]
862 # Return 1 if the target supports long double larger than double when
863 # using the new ABI, 0 otherwise.
865 proc check_effective_target_mips_newabi_large_long_double { } {
866 return [check_no_compiler_messages mips_newabi_large_long_double object {
867 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
871 # Return 1 if the current multilib does not generate PIC by default.
873 proc check_effective_target_nonpic { } {
874 return [check_no_compiler_messages nonpic assembly {
881 # Return 1 if the target does not use a status wrapper.
883 proc check_effective_target_unwrapped { } {
884 if { [target_info needs_status_wrapper] != "" \
885 && [target_info needs_status_wrapper] != "0" } {
891 # Return true if iconv is supported on the target. In particular IBM1047.
893 proc check_iconv_available { test_what } {
896 # If the tool configuration file has not set libiconv, try "-liconv"
897 if { ![info exists libiconv] } {
898 set libiconv "-liconv"
900 set test_what [lindex $test_what 1]
901 return [check_runtime_nocache $test_what [subst {
907 cd = iconv_open ("$test_what", "UTF-8");
908 if (cd == (iconv_t) -1)
915 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
917 proc check_ascii_locale_available { } {
918 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
919 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
926 # Return true if named sections are supported on this target.
928 proc check_named_sections_available { } {
929 return [check_no_compiler_messages named_sections assembly {
930 int __attribute__ ((section("whatever"))) foo;
934 # Return 1 if the target supports Fortran real kinds larger than real(8),
937 # When the target name changes, replace the cached result.
939 proc check_effective_target_fortran_large_real { } {
940 return [check_no_compiler_messages fortran_large_real executable {
942 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
949 # Return 1 if the target supports Fortran real kind real(16),
950 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
951 # this checks for Real(16) only; the other returned real(10) if
952 # both real(10) and real(16) are available.
954 # When the target name changes, replace the cached result.
956 proc check_effective_target_fortran_real_16 { } {
957 return [check_no_compiler_messages fortran_real_16 executable {
965 # Return 1 if the target supports Fortran integer kinds larger than
966 # integer(8), 0 otherwise.
968 # When the target name changes, replace the cached result.
970 proc check_effective_target_fortran_large_int { } {
971 return [check_no_compiler_messages fortran_large_int executable {
973 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
979 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
981 # When the target name changes, replace the cached result.
983 proc check_effective_target_fortran_integer_16 { } {
984 return [check_no_compiler_messages fortran_integer_16 executable {
991 # Return 1 if we can statically link libgfortran, 0 otherwise.
993 # When the target name changes, replace the cached result.
995 proc check_effective_target_static_libgfortran { } {
996 return [check_no_compiler_messages static_libgfortran executable {
1003 proc check_linker_plugin_available { } {
1004 return [check_no_compiler_messages_nocache linker_plugin executable {
1005 int main() { return 0; }
1006 } "-flto -fuse-linker-plugin"]
1009 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1010 # otherwise. Cache the result.
1012 proc check_750cl_hw_available { } {
1013 return [check_cached_effective_target 750cl_hw_available {
1014 # If this is not the right target then we can skip the test.
1015 if { ![istarget powerpc-*paired*] } {
1018 check_runtime_nocache 750cl_hw_available {
1022 asm volatile ("ps_mul v0,v0,v0");
1024 asm volatile ("ps_mul 0,0,0");
1033 # Return 1 if the target OS supports running SSE executables, 0
1034 # otherwise. Cache the result.
1036 proc check_sse_os_support_available { } {
1037 return [check_cached_effective_target sse_os_support_available {
1038 # If this is not the right target then we can skip the test.
1039 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1041 } elseif { [istarget i?86-*-solaris2*] } {
1042 # The Solaris 2 kernel doesn't save and restore SSE registers
1043 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1044 check_runtime_nocache sse_os_support_available {
1047 asm volatile ("movaps %xmm0,%xmm0");
1057 # Return 1 if the target OS supports running AVX executables, 0
1058 # otherwise. Cache the result.
1060 proc check_avx_os_support_available { } {
1061 return [check_cached_effective_target avx_os_support_available {
1062 # If this is not the right target then we can skip the test.
1063 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1066 # Check that OS has AVX and SSE saving enabled.
1067 check_runtime_nocache avx_os_support_available {
1070 unsigned int eax, edx;
1072 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1073 return (eax & 6) != 6;
1080 # Return 1 if the target supports executing SSE instructions, 0
1081 # otherwise. Cache the result.
1083 proc check_sse_hw_available { } {
1084 return [check_cached_effective_target sse_hw_available {
1085 # If this is not the right target then we can skip the test.
1086 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1089 check_runtime_nocache sse_hw_available {
1093 unsigned int eax, ebx, ecx, edx;
1094 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1095 return !(edx & bit_SSE);
1103 # Return 1 if the target supports executing SSE2 instructions, 0
1104 # otherwise. Cache the result.
1106 proc check_sse2_hw_available { } {
1107 return [check_cached_effective_target sse2_hw_available {
1108 # If this is not the right target then we can skip the test.
1109 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1112 check_runtime_nocache sse2_hw_available {
1116 unsigned int eax, ebx, ecx, edx;
1117 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1118 return !(edx & bit_SSE2);
1126 # Return 1 if the target supports executing AVX instructions, 0
1127 # otherwise. Cache the result.
1129 proc check_avx_hw_available { } {
1130 return [check_cached_effective_target avx_hw_available {
1131 # If this is not the right target then we can skip the test.
1132 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1135 check_runtime_nocache avx_hw_available {
1139 unsigned int eax, ebx, ecx, edx;
1140 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1141 return ((ecx & (bit_AVX | bit_OSXSAVE))
1142 != (bit_AVX | bit_OSXSAVE));
1150 # Return 1 if the target supports running SSE executables, 0 otherwise.
1152 proc check_effective_target_sse_runtime { } {
1153 if { [check_effective_target_sse]
1154 && [check_sse_hw_available]
1155 && [check_sse_os_support_available] } {
1161 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1163 proc check_effective_target_sse2_runtime { } {
1164 if { [check_effective_target_sse2]
1165 && [check_sse2_hw_available]
1166 && [check_sse_os_support_available] } {
1172 # Return 1 if the target supports running AVX executables, 0 otherwise.
1174 proc check_effective_target_avx_runtime { } {
1175 if { [check_effective_target_avx]
1176 && [check_avx_hw_available]
1177 && [check_avx_os_support_available] } {
1183 # Return 1 if the target supports executing VSX instructions, 0
1184 # otherwise. Cache the result.
1186 proc check_vsx_hw_available { } {
1187 return [check_cached_effective_target vsx_hw_available {
1188 # Some simulators are known to not support VSX instructions.
1189 # For now, disable on Darwin
1190 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1194 check_runtime_nocache vsx_hw_available {
1198 asm volatile ("xxlor vs0,vs0,vs0");
1200 asm volatile ("xxlor 0,0,0");
1209 # Return 1 if the target supports executing AltiVec instructions, 0
1210 # otherwise. Cache the result.
1212 proc check_vmx_hw_available { } {
1213 return [check_cached_effective_target vmx_hw_available {
1214 # Some simulators are known to not support VMX instructions.
1215 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1218 # Most targets don't require special flags for this test case, but
1219 # Darwin does. Just to be sure, make sure VSX is not enabled for
1220 # the altivec tests.
1221 if { [istarget *-*-darwin*]
1222 || [istarget *-*-aix*] } {
1223 set options "-maltivec -mno-vsx"
1225 set options "-mno-vsx"
1227 check_runtime_nocache vmx_hw_available {
1231 asm volatile ("vor v0,v0,v0");
1233 asm volatile ("vor 0,0,0");
1242 proc check_ppc_recip_hw_available { } {
1243 return [check_cached_effective_target ppc_recip_hw_available {
1244 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1245 # For now, disable on Darwin
1246 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1249 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1250 check_runtime_nocache ppc_recip_hw_available {
1251 volatile double d_recip, d_rsqrt, d_four = 4.0;
1252 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1255 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1256 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1257 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1258 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1266 # Return 1 if the target supports executing AltiVec and Cell PPU
1267 # instructions, 0 otherwise. Cache the result.
1269 proc check_effective_target_cell_hw { } {
1270 return [check_cached_effective_target cell_hw_available {
1271 # Some simulators are known to not support VMX and PPU instructions.
1272 if { [istarget powerpc-*-eabi*] } {
1275 # Most targets don't require special flags for this test
1276 # case, but Darwin and AIX do.
1277 if { [istarget *-*-darwin*]
1278 || [istarget *-*-aix*] } {
1279 set options "-maltivec -mcpu=cell"
1281 set options "-mcpu=cell"
1283 check_runtime_nocache cell_hw_available {
1287 asm volatile ("vor v0,v0,v0");
1288 asm volatile ("lvlx v0,r0,r0");
1290 asm volatile ("vor 0,0,0");
1291 asm volatile ("lvlx 0,0,0");
1300 # Return 1 if the target supports executing 64-bit instructions, 0
1301 # otherwise. Cache the result.
1303 proc check_effective_target_powerpc64 { } {
1304 global powerpc64_available_saved
1307 if [info exists powerpc64_available_saved] {
1308 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1310 set powerpc64_available_saved 0
1312 # Some simulators are known to not support powerpc64 instructions.
1313 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1314 verbose "check_effective_target_powerpc64 returning 0" 2
1315 return $powerpc64_available_saved
1318 # Set up, compile, and execute a test program containing a 64-bit
1319 # instruction. Include the current process ID in the file
1320 # names to prevent conflicts with invocations for multiple
1325 set f [open $src "w"]
1326 puts $f "int main() {"
1327 puts $f "#ifdef __MACH__"
1328 puts $f " asm volatile (\"extsw r0,r0\");"
1330 puts $f " asm volatile (\"extsw 0,0\");"
1332 puts $f " return 0; }"
1335 set opts "additional_flags=-mcpu=G5"
1337 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1338 set lines [${tool}_target_compile $src $exe executable "$opts"]
1341 if [string match "" $lines] then {
1342 # No error message, compilation succeeded.
1343 set result [${tool}_load "./$exe" "" ""]
1344 set status [lindex $result 0]
1345 remote_file build delete $exe
1346 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1348 if { $status == "pass" } then {
1349 set powerpc64_available_saved 1
1352 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1356 return $powerpc64_available_saved
1359 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1360 # complex float arguments. This affects gfortran tests that call cabsf
1361 # in libm built by an earlier compiler. Return 1 if libm uses the same
1362 # argument passing as the compiler under test, 0 otherwise.
1364 # When the target name changes, replace the cached result.
1366 proc check_effective_target_broken_cplxf_arg { } {
1367 return [check_cached_effective_target broken_cplxf_arg {
1368 # Skip the work for targets known not to be affected.
1369 if { ![istarget powerpc64-*-linux*] } {
1371 } elseif { ![is-effective-target lp64] } {
1374 check_runtime_nocache broken_cplxf_arg {
1375 #include <complex.h>
1376 extern void abort (void);
1377 float fabsf (float);
1378 float cabsf (_Complex float);
1385 if (fabsf (f - 5.0) > 0.0001)
1394 # Return 1 is this is a TI C6X target supporting C67X instructions
1395 proc check_effective_target_ti_c67x { } {
1396 return [check_no_compiler_messages ti_c67x assembly {
1397 #if !defined(_TMS320C6700)
1403 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1404 proc check_effective_target_ti_c64xp { } {
1405 return [check_no_compiler_messages ti_c64xp assembly {
1406 #if !defined(_TMS320C6400_PLUS)
1413 proc check_alpha_max_hw_available { } {
1414 return [check_runtime alpha_max_hw_available {
1415 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1419 # Returns true iff the FUNCTION is available on the target system.
1420 # (This is essentially a Tcl implementation of Autoconf's
1423 proc check_function_available { function } {
1424 return [check_no_compiler_messages ${function}_available \
1430 int main () { $function (); }
1434 # Returns true iff "fork" is available on the target system.
1436 proc check_fork_available {} {
1437 return [check_function_available "fork"]
1440 # Returns true iff "mkfifo" is available on the target system.
1442 proc check_mkfifo_available {} {
1443 if { [istarget *-*-cygwin*] } {
1444 # Cygwin has mkfifo, but support is incomplete.
1448 return [check_function_available "mkfifo"]
1451 # Returns true iff "__cxa_atexit" is used on the target system.
1453 proc check_cxa_atexit_available { } {
1454 return [check_cached_effective_target cxa_atexit_available {
1455 if { [istarget hppa*-*-hpux10*] } {
1456 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1458 } elseif { [istarget *-*-vxworks] } {
1459 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1462 check_runtime_nocache cxa_atexit_available {
1465 static unsigned int count;
1482 Y() { f(); count = 2; }
1491 int main() { return 0; }
1497 proc check_effective_target_objc2 { } {
1498 return [check_no_compiler_messages objc2 object {
1507 proc check_effective_target_next_runtime { } {
1508 return [check_no_compiler_messages objc2 object {
1509 #ifdef __NEXT_RUNTIME__
1517 # Return 1 if we're generating 32-bit code using default options, 0
1520 proc check_effective_target_ilp32 { } {
1521 return [check_no_compiler_messages ilp32 object {
1522 int dummy[sizeof (int) == 4
1523 && sizeof (void *) == 4
1524 && sizeof (long) == 4 ? 1 : -1];
1528 # Return 1 if we're generating ia32 code using default options, 0
1531 proc check_effective_target_ia32 { } {
1532 return [check_no_compiler_messages ia32 object {
1533 int dummy[sizeof (int) == 4
1534 && sizeof (void *) == 4
1535 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1539 # Return 1 if we're generating x32 code using default options, 0
1542 proc check_effective_target_x32 { } {
1543 return [check_no_compiler_messages x32 object {
1544 int dummy[sizeof (int) == 4
1545 && sizeof (void *) == 4
1546 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1550 # Return 1 if we're generating 32-bit or larger integers using default
1551 # options, 0 otherwise.
1553 proc check_effective_target_int32plus { } {
1554 return [check_no_compiler_messages int32plus object {
1555 int dummy[sizeof (int) >= 4 ? 1 : -1];
1559 # Return 1 if we're generating 32-bit or larger pointers using default
1560 # options, 0 otherwise.
1562 proc check_effective_target_ptr32plus { } {
1563 return [check_no_compiler_messages ptr32plus object {
1564 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1568 # Return 1 if we support 32-bit or larger array and structure sizes
1569 # using default options, 0 otherwise.
1571 proc check_effective_target_size32plus { } {
1572 return [check_no_compiler_messages size32plus object {
1577 # Returns 1 if we're generating 16-bit or smaller integers with the
1578 # default options, 0 otherwise.
1580 proc check_effective_target_int16 { } {
1581 return [check_no_compiler_messages int16 object {
1582 int dummy[sizeof (int) < 4 ? 1 : -1];
1586 # Return 1 if we're generating 64-bit code using default options, 0
1589 proc check_effective_target_lp64 { } {
1590 return [check_no_compiler_messages lp64 object {
1591 int dummy[sizeof (int) == 4
1592 && sizeof (void *) == 8
1593 && sizeof (long) == 8 ? 1 : -1];
1597 # Return 1 if we're generating 64-bit code using default llp64 options,
1600 proc check_effective_target_llp64 { } {
1601 return [check_no_compiler_messages llp64 object {
1602 int dummy[sizeof (int) == 4
1603 && sizeof (void *) == 8
1604 && sizeof (long long) == 8
1605 && sizeof (long) == 4 ? 1 : -1];
1609 # Return 1 if the target supports long double larger than double,
1612 proc check_effective_target_large_long_double { } {
1613 return [check_no_compiler_messages large_long_double object {
1614 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1618 # Return 1 if the target supports double larger than float,
1621 proc check_effective_target_large_double { } {
1622 return [check_no_compiler_messages large_double object {
1623 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1627 # Return 1 if the target supports double of 64 bits,
1630 proc check_effective_target_double64 { } {
1631 return [check_no_compiler_messages double64 object {
1632 int dummy[sizeof(double) == 8 ? 1 : -1];
1636 # Return 1 if the target supports double of at least 64 bits,
1639 proc check_effective_target_double64plus { } {
1640 return [check_no_compiler_messages double64plus object {
1641 int dummy[sizeof(double) >= 8 ? 1 : -1];
1645 # Return 1 if the target supports compiling fixed-point,
1648 proc check_effective_target_fixed_point { } {
1649 return [check_no_compiler_messages fixed_point object {
1650 _Sat _Fract x; _Sat _Accum y;
1654 # Return 1 if the target supports compiling decimal floating point,
1657 proc check_effective_target_dfp_nocache { } {
1658 verbose "check_effective_target_dfp_nocache: compiling source" 2
1659 set ret [check_no_compiler_messages_nocache dfp object {
1660 float x __attribute__((mode(DD)));
1662 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1666 proc check_effective_target_dfprt_nocache { } {
1667 return [check_runtime_nocache dfprt {
1668 typedef float d64 __attribute__((mode(DD)));
1669 d64 x = 1.2df, y = 2.3dd, z;
1670 int main () { z = x + y; return 0; }
1674 # Return 1 if the target supports compiling Decimal Floating Point,
1677 # This won't change for different subtargets so cache the result.
1679 proc check_effective_target_dfp { } {
1680 return [check_cached_effective_target dfp {
1681 check_effective_target_dfp_nocache
1685 # Return 1 if the target supports linking and executing Decimal Floating
1686 # Point, 0 otherwise.
1688 # This won't change for different subtargets so cache the result.
1690 proc check_effective_target_dfprt { } {
1691 return [check_cached_effective_target dfprt {
1692 check_effective_target_dfprt_nocache
1696 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1698 proc check_effective_target_ucn_nocache { } {
1699 # -std=c99 is only valid for C
1700 if [check_effective_target_c] {
1701 set ucnopts "-std=c99"
1703 append ucnopts " -fextended-identifiers"
1704 verbose "check_effective_target_ucn_nocache: compiling source" 2
1705 set ret [check_no_compiler_messages_nocache ucn object {
1708 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1712 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1714 # This won't change for different subtargets, so cache the result.
1716 proc check_effective_target_ucn { } {
1717 return [check_cached_effective_target ucn {
1718 check_effective_target_ucn_nocache
1722 # Return 1 if the target needs a command line argument to enable a SIMD
1725 proc check_effective_target_vect_cmdline_needed { } {
1726 global et_vect_cmdline_needed_saved
1727 global et_vect_cmdline_needed_target_name
1729 if { ![info exists et_vect_cmdline_needed_target_name] } {
1730 set et_vect_cmdline_needed_target_name ""
1733 # If the target has changed since we set the cached value, clear it.
1734 set current_target [current_target_name]
1735 if { $current_target != $et_vect_cmdline_needed_target_name } {
1736 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1737 set et_vect_cmdline_needed_target_name $current_target
1738 if { [info exists et_vect_cmdline_needed_saved] } {
1739 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1740 unset et_vect_cmdline_needed_saved
1744 if [info exists et_vect_cmdline_needed_saved] {
1745 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1747 set et_vect_cmdline_needed_saved 1
1748 if { [istarget alpha*-*-*]
1749 || [istarget ia64-*-*]
1750 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1751 && ([check_effective_target_x32]
1752 || [check_effective_target_lp64]))
1753 || ([istarget powerpc*-*-*]
1754 && ([check_effective_target_powerpc_spe]
1755 || [check_effective_target_powerpc_altivec]))
1756 || [istarget spu-*-*]
1757 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1758 set et_vect_cmdline_needed_saved 0
1762 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1763 return $et_vect_cmdline_needed_saved
1766 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1768 # This won't change for different subtargets so cache the result.
1770 proc check_effective_target_vect_int { } {
1771 global et_vect_int_saved
1773 if [info exists et_vect_int_saved] {
1774 verbose "check_effective_target_vect_int: using cached result" 2
1776 set et_vect_int_saved 0
1777 if { [istarget i?86-*-*]
1778 || ([istarget powerpc*-*-*]
1779 && ![istarget powerpc-*-linux*paired*])
1780 || [istarget spu-*-*]
1781 || [istarget x86_64-*-*]
1782 || [istarget sparc*-*-*]
1783 || [istarget alpha*-*-*]
1784 || [istarget ia64-*-*]
1785 || [check_effective_target_arm32]
1786 || ([istarget mips*-*-*]
1787 && [check_effective_target_mips_loongson]) } {
1788 set et_vect_int_saved 1
1792 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1793 return $et_vect_int_saved
1796 # Return 1 if the target supports signed int->float conversion
1799 proc check_effective_target_vect_intfloat_cvt { } {
1800 global et_vect_intfloat_cvt_saved
1802 if [info exists et_vect_intfloat_cvt_saved] {
1803 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1805 set et_vect_intfloat_cvt_saved 0
1806 if { [istarget i?86-*-*]
1807 || ([istarget powerpc*-*-*]
1808 && ![istarget powerpc-*-linux*paired*])
1809 || [istarget x86_64-*-*] } {
1810 set et_vect_intfloat_cvt_saved 1
1814 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1815 return $et_vect_intfloat_cvt_saved
1818 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1820 proc check_effective_target_int128 { } {
1821 return [check_no_compiler_messages int128 object {
1823 #ifndef __SIZEOF_INT128__
1832 # Return 1 if the target supports unsigned int->float conversion
1835 proc check_effective_target_vect_uintfloat_cvt { } {
1836 global et_vect_uintfloat_cvt_saved
1838 if [info exists et_vect_uintfloat_cvt_saved] {
1839 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1841 set et_vect_uintfloat_cvt_saved 0
1842 if { [istarget i?86-*-*]
1843 || ([istarget powerpc*-*-*]
1844 && ![istarget powerpc-*-linux*paired*])
1845 || [istarget x86_64-*-*] } {
1846 set et_vect_uintfloat_cvt_saved 1
1850 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1851 return $et_vect_uintfloat_cvt_saved
1855 # Return 1 if the target supports signed float->int conversion
1858 proc check_effective_target_vect_floatint_cvt { } {
1859 global et_vect_floatint_cvt_saved
1861 if [info exists et_vect_floatint_cvt_saved] {
1862 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1864 set et_vect_floatint_cvt_saved 0
1865 if { [istarget i?86-*-*]
1866 || ([istarget powerpc*-*-*]
1867 && ![istarget powerpc-*-linux*paired*])
1868 || [istarget x86_64-*-*] } {
1869 set et_vect_floatint_cvt_saved 1
1873 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1874 return $et_vect_floatint_cvt_saved
1877 # Return 1 if the target supports unsigned float->int conversion
1880 proc check_effective_target_vect_floatuint_cvt { } {
1881 global et_vect_floatuint_cvt_saved
1883 if [info exists et_vect_floatuint_cvt_saved] {
1884 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1886 set et_vect_floatuint_cvt_saved 0
1887 if { ([istarget powerpc*-*-*]
1888 && ![istarget powerpc-*-linux*paired*]) } {
1889 set et_vect_floatuint_cvt_saved 1
1893 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1894 return $et_vect_floatuint_cvt_saved
1897 # Return 1 is this is an arm target using 32-bit instructions
1898 proc check_effective_target_arm32 { } {
1899 return [check_no_compiler_messages arm32 assembly {
1900 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1906 # Return 1 is this is an arm target not using Thumb
1907 proc check_effective_target_arm_nothumb { } {
1908 return [check_no_compiler_messages arm_nothumb assembly {
1909 #if (defined(__thumb__) || defined(__thumb2__))
1915 # Return 1 if this is a little-endian ARM target
1916 proc check_effective_target_arm_little_endian { } {
1917 return [check_no_compiler_messages arm_little_endian assembly {
1918 #if !defined(__arm__) || !defined(__ARMEL__)
1924 # Return 1 if this is an ARM target that only supports aligned vector accesses
1925 proc check_effective_target_arm_vect_no_misalign { } {
1926 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1927 #if !defined(__arm__) \
1928 || (defined(__ARMEL__) \
1929 && (!defined(__thumb__) || defined(__thumb2__)))
1936 # Return 1 if this is an ARM target supporting -mfpu=vfp
1937 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1940 proc check_effective_target_arm_vfp_ok { } {
1941 if { [check_effective_target_arm32] } {
1942 return [check_no_compiler_messages arm_vfp_ok object {
1944 } "-mfpu=vfp -mfloat-abi=softfp"]
1950 # Return 1 if this is an ARM target supporting -mfpu=vfp
1951 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1954 proc check_effective_target_arm_hard_vfp_ok { } {
1955 if { [check_effective_target_arm32] } {
1956 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1957 int main() { return 0;}
1958 } "-mfpu=vfp -mfloat-abi=hard"]
1964 # Return 1 if this is an ARM target that supports DSP multiply with
1965 # current multilib flags.
1967 proc check_effective_target_arm_dsp { } {
1968 return [check_no_compiler_messages arm_dsp assembly {
1969 #ifndef __ARM_FEATURE_DSP
1976 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1977 # or -mfloat-abi=hard, but if one is already specified by the
1978 # multilib, use it. Similarly, if a -mfpu option already enables
1979 # NEON, do not add -mfpu=neon.
1981 proc add_options_for_arm_neon { flags } {
1982 if { ! [check_effective_target_arm_neon_ok] } {
1985 global et_arm_neon_flags
1986 return "$flags $et_arm_neon_flags"
1989 # Return 1 if this is an ARM target supporting -mfpu=neon
1990 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1991 # incompatible with these options. Also set et_arm_neon_flags to the
1992 # best options to add.
1994 proc check_effective_target_arm_neon_ok_nocache { } {
1995 global et_arm_neon_flags
1996 set et_arm_neon_flags ""
1997 if { [check_effective_target_arm32] } {
1998 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1999 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2000 #include "arm_neon.h"
2003 set et_arm_neon_flags $flags
2012 proc check_effective_target_arm_neon_ok { } {
2013 return [check_cached_effective_target arm_neon_ok \
2014 check_effective_target_arm_neon_ok_nocache]
2017 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2018 # or -mfloat-abi=hard, but if one is already specified by the
2021 proc add_options_for_arm_fp16 { flags } {
2022 if { ! [check_effective_target_arm_fp16_ok] } {
2025 global et_arm_fp16_flags
2026 return "$flags $et_arm_fp16_flags"
2029 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2030 # Skip multilibs that are incompatible with these options and set
2031 # et_arm_fp16_flags to the best options to add.
2033 proc check_effective_target_arm_fp16_ok_nocache { } {
2034 global et_arm_fp16_flags
2035 set et_arm_fp16_flags ""
2036 if { ! [check_effective_target_arm32] } {
2039 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2040 # Multilib flags would override -mfpu.
2043 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2044 # Must generate floating-point instructions.
2047 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2048 # The existing -mfpu value is OK; use it, but add softfp.
2049 set et_arm_fp16_flags "-mfloat-abi=softfp"
2052 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2053 # macro to check for this support.
2054 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2055 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2058 set et_arm_fp16_flags "$flags"
2065 proc check_effective_target_arm_fp16_ok { } {
2066 return [check_cached_effective_target arm_fp16_ok \
2067 check_effective_target_arm_fp16_ok_nocache]
2070 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2073 proc check_effective_target_arm_thumb1_ok { } {
2074 return [check_no_compiler_messages arm_thumb1_ok assembly {
2075 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2081 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2084 proc check_effective_target_arm_thumb2_ok { } {
2085 return [check_no_compiler_messages arm_thumb2_ok assembly {
2086 #if !defined(__thumb2__)
2092 # Return 1 if this is an ARM target where Thumb-1 is used without options
2093 # added by the test.
2095 proc check_effective_target_arm_thumb1 { } {
2096 return [check_no_compiler_messages arm_thumb1 assembly {
2097 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2104 # Return 1 if this is an ARM target where Thumb-2 is used without options
2105 # added by the test.
2107 proc check_effective_target_arm_thumb2 { } {
2108 return [check_no_compiler_messages arm_thumb2 assembly {
2109 #if !defined(__thumb2__)
2116 # Return 1 if this is an ARM cortex-M profile cpu
2118 proc check_effective_target_arm_cortex_m { } {
2119 return [check_no_compiler_messages arm_cortex_m assembly {
2120 #if !defined(__ARM_ARCH_7M__) \
2121 && !defined (__ARM_ARCH_7EM__) \
2122 && !defined (__ARM_ARCH_6M__)
2129 # Return 1 if the target supports executing NEON instructions, 0
2130 # otherwise. Cache the result.
2132 proc check_effective_target_arm_neon_hw { } {
2133 return [check_runtime arm_neon_hw_available {
2137 long long a = 0, b = 1;
2138 asm ("vorr %P0, %P1, %P2"
2140 : "0" (a), "w" (b));
2143 } [add_options_for_arm_neon ""]]
2146 # Return 1 if this is a ARM target with NEON enabled.
2148 proc check_effective_target_arm_neon { } {
2149 if { [check_effective_target_arm32] } {
2150 return [check_no_compiler_messages arm_neon object {
2151 #ifndef __ARM_NEON__
2162 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2163 # the Loongson vector modes.
2165 proc check_effective_target_mips_loongson { } {
2166 return [check_no_compiler_messages loongson assembly {
2167 #if !defined(__mips_loongson_vector_rev)
2173 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2176 proc check_effective_target_arm_eabi { } {
2177 return [check_no_compiler_messages arm_eabi object {
2178 #ifndef __ARM_EABI__
2186 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2187 # Some multilibs may be incompatible with this option.
2189 proc check_effective_target_arm_iwmmxt_ok { } {
2190 if { [check_effective_target_arm32] } {
2191 return [check_no_compiler_messages arm_iwmmxt_ok object {
2199 # Return 1 if this is a PowerPC target with floating-point registers.
2201 proc check_effective_target_powerpc_fprs { } {
2202 if { [istarget powerpc*-*-*]
2203 || [istarget rs6000-*-*] } {
2204 return [check_no_compiler_messages powerpc_fprs object {
2216 # Return 1 if this is a PowerPC target with hardware double-precision
2219 proc check_effective_target_powerpc_hard_double { } {
2220 if { [istarget powerpc*-*-*]
2221 || [istarget rs6000-*-*] } {
2222 return [check_no_compiler_messages powerpc_hard_double object {
2234 # Return 1 if this is a PowerPC target supporting -maltivec.
2236 proc check_effective_target_powerpc_altivec_ok { } {
2237 if { ([istarget powerpc*-*-*]
2238 && ![istarget powerpc-*-linux*paired*])
2239 || [istarget rs6000-*-*] } {
2240 # AltiVec is not supported on AIX before 5.3.
2241 if { [istarget powerpc*-*-aix4*]
2242 || [istarget powerpc*-*-aix5.1*]
2243 || [istarget powerpc*-*-aix5.2*] } {
2246 return [check_no_compiler_messages powerpc_altivec_ok object {
2254 # Return 1 if this is a PowerPC target supporting -mvsx
2256 proc check_effective_target_powerpc_vsx_ok { } {
2257 if { ([istarget powerpc*-*-*]
2258 && ![istarget powerpc-*-linux*paired*])
2259 || [istarget rs6000-*-*] } {
2260 # AltiVec is not supported on AIX before 5.3.
2261 if { [istarget powerpc*-*-aix4*]
2262 || [istarget powerpc*-*-aix5.1*]
2263 || [istarget powerpc*-*-aix5.2*] } {
2266 return [check_no_compiler_messages powerpc_vsx_ok object {
2269 asm volatile ("xxlor vs0,vs0,vs0");
2271 asm volatile ("xxlor 0,0,0");
2281 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2283 proc check_effective_target_powerpc_ppu_ok { } {
2284 if [check_effective_target_powerpc_altivec_ok] {
2285 return [check_no_compiler_messages cell_asm_available object {
2288 asm volatile ("lvlx v0,v0,v0");
2290 asm volatile ("lvlx 0,0,0");
2300 # Return 1 if this is a PowerPC target that supports SPU.
2302 proc check_effective_target_powerpc_spu { } {
2303 if { [istarget powerpc*-*-linux*] } {
2304 return [check_effective_target_powerpc_altivec_ok]
2310 # Return 1 if this is a PowerPC SPE target. The check includes options
2311 # specified by dg-options for this test, so don't cache the result.
2313 proc check_effective_target_powerpc_spe_nocache { } {
2314 if { [istarget powerpc*-*-*] } {
2315 return [check_no_compiler_messages_nocache powerpc_spe object {
2321 } [current_compiler_flags]]
2327 # Return 1 if this is a PowerPC target with SPE enabled.
2329 proc check_effective_target_powerpc_spe { } {
2330 if { [istarget powerpc*-*-*] } {
2331 return [check_no_compiler_messages powerpc_spe object {
2343 # Return 1 if this is a PowerPC target with Altivec enabled.
2345 proc check_effective_target_powerpc_altivec { } {
2346 if { [istarget powerpc*-*-*] } {
2347 return [check_no_compiler_messages powerpc_altivec object {
2359 # Return 1 if this is a PowerPC 405 target. The check includes options
2360 # specified by dg-options for this test, so don't cache the result.
2362 proc check_effective_target_powerpc_405_nocache { } {
2363 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2364 return [check_no_compiler_messages_nocache powerpc_405 object {
2370 } [current_compiler_flags]]
2376 # Return 1 if this is a SPU target with a toolchain that
2377 # supports automatic overlay generation.
2379 proc check_effective_target_spu_auto_overlay { } {
2380 if { [istarget spu*-*-elf*] } {
2381 return [check_no_compiler_messages spu_auto_overlay executable {
2383 } "-Wl,--auto-overlay" ]
2389 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2390 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2391 # test environment appears to run executables on such a simulator.
2393 proc check_effective_target_ultrasparc_hw { } {
2394 return [check_runtime ultrasparc_hw {
2395 int main() { return 0; }
2396 } "-mcpu=ultrasparc"]
2399 # Return 1 if the target supports hardware vector shift operation.
2401 proc check_effective_target_vect_shift { } {
2402 global et_vect_shift_saved
2404 if [info exists et_vect_shift_saved] {
2405 verbose "check_effective_target_vect_shift: using cached result" 2
2407 set et_vect_shift_saved 0
2408 if { ([istarget powerpc*-*-*]
2409 && ![istarget powerpc-*-linux*paired*])
2410 || [istarget ia64-*-*]
2411 || [istarget i?86-*-*]
2412 || [istarget x86_64-*-*]
2413 || [check_effective_target_arm32]
2414 || ([istarget mips*-*-*]
2415 && [check_effective_target_mips_loongson]) } {
2416 set et_vect_shift_saved 1
2420 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2421 return $et_vect_shift_saved
2424 # Return 1 if the target supports hardware vector shift operation with
2425 # scalar shift argument.
2427 proc check_effective_target_vect_shift_scalar { } {
2428 global et_vect_shift_scalar_saved
2430 if [info exists et_vect_shift_scalar_saved] {
2431 verbose "check_effective_target_vect_shift_scalar: using cached result" 2
2433 set et_vect_shift_scalar_saved 0
2434 if { [istarget x86_64-*-*]
2435 || [istarget i?86-*-*] } {
2436 set et_vect_shift_scalar_saved 1
2440 verbose "check_effective_target_vect_shift_scalar: returning $et_vect_shift_scalar_saved" 2
2441 return $et_vect_shift_scalar_saved
2445 # Return 1 if the target supports hardware vector shift operation for char.
2447 proc check_effective_target_vect_shift_char { } {
2448 global et_vect_shift_char_saved
2450 if [info exists et_vect_shift_char_saved] {
2451 verbose "check_effective_target_vect_shift_char: using cached result" 2
2453 set et_vect_shift_char_saved 0
2454 if { ([istarget powerpc*-*-*]
2455 && ![istarget powerpc-*-linux*paired*])
2456 || [check_effective_target_arm32] } {
2457 set et_vect_shift_char_saved 1
2461 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2462 return $et_vect_shift_char_saved
2465 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2467 # This can change for different subtargets so do not cache the result.
2469 proc check_effective_target_vect_long { } {
2470 if { [istarget i?86-*-*]
2471 || (([istarget powerpc*-*-*]
2472 && ![istarget powerpc-*-linux*paired*])
2473 && [check_effective_target_ilp32])
2474 || [istarget x86_64-*-*]
2475 || [check_effective_target_arm32]
2476 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2482 verbose "check_effective_target_vect_long: returning $answer" 2
2486 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2488 # This won't change for different subtargets so cache the result.
2490 proc check_effective_target_vect_float { } {
2491 global et_vect_float_saved
2493 if [info exists et_vect_float_saved] {
2494 verbose "check_effective_target_vect_float: using cached result" 2
2496 set et_vect_float_saved 0
2497 if { [istarget i?86-*-*]
2498 || [istarget powerpc*-*-*]
2499 || [istarget spu-*-*]
2500 || [istarget mipsisa64*-*-*]
2501 || [istarget x86_64-*-*]
2502 || [istarget ia64-*-*]
2503 || [check_effective_target_arm32] } {
2504 set et_vect_float_saved 1
2508 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2509 return $et_vect_float_saved
2512 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2514 # This won't change for different subtargets so cache the result.
2516 proc check_effective_target_vect_double { } {
2517 global et_vect_double_saved
2519 if [info exists et_vect_double_saved] {
2520 verbose "check_effective_target_vect_double: using cached result" 2
2522 set et_vect_double_saved 0
2523 if { [istarget i?86-*-*]
2524 || [istarget x86_64-*-*] } {
2525 if { [check_no_compiler_messages vect_double assembly {
2526 #ifdef __tune_atom__
2527 # error No double vectorizer support.
2530 set et_vect_double_saved 1
2532 set et_vect_double_saved 0
2534 } elseif { [istarget spu-*-*] } {
2535 set et_vect_double_saved 1
2539 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2540 return $et_vect_double_saved
2543 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2545 # This won't change for different subtargets so cache the result.
2547 proc check_effective_target_vect_long_long { } {
2548 global et_vect_long_long_saved
2550 if [info exists et_vect_long_long_saved] {
2551 verbose "check_effective_target_vect_long_long: using cached result" 2
2553 set et_vect_long_long_saved 0
2554 if { [istarget i?86-*-*]
2555 || [istarget x86_64-*-*] } {
2556 set et_vect_long_long_saved 1
2560 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2561 return $et_vect_long_long_saved
2565 # Return 1 if the target plus current options does not support a vector
2566 # max instruction on "int", 0 otherwise.
2568 # This won't change for different subtargets so cache the result.
2570 proc check_effective_target_vect_no_int_max { } {
2571 global et_vect_no_int_max_saved
2573 if [info exists et_vect_no_int_max_saved] {
2574 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2576 set et_vect_no_int_max_saved 0
2577 if { [istarget sparc*-*-*]
2578 || [istarget spu-*-*]
2579 || [istarget alpha*-*-*]
2580 || ([istarget mips*-*-*]
2581 && [check_effective_target_mips_loongson]) } {
2582 set et_vect_no_int_max_saved 1
2585 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2586 return $et_vect_no_int_max_saved
2589 # Return 1 if the target plus current options does not support a vector
2590 # add instruction on "int", 0 otherwise.
2592 # This won't change for different subtargets so cache the result.
2594 proc check_effective_target_vect_no_int_add { } {
2595 global et_vect_no_int_add_saved
2597 if [info exists et_vect_no_int_add_saved] {
2598 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2600 set et_vect_no_int_add_saved 0
2601 # Alpha only supports vector add on V8QI and V4HI.
2602 if { [istarget alpha*-*-*] } {
2603 set et_vect_no_int_add_saved 1
2606 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2607 return $et_vect_no_int_add_saved
2610 # Return 1 if the target plus current options does not support vector
2611 # bitwise instructions, 0 otherwise.
2613 # This won't change for different subtargets so cache the result.
2615 proc check_effective_target_vect_no_bitwise { } {
2616 global et_vect_no_bitwise_saved
2618 if [info exists et_vect_no_bitwise_saved] {
2619 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2621 set et_vect_no_bitwise_saved 0
2623 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2624 return $et_vect_no_bitwise_saved
2627 # Return 1 if the target plus current options supports vector permutation,
2630 # This won't change for different subtargets so cache the result.
2632 proc check_effective_target_vect_perm { } {
2635 if [info exists et_vect_perm_saved] {
2636 verbose "check_effective_target_vect_perm: using cached result" 2
2638 set et_vect_perm_saved 0
2639 if { [istarget powerpc*-*-*]
2640 || [istarget spu-*-*]
2641 || [istarget i?86-*-*]
2642 || [istarget x86_64-*-*] } {
2643 set et_vect_perm_saved 1
2646 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2647 return $et_vect_perm_saved
2650 # Return 1 if the target plus current options supports vector permutation
2651 # on byte-sized elements, 0 otherwise.
2653 # This won't change for different subtargets so cache the result.
2655 proc check_effective_target_vect_perm_byte { } {
2656 global et_vect_perm_byte
2658 if [info exists et_vect_perm_byte_saved] {
2659 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2661 set et_vect_perm_byte_saved 0
2662 if { [istarget powerpc*-*-*]
2663 || [istarget spu-*-*] } {
2664 set et_vect_perm_byte_saved 1
2667 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2668 return $et_vect_perm_byte_saved
2671 # Return 1 if the target plus current options supports vector permutation
2672 # on short-sized elements, 0 otherwise.
2674 # This won't change for different subtargets so cache the result.
2676 proc check_effective_target_vect_perm_short { } {
2677 global et_vect_perm_short
2679 if [info exists et_vect_perm_short_saved] {
2680 verbose "check_effective_target_vect_perm_short: using cached result" 2
2682 set et_vect_perm_short_saved 0
2683 if { [istarget powerpc*-*-*]
2684 || [istarget spu-*-*] } {
2685 set et_vect_perm_short_saved 1
2688 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2689 return $et_vect_perm_short_saved
2692 # Return 1 if the target plus current options supports a vector
2693 # widening summation of *short* args into *int* result, 0 otherwise.
2695 # This won't change for different subtargets so cache the result.
2697 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2698 global et_vect_widen_sum_hi_to_si_pattern
2700 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2701 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2703 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2704 if { [istarget powerpc*-*-*]
2705 || [istarget ia64-*-*] } {
2706 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2709 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2710 return $et_vect_widen_sum_hi_to_si_pattern_saved
2713 # Return 1 if the target plus current options supports a vector
2714 # widening summation of *short* args into *int* result, 0 otherwise.
2715 # A target can also support this widening summation if it can support
2716 # promotion (unpacking) from shorts to ints.
2718 # This won't change for different subtargets so cache the result.
2720 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2721 global et_vect_widen_sum_hi_to_si
2723 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2724 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2726 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2727 if { [istarget powerpc*-*-*]
2728 || [istarget ia64-*-*] } {
2729 set et_vect_widen_sum_hi_to_si_saved 1
2732 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2733 return $et_vect_widen_sum_hi_to_si_saved
2736 # Return 1 if the target plus current options supports a vector
2737 # widening summation of *char* args into *short* result, 0 otherwise.
2738 # A target can also support this widening summation if it can support
2739 # promotion (unpacking) from chars to shorts.
2741 # This won't change for different subtargets so cache the result.
2743 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2744 global et_vect_widen_sum_qi_to_hi
2746 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2747 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2749 set et_vect_widen_sum_qi_to_hi_saved 0
2750 if { [check_effective_target_vect_unpack]
2751 || [istarget ia64-*-*] } {
2752 set et_vect_widen_sum_qi_to_hi_saved 1
2755 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2756 return $et_vect_widen_sum_qi_to_hi_saved
2759 # Return 1 if the target plus current options supports a vector
2760 # widening summation of *char* args into *int* result, 0 otherwise.
2762 # This won't change for different subtargets so cache the result.
2764 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2765 global et_vect_widen_sum_qi_to_si
2767 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2768 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2770 set et_vect_widen_sum_qi_to_si_saved 0
2771 if { [istarget powerpc*-*-*] } {
2772 set et_vect_widen_sum_qi_to_si_saved 1
2775 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2776 return $et_vect_widen_sum_qi_to_si_saved
2779 # Return 1 if the target plus current options supports a vector
2780 # widening multiplication of *char* args into *short* result, 0 otherwise.
2781 # A target can also support this widening multplication if it can support
2782 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2783 # multiplication of shorts).
2785 # This won't change for different subtargets so cache the result.
2788 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2789 global et_vect_widen_mult_qi_to_hi
2791 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2792 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2794 if { [check_effective_target_vect_unpack]
2795 && [check_effective_target_vect_short_mult] } {
2796 set et_vect_widen_mult_qi_to_hi_saved 1
2798 set et_vect_widen_mult_qi_to_hi_saved 0
2800 if { [istarget powerpc*-*-*]
2801 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2802 set et_vect_widen_mult_qi_to_hi_saved 1
2805 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2806 return $et_vect_widen_mult_qi_to_hi_saved
2809 # Return 1 if the target plus current options supports a vector
2810 # widening multiplication of *short* args into *int* result, 0 otherwise.
2811 # A target can also support this widening multplication if it can support
2812 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2813 # multiplication of ints).
2815 # This won't change for different subtargets so cache the result.
2818 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2819 global et_vect_widen_mult_hi_to_si
2821 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2822 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2824 if { [check_effective_target_vect_unpack]
2825 && [check_effective_target_vect_int_mult] } {
2826 set et_vect_widen_mult_hi_to_si_saved 1
2828 set et_vect_widen_mult_hi_to_si_saved 0
2830 if { [istarget powerpc*-*-*]
2831 || [istarget spu-*-*]
2832 || [istarget ia64-*-*]
2833 || [istarget i?86-*-*]
2834 || [istarget x86_64-*-*]
2835 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2836 set et_vect_widen_mult_hi_to_si_saved 1
2839 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2840 return $et_vect_widen_mult_hi_to_si_saved
2843 # Return 1 if the target plus current options supports a vector
2844 # widening multiplication of *char* args into *short* result, 0 otherwise.
2846 # This won't change for different subtargets so cache the result.
2848 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
2849 global et_vect_widen_mult_qi_to_hi_pattern
2851 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
2852 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
2854 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
2855 if { [istarget powerpc*-*-*]
2856 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2857 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
2860 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
2861 return $et_vect_widen_mult_qi_to_hi_pattern_saved
2864 # Return 1 if the target plus current options supports a vector
2865 # widening multiplication of *short* args into *int* result, 0 otherwise.
2867 # This won't change for different subtargets so cache the result.
2869 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
2870 global et_vect_widen_mult_hi_to_si_pattern
2872 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
2873 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
2875 set et_vect_widen_mult_hi_to_si_pattern_saved 0
2876 if { [istarget powerpc*-*-*]
2877 || [istarget spu-*-*]
2878 || [istarget ia64-*-*]
2879 || [istarget i?86-*-*]
2880 || [istarget x86_64-*-*]
2881 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2882 set et_vect_widen_mult_hi_to_si_pattern_saved 1
2885 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
2886 return $et_vect_widen_mult_hi_to_si_pattern_saved
2889 # Return 1 if the target plus current options supports a vector
2890 # dot-product of signed chars, 0 otherwise.
2892 # This won't change for different subtargets so cache the result.
2894 proc check_effective_target_vect_sdot_qi { } {
2895 global et_vect_sdot_qi
2897 if [info exists et_vect_sdot_qi_saved] {
2898 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2900 set et_vect_sdot_qi_saved 0
2901 if { [istarget ia64-*-*] } {
2902 set et_vect_udot_qi_saved 1
2905 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2906 return $et_vect_sdot_qi_saved
2909 # Return 1 if the target plus current options supports a vector
2910 # dot-product of unsigned chars, 0 otherwise.
2912 # This won't change for different subtargets so cache the result.
2914 proc check_effective_target_vect_udot_qi { } {
2915 global et_vect_udot_qi
2917 if [info exists et_vect_udot_qi_saved] {
2918 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2920 set et_vect_udot_qi_saved 0
2921 if { [istarget powerpc*-*-*]
2922 || [istarget ia64-*-*] } {
2923 set et_vect_udot_qi_saved 1
2926 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2927 return $et_vect_udot_qi_saved
2930 # Return 1 if the target plus current options supports a vector
2931 # dot-product of signed shorts, 0 otherwise.
2933 # This won't change for different subtargets so cache the result.
2935 proc check_effective_target_vect_sdot_hi { } {
2936 global et_vect_sdot_hi
2938 if [info exists et_vect_sdot_hi_saved] {
2939 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2941 set et_vect_sdot_hi_saved 0
2942 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2943 || [istarget ia64-*-*]
2944 || [istarget i?86-*-*]
2945 || [istarget x86_64-*-*] } {
2946 set et_vect_sdot_hi_saved 1
2949 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2950 return $et_vect_sdot_hi_saved
2953 # Return 1 if the target plus current options supports a vector
2954 # dot-product of unsigned shorts, 0 otherwise.
2956 # This won't change for different subtargets so cache the result.
2958 proc check_effective_target_vect_udot_hi { } {
2959 global et_vect_udot_hi
2961 if [info exists et_vect_udot_hi_saved] {
2962 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2964 set et_vect_udot_hi_saved 0
2965 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2966 set et_vect_udot_hi_saved 1
2969 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2970 return $et_vect_udot_hi_saved
2974 # Return 1 if the target plus current options supports a vector
2975 # demotion (packing) of shorts (to chars) and ints (to shorts)
2976 # using modulo arithmetic, 0 otherwise.
2978 # This won't change for different subtargets so cache the result.
2980 proc check_effective_target_vect_pack_trunc { } {
2981 global et_vect_pack_trunc
2983 if [info exists et_vect_pack_trunc_saved] {
2984 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2986 set et_vect_pack_trunc_saved 0
2987 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2988 || [istarget i?86-*-*]
2989 || [istarget x86_64-*-*]
2990 || [istarget spu-*-*]
2991 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
2992 && [check_effective_target_arm_little_endian]) } {
2993 set et_vect_pack_trunc_saved 1
2996 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2997 return $et_vect_pack_trunc_saved
3000 # Return 1 if the target plus current options supports a vector
3001 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3003 # This won't change for different subtargets so cache the result.
3005 proc check_effective_target_vect_unpack { } {
3006 global et_vect_unpack
3008 if [info exists et_vect_unpack_saved] {
3009 verbose "check_effective_target_vect_unpack: using cached result" 2
3011 set et_vect_unpack_saved 0
3012 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3013 || [istarget i?86-*-*]
3014 || [istarget x86_64-*-*]
3015 || [istarget spu-*-*]
3016 || [istarget ia64-*-*]
3017 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3018 && [check_effective_target_arm_little_endian]) } {
3019 set et_vect_unpack_saved 1
3022 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3023 return $et_vect_unpack_saved
3026 # Return 1 if the target plus current options does not guarantee
3027 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3029 # This won't change for different subtargets so cache the result.
3031 proc check_effective_target_unaligned_stack { } {
3032 global et_unaligned_stack_saved
3034 if [info exists et_unaligned_stack_saved] {
3035 verbose "check_effective_target_unaligned_stack: using cached result" 2
3037 set et_unaligned_stack_saved 0
3039 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3040 return $et_unaligned_stack_saved
3043 # Return 1 if the target plus current options does not support a vector
3044 # alignment mechanism, 0 otherwise.
3046 # This won't change for different subtargets so cache the result.
3048 proc check_effective_target_vect_no_align { } {
3049 global et_vect_no_align_saved
3051 if [info exists et_vect_no_align_saved] {
3052 verbose "check_effective_target_vect_no_align: using cached result" 2
3054 set et_vect_no_align_saved 0
3055 if { [istarget mipsisa64*-*-*]
3056 || [istarget sparc*-*-*]
3057 || [istarget ia64-*-*]
3058 || [check_effective_target_arm_vect_no_misalign]
3059 || ([istarget mips*-*-*]
3060 && [check_effective_target_mips_loongson]) } {
3061 set et_vect_no_align_saved 1
3064 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3065 return $et_vect_no_align_saved
3068 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3070 # This won't change for different subtargets so cache the result.
3072 proc check_effective_target_vect_hw_misalign { } {
3073 global et_vect_hw_misalign_saved
3075 if [info exists et_vect_hw_misalign_saved] {
3076 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3078 set et_vect_hw_misalign_saved 0
3079 if { ([istarget x86_64-*-*]
3080 || [istarget i?86-*-*]) } {
3081 set et_vect_hw_misalign_saved 1
3084 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3085 return $et_vect_hw_misalign_saved
3089 # Return 1 if arrays are aligned to the vector alignment
3090 # boundary, 0 otherwise.
3092 # This won't change for different subtargets so cache the result.
3094 proc check_effective_target_vect_aligned_arrays { } {
3095 global et_vect_aligned_arrays
3097 if [info exists et_vect_aligned_arrays_saved] {
3098 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3100 set et_vect_aligned_arrays_saved 0
3101 if { (([istarget x86_64-*-*]
3102 || [istarget i?86-*-*]) && [is-effective-target lp64])
3103 || [istarget spu-*-*] } {
3104 set et_vect_aligned_arrays_saved 1
3107 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3108 return $et_vect_aligned_arrays_saved
3111 # Return 1 if types of size 32 bit or less are naturally aligned
3112 # (aligned to their type-size), 0 otherwise.
3114 # This won't change for different subtargets so cache the result.
3116 proc check_effective_target_natural_alignment_32 { } {
3117 global et_natural_alignment_32
3119 if [info exists et_natural_alignment_32_saved] {
3120 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3122 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3123 set et_natural_alignment_32_saved 1
3124 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3125 set et_natural_alignment_32_saved 0
3128 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3129 return $et_natural_alignment_32_saved
3132 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3133 # type-size), 0 otherwise.
3135 # This won't change for different subtargets so cache the result.
3137 proc check_effective_target_natural_alignment_64 { } {
3138 global et_natural_alignment_64
3140 if [info exists et_natural_alignment_64_saved] {
3141 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3143 set et_natural_alignment_64_saved 0
3144 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3145 || [istarget spu-*-*] } {
3146 set et_natural_alignment_64_saved 1
3149 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3150 return $et_natural_alignment_64_saved
3153 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3155 # This won't change for different subtargets so cache the result.
3157 proc check_effective_target_vector_alignment_reachable { } {
3158 global et_vector_alignment_reachable
3160 if [info exists et_vector_alignment_reachable_saved] {
3161 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3163 if { [check_effective_target_vect_aligned_arrays]
3164 || [check_effective_target_natural_alignment_32] } {
3165 set et_vector_alignment_reachable_saved 1
3167 set et_vector_alignment_reachable_saved 0
3170 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3171 return $et_vector_alignment_reachable_saved
3174 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3176 # This won't change for different subtargets so cache the result.
3178 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3179 global et_vector_alignment_reachable_for_64bit
3181 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3182 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3184 if { [check_effective_target_vect_aligned_arrays]
3185 || [check_effective_target_natural_alignment_64] } {
3186 set et_vector_alignment_reachable_for_64bit_saved 1
3188 set et_vector_alignment_reachable_for_64bit_saved 0
3191 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3192 return $et_vector_alignment_reachable_for_64bit_saved
3195 # Return 1 if the target only requires element alignment for vector accesses
3197 proc check_effective_target_vect_element_align { } {
3198 global et_vect_element_align
3200 if [info exists et_vect_element_align] {
3201 verbose "check_effective_target_vect_element_align: using cached result" 2
3203 set et_vect_element_align 0
3204 if { ([istarget arm*-*-*]
3205 && ![check_effective_target_arm_vect_no_misalign])
3206 || [check_effective_target_vect_hw_misalign] } {
3207 set et_vect_element_align 1
3211 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3212 return $et_vect_element_align
3215 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3217 proc check_effective_target_vect_condition { } {
3218 global et_vect_cond_saved
3220 if [info exists et_vect_cond_saved] {
3221 verbose "check_effective_target_vect_cond: using cached result" 2
3223 set et_vect_cond_saved 0
3224 if { [istarget powerpc*-*-*]
3225 || [istarget ia64-*-*]
3226 || [istarget i?86-*-*]
3227 || [istarget spu-*-*]
3228 || [istarget x86_64-*-*] } {
3229 set et_vect_cond_saved 1
3233 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3234 return $et_vect_cond_saved
3237 # Return 1 if the target supports vector conditional operations where
3238 # the comparison has different type from the lhs, 0 otherwise.
3240 proc check_effective_target_vect_cond_mixed { } {
3241 global et_vect_cond_mixed_saved
3243 if [info exists et_vect_cond_mixed_saved] {
3244 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3246 set et_vect_cond_mixed_saved 0
3247 if { [istarget i?86-*-*]
3248 || [istarget x86_64-*-*] } {
3249 set et_vect_cond_mixed_saved 1
3253 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3254 return $et_vect_cond_mixed_saved
3257 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3259 proc check_effective_target_vect_char_mult { } {
3260 global et_vect_char_mult_saved
3262 if [info exists et_vect_char_mult_saved] {
3263 verbose "check_effective_target_vect_char_mult: using cached result" 2
3265 set et_vect_char_mult_saved 0
3266 if { [istarget ia64-*-*]
3267 || [istarget i?86-*-*]
3268 || [istarget x86_64-*-*] } {
3269 set et_vect_char_mult_saved 1
3273 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3274 return $et_vect_char_mult_saved
3277 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3279 proc check_effective_target_vect_short_mult { } {
3280 global et_vect_short_mult_saved
3282 if [info exists et_vect_short_mult_saved] {
3283 verbose "check_effective_target_vect_short_mult: using cached result" 2
3285 set et_vect_short_mult_saved 0
3286 if { [istarget ia64-*-*]
3287 || [istarget spu-*-*]
3288 || [istarget i?86-*-*]
3289 || [istarget x86_64-*-*]
3290 || [istarget powerpc*-*-*]
3291 || [check_effective_target_arm32]
3292 || ([istarget mips*-*-*]
3293 && [check_effective_target_mips_loongson]) } {
3294 set et_vect_short_mult_saved 1
3298 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3299 return $et_vect_short_mult_saved
3302 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3304 proc check_effective_target_vect_int_mult { } {
3305 global et_vect_int_mult_saved
3307 if [info exists et_vect_int_mult_saved] {