2015-09-24 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob82697f4e4df4ff24c09a625e0692a1f89b5fe817
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
120 global et_prop_list
122 set target [current_target_name]
123 if {![info exists et_cache($prop,target)]
124 || $et_cache($prop,target) != $target} {
125 verbose "check_cached_effective_target $prop: checking $target" 2
126 set et_cache($prop,target) $target
127 set et_cache($prop,value) [uplevel eval $args]
128 if {![info exists et_prop_list]
129 || [lsearch $et_prop_list $prop] < 0} {
130 lappend et_prop_list $prop
132 verbose "check_cached_effective_target cached list is now: $et_prop_list" 2
134 set value $et_cache($prop,value)
135 verbose "check_cached_effective_target $prop: returning $value for $target" 2
136 return $value
139 # Clear effective-target cache. This is useful after testing
140 # effective-target features and overriding TEST_ALWAYS_FLAGS and/or
141 # ALWAYS_CXXFLAGS.
142 # If one changes ALWAYS_CXXFLAGS or TEST_ALWAYS_FLAGS then they should
143 # do a clear_effective_target_cache at the end as the target cache can
144 # make decisions based upon the flags, and those decisions need to be
145 # redone when the flags change. An example of this is the
146 # asan_init/asan_finish pair.
148 proc clear_effective_target_cache { } {
149 global et_cache
150 global et_prop_list
152 if {[info exists et_prop_list]} {
153 verbose "clear_effective_target_cache: $et_prop_list" 2
154 foreach prop $et_prop_list {
155 unset et_cache($prop,value)
156 unset et_cache($prop,target)
158 unset et_prop_list
162 # Like check_compile, but delete the output file and return true if the
163 # compiler printed no messages.
164 proc check_no_compiler_messages_nocache {args} {
165 set result [eval check_compile $args]
166 set lines [lindex $result 0]
167 set output [lindex $result 1]
168 remote_file build delete $output
169 return [string match "" $lines]
172 # Like check_no_compiler_messages_nocache, but cache the result.
173 # PROP is the property we're checking, and doubles as a prefix for
174 # temporary filenames.
175 proc check_no_compiler_messages {prop args} {
176 return [check_cached_effective_target $prop {
177 eval [list check_no_compiler_messages_nocache $prop] $args
181 # Like check_compile, but return true if the compiler printed no
182 # messages and if the contents of the output file satisfy PATTERN.
183 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
184 # don't match regular expression REGEXP, otherwise they satisfy it
185 # if they do match regular expression PATTERN. (PATTERN can start
186 # with something like "[!]" if the regular expression needs to match
187 # "!" as the first character.)
189 # Delete the output file before returning. The other arguments are
190 # as for check_compile.
191 proc check_no_messages_and_pattern_nocache {basename pattern args} {
192 global tool
194 set result [eval [list check_compile $basename] $args]
195 set lines [lindex $result 0]
196 set output [lindex $result 1]
198 set ok 0
199 if { [string match "" $lines] } {
200 set chan [open "$output"]
201 set invert [regexp {^!(.*)} $pattern dummy pattern]
202 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
203 close $chan
206 remote_file build delete $output
207 return $ok
210 # Like check_no_messages_and_pattern_nocache, but cache the result.
211 # PROP is the property we're checking, and doubles as a prefix for
212 # temporary filenames.
213 proc check_no_messages_and_pattern {prop pattern args} {
214 return [check_cached_effective_target $prop {
215 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
219 # Try to compile and run an executable from code CONTENTS. Return true
220 # if the compiler reports no messages and if execution "passes" in the
221 # usual DejaGNU sense. The arguments are as for check_compile, with
222 # TYPE implicitly being "executable".
223 proc check_runtime_nocache {basename contents args} {
224 global tool
226 set result [eval [list check_compile $basename executable $contents] $args]
227 set lines [lindex $result 0]
228 set output [lindex $result 1]
230 set ok 0
231 if { [string match "" $lines] } {
232 # No error messages, everything is OK.
233 set result [remote_load target "./$output" "" ""]
234 set status [lindex $result 0]
235 verbose "check_runtime_nocache $basename: status is <$status>" 2
236 if { $status == "pass" } {
237 set ok 1
240 remote_file build delete $output
241 return $ok
244 # Like check_runtime_nocache, but cache the result. PROP is the
245 # property we're checking, and doubles as a prefix for temporary
246 # filenames.
247 proc check_runtime {prop args} {
248 global tool
250 return [check_cached_effective_target $prop {
251 eval [list check_runtime_nocache $prop] $args
255 ###############################
256 # proc check_weak_available { }
257 ###############################
259 # weak symbols are only supported in some configs/object formats
260 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
262 proc check_weak_available { } {
263 global target_cpu
265 # All mips targets should support it
267 if { [ string first "mips" $target_cpu ] >= 0 } {
268 return 1
271 # All AIX targets should support it
273 if { [istarget *-*-aix*] } {
274 return 1
277 # All solaris2 targets should support it
279 if { [istarget *-*-solaris2*] } {
280 return 1
283 # Windows targets Cygwin and MingW32 support it
285 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
286 return 1
289 # HP-UX 10.X doesn't support it
291 if { [istarget hppa*-*-hpux10*] } {
292 return 0
295 # ELF and ECOFF support it. a.out does with gas/gld but may also with
296 # other linkers, so we should try it
298 set objformat [gcc_target_object_format]
300 switch $objformat {
301 elf { return 1 }
302 ecoff { return 1 }
303 a.out { return 1 }
304 mach-o { return 1 }
305 som { return 1 }
306 unknown { return -1 }
307 default { return 0 }
311 ###############################
312 # proc check_weak_override_available { }
313 ###############################
315 # Like check_weak_available, but return 0 if weak symbol definitions
316 # cannot be overridden.
318 proc check_weak_override_available { } {
319 if { [istarget *-*-mingw*] } {
320 return 0
322 return [check_weak_available]
325 ###############################
326 # proc check_visibility_available { what_kind }
327 ###############################
329 # The visibility attribute is only support in some object formats
330 # This proc returns 1 if it is supported, 0 if not.
331 # The argument is the kind of visibility, default/protected/hidden/internal.
333 proc check_visibility_available { what_kind } {
334 if [string match "" $what_kind] { set what_kind "hidden" }
336 return [check_no_compiler_messages visibility_available_$what_kind object "
337 void f() __attribute__((visibility(\"$what_kind\")));
338 void f() {}
342 ###############################
343 # proc check_alias_available { }
344 ###############################
346 # Determine if the target toolchain supports the alias attribute.
348 # Returns 2 if the target supports aliases. Returns 1 if the target
349 # only supports weak aliased. Returns 0 if the target does not
350 # support aliases at all. Returns -1 if support for aliases could not
351 # be determined.
353 proc check_alias_available { } {
354 global alias_available_saved
355 global tool
357 if [info exists alias_available_saved] {
358 verbose "check_alias_available returning saved $alias_available_saved" 2
359 } else {
360 set src alias[pid].c
361 set obj alias[pid].o
362 verbose "check_alias_available compiling testfile $src" 2
363 set f [open $src "w"]
364 # Compile a small test program. The definition of "g" is
365 # necessary to keep the Solaris assembler from complaining
366 # about the program.
367 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
368 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
369 close $f
370 set lines [${tool}_target_compile $src $obj object ""]
371 file delete $src
372 remote_file build delete $obj
374 if [string match "" $lines] then {
375 # No error messages, everything is OK.
376 set alias_available_saved 2
377 } else {
378 if [regexp "alias definitions not supported" $lines] {
379 verbose "check_alias_available target does not support aliases" 2
381 set objformat [gcc_target_object_format]
383 if { $objformat == "elf" } {
384 verbose "check_alias_available but target uses ELF format, so it ought to" 2
385 set alias_available_saved -1
386 } else {
387 set alias_available_saved 0
389 } else {
390 if [regexp "only weak aliases are supported" $lines] {
391 verbose "check_alias_available target supports only weak aliases" 2
392 set alias_available_saved 1
393 } else {
394 set alias_available_saved -1
399 verbose "check_alias_available returning $alias_available_saved" 2
402 return $alias_available_saved
405 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
407 proc check_effective_target_alias { } {
408 if { [check_alias_available] < 2 } {
409 return 0
410 } else {
411 return 1
415 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
417 proc check_ifunc_available { } {
418 return [check_no_compiler_messages ifunc_available object {
419 #ifdef __cplusplus
420 extern "C"
421 #endif
422 void g() {}
423 void f() __attribute__((ifunc("g")));
427 # Returns true if --gc-sections is supported on the target.
429 proc check_gc_sections_available { } {
430 global gc_sections_available_saved
431 global tool
433 if {![info exists gc_sections_available_saved]} {
434 # Some targets don't support gc-sections despite whatever's
435 # advertised by ld's options.
436 if { [istarget alpha*-*-*]
437 || [istarget ia64-*-*] } {
438 set gc_sections_available_saved 0
439 return 0
442 # elf2flt uses -q (--emit-relocs), which is incompatible with
443 # --gc-sections.
444 if { [board_info target exists ldflags]
445 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
446 set gc_sections_available_saved 0
447 return 0
450 # VxWorks kernel modules are relocatable objects linked with -r,
451 # while RTP executables are linked with -q (--emit-relocs).
452 # Both of these options are incompatible with --gc-sections.
453 if { [istarget *-*-vxworks*] } {
454 set gc_sections_available_saved 0
455 return 0
458 # Check if the ld used by gcc supports --gc-sections.
459 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
460 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
461 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
462 set ld_output [remote_exec host "$gcc_ld" "--help"]
463 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
464 set gc_sections_available_saved 1
465 } else {
466 set gc_sections_available_saved 0
469 return $gc_sections_available_saved
472 # Return 1 if according to target_info struct and explicit target list
473 # target is supposed to support trampolines.
475 proc check_effective_target_trampolines { } {
476 if [target_info exists no_trampolines] {
477 return 0
479 if { [istarget avr-*-*]
480 || [istarget msp430-*-*]
481 || [istarget nvptx-*-*]
482 || [istarget hppa2.0w-hp-hpux11.23]
483 || [istarget hppa64-hp-hpux11.23] } {
484 return 0;
486 return 1
489 # Return 1 if according to target_info struct and explicit target list
490 # target disables -fdelete-null-pointer-checks. Targets should return 0
491 # if they simply default to -fno-delete-null-pointer-checks but obey
492 # -fdelete-null-pointer-checks when passed explicitly (and tests that
493 # depend on this option should do that).
495 proc check_effective_target_keeps_null_pointer_checks { } {
496 if [target_info exists keeps_null_pointer_checks] {
497 return 1
499 if { [istarget avr-*-*] } {
500 return 1;
502 return 0
505 # Return true if profiling is supported on the target.
507 proc check_profiling_available { test_what } {
508 global profiling_available_saved
510 verbose "Profiling argument is <$test_what>" 1
512 # These conditions depend on the argument so examine them before
513 # looking at the cache variable.
515 # Tree profiling requires TLS runtime support.
516 if { $test_what == "-fprofile-generate" } {
517 if { ![check_effective_target_tls_runtime] } {
518 return 0
522 # Support for -p on solaris2 relies on mcrt1.o which comes with the
523 # vendor compiler. We cannot reliably predict the directory where the
524 # vendor compiler (and thus mcrt1.o) is installed so we can't
525 # necessarily find mcrt1.o even if we have it.
526 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
527 return 0
530 # We don't yet support profiling for MIPS16.
531 if { [istarget mips*-*-*]
532 && ![check_effective_target_nomips16]
533 && ($test_what == "-p" || $test_what == "-pg") } {
534 return 0
537 # MinGW does not support -p.
538 if { [istarget *-*-mingw*] && $test_what == "-p" } {
539 return 0
542 # cygwin does not support -p.
543 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
544 return 0
547 # uClibc does not have gcrt1.o.
548 if { [check_effective_target_uclibc]
549 && ($test_what == "-p" || $test_what == "-pg") } {
550 return 0
553 # Now examine the cache variable.
554 if {![info exists profiling_available_saved]} {
555 # Some targets don't have any implementation of __bb_init_func or are
556 # missing other needed machinery.
557 if {[istarget aarch64*-*-elf]
558 || [istarget am3*-*-linux*]
559 || [istarget arm*-*-eabi*]
560 || [istarget arm*-*-elf]
561 || [istarget arm*-*-symbianelf*]
562 || [istarget avr-*-*]
563 || [istarget bfin-*-*]
564 || [istarget cris-*-*]
565 || [istarget crisv32-*-*]
566 || [istarget fido-*-elf]
567 || [istarget h8300-*-*]
568 || [istarget lm32-*-*]
569 || [istarget m32c-*-elf]
570 || [istarget m68k-*-elf]
571 || [istarget m68k-*-uclinux*]
572 || [istarget mep-*-elf]
573 || [istarget mips*-*-elf*]
574 || [istarget mmix-*-*]
575 || [istarget mn10300-*-elf*]
576 || [istarget moxie-*-elf*]
577 || [istarget msp430-*-*]
578 || [istarget nds32*-*-elf]
579 || [istarget nios2-*-elf]
580 || [istarget nvptx-*-*]
581 || [istarget powerpc-*-eabi*]
582 || [istarget powerpc-*-elf]
583 || [istarget rx-*-*]
584 || [istarget tic6x-*-elf]
585 || [istarget visium-*-*]
586 || [istarget xstormy16-*]
587 || [istarget xtensa*-*-elf]
588 || [istarget *-*-rtems*]
589 || [istarget *-*-vxworks*] } {
590 set profiling_available_saved 0
591 } else {
592 set profiling_available_saved 1
596 # -pg link test result can't be cached since it may change between
597 # runs.
598 set profiling_working $profiling_available_saved
599 if { $profiling_available_saved == 1
600 && ![check_no_compiler_messages_nocache profiling executable {
601 int main() { return 0; } } "-pg"] } {
602 set profiling_working 0
605 return $profiling_working
608 # Check to see if a target is "freestanding". This is as per the definition
609 # in Section 4 of C99 standard. Effectively, it is a target which supports no
610 # extra headers or libraries other than what is considered essential.
611 proc check_effective_target_freestanding { } {
612 if { [istarget nvptx-*-*] } {
613 return 1
615 return 0
618 # Return 1 if target has packed layout of structure members by
619 # default, 0 otherwise. Note that this is slightly different than
620 # whether the target has "natural alignment": both attributes may be
621 # false.
623 proc check_effective_target_default_packed { } {
624 return [check_no_compiler_messages default_packed assembly {
625 struct x { char a; long b; } c;
626 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
630 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
631 # documentation, where the test also comes from.
633 proc check_effective_target_pcc_bitfield_type_matters { } {
634 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
635 # bitfields, but let's stick to the example code from the docs.
636 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
637 struct foo1 { char x; char :0; char y; };
638 struct foo2 { char x; int :0; char y; };
639 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
643 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
645 proc add_options_for_tls { flags } {
646 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
647 # libthread, so always pass -pthread for native TLS. Same for AIX.
648 # Need to duplicate native TLS check from
649 # check_effective_target_tls_native to avoid recursion.
650 if { ([istarget powerpc-ibm-aix*]) &&
651 [check_no_messages_and_pattern tls_native "!emutls" assembly {
652 __thread int i;
653 int f (void) { return i; }
654 void g (int j) { i = j; }
655 }] } {
656 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
658 return $flags
661 # Return 1 if indirect jumps are supported, 0 otherwise.
663 proc check_effective_target_indirect_jumps {} {
664 if { [istarget nvptx-*-*] } {
665 return 0
667 return 1
670 # Return 1 if nonlocal goto is supported, 0 otherwise.
672 proc check_effective_target_nonlocal_goto {} {
673 if { [istarget nvptx-*-*] } {
674 return 0
676 return 1
679 # Return 1 if global constructors are supported, 0 otherwise.
681 proc check_effective_target_global_constructor {} {
682 if { [istarget nvptx-*-*] } {
683 return 0
685 return 1
688 # Return 1 if taking label values is supported, 0 otherwise.
690 proc check_effective_target_label_values {} {
691 if { [istarget nvptx-*-*] } {
692 return 0
694 return [check_no_compiler_messages label_values assembly {
695 #ifdef NO_LABEL_VALUES
696 #error NO
697 #endif
701 # Return 1 if builtin_return_address and builtin_frame_address are
702 # supported, 0 otherwise.
704 proc check_effective_target_return_address {} {
705 if { [istarget nvptx-*-*] } {
706 return 0
708 return 1
711 # Return 1 if the assembler does not verify function types against
712 # calls, 0 otherwise. Such verification will typically show up problems
713 # with K&R C function declarations.
715 proc check_effective_target_untyped_assembly {} {
716 if { [istarget nvptx-*-*] } {
717 return 0
719 return 1
722 # Return 1 if alloca is supported, 0 otherwise.
724 proc check_effective_target_alloca {} {
725 if { [istarget nvptx-*-*] } {
726 return 0
728 return 1
731 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
733 proc check_effective_target_tls {} {
734 return [check_no_compiler_messages tls assembly {
735 __thread int i;
736 int f (void) { return i; }
737 void g (int j) { i = j; }
741 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
743 proc check_effective_target_tls_native {} {
744 # VxWorks uses emulated TLS machinery, but with non-standard helper
745 # functions, so we fail to automatically detect it.
746 if { [istarget *-*-vxworks*] } {
747 return 0
750 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
751 __thread int i;
752 int f (void) { return i; }
753 void g (int j) { i = j; }
757 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
759 proc check_effective_target_tls_emulated {} {
760 # VxWorks uses emulated TLS machinery, but with non-standard helper
761 # functions, so we fail to automatically detect it.
762 if { [istarget *-*-vxworks*] } {
763 return 1
766 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
767 __thread int i;
768 int f (void) { return i; }
769 void g (int j) { i = j; }
773 # Return 1 if TLS executables can run correctly, 0 otherwise.
775 proc check_effective_target_tls_runtime {} {
776 # The runtime does not have TLS support, but just
777 # running the test below is insufficient to show this.
778 if { [istarget msp430-*-*] || [istarget visium-*-*] } {
779 return 0
781 return [check_runtime tls_runtime {
782 __thread int thr = 0;
783 int main (void) { return thr; }
784 } [add_options_for_tls ""]]
787 # Return 1 if atomic compare-and-swap is supported on 'int'
789 proc check_effective_target_cas_char {} {
790 return [check_no_compiler_messages cas_char assembly {
791 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
792 #error unsupported
793 #endif
794 } ""]
797 proc check_effective_target_cas_int {} {
798 return [check_no_compiler_messages cas_int assembly {
799 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
800 /* ok */
801 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
802 /* ok */
803 #else
804 #error unsupported
805 #endif
806 } ""]
809 # Return 1 if -ffunction-sections is supported, 0 otherwise.
811 proc check_effective_target_function_sections {} {
812 # Darwin has its own scheme and silently accepts -ffunction-sections.
813 if { [istarget *-*-darwin*] } {
814 return 0
817 return [check_no_compiler_messages functionsections assembly {
818 void foo (void) { }
819 } "-ffunction-sections"]
822 # Return 1 if instruction scheduling is available, 0 otherwise.
824 proc check_effective_target_scheduling {} {
825 return [check_no_compiler_messages scheduling object {
826 void foo (void) { }
827 } "-fschedule-insns"]
830 # Return 1 if trapping arithmetic is available, 0 otherwise.
832 proc check_effective_target_trapping {} {
833 return [check_no_compiler_messages trapping object {
834 int add (int a, int b) { return a + b; }
835 } "-ftrapv"]
838 # Return 1 if compilation with -fgraphite is error-free for trivial
839 # code, 0 otherwise.
841 proc check_effective_target_fgraphite {} {
842 return [check_no_compiler_messages fgraphite object {
843 void foo (void) { }
844 } "-O1 -fgraphite"]
847 # Return 1 if compilation with -fopenacc is error-free for trivial
848 # code, 0 otherwise.
850 proc check_effective_target_fopenacc {} {
851 # nvptx can be built with the device-side bits of openacc, but it
852 # does not make sense to test it as an openacc host.
853 if [istarget nvptx-*-*] { return 0 }
855 return [check_no_compiler_messages fopenacc object {
856 void foo (void) { }
857 } "-fopenacc"]
860 # Return 1 if compilation with -fopenmp is error-free for trivial
861 # code, 0 otherwise.
863 proc check_effective_target_fopenmp {} {
864 # nvptx can be built with the device-side bits of libgomp, but it
865 # does not make sense to test it as an openmp host.
866 if [istarget nvptx-*-*] { return 0 }
868 return [check_no_compiler_messages fopenmp object {
869 void foo (void) { }
870 } "-fopenmp"]
873 # Return 1 if compilation with -fgnu-tm is error-free for trivial
874 # code, 0 otherwise.
876 proc check_effective_target_fgnu_tm {} {
877 return [check_no_compiler_messages fgnu_tm object {
878 void foo (void) { }
879 } "-fgnu-tm"]
882 # Return 1 if the target supports mmap, 0 otherwise.
884 proc check_effective_target_mmap {} {
885 return [check_function_available "mmap"]
888 # Return 1 if the target supports dlopen, 0 otherwise.
889 proc check_effective_target_dlopen {} {
890 return [check_no_compiler_messages dlopen executable {
891 #include <dlfcn.h>
892 int main(void) { dlopen ("dummy.so", RTLD_NOW); }
893 } [add_options_for_dlopen ""]]
896 proc add_options_for_dlopen { flags } {
897 return "$flags -ldl"
900 # Return 1 if the target supports clone, 0 otherwise.
901 proc check_effective_target_clone {} {
902 return [check_function_available "clone"]
905 # Return 1 if the target supports setrlimit, 0 otherwise.
906 proc check_effective_target_setrlimit {} {
907 # Darwin has non-posix compliant RLIMIT_AS
908 if { [istarget *-*-darwin*] } {
909 return 0
911 return [check_function_available "setrlimit"]
914 # Return 1 if the target supports swapcontext, 0 otherwise.
915 proc check_effective_target_swapcontext {} {
916 return [check_no_compiler_messages swapcontext executable {
917 #include <ucontext.h>
918 int main (void)
920 ucontext_t orig_context,child_context;
921 if (swapcontext(&child_context, &orig_context) < 0) { }
926 # Return 1 if compilation with -pthread is error-free for trivial
927 # code, 0 otherwise.
929 proc check_effective_target_pthread {} {
930 return [check_no_compiler_messages pthread object {
931 void foo (void) { }
932 } "-pthread"]
935 # Return 1 if compilation with -mpe-aligned-commons is error-free
936 # for trivial code, 0 otherwise.
938 proc check_effective_target_pe_aligned_commons {} {
939 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
940 return [check_no_compiler_messages pe_aligned_commons object {
941 int foo;
942 } "-mpe-aligned-commons"]
944 return 0
947 # Return 1 if the target supports -static
948 proc check_effective_target_static {} {
949 return [check_no_compiler_messages static executable {
950 int main (void) { return 0; }
951 } "-static"]
954 # Return 1 if the target supports -fstack-protector
955 proc check_effective_target_fstack_protector {} {
956 return [check_runtime fstack_protector {
957 int main (void) { return 0; }
958 } "-fstack-protector"]
961 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
962 # for trivial code, 0 otherwise.
964 proc check_effective_target_freorder {} {
965 return [check_no_compiler_messages freorder object {
966 void foo (void) { }
967 } "-freorder-blocks-and-partition"]
970 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
971 # emitted, 0 otherwise. Whether a shared library can actually be built is
972 # out of scope for this test.
974 proc check_effective_target_fpic { } {
975 # Note that M68K has a multilib that supports -fpic but not
976 # -fPIC, so we need to check both. We test with a program that
977 # requires GOT references.
978 foreach arg {fpic fPIC} {
979 if [check_no_compiler_messages $arg object {
980 extern int foo (void); extern int bar;
981 int baz (void) { return foo () + bar; }
982 } "-$arg"] {
983 return 1
986 return 0
989 # On AArch64, if -fpic is not supported, then we will fall back to -fPIC
990 # silently. So, we can't rely on above "check_effective_target_fpic" as it
991 # assumes compiler will give warning if -fpic not supported. Here we check
992 # whether binutils supports those new -fpic relocation modifiers, and assume
993 # -fpic is supported if there is binutils support. GCC configuration will
994 # enable -fpic for AArch64 in this case.
996 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
997 # memory model -fpic relocation types.
999 proc check_effective_target_aarch64_small_fpic { } {
1000 if { [istarget aarch64*-*-*] } {
1001 return [check_no_compiler_messages aarch64_small_fpic object {
1002 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
1004 } else {
1005 return 0
1009 # On AArch64, instruction sequence for TLS LE under -mtls-size=32 will utilize
1010 # the relocation modifier "tprel_g0_nc" together with MOVK, it's only supported
1011 # in binutils since 2015-03-04 as PR gas/17843.
1013 # This test directive make sure binutils support all features needed by TLS LE
1014 # under -mtls-size=32 on AArch64.
1016 proc check_effective_target_aarch64_tlsle32 { } {
1017 if { [istarget aarch64*-*-*] } {
1018 return [check_no_compiler_messages aarch64_tlsle32 object {
1019 void foo (void) { asm ("movk x1,#:tprel_g0_nc:t1"); }
1021 } else {
1022 return 0
1026 # Return 1 if -shared is supported, as in no warnings or errors
1027 # emitted, 0 otherwise.
1029 proc check_effective_target_shared { } {
1030 # Note that M68K has a multilib that supports -fpic but not
1031 # -fPIC, so we need to check both. We test with a program that
1032 # requires GOT references.
1033 return [check_no_compiler_messages shared executable {
1034 extern int foo (void); extern int bar;
1035 int baz (void) { return foo () + bar; }
1036 } "-shared -fpic"]
1039 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
1041 proc check_effective_target_pie { } {
1042 if { [istarget *-*-darwin\[912\]*]
1043 || [istarget *-*-dragonfly*]
1044 || [istarget *-*-freebsd*]
1045 || [istarget *-*-linux*]
1046 || [istarget *-*-gnu*] } {
1047 return 1;
1049 if { [istarget *-*-solaris2.1\[1-9\]*] } {
1050 # Full PIE support was added in Solaris 11.x and Solaris 12, but gcc
1051 # errors out if missing, so check for that.
1052 return [check_no_compiler_messages pie executable {
1053 int main (void) { return 0; }
1054 } "-pie -fpie"]
1056 return 0
1059 # Return true if the target supports -mpaired-single (as used on MIPS).
1061 proc check_effective_target_mpaired_single { } {
1062 return [check_no_compiler_messages mpaired_single object {
1063 void foo (void) { }
1064 } "-mpaired-single"]
1067 # Return true if the target has access to FPU instructions.
1069 proc check_effective_target_hard_float { } {
1070 if { [istarget mips*-*-*] } {
1071 return [check_no_compiler_messages hard_float assembly {
1072 #if (defined __mips_soft_float || defined __mips16)
1073 #error __mips_soft_float || __mips16
1074 #endif
1078 # This proc is actually checking the availabilty of FPU
1079 # support for doubles, so on the RX we must fail if the
1080 # 64-bit double multilib has been selected.
1081 if { [istarget rx-*-*] } {
1082 return 0
1083 # return [check_no_compiler_messages hard_float assembly {
1084 #if defined __RX_64_BIT_DOUBLES__
1085 #error __RX_64_BIT_DOUBLES__
1086 #endif
1087 # }]
1090 # The generic test equates hard_float with "no call for adding doubles".
1091 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1092 double a (double b, double c) { return b + c; }
1096 # Return true if the target is a 64-bit MIPS target.
1098 proc check_effective_target_mips64 { } {
1099 return [check_no_compiler_messages mips64 assembly {
1100 #ifndef __mips64
1101 #error !__mips64
1102 #endif
1106 # Return true if the target is a MIPS target that does not produce
1107 # MIPS16 code.
1109 proc check_effective_target_nomips16 { } {
1110 return [check_no_compiler_messages nomips16 object {
1111 #ifndef __mips
1112 #error !__mips
1113 #else
1114 /* A cheap way of testing for -mflip-mips16. */
1115 void foo (void) { asm ("addiu $20,$20,1"); }
1116 void bar (void) { asm ("addiu $20,$20,1"); }
1117 #endif
1121 # Add the options needed for MIPS16 function attributes. At the moment,
1122 # we don't support MIPS16 PIC.
1124 proc add_options_for_mips16_attribute { flags } {
1125 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1128 # Return true if we can force a mode that allows MIPS16 code generation.
1129 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
1130 # for o32 and o64.
1132 proc check_effective_target_mips16_attribute { } {
1133 return [check_no_compiler_messages mips16_attribute assembly {
1134 #ifdef PIC
1135 #error PIC
1136 #endif
1137 #if defined __mips_hard_float \
1138 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1139 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1140 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1141 #endif
1142 } [add_options_for_mips16_attribute ""]]
1145 # Return 1 if the target supports long double larger than double when
1146 # using the new ABI, 0 otherwise.
1148 proc check_effective_target_mips_newabi_large_long_double { } {
1149 return [check_no_compiler_messages mips_newabi_large_long_double object {
1150 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1151 } "-mabi=64"]
1154 # Return true if the target is a MIPS target that has access
1155 # to the LL and SC instructions.
1157 proc check_effective_target_mips_llsc { } {
1158 if { ![istarget mips*-*-*] } {
1159 return 0
1161 # Assume that these instructions are always implemented for
1162 # non-elf* targets, via emulation if necessary.
1163 if { ![istarget *-*-elf*] } {
1164 return 1
1166 # Otherwise assume LL/SC support for everything but MIPS I.
1167 return [check_no_compiler_messages mips_llsc assembly {
1168 #if __mips == 1
1169 #error __mips == 1
1170 #endif
1174 # Return true if the target is a MIPS target that uses in-place relocations.
1176 proc check_effective_target_mips_rel { } {
1177 if { ![istarget mips*-*-*] } {
1178 return 0
1180 return [check_no_compiler_messages mips_rel object {
1181 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1182 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1183 #error _ABIN32 && (_ABIN32 || _ABI64)
1184 #endif
1188 # Return true if the target is a MIPS target that uses the EABI.
1190 proc check_effective_target_mips_eabi { } {
1191 if { ![istarget mips*-*-*] } {
1192 return 0
1194 return [check_no_compiler_messages mips_eabi object {
1195 #ifndef __mips_eabi
1196 #error !__mips_eabi
1197 #endif
1201 # Return 1 if the current multilib does not generate PIC by default.
1203 proc check_effective_target_nonpic { } {
1204 return [check_no_compiler_messages nonpic assembly {
1205 #if __PIC__
1206 #error __PIC__
1207 #endif
1211 # Return 1 if the current multilib generates PIE by default.
1213 proc check_effective_target_pie_enabled { } {
1214 return [check_no_compiler_messages pie_enabled assembly {
1215 #ifndef __PIE__
1216 #error unsupported
1217 #endif
1221 # Return 1 if the target generates -fstack-protector by default.
1223 proc check_effective_target_fstack_protector_enabled {} {
1224 return [ check_no_compiler_messages fstack_protector_enabled assembly {
1225 #if !defined(__SSP__) && !defined(__SSP_ALL__) && \
1226 !defined(__SSP_STRONG__) && !defined(__SSP_EXPICIT__)
1227 #error unsupported
1228 #endif
1232 # Return 1 if the target does not use a status wrapper.
1234 proc check_effective_target_unwrapped { } {
1235 if { [target_info needs_status_wrapper] != "" \
1236 && [target_info needs_status_wrapper] != "0" } {
1237 return 0
1239 return 1
1242 # Return true if iconv is supported on the target. In particular IBM1047.
1244 proc check_iconv_available { test_what } {
1245 global libiconv
1247 # If the tool configuration file has not set libiconv, try "-liconv"
1248 if { ![info exists libiconv] } {
1249 set libiconv "-liconv"
1251 set test_what [lindex $test_what 1]
1252 return [check_runtime_nocache $test_what [subst {
1253 #include <iconv.h>
1254 int main (void)
1256 iconv_t cd;
1258 cd = iconv_open ("$test_what", "UTF-8");
1259 if (cd == (iconv_t) -1)
1260 return 1;
1261 return 0;
1263 }] $libiconv]
1266 # Return true if Cilk Library is supported on the target.
1267 proc check_libcilkrts_available { } {
1268 return [ check_no_compiler_messages_nocache libcilkrts_available executable {
1269 #ifdef __cplusplus
1270 extern "C"
1271 #endif
1272 int __cilkrts_set_param (const char *, const char *);
1273 int main (void) {
1274 int x = __cilkrts_set_param ("nworkers", "0");
1275 return x;
1277 } "-fcilkplus -lcilkrts" ]
1280 # Return true if the atomic library is supported on the target.
1281 proc check_effective_target_libatomic_available { } {
1282 return [check_no_compiler_messages libatomic_available executable {
1283 int main (void) { return 0; }
1284 } "-latomic"]
1287 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1289 proc check_ascii_locale_available { } {
1290 return 1
1293 # Return true if named sections are supported on this target.
1295 proc check_named_sections_available { } {
1296 return [check_no_compiler_messages named_sections assembly {
1297 int __attribute__ ((section("whatever"))) foo;
1301 # Return true if the "naked" function attribute is supported on this target.
1303 proc check_effective_target_naked_functions { } {
1304 return [check_no_compiler_messages naked_functions assembly {
1305 void f() __attribute__((naked));
1309 # Return 1 if the target supports Fortran real kinds larger than real(8),
1310 # 0 otherwise.
1312 # When the target name changes, replace the cached result.
1314 proc check_effective_target_fortran_large_real { } {
1315 return [check_no_compiler_messages fortran_large_real executable {
1316 ! Fortran
1317 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1318 real(kind=k) :: x
1319 x = cos (x)
1324 # Return 1 if the target supports Fortran real kind real(16),
1325 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1326 # this checks for Real(16) only; the other returned real(10) if
1327 # both real(10) and real(16) are available.
1329 # When the target name changes, replace the cached result.
1331 proc check_effective_target_fortran_real_16 { } {
1332 return [check_no_compiler_messages fortran_real_16 executable {
1333 ! Fortran
1334 real(kind=16) :: x
1335 x = cos (x)
1341 # Return 1 if the target supports Fortran's IEEE modules,
1342 # 0 otherwise.
1344 # When the target name changes, replace the cached result.
1346 proc check_effective_target_fortran_ieee { flags } {
1347 return [check_no_compiler_messages fortran_ieee executable {
1348 ! Fortran
1349 use, intrinsic :: ieee_features
1351 } $flags ]
1355 # Return 1 if the target supports SQRT for the largest floating-point
1356 # type. (Some targets lack the libm support for this FP type.)
1357 # On most targets, this check effectively checks either whether sqrtl is
1358 # available or on __float128 systems whether libquadmath is installed,
1359 # which provides sqrtq.
1361 # When the target name changes, replace the cached result.
1363 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1364 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1365 ! Fortran
1366 use iso_fortran_env, only: real_kinds
1367 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1368 real(kind=maxFP), volatile :: x
1369 x = 2.0_maxFP
1370 x = sqrt (x)
1376 # Return 1 if the target supports Fortran integer kinds larger than
1377 # integer(8), 0 otherwise.
1379 # When the target name changes, replace the cached result.
1381 proc check_effective_target_fortran_large_int { } {
1382 return [check_no_compiler_messages fortran_large_int executable {
1383 ! Fortran
1384 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1385 integer(kind=k) :: i
1390 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1392 # When the target name changes, replace the cached result.
1394 proc check_effective_target_fortran_integer_16 { } {
1395 return [check_no_compiler_messages fortran_integer_16 executable {
1396 ! Fortran
1397 integer(16) :: i
1402 # Return 1 if we can statically link libgfortran, 0 otherwise.
1404 # When the target name changes, replace the cached result.
1406 proc check_effective_target_static_libgfortran { } {
1407 return [check_no_compiler_messages static_libgfortran executable {
1408 ! Fortran
1409 print *, 'test'
1411 } "-static"]
1414 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1416 proc check_effective_target_cilkplus { } {
1417 # Skip cilk-plus tests on int16 and size16 targets for now.
1418 # The cilk-plus tests are not generic enough to cover these
1419 # cases and would throw hundreds of FAILs.
1420 if { [check_effective_target_int16]
1421 || ![check_effective_target_size32plus] } {
1422 return 0;
1425 # Skip AVR, its RAM is too small and too many tests would fail.
1426 if { [istarget avr-*-*] } {
1427 return 0;
1429 return 1
1432 proc check_linker_plugin_available { } {
1433 return [check_no_compiler_messages_nocache linker_plugin executable {
1434 int main() { return 0; }
1435 } "-flto -fuse-linker-plugin"]
1438 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1439 # otherwise. Cache the result.
1441 proc check_750cl_hw_available { } {
1442 return [check_cached_effective_target 750cl_hw_available {
1443 # If this is not the right target then we can skip the test.
1444 if { ![istarget powerpc-*paired*] } {
1445 expr 0
1446 } else {
1447 check_runtime_nocache 750cl_hw_available {
1448 int main()
1450 #ifdef __MACH__
1451 asm volatile ("ps_mul v0,v0,v0");
1452 #else
1453 asm volatile ("ps_mul 0,0,0");
1454 #endif
1455 return 0;
1457 } "-mpaired"
1462 # Return 1 if the target OS supports running SSE executables, 0
1463 # otherwise. Cache the result.
1465 proc check_sse_os_support_available { } {
1466 return [check_cached_effective_target sse_os_support_available {
1467 # If this is not the right target then we can skip the test.
1468 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1469 expr 0
1470 } elseif { [istarget i?86-*-solaris2*] } {
1471 # The Solaris 2 kernel doesn't save and restore SSE registers
1472 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1473 check_runtime_nocache sse_os_support_available {
1474 int main ()
1476 asm volatile ("movaps %xmm0,%xmm0");
1477 return 0;
1479 } "-msse"
1480 } else {
1481 expr 1
1486 # Return 1 if the target OS supports running AVX executables, 0
1487 # otherwise. Cache the result.
1489 proc check_avx_os_support_available { } {
1490 return [check_cached_effective_target avx_os_support_available {
1491 # If this is not the right target then we can skip the test.
1492 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1493 expr 0
1494 } else {
1495 # Check that OS has AVX and SSE saving enabled.
1496 check_runtime_nocache avx_os_support_available {
1497 int main ()
1499 unsigned int eax, edx;
1501 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1502 return (eax & 6) != 6;
1504 } ""
1509 # Return 1 if the target supports executing SSE instructions, 0
1510 # otherwise. Cache the result.
1512 proc check_sse_hw_available { } {
1513 return [check_cached_effective_target sse_hw_available {
1514 # If this is not the right target then we can skip the test.
1515 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1516 expr 0
1517 } else {
1518 check_runtime_nocache sse_hw_available {
1519 #include "cpuid.h"
1520 int main ()
1522 unsigned int eax, ebx, ecx, edx;
1523 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1524 return !(edx & bit_SSE);
1525 return 1;
1527 } ""
1532 # Return 1 if the target supports executing SSE2 instructions, 0
1533 # otherwise. Cache the result.
1535 proc check_sse2_hw_available { } {
1536 return [check_cached_effective_target sse2_hw_available {
1537 # If this is not the right target then we can skip the test.
1538 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1539 expr 0
1540 } else {
1541 check_runtime_nocache sse2_hw_available {
1542 #include "cpuid.h"
1543 int main ()
1545 unsigned int eax, ebx, ecx, edx;
1546 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1547 return !(edx & bit_SSE2);
1548 return 1;
1550 } ""
1555 # Return 1 if the target supports executing AVX instructions, 0
1556 # otherwise. Cache the result.
1558 proc check_avx_hw_available { } {
1559 return [check_cached_effective_target avx_hw_available {
1560 # If this is not the right target then we can skip the test.
1561 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1562 expr 0
1563 } else {
1564 check_runtime_nocache avx_hw_available {
1565 #include "cpuid.h"
1566 int main ()
1568 unsigned int eax, ebx, ecx, edx;
1569 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1570 return ((ecx & (bit_AVX | bit_OSXSAVE))
1571 != (bit_AVX | bit_OSXSAVE));
1572 return 1;
1574 } ""
1579 # Return 1 if the target supports running SSE executables, 0 otherwise.
1581 proc check_effective_target_sse_runtime { } {
1582 if { [check_effective_target_sse]
1583 && [check_sse_hw_available]
1584 && [check_sse_os_support_available] } {
1585 return 1
1587 return 0
1590 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1592 proc check_effective_target_sse2_runtime { } {
1593 if { [check_effective_target_sse2]
1594 && [check_sse2_hw_available]
1595 && [check_sse_os_support_available] } {
1596 return 1
1598 return 0
1601 # Return 1 if the target supports running AVX executables, 0 otherwise.
1603 proc check_effective_target_avx_runtime { } {
1604 if { [check_effective_target_avx]
1605 && [check_avx_hw_available]
1606 && [check_avx_os_support_available] } {
1607 return 1
1609 return 0
1612 # Return 1 if the target supports executing power8 vector instructions, 0
1613 # otherwise. Cache the result.
1615 proc check_p8vector_hw_available { } {
1616 return [check_cached_effective_target p8vector_hw_available {
1617 # Some simulators are known to not support VSX/power8 instructions.
1618 # For now, disable on Darwin
1619 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1620 expr 0
1621 } else {
1622 set options "-mpower8-vector"
1623 check_runtime_nocache p8vector_hw_available {
1624 int main()
1626 #ifdef __MACH__
1627 asm volatile ("xxlorc vs0,vs0,vs0");
1628 #else
1629 asm volatile ("xxlorc 0,0,0");
1630 #endif
1631 return 0;
1633 } $options
1638 # Return 1 if the target supports executing VSX instructions, 0
1639 # otherwise. Cache the result.
1641 proc check_vsx_hw_available { } {
1642 return [check_cached_effective_target vsx_hw_available {
1643 # Some simulators are known to not support VSX instructions.
1644 # For now, disable on Darwin
1645 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1646 expr 0
1647 } else {
1648 set options "-mvsx"
1649 check_runtime_nocache vsx_hw_available {
1650 int main()
1652 #ifdef __MACH__
1653 asm volatile ("xxlor vs0,vs0,vs0");
1654 #else
1655 asm volatile ("xxlor 0,0,0");
1656 #endif
1657 return 0;
1659 } $options
1664 # Return 1 if the target supports executing AltiVec instructions, 0
1665 # otherwise. Cache the result.
1667 proc check_vmx_hw_available { } {
1668 return [check_cached_effective_target vmx_hw_available {
1669 # Some simulators are known to not support VMX instructions.
1670 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1671 expr 0
1672 } else {
1673 # Most targets don't require special flags for this test case, but
1674 # Darwin does. Just to be sure, make sure VSX is not enabled for
1675 # the altivec tests.
1676 if { [istarget *-*-darwin*]
1677 || [istarget *-*-aix*] } {
1678 set options "-maltivec -mno-vsx"
1679 } else {
1680 set options "-mno-vsx"
1682 check_runtime_nocache vmx_hw_available {
1683 int main()
1685 #ifdef __MACH__
1686 asm volatile ("vor v0,v0,v0");
1687 #else
1688 asm volatile ("vor 0,0,0");
1689 #endif
1690 return 0;
1692 } $options
1697 proc check_ppc_recip_hw_available { } {
1698 return [check_cached_effective_target ppc_recip_hw_available {
1699 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1700 # For now, disable on Darwin
1701 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1702 expr 0
1703 } else {
1704 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1705 check_runtime_nocache ppc_recip_hw_available {
1706 volatile double d_recip, d_rsqrt, d_four = 4.0;
1707 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1708 int main()
1710 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1711 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1712 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1713 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1714 return 0;
1716 } $options
1721 # Return 1 if the target supports executing AltiVec and Cell PPU
1722 # instructions, 0 otherwise. Cache the result.
1724 proc check_effective_target_cell_hw { } {
1725 return [check_cached_effective_target cell_hw_available {
1726 # Some simulators are known to not support VMX and PPU instructions.
1727 if { [istarget powerpc-*-eabi*] } {
1728 expr 0
1729 } else {
1730 # Most targets don't require special flags for this test
1731 # case, but Darwin and AIX do.
1732 if { [istarget *-*-darwin*]
1733 || [istarget *-*-aix*] } {
1734 set options "-maltivec -mcpu=cell"
1735 } else {
1736 set options "-mcpu=cell"
1738 check_runtime_nocache cell_hw_available {
1739 int main()
1741 #ifdef __MACH__
1742 asm volatile ("vor v0,v0,v0");
1743 asm volatile ("lvlx v0,r0,r0");
1744 #else
1745 asm volatile ("vor 0,0,0");
1746 asm volatile ("lvlx 0,0,0");
1747 #endif
1748 return 0;
1750 } $options
1755 # Return 1 if the target supports executing 64-bit instructions, 0
1756 # otherwise. Cache the result.
1758 proc check_effective_target_powerpc64 { } {
1759 global powerpc64_available_saved
1760 global tool
1762 if [info exists powerpc64_available_saved] {
1763 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1764 } else {
1765 set powerpc64_available_saved 0
1767 # Some simulators are known to not support powerpc64 instructions.
1768 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1769 verbose "check_effective_target_powerpc64 returning 0" 2
1770 return $powerpc64_available_saved
1773 # Set up, compile, and execute a test program containing a 64-bit
1774 # instruction. Include the current process ID in the file
1775 # names to prevent conflicts with invocations for multiple
1776 # testsuites.
1777 set src ppc[pid].c
1778 set exe ppc[pid].x
1780 set f [open $src "w"]
1781 puts $f "int main() {"
1782 puts $f "#ifdef __MACH__"
1783 puts $f " asm volatile (\"extsw r0,r0\");"
1784 puts $f "#else"
1785 puts $f " asm volatile (\"extsw 0,0\");"
1786 puts $f "#endif"
1787 puts $f " return 0; }"
1788 close $f
1790 set opts "additional_flags=-mcpu=G5"
1792 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1793 set lines [${tool}_target_compile $src $exe executable "$opts"]
1794 file delete $src
1796 if [string match "" $lines] then {
1797 # No error message, compilation succeeded.
1798 set result [${tool}_load "./$exe" "" ""]
1799 set status [lindex $result 0]
1800 remote_file build delete $exe
1801 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1803 if { $status == "pass" } then {
1804 set powerpc64_available_saved 1
1806 } else {
1807 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1811 return $powerpc64_available_saved
1814 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1815 # complex float arguments. This affects gfortran tests that call cabsf
1816 # in libm built by an earlier compiler. Return 1 if libm uses the same
1817 # argument passing as the compiler under test, 0 otherwise.
1819 # When the target name changes, replace the cached result.
1821 proc check_effective_target_broken_cplxf_arg { } {
1822 return [check_cached_effective_target broken_cplxf_arg {
1823 # Skip the work for targets known not to be affected.
1824 if { ![istarget powerpc64-*-linux*] } {
1825 expr 0
1826 } elseif { ![is-effective-target lp64] } {
1827 expr 0
1828 } else {
1829 check_runtime_nocache broken_cplxf_arg {
1830 #include <complex.h>
1831 extern void abort (void);
1832 float fabsf (float);
1833 float cabsf (_Complex float);
1834 int main ()
1836 _Complex float cf;
1837 float f;
1838 cf = 3 + 4.0fi;
1839 f = cabsf (cf);
1840 if (fabsf (f - 5.0) > 0.0001)
1841 abort ();
1842 return 0;
1844 } "-lm"
1849 # Return 1 is this is a TI C6X target supporting C67X instructions
1850 proc check_effective_target_ti_c67x { } {
1851 return [check_no_compiler_messages ti_c67x assembly {
1852 #if !defined(_TMS320C6700)
1853 #error !_TMS320C6700
1854 #endif
1858 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1859 proc check_effective_target_ti_c64xp { } {
1860 return [check_no_compiler_messages ti_c64xp assembly {
1861 #if !defined(_TMS320C6400_PLUS)
1862 #error !_TMS320C6400_PLUS
1863 #endif
1868 proc check_alpha_max_hw_available { } {
1869 return [check_runtime alpha_max_hw_available {
1870 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1874 # Returns true iff the FUNCTION is available on the target system.
1875 # (This is essentially a Tcl implementation of Autoconf's
1876 # AC_CHECK_FUNC.)
1878 proc check_function_available { function } {
1879 return [check_no_compiler_messages ${function}_available \
1880 executable [subst {
1881 #ifdef __cplusplus
1882 extern "C"
1883 #endif
1884 char $function ();
1885 int main () { $function (); }
1886 }] "-fno-builtin" ]
1889 # Returns true iff "fork" is available on the target system.
1891 proc check_fork_available {} {
1892 return [check_function_available "fork"]
1895 # Returns true iff "mkfifo" is available on the target system.
1897 proc check_mkfifo_available {} {
1898 if { [istarget *-*-cygwin*] } {
1899 # Cygwin has mkfifo, but support is incomplete.
1900 return 0
1903 return [check_function_available "mkfifo"]
1906 # Returns true iff "__cxa_atexit" is used on the target system.
1908 proc check_cxa_atexit_available { } {
1909 return [check_cached_effective_target cxa_atexit_available {
1910 if { [istarget hppa*-*-hpux10*] } {
1911 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1912 expr 0
1913 } elseif { [istarget *-*-vxworks] } {
1914 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1915 expr 0
1916 } else {
1917 check_runtime_nocache cxa_atexit_available {
1918 // C++
1919 #include <stdlib.h>
1920 static unsigned int count;
1921 struct X
1923 X() { count = 1; }
1924 ~X()
1926 if (count != 3)
1927 exit(1);
1928 count = 4;
1931 void f()
1933 static X x;
1935 struct Y
1937 Y() { f(); count = 2; }
1938 ~Y()
1940 if (count != 2)
1941 exit(1);
1942 count = 3;
1945 Y y;
1946 int main() { return 0; }
1952 proc check_effective_target_objc2 { } {
1953 return [check_no_compiler_messages objc2 object {
1954 #ifdef __OBJC2__
1955 int dummy[1];
1956 #else
1957 #error !__OBJC2__
1958 #endif
1962 proc check_effective_target_next_runtime { } {
1963 return [check_no_compiler_messages objc2 object {
1964 #ifdef __NEXT_RUNTIME__
1965 int dummy[1];
1966 #else
1967 #error !__NEXT_RUNTIME__
1968 #endif
1972 # Return 1 if we're generating 32-bit code using default options, 0
1973 # otherwise.
1975 proc check_effective_target_ilp32 { } {
1976 return [check_no_compiler_messages ilp32 object {
1977 int dummy[sizeof (int) == 4
1978 && sizeof (void *) == 4
1979 && sizeof (long) == 4 ? 1 : -1];
1983 # Return 1 if we're generating ia32 code using default options, 0
1984 # otherwise.
1986 proc check_effective_target_ia32 { } {
1987 return [check_no_compiler_messages ia32 object {
1988 int dummy[sizeof (int) == 4
1989 && sizeof (void *) == 4
1990 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1994 # Return 1 if we're generating x32 code using default options, 0
1995 # otherwise.
1997 proc check_effective_target_x32 { } {
1998 return [check_no_compiler_messages x32 object {
1999 int dummy[sizeof (int) == 4
2000 && sizeof (void *) == 4
2001 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
2005 # Return 1 if we're generating 32-bit integers using default
2006 # options, 0 otherwise.
2008 proc check_effective_target_int32 { } {
2009 return [check_no_compiler_messages int32 object {
2010 int dummy[sizeof (int) == 4 ? 1 : -1];
2014 # Return 1 if we're generating 32-bit or larger integers using default
2015 # options, 0 otherwise.
2017 proc check_effective_target_int32plus { } {
2018 return [check_no_compiler_messages int32plus object {
2019 int dummy[sizeof (int) >= 4 ? 1 : -1];
2023 # Return 1 if we're generating 32-bit or larger pointers using default
2024 # options, 0 otherwise.
2026 proc check_effective_target_ptr32plus { } {
2027 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
2028 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
2029 # cannot really hold a 32-bit address, so we always return false here.
2030 if { [istarget msp430-*-*] } {
2031 return 0
2034 return [check_no_compiler_messages ptr32plus object {
2035 int dummy[sizeof (void *) >= 4 ? 1 : -1];
2039 # Return 1 if we support 32-bit or larger array and structure sizes
2040 # using default options, 0 otherwise. Avoid false positive on
2041 # targets with 20 or 24 bit address spaces.
2043 proc check_effective_target_size32plus { } {
2044 return [check_no_compiler_messages size32plus object {
2045 char dummy[16777217L];
2049 # Returns 1 if we're generating 16-bit or smaller integers with the
2050 # default options, 0 otherwise.
2052 proc check_effective_target_int16 { } {
2053 return [check_no_compiler_messages int16 object {
2054 int dummy[sizeof (int) < 4 ? 1 : -1];
2058 # Return 1 if we're generating 64-bit code using default options, 0
2059 # otherwise.
2061 proc check_effective_target_lp64 { } {
2062 return [check_no_compiler_messages lp64 object {
2063 int dummy[sizeof (int) == 4
2064 && sizeof (void *) == 8
2065 && sizeof (long) == 8 ? 1 : -1];
2069 # Return 1 if we're generating 64-bit code using default llp64 options,
2070 # 0 otherwise.
2072 proc check_effective_target_llp64 { } {
2073 return [check_no_compiler_messages llp64 object {
2074 int dummy[sizeof (int) == 4
2075 && sizeof (void *) == 8
2076 && sizeof (long long) == 8
2077 && sizeof (long) == 4 ? 1 : -1];
2081 # Return 1 if long and int have different sizes,
2082 # 0 otherwise.
2084 proc check_effective_target_long_neq_int { } {
2085 return [check_no_compiler_messages long_ne_int object {
2086 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2090 # Return 1 if the target supports long double larger than double,
2091 # 0 otherwise.
2093 proc check_effective_target_large_long_double { } {
2094 return [check_no_compiler_messages large_long_double object {
2095 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2099 # Return 1 if the target supports double larger than float,
2100 # 0 otherwise.
2102 proc check_effective_target_large_double { } {
2103 return [check_no_compiler_messages large_double object {
2104 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2108 # Return 1 if the target supports long double of 128 bits,
2109 # 0 otherwise.
2111 proc check_effective_target_longdouble128 { } {
2112 return [check_no_compiler_messages longdouble128 object {
2113 int dummy[sizeof(long double) == 16 ? 1 : -1];
2117 # Return 1 if the target supports double of 64 bits,
2118 # 0 otherwise.
2120 proc check_effective_target_double64 { } {
2121 return [check_no_compiler_messages double64 object {
2122 int dummy[sizeof(double) == 8 ? 1 : -1];
2126 # Return 1 if the target supports double of at least 64 bits,
2127 # 0 otherwise.
2129 proc check_effective_target_double64plus { } {
2130 return [check_no_compiler_messages double64plus object {
2131 int dummy[sizeof(double) >= 8 ? 1 : -1];
2135 # Return 1 if the target supports 'w' suffix on floating constant
2136 # 0 otherwise.
2138 proc check_effective_target_has_w_floating_suffix { } {
2139 set opts ""
2140 if [check_effective_target_c++] {
2141 append opts "-std=gnu++03"
2143 return [check_no_compiler_messages w_fp_suffix object {
2144 float dummy = 1.0w;
2145 } "$opts"]
2148 # Return 1 if the target supports 'q' suffix on floating constant
2149 # 0 otherwise.
2151 proc check_effective_target_has_q_floating_suffix { } {
2152 set opts ""
2153 if [check_effective_target_c++] {
2154 append opts "-std=gnu++03"
2156 return [check_no_compiler_messages q_fp_suffix object {
2157 float dummy = 1.0q;
2158 } "$opts"]
2160 # Return 1 if the target supports compiling fixed-point,
2161 # 0 otherwise.
2163 proc check_effective_target_fixed_point { } {
2164 return [check_no_compiler_messages fixed_point object {
2165 _Sat _Fract x; _Sat _Accum y;
2169 # Return 1 if the target supports compiling decimal floating point,
2170 # 0 otherwise.
2172 proc check_effective_target_dfp_nocache { } {
2173 verbose "check_effective_target_dfp_nocache: compiling source" 2
2174 set ret [check_no_compiler_messages_nocache dfp object {
2175 float x __attribute__((mode(DD)));
2177 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2178 return $ret
2181 proc check_effective_target_dfprt_nocache { } {
2182 return [check_runtime_nocache dfprt {
2183 typedef float d64 __attribute__((mode(DD)));
2184 d64 x = 1.2df, y = 2.3dd, z;
2185 int main () { z = x + y; return 0; }
2189 # Return 1 if the target supports compiling Decimal Floating Point,
2190 # 0 otherwise.
2192 # This won't change for different subtargets so cache the result.
2194 proc check_effective_target_dfp { } {
2195 return [check_cached_effective_target dfp {
2196 check_effective_target_dfp_nocache
2200 # Return 1 if the target supports linking and executing Decimal Floating
2201 # Point, 0 otherwise.
2203 # This won't change for different subtargets so cache the result.
2205 proc check_effective_target_dfprt { } {
2206 return [check_cached_effective_target dfprt {
2207 check_effective_target_dfprt_nocache
2211 # Return 1 if the target supports executing DFP hardware instructions,
2212 # 0 otherwise. Cache the result.
2214 proc check_dfp_hw_available { } {
2215 return [check_cached_effective_target dfp_hw_available {
2216 # For now, disable on Darwin
2217 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2218 expr 0
2219 } else {
2220 check_runtime_nocache dfp_hw_available {
2221 volatile _Decimal64 r;
2222 volatile _Decimal64 a = 4.0DD;
2223 volatile _Decimal64 b = 2.0DD;
2224 int main()
2226 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2227 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2228 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2229 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2230 return 0;
2232 } "-mcpu=power6 -mhard-float"
2237 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2239 proc check_effective_target_ucn_nocache { } {
2240 # -std=c99 is only valid for C
2241 if [check_effective_target_c] {
2242 set ucnopts "-std=c99"
2243 } else {
2244 set ucnopts ""
2246 verbose "check_effective_target_ucn_nocache: compiling source" 2
2247 set ret [check_no_compiler_messages_nocache ucn object {
2248 int \u00C0;
2249 } $ucnopts]
2250 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2251 return $ret
2254 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2256 # This won't change for different subtargets, so cache the result.
2258 proc check_effective_target_ucn { } {
2259 return [check_cached_effective_target ucn {
2260 check_effective_target_ucn_nocache
2264 # Return 1 if the target needs a command line argument to enable a SIMD
2265 # instruction set.
2267 proc check_effective_target_vect_cmdline_needed { } {
2268 global et_vect_cmdline_needed_saved
2269 global et_vect_cmdline_needed_target_name
2271 if { ![info exists et_vect_cmdline_needed_target_name] } {
2272 set et_vect_cmdline_needed_target_name ""
2275 # If the target has changed since we set the cached value, clear it.
2276 set current_target [current_target_name]
2277 if { $current_target != $et_vect_cmdline_needed_target_name } {
2278 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2279 set et_vect_cmdline_needed_target_name $current_target
2280 if { [info exists et_vect_cmdline_needed_saved] } {
2281 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
2282 unset et_vect_cmdline_needed_saved
2286 if [info exists et_vect_cmdline_needed_saved] {
2287 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2288 } else {
2289 set et_vect_cmdline_needed_saved 1
2290 if { [istarget alpha*-*-*]
2291 || [istarget ia64-*-*]
2292 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
2293 && ([check_effective_target_x32]
2294 || [check_effective_target_lp64]))
2295 || ([istarget powerpc*-*-*]
2296 && ([check_effective_target_powerpc_spe]
2297 || [check_effective_target_powerpc_altivec]))
2298 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2299 || [istarget spu-*-*]
2300 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2301 || [istarget aarch64*-*-*] } {
2302 set et_vect_cmdline_needed_saved 0
2306 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2307 return $et_vect_cmdline_needed_saved
2310 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2312 # This won't change for different subtargets so cache the result.
2314 proc check_effective_target_vect_int { } {
2315 global et_vect_int_saved
2317 if [info exists et_vect_int_saved] {
2318 verbose "check_effective_target_vect_int: using cached result" 2
2319 } else {
2320 set et_vect_int_saved 0
2321 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2322 || ([istarget powerpc*-*-*]
2323 && ![istarget powerpc-*-linux*paired*])
2324 || [istarget spu-*-*]
2325 || [istarget sparc*-*-*]
2326 || [istarget alpha*-*-*]
2327 || [istarget ia64-*-*]
2328 || [istarget aarch64*-*-*]
2329 || [check_effective_target_arm32]
2330 || ([istarget mips*-*-*]
2331 && [check_effective_target_mips_loongson]) } {
2332 set et_vect_int_saved 1
2336 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2337 return $et_vect_int_saved
2340 # Return 1 if the target supports signed int->float conversion
2343 proc check_effective_target_vect_intfloat_cvt { } {
2344 global et_vect_intfloat_cvt_saved
2346 if [info exists et_vect_intfloat_cvt_saved] {
2347 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2348 } else {
2349 set et_vect_intfloat_cvt_saved 0
2350 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2351 || ([istarget powerpc*-*-*]
2352 && ![istarget powerpc-*-linux*paired*])
2353 || ([istarget arm*-*-*]
2354 && [check_effective_target_arm_neon_ok])} {
2355 set et_vect_intfloat_cvt_saved 1
2359 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2360 return $et_vect_intfloat_cvt_saved
2363 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2365 proc check_effective_target_int128 { } {
2366 return [check_no_compiler_messages int128 object {
2367 int dummy[
2368 #ifndef __SIZEOF_INT128__
2370 #else
2372 #endif
2377 # Return 1 if the target supports unsigned int->float conversion
2380 proc check_effective_target_vect_uintfloat_cvt { } {
2381 global et_vect_uintfloat_cvt_saved
2383 if [info exists et_vect_uintfloat_cvt_saved] {
2384 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2385 } else {
2386 set et_vect_uintfloat_cvt_saved 0
2387 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2388 || ([istarget powerpc*-*-*]
2389 && ![istarget powerpc-*-linux*paired*])
2390 || [istarget aarch64*-*-*]
2391 || ([istarget arm*-*-*]
2392 && [check_effective_target_arm_neon_ok])} {
2393 set et_vect_uintfloat_cvt_saved 1
2397 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2398 return $et_vect_uintfloat_cvt_saved
2402 # Return 1 if the target supports signed float->int conversion
2405 proc check_effective_target_vect_floatint_cvt { } {
2406 global et_vect_floatint_cvt_saved
2408 if [info exists et_vect_floatint_cvt_saved] {
2409 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2410 } else {
2411 set et_vect_floatint_cvt_saved 0
2412 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2413 || ([istarget powerpc*-*-*]
2414 && ![istarget powerpc-*-linux*paired*])
2415 || ([istarget arm*-*-*]
2416 && [check_effective_target_arm_neon_ok])} {
2417 set et_vect_floatint_cvt_saved 1
2421 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2422 return $et_vect_floatint_cvt_saved
2425 # Return 1 if the target supports unsigned float->int conversion
2428 proc check_effective_target_vect_floatuint_cvt { } {
2429 global et_vect_floatuint_cvt_saved
2431 if [info exists et_vect_floatuint_cvt_saved] {
2432 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2433 } else {
2434 set et_vect_floatuint_cvt_saved 0
2435 if { ([istarget powerpc*-*-*]
2436 && ![istarget powerpc-*-linux*paired*])
2437 || ([istarget arm*-*-*]
2438 && [check_effective_target_arm_neon_ok])} {
2439 set et_vect_floatuint_cvt_saved 1
2443 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2444 return $et_vect_floatuint_cvt_saved
2447 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2449 # This won't change for different subtargets so cache the result.
2451 proc check_effective_target_vect_simd_clones { } {
2452 global et_vect_simd_clones_saved
2454 if [info exists et_vect_simd_clones_saved] {
2455 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2456 } else {
2457 set et_vect_simd_clones_saved 0
2458 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2459 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and
2460 # avx2 clone. Only the right clone for the specified arch will be
2461 # chosen, but still we need to at least be able to assemble
2462 # avx2.
2463 if { [check_effective_target_avx2] } {
2464 set et_vect_simd_clones_saved 1
2469 verbose "check_effective_target_vect_simd_clones: returning $et_vect_simd_clones_saved" 2
2470 return $et_vect_simd_clones_saved
2473 # Return 1 if this is a AArch64 target supporting big endian
2474 proc check_effective_target_aarch64_big_endian { } {
2475 return [check_no_compiler_messages aarch64_big_endian assembly {
2476 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2477 #error !__aarch64__ || !__AARCH64EB__
2478 #endif
2482 # Return 1 if this is a AArch64 target supporting little endian
2483 proc check_effective_target_aarch64_little_endian { } {
2484 if { ![istarget aarch64*-*-*] } {
2485 return 0
2488 return [check_no_compiler_messages aarch64_little_endian assembly {
2489 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2490 #error FOO
2491 #endif
2495 # Return 1 if this is an arm target using 32-bit instructions
2496 proc check_effective_target_arm32 { } {
2497 if { ![istarget arm*-*-*] } {
2498 return 0
2501 return [check_no_compiler_messages arm32 assembly {
2502 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2503 #error !__arm || __thumb__ && !__thumb2__
2504 #endif
2508 # Return 1 if this is an arm target not using Thumb
2509 proc check_effective_target_arm_nothumb { } {
2510 if { ![istarget arm*-*-*] } {
2511 return 0
2514 return [check_no_compiler_messages arm_nothumb assembly {
2515 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
2516 #error !__arm__ || __thumb || __thumb2__
2517 #endif
2521 # Return 1 if this is a little-endian ARM target
2522 proc check_effective_target_arm_little_endian { } {
2523 if { ![istarget arm*-*-*] } {
2524 return 0
2527 return [check_no_compiler_messages arm_little_endian assembly {
2528 #if !defined(__arm__) || !defined(__ARMEL__)
2529 #error !__arm__ || !__ARMEL__
2530 #endif
2534 # Return 1 if this is an ARM target that only supports aligned vector accesses
2535 proc check_effective_target_arm_vect_no_misalign { } {
2536 if { ![istarget arm*-*-*] } {
2537 return 0
2540 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2541 #if !defined(__arm__) \
2542 || (defined(__ARM_FEATURE_UNALIGNED) \
2543 && defined(__ARMEL__))
2544 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
2545 #endif
2550 # Return 1 if this is an ARM target supporting -mfpu=vfp
2551 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2552 # options.
2554 proc check_effective_target_arm_vfp_ok { } {
2555 if { [check_effective_target_arm32] } {
2556 return [check_no_compiler_messages arm_vfp_ok object {
2557 int dummy;
2558 } "-mfpu=vfp -mfloat-abi=softfp"]
2559 } else {
2560 return 0
2564 # Return 1 if this is an ARM target supporting -mfpu=vfp3
2565 # -mfloat-abi=softfp.
2567 proc check_effective_target_arm_vfp3_ok { } {
2568 if { [check_effective_target_arm32] } {
2569 return [check_no_compiler_messages arm_vfp3_ok object {
2570 int dummy;
2571 } "-mfpu=vfp3 -mfloat-abi=softfp"]
2572 } else {
2573 return 0
2577 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2578 # -mfloat-abi=softfp.
2579 proc check_effective_target_arm_v8_vfp_ok {} {
2580 if { [check_effective_target_arm32] } {
2581 return [check_no_compiler_messages arm_v8_vfp_ok object {
2582 int foo (void)
2584 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2585 return 0;
2587 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2588 } else {
2589 return 0
2593 # Return 1 if this is an ARM target supporting -mfpu=vfp
2594 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2595 # options.
2597 proc check_effective_target_arm_hard_vfp_ok { } {
2598 if { [check_effective_target_arm32]
2599 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2600 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2601 int main() { return 0;}
2602 } "-mfpu=vfp -mfloat-abi=hard"]
2603 } else {
2604 return 0
2608 # Return 1 if this is an ARM target that supports DSP multiply with
2609 # current multilib flags.
2611 proc check_effective_target_arm_dsp { } {
2612 return [check_no_compiler_messages arm_dsp assembly {
2613 #ifndef __ARM_FEATURE_DSP
2614 #error not DSP
2615 #endif
2616 int i;
2620 # Return 1 if this is an ARM target that supports unaligned word/halfword
2621 # load/store instructions.
2623 proc check_effective_target_arm_unaligned { } {
2624 return [check_no_compiler_messages arm_unaligned assembly {
2625 #ifndef __ARM_FEATURE_UNALIGNED
2626 #error no unaligned support
2627 #endif
2628 int i;
2632 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2633 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2634 # incompatible with these options. Also set et_arm_crypto_flags to the
2635 # best options to add.
2637 proc check_effective_target_arm_crypto_ok_nocache { } {
2638 global et_arm_crypto_flags
2639 set et_arm_crypto_flags ""
2640 if { [check_effective_target_arm32] } {
2641 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2642 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2643 #include "arm_neon.h"
2644 uint8x16_t
2645 foo (uint8x16_t a, uint8x16_t b)
2647 return vaeseq_u8 (a, b);
2649 } "$flags"] } {
2650 set et_arm_crypto_flags $flags
2651 return 1
2656 return 0
2659 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2661 proc check_effective_target_arm_crypto_ok { } {
2662 return [check_cached_effective_target arm_crypto_ok \
2663 check_effective_target_arm_crypto_ok_nocache]
2666 # Add options for crypto extensions.
2667 proc add_options_for_arm_crypto { flags } {
2668 if { ! [check_effective_target_arm_crypto_ok] } {
2669 return "$flags"
2671 global et_arm_crypto_flags
2672 return "$flags $et_arm_crypto_flags"
2675 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2676 # or -mfloat-abi=hard, but if one is already specified by the
2677 # multilib, use it. Similarly, if a -mfpu option already enables
2678 # NEON, do not add -mfpu=neon.
2680 proc add_options_for_arm_neon { flags } {
2681 if { ! [check_effective_target_arm_neon_ok] } {
2682 return "$flags"
2684 global et_arm_neon_flags
2685 return "$flags $et_arm_neon_flags"
2688 proc add_options_for_arm_v8_vfp { flags } {
2689 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2690 return "$flags"
2692 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2695 proc add_options_for_arm_v8_neon { flags } {
2696 if { ! [check_effective_target_arm_v8_neon_ok] } {
2697 return "$flags"
2699 global et_arm_v8_neon_flags
2700 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2703 proc add_options_for_arm_crc { flags } {
2704 if { ! [check_effective_target_arm_crc_ok] } {
2705 return "$flags"
2707 global et_arm_crc_flags
2708 return "$flags $et_arm_crc_flags"
2711 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2712 # or -mfloat-abi=hard, but if one is already specified by the
2713 # multilib, use it. Similarly, if a -mfpu option already enables
2714 # NEON, do not add -mfpu=neon.
2716 proc add_options_for_arm_neonv2 { flags } {
2717 if { ! [check_effective_target_arm_neonv2_ok] } {
2718 return "$flags"
2720 global et_arm_neonv2_flags
2721 return "$flags $et_arm_neonv2_flags"
2724 # Add the options needed for vfp3.
2725 proc add_options_for_arm_vfp3 { flags } {
2726 if { ! [check_effective_target_arm_vfp3_ok] } {
2727 return "$flags"
2729 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
2732 # Return 1 if this is an ARM target supporting -mfpu=neon
2733 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2734 # incompatible with these options. Also set et_arm_neon_flags to the
2735 # best options to add.
2737 proc check_effective_target_arm_neon_ok_nocache { } {
2738 global et_arm_neon_flags
2739 set et_arm_neon_flags ""
2740 if { [check_effective_target_arm32] } {
2741 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2742 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2743 #include "arm_neon.h"
2744 int dummy;
2745 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
2746 configured for -mcpu=arm926ej-s, for example. */
2747 #if __ARM_ARCH < 7
2748 #error Architecture too old for NEON.
2749 #endif
2750 } "$flags"] } {
2751 set et_arm_neon_flags $flags
2752 return 1
2757 return 0
2760 proc check_effective_target_arm_neon_ok { } {
2761 return [check_cached_effective_target arm_neon_ok \
2762 check_effective_target_arm_neon_ok_nocache]
2765 proc check_effective_target_arm_crc_ok_nocache { } {
2766 global et_arm_crc_flags
2767 set et_arm_crc_flags "-march=armv8-a+crc"
2768 return [check_no_compiler_messages_nocache arm_crc_ok object {
2769 #if !defined (__ARM_FEATURE_CRC32)
2770 #error FOO
2771 #endif
2772 } "$et_arm_crc_flags"]
2775 proc check_effective_target_arm_crc_ok { } {
2776 return [check_cached_effective_target arm_crc_ok \
2777 check_effective_target_arm_crc_ok_nocache]
2780 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2781 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2782 # incompatible with these options. Also set et_arm_neon_flags to the
2783 # best options to add.
2785 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2786 global et_arm_neon_fp16_flags
2787 set et_arm_neon_fp16_flags ""
2788 if { [check_effective_target_arm32] } {
2789 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2790 "-mfpu=neon-fp16 -mfloat-abi=softfp"
2791 "-mfp16-format=ieee"
2792 "-mfloat-abi=softfp -mfp16-format=ieee"
2793 "-mfpu=neon-fp16 -mfp16-format=ieee"
2794 "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
2795 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2796 #include "arm_neon.h"
2797 float16x4_t
2798 foo (float32x4_t arg)
2800 return vcvt_f16_f32 (arg);
2802 } "$flags"] } {
2803 set et_arm_neon_fp16_flags $flags
2804 return 1
2809 return 0
2812 proc check_effective_target_arm_neon_fp16_ok { } {
2813 return [check_cached_effective_target arm_neon_fp16_ok \
2814 check_effective_target_arm_neon_fp16_ok_nocache]
2817 proc check_effective_target_arm_neon_fp16_hw { } {
2818 if {! [check_effective_target_arm_neon_fp16_ok] } {
2819 return 0
2821 global et_arm_neon_fp16_flags
2822 check_runtime_nocache arm_neon_fp16_hw {
2824 main (int argc, char **argv)
2826 asm ("vcvt.f32.f16 q1, d0");
2827 return 0;
2829 } $et_arm_neon_fp16_flags
2832 proc add_options_for_arm_neon_fp16 { flags } {
2833 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2834 return "$flags"
2836 global et_arm_neon_fp16_flags
2837 return "$flags $et_arm_neon_fp16_flags"
2840 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2841 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2842 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2843 # best options to add.
2845 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2846 global et_arm_v8_neon_flags
2847 set et_arm_v8_neon_flags ""
2848 if { [check_effective_target_arm32] } {
2849 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2850 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2851 #if __ARM_ARCH < 8
2852 #error not armv8 or later
2853 #endif
2854 #include "arm_neon.h"
2855 void
2856 foo ()
2858 __asm__ volatile ("vrintn.f32 q0, q0");
2860 } "$flags -march=armv8-a"] } {
2861 set et_arm_v8_neon_flags $flags
2862 return 1
2867 return 0
2870 proc check_effective_target_arm_v8_neon_ok { } {
2871 return [check_cached_effective_target arm_v8_neon_ok \
2872 check_effective_target_arm_v8_neon_ok_nocache]
2875 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2876 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2877 # incompatible with these options. Also set et_arm_neonv2_flags to the
2878 # best options to add.
2880 proc check_effective_target_arm_neonv2_ok_nocache { } {
2881 global et_arm_neonv2_flags
2882 set et_arm_neonv2_flags ""
2883 if { [check_effective_target_arm32] } {
2884 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2885 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2886 #include "arm_neon.h"
2887 float32x2_t
2888 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2890 return vfma_f32 (a, b, c);
2892 } "$flags"] } {
2893 set et_arm_neonv2_flags $flags
2894 return 1
2899 return 0
2902 proc check_effective_target_arm_neonv2_ok { } {
2903 return [check_cached_effective_target arm_neonv2_ok \
2904 check_effective_target_arm_neonv2_ok_nocache]
2907 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2908 # or -mfloat-abi=hard, but if one is already specified by the
2909 # multilib, use it.
2911 proc add_options_for_arm_fp16 { flags } {
2912 if { ! [check_effective_target_arm_fp16_ok] } {
2913 return "$flags"
2915 global et_arm_fp16_flags
2916 return "$flags $et_arm_fp16_flags"
2919 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2920 # Skip multilibs that are incompatible with these options and set
2921 # et_arm_fp16_flags to the best options to add.
2923 proc check_effective_target_arm_fp16_ok_nocache { } {
2924 global et_arm_fp16_flags
2925 set et_arm_fp16_flags ""
2926 if { ! [check_effective_target_arm32] } {
2927 return 0;
2929 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2930 # Multilib flags would override -mfpu.
2931 return 0
2933 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2934 # Must generate floating-point instructions.
2935 return 0
2937 if [check_effective_target_arm_hf_eabi] {
2938 # Use existing float-abi and force an fpu which supports fp16
2939 set et_arm_fp16_flags "-mfpu=vfpv4"
2940 return 1;
2942 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2943 # The existing -mfpu value is OK; use it, but add softfp.
2944 set et_arm_fp16_flags "-mfloat-abi=softfp"
2945 return 1;
2947 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2948 # macro to check for this support.
2949 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2950 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2951 int dummy;
2952 } "$flags"] } {
2953 set et_arm_fp16_flags "$flags"
2954 return 1
2957 return 0
2960 proc check_effective_target_arm_fp16_ok { } {
2961 return [check_cached_effective_target arm_fp16_ok \
2962 check_effective_target_arm_fp16_ok_nocache]
2965 # Creates a series of routines that return 1 if the given architecture
2966 # can be selected and a routine to give the flags to select that architecture
2967 # Note: Extra flags may be added to disable options from newer compilers
2968 # (Thumb in particular - but others may be added in the future)
2969 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2970 # /* { dg-add-options arm_arch_v5 } */
2971 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2972 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2973 v4t "-march=armv4t" __ARM_ARCH_4T__
2974 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2975 v5t "-march=armv5t" __ARM_ARCH_5T__
2976 v5te "-march=armv5te" __ARM_ARCH_5TE__
2977 v6 "-march=armv6" __ARM_ARCH_6__
2978 v6k "-march=armv6k" __ARM_ARCH_6K__
2979 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2980 v6z "-march=armv6z" __ARM_ARCH_6Z__
2981 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2982 v7a "-march=armv7-a" __ARM_ARCH_7A__
2983 v7ve "-march=armv7ve" __ARM_ARCH_7A__
2984 v7r "-march=armv7-r" __ARM_ARCH_7R__
2985 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2986 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2987 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2988 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2989 proc check_effective_target_arm_arch_FUNC_ok { } {
2990 if { [ string match "*-marm*" "FLAG" ] &&
2991 ![check_effective_target_arm_arm_ok] } {
2992 return 0
2994 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2995 #if !defined (DEF)
2996 #error !DEF
2997 #endif
2998 } "FLAG" ]
3001 proc add_options_for_arm_arch_FUNC { flags } {
3002 return "$flags FLAG"
3005 proc check_effective_target_arm_arch_FUNC_multilib { } {
3006 return [check_runtime arm_arch_FUNC_multilib {
3008 main (void)
3010 return 0;
3012 } [add_options_for_arm_arch_FUNC ""]]
3017 # Return 1 if this is an ARM target where -marm causes ARM to be
3018 # used (not Thumb)
3020 proc check_effective_target_arm_arm_ok { } {
3021 return [check_no_compiler_messages arm_arm_ok assembly {
3022 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
3023 #error !__arm__ || __thumb__ || __thumb2__
3024 #endif
3025 } "-marm"]
3029 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
3030 # used.
3032 proc check_effective_target_arm_thumb1_ok { } {
3033 return [check_no_compiler_messages arm_thumb1_ok assembly {
3034 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3035 #error !__arm__ || !__thumb__ || __thumb2__
3036 #endif
3037 int foo (int i) { return i; }
3038 } "-mthumb"]
3041 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
3042 # used.
3044 proc check_effective_target_arm_thumb2_ok { } {
3045 return [check_no_compiler_messages arm_thumb2_ok assembly {
3046 #if !defined(__thumb2__)
3047 #error !__thumb2__
3048 #endif
3049 int foo (int i) { return i; }
3050 } "-mthumb"]
3053 # Return 1 if this is an ARM target where Thumb-1 is used without options
3054 # added by the test.
3056 proc check_effective_target_arm_thumb1 { } {
3057 return [check_no_compiler_messages arm_thumb1 assembly {
3058 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3059 #error !__arm__ || !__thumb__ || __thumb2__
3060 #endif
3061 int i;
3062 } ""]
3065 # Return 1 if this is an ARM target where Thumb-2 is used without options
3066 # added by the test.
3068 proc check_effective_target_arm_thumb2 { } {
3069 return [check_no_compiler_messages arm_thumb2 assembly {
3070 #if !defined(__thumb2__)
3071 #error !__thumb2__
3072 #endif
3073 int i;
3074 } ""]
3077 # Return 1 if this is an ARM target where conditional execution is available.
3079 proc check_effective_target_arm_cond_exec { } {
3080 return [check_no_compiler_messages arm_cond_exec assembly {
3081 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
3082 #error FOO
3083 #endif
3084 int i;
3085 } ""]
3088 # Return 1 if this is an ARM cortex-M profile cpu
3090 proc check_effective_target_arm_cortex_m { } {
3091 if { ![istarget arm*-*-*] } {
3092 return 0
3094 return [check_no_compiler_messages arm_cortex_m assembly {
3095 #if !defined(__ARM_ARCH_7M__) \
3096 && !defined (__ARM_ARCH_7EM__) \
3097 && !defined (__ARM_ARCH_6M__)
3098 #error !__ARM_ARCH_7M__ && !__ARM_ARCH_7EM__ && !__ARM_ARCH_6M__
3099 #endif
3100 int i;
3101 } "-mthumb"]
3104 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3106 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3107 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3108 int foo (void) { return 0; }
3109 } "-O2 -mprint-tune-info" ]
3112 # Return 1 if the target supports executing NEON instructions, 0
3113 # otherwise. Cache the result.
3115 proc check_effective_target_arm_neon_hw { } {
3116 return [check_runtime arm_neon_hw_available {
3118 main (void)
3120 long long a = 0, b = 1;
3121 asm ("vorr %P0, %P1, %P2"
3122 : "=w" (a)
3123 : "0" (a), "w" (b));
3124 return (a != 1);
3126 } [add_options_for_arm_neon ""]]
3129 proc check_effective_target_arm_neonv2_hw { } {
3130 return [check_runtime arm_neon_hwv2_available {
3131 #include "arm_neon.h"
3133 main (void)
3135 float32x2_t a, b, c;
3136 asm ("vfma.f32 %P0, %P1, %P2"
3137 : "=w" (a)
3138 : "w" (b), "w" (c));
3139 return 0;
3141 } [add_options_for_arm_neonv2 ""]]
3144 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
3145 # otherwise.
3147 proc check_effective_target_arm_v8_neon_hw { } {
3148 return [check_runtime arm_v8_neon_hw_available {
3149 #include "arm_neon.h"
3151 main (void)
3153 float32x2_t a;
3154 asm ("vrinta.f32 %P0, %P1"
3155 : "=w" (a)
3156 : "0" (a));
3157 return 0;
3159 } [add_options_for_arm_v8_neon ""]]
3162 # Return 1 if this is a ARM target with NEON enabled.
3164 proc check_effective_target_arm_neon { } {
3165 if { [check_effective_target_arm32] } {
3166 return [check_no_compiler_messages arm_neon object {
3167 #ifndef __ARM_NEON__
3168 #error not NEON
3169 #else
3170 int dummy;
3171 #endif
3173 } else {
3174 return 0
3178 proc check_effective_target_arm_neonv2 { } {
3179 if { [check_effective_target_arm32] } {
3180 return [check_no_compiler_messages arm_neon object {
3181 #ifndef __ARM_NEON__
3182 #error not NEON
3183 #else
3184 #ifndef __ARM_FEATURE_FMA
3185 #error not NEONv2
3186 #else
3187 int dummy;
3188 #endif
3189 #endif
3191 } else {
3192 return 0
3196 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
3197 # the Loongson vector modes.
3199 proc check_effective_target_mips_loongson { } {
3200 return [check_no_compiler_messages loongson assembly {
3201 #if !defined(__mips_loongson_vector_rev)
3202 #error !__mips_loongson_vector_rev
3203 #endif
3207 # Return 1 if this is a MIPS target that supports the legacy NAN.
3209 proc check_effective_target_mips_nanlegacy { } {
3210 return [check_no_compiler_messages nanlegacy assembly {
3211 #include <stdlib.h>
3212 int main () { return 0; }
3213 } "-mnan=legacy"]
3216 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
3217 # Architecture.
3219 proc check_effective_target_arm_eabi { } {
3220 return [check_no_compiler_messages arm_eabi object {
3221 #ifndef __ARM_EABI__
3222 #error not EABI
3223 #else
3224 int dummy;
3225 #endif
3229 # Return 1 if this is an ARM target that adheres to the hard-float variant of
3230 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
3232 proc check_effective_target_arm_hf_eabi { } {
3233 return [check_no_compiler_messages arm_hf_eabi object {
3234 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
3235 #error not hard-float EABI
3236 #else
3237 int dummy;
3238 #endif
3242 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
3243 # Some multilibs may be incompatible with this option.
3245 proc check_effective_target_arm_iwmmxt_ok { } {
3246 if { [check_effective_target_arm32] } {
3247 return [check_no_compiler_messages arm_iwmmxt_ok object {
3248 int dummy;
3249 } "-mcpu=iwmmxt"]
3250 } else {
3251 return 0
3255 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
3256 # for an ARM target.
3257 proc check_effective_target_arm_prefer_ldrd_strd { } {
3258 if { ![check_effective_target_arm32] } {
3259 return 0;
3262 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
3263 void foo (int *p) { p[0] = 1; p[1] = 0;}
3264 } "-O2 -mthumb" ]
3267 # Return 1 if this is a PowerPC target supporting -meabi.
3269 proc check_effective_target_powerpc_eabi_ok { } {
3270 if { [istarget powerpc*-*-*] } {
3271 return [check_no_compiler_messages powerpc_eabi_ok object {
3272 int dummy;
3273 } "-meabi"]
3274 } else {
3275 return 0
3279 # Return 1 if this is a PowerPC target with floating-point registers.
3281 proc check_effective_target_powerpc_fprs { } {
3282 if { [istarget powerpc*-*-*]
3283 || [istarget rs6000-*-*] } {
3284 return [check_no_compiler_messages powerpc_fprs object {
3285 #ifdef __NO_FPRS__
3286 #error no FPRs
3287 #else
3288 int dummy;
3289 #endif
3291 } else {
3292 return 0
3296 # Return 1 if this is a PowerPC target with hardware double-precision
3297 # floating point.
3299 proc check_effective_target_powerpc_hard_double { } {
3300 if { [istarget powerpc*-*-*]
3301 || [istarget rs6000-*-*] } {
3302 return [check_no_compiler_messages powerpc_hard_double object {
3303 #ifdef _SOFT_DOUBLE
3304 #error soft double
3305 #else
3306 int dummy;
3307 #endif
3309 } else {
3310 return 0
3314 # Return 1 if this is a PowerPC target supporting -maltivec.
3316 proc check_effective_target_powerpc_altivec_ok { } {
3317 if { ([istarget powerpc*-*-*]
3318 && ![istarget powerpc-*-linux*paired*])
3319 || [istarget rs6000-*-*] } {
3320 # AltiVec is not supported on AIX before 5.3.
3321 if { [istarget powerpc*-*-aix4*]
3322 || [istarget powerpc*-*-aix5.1*]
3323 || [istarget powerpc*-*-aix5.2*] } {
3324 return 0
3326 return [check_no_compiler_messages powerpc_altivec_ok object {
3327 int dummy;
3328 } "-maltivec"]
3329 } else {
3330 return 0
3334 # Return 1 if this is a PowerPC target supporting -mpower8-vector
3336 proc check_effective_target_powerpc_p8vector_ok { } {
3337 if { ([istarget powerpc*-*-*]
3338 && ![istarget powerpc-*-linux*paired*])
3339 || [istarget rs6000-*-*] } {
3340 # AltiVec is not supported on AIX before 5.3.
3341 if { [istarget powerpc*-*-aix4*]
3342 || [istarget powerpc*-*-aix5.1*]
3343 || [istarget powerpc*-*-aix5.2*] } {
3344 return 0
3346 return [check_no_compiler_messages powerpc_p8vector_ok object {
3347 int main (void) {
3348 #ifdef __MACH__
3349 asm volatile ("xxlorc vs0,vs0,vs0");
3350 #else
3351 asm volatile ("xxlorc 0,0,0");
3352 #endif
3353 return 0;
3355 } "-mpower8-vector"]
3356 } else {
3357 return 0
3361 # Return 1 if this is a PowerPC target supporting -mvsx
3363 proc check_effective_target_powerpc_vsx_ok { } {
3364 if { ([istarget powerpc*-*-*]
3365 && ![istarget powerpc-*-linux*paired*])
3366 || [istarget rs6000-*-*] } {
3367 # VSX is not supported on AIX before 7.1.
3368 if { [istarget powerpc*-*-aix4*]
3369 || [istarget powerpc*-*-aix5*]
3370 || [istarget powerpc*-*-aix6*] } {
3371 return 0
3373 return [check_no_compiler_messages powerpc_vsx_ok object {
3374 int main (void) {
3375 #ifdef __MACH__
3376 asm volatile ("xxlor vs0,vs0,vs0");
3377 #else
3378 asm volatile ("xxlor 0,0,0");
3379 #endif
3380 return 0;
3382 } "-mvsx"]
3383 } else {
3384 return 0
3388 # Return 1 if this is a PowerPC target supporting -mhtm
3390 proc check_effective_target_powerpc_htm_ok { } {
3391 if { ([istarget powerpc*-*-*]
3392 && ![istarget powerpc-*-linux*paired*])
3393 || [istarget rs6000-*-*] } {
3394 # HTM is not supported on AIX yet.
3395 if { [istarget powerpc*-*-aix*] } {
3396 return 0
3398 return [check_no_compiler_messages powerpc_htm_ok object {
3399 int main (void) {
3400 asm volatile ("tbegin. 0");
3401 return 0;
3403 } "-mhtm"]
3404 } else {
3405 return 0
3409 # Return 1 if the target supports executing HTM hardware instructions,
3410 # 0 otherwise. Cache the result.
3412 proc check_htm_hw_available { } {
3413 return [check_cached_effective_target htm_hw_available {
3414 # For now, disable on Darwin
3415 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
3416 expr 0
3417 } else {
3418 check_runtime_nocache htm_hw_available {
3419 int main()
3421 __builtin_ttest ();
3422 return 0;
3424 } "-mhtm"
3428 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
3430 proc check_effective_target_powerpc_ppu_ok { } {
3431 if [check_effective_target_powerpc_altivec_ok] {
3432 return [check_no_compiler_messages cell_asm_available object {
3433 int main (void) {
3434 #ifdef __MACH__
3435 asm volatile ("lvlx v0,v0,v0");
3436 #else
3437 asm volatile ("lvlx 0,0,0");
3438 #endif
3439 return 0;
3442 } else {
3443 return 0
3447 # Return 1 if this is a PowerPC target that supports SPU.
3449 proc check_effective_target_powerpc_spu { } {
3450 if { [istarget powerpc*-*-linux*] } {
3451 return [check_effective_target_powerpc_altivec_ok]
3452 } else {
3453 return 0
3457 # Return 1 if this is a PowerPC SPE target. The check includes options
3458 # specified by dg-options for this test, so don't cache the result.
3460 proc check_effective_target_powerpc_spe_nocache { } {
3461 if { [istarget powerpc*-*-*] } {
3462 return [check_no_compiler_messages_nocache powerpc_spe object {
3463 #ifndef __SPE__
3464 #error not SPE
3465 #else
3466 int dummy;
3467 #endif
3468 } [current_compiler_flags]]
3469 } else {
3470 return 0
3474 # Return 1 if this is a PowerPC target with SPE enabled.
3476 proc check_effective_target_powerpc_spe { } {
3477 if { [istarget powerpc*-*-*] } {
3478 return [check_no_compiler_messages powerpc_spe object {
3479 #ifndef __SPE__
3480 #error not SPE
3481 #else
3482 int dummy;
3483 #endif
3485 } else {
3486 return 0
3490 # Return 1 if this is a PowerPC target with Altivec enabled.
3492 proc check_effective_target_powerpc_altivec { } {
3493 if { [istarget powerpc*-*-*] } {
3494 return [check_no_compiler_messages powerpc_altivec object {
3495 #ifndef __ALTIVEC__
3496 #error not Altivec
3497 #else
3498 int dummy;
3499 #endif
3501 } else {
3502 return 0
3506 # Return 1 if this is a PowerPC 405 target. The check includes options
3507 # specified by dg-options for this test, so don't cache the result.
3509 proc check_effective_target_powerpc_405_nocache { } {
3510 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3511 return [check_no_compiler_messages_nocache powerpc_405 object {
3512 #ifdef __PPC405__
3513 int dummy;
3514 #else
3515 #error not a PPC405
3516 #endif
3517 } [current_compiler_flags]]
3518 } else {
3519 return 0
3523 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3525 proc check_effective_target_powerpc_elfv2 { } {
3526 if { [istarget powerpc*-*-*] } {
3527 return [check_no_compiler_messages powerpc_elfv2 object {
3528 #if _CALL_ELF != 2
3529 #error not ELF v2 ABI
3530 #else
3531 int dummy;
3532 #endif
3534 } else {
3535 return 0
3539 # Return 1 if this is a SPU target with a toolchain that
3540 # supports automatic overlay generation.
3542 proc check_effective_target_spu_auto_overlay { } {
3543 if { [istarget spu*-*-elf*] } {
3544 return [check_no_compiler_messages spu_auto_overlay executable {
3545 int main (void) { }
3546 } "-Wl,--auto-overlay" ]
3547 } else {
3548 return 0
3552 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3553 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3554 # test environment appears to run executables on such a simulator.
3556 proc check_effective_target_ultrasparc_hw { } {
3557 return [check_runtime ultrasparc_hw {
3558 int main() { return 0; }
3559 } "-mcpu=ultrasparc"]
3562 # Return 1 if the test environment supports executing UltraSPARC VIS2
3563 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3565 proc check_effective_target_ultrasparc_vis2_hw { } {
3566 return [check_runtime ultrasparc_vis2_hw {
3567 int main() { __asm__(".word 0x81b00320"); return 0; }
3568 } "-mcpu=ultrasparc3"]
3571 # Return 1 if the test environment supports executing UltraSPARC VIS3
3572 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3574 proc check_effective_target_ultrasparc_vis3_hw { } {
3575 return [check_runtime ultrasparc_vis3_hw {
3576 int main() { __asm__(".word 0x81b00220"); return 0; }
3577 } "-mcpu=niagara3"]
3580 # Return 1 if this is a SPARC-V9 target.
3582 proc check_effective_target_sparc_v9 { } {
3583 if { [istarget sparc*-*-*] } {
3584 return [check_no_compiler_messages sparc_v9 object {
3585 int main (void) {
3586 asm volatile ("return %i7+8");
3587 return 0;
3590 } else {
3591 return 0
3595 # Return 1 if this is a SPARC target with VIS enabled.
3597 proc check_effective_target_sparc_vis { } {
3598 if { [istarget sparc*-*-*] } {
3599 return [check_no_compiler_messages sparc_vis object {
3600 #ifndef __VIS__
3601 #error not VIS
3602 #else
3603 int dummy;
3604 #endif
3606 } else {
3607 return 0
3611 # Return 1 if the target supports hardware vector shift operation.
3613 proc check_effective_target_vect_shift { } {
3614 global et_vect_shift_saved
3616 if [info exists et_vect_shift_saved] {
3617 verbose "check_effective_target_vect_shift: using cached result" 2
3618 } else {
3619 set et_vect_shift_saved 0
3620 if { ([istarget powerpc*-*-*]
3621 && ![istarget powerpc-*-linux*paired*])
3622 || [istarget ia64-*-*]
3623 || [istarget i?86-*-*] || [istarget x86_64-*-*]
3624 || [istarget aarch64*-*-*]
3625 || [check_effective_target_arm32]
3626 || ([istarget mips*-*-*]
3627 && [check_effective_target_mips_loongson]) } {
3628 set et_vect_shift_saved 1
3632 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3633 return $et_vect_shift_saved
3636 proc check_effective_target_whole_vector_shift { } {
3637 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3638 || [istarget ia64-*-*]
3639 || [istarget aarch64*-*-*]
3640 || ([check_effective_target_arm32]
3641 && [check_effective_target_arm_little_endian])
3642 || ([istarget mips*-*-*]
3643 && [check_effective_target_mips_loongson]) } {
3644 set answer 1
3645 } else {
3646 set answer 0
3649 verbose "check_effective_target_vect_long: returning $answer" 2
3650 return $answer
3653 # Return 1 if the target supports vector bswap operations.
3655 proc check_effective_target_vect_bswap { } {
3656 global et_vect_bswap_saved
3658 if [info exists et_vect_bswap_saved] {
3659 verbose "check_effective_target_vect_bswap: using cached result" 2
3660 } else {
3661 set et_vect_bswap_saved 0
3662 if { [istarget aarch64*-*-*]
3663 || ([istarget arm*-*-*]
3664 && [check_effective_target_arm_neon])
3666 set et_vect_bswap_saved 1
3670 verbose "check_effective_target_vect_bswap: returning $et_vect_bswap_saved" 2
3671 return $et_vect_bswap_saved
3674 # Return 1 if the target supports hardware vector shift operation for char.
3676 proc check_effective_target_vect_shift_char { } {
3677 global et_vect_shift_char_saved
3679 if [info exists et_vect_shift_char_saved] {
3680 verbose "check_effective_target_vect_shift_char: using cached result" 2
3681 } else {
3682 set et_vect_shift_char_saved 0
3683 if { ([istarget powerpc*-*-*]
3684 && ![istarget powerpc-*-linux*paired*])
3685 || [check_effective_target_arm32] } {
3686 set et_vect_shift_char_saved 1
3690 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3691 return $et_vect_shift_char_saved
3694 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3696 # This can change for different subtargets so do not cache the result.
3698 proc check_effective_target_vect_long { } {
3699 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3700 || (([istarget powerpc*-*-*]
3701 && ![istarget powerpc-*-linux*paired*])
3702 && [check_effective_target_ilp32])
3703 || [check_effective_target_arm32]
3704 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3705 set answer 1
3706 } else {
3707 set answer 0
3710 verbose "check_effective_target_vect_long: returning $answer" 2
3711 return $answer
3714 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3716 # This won't change for different subtargets so cache the result.
3718 proc check_effective_target_vect_float { } {
3719 global et_vect_float_saved
3721 if [info exists et_vect_float_saved] {
3722 verbose "check_effective_target_vect_float: using cached result" 2
3723 } else {
3724 set et_vect_float_saved 0
3725 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3726 || [istarget powerpc*-*-*]
3727 || [istarget spu-*-*]
3728 || [istarget mips-sde-elf]
3729 || [istarget mipsisa64*-*-*]
3730 || [istarget ia64-*-*]
3731 || [istarget aarch64*-*-*]
3732 || [check_effective_target_arm32] } {
3733 set et_vect_float_saved 1
3737 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
3738 return $et_vect_float_saved
3741 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
3743 # This won't change for different subtargets so cache the result.
3745 proc check_effective_target_vect_double { } {
3746 global et_vect_double_saved
3748 if [info exists et_vect_double_saved] {
3749 verbose "check_effective_target_vect_double: using cached result" 2
3750 } else {
3751 set et_vect_double_saved 0
3752 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3753 || [istarget aarch64*-*-*] } {
3754 if { [check_no_compiler_messages vect_double assembly {
3755 #ifdef __tune_atom__
3756 # error No double vectorizer support.
3757 #endif
3758 }] } {
3759 set et_vect_double_saved 1
3760 } else {
3761 set et_vect_double_saved 0
3763 } elseif { [istarget spu-*-*] } {
3764 set et_vect_double_saved 1
3765 } elseif { [istarget powerpc*-*-*] && [check_vsx_hw_available] } {
3766 set et_vect_double_saved 1
3770 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3771 return $et_vect_double_saved
3774 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3776 # This won't change for different subtargets so cache the result.
3778 proc check_effective_target_vect_long_long { } {
3779 global et_vect_long_long_saved
3781 if [info exists et_vect_long_long_saved] {
3782 verbose "check_effective_target_vect_long_long: using cached result" 2
3783 } else {
3784 set et_vect_long_long_saved 0
3785 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
3786 set et_vect_long_long_saved 1
3790 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3791 return $et_vect_long_long_saved
3795 # Return 1 if the target plus current options does not support a vector
3796 # max instruction on "int", 0 otherwise.
3798 # This won't change for different subtargets so cache the result.
3800 proc check_effective_target_vect_no_int_min_max { } {
3801 global et_vect_no_int_min_max_saved
3803 if [info exists et_vect_no_int_min_max_saved] {
3804 verbose "check_effective_target_vect_no_int_min_max: using cached result" 2
3805 } else {
3806 set et_vect_no_int_min_max_saved 0
3807 if { [istarget sparc*-*-*]
3808 || [istarget spu-*-*]
3809 || [istarget alpha*-*-*]
3810 || ([istarget mips*-*-*]
3811 && [check_effective_target_mips_loongson]) } {
3812 set et_vect_no_int_min_max_saved 1
3815 verbose "check_effective_target_vect_no_int_min_max: returning $et_vect_no_int_min_max_saved" 2
3816 return $et_vect_no_int_min_max_saved
3819 # Return 1 if the target plus current options does not support a vector
3820 # add instruction on "int", 0 otherwise.
3822 # This won't change for different subtargets so cache the result.
3824 proc check_effective_target_vect_no_int_add { } {
3825 global et_vect_no_int_add_saved
3827 if [info exists et_vect_no_int_add_saved] {
3828 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3829 } else {
3830 set et_vect_no_int_add_saved 0
3831 # Alpha only supports vector add on V8QI and V4HI.
3832 if { [istarget alpha*-*-*] } {
3833 set et_vect_no_int_add_saved 1
3836 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3837 return $et_vect_no_int_add_saved
3840 # Return 1 if the target plus current options does not support vector
3841 # bitwise instructions, 0 otherwise.
3843 # This won't change for different subtargets so cache the result.
3845 proc check_effective_target_vect_no_bitwise { } {
3846 global et_vect_no_bitwise_saved
3848 if [info exists et_vect_no_bitwise_saved] {
3849 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3850 } else {
3851 set et_vect_no_bitwise_saved 0
3853 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3854 return $et_vect_no_bitwise_saved
3857 # Return 1 if the target plus current options supports vector permutation,
3858 # 0 otherwise.
3860 # This won't change for different subtargets so cache the result.
3862 proc check_effective_target_vect_perm { } {
3863 global et_vect_perm
3865 if [info exists et_vect_perm_saved] {
3866 verbose "check_effective_target_vect_perm: using cached result" 2
3867 } else {
3868 set et_vect_perm_saved 0
3869 if { [is-effective-target arm_neon_ok]
3870 || [istarget aarch64*-*-*]
3871 || [istarget powerpc*-*-*]
3872 || [istarget spu-*-*]
3873 || [istarget i?86-*-*] || [istarget x86_64-*-*]
3874 || ([istarget mips*-*-*]
3875 && [check_effective_target_mpaired_single]) } {
3876 set et_vect_perm_saved 1
3879 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3880 return $et_vect_perm_saved
3883 # Return 1 if the target plus current options supports vector permutation
3884 # on byte-sized elements, 0 otherwise.
3886 # This won't change for different subtargets so cache the result.
3888 proc check_effective_target_vect_perm_byte { } {
3889 global et_vect_perm_byte
3891 if [info exists et_vect_perm_byte_saved] {
3892 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3893 } else {
3894 set et_vect_perm_byte_saved 0
3895 if { ([is-effective-target arm_neon_ok]
3896 && [is-effective-target arm_little_endian])
3897 || ([istarget aarch64*-*-*]
3898 && [is-effective-target aarch64_little_endian])
3899 || [istarget powerpc*-*-*]
3900 || [istarget spu-*-*] } {
3901 set et_vect_perm_byte_saved 1
3904 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3905 return $et_vect_perm_byte_saved
3908 # Return 1 if the target plus current options supports vector permutation
3909 # on short-sized elements, 0 otherwise.
3911 # This won't change for different subtargets so cache the result.
3913 proc check_effective_target_vect_perm_short { } {
3914 global et_vect_perm_short
3916 if [info exists et_vect_perm_short_saved] {
3917 verbose "check_effective_target_vect_perm_short: using cached result" 2
3918 } else {
3919 set et_vect_perm_short_saved 0
3920 if { ([is-effective-target arm_neon_ok]
3921 && [is-effective-target arm_little_endian])
3922 || ([istarget aarch64*-*-*]
3923 && [is-effective-target aarch64_little_endian])
3924 || [istarget powerpc*-*-*]
3925 || [istarget spu-*-*] } {
3926 set et_vect_perm_short_saved 1
3929 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3930 return $et_vect_perm_short_saved
3933 # Return 1 if the target plus current options supports a vector
3934 # widening summation of *short* args into *int* result, 0 otherwise.
3936 # This won't change for different subtargets so cache the result.
3938 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3939 global et_vect_widen_sum_hi_to_si_pattern
3941 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3942 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3943 } else {
3944 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3945 if { [istarget powerpc*-*-*]
3946 || [istarget ia64-*-*] } {
3947 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3950 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3951 return $et_vect_widen_sum_hi_to_si_pattern_saved
3954 # Return 1 if the target plus current options supports a vector
3955 # widening summation of *short* args into *int* result, 0 otherwise.
3956 # A target can also support this widening summation if it can support
3957 # promotion (unpacking) from shorts to ints.
3959 # This won't change for different subtargets so cache the result.
3961 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3962 global et_vect_widen_sum_hi_to_si
3964 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3965 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3966 } else {
3967 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3968 if { [istarget powerpc*-*-*]
3969 || [istarget ia64-*-*] } {
3970 set et_vect_widen_sum_hi_to_si_saved 1
3973 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3974 return $et_vect_widen_sum_hi_to_si_saved
3977 # Return 1 if the target plus current options supports a vector
3978 # widening summation of *char* args into *short* result, 0 otherwise.
3979 # A target can also support this widening summation if it can support
3980 # promotion (unpacking) from chars to shorts.
3982 # This won't change for different subtargets so cache the result.
3984 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3985 global et_vect_widen_sum_qi_to_hi
3987 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3988 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3989 } else {
3990 set et_vect_widen_sum_qi_to_hi_saved 0
3991 if { [check_effective_target_vect_unpack]
3992 || [check_effective_target_arm_neon_ok]
3993 || [istarget ia64-*-*] } {
3994 set et_vect_widen_sum_qi_to_hi_saved 1
3997 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3998 return $et_vect_widen_sum_qi_to_hi_saved
4001 # Return 1 if the target plus current options supports a vector
4002 # widening summation of *char* args into *int* result, 0 otherwise.
4004 # This won't change for different subtargets so cache the result.
4006 proc check_effective_target_vect_widen_sum_qi_to_si { } {
4007 global et_vect_widen_sum_qi_to_si
4009 if [info exists et_vect_widen_sum_qi_to_si_saved] {
4010 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
4011 } else {
4012 set et_vect_widen_sum_qi_to_si_saved 0
4013 if { [istarget powerpc*-*-*] } {
4014 set et_vect_widen_sum_qi_to_si_saved 1
4017 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
4018 return $et_vect_widen_sum_qi_to_si_saved
4021 # Return 1 if the target plus current options supports a vector
4022 # widening multiplication of *char* args into *short* result, 0 otherwise.
4023 # A target can also support this widening multplication if it can support
4024 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
4025 # multiplication of shorts).
4027 # This won't change for different subtargets so cache the result.
4030 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
4031 global et_vect_widen_mult_qi_to_hi
4033 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
4034 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
4035 } else {
4036 if { [check_effective_target_vect_unpack]
4037 && [check_effective_target_vect_short_mult] } {
4038 set et_vect_widen_mult_qi_to_hi_saved 1
4039 } else {
4040 set et_vect_widen_mult_qi_to_hi_saved 0
4042 if { [istarget powerpc*-*-*]
4043 || [istarget aarch64*-*-*]
4044 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4045 set et_vect_widen_mult_qi_to_hi_saved 1
4048 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
4049 return $et_vect_widen_mult_qi_to_hi_saved
4052 # Return 1 if the target plus current options supports a vector
4053 # widening multiplication of *short* args into *int* result, 0 otherwise.
4054 # A target can also support this widening multplication if it can support
4055 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
4056 # multiplication of ints).
4058 # This won't change for different subtargets so cache the result.
4061 proc check_effective_target_vect_widen_mult_hi_to_si { } {
4062 global et_vect_widen_mult_hi_to_si
4064 if [info exists et_vect_widen_mult_hi_to_si_saved] {
4065 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
4066 } else {
4067 if { [check_effective_target_vect_unpack]
4068 && [check_effective_target_vect_int_mult] } {
4069 set et_vect_widen_mult_hi_to_si_saved 1
4070 } else {
4071 set et_vect_widen_mult_hi_to_si_saved 0
4073 if { [istarget powerpc*-*-*]
4074 || [istarget spu-*-*]
4075 || [istarget ia64-*-*]
4076 || [istarget aarch64*-*-*]
4077 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4078 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4079 set et_vect_widen_mult_hi_to_si_saved 1
4082 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
4083 return $et_vect_widen_mult_hi_to_si_saved
4086 # Return 1 if the target plus current options supports a vector
4087 # widening multiplication of *char* args into *short* result, 0 otherwise.
4089 # This won't change for different subtargets so cache the result.
4091 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
4092 global et_vect_widen_mult_qi_to_hi_pattern
4094 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
4095 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
4096 } else {
4097 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
4098 if { [istarget powerpc*-*-*]
4099 || ([istarget arm*-*-*]
4100 && [check_effective_target_arm_neon_ok]
4101 && [check_effective_target_arm_little_endian]) } {
4102 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
4105 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
4106 return $et_vect_widen_mult_qi_to_hi_pattern_saved
4109 # Return 1 if the target plus current options supports a vector
4110 # widening multiplication of *short* args into *int* result, 0 otherwise.
4112 # This won't change for different subtargets so cache the result.
4114 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
4115 global et_vect_widen_mult_hi_to_si_pattern
4117 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
4118 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
4119 } else {
4120 set et_vect_widen_mult_hi_to_si_pattern_saved 0
4121 if { [istarget powerpc*-*-*]
4122 || [istarget spu-*-*]
4123 || [istarget ia64-*-*]
4124 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4125 || ([istarget arm*-*-*]
4126 && [check_effective_target_arm_neon_ok]
4127 && [check_effective_target_arm_little_endian]) } {
4128 set et_vect_widen_mult_hi_to_si_pattern_saved 1
4131 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
4132 return $et_vect_widen_mult_hi_to_si_pattern_saved
4135 # Return 1 if the target plus current options supports a vector
4136 # widening multiplication of *int* args into *long* result, 0 otherwise.
4138 # This won't change for different subtargets so cache the result.
4140 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
4141 global et_vect_widen_mult_si_to_di_pattern
4143 if [info exists et_vect_widen_mult_si_to_di_pattern_saved] {
4144 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: using cached result" 2
4145 } else {
4146 set et_vect_widen_mult_si_to_di_pattern_saved 0
4147 if {[istarget ia64-*-*]
4148 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4149 set et_vect_widen_mult_si_to_di_pattern_saved 1
4152 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: returning $et_vect_widen_mult_si_to_di_pattern_saved" 2
4153 return $et_vect_widen_mult_si_to_di_pattern_saved
4156 # Return 1 if the target plus current options supports a vector
4157 # widening shift, 0 otherwise.
4159 # This won't change for different subtargets so cache the result.
4161 proc check_effective_target_vect_widen_shift { } {
4162 global et_vect_widen_shift_saved
4164 if [info exists et_vect_shift_saved] {
4165 verbose "check_effective_target_vect_widen_shift: using cached result" 2
4166 } else {
4167 set et_vect_widen_shift_saved 0
4168 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4169 set et_vect_widen_shift_saved 1
4172 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
4173 return $et_vect_widen_shift_saved
4176 # Return 1 if the target plus current options supports a vector
4177 # dot-product of signed chars, 0 otherwise.
4179 # This won't change for different subtargets so cache the result.
4181 proc check_effective_target_vect_sdot_qi { } {
4182 global et_vect_sdot_qi
4184 if [info exists et_vect_sdot_qi_saved] {
4185 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
4186 } else {
4187 set et_vect_sdot_qi_saved 0
4188 if { [istarget ia64-*-*] } {
4189 set et_vect_udot_qi_saved 1
4192 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
4193 return $et_vect_sdot_qi_saved
4196 # Return 1 if the target plus current options supports a vector
4197 # dot-product of unsigned chars, 0 otherwise.
4199 # This won't change for different subtargets so cache the result.
4201 proc check_effective_target_vect_udot_qi { } {
4202 global et_vect_udot_qi
4204 if [info exists et_vect_udot_qi_saved] {
4205 verbose "check_effective_target_vect_udot_qi: using cached result" 2
4206 } else {
4207 set et_vect_udot_qi_saved 0
4208 if { [istarget powerpc*-*-*]
4209 || [istarget ia64-*-*] } {
4210 set et_vect_udot_qi_saved 1
4213 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
4214 return $et_vect_udot_qi_saved
4217 # Return 1 if the target plus current options supports a vector
4218 # dot-product of signed shorts, 0 otherwise.
4220 # This won't change for different subtargets so cache the result.
4222 proc check_effective_target_vect_sdot_hi { } {
4223 global et_vect_sdot_hi
4225 if [info exists et_vect_sdot_hi_saved] {
4226 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
4227 } else {
4228 set et_vect_sdot_hi_saved 0
4229 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4230 || [istarget ia64-*-*]
4231 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4232 set et_vect_sdot_hi_saved 1
4235 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
4236 return $et_vect_sdot_hi_saved
4239 # Return 1 if the target plus current options supports a vector
4240 # dot-product of unsigned shorts, 0 otherwise.
4242 # This won't change for different subtargets so cache the result.
4244 proc check_effective_target_vect_udot_hi { } {
4245 global et_vect_udot_hi
4247 if [info exists et_vect_udot_hi_saved] {
4248 verbose "check_effective_target_vect_udot_hi: using cached result" 2
4249 } else {
4250 set et_vect_udot_hi_saved 0
4251 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
4252 set et_vect_udot_hi_saved 1
4255 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
4256 return $et_vect_udot_hi_saved
4259 # Return 1 if the target plus current options supports a vector
4260 # sad operation of unsigned chars, 0 otherwise.
4262 # This won't change for different subtargets so cache the result.
4264 proc check_effective_target_vect_usad_char { } {
4265 global et_vect_usad_char
4267 if [info exists et_vect_usad_char_saved] {
4268 verbose "check_effective_target_vect_usad_char: using cached result" 2
4269 } else {
4270 set et_vect_usad_char_saved 0
4271 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
4272 set et_vect_usad_char_saved 1
4275 verbose "check_effective_target_vect_usad_char: returning $et_vect_usad_char_saved" 2
4276 return $et_vect_usad_char_saved
4279 # Return 1 if the target plus current options supports a vector
4280 # demotion (packing) of shorts (to chars) and ints (to shorts)
4281 # using modulo arithmetic, 0 otherwise.
4283 # This won't change for different subtargets so cache the result.
4285 proc check_effective_target_vect_pack_trunc { } {
4286 global et_vect_pack_trunc
4288 if [info exists et_vect_pack_trunc_saved] {
4289 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
4290 } else {
4291 set et_vect_pack_trunc_saved 0
4292 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4293 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4294 || [istarget aarch64*-*-*]
4295 || [istarget spu-*-*]
4296 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4297 && [check_effective_target_arm_little_endian]) } {
4298 set et_vect_pack_trunc_saved 1
4301 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
4302 return $et_vect_pack_trunc_saved
4305 # Return 1 if the target plus current options supports a vector
4306 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
4308 # This won't change for different subtargets so cache the result.
4310 proc check_effective_target_vect_unpack { } {
4311 global et_vect_unpack
4313 if [info exists et_vect_unpack_saved] {
4314 verbose "check_effective_target_vect_unpack: using cached result" 2
4315 } else {
4316 set et_vect_unpack_saved 0
4317 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
4318 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4319 || [istarget spu-*-*]
4320 || [istarget ia64-*-*]
4321 || [istarget aarch64*-*-*]
4322 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4323 && [check_effective_target_arm_little_endian]) } {
4324 set et_vect_unpack_saved 1
4327 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
4328 return $et_vect_unpack_saved
4331 # Return 1 if the target plus current options does not guarantee
4332 # that its STACK_BOUNDARY is >= the reguired vector alignment.
4334 # This won't change for different subtargets so cache the result.
4336 proc check_effective_target_unaligned_stack { } {
4337 global et_unaligned_stack_saved
4339 if [info exists et_unaligned_stack_saved] {
4340 verbose "check_effective_target_unaligned_stack: using cached result" 2
4341 } else {
4342 set et_unaligned_stack_saved 0
4344 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
4345 return $et_unaligned_stack_saved
4348 # Return 1 if the target plus current options does not support a vector
4349 # alignment mechanism, 0 otherwise.
4351 # This won't change for different subtargets so cache the result.
4353 proc check_effective_target_vect_no_align { } {
4354 global et_vect_no_align_saved
4356 if [info exists et_vect_no_align_saved] {
4357 verbose "check_effective_target_vect_no_align: using cached result" 2
4358 } else {
4359 set et_vect_no_align_saved 0
4360 if { [istarget mipsisa64*-*-*]
4361 || [istarget mips-sde-elf]
4362 || [istarget sparc*-*-*]
4363 || [istarget ia64-*-*]
4364 || [check_effective_target_arm_vect_no_misalign]
4365 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4366 || ([istarget mips*-*-*]
4367 && [check_effective_target_mips_loongson]) } {
4368 set et_vect_no_align_saved 1
4371 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
4372 return $et_vect_no_align_saved
4375 # Return 1 if the target supports a vector misalign access, 0 otherwise.
4377 # This won't change for different subtargets so cache the result.
4379 proc check_effective_target_vect_hw_misalign { } {
4380 global et_vect_hw_misalign_saved
4382 if [info exists et_vect_hw_misalign_saved] {
4383 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
4384 } else {
4385 set et_vect_hw_misalign_saved 0
4386 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4387 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4388 || [istarget aarch64*-*-*] } {
4389 set et_vect_hw_misalign_saved 1
4392 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
4393 return $et_vect_hw_misalign_saved
4397 # Return 1 if arrays are aligned to the vector alignment
4398 # boundary, 0 otherwise.
4400 # This won't change for different subtargets so cache the result.
4402 proc check_effective_target_vect_aligned_arrays { } {
4403 global et_vect_aligned_arrays
4405 if [info exists et_vect_aligned_arrays_saved] {
4406 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
4407 } else {
4408 set et_vect_aligned_arrays_saved 0
4409 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4410 if { ([is-effective-target lp64]
4411 && ( ![check_avx_available]
4412 || [check_prefer_avx128])) } {
4413 set et_vect_aligned_arrays_saved 1
4416 if [istarget spu-*-*] {
4417 set et_vect_aligned_arrays_saved 1
4420 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
4421 return $et_vect_aligned_arrays_saved
4424 # Return 1 if types of size 32 bit or less are naturally aligned
4425 # (aligned to their type-size), 0 otherwise.
4427 # This won't change for different subtargets so cache the result.
4429 proc check_effective_target_natural_alignment_32 { } {
4430 global et_natural_alignment_32
4432 if [info exists et_natural_alignment_32_saved] {
4433 verbose "check_effective_target_natural_alignment_32: using cached result" 2
4434 } else {
4435 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
4436 set et_natural_alignment_32_saved 1
4437 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
4438 set et_natural_alignment_32_saved 0
4441 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
4442 return $et_natural_alignment_32_saved
4445 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
4446 # type-size), 0 otherwise.
4448 # This won't change for different subtargets so cache the result.
4450 proc check_effective_target_natural_alignment_64 { } {
4451 global et_natural_alignment_64
4453 if [info exists et_natural_alignment_64_saved] {
4454 verbose "check_effective_target_natural_alignment_64: using cached result" 2
4455 } else {
4456 set et_natural_alignment_64_saved 0
4457 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
4458 || [istarget spu-*-*] } {
4459 set et_natural_alignment_64_saved 1
4462 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
4463 return $et_natural_alignment_64_saved
4466 # Return 1 if all vector types are naturally aligned (aligned to their
4467 # type-size), 0 otherwise.
4469 # This won't change for different subtargets so cache the result.
4471 proc check_effective_target_vect_natural_alignment { } {
4472 global et_vect_natural_alignment
4474 if [info exists et_vect_natural_alignment_saved] {
4475 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
4476 } else {
4477 set et_vect_natural_alignment_saved 1
4478 if { [check_effective_target_arm_eabi]
4479 || [istarget nvptx-*-*]
4480 || [istarget s390*-*-*] } {
4481 set et_vect_natural_alignment_saved 0
4484 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
4485 return $et_vect_natural_alignment_saved
4488 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
4490 # This won't change for different subtargets so cache the result.
4492 proc check_effective_target_vector_alignment_reachable { } {
4493 global et_vector_alignment_reachable
4495 if [info exists et_vector_alignment_reachable_saved] {
4496 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
4497 } else {
4498 if { [check_effective_target_vect_aligned_arrays]
4499 || [check_effective_target_natural_alignment_32] } {
4500 set et_vector_alignment_reachable_saved 1
4501 } else {
4502 set et_vector_alignment_reachable_saved 0
4505 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
4506 return $et_vector_alignment_reachable_saved
4509 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
4511 # This won't change for different subtargets so cache the result.
4513 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
4514 global et_vector_alignment_reachable_for_64bit
4516 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
4517 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
4518 } else {
4519 if { [check_effective_target_vect_aligned_arrays]
4520 || [check_effective_target_natural_alignment_64] } {
4521 set et_vector_alignment_reachable_for_64bit_saved 1
4522 } else {
4523 set et_vector_alignment_reachable_for_64bit_saved 0
4526 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
4527 return $et_vector_alignment_reachable_for_64bit_saved
4530 # Return 1 if the target only requires element alignment for vector accesses
4532 proc check_effective_target_vect_element_align { } {
4533 global et_vect_element_align
4535 if [info exists et_vect_element_align] {
4536 verbose "check_effective_target_vect_element_align: using cached result" 2
4537 } else {
4538 set et_vect_element_align 0
4539 if { ([istarget arm*-*-*]
4540 && ![check_effective_target_arm_vect_no_misalign])
4541 || [check_effective_target_vect_hw_misalign] } {
4542 set et_vect_element_align 1
4546 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4547 return $et_vect_element_align
4550 # Return 1 if the target supports vector conditional operations, 0 otherwise.
4552 proc check_effective_target_vect_condition { } {
4553 global et_vect_cond_saved
4555 if [info exists et_vect_cond_saved] {
4556 verbose "check_effective_target_vect_cond: using cached result" 2
4557 } else {
4558 set et_vect_cond_saved 0
4559 if { [istarget aarch64*-*-*]
4560 || [istarget powerpc*-*-*]
4561 || [istarget ia64-*-*]
4562 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4563 || [istarget spu-*-*]
4564 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4565 set et_vect_cond_saved 1
4569 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
4570 return $et_vect_cond_saved
4573 # Return 1 if the target supports vector conditional operations where
4574 # the comparison has different type from the lhs, 0 otherwise.
4576 proc check_effective_target_vect_cond_mixed { } {
4577 global et_vect_cond_mixed_saved
4579 if [info exists et_vect_cond_mixed_saved] {
4580 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
4581 } else {
4582 set et_vect_cond_mixed_saved 0
4583 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4584 || [istarget powerpc*-*-*] } {
4585 set et_vect_cond_mixed_saved 1
4589 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
4590 return $et_vect_cond_mixed_saved
4593 # Return 1 if the target supports vector char multiplication, 0 otherwise.
4595 proc check_effective_target_vect_char_mult { } {
4596 global et_vect_char_mult_saved
4598 if [info exists et_vect_char_mult_saved] {
4599 verbose "check_effective_target_vect_char_mult: using cached result" 2
4600 } else {
4601 set et_vect_char_mult_saved 0
4602 if { [istarget aarch64*-*-*]
4603 || [istarget ia64-*-*]
4604 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4605 || [check_effective_target_arm32]
4606 || [check_effective_target_powerpc_altivec] } {
4607 set et_vect_char_mult_saved 1
4611 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4612 return $et_vect_char_mult_saved
4615 # Return 1 if the target supports vector short multiplication, 0 otherwise.
4617 proc check_effective_target_vect_short_mult { } {
4618 global et_vect_short_mult_saved
4620 if [info exists et_vect_short_mult_saved] {
4621 verbose "check_effective_target_vect_short_mult: using cached result" 2
4622 } else {
4623 set et_vect_short_mult_saved 0
4624 if { [istarget ia64-*-*]
4625 || [istarget spu-*-*]
4626 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4627 || [istarget powerpc*-*-*]
4628 || [istarget aarch64*-*-*]
4629 || [check_effective_target_arm32]
4630 || ([istarget mips*-*-*]
4631 && [check_effective_target_mips_loongson]) } {
4632 set et_vect_short_mult_saved 1
4636 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4637 return $et_vect_short_mult_saved
4640 # Return 1 if the target supports vector int multiplication, 0 otherwise.
4642 proc check_effective_target_vect_int_mult { } {
4643 global et_vect_int_mult_saved
4645 if [info exists et_vect_int_mult_saved] {
4646 verbose "check_effective_target_vect_int_mult: using cached result" 2
4647 } else {
4648 set et_vect_int_mult_saved 0
4649 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4650 || [istarget spu-*-*]
4651 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4652 || [istarget ia64-*-*]
4653 || [istarget aarch64*-*-*]
4654 || [check_effective_target_arm32] } {
4655 set et_vect_int_mult_saved 1
4659 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4660 return $et_vect_int_mult_saved
4663 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
4665 proc check_effective_target_vect_extract_even_odd { } {
4666 global et_vect_extract_even_odd_saved
4668 if [info exists et_vect_extract_even_odd_saved] {
4669 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
4670 } else {
4671 set et_vect_extract_even_odd_saved 0
4672 if { [istarget aarch64*-*-*]
4673 || [istarget powerpc*-*-*]
4674 || [is-effective-target arm_neon_ok]
4675 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4676 || [istarget ia64-*-*]
4677 || [istarget spu-*-*]
4678 || ([istarget mips*-*-*]
4679 && [check_effective_target_mpaired_single]) } {
4680 set et_vect_extract_even_odd_saved 1
4684 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4685 return $et_vect_extract_even_odd_saved
4688 # Return 1 if the target supports vector interleaving, 0 otherwise.
4690 proc check_effective_target_vect_interleave { } {
4691 global et_vect_interleave_saved
4693 if [info exists et_vect_interleave_saved] {
4694 verbose "check_effective_target_vect_interleave: using cached result" 2
4695 } else {
4696 set et_vect_interleave_saved 0
4697 if { [istarget aarch64*-*-*]
4698 || [istarget powerpc*-*-*]
4699 || [is-effective-target arm_neon_ok]
4700 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4701 || [istarget ia64-*-*]
4702 || [istarget spu-*-*]
4703 || ([istarget mips*-*-*]
4704 && [check_effective_target_mpaired_single]) } {
4705 set et_vect_interleave_saved 1
4709 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4710 return $et_vect_interleave_saved
4713 foreach N {2 3 4 8} {
4714 eval [string map [list N $N] {
4715 # Return 1 if the target supports 2-vector interleaving
4716 proc check_effective_target_vect_stridedN { } {
4717 global et_vect_stridedN_saved
4719 if [info exists et_vect_stridedN_saved] {
4720 verbose "check_effective_target_vect_stridedN: using cached result" 2
4721 } else {
4722 set et_vect_stridedN_saved 0
4723 if { (N & -N) == N
4724 && [check_effective_target_vect_interleave]
4725 && [check_effective_target_vect_extract_even_odd] } {
4726 set et_vect_stridedN_saved 1
4728 if { ([istarget arm*-*-*]
4729 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
4730 set et_vect_stridedN_saved 1
4734 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4735 return $et_vect_stridedN_saved
4740 # Return 1 if the target supports multiple vector sizes
4742 proc check_effective_target_vect_multiple_sizes { } {
4743 global et_vect_multiple_sizes_saved
4745 set et_vect_multiple_sizes_saved 0
4746 if { ([istarget aarch64*-*-*]
4747 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
4748 set et_vect_multiple_sizes_saved 1
4750 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4751 if { ([check_avx_available] && ![check_prefer_avx128]) } {
4752 set et_vect_multiple_sizes_saved 1
4756 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4757 return $et_vect_multiple_sizes_saved
4760 # Return 1 if the target supports vectors of 64 bits.
4762 proc check_effective_target_vect64 { } {
4763 global et_vect64_saved
4765 if [info exists et_vect64_saved] {
4766 verbose "check_effective_target_vect64: using cached result" 2
4767 } else {
4768 set et_vect64_saved 0
4769 if { ([istarget arm*-*-*]
4770 && [check_effective_target_arm_neon_ok]
4771 && [check_effective_target_arm_little_endian])
4772 || [istarget sparc*-*-*] } {
4773 set et_vect64_saved 1
4777 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
4778 return $et_vect64_saved
4781 # Return 1 if the target supports vector copysignf calls.
4783 proc check_effective_target_vect_call_copysignf { } {
4784 global et_vect_call_copysignf_saved
4786 if [info exists et_vect_call_copysignf_saved] {
4787 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
4788 } else {
4789 set et_vect_call_copysignf_saved 0
4790 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4791 || [istarget powerpc*-*-*] } {
4792 set et_vect_call_copysignf_saved 1
4796 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4797 return $et_vect_call_copysignf_saved
4800 # Return 1 if the target supports hardware square root instructions.
4802 proc check_effective_target_sqrt_insn { } {
4803 global et_sqrt_insn_saved
4805 if [info exists et_sqrt_insn_saved] {
4806 verbose "check_effective_target_hw_sqrt: using cached result" 2
4807 } else {
4808 set et_sqrt_insn_saved 0
4809 if { [istarget x86_64-*-*]
4810 || [istarget powerpc*-*-*]
4811 || [istarget aarch64*-*-*]
4812 || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok]) } {
4813 set et_sqrt_insn_saved 1
4817 verbose "check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
4818 return $et_sqrt_insn_saved
4821 # Return 1 if the target supports vector sqrtf calls.
4823 proc check_effective_target_vect_call_sqrtf { } {
4824 global et_vect_call_sqrtf_saved
4826 if [info exists et_vect_call_sqrtf_saved] {
4827 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
4828 } else {
4829 set et_vect_call_sqrtf_saved 0
4830 if { [istarget aarch64*-*-*]
4831 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4832 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
4833 set et_vect_call_sqrtf_saved 1
4837 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4838 return $et_vect_call_sqrtf_saved
4841 # Return 1 if the target supports vector lrint calls.
4843 proc check_effective_target_vect_call_lrint { } {
4844 set et_vect_call_lrint 0
4845 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
4846 && [check_effective_target_ilp32] } {
4847 set et_vect_call_lrint 1
4850 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4851 return $et_vect_call_lrint
4854 # Return 1 if the target supports vector btrunc calls.
4856 proc check_effective_target_vect_call_btrunc { } {
4857 global et_vect_call_btrunc_saved
4859 if [info exists et_vect_call_btrunc_saved] {
4860 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4861 } else {
4862 set et_vect_call_btrunc_saved 0
4863 if { [istarget aarch64*-*-*] } {
4864 set et_vect_call_btrunc_saved 1
4868 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4869 return $et_vect_call_btrunc_saved
4872 # Return 1 if the target supports vector btruncf calls.
4874 proc check_effective_target_vect_call_btruncf { } {
4875 global et_vect_call_btruncf_saved
4877 if [info exists et_vect_call_btruncf_saved] {
4878 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4879 } else {
4880 set et_vect_call_btruncf_saved 0
4881 if { [istarget aarch64*-*-*] } {
4882 set et_vect_call_btruncf_saved 1
4886 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4887 return $et_vect_call_btruncf_saved
4890 # Return 1 if the target supports vector ceil calls.
4892 proc check_effective_target_vect_call_ceil { } {
4893 global et_vect_call_ceil_saved
4895 if [info exists et_vect_call_ceil_saved] {
4896 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4897 } else {
4898 set et_vect_call_ceil_saved 0
4899 if { [istarget aarch64*-*-*] } {
4900 set et_vect_call_ceil_saved 1
4904 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4905 return $et_vect_call_ceil_saved
4908 # Return 1 if the target supports vector ceilf calls.
4910 proc check_effective_target_vect_call_ceilf { } {
4911 global et_vect_call_ceilf_saved
4913 if [info exists et_vect_call_ceilf_saved] {
4914 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4915 } else {
4916 set et_vect_call_ceilf_saved 0
4917 if { [istarget aarch64*-*-*] } {
4918 set et_vect_call_ceilf_saved 1
4922 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4923 return $et_vect_call_ceilf_saved
4926 # Return 1 if the target supports vector floor calls.
4928 proc check_effective_target_vect_call_floor { } {
4929 global et_vect_call_floor_saved
4931 if [info exists et_vect_call_floor_saved] {
4932 verbose "check_effective_target_vect_call_floor: using cached result" 2
4933 } else {
4934 set et_vect_call_floor_saved 0
4935 if { [istarget aarch64*-*-*] } {
4936 set et_vect_call_floor_saved 1
4940 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4941 return $et_vect_call_floor_saved
4944 # Return 1 if the target supports vector floorf calls.
4946 proc check_effective_target_vect_call_floorf { } {
4947 global et_vect_call_floorf_saved
4949 if [info exists et_vect_call_floorf_saved] {
4950 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4951 } else {
4952 set et_vect_call_floorf_saved 0
4953 if { [istarget aarch64*-*-*] } {
4954 set et_vect_call_floorf_saved 1
4958 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4959 return $et_vect_call_floorf_saved
4962 # Return 1 if the target supports vector lceil calls.
4964 proc check_effective_target_vect_call_lceil { } {
4965 global et_vect_call_lceil_saved
4967 if [info exists et_vect_call_lceil_saved] {
4968 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4969 } else {
4970 set et_vect_call_lceil_saved 0
4971 if { [istarget aarch64*-*-*] } {
4972 set et_vect_call_lceil_saved 1
4976 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4977 return $et_vect_call_lceil_saved
4980 # Return 1 if the target supports vector lfloor calls.
4982 proc check_effective_target_vect_call_lfloor { } {
4983 global et_vect_call_lfloor_saved
4985 if [info exists et_vect_call_lfloor_saved] {
4986 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4987 } else {
4988 set et_vect_call_lfloor_saved 0
4989 if { [istarget aarch64*-*-*] } {
4990 set et_vect_call_lfloor_saved 1
4994 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4995 return $et_vect_call_lfloor_saved
4998 # Return 1 if the target supports vector nearbyint calls.
5000 proc check_effective_target_vect_call_nearbyint { } {
5001 global et_vect_call_nearbyint_saved
5003 if [info exists et_vect_call_nearbyint_saved] {
5004 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
5005 } else {
5006 set et_vect_call_nearbyint_saved 0
5007 if { [istarget aarch64*-*-*] } {
5008 set et_vect_call_nearbyint_saved 1
5012 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
5013 return $et_vect_call_nearbyint_saved
5016 # Return 1 if the target supports vector nearbyintf calls.
5018 proc check_effective_target_vect_call_nearbyintf { } {
5019 global et_vect_call_nearbyintf_saved
5021 if [info exists et_vect_call_nearbyintf_saved] {
5022 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
5023 } else {
5024 set et_vect_call_nearbyintf_saved 0
5025 if { [istarget aarch64*-*-*] } {
5026 set et_vect_call_nearbyintf_saved 1
5030 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
5031 return $et_vect_call_nearbyintf_saved
5034 # Return 1 if the target supports vector round calls.
5036 proc check_effective_target_vect_call_round { } {
5037 global et_vect_call_round_saved
5039 if [info exists et_vect_call_round_saved] {
5040 verbose "check_effective_target_vect_call_round: using cached result" 2
5041 } else {
5042 set et_vect_call_round_saved 0
5043 if { [istarget aarch64*-*-*] } {
5044 set et_vect_call_round_saved 1
5048 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
5049 return $et_vect_call_round_saved
5052 # Return 1 if the target supports vector roundf calls.
5054 proc check_effective_target_vect_call_roundf { } {
5055 global et_vect_call_roundf_saved
5057 if [info exists et_vect_call_roundf_saved] {
5058 verbose "check_effective_target_vect_call_roundf: using cached result" 2
5059 } else {
5060 set et_vect_call_roundf_saved 0
5061 if { [istarget aarch64*-*-*] } {
5062 set et_vect_call_roundf_saved 1
5066 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
5067 return $et_vect_call_roundf_saved
5070 # Return 1 if the target supports section-anchors
5072 proc check_effective_target_section_anchors { } {
5073 global et_section_anchors_saved
5075 if [info exists et_section_anchors_saved] {
5076 verbose "check_effective_target_section_anchors: using cached result" 2
5077 } else {
5078 set et_section_anchors_saved 0
5079 if { [istarget powerpc*-*-*]
5080 || [istarget arm*-*-*] } {
5081 set et_section_anchors_saved 1
5085 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
5086 return $et_section_anchors_saved
5089 # Return 1 if the target supports atomic operations on "int_128" values.
5091 proc check_effective_target_sync_int_128 { } {
5092 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5093 && ![is-effective-target ia32] } {
5094 return 1
5095 } else {
5096 return 0
5100 # Return 1 if the target supports atomic operations on "int_128" values
5101 # and can execute them.
5103 proc check_effective_target_sync_int_128_runtime { } {
5104 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5105 && ![is-effective-target ia32] } {
5106 return [check_cached_effective_target sync_int_128_available {
5107 check_runtime_nocache sync_int_128_available {
5108 #include "cpuid.h"
5109 int main ()
5111 unsigned int eax, ebx, ecx, edx;
5112 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5113 return !(ecx & bit_CMPXCHG16B);
5114 return 1;
5116 } ""
5118 } else {
5119 return 0
5123 # Return 1 if the target supports atomic operations on "long long".
5125 # Note: 32bit x86 targets require -march=pentium in dg-options.
5127 proc check_effective_target_sync_long_long { } {
5128 if { [istarget x86_64-*-*] || [istarget i?86-*-*])
5129 || [istarget aarch64*-*-*]
5130 || [istarget arm*-*-*]
5131 || [istarget alpha*-*-*]
5132 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
5133 return 1
5134 } else {
5135 return 0
5139 # Return 1 if the target supports atomic operations on "long long"
5140 # and can execute them.
5142 # Note: 32bit x86 targets require -march=pentium in dg-options.
5144 proc check_effective_target_sync_long_long_runtime { } {
5145 if { [istarget x86_64-*-*] || [istarget i?86-*-*] } {
5146 return [check_cached_effective_target sync_long_long_available {
5147 check_runtime_nocache sync_long_long_available {
5148 #include "cpuid.h"
5149 int main ()
5151 unsigned int eax, ebx, ecx, edx;
5152 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5153 return !(edx & bit_CMPXCHG8B);
5154 return 1;
5156 } ""
5158 } elseif { [istarget aarch64*-*-*] } {
5159 return 1
5160 } elseif { [istarget arm*-*-linux-*] } {
5161 return [check_runtime sync_longlong_runtime {
5162 #include <stdlib.h>
5163 int main ()
5165 long long l1;
5167 if (sizeof (long long) != 8)
5168 exit (1);
5170 /* Just check for native; checking for kernel fallback is tricky. */
5171 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
5173 exit (0);
5175 } "" ]
5176 } elseif { [istarget alpha*-*-*] } {
5177 return 1
5178 } elseif { ([istarget sparc*-*-*]
5179 && [check_effective_target_lp64]
5180 && [check_effective_target_ultrasparc_hw]) } {
5181 return 1
5182 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
5183 return 1
5184 } else {
5185 return 0
5189 # Return 1 if the target supports byte swap instructions.
5191 proc check_effective_target_bswap { } {
5192 global et_bswap_saved
5194 if [info exists et_bswap_saved] {
5195 verbose "check_effective_target_bswap: using cached result" 2
5196 } else {
5197 set et_bswap_saved 0
5198 if { [istarget aarch64*-*-*]
5199 || [istarget alpha*-*-*]
5200 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5201 || [istarget m68k-*-*]
5202 || [istarget powerpc*-*-*]
5203 || [istarget rs6000-*-*]
5204 || [istarget s390*-*-*] } {
5205 set et_bswap_saved 1
5206 } else {
5207 if { [istarget arm*-*-*]
5208 && [check_no_compiler_messages_nocache arm_v6_or_later object {
5209 #if __ARM_ARCH < 6
5210 #error not armv6 or later
5211 #endif
5212 int i;
5213 } ""] } {
5214 set et_bswap_saved 1
5219 verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
5220 return $et_bswap_saved
5223 # Return 1 if the target supports 16-bit byte swap instructions.
5225 proc check_effective_target_bswap16 { } {
5226 global et_bswap16_saved
5228 if [info exists et_bswap16_saved] {
5229 verbose "check_effective_target_bswap16: using cached result" 2
5230 } else {
5231 set et_bswap16_saved 0
5232 if { [is-effective-target bswap]
5233 && ![istarget alpha*-*-*]
5234 && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
5235 set et_bswap16_saved 1
5239 verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
5240 return $et_bswap16_saved
5243 # Return 1 if the target supports 32-bit byte swap instructions.
5245 proc check_effective_target_bswap32 { } {
5246 global et_bswap32_saved
5248 if [info exists et_bswap32_saved] {
5249 verbose "check_effective_target_bswap32: using cached result" 2
5250 } else {
5251 set et_bswap32_saved 0
5252 if { [is-effective-target bswap] } {
5253 set et_bswap32_saved 1
5257 verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
5258 return $et_bswap32_saved
5261 # Return 1 if the target supports 64-bit byte swap instructions.
5263 proc check_effective_target_bswap64 { } {
5264 global et_bswap64_saved
5266 # expand_unop can expand 64-bit byte swap on 32-bit targets
5267 if { [is-effective-target bswap] && [is-effective-target int32plus] } {
5268 return 1
5270 return 0
5273 # Return 1 if the target supports atomic operations on "int" and "long".
5275 proc check_effective_target_sync_int_long { } {
5276 global et_sync_int_long_saved
5278 if [info exists et_sync_int_long_saved] {
5279 verbose "check_effective_target_sync_int_long: using cached result" 2
5280 } else {
5281 set et_sync_int_long_saved 0
5282 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5283 # load-reserved/store-conditional instructions.
5284 if { [istarget ia64-*-*]
5285 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5286 || [istarget aarch64*-*-*]
5287 || [istarget alpha*-*-*]
5288 || [istarget arm*-*-linux-*]
5289 || [istarget bfin*-*linux*]
5290 || [istarget hppa*-*linux*]
5291 || [istarget s390*-*-*]
5292 || [istarget powerpc*-*-*]
5293 || [istarget crisv32-*-*] || [istarget cris-*-*]
5294 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5295 || [check_effective_target_mips_llsc] } {
5296 set et_sync_int_long_saved 1
5300 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
5301 return $et_sync_int_long_saved
5304 # Return 1 if the target supports atomic operations on "char" and "short".
5306 proc check_effective_target_sync_char_short { } {
5307 global et_sync_char_short_saved
5309 if [info exists et_sync_char_short_saved] {
5310 verbose "check_effective_target_sync_char_short: using cached result" 2
5311 } else {
5312 set et_sync_char_short_saved 0
5313 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5314 # load-reserved/store-conditional instructions.
5315 if { [istarget aarch64*-*-*]
5316 || [istarget ia64-*-*]
5317 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5318 || [istarget alpha*-*-*]
5319 || [istarget arm*-*-linux-*]
5320 || [istarget hppa*-*linux*]
5321 || [istarget s390*-*-*]
5322 || [istarget powerpc*-*-*]
5323 || [istarget crisv32-*-*] || [istarget cris-*-*]
5324 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5325 || [check_effective_target_mips_llsc] } {
5326 set et_sync_char_short_saved 1
5330 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
5331 return $et_sync_char_short_saved
5334 # Return 1 if the target uses a ColdFire FPU.
5336 proc check_effective_target_coldfire_fpu { } {
5337 return [check_no_compiler_messages coldfire_fpu assembly {
5338 #ifndef __mcffpu__
5339 #error !__mcffpu__
5340 #endif
5344 # Return true if this is a uClibc target.
5346 proc check_effective_target_uclibc {} {
5347 return [check_no_compiler_messages uclibc object {
5348 #include <features.h>
5349 #if !defined (__UCLIBC__)
5350 #error !__UCLIBC__
5351 #endif
5355 # Return true if this is a uclibc target and if the uclibc feature
5356 # described by __$feature__ is not present.
5358 proc check_missing_uclibc_feature {feature} {
5359 return [check_no_compiler_messages $feature object "
5360 #include <features.h>
5361 #if !defined (__UCLIBC) || defined (__${feature}__)
5362 #error FOO
5363 #endif
5367 # Return true if this is a Newlib target.
5369 proc check_effective_target_newlib {} {
5370 return [check_no_compiler_messages newlib object {
5371 #include <newlib.h>
5375 # Return true if this is NOT a Bionic target.
5377 proc check_effective_target_non_bionic {} {
5378 return [check_no_compiler_messages non_bionic object {
5379 #include <ctype.h>
5380 #if defined (__BIONIC__)
5381 #error FOO
5382 #endif
5386 # Return true if this target has error.h header.
5388 proc check_effective_target_error_h {} {
5389 return [check_no_compiler_messages error_h object {
5390 #include <error.h>
5394 # Return true if this target has tgmath.h header.
5396 proc check_effective_target_tgmath_h {} {
5397 return [check_no_compiler_messages tgmath_h object {
5398 #include <tgmath.h>
5402 # Return true if target's libc supports complex functions.
5404 proc check_effective_target_libc_has_complex_functions {} {
5405 return [check_no_compiler_messages libc_has_complex_functions object {
5406 #include <complex.h>
5410 # Return 1 if
5411 # (a) an error of a few ULP is expected in string to floating-point
5412 # conversion functions; and
5413 # (b) overflow is not always detected correctly by those functions.
5415 proc check_effective_target_lax_strtofp {} {
5416 # By default, assume that all uClibc targets suffer from this.
5417 return [check_effective_target_uclibc]
5420 # Return 1 if this is a target for which wcsftime is a dummy
5421 # function that always returns 0.
5423 proc check_effective_target_dummy_wcsftime {} {
5424 # By default, assume that all uClibc targets suffer from this.
5425 return [check_effective_target_uclibc]
5428 # Return 1 if constructors with initialization priority arguments are
5429 # supposed on this target.
5431 proc check_effective_target_init_priority {} {
5432 return [check_no_compiler_messages init_priority assembly "
5433 void f() __attribute__((constructor (1000)));
5434 void f() \{\}
5438 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
5439 # This can be used with any check_* proc that takes no argument and
5440 # returns only 1 or 0. It could be used with check_* procs that take
5441 # arguments with keywords that pass particular arguments.
5443 proc is-effective-target { arg } {
5444 set selected 0
5445 if { [info procs check_effective_target_${arg}] != [list] } {
5446 set selected [check_effective_target_${arg}]
5447 } else {
5448 switch $arg {
5449 "vmx_hw" { set selected [check_vmx_hw_available] }
5450 "vsx_hw" { set selected [check_vsx_hw_available] }
5451 "p8vector_hw" { set selected [check_p8vector_hw_available] }
5452 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
5453 "dfp_hw" { set selected [check_dfp_hw_available] }
5454 "htm_hw" { set selected [check_htm_hw_available] }
5455 "named_sections" { set selected [check_named_sections_available] }
5456 "gc_sections" { set selected [check_gc_sections_available] }
5457 "cxa_atexit" { set selected [check_cxa_atexit_available] }
5458 default { error "unknown effective target keyword `$arg'" }
5461 verbose "is-effective-target: $arg $selected" 2
5462 return $selected
5465 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
5467 proc is-effective-target-keyword { arg } {
5468 if { [info procs check_effective_target_${arg}] != [list] } {
5469 return 1
5470 } else {
5471 # These have different names for their check_* procs.
5472 switch $arg {
5473 "vmx_hw" { return 1 }
5474 "vsx_hw" { return 1 }
5475 "p8vector_hw" { return 1 }
5476 "ppc_recip_hw" { return 1 }
5477 "dfp_hw" { return 1 }
5478 "htm_hw" { return 1 }
5479 "named_sections" { return 1 }
5480 "gc_sections" { return 1 }
5481 "cxa_atexit" { return 1 }
5482 default { return 0 }
5487 # Return 1 if target default to short enums
5489 proc check_effective_target_short_enums { } {
5490 return [check_no_compiler_messages short_enums assembly {
5491 enum foo { bar };
5492 int s[sizeof (enum foo) == 1 ? 1 : -1];
5496 # Return 1 if target supports merging string constants at link time.
5498 proc check_effective_target_string_merging { } {
5499 return [check_no_messages_and_pattern string_merging \
5500 "rodata\\.str" assembly {
5501 const char *var = "String";
5502 } {-O2}]
5505 # Return 1 if target has the basic signed and unsigned types in
5506 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
5507 # working <stdint.h> for all targets.
5509 proc check_effective_target_stdint_types { } {
5510 return [check_no_compiler_messages stdint_types assembly {
5511 #include <stdint.h>
5512 int8_t a; int16_t b; int32_t c; int64_t d;
5513 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5517 # Return 1 if target has the basic signed and unsigned types in
5518 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
5519 # these types agree with those in the header, as some systems have
5520 # only <inttypes.h>.
5522 proc check_effective_target_inttypes_types { } {
5523 return [check_no_compiler_messages inttypes_types assembly {
5524 #include <inttypes.h>
5525 int8_t a; int16_t b; int32_t c; int64_t d;
5526 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5530 # Return 1 if programs are intended to be run on a simulator
5531 # (i.e. slowly) rather than hardware (i.e. fast).
5533 proc check_effective_target_simulator { } {
5535 # All "src/sim" simulators set this one.
5536 if [board_info target exists is_simulator] {
5537 return [board_info target is_simulator]
5540 # The "sid" simulators don't set that one, but at least they set
5541 # this one.
5542 if [board_info target exists slow_simulator] {
5543 return [board_info target slow_simulator]
5546 return 0
5549 # Return 1 if programs are intended to be run on hardware rather than
5550 # on a simulator
5552 proc check_effective_target_hw { } {
5554 # All "src/sim" simulators set this one.
5555 if [board_info target exists is_simulator] {
5556 if [board_info target is_simulator] {
5557 return 0
5558 } else {
5559 return 1
5563 # The "sid" simulators don't set that one, but at least they set
5564 # this one.
5565 if [board_info target exists slow_simulator] {
5566 if [board_info target slow_simulator] {
5567 return 0
5568 } else {
5569 return 1
5573 return 1
5576 # Return 1 if the target is a VxWorks kernel.
5578 proc check_effective_target_vxworks_kernel { } {
5579 return [check_no_compiler_messages vxworks_kernel assembly {
5580 #if !defined __vxworks || defined __RTP__
5581 #error NO
5582 #endif
5586 # Return 1 if the target is a VxWorks RTP.
5588 proc check_effective_target_vxworks_rtp { } {
5589 return [check_no_compiler_messages vxworks_rtp assembly {
5590 #if !defined __vxworks || !defined __RTP__
5591 #error NO
5592 #endif
5596 # Return 1 if the target is expected to provide wide character support.
5598 proc check_effective_target_wchar { } {
5599 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
5600 return 0
5602 return [check_no_compiler_messages wchar assembly {
5603 #include <wchar.h>
5607 # Return 1 if the target has <pthread.h>.
5609 proc check_effective_target_pthread_h { } {
5610 return [check_no_compiler_messages pthread_h assembly {
5611 #include <pthread.h>
5615 # Return 1 if the target can truncate a file from a file-descriptor,
5616 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
5617 # chsize. We test for a trivially functional truncation; no stubs.
5618 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
5619 # different function to be used.
5621 proc check_effective_target_fd_truncate { } {
5622 set prog {
5623 #define _FILE_OFFSET_BITS 64
5624 #include <unistd.h>
5625 #include <stdio.h>
5626 #include <stdlib.h>
5627 #include <string.h>
5628 int main ()
5630 FILE *f = fopen ("tst.tmp", "wb");
5631 int fd;
5632 const char t[] = "test writing more than ten characters";
5633 char s[11];
5634 int status = 0;
5635 fd = fileno (f);
5636 write (fd, t, sizeof (t) - 1);
5637 lseek (fd, 0, 0);
5638 if (ftruncate (fd, 10) != 0)
5639 status = 1;
5640 close (fd);
5641 fclose (f);
5642 if (status)
5644 unlink ("tst.tmp");
5645 exit (status);
5647 f = fopen ("tst.tmp", "rb");
5648 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
5649 status = 1;
5650 fclose (f);
5651 unlink ("tst.tmp");
5652 exit (status);
5656 if { [check_runtime ftruncate $prog] } {
5657 return 1;
5660 regsub "ftruncate" $prog "chsize" prog
5661 return [check_runtime chsize $prog]
5664 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
5666 proc add_options_for_c99_runtime { flags } {
5667 if { [istarget *-*-solaris2*] } {
5668 return "$flags -std=c99"
5670 if { [istarget powerpc-*-darwin*] } {
5671 return "$flags -mmacosx-version-min=10.3"
5673 return $flags
5676 # Add to FLAGS all the target-specific flags needed to enable
5677 # full IEEE compliance mode.
5679 proc add_options_for_ieee { flags } {
5680 if { [istarget alpha*-*-*]
5681 || [istarget sh*-*-*] } {
5682 return "$flags -mieee"
5684 if { [istarget rx-*-*] } {
5685 return "$flags -mnofpu"
5687 return $flags
5690 if {![info exists flags_to_postpone]} {
5691 set flags_to_postpone ""
5694 # Add to FLAGS the flags needed to enable functions to bind locally
5695 # when using pic/PIC passes in the testsuite.
5696 proc add_options_for_bind_pic_locally { flags } {
5697 global flags_to_postpone
5699 # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
5700 # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
5701 # order to make sure that the multilib_flags doesn't override this.
5703 if {[check_no_compiler_messages using_pic2 assembly {
5704 #if __PIC__ != 2
5705 #error __PIC__ != 2
5706 #endif
5707 }]} {
5708 set flags_to_postpone "-fPIE"
5709 return $flags
5711 if {[check_no_compiler_messages using_pic1 assembly {
5712 #if __PIC__ != 1
5713 #error __PIC__ != 1
5714 #endif
5715 }]} {
5716 set flags_to_postpone "-fpie"
5717 return $flags
5719 return $flags
5722 # Add to FLAGS the flags needed to enable 64-bit vectors.
5724 proc add_options_for_double_vectors { flags } {
5725 if [is-effective-target arm_neon_ok] {
5726 return "$flags -mvectorize-with-neon-double"
5729 return $flags
5732 # Return 1 if the target provides a full C99 runtime.
5734 proc check_effective_target_c99_runtime { } {
5735 return [check_cached_effective_target c99_runtime {
5736 global srcdir
5738 set file [open "$srcdir/gcc.dg/builtins-config.h"]
5739 set contents [read $file]
5740 close $file
5741 append contents {
5742 #ifndef HAVE_C99_RUNTIME
5743 #error !HAVE_C99_RUNTIME
5744 #endif
5746 check_no_compiler_messages_nocache c99_runtime assembly \
5747 $contents [add_options_for_c99_runtime ""]
5751 # Return 1 if target wchar_t is at least 4 bytes.
5753 proc check_effective_target_4byte_wchar_t { } {
5754 return [check_no_compiler_messages 4byte_wchar_t object {
5755 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
5759 # Return 1 if the target supports automatic stack alignment.
5761 proc check_effective_target_automatic_stack_alignment { } {
5762 # Ordinarily x86 supports automatic stack alignment ...
5763 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
5764 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
5765 # ... except Win64 SEH doesn't. Succeed for Win32 though.
5766 return [check_effective_target_ilp32];
5768 return 1;
5770 return 0;
5773 # Return true if we are compiling for AVX target.
5775 proc check_avx_available { } {
5776 if { [check_no_compiler_messages avx_available assembly {
5777 #ifndef __AVX__
5778 #error unsupported
5779 #endif
5780 } ""] } {
5781 return 1;
5783 return 0;
5786 # Return true if 32- and 16-bytes vectors are available.
5788 proc check_effective_target_vect_sizes_32B_16B { } {
5789 if { [check_avx_available] && ![check_prefer_avx128] } {
5790 return 1;
5791 } else {
5792 return 0;
5796 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5797 # are available.
5799 proc check_prefer_avx128 { } {
5800 if ![check_avx_available] {
5801 return 0;
5803 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5804 float a[1024],b[1024],c[1024];
5805 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5806 } "-O2 -ftree-vectorize"]
5810 # Return 1 if avx512f instructions can be compiled.
5812 proc check_effective_target_avx512f { } {
5813 return [check_no_compiler_messages avx512f object {
5814 typedef double __m512d __attribute__ ((__vector_size__ (64)));
5816 __m512d _mm512_add (__m512d a)
5818 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
5820 } "-O2 -mavx512f" ]
5823 # Return 1 if avx instructions can be compiled.
5825 proc check_effective_target_avx { } {
5826 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
5827 return 0
5829 return [check_no_compiler_messages avx object {
5830 void _mm256_zeroall (void)
5832 __builtin_ia32_vzeroall ();
5834 } "-O2 -mavx" ]
5837 # Return 1 if avx2 instructions can be compiled.
5838 proc check_effective_target_avx2 { } {
5839 return [check_no_compiler_messages avx2 object {
5840 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
5841 __v4di
5842 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
5844 return __builtin_ia32_andnotsi256 (__X, __Y);
5846 } "-O0 -mavx2" ]
5849 # Return 1 if sse instructions can be compiled.
5850 proc check_effective_target_sse { } {
5851 return [check_no_compiler_messages sse object {
5852 int main ()
5854 __builtin_ia32_stmxcsr ();
5855 return 0;
5857 } "-O2 -msse" ]
5860 # Return 1 if sse2 instructions can be compiled.
5861 proc check_effective_target_sse2 { } {
5862 return [check_no_compiler_messages sse2 object {
5863 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5865 __m128i _mm_srli_si128 (__m128i __A, int __N)
5867 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5869 } "-O2 -msse2" ]
5872 # Return 1 if F16C instructions can be compiled.
5874 proc check_effective_target_f16c { } {
5875 return [check_no_compiler_messages f16c object {
5876 #include "immintrin.h"
5877 float
5878 foo (unsigned short val)
5880 return _cvtsh_ss (val);
5882 } "-O2 -mf16c" ]
5885 # Return 1 if C wchar_t type is compatible with char16_t.
5887 proc check_effective_target_wchar_t_char16_t_compatible { } {
5888 return [check_no_compiler_messages wchar_t_char16_t object {
5889 __WCHAR_TYPE__ wc;
5890 __CHAR16_TYPE__ *p16 = &wc;
5891 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5895 # Return 1 if C wchar_t type is compatible with char32_t.
5897 proc check_effective_target_wchar_t_char32_t_compatible { } {
5898 return [check_no_compiler_messages wchar_t_char32_t object {
5899 __WCHAR_TYPE__ wc;
5900 __CHAR32_TYPE__ *p32 = &wc;
5901 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5905 # Return 1 if pow10 function exists.
5907 proc check_effective_target_pow10 { } {
5908 return [check_runtime pow10 {
5909 #include <math.h>
5910 int main () {
5911 double x;
5912 x = pow10 (1);
5913 return 0;
5915 } "-lm" ]
5918 # Return 1 if current options generate DFP instructions, 0 otherwise.
5920 proc check_effective_target_hard_dfp {} {
5921 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5922 typedef float d64 __attribute__((mode(DD)));
5923 d64 x, y, z;
5924 void foo (void) { z = x + y; }
5928 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5929 # for strchr etc. functions.
5931 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5932 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5933 #include <string.h>
5934 #include <wchar.h>
5935 #if !defined(__cplusplus) \
5936 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5937 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5938 ISO C++ correct string.h and wchar.h protos not supported.
5939 #else
5940 int i;
5941 #endif
5945 # Return 1 if GNU as is used.
5947 proc check_effective_target_gas { } {
5948 global use_gas_saved
5949 global tool
5951 if {![info exists use_gas_saved]} {
5952 # Check if the as used by gcc is GNU as.
5953 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5954 # Provide /dev/null as input, otherwise gas times out reading from
5955 # stdin.
5956 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5957 set as_output [lindex $status 1]
5958 if { [ string first "GNU" $as_output ] >= 0 } {
5959 set use_gas_saved 1
5960 } else {
5961 set use_gas_saved 0
5964 return $use_gas_saved
5967 # Return 1 if GNU ld is used.
5969 proc check_effective_target_gld { } {
5970 global use_gld_saved
5971 global tool
5973 if {![info exists use_gld_saved]} {
5974 # Check if the ld used by gcc is GNU ld.
5975 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5976 set status [remote_exec host "$gcc_ld" "--version"]
5977 set ld_output [lindex $status 1]
5978 if { [ string first "GNU" $ld_output ] >= 0 } {
5979 set use_gld_saved 1
5980 } else {
5981 set use_gld_saved 0
5984 return $use_gld_saved
5987 # Return 1 if the compiler has been configure with link-time optimization
5988 # (LTO) support.
5990 proc check_effective_target_lto { } {
5991 if { [istarget nvptx-*-*] } {
5992 return 0;
5994 return [check_no_compiler_messages lto object {
5995 void foo (void) { }
5996 } "-flto"]
5999 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
6001 proc check_effective_target_maybe_x32 { } {
6002 return [check_no_compiler_messages maybe_x32 object {
6003 void foo (void) {}
6004 } "-mx32 -maddress-mode=short"]
6007 # Return 1 if this target supports the -fsplit-stack option, 0
6008 # otherwise.
6010 proc check_effective_target_split_stack {} {
6011 return [check_no_compiler_messages split_stack object {
6012 void foo (void) { }
6013 } "-fsplit-stack"]
6016 # Return 1 if this target supports the -masm=intel option, 0
6017 # otherwise
6019 proc check_effective_target_masm_intel {} {
6020 return [check_no_compiler_messages masm_intel object {
6021 extern void abort (void);
6022 } "-masm=intel"]
6025 # Return 1 if the language for the compiler under test is C.
6027 proc check_effective_target_c { } {
6028 global tool
6029 if [string match $tool "gcc"] {
6030 return 1
6032 return 0
6035 # Return 1 if the language for the compiler under test is C++.
6037 proc check_effective_target_c++ { } {
6038 global tool
6039 if [string match $tool "g++"] {
6040 return 1
6042 return 0
6045 set cxx_default "c++14"
6046 # Check whether the current active language standard supports the features
6047 # of C++11/C++14 by checking for the presence of one of the -std flags.
6048 # This assumes that the default for the compiler is $cxx_default, and that
6049 # there will never be multiple -std= arguments on the command line.
6050 proc check_effective_target_c++11_only { } {
6051 global cxx_default
6052 if ![check_effective_target_c++] {
6053 return 0
6055 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
6056 return 1
6058 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
6059 return 1
6061 return 0
6063 proc check_effective_target_c++11 { } {
6064 if [check_effective_target_c++11_only] {
6065 return 1
6067 return [check_effective_target_c++14]
6069 proc check_effective_target_c++11_down { } {
6070 if ![check_effective_target_c++] {
6071 return 0
6073 return [expr ![check_effective_target_c++14] ]
6076 proc check_effective_target_c++14_only { } {
6077 global cxx_default
6078 if ![check_effective_target_c++] {
6079 return 0
6081 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
6082 return 1
6084 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
6085 return 1
6087 return 0
6090 proc check_effective_target_c++14 { } {
6091 if [check_effective_target_c++14_only] {
6092 return 1
6094 return [check_effective_target_c++1z]
6096 proc check_effective_target_c++14_down { } {
6097 if ![check_effective_target_c++] {
6098 return 0
6100 return [expr ![check_effective_target_c++1z] ]
6103 proc check_effective_target_c++98_only { } {
6104 global cxx_default
6105 if ![check_effective_target_c++] {
6106 return 0
6108 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
6109 return 1
6111 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
6112 return 1
6114 return 0
6117 proc check_effective_target_c++1z_only { } {
6118 global cxx_default
6119 if ![check_effective_target_c++] {
6120 return 0
6122 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
6123 return 1
6125 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
6126 return 1
6128 return 0
6130 proc check_effective_target_c++1z { } {
6131 return [check_effective_target_c++1z_only]
6134 # Return 1 if expensive testcases should be run.
6136 proc check_effective_target_run_expensive_tests { } {
6137 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
6138 return 1
6140 return 0
6143 # Returns 1 if "mempcpy" is available on the target system.
6145 proc check_effective_target_mempcpy {} {
6146 return [check_function_available "mempcpy"]
6149 # Returns 1 if "stpcpy" is available on the target system.
6151 proc check_effective_target_stpcpy {} {
6152 return [check_function_available "stpcpy"]
6155 # Check whether the vectorizer tests are supported by the target and
6156 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
6157 # Set dg-do-what-default to either compile or run, depending on target
6158 # capabilities. Return 1 if vectorizer tests are supported by
6159 # target, 0 otherwise.
6161 proc check_vect_support_and_set_flags { } {
6162 global DEFAULT_VECTCFLAGS
6163 global dg-do-what-default
6165 if [istarget powerpc-*paired*] {
6166 lappend DEFAULT_VECTCFLAGS "-mpaired"
6167 if [check_750cl_hw_available] {
6168 set dg-do-what-default run
6169 } else {
6170 set dg-do-what-default compile
6172 } elseif [istarget powerpc*-*-*] {
6173 # Skip targets not supporting -maltivec.
6174 if ![is-effective-target powerpc_altivec_ok] {
6175 return 0
6178 lappend DEFAULT_VECTCFLAGS "-maltivec"
6179 if [check_p8vector_hw_available] {
6180 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
6181 } elseif [check_vsx_hw_available] {
6182 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
6185 if [check_vmx_hw_available] {
6186 set dg-do-what-default run
6187 } else {
6188 if [is-effective-target ilp32] {
6189 # Specify a cpu that supports VMX for compile-only tests.
6190 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
6192 set dg-do-what-default compile
6194 } elseif { [istarget spu-*-*] } {
6195 set dg-do-what-default run
6196 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
6197 lappend DEFAULT_VECTCFLAGS "-msse2"
6198 if { [check_effective_target_sse2_runtime] } {
6199 set dg-do-what-default run
6200 } else {
6201 set dg-do-what-default compile
6203 } elseif { [istarget mips*-*-*]
6204 && ([check_effective_target_mpaired_single]
6205 || [check_effective_target_mips_loongson])
6206 && [check_effective_target_nomips16] } {
6207 if { [check_effective_target_mpaired_single] } {
6208 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
6210 set dg-do-what-default run
6211 } elseif [istarget sparc*-*-*] {
6212 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
6213 if [check_effective_target_ultrasparc_hw] {
6214 set dg-do-what-default run
6215 } else {
6216 set dg-do-what-default compile
6218 } elseif [istarget alpha*-*-*] {
6219 # Alpha's vectorization capabilities are extremely limited.
6220 # It's more effort than its worth disabling all of the tests
6221 # that it cannot pass. But if you actually want to see what
6222 # does work, command out the return.
6223 return 0
6225 lappend DEFAULT_VECTCFLAGS "-mmax"
6226 if [check_alpha_max_hw_available] {
6227 set dg-do-what-default run
6228 } else {
6229 set dg-do-what-default compile
6231 } elseif [istarget ia64-*-*] {
6232 set dg-do-what-default run
6233 } elseif [is-effective-target arm_neon_ok] {
6234 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
6235 # NEON does not support denormals, so is not used for vectorization by
6236 # default to avoid loss of precision. We must pass -ffast-math to test
6237 # vectorization of float operations.
6238 lappend DEFAULT_VECTCFLAGS "-ffast-math"
6239 if [is-effective-target arm_neon_hw] {
6240 set dg-do-what-default run
6241 } else {
6242 set dg-do-what-default compile
6244 } elseif [istarget "aarch64*-*-*"] {
6245 set dg-do-what-default run
6246 } else {
6247 return 0
6250 return 1
6253 # Return 1 if the target does *not* require strict alignment.
6255 proc check_effective_target_non_strict_align {} {
6256 return [check_no_compiler_messages non_strict_align assembly {
6257 char *y;
6258 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
6259 c *z;
6260 void foo(void) { z = (c *) y; }
6261 } "-Wcast-align"]
6264 # Return 1 if the target has <ucontext.h>.
6266 proc check_effective_target_ucontext_h { } {
6267 return [check_no_compiler_messages ucontext_h assembly {
6268 #include <ucontext.h>
6272 proc check_effective_target_aarch64_tiny { } {
6273 if { [istarget aarch64*-*-*] } {
6274 return [check_no_compiler_messages aarch64_tiny object {
6275 #ifdef __AARCH64_CMODEL_TINY__
6276 int dummy;
6277 #else
6278 #error target not AArch64 tiny code model
6279 #endif
6281 } else {
6282 return 0
6286 proc check_effective_target_aarch64_small { } {
6287 if { [istarget aarch64*-*-*] } {
6288 return [check_no_compiler_messages aarch64_small object {
6289 #ifdef __AARCH64_CMODEL_SMALL__
6290 int dummy;
6291 #else
6292 #error target not AArch64 small code model
6293 #endif
6295 } else {
6296 return 0
6300 proc check_effective_target_aarch64_large { } {
6301 if { [istarget aarch64*-*-*] } {
6302 return [check_no_compiler_messages aarch64_large object {
6303 #ifdef __AARCH64_CMODEL_LARGE__
6304 int dummy;
6305 #else
6306 #error target not AArch64 large code model
6307 #endif
6309 } else {
6310 return 0
6314 # Return 1 if <fenv.h> is available with all the standard IEEE
6315 # exceptions and floating-point exceptions are raised by arithmetic
6316 # operations. (If the target requires special options for "inexact"
6317 # exceptions, those need to be specified in the testcases.)
6319 proc check_effective_target_fenv_exceptions {} {
6320 return [check_runtime fenv_exceptions {
6321 #include <fenv.h>
6322 #include <stdlib.h>
6323 #ifndef FE_DIVBYZERO
6324 # error Missing FE_DIVBYZERO
6325 #endif
6326 #ifndef FE_INEXACT
6327 # error Missing FE_INEXACT
6328 #endif
6329 #ifndef FE_INVALID
6330 # error Missing FE_INVALID
6331 #endif
6332 #ifndef FE_OVERFLOW
6333 # error Missing FE_OVERFLOW
6334 #endif
6335 #ifndef FE_UNDERFLOW
6336 # error Missing FE_UNDERFLOW
6337 #endif
6338 volatile float a = 0.0f, r;
6340 main (void)
6342 r = a / a;
6343 if (fetestexcept (FE_INVALID))
6344 exit (0);
6345 else
6346 abort ();
6348 } [add_options_for_ieee "-std=gnu99"]]
6351 proc check_effective_target_tiny {} {
6352 global et_target_tiny_saved
6354 if [info exists et_target_tine_saved] {
6355 verbose "check_effective_target_tiny: using cached result" 2
6356 } else {
6357 set et_target_tiny_saved 0
6358 if { [istarget aarch64*-*-*]
6359 && [check_effective_target_aarch64_tiny] } {
6360 set et_target_tiny_saved 1
6364 return $et_target_tiny_saved
6367 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
6369 proc check_effective_target_logical_op_short_circuit {} {
6370 if { [istarget mips*-*-*]
6371 || [istarget arc*-*-*]
6372 || [istarget avr*-*-*]
6373 || [istarget crisv32-*-*] || [istarget cris-*-*]
6374 || [istarget mmix-*-*]
6375 || [istarget s390*-*-*]
6376 || [istarget powerpc*-*-*]
6377 || [istarget nios2*-*-*]
6378 || [istarget visium-*-*]
6379 || [check_effective_target_arm_cortex_m] } {
6380 return 1
6382 return 0
6385 # Record that dg-final test TEST requires convential compilation.
6387 proc force_conventional_output_for { test } {
6388 if { [info proc $test] == "" } {
6389 perror "$test does not exist"
6390 exit 1
6392 proc ${test}_required_options {} {
6393 global gcc_force_conventional_output
6394 return $gcc_force_conventional_output
6398 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
6399 # otherwise. Cache the result.
6401 proc check_effective_target_pie_copyreloc { } {
6402 global pie_copyreloc_available_saved
6403 global tool
6404 global GCC_UNDER_TEST
6406 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6407 return 0
6410 # Need auto-host.h to check linker support.
6411 if { ![file exists ../../auto-host.h ] } {
6412 return 0
6415 if [info exists pie_copyreloc_available_saved] {
6416 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
6417 } else {
6418 # Set up and compile to see if linker supports PIE with copy
6419 # reloc. Include the current process ID in the file names to
6420 # prevent conflicts with invocations for multiple testsuites.
6422 set src pie[pid].c
6423 set obj pie[pid].o
6425 set f [open $src "w"]
6426 puts $f "#include \"../../auto-host.h\""
6427 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
6428 puts $f "# error Linker does not support PIE with copy reloc."
6429 puts $f "#endif"
6430 close $f
6432 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
6433 set lines [${tool}_target_compile $src $obj object ""]
6435 file delete $src
6436 file delete $obj
6438 if [string match "" $lines] then {
6439 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
6440 set pie_copyreloc_available_saved 1
6441 } else {
6442 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
6443 set pie_copyreloc_available_saved 0
6447 return $pie_copyreloc_available_saved
6450 # Return 1 if the target uses comdat groups.
6452 proc check_effective_target_comdat_group {} {
6453 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
6454 // C++
6455 inline int foo () { return 1; }
6456 int (*fn) () = foo;
6460 # Return 1 if target supports __builtin_eh_return
6461 proc check_effective_target_builtin_eh_return { } {
6462 return [check_no_compiler_messages builtin_eh_return object {
6463 void test (long l, void *p)
6465 __builtin_eh_return (l, p);
6467 } "" ]