1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2 # 2011, 2012 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 # Windows targets Cygwin and MingW32 support it
238 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
242 # HP-UX 10.X doesn't support it
244 if { [istarget hppa*-*-hpux10*] } {
248 # ELF and ECOFF support it. a.out does with gas/gld but may also with
249 # other linkers, so we should try it
251 set objformat [gcc_target_object_format]
259 unknown { return -1 }
264 ###############################
265 # proc check_weak_override_available { }
266 ###############################
268 # Like check_weak_available, but return 0 if weak symbol definitions
269 # cannot be overridden.
271 proc check_weak_override_available { } {
272 if { [istarget *-*-mingw*] } {
275 return [check_weak_available]
278 ###############################
279 # proc check_visibility_available { what_kind }
280 ###############################
282 # The visibility attribute is only support in some object formats
283 # This proc returns 1 if it is supported, 0 if not.
284 # The argument is the kind of visibility, default/protected/hidden/internal.
286 proc check_visibility_available { what_kind } {
287 if [string match "" $what_kind] { set what_kind "hidden" }
289 return [check_no_compiler_messages visibility_available_$what_kind object "
290 void f() __attribute__((visibility(\"$what_kind\")));
295 ###############################
296 # proc check_alias_available { }
297 ###############################
299 # Determine if the target toolchain supports the alias attribute.
301 # Returns 2 if the target supports aliases. Returns 1 if the target
302 # only supports weak aliased. Returns 0 if the target does not
303 # support aliases at all. Returns -1 if support for aliases could not
306 proc check_alias_available { } {
307 global alias_available_saved
310 if [info exists alias_available_saved] {
311 verbose "check_alias_available returning saved $alias_available_saved" 2
315 verbose "check_alias_available compiling testfile $src" 2
316 set f [open $src "w"]
317 # Compile a small test program. The definition of "g" is
318 # necessary to keep the Solaris assembler from complaining
320 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
321 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
323 set lines [${tool}_target_compile $src $obj object ""]
325 remote_file build delete $obj
327 if [string match "" $lines] then {
328 # No error messages, everything is OK.
329 set alias_available_saved 2
331 if [regexp "alias definitions not supported" $lines] {
332 verbose "check_alias_available target does not support aliases" 2
334 set objformat [gcc_target_object_format]
336 if { $objformat == "elf" } {
337 verbose "check_alias_available but target uses ELF format, so it ought to" 2
338 set alias_available_saved -1
340 set alias_available_saved 0
343 if [regexp "only weak aliases are supported" $lines] {
344 verbose "check_alias_available target supports only weak aliases" 2
345 set alias_available_saved 1
347 set alias_available_saved -1
352 verbose "check_alias_available returning $alias_available_saved" 2
355 return $alias_available_saved
358 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
360 proc check_ifunc_available { } {
361 return [check_no_compiler_messages ifunc_available object {
366 void f() __attribute__((ifunc("g")));
370 # Returns true if --gc-sections is supported on the target.
372 proc check_gc_sections_available { } {
373 global gc_sections_available_saved
376 if {![info exists gc_sections_available_saved]} {
377 # Some targets don't support gc-sections despite whatever's
378 # advertised by ld's options.
379 if { [istarget alpha*-*-*]
380 || [istarget ia64-*-*] } {
381 set gc_sections_available_saved 0
385 # elf2flt uses -q (--emit-relocs), which is incompatible with
387 if { [board_info target exists ldflags]
388 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
389 set gc_sections_available_saved 0
393 # VxWorks kernel modules are relocatable objects linked with -r,
394 # while RTP executables are linked with -q (--emit-relocs).
395 # Both of these options are incompatible with --gc-sections.
396 if { [istarget *-*-vxworks*] } {
397 set gc_sections_available_saved 0
401 # Check if the ld used by gcc supports --gc-sections.
402 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
403 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
404 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
405 set ld_output [remote_exec host "$gcc_ld" "--help"]
406 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
407 set gc_sections_available_saved 1
409 set gc_sections_available_saved 0
412 return $gc_sections_available_saved
415 # Return 1 if according to target_info struct and explicit target list
416 # target is supposed to support trampolines.
418 proc check_effective_target_trampolines { } {
419 if [target_info exists no_trampolines] {
422 if { [istarget avr-*-*]
423 || [istarget hppa2.0w-hp-hpux11.23]
424 || [istarget hppa64-hp-hpux11.23] } {
430 # Return 1 if according to target_info struct and explicit target list
431 # target is supposed to keep null pointer checks. This could be due to
432 # use of option fno-delete-null-pointer-checks or hardwired in target.
434 proc check_effective_target_keeps_null_pointer_checks { } {
435 if [target_info exists keeps_null_pointer_checks] {
438 if { [istarget avr-*-*] } {
444 # Return true if profiling is supported on the target.
446 proc check_profiling_available { test_what } {
447 global profiling_available_saved
449 verbose "Profiling argument is <$test_what>" 1
451 # These conditions depend on the argument so examine them before
452 # looking at the cache variable.
454 # Tree profiling requires TLS runtime support.
455 if { $test_what == "-fprofile-generate" } {
456 if { ![check_effective_target_tls_runtime] } {
461 # Support for -p on solaris2 relies on mcrt1.o which comes with the
462 # vendor compiler. We cannot reliably predict the directory where the
463 # vendor compiler (and thus mcrt1.o) is installed so we can't
464 # necessarily find mcrt1.o even if we have it.
465 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
469 # We don't yet support profiling for MIPS16.
470 if { [istarget mips*-*-*]
471 && ![check_effective_target_nomips16]
472 && ($test_what == "-p" || $test_what == "-pg") } {
476 # MinGW does not support -p.
477 if { [istarget *-*-mingw*] && $test_what == "-p" } {
481 # cygwin does not support -p.
482 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
486 # uClibc does not have gcrt1.o.
487 if { [check_effective_target_uclibc]
488 && ($test_what == "-p" || $test_what == "-pg") } {
492 # Now examine the cache variable.
493 if {![info exists profiling_available_saved]} {
494 # Some targets don't have any implementation of __bb_init_func or are
495 # missing other needed machinery.
496 if { [istarget am3*-*-linux*]
497 || [istarget arm*-*-eabi*]
498 || [istarget arm*-*-elf]
499 || [istarget arm*-*-symbianelf*]
500 || [istarget avr-*-*]
501 || [istarget bfin-*-*]
502 || [istarget cris-*-*]
503 || [istarget crisv32-*-*]
504 || [istarget fido-*-elf]
505 || [istarget h8300-*-*]
506 || [istarget lm32-*-*]
507 || [istarget m32c-*-elf]
508 || [istarget m68k-*-elf]
509 || [istarget m68k-*-uclinux*]
510 || [istarget mep-*-elf]
511 || [istarget mips*-*-elf*]
512 || [istarget mmix-*-*]
513 || [istarget mn10300-*-elf*]
514 || [istarget moxie-*-elf*]
515 || [istarget picochip-*-*]
516 || [istarget powerpc-*-eabi*]
517 || [istarget powerpc-*-elf]
519 || [istarget tic6x-*-elf]
520 || [istarget xstormy16-*]
521 || [istarget xtensa*-*-elf]
522 || [istarget *-*-rtems*]
523 || [istarget *-*-vxworks*] } {
524 set profiling_available_saved 0
526 set profiling_available_saved 1
530 return $profiling_available_saved
533 # Check to see if a target is "freestanding". This is as per the definition
534 # in Section 4 of C99 standard. Effectively, it is a target which supports no
535 # extra headers or libraries other than what is considered essential.
536 proc check_effective_target_freestanding { } {
537 if { [istarget picochip-*-*] } then {
544 # Return 1 if target has packed layout of structure members by
545 # default, 0 otherwise. Note that this is slightly different than
546 # whether the target has "natural alignment": both attributes may be
549 proc check_effective_target_default_packed { } {
550 return [check_no_compiler_messages default_packed assembly {
551 struct x { char a; long b; } c;
552 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
556 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
557 # documentation, where the test also comes from.
559 proc check_effective_target_pcc_bitfield_type_matters { } {
560 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
561 # bitfields, but let's stick to the example code from the docs.
562 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
563 struct foo1 { char x; char :0; char y; };
564 struct foo2 { char x; int :0; char y; };
565 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
569 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
571 proc add_options_for_tls { flags } {
572 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
573 # libthread, so always pass -pthread for native TLS.
574 # Need to duplicate native TLS check from
575 # check_effective_target_tls_native to avoid recursion.
576 if { [istarget *-*-solaris2.\[89\]*] &&
577 [check_no_messages_and_pattern tls_native "!emutls" assembly {
579 int f (void) { return i; }
580 void g (int j) { i = j; }
582 return "$flags -pthread"
587 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
589 proc check_effective_target_tls {} {
590 return [check_no_compiler_messages tls assembly {
592 int f (void) { return i; }
593 void g (int j) { i = j; }
597 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
599 proc check_effective_target_tls_native {} {
600 # VxWorks uses emulated TLS machinery, but with non-standard helper
601 # functions, so we fail to automatically detect it.
602 if { [istarget *-*-vxworks*] } {
606 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
608 int f (void) { return i; }
609 void g (int j) { i = j; }
613 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
615 proc check_effective_target_tls_emulated {} {
616 # VxWorks uses emulated TLS machinery, but with non-standard helper
617 # functions, so we fail to automatically detect it.
618 if { [istarget *-*-vxworks*] } {
622 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
624 int f (void) { return i; }
625 void g (int j) { i = j; }
629 # Return 1 if TLS executables can run correctly, 0 otherwise.
631 proc check_effective_target_tls_runtime {} {
632 return [check_runtime tls_runtime {
633 __thread int thr = 0;
634 int main (void) { return thr; }
635 } [add_options_for_tls ""]]
638 # Return 1 if atomic compare-and-swap is supported on 'int'
640 proc check_effective_target_cas_char {} {
641 return [check_no_compiler_messages cas_char assembly {
642 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
648 proc check_effective_target_cas_int {} {
649 return [check_no_compiler_messages cas_int assembly {
650 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
652 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
660 # Return 1 if -ffunction-sections is supported, 0 otherwise.
662 proc check_effective_target_function_sections {} {
663 # Darwin has its own scheme and silently accepts -ffunction-sections.
664 if { [istarget *-*-darwin*] } {
668 return [check_no_compiler_messages functionsections assembly {
670 } "-ffunction-sections"]
673 # Return 1 if instruction scheduling is available, 0 otherwise.
675 proc check_effective_target_scheduling {} {
676 return [check_no_compiler_messages scheduling object {
678 } "-fschedule-insns"]
681 # Return 1 if compilation with -fgraphite is error-free for trivial
684 proc check_effective_target_fgraphite {} {
685 return [check_no_compiler_messages fgraphite object {
690 # Return 1 if compilation with -fopenmp is error-free for trivial
693 proc check_effective_target_fopenmp {} {
694 return [check_no_compiler_messages fopenmp object {
699 # Return 1 if compilation with -fgnu-tm is error-free for trivial
702 proc check_effective_target_fgnu_tm {} {
703 return [check_no_compiler_messages fgnu_tm object {
708 # Return 1 if the target supports mmap, 0 otherwise.
710 proc check_effective_target_mmap {} {
711 return [check_function_available "mmap"]
714 # Return 1 if compilation with -pthread is error-free for trivial
717 proc check_effective_target_pthread {} {
718 return [check_no_compiler_messages pthread object {
723 # Return 1 if compilation with -mpe-aligned-commons is error-free
724 # for trivial code, 0 otherwise.
726 proc check_effective_target_pe_aligned_commons {} {
727 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
728 return [check_no_compiler_messages pe_aligned_commons object {
730 } "-mpe-aligned-commons"]
735 # Return 1 if the target supports -static
736 proc check_effective_target_static {} {
737 return [check_no_compiler_messages static executable {
738 int main (void) { return 0; }
742 # Return 1 if the target supports -fstack-protector
743 proc check_effective_target_fstack_protector {} {
744 return [check_runtime fstack_protector {
745 int main (void) { return 0; }
746 } "-fstack-protector"]
749 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
750 # for trivial code, 0 otherwise.
752 proc check_effective_target_freorder {} {
753 return [check_no_compiler_messages freorder object {
755 } "-freorder-blocks-and-partition"]
758 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
759 # emitted, 0 otherwise. Whether a shared library can actually be built is
760 # out of scope for this test.
762 proc check_effective_target_fpic { } {
763 # Note that M68K has a multilib that supports -fpic but not
764 # -fPIC, so we need to check both. We test with a program that
765 # requires GOT references.
766 foreach arg {fpic fPIC} {
767 if [check_no_compiler_messages $arg object {
768 extern int foo (void); extern int bar;
769 int baz (void) { return foo () + bar; }
777 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
779 proc check_effective_target_pie { } {
780 if { [istarget *-*-darwin\[912\]*]
781 || [istarget *-*-linux*] } {
787 # Return true if the target supports -mpaired-single (as used on MIPS).
789 proc check_effective_target_mpaired_single { } {
790 return [check_no_compiler_messages mpaired_single object {
795 # Return true if the target has access to FPU instructions.
797 proc check_effective_target_hard_float { } {
798 if { [istarget mips*-*-*] } {
799 return [check_no_compiler_messages hard_float assembly {
800 #if (defined __mips_soft_float || defined __mips16)
806 # This proc is actually checking the availabilty of FPU
807 # support for doubles, so on the RX we must fail if the
808 # 64-bit double multilib has been selected.
809 if { [istarget rx-*-*] } {
811 # return [check_no_compiler_messages hard_float assembly {
812 #if defined __RX_64_BIT_DOUBLES__
818 # The generic test equates hard_float with "no call for adding doubles".
819 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
820 double a (double b, double c) { return b + c; }
824 # Return true if the target is a 64-bit MIPS target.
826 proc check_effective_target_mips64 { } {
827 return [check_no_compiler_messages mips64 assembly {
834 # Return true if the target is a MIPS target that does not produce
837 proc check_effective_target_nomips16 { } {
838 return [check_no_compiler_messages nomips16 object {
842 /* A cheap way of testing for -mflip-mips16. */
843 void foo (void) { asm ("addiu $20,$20,1"); }
844 void bar (void) { asm ("addiu $20,$20,1"); }
849 # Add the options needed for MIPS16 function attributes. At the moment,
850 # we don't support MIPS16 PIC.
852 proc add_options_for_mips16_attribute { flags } {
853 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
856 # Return true if we can force a mode that allows MIPS16 code generation.
857 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
860 proc check_effective_target_mips16_attribute { } {
861 return [check_no_compiler_messages mips16_attribute assembly {
865 #if defined __mips_hard_float \
866 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
867 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
870 } [add_options_for_mips16_attribute ""]]
873 # Return 1 if the target supports long double larger than double when
874 # using the new ABI, 0 otherwise.
876 proc check_effective_target_mips_newabi_large_long_double { } {
877 return [check_no_compiler_messages mips_newabi_large_long_double object {
878 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
882 # Return true if the target is a MIPS target that has access
883 # to the LL and SC instructions.
885 proc check_effective_target_mips_llsc { } {
886 if { ![istarget mips*-*-*] } {
889 # Assume that these instructions are always implemented for
890 # non-elf* targets, via emulation if necessary.
891 if { ![istarget *-*-elf*] } {
894 # Otherwise assume LL/SC support for everything but MIPS I.
895 return [check_no_compiler_messages mips_llsc assembly {
902 # Return true if the target is a MIPS target that uses in-place relocations.
904 proc check_effective_target_mips_rel { } {
905 if { ![istarget mips*-*-*] } {
908 return [check_no_compiler_messages mips_rel object {
909 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
910 || (defined _ABI64 && _MIPS_SIM == _ABI64)
916 # Return true if the target is a MIPS target that uses the EABI.
918 proc check_effective_target_mips_eabi { } {
919 if { ![istarget mips*-*-*] } {
922 return [check_no_compiler_messages mips_eabi object {
929 # Return 1 if the current multilib does not generate PIC by default.
931 proc check_effective_target_nonpic { } {
932 return [check_no_compiler_messages nonpic assembly {
939 # Return 1 if the target does not use a status wrapper.
941 proc check_effective_target_unwrapped { } {
942 if { [target_info needs_status_wrapper] != "" \
943 && [target_info needs_status_wrapper] != "0" } {
949 # Return true if iconv is supported on the target. In particular IBM1047.
951 proc check_iconv_available { test_what } {
954 # If the tool configuration file has not set libiconv, try "-liconv"
955 if { ![info exists libiconv] } {
956 set libiconv "-liconv"
958 set test_what [lindex $test_what 1]
959 return [check_runtime_nocache $test_what [subst {
965 cd = iconv_open ("$test_what", "UTF-8");
966 if (cd == (iconv_t) -1)
973 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
975 proc check_ascii_locale_available { } {
979 # Return true if named sections are supported on this target.
981 proc check_named_sections_available { } {
982 return [check_no_compiler_messages named_sections assembly {
983 int __attribute__ ((section("whatever"))) foo;
987 # Return 1 if the target supports Fortran real kinds larger than real(8),
990 # When the target name changes, replace the cached result.
992 proc check_effective_target_fortran_large_real { } {
993 return [check_no_compiler_messages fortran_large_real executable {
995 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1002 # Return 1 if the target supports Fortran real kind real(16),
1003 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1004 # this checks for Real(16) only; the other returned real(10) if
1005 # both real(10) and real(16) are available.
1007 # When the target name changes, replace the cached result.
1009 proc check_effective_target_fortran_real_16 { } {
1010 return [check_no_compiler_messages fortran_real_16 executable {
1019 # Return 1 if the target supports SQRT for the largest floating-point
1020 # type. (Some targets lack the libm support for this FP type.)
1021 # On most targets, this check effectively checks either whether sqrtl is
1022 # available or on __float128 systems whether libquadmath is installed,
1023 # which provides sqrtq.
1025 # When the target name changes, replace the cached result.
1027 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1028 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1030 use iso_fortran_env, only: real_kinds
1031 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1032 real(kind=maxFP), volatile :: x
1040 # Return 1 if the target supports Fortran integer kinds larger than
1041 # integer(8), 0 otherwise.
1043 # When the target name changes, replace the cached result.
1045 proc check_effective_target_fortran_large_int { } {
1046 return [check_no_compiler_messages fortran_large_int executable {
1048 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1049 integer(kind=k) :: i
1054 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1056 # When the target name changes, replace the cached result.
1058 proc check_effective_target_fortran_integer_16 { } {
1059 return [check_no_compiler_messages fortran_integer_16 executable {
1066 # Return 1 if we can statically link libgfortran, 0 otherwise.
1068 # When the target name changes, replace the cached result.
1070 proc check_effective_target_static_libgfortran { } {
1071 return [check_no_compiler_messages static_libgfortran executable {
1078 proc check_linker_plugin_available { } {
1079 return [check_no_compiler_messages_nocache linker_plugin executable {
1080 int main() { return 0; }
1081 } "-flto -fuse-linker-plugin"]
1084 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1085 # otherwise. Cache the result.
1087 proc check_750cl_hw_available { } {
1088 return [check_cached_effective_target 750cl_hw_available {
1089 # If this is not the right target then we can skip the test.
1090 if { ![istarget powerpc-*paired*] } {
1093 check_runtime_nocache 750cl_hw_available {
1097 asm volatile ("ps_mul v0,v0,v0");
1099 asm volatile ("ps_mul 0,0,0");
1108 # Return 1 if the target OS supports running SSE executables, 0
1109 # otherwise. Cache the result.
1111 proc check_sse_os_support_available { } {
1112 return [check_cached_effective_target sse_os_support_available {
1113 # If this is not the right target then we can skip the test.
1114 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1116 } elseif { [istarget i?86-*-solaris2*] } {
1117 # The Solaris 2 kernel doesn't save and restore SSE registers
1118 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1119 check_runtime_nocache sse_os_support_available {
1122 asm volatile ("movaps %xmm0,%xmm0");
1132 # Return 1 if the target OS supports running AVX executables, 0
1133 # otherwise. Cache the result.
1135 proc check_avx_os_support_available { } {
1136 return [check_cached_effective_target avx_os_support_available {
1137 # If this is not the right target then we can skip the test.
1138 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1141 # Check that OS has AVX and SSE saving enabled.
1142 check_runtime_nocache avx_os_support_available {
1145 unsigned int eax, edx;
1147 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1148 return (eax & 6) != 6;
1155 # Return 1 if the target supports executing SSE instructions, 0
1156 # otherwise. Cache the result.
1158 proc check_sse_hw_available { } {
1159 return [check_cached_effective_target sse_hw_available {
1160 # If this is not the right target then we can skip the test.
1161 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1164 check_runtime_nocache sse_hw_available {
1168 unsigned int eax, ebx, ecx, edx;
1169 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1170 return !(edx & bit_SSE);
1178 # Return 1 if the target supports executing SSE2 instructions, 0
1179 # otherwise. Cache the result.
1181 proc check_sse2_hw_available { } {
1182 return [check_cached_effective_target sse2_hw_available {
1183 # If this is not the right target then we can skip the test.
1184 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1187 check_runtime_nocache sse2_hw_available {
1191 unsigned int eax, ebx, ecx, edx;
1192 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1193 return !(edx & bit_SSE2);
1201 # Return 1 if the target supports executing AVX instructions, 0
1202 # otherwise. Cache the result.
1204 proc check_avx_hw_available { } {
1205 return [check_cached_effective_target avx_hw_available {
1206 # If this is not the right target then we can skip the test.
1207 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1210 check_runtime_nocache avx_hw_available {
1214 unsigned int eax, ebx, ecx, edx;
1215 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1216 return ((ecx & (bit_AVX | bit_OSXSAVE))
1217 != (bit_AVX | bit_OSXSAVE));
1225 # Return 1 if the target supports running SSE executables, 0 otherwise.
1227 proc check_effective_target_sse_runtime { } {
1228 if { [check_effective_target_sse]
1229 && [check_sse_hw_available]
1230 && [check_sse_os_support_available] } {
1236 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1238 proc check_effective_target_sse2_runtime { } {
1239 if { [check_effective_target_sse2]
1240 && [check_sse2_hw_available]
1241 && [check_sse_os_support_available] } {
1247 # Return 1 if the target supports running AVX executables, 0 otherwise.
1249 proc check_effective_target_avx_runtime { } {
1250 if { [check_effective_target_avx]
1251 && [check_avx_hw_available]
1252 && [check_avx_os_support_available] } {
1258 # Return 1 if the target supports executing VSX instructions, 0
1259 # otherwise. Cache the result.
1261 proc check_vsx_hw_available { } {
1262 return [check_cached_effective_target vsx_hw_available {
1263 # Some simulators are known to not support VSX instructions.
1264 # For now, disable on Darwin
1265 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1269 check_runtime_nocache vsx_hw_available {
1273 asm volatile ("xxlor vs0,vs0,vs0");
1275 asm volatile ("xxlor 0,0,0");
1284 # Return 1 if the target supports executing AltiVec instructions, 0
1285 # otherwise. Cache the result.
1287 proc check_vmx_hw_available { } {
1288 return [check_cached_effective_target vmx_hw_available {
1289 # Some simulators are known to not support VMX instructions.
1290 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1293 # Most targets don't require special flags for this test case, but
1294 # Darwin does. Just to be sure, make sure VSX is not enabled for
1295 # the altivec tests.
1296 if { [istarget *-*-darwin*]
1297 || [istarget *-*-aix*] } {
1298 set options "-maltivec -mno-vsx"
1300 set options "-mno-vsx"
1302 check_runtime_nocache vmx_hw_available {
1306 asm volatile ("vor v0,v0,v0");
1308 asm volatile ("vor 0,0,0");
1317 proc check_ppc_recip_hw_available { } {
1318 return [check_cached_effective_target ppc_recip_hw_available {
1319 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1320 # For now, disable on Darwin
1321 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1324 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1325 check_runtime_nocache ppc_recip_hw_available {
1326 volatile double d_recip, d_rsqrt, d_four = 4.0;
1327 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1330 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1331 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1332 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1333 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1341 # Return 1 if the target supports executing AltiVec and Cell PPU
1342 # instructions, 0 otherwise. Cache the result.
1344 proc check_effective_target_cell_hw { } {
1345 return [check_cached_effective_target cell_hw_available {
1346 # Some simulators are known to not support VMX and PPU instructions.
1347 if { [istarget powerpc-*-eabi*] } {
1350 # Most targets don't require special flags for this test
1351 # case, but Darwin and AIX do.
1352 if { [istarget *-*-darwin*]
1353 || [istarget *-*-aix*] } {
1354 set options "-maltivec -mcpu=cell"
1356 set options "-mcpu=cell"
1358 check_runtime_nocache cell_hw_available {
1362 asm volatile ("vor v0,v0,v0");
1363 asm volatile ("lvlx v0,r0,r0");
1365 asm volatile ("vor 0,0,0");
1366 asm volatile ("lvlx 0,0,0");
1375 # Return 1 if the target supports executing 64-bit instructions, 0
1376 # otherwise. Cache the result.
1378 proc check_effective_target_powerpc64 { } {
1379 global powerpc64_available_saved
1382 if [info exists powerpc64_available_saved] {
1383 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1385 set powerpc64_available_saved 0
1387 # Some simulators are known to not support powerpc64 instructions.
1388 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1389 verbose "check_effective_target_powerpc64 returning 0" 2
1390 return $powerpc64_available_saved
1393 # Set up, compile, and execute a test program containing a 64-bit
1394 # instruction. Include the current process ID in the file
1395 # names to prevent conflicts with invocations for multiple
1400 set f [open $src "w"]
1401 puts $f "int main() {"
1402 puts $f "#ifdef __MACH__"
1403 puts $f " asm volatile (\"extsw r0,r0\");"
1405 puts $f " asm volatile (\"extsw 0,0\");"
1407 puts $f " return 0; }"
1410 set opts "additional_flags=-mcpu=G5"
1412 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1413 set lines [${tool}_target_compile $src $exe executable "$opts"]
1416 if [string match "" $lines] then {
1417 # No error message, compilation succeeded.
1418 set result [${tool}_load "./$exe" "" ""]
1419 set status [lindex $result 0]
1420 remote_file build delete $exe
1421 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1423 if { $status == "pass" } then {
1424 set powerpc64_available_saved 1
1427 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1431 return $powerpc64_available_saved
1434 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1435 # complex float arguments. This affects gfortran tests that call cabsf
1436 # in libm built by an earlier compiler. Return 1 if libm uses the same
1437 # argument passing as the compiler under test, 0 otherwise.
1439 # When the target name changes, replace the cached result.
1441 proc check_effective_target_broken_cplxf_arg { } {
1442 return [check_cached_effective_target broken_cplxf_arg {
1443 # Skip the work for targets known not to be affected.
1444 if { ![istarget powerpc64-*-linux*] } {
1446 } elseif { ![is-effective-target lp64] } {
1449 check_runtime_nocache broken_cplxf_arg {
1450 #include <complex.h>
1451 extern void abort (void);
1452 float fabsf (float);
1453 float cabsf (_Complex float);
1460 if (fabsf (f - 5.0) > 0.0001)
1469 # Return 1 is this is a TI C6X target supporting C67X instructions
1470 proc check_effective_target_ti_c67x { } {
1471 return [check_no_compiler_messages ti_c67x assembly {
1472 #if !defined(_TMS320C6700)
1478 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1479 proc check_effective_target_ti_c64xp { } {
1480 return [check_no_compiler_messages ti_c64xp assembly {
1481 #if !defined(_TMS320C6400_PLUS)
1488 proc check_alpha_max_hw_available { } {
1489 return [check_runtime alpha_max_hw_available {
1490 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1494 # Returns true iff the FUNCTION is available on the target system.
1495 # (This is essentially a Tcl implementation of Autoconf's
1498 proc check_function_available { function } {
1499 return [check_no_compiler_messages ${function}_available \
1505 int main () { $function (); }
1509 # Returns true iff "fork" is available on the target system.
1511 proc check_fork_available {} {
1512 return [check_function_available "fork"]
1515 # Returns true iff "mkfifo" is available on the target system.
1517 proc check_mkfifo_available {} {
1518 if { [istarget *-*-cygwin*] } {
1519 # Cygwin has mkfifo, but support is incomplete.
1523 return [check_function_available "mkfifo"]
1526 # Returns true iff "__cxa_atexit" is used on the target system.
1528 proc check_cxa_atexit_available { } {
1529 return [check_cached_effective_target cxa_atexit_available {
1530 if { [istarget hppa*-*-hpux10*] } {
1531 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1533 } elseif { [istarget *-*-vxworks] } {
1534 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1537 check_runtime_nocache cxa_atexit_available {
1540 static unsigned int count;
1557 Y() { f(); count = 2; }
1566 int main() { return 0; }
1572 proc check_effective_target_objc2 { } {
1573 return [check_no_compiler_messages objc2 object {
1582 proc check_effective_target_next_runtime { } {
1583 return [check_no_compiler_messages objc2 object {
1584 #ifdef __NEXT_RUNTIME__
1592 # Return 1 if we're generating 32-bit code using default options, 0
1595 proc check_effective_target_ilp32 { } {
1596 return [check_no_compiler_messages ilp32 object {
1597 int dummy[sizeof (int) == 4
1598 && sizeof (void *) == 4
1599 && sizeof (long) == 4 ? 1 : -1];
1603 # Return 1 if we're generating ia32 code using default options, 0
1606 proc check_effective_target_ia32 { } {
1607 return [check_no_compiler_messages ia32 object {
1608 int dummy[sizeof (int) == 4
1609 && sizeof (void *) == 4
1610 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1614 # Return 1 if we're generating x32 code using default options, 0
1617 proc check_effective_target_x32 { } {
1618 return [check_no_compiler_messages x32 object {
1619 int dummy[sizeof (int) == 4
1620 && sizeof (void *) == 4
1621 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1625 # Return 1 if we're generating 32-bit or larger integers using default
1626 # options, 0 otherwise.
1628 proc check_effective_target_int32plus { } {
1629 return [check_no_compiler_messages int32plus object {
1630 int dummy[sizeof (int) >= 4 ? 1 : -1];
1634 # Return 1 if we're generating 32-bit or larger pointers using default
1635 # options, 0 otherwise.
1637 proc check_effective_target_ptr32plus { } {
1638 return [check_no_compiler_messages ptr32plus object {
1639 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1643 # Return 1 if we support 32-bit or larger array and structure sizes
1644 # using default options, 0 otherwise.
1646 proc check_effective_target_size32plus { } {
1647 return [check_no_compiler_messages size32plus object {
1652 # Returns 1 if we're generating 16-bit or smaller integers with the
1653 # default options, 0 otherwise.
1655 proc check_effective_target_int16 { } {
1656 return [check_no_compiler_messages int16 object {
1657 int dummy[sizeof (int) < 4 ? 1 : -1];
1661 # Return 1 if we're generating 64-bit code using default options, 0
1664 proc check_effective_target_lp64 { } {
1665 return [check_no_compiler_messages lp64 object {
1666 int dummy[sizeof (int) == 4
1667 && sizeof (void *) == 8
1668 && sizeof (long) == 8 ? 1 : -1];
1672 # Return 1 if we're generating 64-bit code using default llp64 options,
1675 proc check_effective_target_llp64 { } {
1676 return [check_no_compiler_messages llp64 object {
1677 int dummy[sizeof (int) == 4
1678 && sizeof (void *) == 8
1679 && sizeof (long long) == 8
1680 && sizeof (long) == 4 ? 1 : -1];
1684 # Return 1 if the target supports long double larger than double,
1687 proc check_effective_target_large_long_double { } {
1688 return [check_no_compiler_messages large_long_double object {
1689 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1693 # Return 1 if the target supports double larger than float,
1696 proc check_effective_target_large_double { } {
1697 return [check_no_compiler_messages large_double object {
1698 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1702 # Return 1 if the target supports double of 64 bits,
1705 proc check_effective_target_double64 { } {
1706 return [check_no_compiler_messages double64 object {
1707 int dummy[sizeof(double) == 8 ? 1 : -1];
1711 # Return 1 if the target supports double of at least 64 bits,
1714 proc check_effective_target_double64plus { } {
1715 return [check_no_compiler_messages double64plus object {
1716 int dummy[sizeof(double) >= 8 ? 1 : -1];
1720 # Return 1 if the target supports compiling fixed-point,
1723 proc check_effective_target_fixed_point { } {
1724 return [check_no_compiler_messages fixed_point object {
1725 _Sat _Fract x; _Sat _Accum y;
1729 # Return 1 if the target supports compiling decimal floating point,
1732 proc check_effective_target_dfp_nocache { } {
1733 verbose "check_effective_target_dfp_nocache: compiling source" 2
1734 set ret [check_no_compiler_messages_nocache dfp object {
1735 float x __attribute__((mode(DD)));
1737 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1741 proc check_effective_target_dfprt_nocache { } {
1742 return [check_runtime_nocache dfprt {
1743 typedef float d64 __attribute__((mode(DD)));
1744 d64 x = 1.2df, y = 2.3dd, z;
1745 int main () { z = x + y; return 0; }
1749 # Return 1 if the target supports compiling Decimal Floating Point,
1752 # This won't change for different subtargets so cache the result.
1754 proc check_effective_target_dfp { } {
1755 return [check_cached_effective_target dfp {
1756 check_effective_target_dfp_nocache
1760 # Return 1 if the target supports linking and executing Decimal Floating
1761 # Point, 0 otherwise.
1763 # This won't change for different subtargets so cache the result.
1765 proc check_effective_target_dfprt { } {
1766 return [check_cached_effective_target dfprt {
1767 check_effective_target_dfprt_nocache
1771 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1773 proc check_effective_target_ucn_nocache { } {
1774 # -std=c99 is only valid for C
1775 if [check_effective_target_c] {
1776 set ucnopts "-std=c99"
1778 append ucnopts " -fextended-identifiers"
1779 verbose "check_effective_target_ucn_nocache: compiling source" 2
1780 set ret [check_no_compiler_messages_nocache ucn object {
1783 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1787 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1789 # This won't change for different subtargets, so cache the result.
1791 proc check_effective_target_ucn { } {
1792 return [check_cached_effective_target ucn {
1793 check_effective_target_ucn_nocache
1797 # Return 1 if the target needs a command line argument to enable a SIMD
1800 proc check_effective_target_vect_cmdline_needed { } {
1801 global et_vect_cmdline_needed_saved
1802 global et_vect_cmdline_needed_target_name
1804 if { ![info exists et_vect_cmdline_needed_target_name] } {
1805 set et_vect_cmdline_needed_target_name ""
1808 # If the target has changed since we set the cached value, clear it.
1809 set current_target [current_target_name]
1810 if { $current_target != $et_vect_cmdline_needed_target_name } {
1811 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1812 set et_vect_cmdline_needed_target_name $current_target
1813 if { [info exists et_vect_cmdline_needed_saved] } {
1814 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1815 unset et_vect_cmdline_needed_saved
1819 if [info exists et_vect_cmdline_needed_saved] {
1820 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1822 set et_vect_cmdline_needed_saved 1
1823 if { [istarget alpha*-*-*]
1824 || [istarget ia64-*-*]
1825 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1826 && ([check_effective_target_x32]
1827 || [check_effective_target_lp64]))
1828 || ([istarget powerpc*-*-*]
1829 && ([check_effective_target_powerpc_spe]
1830 || [check_effective_target_powerpc_altivec]))
1831 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1832 || [istarget spu-*-*]
1833 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1834 set et_vect_cmdline_needed_saved 0
1838 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1839 return $et_vect_cmdline_needed_saved
1842 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1844 # This won't change for different subtargets so cache the result.
1846 proc check_effective_target_vect_int { } {
1847 global et_vect_int_saved
1849 if [info exists et_vect_int_saved] {
1850 verbose "check_effective_target_vect_int: using cached result" 2
1852 set et_vect_int_saved 0
1853 if { [istarget i?86-*-*]
1854 || ([istarget powerpc*-*-*]
1855 && ![istarget powerpc-*-linux*paired*])
1856 || [istarget spu-*-*]
1857 || [istarget x86_64-*-*]
1858 || [istarget sparc*-*-*]
1859 || [istarget alpha*-*-*]
1860 || [istarget ia64-*-*]
1861 || [check_effective_target_arm32]
1862 || ([istarget mips*-*-*]
1863 && [check_effective_target_mips_loongson]) } {
1864 set et_vect_int_saved 1
1868 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1869 return $et_vect_int_saved
1872 # Return 1 if the target supports signed int->float conversion
1875 proc check_effective_target_vect_intfloat_cvt { } {
1876 global et_vect_intfloat_cvt_saved
1878 if [info exists et_vect_intfloat_cvt_saved] {
1879 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1881 set et_vect_intfloat_cvt_saved 0
1882 if { [istarget i?86-*-*]
1883 || ([istarget powerpc*-*-*]
1884 && ![istarget powerpc-*-linux*paired*])
1885 || [istarget x86_64-*-*]
1886 || ([istarget arm*-*-*]
1887 && [check_effective_target_arm_neon_ok])} {
1888 set et_vect_intfloat_cvt_saved 1
1892 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1893 return $et_vect_intfloat_cvt_saved
1896 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1898 proc check_effective_target_int128 { } {
1899 return [check_no_compiler_messages int128 object {
1901 #ifndef __SIZEOF_INT128__
1910 # Return 1 if the target supports unsigned int->float conversion
1913 proc check_effective_target_vect_uintfloat_cvt { } {
1914 global et_vect_uintfloat_cvt_saved
1916 if [info exists et_vect_uintfloat_cvt_saved] {
1917 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1919 set et_vect_uintfloat_cvt_saved 0
1920 if { [istarget i?86-*-*]
1921 || ([istarget powerpc*-*-*]
1922 && ![istarget powerpc-*-linux*paired*])
1923 || [istarget x86_64-*-*]
1924 || ([istarget arm*-*-*]
1925 && [check_effective_target_arm_neon_ok])} {
1926 set et_vect_uintfloat_cvt_saved 1
1930 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1931 return $et_vect_uintfloat_cvt_saved
1935 # Return 1 if the target supports signed float->int conversion
1938 proc check_effective_target_vect_floatint_cvt { } {
1939 global et_vect_floatint_cvt_saved
1941 if [info exists et_vect_floatint_cvt_saved] {
1942 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1944 set et_vect_floatint_cvt_saved 0
1945 if { [istarget i?86-*-*]
1946 || ([istarget powerpc*-*-*]
1947 && ![istarget powerpc-*-linux*paired*])
1948 || [istarget x86_64-*-*]
1949 || ([istarget arm*-*-*]
1950 && [check_effective_target_arm_neon_ok])} {
1951 set et_vect_floatint_cvt_saved 1
1955 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1956 return $et_vect_floatint_cvt_saved
1959 # Return 1 if the target supports unsigned float->int conversion
1962 proc check_effective_target_vect_floatuint_cvt { } {
1963 global et_vect_floatuint_cvt_saved
1965 if [info exists et_vect_floatuint_cvt_saved] {
1966 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1968 set et_vect_floatuint_cvt_saved 0
1969 if { ([istarget powerpc*-*-*]
1970 && ![istarget powerpc-*-linux*paired*])
1971 || ([istarget arm*-*-*]
1972 && [check_effective_target_arm_neon_ok])} {
1973 set et_vect_floatuint_cvt_saved 1
1977 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1978 return $et_vect_floatuint_cvt_saved
1981 # Return 1 is this is an arm target using 32-bit instructions
1982 proc check_effective_target_arm32 { } {
1983 return [check_no_compiler_messages arm32 assembly {
1984 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1990 # Return 1 is this is an arm target not using Thumb
1991 proc check_effective_target_arm_nothumb { } {
1992 return [check_no_compiler_messages arm_nothumb assembly {
1993 #if (defined(__thumb__) || defined(__thumb2__))
1999 # Return 1 if this is a little-endian ARM target
2000 proc check_effective_target_arm_little_endian { } {
2001 return [check_no_compiler_messages arm_little_endian assembly {
2002 #if !defined(__arm__) || !defined(__ARMEL__)
2008 # Return 1 if this is an ARM target that only supports aligned vector accesses
2009 proc check_effective_target_arm_vect_no_misalign { } {
2010 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2011 #if !defined(__arm__) \
2012 || (defined(__ARMEL__) \
2013 && (!defined(__thumb__) || defined(__thumb2__)))
2020 # Return 1 if this is an ARM target supporting -mfpu=vfp
2021 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2024 proc check_effective_target_arm_vfp_ok { } {
2025 if { [check_effective_target_arm32] } {
2026 return [check_no_compiler_messages arm_vfp_ok object {
2028 } "-mfpu=vfp -mfloat-abi=softfp"]
2034 # Return 1 if this is an ARM target supporting -mfpu=vfp
2035 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2038 proc check_effective_target_arm_hard_vfp_ok { } {
2039 if { [check_effective_target_arm32] } {
2040 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2041 int main() { return 0;}
2042 } "-mfpu=vfp -mfloat-abi=hard"]
2048 # Return 1 if this is an ARM target that supports DSP multiply with
2049 # current multilib flags.
2051 proc check_effective_target_arm_dsp { } {
2052 return [check_no_compiler_messages arm_dsp assembly {
2053 #ifndef __ARM_FEATURE_DSP
2060 # Return 1 if this is an ARM target that supports unaligned word/halfword
2061 # load/store instructions.
2063 proc check_effective_target_arm_unaligned { } {
2064 return [check_no_compiler_messages arm_unaligned assembly {
2065 #ifndef __ARM_FEATURE_UNALIGNED
2066 #error no unaligned support
2072 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2073 # or -mfloat-abi=hard, but if one is already specified by the
2074 # multilib, use it. Similarly, if a -mfpu option already enables
2075 # NEON, do not add -mfpu=neon.
2077 proc add_options_for_arm_neon { flags } {
2078 if { ! [check_effective_target_arm_neon_ok] } {
2081 global et_arm_neon_flags
2082 return "$flags $et_arm_neon_flags"
2085 # Return 1 if this is an ARM target supporting -mfpu=neon
2086 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2087 # incompatible with these options. Also set et_arm_neon_flags to the
2088 # best options to add.
2090 proc check_effective_target_arm_neon_ok_nocache { } {
2091 global et_arm_neon_flags
2092 set et_arm_neon_flags ""
2093 if { [check_effective_target_arm32] } {
2094 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2095 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2096 #include "arm_neon.h"
2099 set et_arm_neon_flags $flags
2108 proc check_effective_target_arm_neon_ok { } {
2109 return [check_cached_effective_target arm_neon_ok \
2110 check_effective_target_arm_neon_ok_nocache]
2113 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2114 # or -mfloat-abi=hard, but if one is already specified by the
2117 proc add_options_for_arm_fp16 { flags } {
2118 if { ! [check_effective_target_arm_fp16_ok] } {
2121 global et_arm_fp16_flags
2122 return "$flags $et_arm_fp16_flags"
2125 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2126 # Skip multilibs that are incompatible with these options and set
2127 # et_arm_fp16_flags to the best options to add.
2129 proc check_effective_target_arm_fp16_ok_nocache { } {
2130 global et_arm_fp16_flags
2131 set et_arm_fp16_flags ""
2132 if { ! [check_effective_target_arm32] } {
2135 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2136 # Multilib flags would override -mfpu.
2139 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2140 # Must generate floating-point instructions.
2143 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2144 # The existing -mfpu value is OK; use it, but add softfp.
2145 set et_arm_fp16_flags "-mfloat-abi=softfp"
2148 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2149 # macro to check for this support.
2150 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2151 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2154 set et_arm_fp16_flags "$flags"
2161 proc check_effective_target_arm_fp16_ok { } {
2162 return [check_cached_effective_target arm_fp16_ok \
2163 check_effective_target_arm_fp16_ok_nocache]
2166 # Creates a series of routines that return 1 if the given architecture
2167 # can be selected and a routine to give the flags to select that architecture
2168 # Note: Extra flags may be added to disable options from newer compilers
2169 # (Thumb in particular - but others may be added in the future)
2170 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2171 # /* { dg-add-options arm_arch_v5 } */
2172 foreach { armfunc armflag armdef } { v5 "-march=armv5 -marm" __ARM_ARCH_5__
2173 v6 "-march=armv6" __ARM_ARCH_6__
2174 v6k "-march=armv6k" __ARM_ARCH_6K__
2175 v7a "-march=armv7-a" __ARM_ARCH_7A__ } {
2176 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2177 proc check_effective_target_arm_arch_FUNC_ok { } {
2178 if { [ string match "*-marm*" "FLAG" ] &&
2179 ![check_effective_target_arm_arm_ok] } {
2182 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2189 proc add_options_for_arm_arch_FUNC { flags } {
2190 return "$flags FLAG"
2195 # Return 1 if this is an ARM target where -marm causes ARM to be
2198 proc check_effective_target_arm_arm_ok { } {
2199 return [check_no_compiler_messages arm_arm_ok assembly {
2200 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2207 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2210 proc check_effective_target_arm_thumb1_ok { } {
2211 return [check_no_compiler_messages arm_thumb1_ok assembly {
2212 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2218 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2221 proc check_effective_target_arm_thumb2_ok { } {
2222 return [check_no_compiler_messages arm_thumb2_ok assembly {
2223 #if !defined(__thumb2__)
2229 # Return 1 if this is an ARM target where Thumb-1 is used without options
2230 # added by the test.
2232 proc check_effective_target_arm_thumb1 { } {
2233 return [check_no_compiler_messages arm_thumb1 assembly {
2234 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2241 # Return 1 if this is an ARM target where Thumb-2 is used without options
2242 # added by the test.
2244 proc check_effective_target_arm_thumb2 { } {
2245 return [check_no_compiler_messages arm_thumb2 assembly {
2246 #if !defined(__thumb2__)
2253 # Return 1 if this is an ARM cortex-M profile cpu
2255 proc check_effective_target_arm_cortex_m { } {
2256 return [check_no_compiler_messages arm_cortex_m assembly {
2257 #if !defined(__ARM_ARCH_7M__) \
2258 && !defined (__ARM_ARCH_7EM__) \
2259 && !defined (__ARM_ARCH_6M__)
2266 # Return 1 if the target supports executing NEON instructions, 0
2267 # otherwise. Cache the result.
2269 proc check_effective_target_arm_neon_hw { } {
2270 return [check_runtime arm_neon_hw_available {
2274 long long a = 0, b = 1;
2275 asm ("vorr %P0, %P1, %P2"
2277 : "0" (a), "w" (b));
2280 } [add_options_for_arm_neon ""]]
2283 # Return 1 if this is a ARM target with NEON enabled.
2285 proc check_effective_target_arm_neon { } {
2286 if { [check_effective_target_arm32] } {
2287 return [check_no_compiler_messages arm_neon object {
2288 #ifndef __ARM_NEON__
2299 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2300 # the Loongson vector modes.
2302 proc check_effective_target_mips_loongson { } {
2303 return [check_no_compiler_messages loongson assembly {
2304 #if !defined(__mips_loongson_vector_rev)
2310 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2313 proc check_effective_target_arm_eabi { } {
2314 return [check_no_compiler_messages arm_eabi object {
2315 #ifndef __ARM_EABI__
2323 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2324 # Some multilibs may be incompatible with this option.
2326 proc check_effective_target_arm_iwmmxt_ok { } {
2327 if { [check_effective_target_arm32] } {
2328 return [check_no_compiler_messages arm_iwmmxt_ok object {
2336 # Return 1 if this is a PowerPC target with floating-point registers.
2338 proc check_effective_target_powerpc_fprs { } {
2339 if { [istarget powerpc*-*-*]
2340 || [istarget rs6000-*-*] } {
2341 return [check_no_compiler_messages powerpc_fprs object {
2353 # Return 1 if this is a PowerPC target with hardware double-precision
2356 proc check_effective_target_powerpc_hard_double { } {
2357 if { [istarget powerpc*-*-*]
2358 || [istarget rs6000-*-*] } {
2359 return [check_no_compiler_messages powerpc_hard_double object {
2371 # Return 1 if this is a PowerPC target supporting -maltivec.
2373 proc check_effective_target_powerpc_altivec_ok { } {
2374 if { ([istarget powerpc*-*-*]
2375 && ![istarget powerpc-*-linux*paired*])
2376 || [istarget rs6000-*-*] } {
2377 # AltiVec is not supported on AIX before 5.3.
2378 if { [istarget powerpc*-*-aix4*]
2379 || [istarget powerpc*-*-aix5.1*]
2380 || [istarget powerpc*-*-aix5.2*] } {
2383 return [check_no_compiler_messages powerpc_altivec_ok object {
2391 # Return 1 if this is a PowerPC target supporting -mvsx
2393 proc check_effective_target_powerpc_vsx_ok { } {
2394 if { ([istarget powerpc*-*-*]
2395 && ![istarget powerpc-*-linux*paired*])
2396 || [istarget rs6000-*-*] } {
2397 # AltiVec is not supported on AIX before 5.3.
2398 if { [istarget powerpc*-*-aix4*]
2399 || [istarget powerpc*-*-aix5.1*]
2400 || [istarget powerpc*-*-aix5.2*] } {
2403 return [check_no_compiler_messages powerpc_vsx_ok object {
2406 asm volatile ("xxlor vs0,vs0,vs0");
2408 asm volatile ("xxlor 0,0,0");
2418 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2420 proc check_effective_target_powerpc_ppu_ok { } {
2421 if [check_effective_target_powerpc_altivec_ok] {
2422 return [check_no_compiler_messages cell_asm_available object {
2425 asm volatile ("lvlx v0,v0,v0");
2427 asm volatile ("lvlx 0,0,0");
2437 # Return 1 if this is a PowerPC target that supports SPU.
2439 proc check_effective_target_powerpc_spu { } {
2440 if { [istarget powerpc*-*-linux*] } {
2441 return [check_effective_target_powerpc_altivec_ok]
2447 # Return 1 if this is a PowerPC SPE target. The check includes options
2448 # specified by dg-options for this test, so don't cache the result.
2450 proc check_effective_target_powerpc_spe_nocache { } {
2451 if { [istarget powerpc*-*-*] } {
2452 return [check_no_compiler_messages_nocache powerpc_spe object {
2458 } [current_compiler_flags]]
2464 # Return 1 if this is a PowerPC target with SPE enabled.
2466 proc check_effective_target_powerpc_spe { } {
2467 if { [istarget powerpc*-*-*] } {
2468 return [check_no_compiler_messages powerpc_spe object {
2480 # Return 1 if this is a PowerPC target with Altivec enabled.
2482 proc check_effective_target_powerpc_altivec { } {
2483 if { [istarget powerpc*-*-*] } {
2484 return [check_no_compiler_messages powerpc_altivec object {
2496 # Return 1 if this is a PowerPC 405 target. The check includes options
2497 # specified by dg-options for this test, so don't cache the result.
2499 proc check_effective_target_powerpc_405_nocache { } {
2500 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2501 return [check_no_compiler_messages_nocache powerpc_405 object {
2507 } [current_compiler_flags]]
2513 # Return 1 if this is a SPU target with a toolchain that
2514 # supports automatic overlay generation.
2516 proc check_effective_target_spu_auto_overlay { } {
2517 if { [istarget spu*-*-elf*] } {
2518 return [check_no_compiler_messages spu_auto_overlay executable {
2520 } "-Wl,--auto-overlay" ]
2526 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2527 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2528 # test environment appears to run executables on such a simulator.
2530 proc check_effective_target_ultrasparc_hw { } {
2531 return [check_runtime ultrasparc_hw {
2532 int main() { return 0; }
2533 } "-mcpu=ultrasparc"]
2536 # Return 1 if the test environment supports executing UltraSPARC VIS2
2537 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
2539 proc check_effective_target_ultrasparc_vis2_hw { } {
2540 return [check_runtime ultrasparc_vis2_hw {
2541 int main() { __asm__(".word 0x81b00320"); return 0; }
2542 } "-mcpu=ultrasparc3"]
2545 # Return 1 if the test environment supports executing UltraSPARC VIS3
2546 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
2548 proc check_effective_target_ultrasparc_vis3_hw { } {
2549 return [check_runtime ultrasparc_vis3_hw {
2550 int main() { __asm__(".word 0x81b00220"); return 0; }
2554 # Return 1 if this is a Sparc target with VIS enabled.
2556 proc check_effective_target_sparc_vis { } {
2557 if { [istarget sparc*-*-*] } {
2558 return [check_no_compiler_messages sparc_vis object {
2570 # Return 1 if the target supports hardware vector shift operation.
2572 proc check_effective_target_vect_shift { } {
2573 global et_vect_shift_saved
2575 if [info exists et_vect_shift_saved] {
2576 verbose "check_effective_target_vect_shift: using cached result" 2
2578 set et_vect_shift_saved 0
2579 if { ([istarget powerpc*-*-*]
2580 && ![istarget powerpc-*-linux*paired*])
2581 || [istarget ia64-*-*]
2582 || [istarget i?86-*-*]
2583 || [istarget x86_64-*-*]
2584 || [check_effective_target_arm32]
2585 || ([istarget mips*-*-*]
2586 && [check_effective_target_mips_loongson]) } {
2587 set et_vect_shift_saved 1
2591 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2592 return $et_vect_shift_saved
2595 # Return 1 if the target supports hardware vector shift operation for char.
2597 proc check_effective_target_vect_shift_char { } {
2598 global et_vect_shift_char_saved
2600 if [info exists et_vect_shift_char_saved] {
2601 verbose "check_effective_target_vect_shift_char: using cached result" 2
2603 set et_vect_shift_char_saved 0
2604 if { ([istarget powerpc*-*-*]
2605 && ![istarget powerpc-*-linux*paired*])
2606 || [check_effective_target_arm32] } {
2607 set et_vect_shift_char_saved 1
2611 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2612 return $et_vect_shift_char_saved
2615 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2617 # This can change for different subtargets so do not cache the result.
2619 proc check_effective_target_vect_long { } {
2620 if { [istarget i?86-*-*]
2621 || (([istarget powerpc*-*-*]
2622 && ![istarget powerpc-*-linux*paired*])
2623 && [check_effective_target_ilp32])
2624 || [istarget x86_64-*-*]
2625 || [check_effective_target_arm32]
2626 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2632 verbose "check_effective_target_vect_long: returning $answer" 2
2636 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2638 # This won't change for different subtargets so cache the result.
2640 proc check_effective_target_vect_float { } {
2641 global et_vect_float_saved
2643 if [info exists et_vect_float_saved] {
2644 verbose "check_effective_target_vect_float: using cached result" 2
2646 set et_vect_float_saved 0
2647 if { [istarget i?86-*-*]
2648 || [istarget powerpc*-*-*]
2649 || [istarget spu-*-*]
2650 || [istarget mipsisa64*-*-*]
2651 || [istarget x86_64-*-*]
2652 || [istarget ia64-*-*]
2653 || [check_effective_target_arm32] } {
2654 set et_vect_float_saved 1
2658 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2659 return $et_vect_float_saved
2662 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2664 # This won't change for different subtargets so cache the result.
2666 proc check_effective_target_vect_double { } {
2667 global et_vect_double_saved
2669 if [info exists et_vect_double_saved] {
2670 verbose "check_effective_target_vect_double: using cached result" 2
2672 set et_vect_double_saved 0
2673 if { [istarget i?86-*-*]
2674 || [istarget x86_64-*-*] } {
2675 if { [check_no_compiler_messages vect_double assembly {
2676 #ifdef __tune_atom__
2677 # error No double vectorizer support.
2680 set et_vect_double_saved 1
2682 set et_vect_double_saved 0
2684 } elseif { [istarget spu-*-*] } {
2685 set et_vect_double_saved 1
2689 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2690 return $et_vect_double_saved
2693 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2695 # This won't change for different subtargets so cache the result.
2697 proc check_effective_target_vect_long_long { } {
2698 global et_vect_long_long_saved
2700 if [info exists et_vect_long_long_saved] {
2701 verbose "check_effective_target_vect_long_long: using cached result" 2
2703 set et_vect_long_long_saved 0
2704 if { [istarget i?86-*-*]
2705 || [istarget x86_64-*-*] } {
2706 set et_vect_long_long_saved 1
2710 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2711 return $et_vect_long_long_saved
2715 # Return 1 if the target plus current options does not support a vector
2716 # max instruction on "int", 0 otherwise.
2718 # This won't change for different subtargets so cache the result.
2720 proc check_effective_target_vect_no_int_max { } {
2721 global et_vect_no_int_max_saved
2723 if [info exists et_vect_no_int_max_saved] {
2724 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2726 set et_vect_no_int_max_saved 0
2727 if { [istarget sparc*-*-*]
2728 || [istarget spu-*-*]
2729 || [istarget alpha*-*-*]
2730 || ([istarget mips*-*-*]
2731 && [check_effective_target_mips_loongson]) } {
2732 set et_vect_no_int_max_saved 1
2735 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2736 return $et_vect_no_int_max_saved
2739 # Return 1 if the target plus current options does not support a vector
2740 # add instruction on "int", 0 otherwise.
2742 # This won't change for different subtargets so cache the result.
2744 proc check_effective_target_vect_no_int_add { } {
2745 global et_vect_no_int_add_saved
2747 if [info exists et_vect_no_int_add_saved] {
2748 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2750 set et_vect_no_int_add_saved 0
2751 # Alpha only supports vector add on V8QI and V4HI.
2752 if { [istarget alpha*-*-*] } {
2753 set et_vect_no_int_add_saved 1
2756 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2757 return $et_vect_no_int_add_saved
2760 # Return 1 if the target plus current options does not support vector
2761 # bitwise instructions, 0 otherwise.
2763 # This won't change for different subtargets so cache the result.
2765 proc check_effective_target_vect_no_bitwise { } {
2766 global et_vect_no_bitwise_saved
2768 if [info exists et_vect_no_bitwise_saved] {
2769 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2771 set et_vect_no_bitwise_saved 0
2773 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2774 return $et_vect_no_bitwise_saved
2777 # Return 1 if the target plus current options supports vector permutation,
2780 # This won't change for different subtargets so cache the result.
2782 proc check_effective_target_vect_perm { } {
2785 if [info exists et_vect_perm_saved] {
2786 verbose "check_effective_target_vect_perm: using cached result" 2
2788 set et_vect_perm_saved 0
2789 if { [is-effective-target arm_neon_ok]
2790 || [istarget powerpc*-*-*]
2791 || [istarget spu-*-*]
2792 || [istarget i?86-*-*]
2793 || [istarget x86_64-*-*]
2794 || ([istarget mips*-*-*]
2795 && [check_effective_target_mpaired_single]) } {
2796 set et_vect_perm_saved 1
2799 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2800 return $et_vect_perm_saved
2803 # Return 1 if the target plus current options supports vector permutation
2804 # on byte-sized elements, 0 otherwise.
2806 # This won't change for different subtargets so cache the result.
2808 proc check_effective_target_vect_perm_byte { } {
2809 global et_vect_perm_byte
2811 if [info exists et_vect_perm_byte_saved] {
2812 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2814 set et_vect_perm_byte_saved 0
2815 if { [is-effective-target arm_neon_ok]
2816 || [istarget powerpc*-*-*]
2817 || [istarget spu-*-*] } {
2818 set et_vect_perm_byte_saved 1
2821 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2822 return $et_vect_perm_byte_saved
2825 # Return 1 if the target plus current options supports vector permutation
2826 # on short-sized elements, 0 otherwise.
2828 # This won't change for different subtargets so cache the result.
2830 proc check_effective_target_vect_perm_short { } {
2831 global et_vect_perm_short
2833 if [info exists et_vect_perm_short_saved] {
2834 verbose "check_effective_target_vect_perm_short: using cached result" 2
2836 set et_vect_perm_short_saved 0
2837 if { [is-effective-target arm_neon_ok]
2838 || [istarget powerpc*-*-*]
2839 || [istarget spu-*-*] } {
2840 set et_vect_perm_short_saved 1
2843 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2844 return $et_vect_perm_short_saved
2847 # Return 1 if the target plus current options supports a vector
2848 # widening summation of *short* args into *int* result, 0 otherwise.
2850 # This won't change for different subtargets so cache the result.
2852 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2853 global et_vect_widen_sum_hi_to_si_pattern
2855 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2856 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2858 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2859 if { [istarget powerpc*-*-*]
2860 || [istarget ia64-*-*] } {
2861 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2864 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2865 return $et_vect_widen_sum_hi_to_si_pattern_saved
2868 # Return 1 if the target plus current options supports a vector
2869 # widening summation of *short* args into *int* result, 0 otherwise.
2870 # A target can also support this widening summation if it can support
2871 # promotion (unpacking) from shorts to ints.
2873 # This won't change for different subtargets so cache the result.
2875 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2876 global et_vect_widen_sum_hi_to_si
2878 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2879 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2881 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2882 if { [istarget powerpc*-*-*]
2883 || [istarget ia64-*-*] } {
2884 set et_vect_widen_sum_hi_to_si_saved 1
2887 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2888 return $et_vect_widen_sum_hi_to_si_saved
2891 # Return 1 if the target plus current options supports a vector
2892 # widening summation of *char* args into *short* result, 0 otherwise.
2893 # A target can also support this widening summation if it can support
2894 # promotion (unpacking) from chars to shorts.
2896 # This won't change for different subtargets so cache the result.
2898 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2899 global et_vect_widen_sum_qi_to_hi
2901 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2902 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2904 set et_vect_widen_sum_qi_to_hi_saved 0
2905 if { [check_effective_target_vect_unpack]
2906 || [istarget ia64-*-*] } {
2907 set et_vect_widen_sum_qi_to_hi_saved 1
2910 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2911 return $et_vect_widen_sum_qi_to_hi_saved
2914 # Return 1 if the target plus current options supports a vector
2915 # widening summation of *char* args into *int* result, 0 otherwise.
2917 # This won't change for different subtargets so cache the result.
2919 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2920 global et_vect_widen_sum_qi_to_si
2922 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2923 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2925 set et_vect_widen_sum_qi_to_si_saved 0
2926 if { [istarget powerpc*-*-*] } {
2927 set et_vect_widen_sum_qi_to_si_saved 1
2930 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2931 return $et_vect_widen_sum_qi_to_si_saved
2934 # Return 1 if the target plus current options supports a vector
2935 # widening multiplication of *char* args into *short* result, 0 otherwise.
2936 # A target can also support this widening multplication if it can support
2937 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2938 # multiplication of shorts).
2940 # This won't change for different subtargets so cache the result.
2943 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2944 global et_vect_widen_mult_qi_to_hi
2946 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2947 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2949 if { [check_effective_target_vect_unpack]
2950 && [check_effective_target_vect_short_mult] } {
2951 set et_vect_widen_mult_qi_to_hi_saved 1
2953 set et_vect_widen_mult_qi_to_hi_saved 0
2955 if { [istarget powerpc*-*-*]
2956 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2957 set et_vect_widen_mult_qi_to_hi_saved 1
2960 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2961 return $et_vect_widen_mult_qi_to_hi_saved
2964 # Return 1 if the target plus current options supports a vector
2965 # widening multiplication of *short* args into *int* result, 0 otherwise.
2966 # A target can also support this widening multplication if it can support
2967 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2968 # multiplication of ints).
2970 # This won't change for different subtargets so cache the result.
2973 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2974 global et_vect_widen_mult_hi_to_si
2976 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2977 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2979 if { [check_effective_target_vect_unpack]
2980 && [check_effective_target_vect_int_mult] } {
2981 set et_vect_widen_mult_hi_to_si_saved 1
2983 set et_vect_widen_mult_hi_to_si_saved 0
2985 if { [istarget powerpc*-*-*]
2986 || [istarget spu-*-*]
2987 || [istarget ia64-*-*]
2988 || [istarget i?86-*-*]
2989 || [istarget x86_64-*-*]
2990 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2991 set et_vect_widen_mult_hi_to_si_saved 1
2994 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2995 return $et_vect_widen_mult_hi_to_si_saved
2998 # Return 1 if the target plus current options supports a vector
2999 # widening multiplication of *char* args into *short* result, 0 otherwise.
3001 # This won't change for different subtargets so cache the result.
3003 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3004 global et_vect_widen_mult_qi_to_hi_pattern
3006 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3007 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3009 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3010 if { [istarget powerpc*-*-*]
3011 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3012 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3015 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3016 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3019 # Return 1 if the target plus current options supports a vector
3020 # widening multiplication of *short* args into *int* result, 0 otherwise.
3022 # This won't change for different subtargets so cache the result.
3024 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3025 global et_vect_widen_mult_hi_to_si_pattern
3027 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3028 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3030 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3031 if { [istarget powerpc*-*-*]
3032 || [istarget spu-*-*]
3033 || [istarget ia64-*-*]
3034 || [istarget i?86-*-*]
3035 || [istarget x86_64-*-*]
3036 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3037 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3040 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3041 return $et_vect_widen_mult_hi_to_si_pattern_saved
3044 # Return 1 if the target plus current options supports a vector
3045 # widening shift, 0 otherwise.
3047 # This won't change for different subtargets so cache the result.
3049 proc check_effective_target_vect_widen_shift { } {
3050 global et_vect_widen_shift_saved
3052 if [info exists et_vect_shift_saved] {
3053 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3055 set et_vect_widen_shift_saved 0
3056 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3057 set et_vect_widen_shift_saved 1
3060 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3061 return $et_vect_widen_shift_saved
3064 # Return 1 if the target plus current options supports a vector
3065 # dot-product of signed chars, 0 otherwise.
3067 # This won't change for different subtargets so cache the result.
3069 proc check_effective_target_vect_sdot_qi { } {
3070 global et_vect_sdot_qi
3072 if [info exists et_vect_sdot_qi_saved] {
3073 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3075 set et_vect_sdot_qi_saved 0
3076 if { [istarget ia64-*-*] } {
3077 set et_vect_udot_qi_saved 1
3080 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3081 return $et_vect_sdot_qi_saved
3084 # Return 1 if the target plus current options supports a vector
3085 # dot-product of unsigned chars, 0 otherwise.
3087 # This won't change for different subtargets so cache the result.
3089 proc check_effective_target_vect_udot_qi { } {
3090 global et_vect_udot_qi
3092 if [info exists et_vect_udot_qi_saved] {
3093 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3095 set et_vect_udot_qi_saved 0
3096 if { [istarget powerpc*-*-*]
3097 || [istarget ia64-*-*] } {
3098 set et_vect_udot_qi_saved 1
3101 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3102 return $et_vect_udot_qi_saved
3105 # Return 1 if the target plus current options supports a vector
3106 # dot-product of signed shorts, 0 otherwise.
3108 # This won't change for different subtargets so cache the result.
3110 proc check_effective_target_vect_sdot_hi { } {
3111 global et_vect_sdot_hi
3113 if [info exists et_vect_sdot_hi_saved] {
3114 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3116 set et_vect_sdot_hi_saved 0
3117 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3118 || [istarget ia64-*-*]
3119 || [istarget i?86-*-*]
3120 || [istarget x86_64-*-*] } {
3121 set et_vect_sdot_hi_saved 1
3124 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3125 return $et_vect_sdot_hi_saved
3128 # Return 1 if the target plus current options supports a vector
3129 # dot-product of unsigned shorts, 0 otherwise.
3131 # This won't change for different subtargets so cache the result.
3133 proc check_effective_target_vect_udot_hi { } {
3134 global et_vect_udot_hi
3136 if [info exists et_vect_udot_hi_saved] {
3137 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3139 set et_vect_udot_hi_saved 0
3140 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3141 set et_vect_udot_hi_saved 1
3144 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3145 return $et_vect_udot_hi_saved
3149 # Return 1 if the target plus current options supports a vector
3150 # demotion (packing) of shorts (to chars) and ints (to shorts)
3151 # using modulo arithmetic, 0 otherwise.
3153 # This won't change for different subtargets so cache the result.
3155 proc check_effective_target_vect_pack_trunc { } {
3156 global et_vect_pack_trunc
3158 if [info exists et_vect_pack_trunc_saved] {
3159 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3161 set et_vect_pack_trunc_saved 0
3162 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3163 || [istarget i?86-*-*]
3164 || [istarget x86_64-*-*]
3165 || [istarget spu-*-*]
3166 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3167 && [check_effective_target_arm_little_endian]) } {
3168 set et_vect_pack_trunc_saved 1
3171 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3172 return $et_vect_pack_trunc_saved
3175 # Return 1 if the target plus current options supports a vector
3176 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3178 # This won't change for different subtargets so cache the result.
3180 proc check_effective_target_vect_unpack { } {
3181 global et_vect_unpack
3183 if [info exists et_vect_unpack_saved] {
3184 verbose "check_effective_target_vect_unpack: using cached result" 2
3186 set et_vect_unpack_saved 0
3187 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3188 || [istarget i?86-*-*]
3189 || [istarget x86_64-*-*]
3190 || [istarget spu-*-*]
3191 || [istarget ia64-*-*]
3192 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]
3193 && [check_effective_target_arm_little_endian]) } {
3194 set et_vect_unpack_saved 1
3197 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3198 return $et_vect_unpack_saved
3201 # Return 1 if the target plus current options does not guarantee
3202 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3204 # This won't change for different subtargets so cache the result.
3206 proc check_effective_target_unaligned_stack { } {
3207 global et_unaligned_stack_saved
3209 if [info exists et_unaligned_stack_saved] {
3210 verbose "check_effective_target_unaligned_stack: using cached result" 2
3212 set et_unaligned_stack_saved 0
3214 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3215 return $et_unaligned_stack_saved
3218 # Return 1 if the target plus current options does not support a vector
3219 # alignment mechanism, 0 otherwise.
3221 # This won't change for different subtargets so cache the result.
3223 proc check_effective_target_vect_no_align { } {
3224 global et_vect_no_align_saved
3226 if [info exists et_vect_no_align_saved] {
3227 verbose "check_effective_target_vect_no_align: using cached result" 2
3229 set et_vect_no_align_saved 0
3230 if { [istarget mipsisa64*-*-*]
3231 || [istarget sparc*-*-*]
3232 || [istarget ia64-*-*]
3233 || [check_effective_target_arm_vect_no_misalign]
3234 || ([istarget mips*-*-*]
3235 && [check_effective_target_mips_loongson]) } {
3236 set et_vect_no_align_saved 1
3239 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3240 return $et_vect_no_align_saved
3243 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3245 # This won't change for different subtargets so cache the result.
3247 proc check_effective_target_vect_hw_misalign { } {
3248 global et_vect_hw_misalign_saved
3250 if [info exists et_vect_hw_misalign_saved] {
3251 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3253 set et_vect_hw_misalign_saved 0
3254 if { ([istarget x86_64-*-*]
3255 || [istarget i?86-*-*]) } {
3256 set et_vect_hw_misalign_saved 1
3259 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3260 return $et_vect_hw_misalign_saved
3264 # Return 1 if arrays are aligned to the vector alignment
3265 # boundary, 0 otherwise.
3267 # This won't change for different subtargets so cache the result.
3269 proc check_effective_target_vect_aligned_arrays { } {
3270 global et_vect_aligned_arrays
3272 if [info exists et_vect_aligned_arrays_saved] {
3273 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3275 set et_vect_aligned_arrays_saved 0
3276 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3277 if { ([is-effective-target lp64]
3278 && ( ![check_avx_available]
3279 || [check_prefer_avx128])) } {
3280 set et_vect_aligned_arrays_saved 1
3283 if [istarget spu-*-*] {
3284 set et_vect_aligned_arrays_saved 1
3287 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3288 return $et_vect_aligned_arrays_saved
3291 # Return 1 if types of size 32 bit or less are naturally aligned
3292 # (aligned to their type-size), 0 otherwise.
3294 # This won't change for different subtargets so cache the result.
3296 proc check_effective_target_natural_alignment_32 { } {
3297 global et_natural_alignment_32
3299 if [info exists et_natural_alignment_32_saved] {
3300 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3302 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3303 set et_natural_alignment_32_saved 1
3304 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3305 set et_natural_alignment_32_saved 0
3308 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3309 return $et_natural_alignment_32_saved
3312 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3313 # type-size), 0 otherwise.
3315 # This won't change for different subtargets so cache the result.
3317 proc check_effective_target_natural_alignment_64 { } {
3318 global et_natural_alignment_64
3320 if [info exists et_natural_alignment_64_saved] {
3321 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3323 set et_natural_alignment_64_saved 0
3324 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3325 || [istarget spu-*-*] } {
3326 set et_natural_alignment_64_saved 1
3329 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3330 return $et_natural_alignment_64_saved
3333 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3335 # This won't change for different subtargets so cache the result.
3337 proc check_effective_target_vector_alignment_reachable { } {
3338 global et_vector_alignment_reachable
3340 if [info exists et_vector_alignment_reachable_saved] {
3341 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3343 if { [check_effective_target_vect_aligned_arrays]
3344 || [check_effective_target_natural_alignment_32] } {
3345 set et_vector_alignment_reachable_saved 1
3347 set et_vector_alignment_reachable_saved 0
3350 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3351 return $et_vector_alignment_reachable_saved
3354 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3356 # This won't change for different subtargets so cache the result.
3358 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3359 global et_vector_alignment_reachable_for_64bit
3361 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3362 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3364 if { [check_effective_target_vect_aligned_arrays]
3365 || [check_effective_target_natural_alignment_64] } {
3366 set et_vector_alignment_reachable_for_64bit_saved 1
3368 set et_vector_alignment_reachable_for_64bit_saved 0
3371 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3372 return $et_vector_alignment_reachable_for_64bit_saved
3375 # Return 1 if the target only requires element alignment for vector accesses
3377 proc check_effective_target_vect_element_align { } {
3378 global et_vect_element_align
3380 if [info exists et_vect_element_align] {
3381 verbose "check_effective_target_vect_element_align: using cached result" 2
3383 set et_vect_element_align 0
3384 if { ([istarget arm*-*-*]
3385 && ![check_effective_target_arm_vect_no_misalign])
3386 || [check_effective_target_vect_hw_misalign] } {
3387 set et_vect_element_align 1
3391 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3392 return $et_vect_element_align
3395 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3397 proc check_effective_target_vect_condition { } {
3398 global et_vect_cond_saved
3400 if [info exists et_vect_cond_saved] {
3401 verbose "check_effective_target_vect_cond: using cached result" 2
3403 set et_vect_cond_saved 0
3404 if { [istarget powerpc*-*-*]
3405 || [istarget ia64-*-*]
3406 || [istarget i?86-*-*]
3407 || [istarget spu-*-*]
3408 || [istarget x86_64-*-*]
3409 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3410 set et_vect_cond_saved 1
3414 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3415 return $et_vect_cond_saved
3418 # Return 1 if the target supports vector conditional operations where
3419 # the comparison has different type from the lhs, 0 otherwise.
3421 proc check_effective_target_vect_cond_mixed { } {
3422 global et_vect_cond_mixed_saved
3424 if [info exists et_vect_cond_mixed_saved] {
3425 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3427 set et_vect_cond_mixed_saved 0
3428 if { [istarget i?86-*-*]
3429 || [istarget x86_64-*-*]
3430 || [istarget powerpc*-*-*] } {
3431 set et_vect_cond_mixed_saved 1
3435 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3436 return $et_vect_cond_mixed_saved
3439 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3441 proc check_effective_target_vect_char_mult { } {
3442 global et_vect_char_mult_saved
3444 if [info exists et_vect_char_mult_saved] {
3445 verbose "check_effective_target_vect_char_mult: using cached result" 2
3447 set et_vect_char_mult_saved 0
3448 if { [istarget ia64-*-*]
3449 || [istarget i?86-*-*]
3450 || [istarget x86_64-*-*] } {
3451 set et_vect_char_mult_saved 1
3455 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3456 return $et_vect_char_mult_saved
3459 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3461 proc check_effective_target_vect_short_mult { } {
3462 global et_vect_short_mult_saved
3464 if [info exists et_vect_short_mult_saved] {
3465 verbose "check_effective_target_vect_short_mult: using cached result" 2
3467 set et_vect_short_mult_saved 0
3468 if { [istarget ia64-*-*]
3469 || [istarget spu-*-*]
3470 || [istarget i?86-*-*]
3471 || [istarget x86_64-*-*]
3472 || [istarget powerpc*-*-*]
3473 || [check_effective_target_arm32]
3474 || ([istarget mips*-*-*]
3475 && [check_effective_target_mips_loongson]) } {
3476 set et_vect_short_mult_saved 1
3480 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3481 return $et_vect_short_mult_saved
3484 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3486 proc check_effective_target_vect_int_mult { } {
3487 global et_vect_int_mult_saved
3489 if [info exists et_vect_int_mult_saved] {
3490 verbose "check_effective_target_vect_int_mult: using cached result" 2
3492 set et_vect_int_mult_saved 0
3493 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3494 || [istarget spu-*-*]
3495 || [istarget i?86-*-*]
3496 || [istarget x86_64-*-*]
3497 || [istarget ia64-*-*]
3498 || [check_effective_target_arm32] } {
3499 set et_vect_int_mult_saved 1
3503 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3504 return $et_vect_int_mult_saved
3507 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3509 proc check_effective_target_vect_extract_even_odd { } {
3510 global et_vect_extract_even_odd_saved
3512 if [info exists et_vect_extract_even_odd_saved] {
3513 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3515 set et_vect_extract_even_odd_saved 0
3516 if { [istarget powerpc*-*-*]
3517 || [is-effective-target arm_neon_ok]
3518 || [istarget i?86-*-*]
3519 || [istarget x86_64-*-*]
3520 || [istarget ia64-*-*]
3521 || [istarget spu-*-*]
3522 || ([istarget mips*-*-*]
3523 && [check_effective_target_mpaired_single]) } {
3524 set et_vect_extract_even_odd_saved 1
3528 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3529 return $et_vect_extract_even_odd_saved
3532 # Return 1 if the target supports vector interleaving, 0 otherwise.
3534 proc check_effective_target_vect_interleave { } {
3535 global et_vect_interleave_saved
3537 if [info exists et_vect_interleave_saved] {
3538 verbose "check_effective_target_vect_interleave: using cached result" 2
3540 set et_vect_interleave_saved 0
3541 if { [istarget powerpc*-*-*]
3542 || [is-effective-target arm_neon_ok]
3543 || [istarget i?86-*-*]
3544 || [istarget x86_64-*-*]
3545 || [istarget ia64-*-*]
3546 || [istarget spu-*-*]
3547 || ([istarget mips*-*-*]
3548 && [check_effective_target_mpaired_single]) } {
3549 set et_vect_interleave_saved 1
3553 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3554 return $et_vect_interleave_saved
3557 foreach N {2 3 4 8} {
3558 eval [string map [list N $N] {
3559 # Return 1 if the target supports 2-vector interleaving
3560 proc check_effective_target_vect_stridedN { } {
3561 global et_vect_stridedN_saved
3563 if [info exists et_vect_stridedN_saved] {
3564 verbose "check_effective_target_vect_stridedN: using cached result" 2
3566 set et_vect_stridedN_saved 0
3568 && [check_effective_target_vect_interleave]
3569 && [check_effective_target_vect_extract_even_odd] } {
3570 set et_vect_stridedN_saved 1
3572 if { [istarget arm*-*-*] && N >= 2 && N <= 4 } {
3573 set et_vect_stridedN_saved 1
3577 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3578 return $et_vect_stridedN_saved
3583 # Return 1 if the target supports multiple vector sizes
3585 proc check_effective_target_vect_multiple_sizes { } {
3586 global et_vect_multiple_sizes_saved
3588 set et_vect_multiple_sizes_saved 0
3589 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
3590 set et_vect_multiple_sizes_saved 1
3592 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3593 if { ([check_avx_available] && ![check_prefer_avx128]) } {
3594 set et_vect_multiple_sizes_saved 1
3598 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
3599 return $et_vect_multiple_sizes_saved
3602 # Return 1 if the target supports vectors of 64 bits.
3604 proc check_effective_target_vect64 { } {
3605 global et_vect64_saved
3607 if [info exists et_vect64_saved] {
3608 verbose "check_effective_target_vect64: using cached result" 2
3610 set et_vect64_saved 0
3611 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3612 set et_vect64_saved 1
3616 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
3617 return $et_vect64_saved
3620 # Return 1 if the target supports vector copysignf calls.
3622 proc check_effective_target_vect_call_copysignf { } {
3623 global et_vect_call_copysignf_saved
3625 if [info exists et_vect_call_copysignf_saved] {
3626 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
3628 set et_vect_call_copysignf_saved 0
3629 if { [istarget i?86-*-*]
3630 || [istarget x86_64-*-*]
3631 || [istarget powerpc*-*-*] } {
3632 set et_vect_call_copysignf_saved 1
3636 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
3637 return $et_vect_call_copysignf_saved
3640 # Return 1 if the target supports vector sqrtf calls.
3642 proc check_effective_target_vect_call_sqrtf { } {
3643 global et_vect_call_sqrtf_saved
3645 if [info exists et_vect_call_sqrtf_saved] {
3646 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
3648 set et_vect_call_sqrtf_saved 0
3649 if { [istarget i?86-*-*]
3650 || [istarget x86_64-*-*]
3651 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
3652 set et_vect_call_sqrtf_saved 1
3656 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
3657 return $et_vect_call_sqrtf_saved
3660 # Return 1 if the target supports vector lrint calls.
3662 proc check_effective_target_vect_call_lrint { } {
3663 set et_vect_call_lrint 0
3664 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
3665 set et_vect_call_lrint 1
3668 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
3669 return $et_vect_call_lrint
3672 # Return 1 if the target supports section-anchors
3674 proc check_effective_target_section_anchors { } {
3675 global et_section_anchors_saved
3677 if [info exists et_section_anchors_saved] {
3678 verbose "check_effective_target_section_anchors: using cached result" 2
3680 set et_section_anchors_saved 0
3681 if { [istarget powerpc*-*-*]
3682 || [istarget arm*-*-*] } {
3683 set et_section_anchors_saved 1
3687 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3688 return $et_section_anchors_saved
3691 # Return 1 if the target supports atomic operations on "int_128" values.
3693 proc check_effective_target_sync_int_128 { } {
3694 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3695 && ![is-effective-target ia32] } {
3702 # Return 1 if the target supports atomic operations on "int_128" values
3703 # and can execute them.
3705 proc check_effective_target_sync_int_128_runtime { } {
3706 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
3707 && ![is-effective-target ia32] } {
3708 return [check_cached_effective_target sync_int_128_available {
3709 check_runtime_nocache sync_int_128_available {
3713 unsigned int eax, ebx, ecx, edx;
3714 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3715 return !(ecx & bit_CMPXCHG16B);
3725 # Return 1 if the target supports atomic operations on "long long".
3727 # Note: 32bit x86 targets require -march=pentium in dg-options.
3729 proc check_effective_target_sync_long_long { } {
3730 if { [istarget x86_64-*-*]
3731 || [istarget i?86-*-*])
3732 || [istarget arm*-*-*]
3733 || [istarget alpha*-*-*] } {
3740 # Return 1 if the target supports atomic operations on "long long"
3741 # and can execute them.
3743 # Note: 32bit x86 targets require -march=pentium in dg-options.
3745 proc check_effective_target_sync_long_long_runtime { } {
3746 if { [istarget x86_64-*-*]
3747 || [istarget i?86-*-*] } {
3748 return [check_cached_effective_target sync_long_long_available {
3749 check_runtime_nocache sync_long_long_available {
3753 unsigned int eax, ebx, ecx, edx;
3754 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
3755 return !(edx & bit_CMPXCHG8B);
3760 } elseif { [istarget arm*-*-linux-gnueabi] } {
3761 return [check_runtime sync_longlong_runtime {
3767 if (sizeof (long long) != 8)
3770 /* Just check for native; checking for kernel fallback is tricky. */
3771 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
3776 } elseif { [istarget alpha*-*-*] } {
3783 # Return 1 if the target supports atomic operations on "int" and "long".
3785 proc check_effective_target_sync_int_long { } {
3786 global et_sync_int_long_saved
3788 if [info exists et_sync_int_long_saved] {
3789 verbose "check_effective_target_sync_int_long: using cached result" 2
3791 set et_sync_int_long_saved 0
3792 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3793 # load-reserved/store-conditional instructions.
3794 if { [istarget ia64-*-*]
3795 || [istarget i?86-*-*]
3796 || [istarget x86_64-*-*]
3797 || [istarget alpha*-*-*]
3798 || [istarget arm*-*-linux-gnueabi]
3799 || [istarget bfin*-*linux*]
3800 || [istarget hppa*-*linux*]
3801 || [istarget s390*-*-*]
3802 || [istarget powerpc*-*-*]
3803 || [istarget sparc64-*-*]
3804 || [istarget sparcv9-*-*]
3805 || [check_effective_target_mips_llsc] } {
3806 set et_sync_int_long_saved 1
3810 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3811 return $et_sync_int_long_saved
3814 # Return 1 if the target supports atomic operations on "char" and "short".
3816 proc check_effective_target_sync_char_short { } {
3817 global et_sync_char_short_saved
3819 if [info exists et_sync_char_short_saved] {
3820 verbose "check_effective_target_sync_char_short: using cached result" 2
3822 set et_sync_char_short_saved 0
3823 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3824 # load-reserved/store-conditional instructions.
3825 if { [istarget ia64-*-*]
3826 || [istarget i?86-*-*]
3827 || [istarget x86_64-*-*]
3828 || [istarget alpha*-*-*]
3829 || [istarget arm*-*-linux-gnueabi]
3830 || [istarget hppa*-*linux*]
3831 || [istarget s390*-*-*]
3832 || [istarget powerpc*-*-*]
3833 || [istarget sparc64-*-*]
3834 || [istarget sparcv9-*-*]
3835 || [check_effective_target_mips_llsc] } {
3836 set et_sync_char_short_saved 1
3840 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3841 return $et_sync_char_short_saved
3844 # Return 1 if the target uses a ColdFire FPU.
3846 proc check_effective_target_coldfire_fpu { } {
3847 return [check_no_compiler_messages coldfire_fpu assembly {
3854 # Return true if this is a uClibc target.
3856 proc check_effective_target_uclibc {} {
3857 return [check_no_compiler_messages uclibc object {
3858 #include <features.h>
3859 #if !defined (__UCLIBC__)
3865 # Return true if this is a uclibc target and if the uclibc feature
3866 # described by __$feature__ is not present.
3868 proc check_missing_uclibc_feature {feature} {
3869 return [check_no_compiler_messages $feature object "
3870 #include <features.h>
3871 #if !defined (__UCLIBC) || defined (__${feature}__)
3877 # Return true if this is a Newlib target.
3879 proc check_effective_target_newlib {} {
3880 return [check_no_compiler_messages newlib object {
3886 # (a) an error of a few ULP is expected in string to floating-point
3887 # conversion functions; and
3888 # (b) overflow is not always detected correctly by those functions.
3890 proc check_effective_target_lax_strtofp {} {
3891 # By default, assume that all uClibc targets suffer from this.
3892 return [check_effective_target_uclibc]
3895 # Return 1 if this is a target for which wcsftime is a dummy
3896 # function that always returns 0.
3898 proc check_effective_target_dummy_wcsftime {} {
3899 # By default, assume that all uClibc targets suffer from this.
3900 return [check_effective_target_uclibc]
3903 # Return 1 if constructors with initialization priority arguments are
3904 # supposed on this target.
3906 proc check_effective_target_init_priority {} {
3907 return [check_no_compiler_messages init_priority assembly "
3908 void f() __attribute__((constructor (1000)));
3913 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3914 # This can be used with any check_* proc that takes no argument and
3915 # returns only 1 or 0. It could be used with check_* procs that take
3916 # arguments with keywords that pass particular arguments.
3918 proc is-effective-target { arg } {
3920 if { [info procs check_effective_target_${arg}] != [list] } {
3921 set selected [check_effective_target_${arg}]
3924 "vmx_hw" { set selected [check_vmx_hw_available] }
3925 "vsx_hw" { set selected [check_vsx_hw_available] }
3926 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3927 "named_sections" { set selected [check_named_sections_available] }
3928 "gc_sections" { set selected [check_gc_sections_available] }
3929 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3930 default { error "unknown effective target keyword `$arg'" }
3933 verbose "is-effective-target: $arg $selected" 2
3937 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3939 proc is-effective-target-keyword { arg } {
3940 if { [info procs check_effective_target_${arg}] != [list] } {
3943 # These have different names for their check_* procs.
3945 "vmx_hw" { return 1 }
3946 "vsx_hw" { return 1 }
3947 "ppc_recip_hw" { return 1 }
3948 "named_sections" { return 1 }
3949 "gc_sections" { return 1 }
3950 "cxa_atexit" { return 1 }
3951 default { return 0 }
3956 # Return 1 if target default to short enums
3958 proc check_effective_target_short_enums { } {
3959 return [check_no_compiler_messages short_enums assembly {
3961 int s[sizeof (enum foo) == 1 ? 1 : -1];
3965 # Return 1 if target supports merging string constants at link time.
3967 proc check_effective_target_string_merging { } {
3968 return [check_no_messages_and_pattern string_merging \
3969 "rodata\\.str" assembly {
3970 const char *var = "String";
3974 # Return 1 if target has the basic signed and unsigned types in
3975 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3976 # working <stdint.h> for all targets.
3978 proc check_effective_target_stdint_types { } {
3979 return [check_no_compiler_messages stdint_types assembly {
3981 int8_t a; int16_t b; int32_t c; int64_t d;
3982 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3986 # Return 1 if target has the basic signed and unsigned types in
3987 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3988 # these types agree with those in the header, as some systems have
3989 # only <inttypes.h>.
3991 proc check_effective_target_inttypes_types { } {
3992 return [check_no_compiler_messages inttypes_types assembly {
3993 #include <inttypes.h>
3994 int8_t a; int16_t b; int32_t c; int64_t d;
3995 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3999 # Return 1 if programs are intended to be run on a simulator
4000 # (i.e. slowly) rather than hardware (i.e. fast).
4002 proc check_effective_target_simulator { } {
4004 # All "src/sim" simulators set this one.
4005 if [board_info target exists is_simulator] {
4006 return [board_info target is_simulator]
4009 # The "sid" simulators don't set that one, but at least they set
4011 if [board_info target exists slow_simulator] {
4012 return [board_info target slow_simulator]
4018 # Return 1 if the target is a VxWorks kernel.
4020 proc check_effective_target_vxworks_kernel { } {
4021 return [check_no_compiler_messages vxworks_kernel assembly {
4022 #if !defined __vxworks || defined __RTP__
4028 # Return 1 if the target is a VxWorks RTP.
4030 proc check_effective_target_vxworks_rtp { } {
4031 return [check_no_compiler_messages vxworks_rtp assembly {
4032 #if !defined __vxworks || !defined __RTP__
4038 # Return 1 if the target is expected to provide wide character support.
4040 proc check_effective_target_wchar { } {
4041 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4044 return [check_no_compiler_messages wchar assembly {
4049 # Return 1 if the target has <pthread.h>.
4051 proc check_effective_target_pthread_h { } {
4052 return [check_no_compiler_messages pthread_h assembly {
4053 #include <pthread.h>
4057 # Return 1 if the target can truncate a file from a file-descriptor,
4058 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4059 # chsize. We test for a trivially functional truncation; no stubs.
4060 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4061 # different function to be used.
4063 proc check_effective_target_fd_truncate { } {
4065 #define _FILE_OFFSET_BITS 64
4071 FILE *f = fopen ("tst.tmp", "wb");
4073 const char t[] = "test writing more than ten characters";
4077 write (fd, t, sizeof (t) - 1);
4079 if (ftruncate (fd, 10) != 0)
4088 f = fopen ("tst.tmp", "rb");
4089 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4097 if { [check_runtime ftruncate $prog] } {
4101 regsub "ftruncate" $prog "chsize" prog
4102 return [check_runtime chsize $prog]
4105 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4107 proc add_options_for_c99_runtime { flags } {
4108 if { [istarget *-*-solaris2*] } {
4109 return "$flags -std=c99"
4111 if { [istarget powerpc-*-darwin*] } {
4112 return "$flags -mmacosx-version-min=10.3"
4117 # Add to FLAGS all the target-specific flags needed to enable
4118 # full IEEE compliance mode.
4120 proc add_options_for_ieee { flags } {
4121 if { [istarget alpha*-*-*]
4122 || [istarget sh*-*-*] } {
4123 return "$flags -mieee"
4125 if { [istarget rx-*-*] } {
4126 return "$flags -mnofpu"
4131 # Add to FLAGS the flags needed to enable functions to bind locally
4132 # when using pic/PIC passes in the testsuite.
4134 proc add_options_for_bind_pic_locally { flags } {
4135 if {[check_no_compiler_messages using_pic2 assembly {
4140 return "$flags -fPIE"
4142 if {[check_no_compiler_messages using_pic1 assembly {
4147 return "$flags -fpie"
4153 # Add to FLAGS the flags needed to enable 64-bit vectors.
4155 proc add_options_for_double_vectors { flags } {
4156 if [is-effective-target arm_neon_ok] {
4157 return "$flags -mvectorize-with-neon-double"
4163 # Return 1 if the target provides a full C99 runtime.
4165 proc check_effective_target_c99_runtime { } {
4166 return [check_cached_effective_target c99_runtime {
4169 set file [open "$srcdir/gcc.dg/builtins-config.h"]
4170 set contents [read $file]
4173 #ifndef HAVE_C99_RUNTIME
4177 check_no_compiler_messages_nocache c99_runtime assembly \
4178 $contents [add_options_for_c99_runtime ""]
4182 # Return 1 if target wchar_t is at least 4 bytes.
4184 proc check_effective_target_4byte_wchar_t { } {
4185 return [check_no_compiler_messages 4byte_wchar_t object {
4186 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
4190 # Return 1 if the target supports automatic stack alignment.
4192 proc check_effective_target_automatic_stack_alignment { } {
4193 # Ordinarily x86 supports automatic stack alignment ...
4194 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
4195 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
4196 # ... except Win64 SEH doesn't. Succeed for Win32 though.
4197 return [check_effective_target_ilp32];
4204 # Return true if we are compiling for AVX target.
4206 proc check_avx_available { } {
4207 if { [check_no_compiler_messages avx_available assembly {
4217 # Return true if 32- and 16-bytes vectors are available.
4219 proc check_effective_target_vect_sizes_32B_16B { } {
4220 return [check_avx_available];
4223 # Return true if 128-bits vectors are preferred even if 256-bits vectors
4226 proc check_prefer_avx128 { } {
4227 if ![check_avx_available] {
4230 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
4231 float a[1024],b[1024],c[1024];
4232 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
4233 } "-O2 -ftree-vectorize"]
4237 # Return 1 if avx instructions can be compiled.
4239 proc check_effective_target_avx { } {
4240 return [check_no_compiler_messages avx object {
4241 void _mm256_zeroall (void)
4243 __builtin_ia32_vzeroall ();
4248 # Return 1 if sse instructions can be compiled.
4249 proc check_effective_target_sse { } {
4250 return [check_no_compiler_messages sse object {
4253 __builtin_ia32_stmxcsr ();
4259 # Return 1 if sse2 instructions can be compiled.
4260 proc check_effective_target_sse2 { } {
4261 return [check_no_compiler_messages sse2 object {
4262 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
4264 __m128i _mm_srli_si128 (__m128i __A, int __N)
4266 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
4271 # Return 1 if F16C instructions can be compiled.
4273 proc check_effective_target_f16c { } {
4274 return [check_no_compiler_messages f16c object {
4275 #include "immintrin.h"
4277 foo (unsigned short val)
4279 return _cvtsh_ss (val);
4284 # Return 1 if C wchar_t type is compatible with char16_t.
4286 proc check_effective_target_wchar_t_char16_t_compatible { } {
4287 return [check_no_compiler_messages wchar_t_char16_t object {
4289 __CHAR16_TYPE__ *p16 = &wc;
4290 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4294 # Return 1 if C wchar_t type is compatible with char32_t.
4296 proc check_effective_target_wchar_t_char32_t_compatible { } {
4297 return [check_no_compiler_messages wchar_t_char32_t object {
4299 __CHAR32_TYPE__ *p32 = &wc;
4300 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4304 # Return 1 if pow10 function exists.
4306 proc check_effective_target_pow10 { } {
4307 return [check_runtime pow10 {
4317 # Return 1 if current options generate DFP instructions, 0 otherwise.
4319 proc check_effective_target_hard_dfp {} {
4320 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
4321 typedef float d64 __attribute__((mode(DD)));
4323 void foo (void) { z = x + y; }
4327 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
4328 # for strchr etc. functions.
4330 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
4331 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
4334 #if !defined(__cplusplus) \
4335 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
4336 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
4337 ISO C++ correct string.h and wchar.h protos not supported.
4344 # Return 1 if GNU as is used.
4346 proc check_effective_target_gas { } {
4347 global use_gas_saved
4350 if {![info exists use_gas_saved]} {
4351 # Check if the as used by gcc is GNU as.
4352 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
4353 # Provide /dev/null as input, otherwise gas times out reading from
4355 set status [remote_exec host "$gcc_as" "-v /dev/null"]
4356 set as_output [lindex $status 1]
4357 if { [ string first "GNU" $as_output ] >= 0 } {
4363 return $use_gas_saved
4366 # Return 1 if GNU ld is used.
4368 proc check_effective_target_gld { } {
4369 global use_gld_saved
4372 if {![info exists use_gld_saved]} {
4373 # Check if the ld used by gcc is GNU ld.
4374 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
4375 set status [remote_exec host "$gcc_ld" "--version"]
4376 set ld_output [lindex $status 1]
4377 if { [ string first "GNU" $ld_output ] >= 0 } {
4383 return $use_gld_saved
4386 # Return 1 if the compiler has been configure with link-time optimization
4389 proc check_effective_target_lto { } {
4391 return [info exists ENABLE_LTO]
4394 # Return 1 if this target supports the -fsplit-stack option, 0
4397 proc check_effective_target_split_stack {} {
4398 return [check_no_compiler_messages split_stack object {
4403 # Return 1 if the language for the compiler under test is C.
4405 proc check_effective_target_c { } {
4407 if [string match $tool "gcc"] {
4413 # Return 1 if the language for the compiler under test is C++.
4415 proc check_effective_target_c++ { } {
4417 if [string match $tool "g++"] {
4423 # Check which language standard is active by checking for the presence of
4424 # one of the C++11 -std flags. This assumes that the default for the
4425 # compiler is C++98, and that there will never be multiple -std= arguments
4426 # on the command line.
4427 proc check_effective_target_c++11 { } {
4428 if ![check_effective_target_c++] {
4431 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4434 proc check_effective_target_c++98 { } {
4435 if ![check_effective_target_c++] {
4438 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
4441 # Return 1 if expensive testcases should be run.
4443 proc check_effective_target_run_expensive_tests { } {
4444 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
4450 # Returns 1 if "mempcpy" is available on the target system.
4452 proc check_effective_target_mempcpy {} {
4453 return [check_function_available "mempcpy"]
4456 # Check whether the vectorizer tests are supported by the target and
4457 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
4458 # Set dg-do-what-default to either compile or run, depending on target
4459 # capabilities. Return 1 if vectorizer tests are supported by
4460 # target, 0 otherwise.
4462 proc check_vect_support_and_set_flags { } {
4463 global DEFAULT_VECTCFLAGS
4464 global dg-do-what-default
4466 if [istarget powerpc-*paired*] {
4467 lappend DEFAULT_VECTCFLAGS "-mpaired"
4468 if [check_750cl_hw_available] {
4469 set dg-do-what-default run
4471 set dg-do-what-default compile
4473 } elseif [istarget powerpc*-*-*] {
4474 # Skip targets not supporting -maltivec.
4475 if ![is-effective-target powerpc_altivec_ok] {
4479 lappend DEFAULT_VECTCFLAGS "-maltivec"
4480 if [check_vsx_hw_available] {
4481 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
4484 if [check_vmx_hw_available] {
4485 set dg-do-what-default run
4487 if [is-effective-target ilp32] {
4488 # Specify a cpu that supports VMX for compile-only tests.
4489 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
4491 set dg-do-what-default compile
4493 } elseif { [istarget spu-*-*] } {
4494 set dg-do-what-default run
4495 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4496 lappend DEFAULT_VECTCFLAGS "-msse2"
4497 if { [check_effective_target_sse2_runtime] } {
4498 set dg-do-what-default run
4500 set dg-do-what-default compile
4502 } elseif { [istarget mips*-*-*]
4503 && ([check_effective_target_mpaired_single]
4504 || [check_effective_target_mips_loongson])
4505 && [check_effective_target_nomips16] } {
4506 if { [check_effective_target_mpaired_single] } {
4507 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
4509 set dg-do-what-default run
4510 } elseif [istarget sparc*-*-*] {
4511 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
4512 if [check_effective_target_ultrasparc_hw] {
4513 set dg-do-what-default run
4515 set dg-do-what-default compile
4517 } elseif [istarget alpha*-*-*] {
4518 # Alpha's vectorization capabilities are extremely limited.
4519 # It's more effort than its worth disabling all of the tests
4520 # that it cannot pass. But if you actually want to see what
4521 # does work, command out the return.
4524 lappend DEFAULT_VECTCFLAGS "-mmax"
4525 if [check_alpha_max_hw_available] {
4526 set dg-do-what-default run
4528 set dg-do-what-default compile
4530 } elseif [istarget ia64-*-*] {
4531 set dg-do-what-default run
4532 } elseif [is-effective-target arm_neon_ok] {
4533 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
4534 # NEON does not support denormals, so is not used for vectorization by
4535 # default to avoid loss of precision. We must pass -ffast-math to test
4536 # vectorization of float operations.
4537 lappend DEFAULT_VECTCFLAGS "-ffast-math"
4538 if [is-effective-target arm_neon_hw] {
4539 set dg-do-what-default run
4541 set dg-do-what-default compile
4550 proc check_effective_target_non_strict_align {} {
4551 return [check_no_compiler_messages non_strict_align assembly {
4553 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
4555 void foo(void) { z = (c *) y; }
4559 # Return 1 if the target has <ucontext.h>.
4561 proc check_effective_target_ucontext_h { } {
4562 return [check_no_compiler_messages ucontext_h assembly {
4563 #include <ucontext.h>