Merge trunk version 227333 into gupc branch.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob6d03d57a7a2c969a3fc0928ce6b8cb947c18aeb6
1 # Copyright (C) 1999-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # This file defines procs for determining features supported by the target.
22 # Try to compile the code given by CONTENTS into an output file of
23 # type TYPE, where TYPE is as for target_compile. Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the name of the output file.
27 # BASENAME is a prefix to use for source and output files.
28 # If ARGS is not empty, its first element is a string that
29 # should be added to the command line.
31 # Assume by default that CONTENTS is C code.
32 # Otherwise, code should contain:
33 # "// C++" for c++,
34 # "! Fortran" for Fortran code,
35 # "/* ObjC", for ObjC
36 # "// ObjC++" for ObjC++
37 # and "// Go" for Go
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
44 # Save additional_sources to avoid compiling testsuite's sources
45 # against check_compile's source.
46 global additional_sources
47 if [info exists additional_sources] {
48 set tmp_additional_sources "$additional_sources"
49 set additional_sources ""
52 if { [llength $args] > 0 } {
53 set options [list "additional_flags=[lindex $args 0]"]
54 } else {
55 set options ""
57 switch -glob -- $contents {
58 "*! Fortran*" { set src ${basename}[pid].f90 }
59 "*// C++*" { set src ${basename}[pid].cc }
60 "*// ObjC++*" { set src ${basename}[pid].mm }
61 "*/* ObjC*" { set src ${basename}[pid].m }
62 "*// Go*" { set src ${basename}[pid].go }
63 default {
64 switch -- $tool {
65 "objc" { set src ${basename}[pid].m }
66 "obj-c++" { set src ${basename}[pid].mm }
67 default { set src ${basename}[pid].c }
72 set compile_type $type
73 switch -glob $type {
74 assembly { set output ${basename}[pid].s }
75 object { set output ${basename}[pid].o }
76 executable { set output ${basename}[pid].exe }
77 "rtl-*" {
78 set output ${basename}[pid].s
79 lappend options "additional_flags=-fdump-$type"
80 set compile_type assembly
83 set f [open $src "w"]
84 puts $f $contents
85 close $f
86 set lines [${tool}_target_compile $src $output $compile_type "$options"]
87 file delete $src
89 set scan_output $output
90 # Don't try folding this into the switch above; calling "glob" before the
91 # file is created won't work.
92 if [regexp "rtl-(.*)" $type dummy rtl_type] {
93 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
94 file delete $output
97 # Restore additional_sources.
98 if [info exists additional_sources] {
99 set additional_sources "$tmp_additional_sources"
102 return [list $lines $scan_output]
105 proc current_target_name { } {
106 global target_info
107 if [info exists target_info(target,name)] {
108 set answer $target_info(target,name)
109 } else {
110 set answer ""
112 return $answer
115 # Implement an effective-target check for property PROP by invoking
116 # the Tcl command ARGS and seeing if it returns true.
118 proc check_cached_effective_target { prop args } {
119 global et_cache
121 set target [current_target_name]
122 if {![info exists et_cache($prop,target)]
123 || $et_cache($prop,target) != $target} {
124 verbose "check_cached_effective_target $prop: checking $target" 2
125 set et_cache($prop,target) $target
126 set et_cache($prop,value) [uplevel eval $args]
128 set value $et_cache($prop,value)
129 verbose "check_cached_effective_target $prop: returning $value for $target" 2
130 return $value
133 # Like check_compile, but delete the output file and return true if the
134 # compiler printed no messages.
135 proc check_no_compiler_messages_nocache {args} {
136 set result [eval check_compile $args]
137 set lines [lindex $result 0]
138 set output [lindex $result 1]
139 remote_file build delete $output
140 return [string match "" $lines]
143 # Like check_no_compiler_messages_nocache, but cache the result.
144 # PROP is the property we're checking, and doubles as a prefix for
145 # temporary filenames.
146 proc check_no_compiler_messages {prop args} {
147 return [check_cached_effective_target $prop {
148 eval [list check_no_compiler_messages_nocache $prop] $args
152 # Like check_compile, but return true if the compiler printed no
153 # messages and if the contents of the output file satisfy PATTERN.
154 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
155 # don't match regular expression REGEXP, otherwise they satisfy it
156 # if they do match regular expression PATTERN. (PATTERN can start
157 # with something like "[!]" if the regular expression needs to match
158 # "!" as the first character.)
160 # Delete the output file before returning. The other arguments are
161 # as for check_compile.
162 proc check_no_messages_and_pattern_nocache {basename pattern args} {
163 global tool
165 set result [eval [list check_compile $basename] $args]
166 set lines [lindex $result 0]
167 set output [lindex $result 1]
169 set ok 0
170 if { [string match "" $lines] } {
171 set chan [open "$output"]
172 set invert [regexp {^!(.*)} $pattern dummy pattern]
173 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
174 close $chan
177 remote_file build delete $output
178 return $ok
181 # Like check_no_messages_and_pattern_nocache, but cache the result.
182 # PROP is the property we're checking, and doubles as a prefix for
183 # temporary filenames.
184 proc check_no_messages_and_pattern {prop pattern args} {
185 return [check_cached_effective_target $prop {
186 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
190 # Try to compile and run an executable from code CONTENTS. Return true
191 # if the compiler reports no messages and if execution "passes" in the
192 # usual DejaGNU sense. The arguments are as for check_compile, with
193 # TYPE implicitly being "executable".
194 proc check_runtime_nocache {basename contents args} {
195 global tool
197 set result [eval [list check_compile $basename executable $contents] $args]
198 set lines [lindex $result 0]
199 set output [lindex $result 1]
201 set ok 0
202 if { [string match "" $lines] } {
203 # No error messages, everything is OK.
204 set result [remote_load target "./$output" "" ""]
205 set status [lindex $result 0]
206 verbose "check_runtime_nocache $basename: status is <$status>" 2
207 if { $status == "pass" } {
208 set ok 1
211 remote_file build delete $output
212 return $ok
215 # Like check_runtime_nocache, but cache the result. PROP is the
216 # property we're checking, and doubles as a prefix for temporary
217 # filenames.
218 proc check_runtime {prop args} {
219 global tool
221 return [check_cached_effective_target $prop {
222 eval [list check_runtime_nocache $prop] $args
226 ###############################
227 # proc check_weak_available { }
228 ###############################
230 # weak symbols are only supported in some configs/object formats
231 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
233 proc check_weak_available { } {
234 global target_cpu
236 # All mips targets should support it
238 if { [ string first "mips" $target_cpu ] >= 0 } {
239 return 1
242 # All AIX targets should support it
244 if { [istarget *-*-aix*] } {
245 return 1
248 # All solaris2 targets should support it
250 if { [istarget *-*-solaris2*] } {
251 return 1
254 # Windows targets Cygwin and MingW32 support it
256 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
257 return 1
260 # HP-UX 10.X doesn't support it
262 if { [istarget hppa*-*-hpux10*] } {
263 return 0
266 # ELF and ECOFF support it. a.out does with gas/gld but may also with
267 # other linkers, so we should try it
269 set objformat [gcc_target_object_format]
271 switch $objformat {
272 elf { return 1 }
273 ecoff { return 1 }
274 a.out { return 1 }
275 mach-o { return 1 }
276 som { return 1 }
277 unknown { return -1 }
278 default { return 0 }
282 ###############################
283 # proc check_weak_override_available { }
284 ###############################
286 # Like check_weak_available, but return 0 if weak symbol definitions
287 # cannot be overridden.
289 proc check_weak_override_available { } {
290 if { [istarget *-*-mingw*] } {
291 return 0
293 return [check_weak_available]
296 ###############################
297 # proc check_visibility_available { what_kind }
298 ###############################
300 # The visibility attribute is only support in some object formats
301 # This proc returns 1 if it is supported, 0 if not.
302 # The argument is the kind of visibility, default/protected/hidden/internal.
304 proc check_visibility_available { what_kind } {
305 if [string match "" $what_kind] { set what_kind "hidden" }
307 return [check_no_compiler_messages visibility_available_$what_kind object "
308 void f() __attribute__((visibility(\"$what_kind\")));
309 void f() {}
313 ###############################
314 # proc check_alias_available { }
315 ###############################
317 # Determine if the target toolchain supports the alias attribute.
319 # Returns 2 if the target supports aliases. Returns 1 if the target
320 # only supports weak aliased. Returns 0 if the target does not
321 # support aliases at all. Returns -1 if support for aliases could not
322 # be determined.
324 proc check_alias_available { } {
325 global alias_available_saved
326 global tool
328 if [info exists alias_available_saved] {
329 verbose "check_alias_available returning saved $alias_available_saved" 2
330 } else {
331 set src alias[pid].c
332 set obj alias[pid].o
333 verbose "check_alias_available compiling testfile $src" 2
334 set f [open $src "w"]
335 # Compile a small test program. The definition of "g" is
336 # necessary to keep the Solaris assembler from complaining
337 # about the program.
338 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
339 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
340 close $f
341 set lines [${tool}_target_compile $src $obj object ""]
342 file delete $src
343 remote_file build delete $obj
345 if [string match "" $lines] then {
346 # No error messages, everything is OK.
347 set alias_available_saved 2
348 } else {
349 if [regexp "alias definitions not supported" $lines] {
350 verbose "check_alias_available target does not support aliases" 2
352 set objformat [gcc_target_object_format]
354 if { $objformat == "elf" } {
355 verbose "check_alias_available but target uses ELF format, so it ought to" 2
356 set alias_available_saved -1
357 } else {
358 set alias_available_saved 0
360 } else {
361 if [regexp "only weak aliases are supported" $lines] {
362 verbose "check_alias_available target supports only weak aliases" 2
363 set alias_available_saved 1
364 } else {
365 set alias_available_saved -1
370 verbose "check_alias_available returning $alias_available_saved" 2
373 return $alias_available_saved
376 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
378 proc check_effective_target_alias { } {
379 if { [check_alias_available] < 2 } {
380 return 0
381 } else {
382 return 1
386 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
388 proc check_ifunc_available { } {
389 return [check_no_compiler_messages ifunc_available object {
390 #ifdef __cplusplus
391 extern "C"
392 #endif
393 void g() {}
394 void f() __attribute__((ifunc("g")));
398 # Returns true if --gc-sections is supported on the target.
400 proc check_gc_sections_available { } {
401 global gc_sections_available_saved
402 global tool
404 if {![info exists gc_sections_available_saved]} {
405 # Some targets don't support gc-sections despite whatever's
406 # advertised by ld's options.
407 if { [istarget alpha*-*-*]
408 || [istarget ia64-*-*] } {
409 set gc_sections_available_saved 0
410 return 0
413 # elf2flt uses -q (--emit-relocs), which is incompatible with
414 # --gc-sections.
415 if { [board_info target exists ldflags]
416 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
417 set gc_sections_available_saved 0
418 return 0
421 # VxWorks kernel modules are relocatable objects linked with -r,
422 # while RTP executables are linked with -q (--emit-relocs).
423 # Both of these options are incompatible with --gc-sections.
424 if { [istarget *-*-vxworks*] } {
425 set gc_sections_available_saved 0
426 return 0
429 # Check if the ld used by gcc supports --gc-sections.
430 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
431 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
432 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
433 set ld_output [remote_exec host "$gcc_ld" "--help"]
434 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
435 set gc_sections_available_saved 1
436 } else {
437 set gc_sections_available_saved 0
440 return $gc_sections_available_saved
443 # Return 1 if according to target_info struct and explicit target list
444 # target is supposed to support trampolines.
446 proc check_effective_target_trampolines { } {
447 if [target_info exists no_trampolines] {
448 return 0
450 if { [istarget avr-*-*]
451 || [istarget msp430-*-*]
452 || [istarget nvptx-*-*]
453 || [istarget hppa2.0w-hp-hpux11.23]
454 || [istarget hppa64-hp-hpux11.23] } {
455 return 0;
457 return 1
460 # Return 1 if according to target_info struct and explicit target list
461 # target disables -fdelete-null-pointer-checks. Targets should return 0
462 # if they simply default to -fno-delete-null-pointer-checks but obey
463 # -fdelete-null-pointer-checks when passed explicitly (and tests that
464 # depend on this option should do that).
466 proc check_effective_target_keeps_null_pointer_checks { } {
467 if [target_info exists keeps_null_pointer_checks] {
468 return 1
470 if { [istarget avr-*-*] } {
471 return 1;
473 return 0
476 # Return true if profiling is supported on the target.
478 proc check_profiling_available { test_what } {
479 global profiling_available_saved
481 verbose "Profiling argument is <$test_what>" 1
483 # These conditions depend on the argument so examine them before
484 # looking at the cache variable.
486 # Tree profiling requires TLS runtime support.
487 if { $test_what == "-fprofile-generate" } {
488 if { ![check_effective_target_tls_runtime] } {
489 return 0
493 # Support for -p on solaris2 relies on mcrt1.o which comes with the
494 # vendor compiler. We cannot reliably predict the directory where the
495 # vendor compiler (and thus mcrt1.o) is installed so we can't
496 # necessarily find mcrt1.o even if we have it.
497 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
498 return 0
501 # We don't yet support profiling for MIPS16.
502 if { [istarget mips*-*-*]
503 && ![check_effective_target_nomips16]
504 && ($test_what == "-p" || $test_what == "-pg") } {
505 return 0
508 # MinGW does not support -p.
509 if { [istarget *-*-mingw*] && $test_what == "-p" } {
510 return 0
513 # cygwin does not support -p.
514 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
515 return 0
518 # uClibc does not have gcrt1.o.
519 if { [check_effective_target_uclibc]
520 && ($test_what == "-p" || $test_what == "-pg") } {
521 return 0
524 # Now examine the cache variable.
525 if {![info exists profiling_available_saved]} {
526 # Some targets don't have any implementation of __bb_init_func or are
527 # missing other needed machinery.
528 if {[istarget aarch64*-*-elf]
529 || [istarget am3*-*-linux*]
530 || [istarget arm*-*-eabi*]
531 || [istarget arm*-*-elf]
532 || [istarget arm*-*-symbianelf*]
533 || [istarget avr-*-*]
534 || [istarget bfin-*-*]
535 || [istarget cris-*-*]
536 || [istarget crisv32-*-*]
537 || [istarget fido-*-elf]
538 || [istarget h8300-*-*]
539 || [istarget lm32-*-*]
540 || [istarget m32c-*-elf]
541 || [istarget m68k-*-elf]
542 || [istarget m68k-*-uclinux*]
543 || [istarget mep-*-elf]
544 || [istarget mips*-*-elf*]
545 || [istarget mmix-*-*]
546 || [istarget mn10300-*-elf*]
547 || [istarget moxie-*-elf*]
548 || [istarget msp430-*-*]
549 || [istarget nds32*-*-elf]
550 || [istarget nios2-*-elf]
551 || [istarget nvptx-*-*]
552 || [istarget powerpc-*-eabi*]
553 || [istarget powerpc-*-elf]
554 || [istarget rx-*-*]
555 || [istarget tic6x-*-elf]
556 || [istarget visium-*-*]
557 || [istarget xstormy16-*]
558 || [istarget xtensa*-*-elf]
559 || [istarget *-*-rtems*]
560 || [istarget *-*-vxworks*] } {
561 set profiling_available_saved 0
562 } else {
563 set profiling_available_saved 1
567 # -pg link test result can't be cached since it may change between
568 # runs.
569 set profiling_working $profiling_available_saved
570 if { $profiling_available_saved == 1
571 && ![check_no_compiler_messages_nocache profiling executable {
572 int main() { return 0; } } "-pg"] } {
573 set profiling_working 0
576 return $profiling_working
579 # Check to see if a target is "freestanding". This is as per the definition
580 # in Section 4 of C99 standard. Effectively, it is a target which supports no
581 # extra headers or libraries other than what is considered essential.
582 proc check_effective_target_freestanding { } {
583 if { [istarget nvptx-*-*] } {
584 return 1
586 return 0
589 # Return 1 if target has packed layout of structure members by
590 # default, 0 otherwise. Note that this is slightly different than
591 # whether the target has "natural alignment": both attributes may be
592 # false.
594 proc check_effective_target_default_packed { } {
595 return [check_no_compiler_messages default_packed assembly {
596 struct x { char a; long b; } c;
597 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
601 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
602 # documentation, where the test also comes from.
604 proc check_effective_target_pcc_bitfield_type_matters { } {
605 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
606 # bitfields, but let's stick to the example code from the docs.
607 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
608 struct foo1 { char x; char :0; char y; };
609 struct foo2 { char x; int :0; char y; };
610 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
614 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
616 proc add_options_for_tls { flags } {
617 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
618 # libthread, so always pass -pthread for native TLS. Same for AIX.
619 # Need to duplicate native TLS check from
620 # check_effective_target_tls_native to avoid recursion.
621 if { ([istarget powerpc-ibm-aix*]) &&
622 [check_no_messages_and_pattern tls_native "!emutls" assembly {
623 __thread int i;
624 int f (void) { return i; }
625 void g (int j) { i = j; }
626 }] } {
627 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
629 return $flags
632 # Return 1 if indirect jumps are supported, 0 otherwise.
634 proc check_effective_target_indirect_jumps {} {
635 if { [istarget nvptx-*-*] } {
636 return 0
638 return 1
641 # Return 1 if nonlocal goto is supported, 0 otherwise.
643 proc check_effective_target_nonlocal_goto {} {
644 if { [istarget nvptx-*-*] } {
645 return 0
647 return 1
650 # Return 1 if global constructors are supported, 0 otherwise.
652 proc check_effective_target_global_constructor {} {
653 if { [istarget nvptx-*-*] } {
654 return 0
656 return 1
659 # Return 1 if taking label values is supported, 0 otherwise.
661 proc check_effective_target_label_values {} {
662 if { [istarget nvptx-*-*] } {
663 return 0
665 return [check_no_compiler_messages label_values assembly {
666 #ifdef NO_LABEL_VALUES
667 #error NO
668 #endif
672 # Return 1 if builtin_return_address and builtin_frame_address are
673 # supported, 0 otherwise.
675 proc check_effective_target_return_address {} {
676 if { [istarget nvptx-*-*] } {
677 return 0
679 return 1
682 # Return 1 if the assembler does not verify function types against
683 # calls, 0 otherwise. Such verification will typically show up problems
684 # with K&R C function declarations.
686 proc check_effective_target_untyped_assembly {} {
687 if { [istarget nvptx-*-*] } {
688 return 0
690 return 1
693 # Return 1 if alloca is supported, 0 otherwise.
695 proc check_effective_target_alloca {} {
696 if { [istarget nvptx-*-*] } {
697 return 0
699 return 1
702 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
704 proc check_effective_target_tls {} {
705 return [check_no_compiler_messages tls assembly {
706 __thread int i;
707 int f (void) { return i; }
708 void g (int j) { i = j; }
712 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
714 proc check_effective_target_tls_native {} {
715 # VxWorks uses emulated TLS machinery, but with non-standard helper
716 # functions, so we fail to automatically detect it.
717 if { [istarget *-*-vxworks*] } {
718 return 0
721 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
722 __thread int i;
723 int f (void) { return i; }
724 void g (int j) { i = j; }
728 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
730 proc check_effective_target_tls_emulated {} {
731 # VxWorks uses emulated TLS machinery, but with non-standard helper
732 # functions, so we fail to automatically detect it.
733 if { [istarget *-*-vxworks*] } {
734 return 1
737 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
738 __thread int i;
739 int f (void) { return i; }
740 void g (int j) { i = j; }
744 # Return 1 if TLS executables can run correctly, 0 otherwise.
746 proc check_effective_target_tls_runtime {} {
747 # The runtime does not have TLS support, but just
748 # running the test below is insufficient to show this.
749 if { [istarget msp430-*-*] || [istarget visium-*-*] } {
750 return 0
752 return [check_runtime tls_runtime {
753 __thread int thr = 0;
754 int main (void) { return thr; }
755 } [add_options_for_tls ""]]
758 # Return 1 if atomic compare-and-swap is supported on 'int'
760 proc check_effective_target_cas_char {} {
761 return [check_no_compiler_messages cas_char assembly {
762 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
763 #error unsupported
764 #endif
765 } ""]
768 proc check_effective_target_cas_int {} {
769 return [check_no_compiler_messages cas_int assembly {
770 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
771 /* ok */
772 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
773 /* ok */
774 #else
775 #error unsupported
776 #endif
777 } ""]
780 # Return 1 if -ffunction-sections is supported, 0 otherwise.
782 proc check_effective_target_function_sections {} {
783 # Darwin has its own scheme and silently accepts -ffunction-sections.
784 if { [istarget *-*-darwin*] } {
785 return 0
788 return [check_no_compiler_messages functionsections assembly {
789 void foo (void) { }
790 } "-ffunction-sections"]
793 # Return 1 if instruction scheduling is available, 0 otherwise.
795 proc check_effective_target_scheduling {} {
796 return [check_no_compiler_messages scheduling object {
797 void foo (void) { }
798 } "-fschedule-insns"]
801 # Return 1 if trapping arithmetic is available, 0 otherwise.
803 proc check_effective_target_trapping {} {
804 return [check_no_compiler_messages trapping object {
805 int add (int a, int b) { return a + b; }
806 } "-ftrapv"]
809 # Return 1 if compilation with -fgraphite is error-free for trivial
810 # code, 0 otherwise.
812 proc check_effective_target_fgraphite {} {
813 return [check_no_compiler_messages fgraphite object {
814 void foo (void) { }
815 } "-O1 -fgraphite"]
818 # Return 1 if compilation with -fopenacc is error-free for trivial
819 # code, 0 otherwise.
821 proc check_effective_target_fopenacc {} {
822 # nvptx can be built with the device-side bits of openacc, but it
823 # does not make sense to test it as an openacc host.
824 if [istarget nvptx-*-*] { return 0 }
826 return [check_no_compiler_messages fopenacc object {
827 void foo (void) { }
828 } "-fopenacc"]
831 # Return 1 if compilation with -fopenmp is error-free for trivial
832 # code, 0 otherwise.
834 proc check_effective_target_fopenmp {} {
835 # nvptx can be built with the device-side bits of libgomp, but it
836 # does not make sense to test it as an openmp host.
837 if [istarget nvptx-*-*] { return 0 }
839 return [check_no_compiler_messages fopenmp object {
840 void foo (void) { }
841 } "-fopenmp"]
844 # Return 1 if compilation with -fupc is error-free for trivial
845 # code, 0 otherwise.
847 proc check_effective_target_fupc {} {
848 return [check_no_compiler_messages fupc object {
849 void foo (void) { }
850 } "-fupc -fno-upc-pre-include"]
853 # Return 1 if compilation with -fgnu-tm is error-free for trivial
854 # code, 0 otherwise.
856 proc check_effective_target_fgnu_tm {} {
857 return [check_no_compiler_messages fgnu_tm object {
858 void foo (void) { }
859 } "-fgnu-tm"]
862 # Return 1 if the target supports mmap, 0 otherwise.
864 proc check_effective_target_mmap {} {
865 return [check_function_available "mmap"]
868 # Return 1 if the target supports dlopen, 0 otherwise.
869 proc check_effective_target_dlopen {} {
870 return [check_no_compiler_messages dlopen executable {
871 #include <dlfcn.h>
872 int main(void) { dlopen ("dummy.so", RTLD_NOW); }
873 } [add_options_for_dlopen ""]]
876 proc add_options_for_dlopen { flags } {
877 return "$flags -ldl"
880 # Return 1 if the target supports clone, 0 otherwise.
881 proc check_effective_target_clone {} {
882 return [check_function_available "clone"]
885 # Return 1 if the target supports setrlimit, 0 otherwise.
886 proc check_effective_target_setrlimit {} {
887 # Darwin has non-posix compliant RLIMIT_AS
888 if { [istarget *-*-darwin*] } {
889 return 0
891 return [check_function_available "setrlimit"]
894 # Return 1 if the target supports swapcontext, 0 otherwise.
895 proc check_effective_target_swapcontext {} {
896 return [check_no_compiler_messages swapcontext executable {
897 #include <ucontext.h>
898 int main (void)
900 ucontext_t orig_context,child_context;
901 if (swapcontext(&child_context, &orig_context) < 0) { }
906 # Return 1 if compilation with -pthread is error-free for trivial
907 # code, 0 otherwise.
909 proc check_effective_target_pthread {} {
910 return [check_no_compiler_messages pthread object {
911 void foo (void) { }
912 } "-pthread"]
915 # Return 1 if compilation with -mpe-aligned-commons is error-free
916 # for trivial code, 0 otherwise.
918 proc check_effective_target_pe_aligned_commons {} {
919 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
920 return [check_no_compiler_messages pe_aligned_commons object {
921 int foo;
922 } "-mpe-aligned-commons"]
924 return 0
927 # Return 1 if the target supports -static
928 proc check_effective_target_static {} {
929 return [check_no_compiler_messages static executable {
930 int main (void) { return 0; }
931 } "-static"]
934 # Return 1 if the target supports -fstack-protector
935 proc check_effective_target_fstack_protector {} {
936 return [check_runtime fstack_protector {
937 int main (void) { return 0; }
938 } "-fstack-protector"]
941 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
942 # for trivial code, 0 otherwise.
944 proc check_effective_target_freorder {} {
945 return [check_no_compiler_messages freorder object {
946 void foo (void) { }
947 } "-freorder-blocks-and-partition"]
950 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
951 # emitted, 0 otherwise. Whether a shared library can actually be built is
952 # out of scope for this test.
954 proc check_effective_target_fpic { } {
955 # Note that M68K has a multilib that supports -fpic but not
956 # -fPIC, so we need to check both. We test with a program that
957 # requires GOT references.
958 foreach arg {fpic fPIC} {
959 if [check_no_compiler_messages $arg object {
960 extern int foo (void); extern int bar;
961 int baz (void) { return foo () + bar; }
962 } "-$arg"] {
963 return 1
966 return 0
969 # On AArch64, if -fpic is not supported, then we will fall back to -fPIC
970 # silently. So, we can't rely on above "check_effective_target_fpic" as it
971 # assumes compiler will give warning if -fpic not supported. Here we check
972 # whether binutils supports those new -fpic relocation modifiers, and assume
973 # -fpic is supported if there is binutils support. GCC configuration will
974 # enable -fpic for AArch64 in this case.
976 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
977 # memory model -fpic relocation types.
979 proc check_effective_target_aarch64_small_fpic { } {
980 if { [istarget aarch64*-*-*] } {
981 return [check_no_compiler_messages aarch64_small_fpic object {
982 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
984 } else {
985 return 0
989 # On AArch64, instruction sequence for TLS LE under -mtls-size=32 will utilize
990 # the relocation modifier "tprel_g0_nc" together with MOVK, it's only supported
991 # in binutils since 2015-03-04 as PR gas/17843.
993 # This test directive make sure binutils support all features needed by TLS LE
994 # under -mtls-size=32 on AArch64.
996 proc check_effective_target_aarch64_tlsle32 { } {
997 if { [istarget aarch64*-*-*] } {
998 return [check_no_compiler_messages aarch64_tlsle32 object {
999 void foo (void) { asm ("movk x1,#:tprel_g0_nc:t1"); }
1001 } else {
1002 return 0
1006 # Return 1 if -shared is supported, as in no warnings or errors
1007 # emitted, 0 otherwise.
1009 proc check_effective_target_shared { } {
1010 # Note that M68K has a multilib that supports -fpic but not
1011 # -fPIC, so we need to check both. We test with a program that
1012 # requires GOT references.
1013 return [check_no_compiler_messages shared executable {
1014 extern int foo (void); extern int bar;
1015 int baz (void) { return foo () + bar; }
1016 } "-shared -fpic"]
1019 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
1021 proc check_effective_target_pie { } {
1022 if { [istarget *-*-darwin\[912\]*]
1023 || [istarget *-*-dragonfly*]
1024 || [istarget *-*-freebsd*]
1025 || [istarget *-*-linux*]
1026 || [istarget *-*-gnu*] } {
1027 return 1;
1029 return 0
1032 # Return true if the target supports -mpaired-single (as used on MIPS).
1034 proc check_effective_target_mpaired_single { } {
1035 return [check_no_compiler_messages mpaired_single object {
1036 void foo (void) { }
1037 } "-mpaired-single"]
1040 # Return true if the target has access to FPU instructions.
1042 proc check_effective_target_hard_float { } {
1043 if { [istarget mips*-*-*] } {
1044 return [check_no_compiler_messages hard_float assembly {
1045 #if (defined __mips_soft_float || defined __mips16)
1046 #error __mips_soft_float || __mips16
1047 #endif
1051 # This proc is actually checking the availabilty of FPU
1052 # support for doubles, so on the RX we must fail if the
1053 # 64-bit double multilib has been selected.
1054 if { [istarget rx-*-*] } {
1055 return 0
1056 # return [check_no_compiler_messages hard_float assembly {
1057 #if defined __RX_64_BIT_DOUBLES__
1058 #error __RX_64_BIT_DOUBLES__
1059 #endif
1060 # }]
1063 # The generic test equates hard_float with "no call for adding doubles".
1064 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1065 double a (double b, double c) { return b + c; }
1069 # Return true if the target is a 64-bit MIPS target.
1071 proc check_effective_target_mips64 { } {
1072 return [check_no_compiler_messages mips64 assembly {
1073 #ifndef __mips64
1074 #error !__mips64
1075 #endif
1079 # Return true if the target is a MIPS target that does not produce
1080 # MIPS16 code.
1082 proc check_effective_target_nomips16 { } {
1083 return [check_no_compiler_messages nomips16 object {
1084 #ifndef __mips
1085 #error !__mips
1086 #else
1087 /* A cheap way of testing for -mflip-mips16. */
1088 void foo (void) { asm ("addiu $20,$20,1"); }
1089 void bar (void) { asm ("addiu $20,$20,1"); }
1090 #endif
1094 # Add the options needed for MIPS16 function attributes. At the moment,
1095 # we don't support MIPS16 PIC.
1097 proc add_options_for_mips16_attribute { flags } {
1098 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1101 # Return true if we can force a mode that allows MIPS16 code generation.
1102 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
1103 # for o32 and o64.
1105 proc check_effective_target_mips16_attribute { } {
1106 return [check_no_compiler_messages mips16_attribute assembly {
1107 #ifdef PIC
1108 #error PIC
1109 #endif
1110 #if defined __mips_hard_float \
1111 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1112 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1113 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1114 #endif
1115 } [add_options_for_mips16_attribute ""]]
1118 # Return 1 if the target supports long double larger than double when
1119 # using the new ABI, 0 otherwise.
1121 proc check_effective_target_mips_newabi_large_long_double { } {
1122 return [check_no_compiler_messages mips_newabi_large_long_double object {
1123 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1124 } "-mabi=64"]
1127 # Return true if the target is a MIPS target that has access
1128 # to the LL and SC instructions.
1130 proc check_effective_target_mips_llsc { } {
1131 if { ![istarget mips*-*-*] } {
1132 return 0
1134 # Assume that these instructions are always implemented for
1135 # non-elf* targets, via emulation if necessary.
1136 if { ![istarget *-*-elf*] } {
1137 return 1
1139 # Otherwise assume LL/SC support for everything but MIPS I.
1140 return [check_no_compiler_messages mips_llsc assembly {
1141 #if __mips == 1
1142 #error __mips == 1
1143 #endif
1147 # Return true if the target is a MIPS target that uses in-place relocations.
1149 proc check_effective_target_mips_rel { } {
1150 if { ![istarget mips*-*-*] } {
1151 return 0
1153 return [check_no_compiler_messages mips_rel object {
1154 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1155 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1156 #error _ABIN32 && (_ABIN32 || _ABI64)
1157 #endif
1161 # Return true if the target is a MIPS target that uses the EABI.
1163 proc check_effective_target_mips_eabi { } {
1164 if { ![istarget mips*-*-*] } {
1165 return 0
1167 return [check_no_compiler_messages mips_eabi object {
1168 #ifndef __mips_eabi
1169 #error !__mips_eabi
1170 #endif
1174 # Return 1 if the current multilib does not generate PIC by default.
1176 proc check_effective_target_nonpic { } {
1177 return [check_no_compiler_messages nonpic assembly {
1178 #if __PIC__
1179 #error __PIC__
1180 #endif
1184 # Return 1 if the current multilib generates PIE by default.
1186 proc check_effective_target_pie_enabled { } {
1187 return [check_no_compiler_messages pie_enabled assembly {
1188 #ifndef __PIE__
1189 #error unsupported
1190 #endif
1194 # Return 1 if the target generates -fstack-protector by default.
1196 proc check_effective_target_fstack_protector_enabled {} {
1197 return [ check_no_compiler_messages fstack_protector_enabled assembly {
1198 #if !defined(__SSP__) && !defined(__SSP_ALL__) && \
1199 !defined(__SSP_STRONG__) && !defined(__SSP_EXPICIT__)
1200 #error unsupported
1201 #endif
1205 # Return 1 if the target does not use a status wrapper.
1207 proc check_effective_target_unwrapped { } {
1208 if { [target_info needs_status_wrapper] != "" \
1209 && [target_info needs_status_wrapper] != "0" } {
1210 return 0
1212 return 1
1215 # Return true if iconv is supported on the target. In particular IBM1047.
1217 proc check_iconv_available { test_what } {
1218 global libiconv
1220 # If the tool configuration file has not set libiconv, try "-liconv"
1221 if { ![info exists libiconv] } {
1222 set libiconv "-liconv"
1224 set test_what [lindex $test_what 1]
1225 return [check_runtime_nocache $test_what [subst {
1226 #include <iconv.h>
1227 int main (void)
1229 iconv_t cd;
1231 cd = iconv_open ("$test_what", "UTF-8");
1232 if (cd == (iconv_t) -1)
1233 return 1;
1234 return 0;
1236 }] $libiconv]
1239 # Return true if Cilk Library is supported on the target.
1240 proc check_libcilkrts_available { } {
1241 return [ check_no_compiler_messages_nocache libcilkrts_available executable {
1242 #ifdef __cplusplus
1243 extern "C"
1244 #endif
1245 int __cilkrts_set_param (const char *, const char *);
1246 int main (void) {
1247 int x = __cilkrts_set_param ("nworkers", "0");
1248 return x;
1250 } "-fcilkplus -lcilkrts" ]
1253 # Return true if the atomic library is supported on the target.
1254 proc check_effective_target_libatomic_available { } {
1255 return [check_no_compiler_messages libatomic_available executable {
1256 int main (void) { return 0; }
1257 } "-latomic"]
1260 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1262 proc check_ascii_locale_available { } {
1263 return 1
1266 # Return true if named sections are supported on this target.
1268 proc check_named_sections_available { } {
1269 return [check_no_compiler_messages named_sections assembly {
1270 int __attribute__ ((section("whatever"))) foo;
1274 # Return true if the "naked" function attribute is supported on this target.
1276 proc check_effective_target_naked_functions { } {
1277 return [check_no_compiler_messages naked_functions assembly {
1278 void f() __attribute__((naked));
1282 # Return 1 if the target supports Fortran real kinds larger than real(8),
1283 # 0 otherwise.
1285 # When the target name changes, replace the cached result.
1287 proc check_effective_target_fortran_large_real { } {
1288 return [check_no_compiler_messages fortran_large_real executable {
1289 ! Fortran
1290 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1291 real(kind=k) :: x
1292 x = cos (x)
1297 # Return 1 if the target supports Fortran real kind real(16),
1298 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1299 # this checks for Real(16) only; the other returned real(10) if
1300 # both real(10) and real(16) are available.
1302 # When the target name changes, replace the cached result.
1304 proc check_effective_target_fortran_real_16 { } {
1305 return [check_no_compiler_messages fortran_real_16 executable {
1306 ! Fortran
1307 real(kind=16) :: x
1308 x = cos (x)
1314 # Return 1 if the target supports Fortran's IEEE modules,
1315 # 0 otherwise.
1317 # When the target name changes, replace the cached result.
1319 proc check_effective_target_fortran_ieee { flags } {
1320 return [check_no_compiler_messages fortran_ieee executable {
1321 ! Fortran
1322 use, intrinsic :: ieee_features
1324 } $flags ]
1328 # Return 1 if the target supports SQRT for the largest floating-point
1329 # type. (Some targets lack the libm support for this FP type.)
1330 # On most targets, this check effectively checks either whether sqrtl is
1331 # available or on __float128 systems whether libquadmath is installed,
1332 # which provides sqrtq.
1334 # When the target name changes, replace the cached result.
1336 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1337 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1338 ! Fortran
1339 use iso_fortran_env, only: real_kinds
1340 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1341 real(kind=maxFP), volatile :: x
1342 x = 2.0_maxFP
1343 x = sqrt (x)
1349 # Return 1 if the target supports Fortran integer kinds larger than
1350 # integer(8), 0 otherwise.
1352 # When the target name changes, replace the cached result.
1354 proc check_effective_target_fortran_large_int { } {
1355 return [check_no_compiler_messages fortran_large_int executable {
1356 ! Fortran
1357 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1358 integer(kind=k) :: i
1363 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1365 # When the target name changes, replace the cached result.
1367 proc check_effective_target_fortran_integer_16 { } {
1368 return [check_no_compiler_messages fortran_integer_16 executable {
1369 ! Fortran
1370 integer(16) :: i
1375 # Return 1 if we can statically link libgfortran, 0 otherwise.
1377 # When the target name changes, replace the cached result.
1379 proc check_effective_target_static_libgfortran { } {
1380 return [check_no_compiler_messages static_libgfortran executable {
1381 ! Fortran
1382 print *, 'test'
1384 } "-static"]
1387 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1389 proc check_effective_target_cilkplus { } {
1390 # Skip cilk-plus tests on int16 and size16 targets for now.
1391 # The cilk-plus tests are not generic enough to cover these
1392 # cases and would throw hundreds of FAILs.
1393 if { [check_effective_target_int16]
1394 || ![check_effective_target_size32plus] } {
1395 return 0;
1398 # Skip AVR, its RAM is too small and too many tests would fail.
1399 if { [istarget avr-*-*] } {
1400 return 0;
1402 return 1
1405 proc check_linker_plugin_available { } {
1406 return [check_no_compiler_messages_nocache linker_plugin executable {
1407 int main() { return 0; }
1408 } "-flto -fuse-linker-plugin"]
1411 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1412 # otherwise. Cache the result.
1414 proc check_750cl_hw_available { } {
1415 return [check_cached_effective_target 750cl_hw_available {
1416 # If this is not the right target then we can skip the test.
1417 if { ![istarget powerpc-*paired*] } {
1418 expr 0
1419 } else {
1420 check_runtime_nocache 750cl_hw_available {
1421 int main()
1423 #ifdef __MACH__
1424 asm volatile ("ps_mul v0,v0,v0");
1425 #else
1426 asm volatile ("ps_mul 0,0,0");
1427 #endif
1428 return 0;
1430 } "-mpaired"
1435 # Return 1 if the target OS supports running SSE executables, 0
1436 # otherwise. Cache the result.
1438 proc check_sse_os_support_available { } {
1439 return [check_cached_effective_target sse_os_support_available {
1440 # If this is not the right target then we can skip the test.
1441 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1442 expr 0
1443 } elseif { [istarget i?86-*-solaris2*] } {
1444 # The Solaris 2 kernel doesn't save and restore SSE registers
1445 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1446 check_runtime_nocache sse_os_support_available {
1447 int main ()
1449 asm volatile ("movaps %xmm0,%xmm0");
1450 return 0;
1452 } "-msse"
1453 } else {
1454 expr 1
1459 # Return 1 if the target OS supports running AVX executables, 0
1460 # otherwise. Cache the result.
1462 proc check_avx_os_support_available { } {
1463 return [check_cached_effective_target avx_os_support_available {
1464 # If this is not the right target then we can skip the test.
1465 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1466 expr 0
1467 } else {
1468 # Check that OS has AVX and SSE saving enabled.
1469 check_runtime_nocache avx_os_support_available {
1470 int main ()
1472 unsigned int eax, edx;
1474 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1475 return (eax & 6) != 6;
1477 } ""
1482 # Return 1 if the target supports executing SSE instructions, 0
1483 # otherwise. Cache the result.
1485 proc check_sse_hw_available { } {
1486 return [check_cached_effective_target sse_hw_available {
1487 # If this is not the right target then we can skip the test.
1488 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1489 expr 0
1490 } else {
1491 check_runtime_nocache sse_hw_available {
1492 #include "cpuid.h"
1493 int main ()
1495 unsigned int eax, ebx, ecx, edx;
1496 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1497 return !(edx & bit_SSE);
1498 return 1;
1500 } ""
1505 # Return 1 if the target supports executing SSE2 instructions, 0
1506 # otherwise. Cache the result.
1508 proc check_sse2_hw_available { } {
1509 return [check_cached_effective_target sse2_hw_available {
1510 # If this is not the right target then we can skip the test.
1511 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1512 expr 0
1513 } else {
1514 check_runtime_nocache sse2_hw_available {
1515 #include "cpuid.h"
1516 int main ()
1518 unsigned int eax, ebx, ecx, edx;
1519 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1520 return !(edx & bit_SSE2);
1521 return 1;
1523 } ""
1528 # Return 1 if the target supports executing AVX instructions, 0
1529 # otherwise. Cache the result.
1531 proc check_avx_hw_available { } {
1532 return [check_cached_effective_target avx_hw_available {
1533 # If this is not the right target then we can skip the test.
1534 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1535 expr 0
1536 } else {
1537 check_runtime_nocache avx_hw_available {
1538 #include "cpuid.h"
1539 int main ()
1541 unsigned int eax, ebx, ecx, edx;
1542 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1543 return ((ecx & (bit_AVX | bit_OSXSAVE))
1544 != (bit_AVX | bit_OSXSAVE));
1545 return 1;
1547 } ""
1552 # Return 1 if the target supports running SSE executables, 0 otherwise.
1554 proc check_effective_target_sse_runtime { } {
1555 if { [check_effective_target_sse]
1556 && [check_sse_hw_available]
1557 && [check_sse_os_support_available] } {
1558 return 1
1560 return 0
1563 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1565 proc check_effective_target_sse2_runtime { } {
1566 if { [check_effective_target_sse2]
1567 && [check_sse2_hw_available]
1568 && [check_sse_os_support_available] } {
1569 return 1
1571 return 0
1574 # Return 1 if the target supports running AVX executables, 0 otherwise.
1576 proc check_effective_target_avx_runtime { } {
1577 if { [check_effective_target_avx]
1578 && [check_avx_hw_available]
1579 && [check_avx_os_support_available] } {
1580 return 1
1582 return 0
1585 # Return 1 if the target supports executing power8 vector instructions, 0
1586 # otherwise. Cache the result.
1588 proc check_p8vector_hw_available { } {
1589 return [check_cached_effective_target p8vector_hw_available {
1590 # Some simulators are known to not support VSX/power8 instructions.
1591 # For now, disable on Darwin
1592 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1593 expr 0
1594 } else {
1595 set options "-mpower8-vector"
1596 check_runtime_nocache p8vector_hw_available {
1597 int main()
1599 #ifdef __MACH__
1600 asm volatile ("xxlorc vs0,vs0,vs0");
1601 #else
1602 asm volatile ("xxlorc 0,0,0");
1603 #endif
1604 return 0;
1606 } $options
1611 # Return 1 if the target supports executing VSX instructions, 0
1612 # otherwise. Cache the result.
1614 proc check_vsx_hw_available { } {
1615 return [check_cached_effective_target vsx_hw_available {
1616 # Some simulators are known to not support VSX instructions.
1617 # For now, disable on Darwin
1618 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1619 expr 0
1620 } else {
1621 set options "-mvsx"
1622 check_runtime_nocache vsx_hw_available {
1623 int main()
1625 #ifdef __MACH__
1626 asm volatile ("xxlor vs0,vs0,vs0");
1627 #else
1628 asm volatile ("xxlor 0,0,0");
1629 #endif
1630 return 0;
1632 } $options
1637 # Return 1 if the target supports executing AltiVec instructions, 0
1638 # otherwise. Cache the result.
1640 proc check_vmx_hw_available { } {
1641 return [check_cached_effective_target vmx_hw_available {
1642 # Some simulators are known to not support VMX instructions.
1643 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1644 expr 0
1645 } else {
1646 # Most targets don't require special flags for this test case, but
1647 # Darwin does. Just to be sure, make sure VSX is not enabled for
1648 # the altivec tests.
1649 if { [istarget *-*-darwin*]
1650 || [istarget *-*-aix*] } {
1651 set options "-maltivec -mno-vsx"
1652 } else {
1653 set options "-mno-vsx"
1655 check_runtime_nocache vmx_hw_available {
1656 int main()
1658 #ifdef __MACH__
1659 asm volatile ("vor v0,v0,v0");
1660 #else
1661 asm volatile ("vor 0,0,0");
1662 #endif
1663 return 0;
1665 } $options
1670 proc check_ppc_recip_hw_available { } {
1671 return [check_cached_effective_target ppc_recip_hw_available {
1672 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1673 # For now, disable on Darwin
1674 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1675 expr 0
1676 } else {
1677 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1678 check_runtime_nocache ppc_recip_hw_available {
1679 volatile double d_recip, d_rsqrt, d_four = 4.0;
1680 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1681 int main()
1683 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1684 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1685 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1686 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1687 return 0;
1689 } $options
1694 # Return 1 if the target supports executing AltiVec and Cell PPU
1695 # instructions, 0 otherwise. Cache the result.
1697 proc check_effective_target_cell_hw { } {
1698 return [check_cached_effective_target cell_hw_available {
1699 # Some simulators are known to not support VMX and PPU instructions.
1700 if { [istarget powerpc-*-eabi*] } {
1701 expr 0
1702 } else {
1703 # Most targets don't require special flags for this test
1704 # case, but Darwin and AIX do.
1705 if { [istarget *-*-darwin*]
1706 || [istarget *-*-aix*] } {
1707 set options "-maltivec -mcpu=cell"
1708 } else {
1709 set options "-mcpu=cell"
1711 check_runtime_nocache cell_hw_available {
1712 int main()
1714 #ifdef __MACH__
1715 asm volatile ("vor v0,v0,v0");
1716 asm volatile ("lvlx v0,r0,r0");
1717 #else
1718 asm volatile ("vor 0,0,0");
1719 asm volatile ("lvlx 0,0,0");
1720 #endif
1721 return 0;
1723 } $options
1728 # Return 1 if the target supports executing 64-bit instructions, 0
1729 # otherwise. Cache the result.
1731 proc check_effective_target_powerpc64 { } {
1732 global powerpc64_available_saved
1733 global tool
1735 if [info exists powerpc64_available_saved] {
1736 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1737 } else {
1738 set powerpc64_available_saved 0
1740 # Some simulators are known to not support powerpc64 instructions.
1741 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1742 verbose "check_effective_target_powerpc64 returning 0" 2
1743 return $powerpc64_available_saved
1746 # Set up, compile, and execute a test program containing a 64-bit
1747 # instruction. Include the current process ID in the file
1748 # names to prevent conflicts with invocations for multiple
1749 # testsuites.
1750 set src ppc[pid].c
1751 set exe ppc[pid].x
1753 set f [open $src "w"]
1754 puts $f "int main() {"
1755 puts $f "#ifdef __MACH__"
1756 puts $f " asm volatile (\"extsw r0,r0\");"
1757 puts $f "#else"
1758 puts $f " asm volatile (\"extsw 0,0\");"
1759 puts $f "#endif"
1760 puts $f " return 0; }"
1761 close $f
1763 set opts "additional_flags=-mcpu=G5"
1765 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1766 set lines [${tool}_target_compile $src $exe executable "$opts"]
1767 file delete $src
1769 if [string match "" $lines] then {
1770 # No error message, compilation succeeded.
1771 set result [${tool}_load "./$exe" "" ""]
1772 set status [lindex $result 0]
1773 remote_file build delete $exe
1774 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1776 if { $status == "pass" } then {
1777 set powerpc64_available_saved 1
1779 } else {
1780 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1784 return $powerpc64_available_saved
1787 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1788 # complex float arguments. This affects gfortran tests that call cabsf
1789 # in libm built by an earlier compiler. Return 1 if libm uses the same
1790 # argument passing as the compiler under test, 0 otherwise.
1792 # When the target name changes, replace the cached result.
1794 proc check_effective_target_broken_cplxf_arg { } {
1795 return [check_cached_effective_target broken_cplxf_arg {
1796 # Skip the work for targets known not to be affected.
1797 if { ![istarget powerpc64-*-linux*] } {
1798 expr 0
1799 } elseif { ![is-effective-target lp64] } {
1800 expr 0
1801 } else {
1802 check_runtime_nocache broken_cplxf_arg {
1803 #include <complex.h>
1804 extern void abort (void);
1805 float fabsf (float);
1806 float cabsf (_Complex float);
1807 int main ()
1809 _Complex float cf;
1810 float f;
1811 cf = 3 + 4.0fi;
1812 f = cabsf (cf);
1813 if (fabsf (f - 5.0) > 0.0001)
1814 abort ();
1815 return 0;
1817 } "-lm"
1822 # Return 1 is this is a TI C6X target supporting C67X instructions
1823 proc check_effective_target_ti_c67x { } {
1824 return [check_no_compiler_messages ti_c67x assembly {
1825 #if !defined(_TMS320C6700)
1826 #error !_TMS320C6700
1827 #endif
1831 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1832 proc check_effective_target_ti_c64xp { } {
1833 return [check_no_compiler_messages ti_c64xp assembly {
1834 #if !defined(_TMS320C6400_PLUS)
1835 #error !_TMS320C6400_PLUS
1836 #endif
1841 proc check_alpha_max_hw_available { } {
1842 return [check_runtime alpha_max_hw_available {
1843 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1847 # Returns true iff the FUNCTION is available on the target system.
1848 # (This is essentially a Tcl implementation of Autoconf's
1849 # AC_CHECK_FUNC.)
1851 proc check_function_available { function } {
1852 return [check_no_compiler_messages ${function}_available \
1853 executable [subst {
1854 #ifdef __cplusplus
1855 extern "C"
1856 #endif
1857 char $function ();
1858 int main () { $function (); }
1859 }] "-fno-builtin" ]
1862 # Returns true iff "fork" is available on the target system.
1864 proc check_fork_available {} {
1865 return [check_function_available "fork"]
1868 # Returns true iff "mkfifo" is available on the target system.
1870 proc check_mkfifo_available {} {
1871 if { [istarget *-*-cygwin*] } {
1872 # Cygwin has mkfifo, but support is incomplete.
1873 return 0
1876 return [check_function_available "mkfifo"]
1879 # Returns true iff "__cxa_atexit" is used on the target system.
1881 proc check_cxa_atexit_available { } {
1882 return [check_cached_effective_target cxa_atexit_available {
1883 if { [istarget hppa*-*-hpux10*] } {
1884 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1885 expr 0
1886 } elseif { [istarget *-*-vxworks] } {
1887 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1888 expr 0
1889 } else {
1890 check_runtime_nocache cxa_atexit_available {
1891 // C++
1892 #include <stdlib.h>
1893 static unsigned int count;
1894 struct X
1896 X() { count = 1; }
1897 ~X()
1899 if (count != 3)
1900 exit(1);
1901 count = 4;
1904 void f()
1906 static X x;
1908 struct Y
1910 Y() { f(); count = 2; }
1911 ~Y()
1913 if (count != 2)
1914 exit(1);
1915 count = 3;
1918 Y y;
1919 int main() { return 0; }
1925 proc check_effective_target_objc2 { } {
1926 return [check_no_compiler_messages objc2 object {
1927 #ifdef __OBJC2__
1928 int dummy[1];
1929 #else
1930 #error !__OBJC2__
1931 #endif
1935 proc check_effective_target_next_runtime { } {
1936 return [check_no_compiler_messages objc2 object {
1937 #ifdef __NEXT_RUNTIME__
1938 int dummy[1];
1939 #else
1940 #error !__NEXT_RUNTIME__
1941 #endif
1945 # Return 1 if we're generating 32-bit code using default options, 0
1946 # otherwise.
1948 proc check_effective_target_ilp32 { } {
1949 return [check_no_compiler_messages ilp32 object {
1950 int dummy[sizeof (int) == 4
1951 && sizeof (void *) == 4
1952 && sizeof (long) == 4 ? 1 : -1];
1956 # Return 1 if we're generating ia32 code using default options, 0
1957 # otherwise.
1959 proc check_effective_target_ia32 { } {
1960 return [check_no_compiler_messages ia32 object {
1961 int dummy[sizeof (int) == 4
1962 && sizeof (void *) == 4
1963 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1967 # Return 1 if we're generating x32 code using default options, 0
1968 # otherwise.
1970 proc check_effective_target_x32 { } {
1971 return [check_no_compiler_messages x32 object {
1972 int dummy[sizeof (int) == 4
1973 && sizeof (void *) == 4
1974 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1978 # Return 1 if we're generating 32-bit integers using default
1979 # options, 0 otherwise.
1981 proc check_effective_target_int32 { } {
1982 return [check_no_compiler_messages int32 object {
1983 int dummy[sizeof (int) == 4 ? 1 : -1];
1987 # Return 1 if we're generating 32-bit or larger integers using default
1988 # options, 0 otherwise.
1990 proc check_effective_target_int32plus { } {
1991 return [check_no_compiler_messages int32plus object {
1992 int dummy[sizeof (int) >= 4 ? 1 : -1];
1996 # Return 1 if we're generating 32-bit or larger pointers using default
1997 # options, 0 otherwise.
1999 proc check_effective_target_ptr32plus { } {
2000 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
2001 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
2002 # cannot really hold a 32-bit address, so we always return false here.
2003 if { [istarget msp430-*-*] } {
2004 return 0
2007 return [check_no_compiler_messages ptr32plus object {
2008 int dummy[sizeof (void *) >= 4 ? 1 : -1];
2012 # Return 1 if we support 32-bit or larger array and structure sizes
2013 # using default options, 0 otherwise. Avoid false positive on
2014 # targets with 20 or 24 bit address spaces.
2016 proc check_effective_target_size32plus { } {
2017 return [check_no_compiler_messages size32plus object {
2018 char dummy[16777217L];
2022 # Returns 1 if we're generating 16-bit or smaller integers with the
2023 # default options, 0 otherwise.
2025 proc check_effective_target_int16 { } {
2026 return [check_no_compiler_messages int16 object {
2027 int dummy[sizeof (int) < 4 ? 1 : -1];
2031 # Return 1 if we're generating 64-bit code using default options, 0
2032 # otherwise.
2034 proc check_effective_target_lp64 { } {
2035 return [check_no_compiler_messages lp64 object {
2036 int dummy[sizeof (int) == 4
2037 && sizeof (void *) == 8
2038 && sizeof (long) == 8 ? 1 : -1];
2042 # Return 1 if we're generating 64-bit code using default llp64 options,
2043 # 0 otherwise.
2045 proc check_effective_target_llp64 { } {
2046 return [check_no_compiler_messages llp64 object {
2047 int dummy[sizeof (int) == 4
2048 && sizeof (void *) == 8
2049 && sizeof (long long) == 8
2050 && sizeof (long) == 4 ? 1 : -1];
2054 # Return 1 if long and int have different sizes,
2055 # 0 otherwise.
2057 proc check_effective_target_long_neq_int { } {
2058 return [check_no_compiler_messages long_ne_int object {
2059 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2063 # Return 1 if the target supports long double larger than double,
2064 # 0 otherwise.
2066 proc check_effective_target_large_long_double { } {
2067 return [check_no_compiler_messages large_long_double object {
2068 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2072 # Return 1 if the target supports double larger than float,
2073 # 0 otherwise.
2075 proc check_effective_target_large_double { } {
2076 return [check_no_compiler_messages large_double object {
2077 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2081 # Return 1 if the target supports long double of 128 bits,
2082 # 0 otherwise.
2084 proc check_effective_target_longdouble128 { } {
2085 return [check_no_compiler_messages longdouble128 object {
2086 int dummy[sizeof(long double) == 16 ? 1 : -1];
2090 # Return 1 if the target supports double of 64 bits,
2091 # 0 otherwise.
2093 proc check_effective_target_double64 { } {
2094 return [check_no_compiler_messages double64 object {
2095 int dummy[sizeof(double) == 8 ? 1 : -1];
2099 # Return 1 if the target supports double of at least 64 bits,
2100 # 0 otherwise.
2102 proc check_effective_target_double64plus { } {
2103 return [check_no_compiler_messages double64plus object {
2104 int dummy[sizeof(double) >= 8 ? 1 : -1];
2108 # Return 1 if the target supports 'w' suffix on floating constant
2109 # 0 otherwise.
2111 proc check_effective_target_has_w_floating_suffix { } {
2112 set opts ""
2113 if [check_effective_target_c++] {
2114 append opts "-std=gnu++03"
2116 return [check_no_compiler_messages w_fp_suffix object {
2117 float dummy = 1.0w;
2118 } "$opts"]
2121 # Return 1 if the target supports 'q' suffix on floating constant
2122 # 0 otherwise.
2124 proc check_effective_target_has_q_floating_suffix { } {
2125 set opts ""
2126 if [check_effective_target_c++] {
2127 append opts "-std=gnu++03"
2129 return [check_no_compiler_messages q_fp_suffix object {
2130 float dummy = 1.0q;
2131 } "$opts"]
2133 # Return 1 if the target supports compiling fixed-point,
2134 # 0 otherwise.
2136 proc check_effective_target_fixed_point { } {
2137 return [check_no_compiler_messages fixed_point object {
2138 _Sat _Fract x; _Sat _Accum y;
2142 # Return 1 if the target supports compiling decimal floating point,
2143 # 0 otherwise.
2145 proc check_effective_target_dfp_nocache { } {
2146 verbose "check_effective_target_dfp_nocache: compiling source" 2
2147 set ret [check_no_compiler_messages_nocache dfp object {
2148 float x __attribute__((mode(DD)));
2150 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2151 return $ret
2154 proc check_effective_target_dfprt_nocache { } {
2155 return [check_runtime_nocache dfprt {
2156 typedef float d64 __attribute__((mode(DD)));
2157 d64 x = 1.2df, y = 2.3dd, z;
2158 int main () { z = x + y; return 0; }
2162 # Return 1 if the target supports compiling Decimal Floating Point,
2163 # 0 otherwise.
2165 # This won't change for different subtargets so cache the result.
2167 proc check_effective_target_dfp { } {
2168 return [check_cached_effective_target dfp {
2169 check_effective_target_dfp_nocache
2173 # Return 1 if the target supports linking and executing Decimal Floating
2174 # Point, 0 otherwise.
2176 # This won't change for different subtargets so cache the result.
2178 proc check_effective_target_dfprt { } {
2179 return [check_cached_effective_target dfprt {
2180 check_effective_target_dfprt_nocache
2184 # Return 1 if the target supports executing DFP hardware instructions,
2185 # 0 otherwise. Cache the result.
2187 proc check_dfp_hw_available { } {
2188 return [check_cached_effective_target dfp_hw_available {
2189 # For now, disable on Darwin
2190 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2191 expr 0
2192 } else {
2193 check_runtime_nocache dfp_hw_available {
2194 volatile _Decimal64 r;
2195 volatile _Decimal64 a = 4.0DD;
2196 volatile _Decimal64 b = 2.0DD;
2197 int main()
2199 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2200 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2201 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2202 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2203 return 0;
2205 } "-mcpu=power6 -mhard-float"
2210 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2212 proc check_effective_target_ucn_nocache { } {
2213 # -std=c99 is only valid for C
2214 if [check_effective_target_c] {
2215 set ucnopts "-std=c99"
2216 } else {
2217 set ucnopts ""
2219 verbose "check_effective_target_ucn_nocache: compiling source" 2
2220 set ret [check_no_compiler_messages_nocache ucn object {
2221 int \u00C0;
2222 } $ucnopts]
2223 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2224 return $ret
2227 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2229 # This won't change for different subtargets, so cache the result.
2231 proc check_effective_target_ucn { } {
2232 return [check_cached_effective_target ucn {
2233 check_effective_target_ucn_nocache
2237 # Return 1 if the target needs a command line argument to enable a SIMD
2238 # instruction set.
2240 proc check_effective_target_vect_cmdline_needed { } {
2241 global et_vect_cmdline_needed_saved
2242 global et_vect_cmdline_needed_target_name
2244 if { ![info exists et_vect_cmdline_needed_target_name] } {
2245 set et_vect_cmdline_needed_target_name ""
2248 # If the target has changed since we set the cached value, clear it.
2249 set current_target [current_target_name]
2250 if { $current_target != $et_vect_cmdline_needed_target_name } {
2251 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2252 set et_vect_cmdline_needed_target_name $current_target
2253 if { [info exists et_vect_cmdline_needed_saved] } {
2254 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
2255 unset et_vect_cmdline_needed_saved
2259 if [info exists et_vect_cmdline_needed_saved] {
2260 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2261 } else {
2262 set et_vect_cmdline_needed_saved 1
2263 if { [istarget alpha*-*-*]
2264 || [istarget ia64-*-*]
2265 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
2266 && ([check_effective_target_x32]
2267 || [check_effective_target_lp64]))
2268 || ([istarget powerpc*-*-*]
2269 && ([check_effective_target_powerpc_spe]
2270 || [check_effective_target_powerpc_altivec]))
2271 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2272 || [istarget spu-*-*]
2273 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2274 || [istarget aarch64*-*-*] } {
2275 set et_vect_cmdline_needed_saved 0
2279 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2280 return $et_vect_cmdline_needed_saved
2283 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2285 # This won't change for different subtargets so cache the result.
2287 proc check_effective_target_vect_int { } {
2288 global et_vect_int_saved
2290 if [info exists et_vect_int_saved] {
2291 verbose "check_effective_target_vect_int: using cached result" 2
2292 } else {
2293 set et_vect_int_saved 0
2294 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2295 || ([istarget powerpc*-*-*]
2296 && ![istarget powerpc-*-linux*paired*])
2297 || [istarget spu-*-*]
2298 || [istarget sparc*-*-*]
2299 || [istarget alpha*-*-*]
2300 || [istarget ia64-*-*]
2301 || [istarget aarch64*-*-*]
2302 || [check_effective_target_arm32]
2303 || ([istarget mips*-*-*]
2304 && [check_effective_target_mips_loongson]) } {
2305 set et_vect_int_saved 1
2309 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2310 return $et_vect_int_saved
2313 # Return 1 if the target supports signed int->float conversion
2316 proc check_effective_target_vect_intfloat_cvt { } {
2317 global et_vect_intfloat_cvt_saved
2319 if [info exists et_vect_intfloat_cvt_saved] {
2320 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2321 } else {
2322 set et_vect_intfloat_cvt_saved 0
2323 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2324 || ([istarget powerpc*-*-*]
2325 && ![istarget powerpc-*-linux*paired*])
2326 || ([istarget arm*-*-*]
2327 && [check_effective_target_arm_neon_ok])} {
2328 set et_vect_intfloat_cvt_saved 1
2332 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2333 return $et_vect_intfloat_cvt_saved
2336 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2338 proc check_effective_target_int128 { } {
2339 return [check_no_compiler_messages int128 object {
2340 int dummy[
2341 #ifndef __SIZEOF_INT128__
2343 #else
2345 #endif
2350 # Return 1 if the target supports unsigned int->float conversion
2353 proc check_effective_target_vect_uintfloat_cvt { } {
2354 global et_vect_uintfloat_cvt_saved
2356 if [info exists et_vect_uintfloat_cvt_saved] {
2357 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2358 } else {
2359 set et_vect_uintfloat_cvt_saved 0
2360 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2361 || ([istarget powerpc*-*-*]
2362 && ![istarget powerpc-*-linux*paired*])
2363 || [istarget aarch64*-*-*]
2364 || ([istarget arm*-*-*]
2365 && [check_effective_target_arm_neon_ok])} {
2366 set et_vect_uintfloat_cvt_saved 1
2370 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2371 return $et_vect_uintfloat_cvt_saved
2375 # Return 1 if the target supports signed float->int conversion
2378 proc check_effective_target_vect_floatint_cvt { } {
2379 global et_vect_floatint_cvt_saved
2381 if [info exists et_vect_floatint_cvt_saved] {
2382 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2383 } else {
2384 set et_vect_floatint_cvt_saved 0
2385 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2386 || ([istarget powerpc*-*-*]
2387 && ![istarget powerpc-*-linux*paired*])
2388 || ([istarget arm*-*-*]
2389 && [check_effective_target_arm_neon_ok])} {
2390 set et_vect_floatint_cvt_saved 1
2394 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2395 return $et_vect_floatint_cvt_saved
2398 # Return 1 if the target supports unsigned float->int conversion
2401 proc check_effective_target_vect_floatuint_cvt { } {
2402 global et_vect_floatuint_cvt_saved
2404 if [info exists et_vect_floatuint_cvt_saved] {
2405 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2406 } else {
2407 set et_vect_floatuint_cvt_saved 0
2408 if { ([istarget powerpc*-*-*]
2409 && ![istarget powerpc-*-linux*paired*])
2410 || ([istarget arm*-*-*]
2411 && [check_effective_target_arm_neon_ok])} {
2412 set et_vect_floatuint_cvt_saved 1
2416 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2417 return $et_vect_floatuint_cvt_saved
2420 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2422 # This won't change for different subtargets so cache the result.
2424 proc check_effective_target_vect_simd_clones { } {
2425 global et_vect_simd_clones_saved
2427 if [info exists et_vect_simd_clones_saved] {
2428 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2429 } else {
2430 set et_vect_simd_clones_saved 0
2431 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2432 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and
2433 # avx2 clone. Only the right clone for the specified arch will be
2434 # chosen, but still we need to at least be able to assemble
2435 # avx2.
2436 if { [check_effective_target_avx2] } {
2437 set et_vect_simd_clones_saved 1
2442 verbose "check_effective_target_vect_simd_clones: returning $et_vect_simd_clones_saved" 2
2443 return $et_vect_simd_clones_saved
2446 # Return 1 if this is a AArch64 target supporting big endian
2447 proc check_effective_target_aarch64_big_endian { } {
2448 return [check_no_compiler_messages aarch64_big_endian assembly {
2449 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2450 #error !__aarch64__ || !__AARCH64EB__
2451 #endif
2455 # Return 1 if this is a AArch64 target supporting little endian
2456 proc check_effective_target_aarch64_little_endian { } {
2457 if { ![istarget aarch64*-*-*] } {
2458 return 0
2461 return [check_no_compiler_messages aarch64_little_endian assembly {
2462 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2463 #error FOO
2464 #endif
2468 # Return 1 if this is an arm target using 32-bit instructions
2469 proc check_effective_target_arm32 { } {
2470 if { ![istarget arm*-*-*] } {
2471 return 0
2474 return [check_no_compiler_messages arm32 assembly {
2475 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2476 #error !__arm || __thumb__ && !__thumb2__
2477 #endif
2481 # Return 1 if this is an arm target not using Thumb
2482 proc check_effective_target_arm_nothumb { } {
2483 if { ![istarget arm*-*-*] } {
2484 return 0
2487 return [check_no_compiler_messages arm_nothumb assembly {
2488 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
2489 #error !__arm__ || __thumb || __thumb2__
2490 #endif
2494 # Return 1 if this is a little-endian ARM target
2495 proc check_effective_target_arm_little_endian { } {
2496 if { ![istarget arm*-*-*] } {
2497 return 0
2500 return [check_no_compiler_messages arm_little_endian assembly {
2501 #if !defined(__arm__) || !defined(__ARMEL__)
2502 #error !__arm__ || !__ARMEL__
2503 #endif
2507 # Return 1 if this is an ARM target that only supports aligned vector accesses
2508 proc check_effective_target_arm_vect_no_misalign { } {
2509 if { ![istarget arm*-*-*] } {
2510 return 0
2513 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2514 #if !defined(__arm__) \
2515 || (defined(__ARM_FEATURE_UNALIGNED) \
2516 && defined(__ARMEL__))
2517 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
2518 #endif
2523 # Return 1 if this is an ARM target supporting -mfpu=vfp
2524 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2525 # options.
2527 proc check_effective_target_arm_vfp_ok { } {
2528 if { [check_effective_target_arm32] } {
2529 return [check_no_compiler_messages arm_vfp_ok object {
2530 int dummy;
2531 } "-mfpu=vfp -mfloat-abi=softfp"]
2532 } else {
2533 return 0
2537 # Return 1 if this is an ARM target supporting -mfpu=vfp3
2538 # -mfloat-abi=softfp.
2540 proc check_effective_target_arm_vfp3_ok { } {
2541 if { [check_effective_target_arm32] } {
2542 return [check_no_compiler_messages arm_vfp3_ok object {
2543 int dummy;
2544 } "-mfpu=vfp3 -mfloat-abi=softfp"]
2545 } else {
2546 return 0
2550 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2551 # -mfloat-abi=softfp.
2552 proc check_effective_target_arm_v8_vfp_ok {} {
2553 if { [check_effective_target_arm32] } {
2554 return [check_no_compiler_messages arm_v8_vfp_ok object {
2555 int foo (void)
2557 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2558 return 0;
2560 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2561 } else {
2562 return 0
2566 # Return 1 if this is an ARM target supporting -mfpu=vfp
2567 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2568 # options.
2570 proc check_effective_target_arm_hard_vfp_ok { } {
2571 if { [check_effective_target_arm32]
2572 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2573 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2574 int main() { return 0;}
2575 } "-mfpu=vfp -mfloat-abi=hard"]
2576 } else {
2577 return 0
2581 # Return 1 if this is an ARM target that supports DSP multiply with
2582 # current multilib flags.
2584 proc check_effective_target_arm_dsp { } {
2585 return [check_no_compiler_messages arm_dsp assembly {
2586 #ifndef __ARM_FEATURE_DSP
2587 #error not DSP
2588 #endif
2589 int i;
2593 # Return 1 if this is an ARM target that supports unaligned word/halfword
2594 # load/store instructions.
2596 proc check_effective_target_arm_unaligned { } {
2597 return [check_no_compiler_messages arm_unaligned assembly {
2598 #ifndef __ARM_FEATURE_UNALIGNED
2599 #error no unaligned support
2600 #endif
2601 int i;
2605 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2606 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2607 # incompatible with these options. Also set et_arm_crypto_flags to the
2608 # best options to add.
2610 proc check_effective_target_arm_crypto_ok_nocache { } {
2611 global et_arm_crypto_flags
2612 set et_arm_crypto_flags ""
2613 if { [check_effective_target_arm32] } {
2614 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2615 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2616 #include "arm_neon.h"
2617 uint8x16_t
2618 foo (uint8x16_t a, uint8x16_t b)
2620 return vaeseq_u8 (a, b);
2622 } "$flags"] } {
2623 set et_arm_crypto_flags $flags
2624 return 1
2629 return 0
2632 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2634 proc check_effective_target_arm_crypto_ok { } {
2635 return [check_cached_effective_target arm_crypto_ok \
2636 check_effective_target_arm_crypto_ok_nocache]
2639 # Add options for crypto extensions.
2640 proc add_options_for_arm_crypto { flags } {
2641 if { ! [check_effective_target_arm_crypto_ok] } {
2642 return "$flags"
2644 global et_arm_crypto_flags
2645 return "$flags $et_arm_crypto_flags"
2648 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2649 # or -mfloat-abi=hard, but if one is already specified by the
2650 # multilib, use it. Similarly, if a -mfpu option already enables
2651 # NEON, do not add -mfpu=neon.
2653 proc add_options_for_arm_neon { flags } {
2654 if { ! [check_effective_target_arm_neon_ok] } {
2655 return "$flags"
2657 global et_arm_neon_flags
2658 return "$flags $et_arm_neon_flags"
2661 proc add_options_for_arm_v8_vfp { flags } {
2662 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2663 return "$flags"
2665 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2668 proc add_options_for_arm_v8_neon { flags } {
2669 if { ! [check_effective_target_arm_v8_neon_ok] } {
2670 return "$flags"
2672 global et_arm_v8_neon_flags
2673 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2676 proc add_options_for_arm_crc { flags } {
2677 if { ! [check_effective_target_arm_crc_ok] } {
2678 return "$flags"
2680 global et_arm_crc_flags
2681 return "$flags $et_arm_crc_flags"
2684 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2685 # or -mfloat-abi=hard, but if one is already specified by the
2686 # multilib, use it. Similarly, if a -mfpu option already enables
2687 # NEON, do not add -mfpu=neon.
2689 proc add_options_for_arm_neonv2 { flags } {
2690 if { ! [check_effective_target_arm_neonv2_ok] } {
2691 return "$flags"
2693 global et_arm_neonv2_flags
2694 return "$flags $et_arm_neonv2_flags"
2697 # Add the options needed for vfp3.
2698 proc add_options_for_arm_vfp3 { flags } {
2699 if { ! [check_effective_target_arm_vfp3_ok] } {
2700 return "$flags"
2702 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
2705 # Return 1 if this is an ARM target supporting -mfpu=neon
2706 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2707 # incompatible with these options. Also set et_arm_neon_flags to the
2708 # best options to add.
2710 proc check_effective_target_arm_neon_ok_nocache { } {
2711 global et_arm_neon_flags
2712 set et_arm_neon_flags ""
2713 if { [check_effective_target_arm32] } {
2714 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2715 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2716 #include "arm_neon.h"
2717 int dummy;
2718 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
2719 configured for -mcpu=arm926ej-s, for example. */
2720 #if __ARM_ARCH < 7
2721 #error Architecture too old for NEON.
2722 #endif
2723 } "$flags"] } {
2724 set et_arm_neon_flags $flags
2725 return 1
2730 return 0
2733 proc check_effective_target_arm_neon_ok { } {
2734 return [check_cached_effective_target arm_neon_ok \
2735 check_effective_target_arm_neon_ok_nocache]
2738 proc check_effective_target_arm_crc_ok_nocache { } {
2739 global et_arm_crc_flags
2740 set et_arm_crc_flags "-march=armv8-a+crc"
2741 return [check_no_compiler_messages_nocache arm_crc_ok object {
2742 #if !defined (__ARM_FEATURE_CRC32)
2743 #error FOO
2744 #endif
2745 } "$et_arm_crc_flags"]
2748 proc check_effective_target_arm_crc_ok { } {
2749 return [check_cached_effective_target arm_crc_ok \
2750 check_effective_target_arm_crc_ok_nocache]
2753 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2754 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2755 # incompatible with these options. Also set et_arm_neon_flags to the
2756 # best options to add.
2758 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2759 global et_arm_neon_fp16_flags
2760 set et_arm_neon_fp16_flags ""
2761 if { [check_effective_target_arm32] } {
2762 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2763 "-mfpu=neon-fp16 -mfloat-abi=softfp"
2764 "-mfp16-format=ieee"
2765 "-mfloat-abi=softfp -mfp16-format=ieee"
2766 "-mfpu=neon-fp16 -mfp16-format=ieee"
2767 "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
2768 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2769 #include "arm_neon.h"
2770 float16x4_t
2771 foo (float32x4_t arg)
2773 return vcvt_f16_f32 (arg);
2775 } "$flags"] } {
2776 set et_arm_neon_fp16_flags $flags
2777 return 1
2782 return 0
2785 proc check_effective_target_arm_neon_fp16_ok { } {
2786 return [check_cached_effective_target arm_neon_fp16_ok \
2787 check_effective_target_arm_neon_fp16_ok_nocache]
2790 proc add_options_for_arm_neon_fp16 { flags } {
2791 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2792 return "$flags"
2794 global et_arm_neon_fp16_flags
2795 return "$flags $et_arm_neon_fp16_flags"
2798 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2799 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2800 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2801 # best options to add.
2803 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2804 global et_arm_v8_neon_flags
2805 set et_arm_v8_neon_flags ""
2806 if { [check_effective_target_arm32] } {
2807 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2808 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2809 #if __ARM_ARCH < 8
2810 #error not armv8 or later
2811 #endif
2812 #include "arm_neon.h"
2813 void
2814 foo ()
2816 __asm__ volatile ("vrintn.f32 q0, q0");
2818 } "$flags -march=armv8-a"] } {
2819 set et_arm_v8_neon_flags $flags
2820 return 1
2825 return 0
2828 proc check_effective_target_arm_v8_neon_ok { } {
2829 return [check_cached_effective_target arm_v8_neon_ok \
2830 check_effective_target_arm_v8_neon_ok_nocache]
2833 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2834 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2835 # incompatible with these options. Also set et_arm_neonv2_flags to the
2836 # best options to add.
2838 proc check_effective_target_arm_neonv2_ok_nocache { } {
2839 global et_arm_neonv2_flags
2840 set et_arm_neonv2_flags ""
2841 if { [check_effective_target_arm32] } {
2842 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2843 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2844 #include "arm_neon.h"
2845 float32x2_t
2846 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2848 return vfma_f32 (a, b, c);
2850 } "$flags"] } {
2851 set et_arm_neonv2_flags $flags
2852 return 1
2857 return 0
2860 proc check_effective_target_arm_neonv2_ok { } {
2861 return [check_cached_effective_target arm_neonv2_ok \
2862 check_effective_target_arm_neonv2_ok_nocache]
2865 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2866 # or -mfloat-abi=hard, but if one is already specified by the
2867 # multilib, use it.
2869 proc add_options_for_arm_fp16 { flags } {
2870 if { ! [check_effective_target_arm_fp16_ok] } {
2871 return "$flags"
2873 global et_arm_fp16_flags
2874 return "$flags $et_arm_fp16_flags"
2877 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2878 # Skip multilibs that are incompatible with these options and set
2879 # et_arm_fp16_flags to the best options to add.
2881 proc check_effective_target_arm_fp16_ok_nocache { } {
2882 global et_arm_fp16_flags
2883 set et_arm_fp16_flags ""
2884 if { ! [check_effective_target_arm32] } {
2885 return 0;
2887 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2888 # Multilib flags would override -mfpu.
2889 return 0
2891 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2892 # Must generate floating-point instructions.
2893 return 0
2895 if [check_effective_target_arm_hf_eabi] {
2896 # Use existing float-abi and force an fpu which supports fp16
2897 set et_arm_fp16_flags "-mfpu=vfpv4"
2898 return 1;
2900 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2901 # The existing -mfpu value is OK; use it, but add softfp.
2902 set et_arm_fp16_flags "-mfloat-abi=softfp"
2903 return 1;
2905 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2906 # macro to check for this support.
2907 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2908 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2909 int dummy;
2910 } "$flags"] } {
2911 set et_arm_fp16_flags "$flags"
2912 return 1
2915 return 0
2918 proc check_effective_target_arm_fp16_ok { } {
2919 return [check_cached_effective_target arm_fp16_ok \
2920 check_effective_target_arm_fp16_ok_nocache]
2923 # Creates a series of routines that return 1 if the given architecture
2924 # can be selected and a routine to give the flags to select that architecture
2925 # Note: Extra flags may be added to disable options from newer compilers
2926 # (Thumb in particular - but others may be added in the future)
2927 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2928 # /* { dg-add-options arm_arch_v5 } */
2929 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2930 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2931 v4t "-march=armv4t" __ARM_ARCH_4T__
2932 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2933 v5t "-march=armv5t" __ARM_ARCH_5T__
2934 v5te "-march=armv5te" __ARM_ARCH_5TE__
2935 v6 "-march=armv6" __ARM_ARCH_6__
2936 v6k "-march=armv6k" __ARM_ARCH_6K__
2937 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2938 v6z "-march=armv6z" __ARM_ARCH_6Z__
2939 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2940 v7a "-march=armv7-a" __ARM_ARCH_7A__
2941 v7ve "-march=armv7ve" __ARM_ARCH_7A__
2942 v7r "-march=armv7-r" __ARM_ARCH_7R__
2943 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2944 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2945 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2946 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2947 proc check_effective_target_arm_arch_FUNC_ok { } {
2948 if { [ string match "*-marm*" "FLAG" ] &&
2949 ![check_effective_target_arm_arm_ok] } {
2950 return 0
2952 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2953 #if !defined (DEF)
2954 #error !DEF
2955 #endif
2956 } "FLAG" ]
2959 proc add_options_for_arm_arch_FUNC { flags } {
2960 return "$flags FLAG"
2963 proc check_effective_target_arm_arch_FUNC_multilib { } {
2964 return [check_runtime arm_arch_FUNC_multilib {
2966 main (void)
2968 return 0;
2970 } [add_options_for_arm_arch_FUNC ""]]
2975 # Return 1 if this is an ARM target where -marm causes ARM to be
2976 # used (not Thumb)
2978 proc check_effective_target_arm_arm_ok { } {
2979 return [check_no_compiler_messages arm_arm_ok assembly {
2980 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2981 #error !__arm__ || __thumb__ || __thumb2__
2982 #endif
2983 } "-marm"]
2987 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2988 # used.
2990 proc check_effective_target_arm_thumb1_ok { } {
2991 return [check_no_compiler_messages arm_thumb1_ok assembly {
2992 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2993 #error !__arm__ || !__thumb__ || __thumb2__
2994 #endif
2995 int foo (int i) { return i; }
2996 } "-mthumb"]
2999 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
3000 # used.
3002 proc check_effective_target_arm_thumb2_ok { } {
3003 return [check_no_compiler_messages arm_thumb2_ok assembly {
3004 #if !defined(__thumb2__)
3005 #error !__thumb2__
3006 #endif
3007 int foo (int i) { return i; }
3008 } "-mthumb"]
3011 # Return 1 if this is an ARM target where Thumb-1 is used without options
3012 # added by the test.
3014 proc check_effective_target_arm_thumb1 { } {
3015 return [check_no_compiler_messages arm_thumb1 assembly {
3016 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3017 #error !__arm__ || !__thumb__ || __thumb2__
3018 #endif
3019 int i;
3020 } ""]
3023 # Return 1 if this is an ARM target where Thumb-2 is used without options
3024 # added by the test.
3026 proc check_effective_target_arm_thumb2 { } {
3027 return [check_no_compiler_messages arm_thumb2 assembly {
3028 #if !defined(__thumb2__)
3029 #error !__thumb2__
3030 #endif
3031 int i;
3032 } ""]
3035 # Return 1 if this is an ARM target where conditional execution is available.
3037 proc check_effective_target_arm_cond_exec { } {
3038 return [check_no_compiler_messages arm_cond_exec assembly {
3039 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
3040 #error FOO
3041 #endif
3042 int i;
3043 } ""]
3046 # Return 1 if this is an ARM cortex-M profile cpu
3048 proc check_effective_target_arm_cortex_m { } {
3049 if { ![istarget arm*-*-*] } {
3050 return 0
3052 return [check_no_compiler_messages arm_cortex_m assembly {
3053 #if !defined(__ARM_ARCH_7M__) \
3054 && !defined (__ARM_ARCH_7EM__) \
3055 && !defined (__ARM_ARCH_6M__)
3056 #error !__ARM_ARCH_7M__ && !__ARM_ARCH_7EM__ && !__ARM_ARCH_6M__
3057 #endif
3058 int i;
3059 } "-mthumb"]
3062 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3064 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3065 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3066 int foo (void) { return 0; }
3067 } "-O2 -mprint-tune-info" ]
3070 # Return 1 if the target supports executing NEON instructions, 0
3071 # otherwise. Cache the result.
3073 proc check_effective_target_arm_neon_hw { } {
3074 return [check_runtime arm_neon_hw_available {
3076 main (void)
3078 long long a = 0, b = 1;
3079 asm ("vorr %P0, %P1, %P2"
3080 : "=w" (a)
3081 : "0" (a), "w" (b));
3082 return (a != 1);
3084 } [add_options_for_arm_neon ""]]
3087 proc check_effective_target_arm_neonv2_hw { } {
3088 return [check_runtime arm_neon_hwv2_available {
3089 #include "arm_neon.h"
3091 main (void)
3093 float32x2_t a, b, c;
3094 asm ("vfma.f32 %P0, %P1, %P2"
3095 : "=w" (a)
3096 : "w" (b), "w" (c));
3097 return 0;
3099 } [add_options_for_arm_neonv2 ""]]
3102 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
3103 # otherwise.
3105 proc check_effective_target_arm_v8_neon_hw { } {
3106 return [check_runtime arm_v8_neon_hw_available {
3107 #include "arm_neon.h"
3109 main (void)
3111 float32x2_t a;
3112 asm ("vrinta.f32 %P0, %P1"
3113 : "=w" (a)
3114 : "0" (a));
3115 return 0;
3117 } [add_options_for_arm_v8_neon ""]]
3120 # Return 1 if this is a ARM target with NEON enabled.
3122 proc check_effective_target_arm_neon { } {
3123 if { [check_effective_target_arm32] } {
3124 return [check_no_compiler_messages arm_neon object {
3125 #ifndef __ARM_NEON__
3126 #error not NEON
3127 #else
3128 int dummy;
3129 #endif
3131 } else {
3132 return 0
3136 proc check_effective_target_arm_neonv2 { } {
3137 if { [check_effective_target_arm32] } {
3138 return [check_no_compiler_messages arm_neon object {
3139 #ifndef __ARM_NEON__
3140 #error not NEON
3141 #else
3142 #ifndef __ARM_FEATURE_FMA
3143 #error not NEONv2
3144 #else
3145 int dummy;
3146 #endif
3147 #endif
3149 } else {
3150 return 0
3154 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
3155 # the Loongson vector modes.
3157 proc check_effective_target_mips_loongson { } {
3158 return [check_no_compiler_messages loongson assembly {
3159 #if !defined(__mips_loongson_vector_rev)
3160 #error !__mips_loongson_vector_rev
3161 #endif
3165 # Return 1 if this is a MIPS target that supports the legacy NAN.
3167 proc check_effective_target_mips_nanlegacy { } {
3168 return [check_no_compiler_messages nanlegacy assembly {
3169 #include <stdlib.h>
3170 int main () { return 0; }
3171 } "-mnan=legacy"]
3174 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
3175 # Architecture.
3177 proc check_effective_target_arm_eabi { } {
3178 return [check_no_compiler_messages arm_eabi object {
3179 #ifndef __ARM_EABI__
3180 #error not EABI
3181 #else
3182 int dummy;
3183 #endif
3187 # Return 1 if this is an ARM target that adheres to the hard-float variant of
3188 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
3190 proc check_effective_target_arm_hf_eabi { } {
3191 return [check_no_compiler_messages arm_hf_eabi object {
3192 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
3193 #error not hard-float EABI
3194 #else
3195 int dummy;
3196 #endif
3200 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
3201 # Some multilibs may be incompatible with this option.
3203 proc check_effective_target_arm_iwmmxt_ok { } {
3204 if { [check_effective_target_arm32] } {
3205 return [check_no_compiler_messages arm_iwmmxt_ok object {
3206 int dummy;
3207 } "-mcpu=iwmmxt"]
3208 } else {
3209 return 0
3213 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
3214 # for an ARM target.
3215 proc check_effective_target_arm_prefer_ldrd_strd { } {
3216 if { ![check_effective_target_arm32] } {
3217 return 0;
3220 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
3221 void foo (int *p) { p[0] = 1; p[1] = 0;}
3222 } "-O2 -mthumb" ]
3225 # Return 1 if this is a PowerPC target supporting -meabi.
3227 proc check_effective_target_powerpc_eabi_ok { } {
3228 if { [istarget powerpc*-*-*] } {
3229 return [check_no_compiler_messages powerpc_eabi_ok object {
3230 int dummy;
3231 } "-meabi"]
3232 } else {
3233 return 0
3237 # Return 1 if this is a PowerPC target with floating-point registers.
3239 proc check_effective_target_powerpc_fprs { } {
3240 if { [istarget powerpc*-*-*]
3241 || [istarget rs6000-*-*] } {
3242 return [check_no_compiler_messages powerpc_fprs object {
3243 #ifdef __NO_FPRS__
3244 #error no FPRs
3245 #else
3246 int dummy;
3247 #endif
3249 } else {
3250 return 0
3254 # Return 1 if this is a PowerPC target with hardware double-precision
3255 # floating point.
3257 proc check_effective_target_powerpc_hard_double { } {
3258 if { [istarget powerpc*-*-*]
3259 || [istarget rs6000-*-*] } {
3260 return [check_no_compiler_messages powerpc_hard_double object {
3261 #ifdef _SOFT_DOUBLE
3262 #error soft double
3263 #else
3264 int dummy;
3265 #endif
3267 } else {
3268 return 0
3272 # Return 1 if this is a PowerPC target supporting -maltivec.
3274 proc check_effective_target_powerpc_altivec_ok { } {
3275 if { ([istarget powerpc*-*-*]
3276 && ![istarget powerpc-*-linux*paired*])
3277 || [istarget rs6000-*-*] } {
3278 # AltiVec is not supported on AIX before 5.3.
3279 if { [istarget powerpc*-*-aix4*]
3280 || [istarget powerpc*-*-aix5.1*]
3281 || [istarget powerpc*-*-aix5.2*] } {
3282 return 0
3284 return [check_no_compiler_messages powerpc_altivec_ok object {
3285 int dummy;
3286 } "-maltivec"]
3287 } else {
3288 return 0
3292 # Return 1 if this is a PowerPC target supporting -mpower8-vector
3294 proc check_effective_target_powerpc_p8vector_ok { } {
3295 if { ([istarget powerpc*-*-*]
3296 && ![istarget powerpc-*-linux*paired*])
3297 || [istarget rs6000-*-*] } {
3298 # AltiVec is not supported on AIX before 5.3.
3299 if { [istarget powerpc*-*-aix4*]
3300 || [istarget powerpc*-*-aix5.1*]
3301 || [istarget powerpc*-*-aix5.2*] } {
3302 return 0
3304 return [check_no_compiler_messages powerpc_p8vector_ok object {
3305 int main (void) {
3306 #ifdef __MACH__
3307 asm volatile ("xxlorc vs0,vs0,vs0");
3308 #else
3309 asm volatile ("xxlorc 0,0,0");
3310 #endif
3311 return 0;
3313 } "-mpower8-vector"]
3314 } else {
3315 return 0
3319 # Return 1 if this is a PowerPC target supporting -mvsx
3321 proc check_effective_target_powerpc_vsx_ok { } {
3322 if { ([istarget powerpc*-*-*]
3323 && ![istarget powerpc-*-linux*paired*])
3324 || [istarget rs6000-*-*] } {
3325 # VSX is not supported on AIX before 7.1.
3326 if { [istarget powerpc*-*-aix4*]
3327 || [istarget powerpc*-*-aix5*]
3328 || [istarget powerpc*-*-aix6*] } {
3329 return 0
3331 return [check_no_compiler_messages powerpc_vsx_ok object {
3332 int main (void) {
3333 #ifdef __MACH__
3334 asm volatile ("xxlor vs0,vs0,vs0");
3335 #else
3336 asm volatile ("xxlor 0,0,0");
3337 #endif
3338 return 0;
3340 } "-mvsx"]
3341 } else {
3342 return 0
3346 # Return 1 if this is a PowerPC target supporting -mhtm
3348 proc check_effective_target_powerpc_htm_ok { } {
3349 if { ([istarget powerpc*-*-*]
3350 && ![istarget powerpc-*-linux*paired*])
3351 || [istarget rs6000-*-*] } {
3352 # HTM is not supported on AIX yet.
3353 if { [istarget powerpc*-*-aix*] } {
3354 return 0
3356 return [check_no_compiler_messages powerpc_htm_ok object {
3357 int main (void) {
3358 asm volatile ("tbegin. 0");
3359 return 0;
3361 } "-mhtm"]
3362 } else {
3363 return 0
3367 # Return 1 if the target supports executing HTM hardware instructions,
3368 # 0 otherwise. Cache the result.
3370 proc check_htm_hw_available { } {
3371 return [check_cached_effective_target htm_hw_available {
3372 # For now, disable on Darwin
3373 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
3374 expr 0
3375 } else {
3376 check_runtime_nocache htm_hw_available {
3377 int main()
3379 __builtin_ttest ();
3380 return 0;
3382 } "-mhtm"
3386 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
3388 proc check_effective_target_powerpc_ppu_ok { } {
3389 if [check_effective_target_powerpc_altivec_ok] {
3390 return [check_no_compiler_messages cell_asm_available object {
3391 int main (void) {
3392 #ifdef __MACH__
3393 asm volatile ("lvlx v0,v0,v0");
3394 #else
3395 asm volatile ("lvlx 0,0,0");
3396 #endif
3397 return 0;
3400 } else {
3401 return 0
3405 # Return 1 if this is a PowerPC target that supports SPU.
3407 proc check_effective_target_powerpc_spu { } {
3408 if { [istarget powerpc*-*-linux*] } {
3409 return [check_effective_target_powerpc_altivec_ok]
3410 } else {
3411 return 0
3415 # Return 1 if this is a PowerPC SPE target. The check includes options
3416 # specified by dg-options for this test, so don't cache the result.
3418 proc check_effective_target_powerpc_spe_nocache { } {
3419 if { [istarget powerpc*-*-*] } {
3420 return [check_no_compiler_messages_nocache powerpc_spe object {
3421 #ifndef __SPE__
3422 #error not SPE
3423 #else
3424 int dummy;
3425 #endif
3426 } [current_compiler_flags]]
3427 } else {
3428 return 0
3432 # Return 1 if this is a PowerPC target with SPE enabled.
3434 proc check_effective_target_powerpc_spe { } {
3435 if { [istarget powerpc*-*-*] } {
3436 return [check_no_compiler_messages powerpc_spe object {
3437 #ifndef __SPE__
3438 #error not SPE
3439 #else
3440 int dummy;
3441 #endif
3443 } else {
3444 return 0
3448 # Return 1 if this is a PowerPC target with Altivec enabled.
3450 proc check_effective_target_powerpc_altivec { } {
3451 if { [istarget powerpc*-*-*] } {
3452 return [check_no_compiler_messages powerpc_altivec object {
3453 #ifndef __ALTIVEC__
3454 #error not Altivec
3455 #else
3456 int dummy;
3457 #endif
3459 } else {
3460 return 0
3464 # Return 1 if this is a PowerPC 405 target. The check includes options
3465 # specified by dg-options for this test, so don't cache the result.
3467 proc check_effective_target_powerpc_405_nocache { } {
3468 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3469 return [check_no_compiler_messages_nocache powerpc_405 object {
3470 #ifdef __PPC405__
3471 int dummy;
3472 #else
3473 #error not a PPC405
3474 #endif
3475 } [current_compiler_flags]]
3476 } else {
3477 return 0
3481 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3483 proc check_effective_target_powerpc_elfv2 { } {
3484 if { [istarget powerpc*-*-*] } {
3485 return [check_no_compiler_messages powerpc_elfv2 object {
3486 #if _CALL_ELF != 2
3487 #error not ELF v2 ABI
3488 #else
3489 int dummy;
3490 #endif
3492 } else {
3493 return 0
3497 # Return 1 if this is a SPU target with a toolchain that
3498 # supports automatic overlay generation.
3500 proc check_effective_target_spu_auto_overlay { } {
3501 if { [istarget spu*-*-elf*] } {
3502 return [check_no_compiler_messages spu_auto_overlay executable {
3503 int main (void) { }
3504 } "-Wl,--auto-overlay" ]
3505 } else {
3506 return 0
3510 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3511 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3512 # test environment appears to run executables on such a simulator.
3514 proc check_effective_target_ultrasparc_hw { } {
3515 return [check_runtime ultrasparc_hw {
3516 int main() { return 0; }
3517 } "-mcpu=ultrasparc"]
3520 # Return 1 if the test environment supports executing UltraSPARC VIS2
3521 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3523 proc check_effective_target_ultrasparc_vis2_hw { } {
3524 return [check_runtime ultrasparc_vis2_hw {
3525 int main() { __asm__(".word 0x81b00320"); return 0; }
3526 } "-mcpu=ultrasparc3"]
3529 # Return 1 if the test environment supports executing UltraSPARC VIS3
3530 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3532 proc check_effective_target_ultrasparc_vis3_hw { } {
3533 return [check_runtime ultrasparc_vis3_hw {
3534 int main() { __asm__(".word 0x81b00220"); return 0; }
3535 } "-mcpu=niagara3"]
3538 # Return 1 if this is a SPARC-V9 target.
3540 proc check_effective_target_sparc_v9 { } {
3541 if { [istarget sparc*-*-*] } {
3542 return [check_no_compiler_messages sparc_v9 object {
3543 int main (void) {
3544 asm volatile ("return %i7+8");
3545 return 0;
3548 } else {
3549 return 0
3553 # Return 1 if this is a SPARC target with VIS enabled.
3555 proc check_effective_target_sparc_vis { } {
3556 if { [istarget sparc*-*-*] } {
3557 return [check_no_compiler_messages sparc_vis object {
3558 #ifndef __VIS__
3559 #error not VIS
3560 #else
3561 int dummy;
3562 #endif
3564 } else {
3565 return 0
3569 # Return 1 if the target supports hardware vector shift operation.
3571 proc check_effective_target_vect_shift { } {
3572 global et_vect_shift_saved
3574 if [info exists et_vect_shift_saved] {
3575 verbose "check_effective_target_vect_shift: using cached result" 2
3576 } else {
3577 set et_vect_shift_saved 0
3578 if { ([istarget powerpc*-*-*]
3579 && ![istarget powerpc-*-linux*paired*])
3580 || [istarget ia64-*-*]
3581 || [istarget i?86-*-*] || [istarget x86_64-*-*]
3582 || [istarget aarch64*-*-*]
3583 || [check_effective_target_arm32]
3584 || ([istarget mips*-*-*]
3585 && [check_effective_target_mips_loongson]) } {
3586 set et_vect_shift_saved 1
3590 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3591 return $et_vect_shift_saved
3594 proc check_effective_target_whole_vector_shift { } {
3595 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3596 || [istarget ia64-*-*]
3597 || [istarget aarch64*-*-*]
3598 || ([check_effective_target_arm32]
3599 && [check_effective_target_arm_little_endian])
3600 || ([istarget mips*-*-*]
3601 && [check_effective_target_mips_loongson]) } {
3602 set answer 1
3603 } else {
3604 set answer 0
3607 verbose "check_effective_target_vect_long: returning $answer" 2
3608 return $answer
3611 # Return 1 if the target supports vector bswap operations.
3613 proc check_effective_target_vect_bswap { } {
3614 global et_vect_bswap_saved
3616 if [info exists et_vect_bswap_saved] {
3617 verbose "check_effective_target_vect_bswap: using cached result" 2
3618 } else {
3619 set et_vect_bswap_saved 0
3620 if { [istarget aarch64*-*-*]
3621 || ([istarget arm*-*-*]
3622 && [check_effective_target_arm_neon])
3624 set et_vect_bswap_saved 1
3628 verbose "check_effective_target_vect_bswap: returning $et_vect_bswap_saved" 2
3629 return $et_vect_bswap_saved
3632 # Return 1 if the target supports hardware vector shift operation for char.
3634 proc check_effective_target_vect_shift_char { } {
3635 global et_vect_shift_char_saved
3637 if [info exists et_vect_shift_char_saved] {
3638 verbose "check_effective_target_vect_shift_char: using cached result" 2
3639 } else {
3640 set et_vect_shift_char_saved 0
3641 if { ([istarget powerpc*-*-*]
3642 && ![istarget powerpc-*-linux*paired*])
3643 || [check_effective_target_arm32] } {
3644 set et_vect_shift_char_saved 1
3648 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3649 return $et_vect_shift_char_saved
3652 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3654 # This can change for different subtargets so do not cache the result.
3656 proc check_effective_target_vect_long { } {
3657 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3658 || (([istarget powerpc*-*-*]
3659 && ![istarget powerpc-*-linux*paired*])
3660 && [check_effective_target_ilp32])
3661 || [check_effective_target_arm32]
3662 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3663 set answer 1
3664 } else {
3665 set answer 0
3668 verbose "check_effective_target_vect_long: returning $answer" 2
3669 return $answer
3672 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3674 # This won't change for different subtargets so cache the result.
3676 proc check_effective_target_vect_float { } {
3677 global et_vect_float_saved
3679 if [info exists et_vect_float_saved] {
3680 verbose "check_effective_target_vect_float: using cached result" 2
3681 } else {
3682 set et_vect_float_saved 0
3683 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3684 || [istarget powerpc*-*-*]
3685 || [istarget spu-*-*]
3686 || [istarget mips-sde-elf]
3687 || [istarget mipsisa64*-*-*]
3688 || [istarget ia64-*-*]
3689 || [istarget aarch64*-*-*]
3690 || [check_effective_target_arm32] } {
3691 set et_vect_float_saved 1
3695 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
3696 return $et_vect_float_saved
3699 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
3701 # This won't change for different subtargets so cache the result.
3703 proc check_effective_target_vect_double { } {
3704 global et_vect_double_saved
3706 if [info exists et_vect_double_saved] {
3707 verbose "check_effective_target_vect_double: using cached result" 2
3708 } else {
3709 set et_vect_double_saved 0
3710 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3711 || [istarget aarch64*-*-*] } {
3712 if { [check_no_compiler_messages vect_double assembly {
3713 #ifdef __tune_atom__
3714 # error No double vectorizer support.
3715 #endif
3716 }] } {
3717 set et_vect_double_saved 1
3718 } else {
3719 set et_vect_double_saved 0
3721 } elseif { [istarget spu-*-*] } {
3722 set et_vect_double_saved 1
3723 } elseif { [istarget powerpc*-*-*] && [check_vsx_hw_available] } {
3724 set et_vect_double_saved 1
3728 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3729 return $et_vect_double_saved
3732 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3734 # This won't change for different subtargets so cache the result.
3736 proc check_effective_target_vect_long_long { } {
3737 global et_vect_long_long_saved
3739 if [info exists et_vect_long_long_saved] {
3740 verbose "check_effective_target_vect_long_long: using cached result" 2
3741 } else {
3742 set et_vect_long_long_saved 0
3743 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
3744 set et_vect_long_long_saved 1
3748 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3749 return $et_vect_long_long_saved
3753 # Return 1 if the target plus current options does not support a vector
3754 # max instruction on "int", 0 otherwise.
3756 # This won't change for different subtargets so cache the result.
3758 proc check_effective_target_vect_no_int_min_max { } {
3759 global et_vect_no_int_min_max_saved
3761 if [info exists et_vect_no_int_min_max_saved] {
3762 verbose "check_effective_target_vect_no_int_min_max: using cached result" 2
3763 } else {
3764 set et_vect_no_int_min_max_saved 0
3765 if { [istarget sparc*-*-*]
3766 || [istarget spu-*-*]
3767 || [istarget alpha*-*-*]
3768 || ([istarget mips*-*-*]
3769 && [check_effective_target_mips_loongson]) } {
3770 set et_vect_no_int_min_max_saved 1
3773 verbose "check_effective_target_vect_no_int_min_max: returning $et_vect_no_int_min_max_saved" 2
3774 return $et_vect_no_int_min_max_saved
3777 # Return 1 if the target plus current options does not support a vector
3778 # add instruction on "int", 0 otherwise.
3780 # This won't change for different subtargets so cache the result.
3782 proc check_effective_target_vect_no_int_add { } {
3783 global et_vect_no_int_add_saved
3785 if [info exists et_vect_no_int_add_saved] {
3786 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3787 } else {
3788 set et_vect_no_int_add_saved 0
3789 # Alpha only supports vector add on V8QI and V4HI.
3790 if { [istarget alpha*-*-*] } {
3791 set et_vect_no_int_add_saved 1
3794 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3795 return $et_vect_no_int_add_saved
3798 # Return 1 if the target plus current options does not support vector
3799 # bitwise instructions, 0 otherwise.
3801 # This won't change for different subtargets so cache the result.
3803 proc check_effective_target_vect_no_bitwise { } {
3804 global et_vect_no_bitwise_saved
3806 if [info exists et_vect_no_bitwise_saved] {
3807 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3808 } else {
3809 set et_vect_no_bitwise_saved 0
3811 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3812 return $et_vect_no_bitwise_saved
3815 # Return 1 if the target plus current options supports vector permutation,
3816 # 0 otherwise.
3818 # This won't change for different subtargets so cache the result.
3820 proc check_effective_target_vect_perm { } {
3821 global et_vect_perm
3823 if [info exists et_vect_perm_saved] {
3824 verbose "check_effective_target_vect_perm: using cached result" 2
3825 } else {
3826 set et_vect_perm_saved 0
3827 if { [is-effective-target arm_neon_ok]
3828 || [istarget aarch64*-*-*]
3829 || [istarget powerpc*-*-*]
3830 || [istarget spu-*-*]
3831 || [istarget i?86-*-*] || [istarget x86_64-*-*]
3832 || ([istarget mips*-*-*]
3833 && [check_effective_target_mpaired_single]) } {
3834 set et_vect_perm_saved 1
3837 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3838 return $et_vect_perm_saved
3841 # Return 1 if the target plus current options supports vector permutation
3842 # on byte-sized elements, 0 otherwise.
3844 # This won't change for different subtargets so cache the result.
3846 proc check_effective_target_vect_perm_byte { } {
3847 global et_vect_perm_byte
3849 if [info exists et_vect_perm_byte_saved] {
3850 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3851 } else {
3852 set et_vect_perm_byte_saved 0
3853 if { ([is-effective-target arm_neon_ok]
3854 && [is-effective-target arm_little_endian])
3855 || ([istarget aarch64*-*-*]
3856 && [is-effective-target aarch64_little_endian])
3857 || [istarget powerpc*-*-*]
3858 || [istarget spu-*-*] } {
3859 set et_vect_perm_byte_saved 1
3862 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3863 return $et_vect_perm_byte_saved
3866 # Return 1 if the target plus current options supports vector permutation
3867 # on short-sized elements, 0 otherwise.
3869 # This won't change for different subtargets so cache the result.
3871 proc check_effective_target_vect_perm_short { } {
3872 global et_vect_perm_short
3874 if [info exists et_vect_perm_short_saved] {
3875 verbose "check_effective_target_vect_perm_short: using cached result" 2
3876 } else {
3877 set et_vect_perm_short_saved 0
3878 if { ([is-effective-target arm_neon_ok]
3879 && [is-effective-target arm_little_endian])
3880 || ([istarget aarch64*-*-*]
3881 && [is-effective-target aarch64_little_endian])
3882 || [istarget powerpc*-*-*]
3883 || [istarget spu-*-*] } {
3884 set et_vect_perm_short_saved 1
3887 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3888 return $et_vect_perm_short_saved
3891 # Return 1 if the target plus current options supports a vector
3892 # widening summation of *short* args into *int* result, 0 otherwise.
3894 # This won't change for different subtargets so cache the result.
3896 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3897 global et_vect_widen_sum_hi_to_si_pattern
3899 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3900 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3901 } else {
3902 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3903 if { [istarget powerpc*-*-*]
3904 || [istarget ia64-*-*] } {
3905 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3908 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3909 return $et_vect_widen_sum_hi_to_si_pattern_saved
3912 # Return 1 if the target plus current options supports a vector
3913 # widening summation of *short* args into *int* result, 0 otherwise.
3914 # A target can also support this widening summation if it can support
3915 # promotion (unpacking) from shorts to ints.
3917 # This won't change for different subtargets so cache the result.
3919 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3920 global et_vect_widen_sum_hi_to_si
3922 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3923 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3924 } else {
3925 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3926 if { [istarget powerpc*-*-*]
3927 || [istarget ia64-*-*] } {
3928 set et_vect_widen_sum_hi_to_si_saved 1
3931 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3932 return $et_vect_widen_sum_hi_to_si_saved
3935 # Return 1 if the target plus current options supports a vector
3936 # widening summation of *char* args into *short* result, 0 otherwise.
3937 # A target can also support this widening summation if it can support
3938 # promotion (unpacking) from chars to shorts.
3940 # This won't change for different subtargets so cache the result.
3942 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3943 global et_vect_widen_sum_qi_to_hi
3945 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3946 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3947 } else {
3948 set et_vect_widen_sum_qi_to_hi_saved 0
3949 if { [check_effective_target_vect_unpack]
3950 || [check_effective_target_arm_neon_ok]
3951 || [istarget ia64-*-*] } {
3952 set et_vect_widen_sum_qi_to_hi_saved 1
3955 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3956 return $et_vect_widen_sum_qi_to_hi_saved
3959 # Return 1 if the target plus current options supports a vector
3960 # widening summation of *char* args into *int* result, 0 otherwise.
3962 # This won't change for different subtargets so cache the result.
3964 proc check_effective_target_vect_widen_sum_qi_to_si { } {
3965 global et_vect_widen_sum_qi_to_si
3967 if [info exists et_vect_widen_sum_qi_to_si_saved] {
3968 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3969 } else {
3970 set et_vect_widen_sum_qi_to_si_saved 0
3971 if { [istarget powerpc*-*-*] } {
3972 set et_vect_widen_sum_qi_to_si_saved 1
3975 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3976 return $et_vect_widen_sum_qi_to_si_saved
3979 # Return 1 if the target plus current options supports a vector
3980 # widening multiplication of *char* args into *short* result, 0 otherwise.
3981 # A target can also support this widening multplication if it can support
3982 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
3983 # multiplication of shorts).
3985 # This won't change for different subtargets so cache the result.
3988 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3989 global et_vect_widen_mult_qi_to_hi
3991 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3992 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3993 } else {
3994 if { [check_effective_target_vect_unpack]
3995 && [check_effective_target_vect_short_mult] } {
3996 set et_vect_widen_mult_qi_to_hi_saved 1
3997 } else {
3998 set et_vect_widen_mult_qi_to_hi_saved 0
4000 if { [istarget powerpc*-*-*]
4001 || [istarget aarch64*-*-*]
4002 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4003 set et_vect_widen_mult_qi_to_hi_saved 1
4006 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
4007 return $et_vect_widen_mult_qi_to_hi_saved
4010 # Return 1 if the target plus current options supports a vector
4011 # widening multiplication of *short* args into *int* result, 0 otherwise.
4012 # A target can also support this widening multplication if it can support
4013 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
4014 # multiplication of ints).
4016 # This won't change for different subtargets so cache the result.
4019 proc check_effective_target_vect_widen_mult_hi_to_si { } {
4020 global et_vect_widen_mult_hi_to_si
4022 if [info exists et_vect_widen_mult_hi_to_si_saved] {
4023 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
4024 } else {
4025 if { [check_effective_target_vect_unpack]
4026 && [check_effective_target_vect_int_mult] } {
4027 set et_vect_widen_mult_hi_to_si_saved 1
4028 } else {
4029 set et_vect_widen_mult_hi_to_si_saved 0
4031 if { [istarget powerpc*-*-*]
4032 || [istarget spu-*-*]
4033 || [istarget ia64-*-*]
4034 || [istarget aarch64*-*-*]
4035 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4036 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4037 set et_vect_widen_mult_hi_to_si_saved 1
4040 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
4041 return $et_vect_widen_mult_hi_to_si_saved
4044 # Return 1 if the target plus current options supports a vector
4045 # widening multiplication of *char* args into *short* result, 0 otherwise.
4047 # This won't change for different subtargets so cache the result.
4049 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
4050 global et_vect_widen_mult_qi_to_hi_pattern
4052 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
4053 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
4054 } else {
4055 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
4056 if { [istarget powerpc*-*-*]
4057 || ([istarget arm*-*-*]
4058 && [check_effective_target_arm_neon_ok]
4059 && [check_effective_target_arm_little_endian]) } {
4060 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
4063 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
4064 return $et_vect_widen_mult_qi_to_hi_pattern_saved
4067 # Return 1 if the target plus current options supports a vector
4068 # widening multiplication of *short* args into *int* result, 0 otherwise.
4070 # This won't change for different subtargets so cache the result.
4072 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
4073 global et_vect_widen_mult_hi_to_si_pattern
4075 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
4076 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
4077 } else {
4078 set et_vect_widen_mult_hi_to_si_pattern_saved 0
4079 if { [istarget powerpc*-*-*]
4080 || [istarget spu-*-*]
4081 || [istarget ia64-*-*]
4082 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4083 || ([istarget arm*-*-*]
4084 && [check_effective_target_arm_neon_ok]
4085 && [check_effective_target_arm_little_endian]) } {
4086 set et_vect_widen_mult_hi_to_si_pattern_saved 1
4089 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
4090 return $et_vect_widen_mult_hi_to_si_pattern_saved
4093 # Return 1 if the target plus current options supports a vector
4094 # widening multiplication of *int* args into *long* result, 0 otherwise.
4096 # This won't change for different subtargets so cache the result.
4098 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
4099 global et_vect_widen_mult_si_to_di_pattern
4101 if [info exists et_vect_widen_mult_si_to_di_pattern_saved] {
4102 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: using cached result" 2
4103 } else {
4104 set et_vect_widen_mult_si_to_di_pattern_saved 0
4105 if {[istarget ia64-*-*]
4106 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4107 set et_vect_widen_mult_si_to_di_pattern_saved 1
4110 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: returning $et_vect_widen_mult_si_to_di_pattern_saved" 2
4111 return $et_vect_widen_mult_si_to_di_pattern_saved
4114 # Return 1 if the target plus current options supports a vector
4115 # widening shift, 0 otherwise.
4117 # This won't change for different subtargets so cache the result.
4119 proc check_effective_target_vect_widen_shift { } {
4120 global et_vect_widen_shift_saved
4122 if [info exists et_vect_shift_saved] {
4123 verbose "check_effective_target_vect_widen_shift: using cached result" 2
4124 } else {
4125 set et_vect_widen_shift_saved 0
4126 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4127 set et_vect_widen_shift_saved 1
4130 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
4131 return $et_vect_widen_shift_saved
4134 # Return 1 if the target plus current options supports a vector
4135 # dot-product of signed chars, 0 otherwise.
4137 # This won't change for different subtargets so cache the result.
4139 proc check_effective_target_vect_sdot_qi { } {
4140 global et_vect_sdot_qi
4142 if [info exists et_vect_sdot_qi_saved] {
4143 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
4144 } else {
4145 set et_vect_sdot_qi_saved 0
4146 if { [istarget ia64-*-*] } {
4147 set et_vect_udot_qi_saved 1
4150 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
4151 return $et_vect_sdot_qi_saved
4154 # Return 1 if the target plus current options supports a vector
4155 # dot-product of unsigned chars, 0 otherwise.
4157 # This won't change for different subtargets so cache the result.
4159 proc check_effective_target_vect_udot_qi { } {
4160 global et_vect_udot_qi
4162 if [info exists et_vect_udot_qi_saved] {
4163 verbose "check_effective_target_vect_udot_qi: using cached result" 2
4164 } else {
4165 set et_vect_udot_qi_saved 0
4166 if { [istarget powerpc*-*-*]
4167 || [istarget ia64-*-*] } {
4168 set et_vect_udot_qi_saved 1
4171 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
4172 return $et_vect_udot_qi_saved
4175 # Return 1 if the target plus current options supports a vector
4176 # dot-product of signed shorts, 0 otherwise.
4178 # This won't change for different subtargets so cache the result.
4180 proc check_effective_target_vect_sdot_hi { } {
4181 global et_vect_sdot_hi
4183 if [info exists et_vect_sdot_hi_saved] {
4184 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
4185 } else {
4186 set et_vect_sdot_hi_saved 0
4187 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4188 || [istarget ia64-*-*]
4189 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4190 set et_vect_sdot_hi_saved 1
4193 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
4194 return $et_vect_sdot_hi_saved
4197 # Return 1 if the target plus current options supports a vector
4198 # dot-product of unsigned shorts, 0 otherwise.
4200 # This won't change for different subtargets so cache the result.
4202 proc check_effective_target_vect_udot_hi { } {
4203 global et_vect_udot_hi
4205 if [info exists et_vect_udot_hi_saved] {
4206 verbose "check_effective_target_vect_udot_hi: using cached result" 2
4207 } else {
4208 set et_vect_udot_hi_saved 0
4209 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
4210 set et_vect_udot_hi_saved 1
4213 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
4214 return $et_vect_udot_hi_saved
4217 # Return 1 if the target plus current options supports a vector
4218 # sad operation of unsigned chars, 0 otherwise.
4220 # This won't change for different subtargets so cache the result.
4222 proc check_effective_target_vect_usad_char { } {
4223 global et_vect_usad_char
4225 if [info exists et_vect_usad_char_saved] {
4226 verbose "check_effective_target_vect_usad_char: using cached result" 2
4227 } else {
4228 set et_vect_usad_char_saved 0
4229 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
4230 set et_vect_usad_char_saved 1
4233 verbose "check_effective_target_vect_usad_char: returning $et_vect_usad_char_saved" 2
4234 return $et_vect_usad_char_saved
4237 # Return 1 if the target plus current options supports a vector
4238 # demotion (packing) of shorts (to chars) and ints (to shorts)
4239 # using modulo arithmetic, 0 otherwise.
4241 # This won't change for different subtargets so cache the result.
4243 proc check_effective_target_vect_pack_trunc { } {
4244 global et_vect_pack_trunc
4246 if [info exists et_vect_pack_trunc_saved] {
4247 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
4248 } else {
4249 set et_vect_pack_trunc_saved 0
4250 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4251 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4252 || [istarget aarch64*-*-*]
4253 || [istarget spu-*-*]
4254 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4255 && [check_effective_target_arm_little_endian]) } {
4256 set et_vect_pack_trunc_saved 1
4259 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
4260 return $et_vect_pack_trunc_saved
4263 # Return 1 if the target plus current options supports a vector
4264 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
4266 # This won't change for different subtargets so cache the result.
4268 proc check_effective_target_vect_unpack { } {
4269 global et_vect_unpack
4271 if [info exists et_vect_unpack_saved] {
4272 verbose "check_effective_target_vect_unpack: using cached result" 2
4273 } else {
4274 set et_vect_unpack_saved 0
4275 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
4276 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4277 || [istarget spu-*-*]
4278 || [istarget ia64-*-*]
4279 || [istarget aarch64*-*-*]
4280 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4281 && [check_effective_target_arm_little_endian]) } {
4282 set et_vect_unpack_saved 1
4285 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
4286 return $et_vect_unpack_saved
4289 # Return 1 if the target plus current options does not guarantee
4290 # that its STACK_BOUNDARY is >= the reguired vector alignment.
4292 # This won't change for different subtargets so cache the result.
4294 proc check_effective_target_unaligned_stack { } {
4295 global et_unaligned_stack_saved
4297 if [info exists et_unaligned_stack_saved] {
4298 verbose "check_effective_target_unaligned_stack: using cached result" 2
4299 } else {
4300 set et_unaligned_stack_saved 0
4302 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
4303 return $et_unaligned_stack_saved
4306 # Return 1 if the target plus current options does not support a vector
4307 # alignment mechanism, 0 otherwise.
4309 # This won't change for different subtargets so cache the result.
4311 proc check_effective_target_vect_no_align { } {
4312 global et_vect_no_align_saved
4314 if [info exists et_vect_no_align_saved] {
4315 verbose "check_effective_target_vect_no_align: using cached result" 2
4316 } else {
4317 set et_vect_no_align_saved 0
4318 if { [istarget mipsisa64*-*-*]
4319 || [istarget mips-sde-elf]
4320 || [istarget sparc*-*-*]
4321 || [istarget ia64-*-*]
4322 || [check_effective_target_arm_vect_no_misalign]
4323 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4324 || ([istarget mips*-*-*]
4325 && [check_effective_target_mips_loongson]) } {
4326 set et_vect_no_align_saved 1
4329 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
4330 return $et_vect_no_align_saved
4333 # Return 1 if the target supports a vector misalign access, 0 otherwise.
4335 # This won't change for different subtargets so cache the result.
4337 proc check_effective_target_vect_hw_misalign { } {
4338 global et_vect_hw_misalign_saved
4340 if [info exists et_vect_hw_misalign_saved] {
4341 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
4342 } else {
4343 set et_vect_hw_misalign_saved 0
4344 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4345 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4346 || [istarget aarch64*-*-*] } {
4347 set et_vect_hw_misalign_saved 1
4350 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
4351 return $et_vect_hw_misalign_saved
4355 # Return 1 if arrays are aligned to the vector alignment
4356 # boundary, 0 otherwise.
4358 # This won't change for different subtargets so cache the result.
4360 proc check_effective_target_vect_aligned_arrays { } {
4361 global et_vect_aligned_arrays
4363 if [info exists et_vect_aligned_arrays_saved] {
4364 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
4365 } else {
4366 set et_vect_aligned_arrays_saved 0
4367 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4368 if { ([is-effective-target lp64]
4369 && ( ![check_avx_available]
4370 || [check_prefer_avx128])) } {
4371 set et_vect_aligned_arrays_saved 1
4374 if [istarget spu-*-*] {
4375 set et_vect_aligned_arrays_saved 1
4378 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
4379 return $et_vect_aligned_arrays_saved
4382 # Return 1 if types of size 32 bit or less are naturally aligned
4383 # (aligned to their type-size), 0 otherwise.
4385 # This won't change for different subtargets so cache the result.
4387 proc check_effective_target_natural_alignment_32 { } {
4388 global et_natural_alignment_32
4390 if [info exists et_natural_alignment_32_saved] {
4391 verbose "check_effective_target_natural_alignment_32: using cached result" 2
4392 } else {
4393 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
4394 set et_natural_alignment_32_saved 1
4395 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
4396 set et_natural_alignment_32_saved 0
4399 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
4400 return $et_natural_alignment_32_saved
4403 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
4404 # type-size), 0 otherwise.
4406 # This won't change for different subtargets so cache the result.
4408 proc check_effective_target_natural_alignment_64 { } {
4409 global et_natural_alignment_64
4411 if [info exists et_natural_alignment_64_saved] {
4412 verbose "check_effective_target_natural_alignment_64: using cached result" 2
4413 } else {
4414 set et_natural_alignment_64_saved 0
4415 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
4416 || [istarget spu-*-*] } {
4417 set et_natural_alignment_64_saved 1
4420 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
4421 return $et_natural_alignment_64_saved
4424 # Return 1 if all vector types are naturally aligned (aligned to their
4425 # type-size), 0 otherwise.
4427 # This won't change for different subtargets so cache the result.
4429 proc check_effective_target_vect_natural_alignment { } {
4430 global et_vect_natural_alignment
4432 if [info exists et_vect_natural_alignment_saved] {
4433 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
4434 } else {
4435 set et_vect_natural_alignment_saved 1
4436 if { [check_effective_target_arm_eabi]
4437 || [istarget nvptx-*-*]
4438 || [istarget s390*-*-*] } {
4439 set et_vect_natural_alignment_saved 0
4442 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
4443 return $et_vect_natural_alignment_saved
4446 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
4448 # This won't change for different subtargets so cache the result.
4450 proc check_effective_target_vector_alignment_reachable { } {
4451 global et_vector_alignment_reachable
4453 if [info exists et_vector_alignment_reachable_saved] {
4454 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
4455 } else {
4456 if { [check_effective_target_vect_aligned_arrays]
4457 || [check_effective_target_natural_alignment_32] } {
4458 set et_vector_alignment_reachable_saved 1
4459 } else {
4460 set et_vector_alignment_reachable_saved 0
4463 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
4464 return $et_vector_alignment_reachable_saved
4467 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
4469 # This won't change for different subtargets so cache the result.
4471 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
4472 global et_vector_alignment_reachable_for_64bit
4474 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
4475 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
4476 } else {
4477 if { [check_effective_target_vect_aligned_arrays]
4478 || [check_effective_target_natural_alignment_64] } {
4479 set et_vector_alignment_reachable_for_64bit_saved 1
4480 } else {
4481 set et_vector_alignment_reachable_for_64bit_saved 0
4484 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
4485 return $et_vector_alignment_reachable_for_64bit_saved
4488 # Return 1 if the target only requires element alignment for vector accesses
4490 proc check_effective_target_vect_element_align { } {
4491 global et_vect_element_align
4493 if [info exists et_vect_element_align] {
4494 verbose "check_effective_target_vect_element_align: using cached result" 2
4495 } else {
4496 set et_vect_element_align 0
4497 if { ([istarget arm*-*-*]
4498 && ![check_effective_target_arm_vect_no_misalign])
4499 || [check_effective_target_vect_hw_misalign] } {
4500 set et_vect_element_align 1
4504 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4505 return $et_vect_element_align
4508 # Return 1 if the target supports vector conditional operations, 0 otherwise.
4510 proc check_effective_target_vect_condition { } {
4511 global et_vect_cond_saved
4513 if [info exists et_vect_cond_saved] {
4514 verbose "check_effective_target_vect_cond: using cached result" 2
4515 } else {
4516 set et_vect_cond_saved 0
4517 if { [istarget aarch64*-*-*]
4518 || [istarget powerpc*-*-*]
4519 || [istarget ia64-*-*]
4520 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4521 || [istarget spu-*-*]
4522 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4523 set et_vect_cond_saved 1
4527 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
4528 return $et_vect_cond_saved
4531 # Return 1 if the target supports vector conditional operations where
4532 # the comparison has different type from the lhs, 0 otherwise.
4534 proc check_effective_target_vect_cond_mixed { } {
4535 global et_vect_cond_mixed_saved
4537 if [info exists et_vect_cond_mixed_saved] {
4538 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
4539 } else {
4540 set et_vect_cond_mixed_saved 0
4541 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4542 || [istarget powerpc*-*-*] } {
4543 set et_vect_cond_mixed_saved 1
4547 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
4548 return $et_vect_cond_mixed_saved
4551 # Return 1 if the target supports vector char multiplication, 0 otherwise.
4553 proc check_effective_target_vect_char_mult { } {
4554 global et_vect_char_mult_saved
4556 if [info exists et_vect_char_mult_saved] {
4557 verbose "check_effective_target_vect_char_mult: using cached result" 2
4558 } else {
4559 set et_vect_char_mult_saved 0
4560 if { [istarget aarch64*-*-*]
4561 || [istarget ia64-*-*]
4562 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4563 || [check_effective_target_arm32] } {
4564 set et_vect_char_mult_saved 1
4568 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4569 return $et_vect_char_mult_saved
4572 # Return 1 if the target supports vector short multiplication, 0 otherwise.
4574 proc check_effective_target_vect_short_mult { } {
4575 global et_vect_short_mult_saved
4577 if [info exists et_vect_short_mult_saved] {
4578 verbose "check_effective_target_vect_short_mult: using cached result" 2
4579 } else {
4580 set et_vect_short_mult_saved 0
4581 if { [istarget ia64-*-*]
4582 || [istarget spu-*-*]
4583 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4584 || [istarget powerpc*-*-*]
4585 || [istarget aarch64*-*-*]
4586 || [check_effective_target_arm32]
4587 || ([istarget mips*-*-*]
4588 && [check_effective_target_mips_loongson]) } {
4589 set et_vect_short_mult_saved 1
4593 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4594 return $et_vect_short_mult_saved
4597 # Return 1 if the target supports vector int multiplication, 0 otherwise.
4599 proc check_effective_target_vect_int_mult { } {
4600 global et_vect_int_mult_saved
4602 if [info exists et_vect_int_mult_saved] {
4603 verbose "check_effective_target_vect_int_mult: using cached result" 2
4604 } else {
4605 set et_vect_int_mult_saved 0
4606 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4607 || [istarget spu-*-*]
4608 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4609 || [istarget ia64-*-*]
4610 || [istarget aarch64*-*-*]
4611 || [check_effective_target_arm32] } {
4612 set et_vect_int_mult_saved 1
4616 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4617 return $et_vect_int_mult_saved
4620 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
4622 proc check_effective_target_vect_extract_even_odd { } {
4623 global et_vect_extract_even_odd_saved
4625 if [info exists et_vect_extract_even_odd_saved] {
4626 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
4627 } else {
4628 set et_vect_extract_even_odd_saved 0
4629 if { [istarget aarch64*-*-*]
4630 || [istarget powerpc*-*-*]
4631 || [is-effective-target arm_neon_ok]
4632 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4633 || [istarget ia64-*-*]
4634 || [istarget spu-*-*]
4635 || ([istarget mips*-*-*]
4636 && [check_effective_target_mpaired_single]) } {
4637 set et_vect_extract_even_odd_saved 1
4641 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4642 return $et_vect_extract_even_odd_saved
4645 # Return 1 if the target supports vector interleaving, 0 otherwise.
4647 proc check_effective_target_vect_interleave { } {
4648 global et_vect_interleave_saved
4650 if [info exists et_vect_interleave_saved] {
4651 verbose "check_effective_target_vect_interleave: using cached result" 2
4652 } else {
4653 set et_vect_interleave_saved 0
4654 if { [istarget aarch64*-*-*]
4655 || [istarget powerpc*-*-*]
4656 || [is-effective-target arm_neon_ok]
4657 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4658 || [istarget ia64-*-*]
4659 || [istarget spu-*-*]
4660 || ([istarget mips*-*-*]
4661 && [check_effective_target_mpaired_single]) } {
4662 set et_vect_interleave_saved 1
4666 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4667 return $et_vect_interleave_saved
4670 foreach N {2 3 4 8} {
4671 eval [string map [list N $N] {
4672 # Return 1 if the target supports 2-vector interleaving
4673 proc check_effective_target_vect_stridedN { } {
4674 global et_vect_stridedN_saved
4676 if [info exists et_vect_stridedN_saved] {
4677 verbose "check_effective_target_vect_stridedN: using cached result" 2
4678 } else {
4679 set et_vect_stridedN_saved 0
4680 if { (N & -N) == N
4681 && [check_effective_target_vect_interleave]
4682 && [check_effective_target_vect_extract_even_odd] } {
4683 set et_vect_stridedN_saved 1
4685 if { ([istarget arm*-*-*]
4686 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
4687 set et_vect_stridedN_saved 1
4691 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4692 return $et_vect_stridedN_saved
4697 # Return 1 if the target supports multiple vector sizes
4699 proc check_effective_target_vect_multiple_sizes { } {
4700 global et_vect_multiple_sizes_saved
4702 set et_vect_multiple_sizes_saved 0
4703 if { ([istarget aarch64*-*-*]
4704 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
4705 set et_vect_multiple_sizes_saved 1
4707 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4708 if { ([check_avx_available] && ![check_prefer_avx128]) } {
4709 set et_vect_multiple_sizes_saved 1
4713 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4714 return $et_vect_multiple_sizes_saved
4717 # Return 1 if the target supports vectors of 64 bits.
4719 proc check_effective_target_vect64 { } {
4720 global et_vect64_saved
4722 if [info exists et_vect64_saved] {
4723 verbose "check_effective_target_vect64: using cached result" 2
4724 } else {
4725 set et_vect64_saved 0
4726 if { ([istarget arm*-*-*]
4727 && [check_effective_target_arm_neon_ok]
4728 && [check_effective_target_arm_little_endian])
4729 || [istarget sparc*-*-*] } {
4730 set et_vect64_saved 1
4734 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
4735 return $et_vect64_saved
4738 # Return 1 if the target supports vector copysignf calls.
4740 proc check_effective_target_vect_call_copysignf { } {
4741 global et_vect_call_copysignf_saved
4743 if [info exists et_vect_call_copysignf_saved] {
4744 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
4745 } else {
4746 set et_vect_call_copysignf_saved 0
4747 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4748 || [istarget powerpc*-*-*] } {
4749 set et_vect_call_copysignf_saved 1
4753 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4754 return $et_vect_call_copysignf_saved
4757 # Return 1 if the target supports hardware square root instructions.
4759 proc check_effective_target_sqrt_insn { } {
4760 global et_sqrt_insn_saved
4762 if [info exists et_sqrt_insn_saved] {
4763 verbose "check_effective_target_hw_sqrt: using cached result" 2
4764 } else {
4765 set et_sqrt_insn_saved 0
4766 if { [istarget x86_64-*-*]
4767 || [istarget powerpc*-*-*]
4768 || [istarget aarch64*-*-*]
4769 || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok]) } {
4770 set et_sqrt_insn_saved 1
4774 verbose "check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
4775 return $et_sqrt_insn_saved
4778 # Return 1 if the target supports vector sqrtf calls.
4780 proc check_effective_target_vect_call_sqrtf { } {
4781 global et_vect_call_sqrtf_saved
4783 if [info exists et_vect_call_sqrtf_saved] {
4784 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
4785 } else {
4786 set et_vect_call_sqrtf_saved 0
4787 if { [istarget aarch64*-*-*]
4788 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4789 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
4790 set et_vect_call_sqrtf_saved 1
4794 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4795 return $et_vect_call_sqrtf_saved
4798 # Return 1 if the target supports vector lrint calls.
4800 proc check_effective_target_vect_call_lrint { } {
4801 set et_vect_call_lrint 0
4802 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
4803 && [check_effective_target_ilp32] } {
4804 set et_vect_call_lrint 1
4807 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4808 return $et_vect_call_lrint
4811 # Return 1 if the target supports vector btrunc calls.
4813 proc check_effective_target_vect_call_btrunc { } {
4814 global et_vect_call_btrunc_saved
4816 if [info exists et_vect_call_btrunc_saved] {
4817 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4818 } else {
4819 set et_vect_call_btrunc_saved 0
4820 if { [istarget aarch64*-*-*] } {
4821 set et_vect_call_btrunc_saved 1
4825 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4826 return $et_vect_call_btrunc_saved
4829 # Return 1 if the target supports vector btruncf calls.
4831 proc check_effective_target_vect_call_btruncf { } {
4832 global et_vect_call_btruncf_saved
4834 if [info exists et_vect_call_btruncf_saved] {
4835 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4836 } else {
4837 set et_vect_call_btruncf_saved 0
4838 if { [istarget aarch64*-*-*] } {
4839 set et_vect_call_btruncf_saved 1
4843 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4844 return $et_vect_call_btruncf_saved
4847 # Return 1 if the target supports vector ceil calls.
4849 proc check_effective_target_vect_call_ceil { } {
4850 global et_vect_call_ceil_saved
4852 if [info exists et_vect_call_ceil_saved] {
4853 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4854 } else {
4855 set et_vect_call_ceil_saved 0
4856 if { [istarget aarch64*-*-*] } {
4857 set et_vect_call_ceil_saved 1
4861 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4862 return $et_vect_call_ceil_saved
4865 # Return 1 if the target supports vector ceilf calls.
4867 proc check_effective_target_vect_call_ceilf { } {
4868 global et_vect_call_ceilf_saved
4870 if [info exists et_vect_call_ceilf_saved] {
4871 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4872 } else {
4873 set et_vect_call_ceilf_saved 0
4874 if { [istarget aarch64*-*-*] } {
4875 set et_vect_call_ceilf_saved 1
4879 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4880 return $et_vect_call_ceilf_saved
4883 # Return 1 if the target supports vector floor calls.
4885 proc check_effective_target_vect_call_floor { } {
4886 global et_vect_call_floor_saved
4888 if [info exists et_vect_call_floor_saved] {
4889 verbose "check_effective_target_vect_call_floor: using cached result" 2
4890 } else {
4891 set et_vect_call_floor_saved 0
4892 if { [istarget aarch64*-*-*] } {
4893 set et_vect_call_floor_saved 1
4897 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4898 return $et_vect_call_floor_saved
4901 # Return 1 if the target supports vector floorf calls.
4903 proc check_effective_target_vect_call_floorf { } {
4904 global et_vect_call_floorf_saved
4906 if [info exists et_vect_call_floorf_saved] {
4907 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4908 } else {
4909 set et_vect_call_floorf_saved 0
4910 if { [istarget aarch64*-*-*] } {
4911 set et_vect_call_floorf_saved 1
4915 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4916 return $et_vect_call_floorf_saved
4919 # Return 1 if the target supports vector lceil calls.
4921 proc check_effective_target_vect_call_lceil { } {
4922 global et_vect_call_lceil_saved
4924 if [info exists et_vect_call_lceil_saved] {
4925 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4926 } else {
4927 set et_vect_call_lceil_saved 0
4928 if { [istarget aarch64*-*-*] } {
4929 set et_vect_call_lceil_saved 1
4933 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4934 return $et_vect_call_lceil_saved
4937 # Return 1 if the target supports vector lfloor calls.
4939 proc check_effective_target_vect_call_lfloor { } {
4940 global et_vect_call_lfloor_saved
4942 if [info exists et_vect_call_lfloor_saved] {
4943 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4944 } else {
4945 set et_vect_call_lfloor_saved 0
4946 if { [istarget aarch64*-*-*] } {
4947 set et_vect_call_lfloor_saved 1
4951 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4952 return $et_vect_call_lfloor_saved
4955 # Return 1 if the target supports vector nearbyint calls.
4957 proc check_effective_target_vect_call_nearbyint { } {
4958 global et_vect_call_nearbyint_saved
4960 if [info exists et_vect_call_nearbyint_saved] {
4961 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
4962 } else {
4963 set et_vect_call_nearbyint_saved 0
4964 if { [istarget aarch64*-*-*] } {
4965 set et_vect_call_nearbyint_saved 1
4969 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4970 return $et_vect_call_nearbyint_saved
4973 # Return 1 if the target supports vector nearbyintf calls.
4975 proc check_effective_target_vect_call_nearbyintf { } {
4976 global et_vect_call_nearbyintf_saved
4978 if [info exists et_vect_call_nearbyintf_saved] {
4979 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
4980 } else {
4981 set et_vect_call_nearbyintf_saved 0
4982 if { [istarget aarch64*-*-*] } {
4983 set et_vect_call_nearbyintf_saved 1
4987 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4988 return $et_vect_call_nearbyintf_saved
4991 # Return 1 if the target supports vector round calls.
4993 proc check_effective_target_vect_call_round { } {
4994 global et_vect_call_round_saved
4996 if [info exists et_vect_call_round_saved] {
4997 verbose "check_effective_target_vect_call_round: using cached result" 2
4998 } else {
4999 set et_vect_call_round_saved 0
5000 if { [istarget aarch64*-*-*] } {
5001 set et_vect_call_round_saved 1
5005 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
5006 return $et_vect_call_round_saved
5009 # Return 1 if the target supports vector roundf calls.
5011 proc check_effective_target_vect_call_roundf { } {
5012 global et_vect_call_roundf_saved
5014 if [info exists et_vect_call_roundf_saved] {
5015 verbose "check_effective_target_vect_call_roundf: using cached result" 2
5016 } else {
5017 set et_vect_call_roundf_saved 0
5018 if { [istarget aarch64*-*-*] } {
5019 set et_vect_call_roundf_saved 1
5023 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
5024 return $et_vect_call_roundf_saved
5027 # Return 1 if the target supports section-anchors
5029 proc check_effective_target_section_anchors { } {
5030 global et_section_anchors_saved
5032 if [info exists et_section_anchors_saved] {
5033 verbose "check_effective_target_section_anchors: using cached result" 2
5034 } else {
5035 set et_section_anchors_saved 0
5036 if { [istarget powerpc*-*-*]
5037 || [istarget arm*-*-*] } {
5038 set et_section_anchors_saved 1
5042 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
5043 return $et_section_anchors_saved
5046 # Return 1 if the target supports atomic operations on "int_128" values.
5048 proc check_effective_target_sync_int_128 { } {
5049 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5050 && ![is-effective-target ia32] } {
5051 return 1
5052 } else {
5053 return 0
5057 # Return 1 if the target supports atomic operations on "int_128" values
5058 # and can execute them.
5060 proc check_effective_target_sync_int_128_runtime { } {
5061 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5062 && ![is-effective-target ia32] } {
5063 return [check_cached_effective_target sync_int_128_available {
5064 check_runtime_nocache sync_int_128_available {
5065 #include "cpuid.h"
5066 int main ()
5068 unsigned int eax, ebx, ecx, edx;
5069 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5070 return !(ecx & bit_CMPXCHG16B);
5071 return 1;
5073 } ""
5075 } else {
5076 return 0
5080 # Return 1 if the target supports atomic operations on "long long".
5082 # Note: 32bit x86 targets require -march=pentium in dg-options.
5084 proc check_effective_target_sync_long_long { } {
5085 if { [istarget x86_64-*-*] || [istarget i?86-*-*])
5086 || [istarget aarch64*-*-*]
5087 || [istarget arm*-*-*]
5088 || [istarget alpha*-*-*]
5089 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
5090 return 1
5091 } else {
5092 return 0
5096 # Return 1 if the target supports atomic operations on "long long"
5097 # and can execute them.
5099 # Note: 32bit x86 targets require -march=pentium in dg-options.
5101 proc check_effective_target_sync_long_long_runtime { } {
5102 if { [istarget x86_64-*-*] || [istarget i?86-*-*] } {
5103 return [check_cached_effective_target sync_long_long_available {
5104 check_runtime_nocache sync_long_long_available {
5105 #include "cpuid.h"
5106 int main ()
5108 unsigned int eax, ebx, ecx, edx;
5109 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5110 return !(edx & bit_CMPXCHG8B);
5111 return 1;
5113 } ""
5115 } elseif { [istarget aarch64*-*-*] } {
5116 return 1
5117 } elseif { [istarget arm*-*-linux-*] } {
5118 return [check_runtime sync_longlong_runtime {
5119 #include <stdlib.h>
5120 int main ()
5122 long long l1;
5124 if (sizeof (long long) != 8)
5125 exit (1);
5127 /* Just check for native; checking for kernel fallback is tricky. */
5128 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
5130 exit (0);
5132 } "" ]
5133 } elseif { [istarget alpha*-*-*] } {
5134 return 1
5135 } elseif { ([istarget sparc*-*-*]
5136 && [check_effective_target_lp64]
5137 && [check_effective_target_ultrasparc_hw]) } {
5138 return 1
5139 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
5140 return 1
5141 } else {
5142 return 0
5146 # Return 1 if the target supports byte swap instructions.
5148 proc check_effective_target_bswap { } {
5149 global et_bswap_saved
5151 if [info exists et_bswap_saved] {
5152 verbose "check_effective_target_bswap: using cached result" 2
5153 } else {
5154 set et_bswap_saved 0
5155 if { [istarget aarch64*-*-*]
5156 || [istarget alpha*-*-*]
5157 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5158 || [istarget m68k-*-*]
5159 || [istarget powerpc*-*-*]
5160 || [istarget rs6000-*-*]
5161 || [istarget s390*-*-*] } {
5162 set et_bswap_saved 1
5163 } else {
5164 if { [istarget arm*-*-*]
5165 && [check_no_compiler_messages_nocache arm_v6_or_later object {
5166 #if __ARM_ARCH < 6
5167 #error not armv6 or later
5168 #endif
5169 int i;
5170 } ""] } {
5171 set et_bswap_saved 1
5176 verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
5177 return $et_bswap_saved
5180 # Return 1 if the target supports 16-bit byte swap instructions.
5182 proc check_effective_target_bswap16 { } {
5183 global et_bswap16_saved
5185 if [info exists et_bswap16_saved] {
5186 verbose "check_effective_target_bswap16: using cached result" 2
5187 } else {
5188 set et_bswap16_saved 0
5189 if { [is-effective-target bswap]
5190 && ![istarget alpha*-*-*]
5191 && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
5192 set et_bswap16_saved 1
5196 verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
5197 return $et_bswap16_saved
5200 # Return 1 if the target supports 32-bit byte swap instructions.
5202 proc check_effective_target_bswap32 { } {
5203 global et_bswap32_saved
5205 if [info exists et_bswap32_saved] {
5206 verbose "check_effective_target_bswap32: using cached result" 2
5207 } else {
5208 set et_bswap32_saved 0
5209 if { [is-effective-target bswap] } {
5210 set et_bswap32_saved 1
5214 verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
5215 return $et_bswap32_saved
5218 # Return 1 if the target supports 64-bit byte swap instructions.
5220 proc check_effective_target_bswap64 { } {
5221 global et_bswap64_saved
5223 # expand_unop can expand 64-bit byte swap on 32-bit targets
5224 if { [is-effective-target bswap] && [is-effective-target int32plus] } {
5225 return 1
5227 return 0
5230 # Return 1 if the target supports atomic operations on "int" and "long".
5232 proc check_effective_target_sync_int_long { } {
5233 global et_sync_int_long_saved
5235 if [info exists et_sync_int_long_saved] {
5236 verbose "check_effective_target_sync_int_long: using cached result" 2
5237 } else {
5238 set et_sync_int_long_saved 0
5239 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5240 # load-reserved/store-conditional instructions.
5241 if { [istarget ia64-*-*]
5242 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5243 || [istarget aarch64*-*-*]
5244 || [istarget alpha*-*-*]
5245 || [istarget arm*-*-linux-*]
5246 || [istarget bfin*-*linux*]
5247 || [istarget hppa*-*linux*]
5248 || [istarget s390*-*-*]
5249 || [istarget powerpc*-*-*]
5250 || [istarget crisv32-*-*] || [istarget cris-*-*]
5251 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5252 || [check_effective_target_mips_llsc] } {
5253 set et_sync_int_long_saved 1
5257 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
5258 return $et_sync_int_long_saved
5261 # Return 1 if the target supports atomic operations on "char" and "short".
5263 proc check_effective_target_sync_char_short { } {
5264 global et_sync_char_short_saved
5266 if [info exists et_sync_char_short_saved] {
5267 verbose "check_effective_target_sync_char_short: using cached result" 2
5268 } else {
5269 set et_sync_char_short_saved 0
5270 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5271 # load-reserved/store-conditional instructions.
5272 if { [istarget aarch64*-*-*]
5273 || [istarget ia64-*-*]
5274 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5275 || [istarget alpha*-*-*]
5276 || [istarget arm*-*-linux-*]
5277 || [istarget hppa*-*linux*]
5278 || [istarget s390*-*-*]
5279 || [istarget powerpc*-*-*]
5280 || [istarget crisv32-*-*] || [istarget cris-*-*]
5281 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5282 || [check_effective_target_mips_llsc] } {
5283 set et_sync_char_short_saved 1
5287 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
5288 return $et_sync_char_short_saved
5291 # Return 1 if the target uses a ColdFire FPU.
5293 proc check_effective_target_coldfire_fpu { } {
5294 return [check_no_compiler_messages coldfire_fpu assembly {
5295 #ifndef __mcffpu__
5296 #error !__mcffpu__
5297 #endif
5301 # Return true if this is a uClibc target.
5303 proc check_effective_target_uclibc {} {
5304 return [check_no_compiler_messages uclibc object {
5305 #include <features.h>
5306 #if !defined (__UCLIBC__)
5307 #error !__UCLIBC__
5308 #endif
5312 # Return true if this is a uclibc target and if the uclibc feature
5313 # described by __$feature__ is not present.
5315 proc check_missing_uclibc_feature {feature} {
5316 return [check_no_compiler_messages $feature object "
5317 #include <features.h>
5318 #if !defined (__UCLIBC) || defined (__${feature}__)
5319 #error FOO
5320 #endif
5324 # Return true if this is a Newlib target.
5326 proc check_effective_target_newlib {} {
5327 return [check_no_compiler_messages newlib object {
5328 #include <newlib.h>
5332 # Return true if this is NOT a Bionic target.
5334 proc check_effective_target_non_bionic {} {
5335 return [check_no_compiler_messages non_bionic object {
5336 #include <ctype.h>
5337 #if defined (__BIONIC__)
5338 #error FOO
5339 #endif
5343 # Return true if this target has error.h header.
5345 proc check_effective_target_error_h {} {
5346 return [check_no_compiler_messages error_h object {
5347 #include <error.h>
5351 # Return true if this target has tgmath.h header.
5353 proc check_effective_target_tgmath_h {} {
5354 return [check_no_compiler_messages tgmath_h object {
5355 #include <tgmath.h>
5359 # Return true if target's libc supports complex functions.
5361 proc check_effective_target_libc_has_complex_functions {} {
5362 return [check_no_compiler_messages libc_has_complex_functions object {
5363 #include <complex.h>
5367 # Return 1 if
5368 # (a) an error of a few ULP is expected in string to floating-point
5369 # conversion functions; and
5370 # (b) overflow is not always detected correctly by those functions.
5372 proc check_effective_target_lax_strtofp {} {
5373 # By default, assume that all uClibc targets suffer from this.
5374 return [check_effective_target_uclibc]
5377 # Return 1 if this is a target for which wcsftime is a dummy
5378 # function that always returns 0.
5380 proc check_effective_target_dummy_wcsftime {} {
5381 # By default, assume that all uClibc targets suffer from this.
5382 return [check_effective_target_uclibc]
5385 # Return 1 if constructors with initialization priority arguments are
5386 # supposed on this target.
5388 proc check_effective_target_init_priority {} {
5389 return [check_no_compiler_messages init_priority assembly "
5390 void f() __attribute__((constructor (1000)));
5391 void f() \{\}
5395 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
5396 # This can be used with any check_* proc that takes no argument and
5397 # returns only 1 or 0. It could be used with check_* procs that take
5398 # arguments with keywords that pass particular arguments.
5400 proc is-effective-target { arg } {
5401 set selected 0
5402 if { [info procs check_effective_target_${arg}] != [list] } {
5403 set selected [check_effective_target_${arg}]
5404 } else {
5405 switch $arg {
5406 "vmx_hw" { set selected [check_vmx_hw_available] }
5407 "vsx_hw" { set selected [check_vsx_hw_available] }
5408 "p8vector_hw" { set selected [check_p8vector_hw_available] }
5409 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
5410 "dfp_hw" { set selected [check_dfp_hw_available] }
5411 "htm_hw" { set selected [check_htm_hw_available] }
5412 "named_sections" { set selected [check_named_sections_available] }
5413 "gc_sections" { set selected [check_gc_sections_available] }
5414 "cxa_atexit" { set selected [check_cxa_atexit_available] }
5415 default { error "unknown effective target keyword `$arg'" }
5418 verbose "is-effective-target: $arg $selected" 2
5419 return $selected
5422 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
5424 proc is-effective-target-keyword { arg } {
5425 if { [info procs check_effective_target_${arg}] != [list] } {
5426 return 1
5427 } else {
5428 # These have different names for their check_* procs.
5429 switch $arg {
5430 "vmx_hw" { return 1 }
5431 "vsx_hw" { return 1 }
5432 "p8vector_hw" { return 1 }
5433 "ppc_recip_hw" { return 1 }
5434 "dfp_hw" { return 1 }
5435 "htm_hw" { return 1 }
5436 "named_sections" { return 1 }
5437 "gc_sections" { return 1 }
5438 "cxa_atexit" { return 1 }
5439 default { return 0 }
5444 # Return 1 if target default to short enums
5446 proc check_effective_target_short_enums { } {
5447 return [check_no_compiler_messages short_enums assembly {
5448 enum foo { bar };
5449 int s[sizeof (enum foo) == 1 ? 1 : -1];
5453 # Return 1 if target supports merging string constants at link time.
5455 proc check_effective_target_string_merging { } {
5456 return [check_no_messages_and_pattern string_merging \
5457 "rodata\\.str" assembly {
5458 const char *var = "String";
5459 } {-O2}]
5462 # Return 1 if target has the basic signed and unsigned types in
5463 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
5464 # working <stdint.h> for all targets.
5466 proc check_effective_target_stdint_types { } {
5467 return [check_no_compiler_messages stdint_types assembly {
5468 #include <stdint.h>
5469 int8_t a; int16_t b; int32_t c; int64_t d;
5470 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5474 # Return 1 if target has the basic signed and unsigned types in
5475 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
5476 # these types agree with those in the header, as some systems have
5477 # only <inttypes.h>.
5479 proc check_effective_target_inttypes_types { } {
5480 return [check_no_compiler_messages inttypes_types assembly {
5481 #include <inttypes.h>
5482 int8_t a; int16_t b; int32_t c; int64_t d;
5483 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5487 # Return 1 if programs are intended to be run on a simulator
5488 # (i.e. slowly) rather than hardware (i.e. fast).
5490 proc check_effective_target_simulator { } {
5492 # All "src/sim" simulators set this one.
5493 if [board_info target exists is_simulator] {
5494 return [board_info target is_simulator]
5497 # The "sid" simulators don't set that one, but at least they set
5498 # this one.
5499 if [board_info target exists slow_simulator] {
5500 return [board_info target slow_simulator]
5503 return 0
5506 # Return 1 if programs are intended to be run on hardware rather than
5507 # on a simulator
5509 proc check_effective_target_hw { } {
5511 # All "src/sim" simulators set this one.
5512 if [board_info target exists is_simulator] {
5513 if [board_info target is_simulator] {
5514 return 0
5515 } else {
5516 return 1
5520 # The "sid" simulators don't set that one, but at least they set
5521 # this one.
5522 if [board_info target exists slow_simulator] {
5523 if [board_info target slow_simulator] {
5524 return 0
5525 } else {
5526 return 1
5530 return 1
5533 # Return 1 if the target is a VxWorks kernel.
5535 proc check_effective_target_vxworks_kernel { } {
5536 return [check_no_compiler_messages vxworks_kernel assembly {
5537 #if !defined __vxworks || defined __RTP__
5538 #error NO
5539 #endif
5543 # Return 1 if the target is a VxWorks RTP.
5545 proc check_effective_target_vxworks_rtp { } {
5546 return [check_no_compiler_messages vxworks_rtp assembly {
5547 #if !defined __vxworks || !defined __RTP__
5548 #error NO
5549 #endif
5553 # Return 1 if the target is expected to provide wide character support.
5555 proc check_effective_target_wchar { } {
5556 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
5557 return 0
5559 return [check_no_compiler_messages wchar assembly {
5560 #include <wchar.h>
5564 # Return 1 if the target has <pthread.h>.
5566 proc check_effective_target_pthread_h { } {
5567 return [check_no_compiler_messages pthread_h assembly {
5568 #include <pthread.h>
5572 # Return 1 if the target can truncate a file from a file-descriptor,
5573 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
5574 # chsize. We test for a trivially functional truncation; no stubs.
5575 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
5576 # different function to be used.
5578 proc check_effective_target_fd_truncate { } {
5579 set prog {
5580 #define _FILE_OFFSET_BITS 64
5581 #include <unistd.h>
5582 #include <stdio.h>
5583 #include <stdlib.h>
5584 #include <string.h>
5585 int main ()
5587 FILE *f = fopen ("tst.tmp", "wb");
5588 int fd;
5589 const char t[] = "test writing more than ten characters";
5590 char s[11];
5591 int status = 0;
5592 fd = fileno (f);
5593 write (fd, t, sizeof (t) - 1);
5594 lseek (fd, 0, 0);
5595 if (ftruncate (fd, 10) != 0)
5596 status = 1;
5597 close (fd);
5598 fclose (f);
5599 if (status)
5601 unlink ("tst.tmp");
5602 exit (status);
5604 f = fopen ("tst.tmp", "rb");
5605 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
5606 status = 1;
5607 fclose (f);
5608 unlink ("tst.tmp");
5609 exit (status);
5613 if { [check_runtime ftruncate $prog] } {
5614 return 1;
5617 regsub "ftruncate" $prog "chsize" prog
5618 return [check_runtime chsize $prog]
5621 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
5623 proc add_options_for_c99_runtime { flags } {
5624 if { [istarget *-*-solaris2*] } {
5625 return "$flags -std=c99"
5627 if { [istarget powerpc-*-darwin*] } {
5628 return "$flags -mmacosx-version-min=10.3"
5630 return $flags
5633 # Add to FLAGS all the target-specific flags needed to enable
5634 # full IEEE compliance mode.
5636 proc add_options_for_ieee { flags } {
5637 if { [istarget alpha*-*-*]
5638 || [istarget sh*-*-*] } {
5639 return "$flags -mieee"
5641 if { [istarget rx-*-*] } {
5642 return "$flags -mnofpu"
5644 return $flags
5647 if {![info exists flags_to_postpone]} {
5648 set flags_to_postpone ""
5651 # Add to FLAGS the flags needed to enable functions to bind locally
5652 # when using pic/PIC passes in the testsuite.
5653 proc add_options_for_bind_pic_locally { flags } {
5654 global flags_to_postpone
5656 # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
5657 # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
5658 # order to make sure that the multilib_flags doesn't override this.
5660 if {[check_no_compiler_messages using_pic2 assembly {
5661 #if __PIC__ != 2
5662 #error __PIC__ != 2
5663 #endif
5664 }]} {
5665 set flags_to_postpone "-fPIE"
5666 return $flags
5668 if {[check_no_compiler_messages using_pic1 assembly {
5669 #if __PIC__ != 1
5670 #error __PIC__ != 1
5671 #endif
5672 }]} {
5673 set flags_to_postpone "-fpie"
5674 return $flags
5676 return $flags
5679 # Add to FLAGS the flags needed to enable 64-bit vectors.
5681 proc add_options_for_double_vectors { flags } {
5682 if [is-effective-target arm_neon_ok] {
5683 return "$flags -mvectorize-with-neon-double"
5686 return $flags
5689 # Add to FLAGS the flags needed to disable inlining of
5690 # UPC run-time access routines.
5692 proc add_options_for_upc_library_calls { flags } {
5693 return "$flags -fno-upc-inline-lib"
5696 # Check if UPC struct pts build
5698 proc check_effective_target_upc_struct_pts { } {
5699 return [check_no_compiler_messages upc_struct_pts object {
5700 #ifndef __UPC_PTS_STRUCT_REP__
5701 # error struct PTS is not supported
5702 #endif
5703 } "-fupc -fno-upc-pre-include" ]
5706 # Check if UPC packed pts build
5708 proc check_effective_target_upc_packed_pts { } {
5709 return [check_no_compiler_messages upc_packed_pts object {
5710 #ifndef __UPC_PTS_PACKED_REP__
5711 # error packed PTS is not supported
5712 #endif
5713 } "-fupc -fno-upc-pre-include" ]
5716 # Return 1 if the target provides a full C99 runtime.
5718 proc check_effective_target_c99_runtime { } {
5719 return [check_cached_effective_target c99_runtime {
5720 global srcdir
5722 set file [open "$srcdir/gcc.dg/builtins-config.h"]
5723 set contents [read $file]
5724 close $file
5725 append contents {
5726 #ifndef HAVE_C99_RUNTIME
5727 #error !HAVE_C99_RUNTIME
5728 #endif
5730 check_no_compiler_messages_nocache c99_runtime assembly \
5731 $contents [add_options_for_c99_runtime ""]
5735 # Return 1 if target wchar_t is at least 4 bytes.
5737 proc check_effective_target_4byte_wchar_t { } {
5738 return [check_no_compiler_messages 4byte_wchar_t object {
5739 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
5743 # Return 1 if the target supports automatic stack alignment.
5745 proc check_effective_target_automatic_stack_alignment { } {
5746 # Ordinarily x86 supports automatic stack alignment ...
5747 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
5748 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
5749 # ... except Win64 SEH doesn't. Succeed for Win32 though.
5750 return [check_effective_target_ilp32];
5752 return 1;
5754 return 0;
5757 # Return true if we are compiling for AVX target.
5759 proc check_avx_available { } {
5760 if { [check_no_compiler_messages avx_available assembly {
5761 #ifndef __AVX__
5762 #error unsupported
5763 #endif
5764 } ""] } {
5765 return 1;
5767 return 0;
5770 # Return true if 32- and 16-bytes vectors are available.
5772 proc check_effective_target_vect_sizes_32B_16B { } {
5773 if { [check_avx_available] && ![check_prefer_avx128] } {
5774 return 1;
5775 } else {
5776 return 0;
5780 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5781 # are available.
5783 proc check_prefer_avx128 { } {
5784 if ![check_avx_available] {
5785 return 0;
5787 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5788 float a[1024],b[1024],c[1024];
5789 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5790 } "-O2 -ftree-vectorize"]
5794 # Return 1 if avx512f instructions can be compiled.
5796 proc check_effective_target_avx512f { } {
5797 return [check_no_compiler_messages avx512f object {
5798 typedef double __m512d __attribute__ ((__vector_size__ (64)));
5800 __m512d _mm512_add (__m512d a)
5802 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
5804 } "-O2 -mavx512f" ]
5807 # Return 1 if avx instructions can be compiled.
5809 proc check_effective_target_avx { } {
5810 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
5811 return 0
5813 return [check_no_compiler_messages avx object {
5814 void _mm256_zeroall (void)
5816 __builtin_ia32_vzeroall ();
5818 } "-O2 -mavx" ]
5821 # Return 1 if avx2 instructions can be compiled.
5822 proc check_effective_target_avx2 { } {
5823 return [check_no_compiler_messages avx2 object {
5824 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
5825 __v4di
5826 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
5828 return __builtin_ia32_andnotsi256 (__X, __Y);
5830 } "-O0 -mavx2" ]
5833 # Return 1 if sse instructions can be compiled.
5834 proc check_effective_target_sse { } {
5835 return [check_no_compiler_messages sse object {
5836 int main ()
5838 __builtin_ia32_stmxcsr ();
5839 return 0;
5841 } "-O2 -msse" ]
5844 # Return 1 if sse2 instructions can be compiled.
5845 proc check_effective_target_sse2 { } {
5846 return [check_no_compiler_messages sse2 object {
5847 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5849 __m128i _mm_srli_si128 (__m128i __A, int __N)
5851 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5853 } "-O2 -msse2" ]
5856 # Return 1 if F16C instructions can be compiled.
5858 proc check_effective_target_f16c { } {
5859 return [check_no_compiler_messages f16c object {
5860 #include "immintrin.h"
5861 float
5862 foo (unsigned short val)
5864 return _cvtsh_ss (val);
5866 } "-O2 -mf16c" ]
5869 # Return 1 if C wchar_t type is compatible with char16_t.
5871 proc check_effective_target_wchar_t_char16_t_compatible { } {
5872 return [check_no_compiler_messages wchar_t_char16_t object {
5873 __WCHAR_TYPE__ wc;
5874 __CHAR16_TYPE__ *p16 = &wc;
5875 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5879 # Return 1 if C wchar_t type is compatible with char32_t.
5881 proc check_effective_target_wchar_t_char32_t_compatible { } {
5882 return [check_no_compiler_messages wchar_t_char32_t object {
5883 __WCHAR_TYPE__ wc;
5884 __CHAR32_TYPE__ *p32 = &wc;
5885 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5889 # Return 1 if pow10 function exists.
5891 proc check_effective_target_pow10 { } {
5892 return [check_runtime pow10 {
5893 #include <math.h>
5894 int main () {
5895 double x;
5896 x = pow10 (1);
5897 return 0;
5899 } "-lm" ]
5902 # Return 1 if current options generate DFP instructions, 0 otherwise.
5904 proc check_effective_target_hard_dfp {} {
5905 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5906 typedef float d64 __attribute__((mode(DD)));
5907 d64 x, y, z;
5908 void foo (void) { z = x + y; }
5912 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5913 # for strchr etc. functions.
5915 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5916 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5917 #include <string.h>
5918 #include <wchar.h>
5919 #if !defined(__cplusplus) \
5920 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5921 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5922 ISO C++ correct string.h and wchar.h protos not supported.
5923 #else
5924 int i;
5925 #endif
5929 # Return 1 if GNU as is used.
5931 proc check_effective_target_gas { } {
5932 global use_gas_saved
5933 global tool
5935 if {![info exists use_gas_saved]} {
5936 # Check if the as used by gcc is GNU as.
5937 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5938 # Provide /dev/null as input, otherwise gas times out reading from
5939 # stdin.
5940 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5941 set as_output [lindex $status 1]
5942 if { [ string first "GNU" $as_output ] >= 0 } {
5943 set use_gas_saved 1
5944 } else {
5945 set use_gas_saved 0
5948 return $use_gas_saved
5951 # Return 1 if GNU ld is used.
5953 proc check_effective_target_gld { } {
5954 global use_gld_saved
5955 global tool
5957 if {![info exists use_gld_saved]} {
5958 # Check if the ld used by gcc is GNU ld.
5959 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5960 set status [remote_exec host "$gcc_ld" "--version"]
5961 set ld_output [lindex $status 1]
5962 if { [ string first "GNU" $ld_output ] >= 0 } {
5963 set use_gld_saved 1
5964 } else {
5965 set use_gld_saved 0
5968 return $use_gld_saved
5971 # Return 1 if the compiler has been configure with link-time optimization
5972 # (LTO) support.
5974 proc check_effective_target_lto { } {
5975 if { [istarget nvptx-*-*] } {
5976 return 0;
5978 return [check_no_compiler_messages lto object {
5979 void foo (void) { }
5980 } "-flto"]
5983 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
5985 proc check_effective_target_maybe_x32 { } {
5986 return [check_no_compiler_messages maybe_x32 object {
5987 void foo (void) {}
5988 } "-mx32 -maddress-mode=short"]
5991 # Return 1 if this target supports the -fsplit-stack option, 0
5992 # otherwise.
5994 proc check_effective_target_split_stack {} {
5995 return [check_no_compiler_messages split_stack object {
5996 void foo (void) { }
5997 } "-fsplit-stack"]
6000 # Return 1 if this target supports the -masm=intel option, 0
6001 # otherwise
6003 proc check_effective_target_masm_intel {} {
6004 return [check_no_compiler_messages masm_intel object {
6005 extern void abort (void);
6006 } "-masm=intel"]
6009 # Return 1 if the language for the compiler under test is C.
6011 proc check_effective_target_c { } {
6012 global tool
6013 if [string match $tool "gcc"] {
6014 return 1
6016 return 0
6019 # Return 1 if the language for the compiler under test is C++.
6021 proc check_effective_target_c++ { } {
6022 global tool
6023 if [string match $tool "g++"] {
6024 return 1
6026 return 0
6029 set cxx_default "c++14"
6030 # Check whether the current active language standard supports the features
6031 # of C++11/C++14 by checking for the presence of one of the -std flags.
6032 # This assumes that the default for the compiler is $cxx_default, and that
6033 # there will never be multiple -std= arguments on the command line.
6034 proc check_effective_target_c++11_only { } {
6035 global cxx_default
6036 if ![check_effective_target_c++] {
6037 return 0
6039 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
6040 return 1
6042 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
6043 return 1
6045 return 0
6047 proc check_effective_target_c++11 { } {
6048 if [check_effective_target_c++11_only] {
6049 return 1
6051 return [check_effective_target_c++14]
6053 proc check_effective_target_c++11_down { } {
6054 if ![check_effective_target_c++] {
6055 return 0
6057 return [expr ![check_effective_target_c++14] ]
6060 proc check_effective_target_c++14_only { } {
6061 global cxx_default
6062 if ![check_effective_target_c++] {
6063 return 0
6065 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
6066 return 1
6068 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
6069 return 1
6071 return 0
6074 proc check_effective_target_c++14 { } {
6075 if [check_effective_target_c++14_only] {
6076 return 1
6078 return [check_effective_target_c++1z]
6080 proc check_effective_target_c++14_down { } {
6081 if ![check_effective_target_c++] {
6082 return 0
6084 return [expr ![check_effective_target_c++1z] ]
6087 proc check_effective_target_c++98_only { } {
6088 global cxx_default
6089 if ![check_effective_target_c++] {
6090 return 0
6092 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
6093 return 1
6095 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
6096 return 1
6098 return 0
6101 proc check_effective_target_c++1z_only { } {
6102 global cxx_default
6103 if ![check_effective_target_c++] {
6104 return 0
6106 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
6107 return 1
6109 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
6110 return 1
6112 return 0
6114 proc check_effective_target_c++1z { } {
6115 return [check_effective_target_c++1z_only]
6118 # Return 1 if expensive testcases should be run.
6120 proc check_effective_target_run_expensive_tests { } {
6121 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
6122 return 1
6124 return 0
6127 # Returns 1 if "mempcpy" is available on the target system.
6129 proc check_effective_target_mempcpy {} {
6130 return [check_function_available "mempcpy"]
6133 # Returns 1 if "stpcpy" is available on the target system.
6135 proc check_effective_target_stpcpy {} {
6136 return [check_function_available "stpcpy"]
6139 # Check whether the vectorizer tests are supported by the target and
6140 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
6141 # Set dg-do-what-default to either compile or run, depending on target
6142 # capabilities. Return 1 if vectorizer tests are supported by
6143 # target, 0 otherwise.
6145 proc check_vect_support_and_set_flags { } {
6146 global DEFAULT_VECTCFLAGS
6147 global dg-do-what-default
6149 if [istarget powerpc-*paired*] {
6150 lappend DEFAULT_VECTCFLAGS "-mpaired"
6151 if [check_750cl_hw_available] {
6152 set dg-do-what-default run
6153 } else {
6154 set dg-do-what-default compile
6156 } elseif [istarget powerpc*-*-*] {
6157 # Skip targets not supporting -maltivec.
6158 if ![is-effective-target powerpc_altivec_ok] {
6159 return 0
6162 lappend DEFAULT_VECTCFLAGS "-maltivec"
6163 if [check_p8vector_hw_available] {
6164 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
6165 } elseif [check_vsx_hw_available] {
6166 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
6169 if [check_vmx_hw_available] {
6170 set dg-do-what-default run
6171 } else {
6172 if [is-effective-target ilp32] {
6173 # Specify a cpu that supports VMX for compile-only tests.
6174 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
6176 set dg-do-what-default compile
6178 } elseif { [istarget spu-*-*] } {
6179 set dg-do-what-default run
6180 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
6181 lappend DEFAULT_VECTCFLAGS "-msse2"
6182 if { [check_effective_target_sse2_runtime] } {
6183 set dg-do-what-default run
6184 } else {
6185 set dg-do-what-default compile
6187 } elseif { [istarget mips*-*-*]
6188 && ([check_effective_target_mpaired_single]
6189 || [check_effective_target_mips_loongson])
6190 && [check_effective_target_nomips16] } {
6191 if { [check_effective_target_mpaired_single] } {
6192 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
6194 set dg-do-what-default run
6195 } elseif [istarget sparc*-*-*] {
6196 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
6197 if [check_effective_target_ultrasparc_hw] {
6198 set dg-do-what-default run
6199 } else {
6200 set dg-do-what-default compile
6202 } elseif [istarget alpha*-*-*] {
6203 # Alpha's vectorization capabilities are extremely limited.
6204 # It's more effort than its worth disabling all of the tests
6205 # that it cannot pass. But if you actually want to see what
6206 # does work, command out the return.
6207 return 0
6209 lappend DEFAULT_VECTCFLAGS "-mmax"
6210 if [check_alpha_max_hw_available] {
6211 set dg-do-what-default run
6212 } else {
6213 set dg-do-what-default compile
6215 } elseif [istarget ia64-*-*] {
6216 set dg-do-what-default run
6217 } elseif [is-effective-target arm_neon_ok] {
6218 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
6219 # NEON does not support denormals, so is not used for vectorization by
6220 # default to avoid loss of precision. We must pass -ffast-math to test
6221 # vectorization of float operations.
6222 lappend DEFAULT_VECTCFLAGS "-ffast-math"
6223 if [is-effective-target arm_neon_hw] {
6224 set dg-do-what-default run
6225 } else {
6226 set dg-do-what-default compile
6228 } elseif [istarget "aarch64*-*-*"] {
6229 set dg-do-what-default run
6230 } else {
6231 return 0
6234 return 1
6237 # Return 1 if the target does *not* require strict alignment.
6239 proc check_effective_target_non_strict_align {} {
6240 return [check_no_compiler_messages non_strict_align assembly {
6241 char *y;
6242 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
6243 c *z;
6244 void foo(void) { z = (c *) y; }
6245 } "-Wcast-align"]
6248 # Return 1 if the target has <ucontext.h>.
6250 proc check_effective_target_ucontext_h { } {
6251 return [check_no_compiler_messages ucontext_h assembly {
6252 #include <ucontext.h>
6256 proc check_effective_target_aarch64_tiny { } {
6257 if { [istarget aarch64*-*-*] } {
6258 return [check_no_compiler_messages aarch64_tiny object {
6259 #ifdef __AARCH64_CMODEL_TINY__
6260 int dummy;
6261 #else
6262 #error target not AArch64 tiny code model
6263 #endif
6265 } else {
6266 return 0
6270 proc check_effective_target_aarch64_small { } {
6271 if { [istarget aarch64*-*-*] } {
6272 return [check_no_compiler_messages aarch64_small object {
6273 #ifdef __AARCH64_CMODEL_SMALL__
6274 int dummy;
6275 #else
6276 #error target not AArch64 small code model
6277 #endif
6279 } else {
6280 return 0
6284 proc check_effective_target_aarch64_large { } {
6285 if { [istarget aarch64*-*-*] } {
6286 return [check_no_compiler_messages aarch64_large object {
6287 #ifdef __AARCH64_CMODEL_LARGE__
6288 int dummy;
6289 #else
6290 #error target not AArch64 large code model
6291 #endif
6293 } else {
6294 return 0
6298 # Return 1 if <fenv.h> is available with all the standard IEEE
6299 # exceptions and floating-point exceptions are raised by arithmetic
6300 # operations. (If the target requires special options for "inexact"
6301 # exceptions, those need to be specified in the testcases.)
6303 proc check_effective_target_fenv_exceptions {} {
6304 return [check_runtime fenv_exceptions {
6305 #include <fenv.h>
6306 #include <stdlib.h>
6307 #ifndef FE_DIVBYZERO
6308 # error Missing FE_DIVBYZERO
6309 #endif
6310 #ifndef FE_INEXACT
6311 # error Missing FE_INEXACT
6312 #endif
6313 #ifndef FE_INVALID
6314 # error Missing FE_INVALID
6315 #endif
6316 #ifndef FE_OVERFLOW
6317 # error Missing FE_OVERFLOW
6318 #endif
6319 #ifndef FE_UNDERFLOW
6320 # error Missing FE_UNDERFLOW
6321 #endif
6322 volatile float a = 0.0f, r;
6324 main (void)
6326 r = a / a;
6327 if (fetestexcept (FE_INVALID))
6328 exit (0);
6329 else
6330 abort ();
6332 } [add_options_for_ieee "-std=gnu99"]]
6335 proc check_effective_target_tiny {} {
6336 global et_target_tiny_saved
6338 if [info exists et_target_tine_saved] {
6339 verbose "check_effective_target_tiny: using cached result" 2
6340 } else {
6341 set et_target_tiny_saved 0
6342 if { [istarget aarch64*-*-*]
6343 && [check_effective_target_aarch64_tiny] } {
6344 set et_target_tiny_saved 1
6348 return $et_target_tiny_saved
6351 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
6353 proc check_effective_target_logical_op_short_circuit {} {
6354 if { [istarget mips*-*-*]
6355 || [istarget arc*-*-*]
6356 || [istarget avr*-*-*]
6357 || [istarget crisv32-*-*] || [istarget cris-*-*]
6358 || [istarget mmix-*-*]
6359 || [istarget s390*-*-*]
6360 || [istarget powerpc*-*-*]
6361 || [istarget nios2*-*-*]
6362 || [istarget visium-*-*]
6363 || [check_effective_target_arm_cortex_m] } {
6364 return 1
6366 return 0
6369 # Record that dg-final test TEST requires convential compilation.
6371 proc force_conventional_output_for { test } {
6372 if { [info proc $test] == "" } {
6373 perror "$test does not exist"
6374 exit 1
6376 proc ${test}_required_options {} {
6377 global gcc_force_conventional_output
6378 return $gcc_force_conventional_output
6382 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
6383 # otherwise. Cache the result.
6385 proc check_effective_target_pie_copyreloc { } {
6386 global pie_copyreloc_available_saved
6387 global tool
6388 global GCC_UNDER_TEST
6390 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6391 return 0
6394 # Need auto-host.h to check linker support.
6395 if { ![file exists ../../auto-host.h ] } {
6396 return 0
6399 if [info exists pie_copyreloc_available_saved] {
6400 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
6401 } else {
6402 # Set up and compile to see if linker supports PIE with copy
6403 # reloc. Include the current process ID in the file names to
6404 # prevent conflicts with invocations for multiple testsuites.
6406 set src pie[pid].c
6407 set obj pie[pid].o
6409 set f [open $src "w"]
6410 puts $f "#include \"../../auto-host.h\""
6411 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
6412 puts $f "# error Linker does not support PIE with copy reloc."
6413 puts $f "#endif"
6414 close $f
6416 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
6417 set lines [${tool}_target_compile $src $obj object ""]
6419 file delete $src
6420 file delete $obj
6422 if [string match "" $lines] then {
6423 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
6424 set pie_copyreloc_available_saved 1
6425 } else {
6426 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
6427 set pie_copyreloc_available_saved 0
6431 return $pie_copyreloc_available_saved
6434 # Return 1 if the target uses comdat groups.
6436 proc check_effective_target_comdat_group {} {
6437 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
6438 // C++
6439 inline int foo () { return 1; }
6440 int (*fn) () = foo;