sched: Do not mix prologue and epilogue insns
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blobb5a9faab5a47d01371c6402a5b07d34071dbc34b
1 # Copyright (C) 1999-2016 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 # nvptx (nearly) supports it
297 if { [istarget nvptx-*-*] } {
298 return 1
301 # ELF and ECOFF support it. a.out does with gas/gld but may also with
302 # other linkers, so we should try it
304 set objformat [gcc_target_object_format]
306 switch $objformat {
307 elf { return 1 }
308 ecoff { return 1 }
309 a.out { return 1 }
310 mach-o { return 1 }
311 som { return 1 }
312 unknown { return -1 }
313 default { return 0 }
317 ###############################
318 # proc check_weak_override_available { }
319 ###############################
321 # Like check_weak_available, but return 0 if weak symbol definitions
322 # cannot be overridden.
324 proc check_weak_override_available { } {
325 if { [istarget *-*-mingw*] } {
326 return 0
328 return [check_weak_available]
331 ###############################
332 # proc check_visibility_available { what_kind }
333 ###############################
335 # The visibility attribute is only support in some object formats
336 # This proc returns 1 if it is supported, 0 if not.
337 # The argument is the kind of visibility, default/protected/hidden/internal.
339 proc check_visibility_available { what_kind } {
340 if [string match "" $what_kind] { set what_kind "hidden" }
342 return [check_no_compiler_messages visibility_available_$what_kind object "
343 void f() __attribute__((visibility(\"$what_kind\")));
344 void f() {}
348 ###############################
349 # proc check_alias_available { }
350 ###############################
352 # Determine if the target toolchain supports the alias attribute.
354 # Returns 2 if the target supports aliases. Returns 1 if the target
355 # only supports weak aliased. Returns 0 if the target does not
356 # support aliases at all. Returns -1 if support for aliases could not
357 # be determined.
359 proc check_alias_available { } {
360 global alias_available_saved
361 global tool
363 if [info exists alias_available_saved] {
364 verbose "check_alias_available returning saved $alias_available_saved" 2
365 } else {
366 set src alias[pid].c
367 set obj alias[pid].o
368 verbose "check_alias_available compiling testfile $src" 2
369 set f [open $src "w"]
370 # Compile a small test program. The definition of "g" is
371 # necessary to keep the Solaris assembler from complaining
372 # about the program.
373 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
374 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
375 close $f
376 set lines [${tool}_target_compile $src $obj object ""]
377 file delete $src
378 remote_file build delete $obj
380 if [string match "" $lines] then {
381 # No error messages, everything is OK.
382 set alias_available_saved 2
383 } else {
384 if [regexp "alias definitions not supported" $lines] {
385 verbose "check_alias_available target does not support aliases" 2
387 set objformat [gcc_target_object_format]
389 if { $objformat == "elf" } {
390 verbose "check_alias_available but target uses ELF format, so it ought to" 2
391 set alias_available_saved -1
392 } else {
393 set alias_available_saved 0
395 } else {
396 if [regexp "only weak aliases are supported" $lines] {
397 verbose "check_alias_available target supports only weak aliases" 2
398 set alias_available_saved 1
399 } else {
400 set alias_available_saved -1
405 verbose "check_alias_available returning $alias_available_saved" 2
408 return $alias_available_saved
411 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
413 proc check_effective_target_alias { } {
414 if { [check_alias_available] < 2 } {
415 return 0
416 } else {
417 return 1
421 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
423 proc check_ifunc_available { } {
424 return [check_no_compiler_messages ifunc_available object {
425 #ifdef __cplusplus
426 extern "C"
427 #endif
428 void g() {}
429 void f() __attribute__((ifunc("g")));
433 # Returns true if --gc-sections is supported on the target.
435 proc check_gc_sections_available { } {
436 global gc_sections_available_saved
437 global tool
439 if {![info exists gc_sections_available_saved]} {
440 # Some targets don't support gc-sections despite whatever's
441 # advertised by ld's options.
442 if { [istarget alpha*-*-*]
443 || [istarget ia64-*-*] } {
444 set gc_sections_available_saved 0
445 return 0
448 # elf2flt uses -q (--emit-relocs), which is incompatible with
449 # --gc-sections.
450 if { [board_info target exists ldflags]
451 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
452 set gc_sections_available_saved 0
453 return 0
456 # VxWorks kernel modules are relocatable objects linked with -r,
457 # while RTP executables are linked with -q (--emit-relocs).
458 # Both of these options are incompatible with --gc-sections.
459 if { [istarget *-*-vxworks*] } {
460 set gc_sections_available_saved 0
461 return 0
464 # Check if the ld used by gcc supports --gc-sections.
465 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
466 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
467 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
468 set ld_output [remote_exec host "$gcc_ld" "--help"]
469 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
470 set gc_sections_available_saved 1
471 } else {
472 set gc_sections_available_saved 0
475 return $gc_sections_available_saved
478 # Return 1 if according to target_info struct and explicit target list
479 # target is supposed to support trampolines.
481 proc check_effective_target_trampolines { } {
482 if [target_info exists no_trampolines] {
483 return 0
485 if { [istarget avr-*-*]
486 || [istarget msp430-*-*]
487 || [istarget nvptx-*-*]
488 || [istarget hppa2.0w-hp-hpux11.23]
489 || [istarget hppa64-hp-hpux11.23] } {
490 return 0;
492 return 1
495 # Return 1 if according to target_info struct and explicit target list
496 # target disables -fdelete-null-pointer-checks. Targets should return 0
497 # if they simply default to -fno-delete-null-pointer-checks but obey
498 # -fdelete-null-pointer-checks when passed explicitly (and tests that
499 # depend on this option should do that).
501 proc check_effective_target_keeps_null_pointer_checks { } {
502 if [target_info exists keeps_null_pointer_checks] {
503 return 1
505 if { [istarget avr-*-*] } {
506 return 1;
508 return 0
511 # Return the autofdo profile wrapper
513 proc profopt-perf-wrapper { } {
514 global srcdir
515 return "$srcdir/../config/i386/gcc-auto-profile -o perf.data "
518 # Return true if profiling is supported on the target.
520 proc check_profiling_available { test_what } {
521 global profiling_available_saved
523 verbose "Profiling argument is <$test_what>" 1
525 # These conditions depend on the argument so examine them before
526 # looking at the cache variable.
528 # Tree profiling requires TLS runtime support.
529 if { $test_what == "-fprofile-generate" } {
530 if { ![check_effective_target_tls_runtime] } {
531 return 0
535 if { $test_what == "-fauto-profile" } {
536 if { ! ([istarget x86_64-*-linux*] || [istarget i?86-*-linux*]) } {
537 verbose "autofdo only supported on linux"
538 return 0
540 # not cross compiling?
541 if { ![isnative] } {
542 verbose "autofdo not supported for non native builds"
543 return 0
545 set event [profopt-perf-wrapper]
546 if {$event == "" } {
547 verbose "autofdo not supported"
548 return 0
550 global srcdir
551 set status [remote_exec host "$srcdir/../config/i386/gcc-auto-profile" "true -v >/dev/null"]
552 if { [lindex $status 0] != 0 } {
553 verbose "autofdo not supported because perf does not work"
554 return 0
557 # no good way to check this in advance -- check later instead.
558 #set status [remote_exec host "create_gcov" "2>/dev/null"]
559 #if { [lindex $status 0] != 255 } {
560 # verbose "autofdo not supported due to missing create_gcov"
561 # return 0
565 # Support for -p on solaris2 relies on mcrt1.o which comes with the
566 # vendor compiler. We cannot reliably predict the directory where the
567 # vendor compiler (and thus mcrt1.o) is installed so we can't
568 # necessarily find mcrt1.o even if we have it.
569 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
570 return 0
573 # We don't yet support profiling for MIPS16.
574 if { [istarget mips*-*-*]
575 && ![check_effective_target_nomips16]
576 && ($test_what == "-p" || $test_what == "-pg") } {
577 return 0
580 # MinGW does not support -p.
581 if { [istarget *-*-mingw*] && $test_what == "-p" } {
582 return 0
585 # cygwin does not support -p.
586 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
587 return 0
590 # uClibc does not have gcrt1.o.
591 if { [check_effective_target_uclibc]
592 && ($test_what == "-p" || $test_what == "-pg") } {
593 return 0
596 # Now examine the cache variable.
597 if {![info exists profiling_available_saved]} {
598 # Some targets don't have any implementation of __bb_init_func or are
599 # missing other needed machinery.
600 if {[istarget aarch64*-*-elf]
601 || [istarget am3*-*-linux*]
602 || [istarget arm*-*-eabi*]
603 || [istarget arm*-*-elf]
604 || [istarget arm*-*-symbianelf*]
605 || [istarget avr-*-*]
606 || [istarget bfin-*-*]
607 || [istarget cris-*-*]
608 || [istarget crisv32-*-*]
609 || [istarget fido-*-elf]
610 || [istarget h8300-*-*]
611 || [istarget lm32-*-*]
612 || [istarget m32c-*-elf]
613 || [istarget m68k-*-elf]
614 || [istarget m68k-*-uclinux*]
615 || [istarget mips*-*-elf*]
616 || [istarget mmix-*-*]
617 || [istarget mn10300-*-elf*]
618 || [istarget moxie-*-elf*]
619 || [istarget msp430-*-*]
620 || [istarget nds32*-*-elf]
621 || [istarget nios2-*-elf]
622 || [istarget nvptx-*-*]
623 || [istarget powerpc-*-eabi*]
624 || [istarget powerpc-*-elf]
625 || [istarget rx-*-*]
626 || [istarget tic6x-*-elf]
627 || [istarget visium-*-*]
628 || [istarget xstormy16-*]
629 || [istarget xtensa*-*-elf]
630 || [istarget *-*-rtems*]
631 || [istarget *-*-vxworks*] } {
632 set profiling_available_saved 0
633 } else {
634 set profiling_available_saved 1
638 # -pg link test result can't be cached since it may change between
639 # runs.
640 set profiling_working $profiling_available_saved
641 if { $profiling_available_saved == 1
642 && ![check_no_compiler_messages_nocache profiling executable {
643 int main() { return 0; } } "-pg"] } {
644 set profiling_working 0
647 return $profiling_working
650 # Check to see if a target is "freestanding". This is as per the definition
651 # in Section 4 of C99 standard. Effectively, it is a target which supports no
652 # extra headers or libraries other than what is considered essential.
653 proc check_effective_target_freestanding { } {
654 if { [istarget nvptx-*-*] } {
655 return 1
657 return 0
660 # Return 1 if target has packed layout of structure members by
661 # default, 0 otherwise. Note that this is slightly different than
662 # whether the target has "natural alignment": both attributes may be
663 # false.
665 proc check_effective_target_default_packed { } {
666 return [check_no_compiler_messages default_packed assembly {
667 struct x { char a; long b; } c;
668 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
672 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
673 # documentation, where the test also comes from.
675 proc check_effective_target_pcc_bitfield_type_matters { } {
676 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
677 # bitfields, but let's stick to the example code from the docs.
678 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
679 struct foo1 { char x; char :0; char y; };
680 struct foo2 { char x; int :0; char y; };
681 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
685 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
687 proc add_options_for_tls { flags } {
688 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
689 # libthread, so always pass -pthread for native TLS. Same for AIX.
690 # Need to duplicate native TLS check from
691 # check_effective_target_tls_native to avoid recursion.
692 if { ([istarget powerpc-ibm-aix*]) &&
693 [check_no_messages_and_pattern tls_native "!emutls" assembly {
694 __thread int i;
695 int f (void) { return i; }
696 void g (int j) { i = j; }
697 }] } {
698 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
700 return $flags
703 # Return 1 if indirect jumps are supported, 0 otherwise.
705 proc check_effective_target_indirect_jumps {} {
706 if { [istarget nvptx-*-*] } {
707 return 0
709 return 1
712 # Return 1 if nonlocal goto is supported, 0 otherwise.
714 proc check_effective_target_nonlocal_goto {} {
715 if { [istarget nvptx-*-*] } {
716 return 0
718 return 1
721 # Return 1 if global constructors are supported, 0 otherwise.
723 proc check_effective_target_global_constructor {} {
724 if { [istarget nvptx-*-*] } {
725 return 0
727 return 1
730 # Return 1 if taking label values is supported, 0 otherwise.
732 proc check_effective_target_label_values {} {
733 if { [istarget nvptx-*-*] } {
734 return 0
736 return [check_no_compiler_messages label_values assembly {
737 #ifdef NO_LABEL_VALUES
738 #error NO
739 #endif
743 # Return 1 if builtin_return_address and builtin_frame_address are
744 # supported, 0 otherwise.
746 proc check_effective_target_return_address {} {
747 if { [istarget nvptx-*-*] } {
748 return 0
750 return 1
753 # Return 1 if the assembler does not verify function types against
754 # calls, 0 otherwise. Such verification will typically show up problems
755 # with K&R C function declarations.
757 proc check_effective_target_untyped_assembly {} {
758 if { [istarget nvptx-*-*] } {
759 return 0
761 return 1
764 # Return 1 if alloca is supported, 0 otherwise.
766 proc check_effective_target_alloca {} {
767 if { [istarget nvptx-*-*] } {
768 return 0
770 return 1
773 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
775 proc check_effective_target_tls {} {
776 return [check_no_compiler_messages tls assembly {
777 __thread int i;
778 int f (void) { return i; }
779 void g (int j) { i = j; }
783 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
785 proc check_effective_target_tls_native {} {
786 # VxWorks uses emulated TLS machinery, but with non-standard helper
787 # functions, so we fail to automatically detect it.
788 if { [istarget *-*-vxworks*] } {
789 return 0
792 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
793 __thread int i;
794 int f (void) { return i; }
795 void g (int j) { i = j; }
799 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
801 proc check_effective_target_tls_emulated {} {
802 # VxWorks uses emulated TLS machinery, but with non-standard helper
803 # functions, so we fail to automatically detect it.
804 if { [istarget *-*-vxworks*] } {
805 return 1
808 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
809 __thread int i;
810 int f (void) { return i; }
811 void g (int j) { i = j; }
815 # Return 1 if TLS executables can run correctly, 0 otherwise.
817 proc check_effective_target_tls_runtime {} {
818 # The runtime does not have TLS support, but just
819 # running the test below is insufficient to show this.
820 if { [istarget msp430-*-*] || [istarget visium-*-*] } {
821 return 0
823 return [check_runtime tls_runtime {
824 __thread int thr = 0;
825 int main (void) { return thr; }
826 } [add_options_for_tls ""]]
829 # Return 1 if atomic compare-and-swap is supported on 'int'
831 proc check_effective_target_cas_char {} {
832 return [check_no_compiler_messages cas_char assembly {
833 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
834 #error unsupported
835 #endif
836 } ""]
839 proc check_effective_target_cas_int {} {
840 return [check_no_compiler_messages cas_int assembly {
841 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
842 /* ok */
843 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
844 /* ok */
845 #else
846 #error unsupported
847 #endif
848 } ""]
851 # Return 1 if -ffunction-sections is supported, 0 otherwise.
853 proc check_effective_target_function_sections {} {
854 # Darwin has its own scheme and silently accepts -ffunction-sections.
855 if { [istarget *-*-darwin*] } {
856 return 0
859 return [check_no_compiler_messages functionsections assembly {
860 void foo (void) { }
861 } "-ffunction-sections"]
864 # Return 1 if instruction scheduling is available, 0 otherwise.
866 proc check_effective_target_scheduling {} {
867 return [check_no_compiler_messages scheduling object {
868 void foo (void) { }
869 } "-fschedule-insns"]
872 # Return 1 if trapping arithmetic is available, 0 otherwise.
874 proc check_effective_target_trapping {} {
875 return [check_no_compiler_messages trapping object {
876 int add (int a, int b) { return a + b; }
877 } "-ftrapv"]
880 # Return 1 if compilation with -fgraphite is error-free for trivial
881 # code, 0 otherwise.
883 proc check_effective_target_fgraphite {} {
884 return [check_no_compiler_messages fgraphite object {
885 void foo (void) { }
886 } "-O1 -fgraphite"]
889 # Return 1 if compilation with -fopenacc is error-free for trivial
890 # code, 0 otherwise.
892 proc check_effective_target_fopenacc {} {
893 # nvptx can be built with the device-side bits of openacc, but it
894 # does not make sense to test it as an openacc host.
895 if [istarget nvptx-*-*] { return 0 }
897 return [check_no_compiler_messages fopenacc object {
898 void foo (void) { }
899 } "-fopenacc"]
902 # Return 1 if compilation with -fopenmp is error-free for trivial
903 # code, 0 otherwise.
905 proc check_effective_target_fopenmp {} {
906 # nvptx can be built with the device-side bits of libgomp, but it
907 # does not make sense to test it as an openmp host.
908 if [istarget nvptx-*-*] { return 0 }
910 return [check_no_compiler_messages fopenmp object {
911 void foo (void) { }
912 } "-fopenmp"]
915 # Return 1 if compilation with -fgnu-tm is error-free for trivial
916 # code, 0 otherwise.
918 proc check_effective_target_fgnu_tm {} {
919 return [check_no_compiler_messages fgnu_tm object {
920 void foo (void) { }
921 } "-fgnu-tm"]
924 # Return 1 if the target supports mmap, 0 otherwise.
926 proc check_effective_target_mmap {} {
927 return [check_function_available "mmap"]
930 # Return 1 if the target supports dlopen, 0 otherwise.
931 proc check_effective_target_dlopen {} {
932 return [check_no_compiler_messages dlopen executable {
933 #include <dlfcn.h>
934 int main(void) { dlopen ("dummy.so", RTLD_NOW); }
935 } [add_options_for_dlopen ""]]
938 proc add_options_for_dlopen { flags } {
939 return "$flags -ldl"
942 # Return 1 if the target supports clone, 0 otherwise.
943 proc check_effective_target_clone {} {
944 return [check_function_available "clone"]
947 # Return 1 if the target supports setrlimit, 0 otherwise.
948 proc check_effective_target_setrlimit {} {
949 # Darwin has non-posix compliant RLIMIT_AS
950 if { [istarget *-*-darwin*] } {
951 return 0
953 return [check_function_available "setrlimit"]
956 # Return 1 if the target supports swapcontext, 0 otherwise.
957 proc check_effective_target_swapcontext {} {
958 return [check_no_compiler_messages swapcontext executable {
959 #include <ucontext.h>
960 int main (void)
962 ucontext_t orig_context,child_context;
963 if (swapcontext(&child_context, &orig_context) < 0) { }
968 # Return 1 if compilation with -pthread is error-free for trivial
969 # code, 0 otherwise.
971 proc check_effective_target_pthread {} {
972 return [check_no_compiler_messages pthread object {
973 void foo (void) { }
974 } "-pthread"]
977 # Return 1 if compilation with -gstabs is error-free for trivial
978 # code, 0 otherwise.
980 proc check_effective_target_stabs {} {
981 return [check_no_compiler_messages stabs object {
982 void foo (void) { }
983 } "-gstabs"]
986 # Return 1 if compilation with -mpe-aligned-commons is error-free
987 # for trivial code, 0 otherwise.
989 proc check_effective_target_pe_aligned_commons {} {
990 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
991 return [check_no_compiler_messages pe_aligned_commons object {
992 int foo;
993 } "-mpe-aligned-commons"]
995 return 0
998 # Return 1 if the target supports -static
999 proc check_effective_target_static {} {
1000 return [check_no_compiler_messages static executable {
1001 int main (void) { return 0; }
1002 } "-static"]
1005 # Return 1 if the target supports -fstack-protector
1006 proc check_effective_target_fstack_protector {} {
1007 return [check_runtime fstack_protector {
1008 int main (void) { return 0; }
1009 } "-fstack-protector"]
1012 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
1013 # for trivial code, 0 otherwise.
1015 proc check_effective_target_freorder {} {
1016 return [check_no_compiler_messages freorder object {
1017 void foo (void) { }
1018 } "-freorder-blocks-and-partition"]
1021 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
1022 # emitted, 0 otherwise. Whether a shared library can actually be built is
1023 # out of scope for this test.
1025 proc check_effective_target_fpic { } {
1026 # Note that M68K has a multilib that supports -fpic but not
1027 # -fPIC, so we need to check both. We test with a program that
1028 # requires GOT references.
1029 foreach arg {fpic fPIC} {
1030 if [check_no_compiler_messages $arg object {
1031 extern int foo (void); extern int bar;
1032 int baz (void) { return foo () + bar; }
1033 } "-$arg"] {
1034 return 1
1037 return 0
1040 # On AArch64, if -fpic is not supported, then we will fall back to -fPIC
1041 # silently. So, we can't rely on above "check_effective_target_fpic" as it
1042 # assumes compiler will give warning if -fpic not supported. Here we check
1043 # whether binutils supports those new -fpic relocation modifiers, and assume
1044 # -fpic is supported if there is binutils support. GCC configuration will
1045 # enable -fpic for AArch64 in this case.
1047 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
1048 # memory model -fpic relocation types.
1050 proc check_effective_target_aarch64_small_fpic { } {
1051 if { [istarget aarch64*-*-*] } {
1052 return [check_no_compiler_messages aarch64_small_fpic object {
1053 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
1055 } else {
1056 return 0
1060 # On AArch64, instruction sequence for TLS LE under -mtls-size=32 will utilize
1061 # the relocation modifier "tprel_g0_nc" together with MOVK, it's only supported
1062 # in binutils since 2015-03-04 as PR gas/17843.
1064 # This test directive make sure binutils support all features needed by TLS LE
1065 # under -mtls-size=32 on AArch64.
1067 proc check_effective_target_aarch64_tlsle32 { } {
1068 if { [istarget aarch64*-*-*] } {
1069 return [check_no_compiler_messages aarch64_tlsle32 object {
1070 void foo (void) { asm ("movk x1,#:tprel_g0_nc:t1"); }
1072 } else {
1073 return 0
1077 # Return 1 if -shared is supported, as in no warnings or errors
1078 # emitted, 0 otherwise.
1080 proc check_effective_target_shared { } {
1081 # Note that M68K has a multilib that supports -fpic but not
1082 # -fPIC, so we need to check both. We test with a program that
1083 # requires GOT references.
1084 return [check_no_compiler_messages shared executable {
1085 extern int foo (void); extern int bar;
1086 int baz (void) { return foo () + bar; }
1087 } "-shared -fpic"]
1090 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
1092 proc check_effective_target_pie { } {
1093 if { [istarget *-*-darwin\[912\]*]
1094 || [istarget *-*-dragonfly*]
1095 || [istarget *-*-freebsd*]
1096 || [istarget *-*-linux*]
1097 || [istarget *-*-gnu*] } {
1098 return 1;
1100 if { [istarget *-*-solaris2.1\[1-9\]*] } {
1101 # Full PIE support was added in Solaris 11.x and Solaris 12, but gcc
1102 # errors out if missing, so check for that.
1103 return [check_no_compiler_messages pie executable {
1104 int main (void) { return 0; }
1105 } "-pie -fpie"]
1107 return 0
1110 # Return true if the target supports -mpaired-single (as used on MIPS).
1112 proc check_effective_target_mpaired_single { } {
1113 return [check_no_compiler_messages mpaired_single object {
1114 void foo (void) { }
1115 } "-mpaired-single"]
1118 # Return true if the target has access to FPU instructions.
1120 proc check_effective_target_hard_float { } {
1121 if { [istarget mips*-*-*] } {
1122 return [check_no_compiler_messages hard_float assembly {
1123 #if (defined __mips_soft_float || defined __mips16)
1124 #error __mips_soft_float || __mips16
1125 #endif
1129 # This proc is actually checking the availabilty of FPU
1130 # support for doubles, so on the RX we must fail if the
1131 # 64-bit double multilib has been selected.
1132 if { [istarget rx-*-*] } {
1133 return 0
1134 # return [check_no_compiler_messages hard_float assembly {
1135 #if defined __RX_64_BIT_DOUBLES__
1136 #error __RX_64_BIT_DOUBLES__
1137 #endif
1138 # }]
1141 # The generic test equates hard_float with "no call for adding doubles".
1142 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1143 double a (double b, double c) { return b + c; }
1147 # Return true if the target is a 64-bit MIPS target.
1149 proc check_effective_target_mips64 { } {
1150 return [check_no_compiler_messages mips64 assembly {
1151 #ifndef __mips64
1152 #error !__mips64
1153 #endif
1157 # Return true if the target is a MIPS target that does not produce
1158 # MIPS16 code.
1160 proc check_effective_target_nomips16 { } {
1161 return [check_no_compiler_messages nomips16 object {
1162 #ifndef __mips
1163 #error !__mips
1164 #else
1165 /* A cheap way of testing for -mflip-mips16. */
1166 void foo (void) { asm ("addiu $20,$20,1"); }
1167 void bar (void) { asm ("addiu $20,$20,1"); }
1168 #endif
1172 # Add the options needed for MIPS16 function attributes. At the moment,
1173 # we don't support MIPS16 PIC.
1175 proc add_options_for_mips16_attribute { flags } {
1176 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1179 # Return true if we can force a mode that allows MIPS16 code generation.
1180 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
1181 # for o32 and o64.
1183 proc check_effective_target_mips16_attribute { } {
1184 return [check_no_compiler_messages mips16_attribute assembly {
1185 #ifdef PIC
1186 #error PIC
1187 #endif
1188 #if defined __mips_hard_float \
1189 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1190 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1191 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1192 #endif
1193 } [add_options_for_mips16_attribute ""]]
1196 # Return 1 if the target supports long double larger than double when
1197 # using the new ABI, 0 otherwise.
1199 proc check_effective_target_mips_newabi_large_long_double { } {
1200 return [check_no_compiler_messages mips_newabi_large_long_double object {
1201 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1202 } "-mabi=64"]
1205 # Return true if the target is a MIPS target that has access
1206 # to the LL and SC instructions.
1208 proc check_effective_target_mips_llsc { } {
1209 if { ![istarget mips*-*-*] } {
1210 return 0
1212 # Assume that these instructions are always implemented for
1213 # non-elf* targets, via emulation if necessary.
1214 if { ![istarget *-*-elf*] } {
1215 return 1
1217 # Otherwise assume LL/SC support for everything but MIPS I.
1218 return [check_no_compiler_messages mips_llsc assembly {
1219 #if __mips == 1
1220 #error __mips == 1
1221 #endif
1225 # Return true if the target is a MIPS target that uses in-place relocations.
1227 proc check_effective_target_mips_rel { } {
1228 if { ![istarget mips*-*-*] } {
1229 return 0
1231 return [check_no_compiler_messages mips_rel object {
1232 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1233 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1234 #error _ABIN32 && (_ABIN32 || _ABI64)
1235 #endif
1239 # Return true if the target is a MIPS target that uses the EABI.
1241 proc check_effective_target_mips_eabi { } {
1242 if { ![istarget mips*-*-*] } {
1243 return 0
1245 return [check_no_compiler_messages mips_eabi object {
1246 #ifndef __mips_eabi
1247 #error !__mips_eabi
1248 #endif
1252 # Return 1 if the current multilib does not generate PIC by default.
1254 proc check_effective_target_nonpic { } {
1255 return [check_no_compiler_messages nonpic assembly {
1256 #if __PIC__
1257 #error __PIC__
1258 #endif
1262 # Return 1 if the current multilib generates PIE by default.
1264 proc check_effective_target_pie_enabled { } {
1265 return [check_no_compiler_messages pie_enabled assembly {
1266 #ifndef __PIE__
1267 #error unsupported
1268 #endif
1272 # Return 1 if the target generates -fstack-protector by default.
1274 proc check_effective_target_fstack_protector_enabled {} {
1275 return [ check_no_compiler_messages fstack_protector_enabled assembly {
1276 #if !defined(__SSP__) && !defined(__SSP_ALL__) && \
1277 !defined(__SSP_STRONG__) && !defined(__SSP_EXPICIT__)
1278 #error unsupported
1279 #endif
1283 # Return 1 if the target does not use a status wrapper.
1285 proc check_effective_target_unwrapped { } {
1286 if { [target_info needs_status_wrapper] != "" \
1287 && [target_info needs_status_wrapper] != "0" } {
1288 return 0
1290 return 1
1293 # Return true if iconv is supported on the target. In particular IBM1047.
1295 proc check_iconv_available { test_what } {
1296 global libiconv
1298 # If the tool configuration file has not set libiconv, try "-liconv"
1299 if { ![info exists libiconv] } {
1300 set libiconv "-liconv"
1302 set test_what [lindex $test_what 1]
1303 return [check_runtime_nocache $test_what [subst {
1304 #include <iconv.h>
1305 int main (void)
1307 iconv_t cd;
1309 cd = iconv_open ("$test_what", "UTF-8");
1310 if (cd == (iconv_t) -1)
1311 return 1;
1312 return 0;
1314 }] $libiconv]
1317 # Return true if Cilk Library is supported on the target.
1318 proc check_effective_target_cilkplus_runtime { } {
1319 return [ check_no_compiler_messages_nocache cilkplus_runtime executable {
1320 #ifdef __cplusplus
1321 extern "C"
1322 #endif
1323 int __cilkrts_set_param (const char *, const char *);
1324 int main (void) {
1325 int x = __cilkrts_set_param ("nworkers", "0");
1326 return x;
1328 } "-fcilkplus -lcilkrts" ]
1331 # Return true if the atomic library is supported on the target.
1332 proc check_effective_target_libatomic_available { } {
1333 return [check_no_compiler_messages libatomic_available executable {
1334 int main (void) { return 0; }
1335 } "-latomic"]
1338 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1340 proc check_ascii_locale_available { } {
1341 return 1
1344 # Return true if named sections are supported on this target.
1346 proc check_named_sections_available { } {
1347 return [check_no_compiler_messages named_sections assembly {
1348 int __attribute__ ((section("whatever"))) foo;
1352 # Return true if the "naked" function attribute is supported on this target.
1354 proc check_effective_target_naked_functions { } {
1355 return [check_no_compiler_messages naked_functions assembly {
1356 void f() __attribute__((naked));
1360 # Return 1 if the target supports Fortran real kinds larger than real(8),
1361 # 0 otherwise.
1363 # When the target name changes, replace the cached result.
1365 proc check_effective_target_fortran_large_real { } {
1366 return [check_no_compiler_messages fortran_large_real executable {
1367 ! Fortran
1368 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1369 real(kind=k) :: x
1370 x = cos (x)
1375 # Return 1 if the target supports Fortran real kind real(16),
1376 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1377 # this checks for Real(16) only; the other returned real(10) if
1378 # both real(10) and real(16) are available.
1380 # When the target name changes, replace the cached result.
1382 proc check_effective_target_fortran_real_16 { } {
1383 return [check_no_compiler_messages fortran_real_16 executable {
1384 ! Fortran
1385 real(kind=16) :: x
1386 x = cos (x)
1392 # Return 1 if the target supports Fortran's IEEE modules,
1393 # 0 otherwise.
1395 # When the target name changes, replace the cached result.
1397 proc check_effective_target_fortran_ieee { flags } {
1398 return [check_no_compiler_messages fortran_ieee executable {
1399 ! Fortran
1400 use, intrinsic :: ieee_features
1402 } $flags ]
1406 # Return 1 if the target supports SQRT for the largest floating-point
1407 # type. (Some targets lack the libm support for this FP type.)
1408 # On most targets, this check effectively checks either whether sqrtl is
1409 # available or on __float128 systems whether libquadmath is installed,
1410 # which provides sqrtq.
1412 # When the target name changes, replace the cached result.
1414 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1415 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1416 ! Fortran
1417 use iso_fortran_env, only: real_kinds
1418 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1419 real(kind=maxFP), volatile :: x
1420 x = 2.0_maxFP
1421 x = sqrt (x)
1427 # Return 1 if the target supports Fortran integer kinds larger than
1428 # integer(8), 0 otherwise.
1430 # When the target name changes, replace the cached result.
1432 proc check_effective_target_fortran_large_int { } {
1433 return [check_no_compiler_messages fortran_large_int executable {
1434 ! Fortran
1435 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1436 integer(kind=k) :: i
1441 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1443 # When the target name changes, replace the cached result.
1445 proc check_effective_target_fortran_integer_16 { } {
1446 return [check_no_compiler_messages fortran_integer_16 executable {
1447 ! Fortran
1448 integer(16) :: i
1453 # Return 1 if we can statically link libgfortran, 0 otherwise.
1455 # When the target name changes, replace the cached result.
1457 proc check_effective_target_static_libgfortran { } {
1458 return [check_no_compiler_messages static_libgfortran executable {
1459 ! Fortran
1460 print *, 'test'
1462 } "-static"]
1465 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1467 proc check_effective_target_cilkplus { } {
1468 # Skip cilk-plus tests on int16 and size16 targets for now.
1469 # The cilk-plus tests are not generic enough to cover these
1470 # cases and would throw hundreds of FAILs.
1471 if { [check_effective_target_int16]
1472 || ![check_effective_target_size32plus] } {
1473 return 0;
1476 # Skip AVR, its RAM is too small and too many tests would fail.
1477 if { [istarget avr-*-*] } {
1478 return 0;
1481 if { ! [check_effective_target_pthread] } {
1482 return 0;
1485 return 1
1488 proc check_linker_plugin_available { } {
1489 return [check_no_compiler_messages_nocache linker_plugin executable {
1490 int main() { return 0; }
1491 } "-flto -fuse-linker-plugin"]
1494 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1495 # otherwise. Cache the result.
1497 proc check_750cl_hw_available { } {
1498 return [check_cached_effective_target 750cl_hw_available {
1499 # If this is not the right target then we can skip the test.
1500 if { ![istarget powerpc-*paired*] } {
1501 expr 0
1502 } else {
1503 check_runtime_nocache 750cl_hw_available {
1504 int main()
1506 #ifdef __MACH__
1507 asm volatile ("ps_mul v0,v0,v0");
1508 #else
1509 asm volatile ("ps_mul 0,0,0");
1510 #endif
1511 return 0;
1513 } "-mpaired"
1518 # Return 1 if the target OS supports running SSE executables, 0
1519 # otherwise. Cache the result.
1521 proc check_sse_os_support_available { } {
1522 return [check_cached_effective_target sse_os_support_available {
1523 # If this is not the right target then we can skip the test.
1524 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1525 expr 0
1526 } elseif { [istarget i?86-*-solaris2*] } {
1527 # The Solaris 2 kernel doesn't save and restore SSE registers
1528 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1529 check_runtime_nocache sse_os_support_available {
1530 int main ()
1532 asm volatile ("movaps %xmm0,%xmm0");
1533 return 0;
1535 } "-msse"
1536 } else {
1537 expr 1
1542 # Return 1 if the target OS supports running AVX executables, 0
1543 # otherwise. Cache the result.
1545 proc check_avx_os_support_available { } {
1546 return [check_cached_effective_target avx_os_support_available {
1547 # If this is not the right target then we can skip the test.
1548 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1549 expr 0
1550 } else {
1551 # Check that OS has AVX and SSE saving enabled.
1552 check_runtime_nocache avx_os_support_available {
1553 int main ()
1555 unsigned int eax, edx;
1557 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1558 return (eax & 6) != 6;
1560 } ""
1565 # Return 1 if the target supports executing SSE instructions, 0
1566 # otherwise. Cache the result.
1568 proc check_sse_hw_available { } {
1569 return [check_cached_effective_target sse_hw_available {
1570 # If this is not the right target then we can skip the test.
1571 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1572 expr 0
1573 } else {
1574 check_runtime_nocache sse_hw_available {
1575 #include "cpuid.h"
1576 int main ()
1578 unsigned int eax, ebx, ecx, edx;
1579 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1580 return !(edx & bit_SSE);
1581 return 1;
1583 } ""
1588 # Return 1 if the target supports executing MIPS Paired-Single instructions,
1589 # 0 otherwise. Cache the result.
1591 proc check_mpaired_single_hw_available { } {
1592 return [check_cached_effective_target mpaired_single_hw_available {
1593 # If this is not the right target then we can skip the test.
1594 if { !([istarget mips*-*-*]) } {
1595 expr 0
1596 } else {
1597 check_runtime_nocache mpaired_single_hw_available {
1598 int main()
1600 asm volatile ("pll.ps $f2,$f4,$f6");
1601 return 0;
1603 } ""
1608 # Return 1 if the target supports executing Loongson vector instructions,
1609 # 0 otherwise. Cache the result.
1611 proc check_mips_loongson_hw_available { } {
1612 return [check_cached_effective_target mips_loongson_hw_available {
1613 # If this is not the right target then we can skip the test.
1614 if { !([istarget mips*-*-*]) } {
1615 expr 0
1616 } else {
1617 check_runtime_nocache mips_loongson_hw_available {
1618 #include <loongson.h>
1619 int main()
1621 asm volatile ("paddw $f2,$f4,$f6");
1622 return 0;
1624 } ""
1629 # Return 1 if the target supports executing MIPS MSA instructions, 0
1630 # otherwise. Cache the result.
1632 proc check_mips_msa_hw_available { } {
1633 return [check_cached_effective_target mips_msa_hw_available {
1634 # If this is not the right target then we can skip the test.
1635 if { !([istarget mips*-*-*]) } {
1636 expr 0
1637 } else {
1638 check_runtime_nocache mips_msa_hw_available {
1639 #if !defined(__mips_msa)
1640 #error "MSA NOT AVAIL"
1641 #else
1642 #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
1643 #error "MSA NOT AVAIL FOR ISA REV < 2"
1644 #endif
1645 #if !defined(__mips_hard_float)
1646 #error "MSA HARD_FLOAT REQUIRED"
1647 #endif
1648 #if __mips_fpr != 64
1649 #error "MSA 64-bit FPR REQUIRED"
1650 #endif
1651 #include <msa.h>
1653 int main()
1655 v8i16 v = __builtin_msa_ldi_h (0);
1656 v[0] = 0;
1657 return v[0];
1659 #endif
1660 } "-mmsa"
1665 # Return 1 if the target supports executing SSE2 instructions, 0
1666 # otherwise. Cache the result.
1668 proc check_sse2_hw_available { } {
1669 return [check_cached_effective_target sse2_hw_available {
1670 # If this is not the right target then we can skip the test.
1671 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1672 expr 0
1673 } else {
1674 check_runtime_nocache sse2_hw_available {
1675 #include "cpuid.h"
1676 int main ()
1678 unsigned int eax, ebx, ecx, edx;
1679 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1680 return !(edx & bit_SSE2);
1681 return 1;
1683 } ""
1688 # Return 1 if the target supports executing SSE4 instructions, 0
1689 # otherwise. Cache the result.
1691 proc check_sse4_hw_available { } {
1692 return [check_cached_effective_target sse4_hw_available {
1693 # If this is not the right target then we can skip the test.
1694 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1695 expr 0
1696 } else {
1697 check_runtime_nocache sse4_hw_available {
1698 #include "cpuid.h"
1699 int main ()
1701 unsigned int eax, ebx, ecx, edx;
1702 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1703 return !(ecx & bit_SSE4_2);
1704 return 1;
1706 } ""
1711 # Return 1 if the target supports executing AVX instructions, 0
1712 # otherwise. Cache the result.
1714 proc check_avx_hw_available { } {
1715 return [check_cached_effective_target avx_hw_available {
1716 # If this is not the right target then we can skip the test.
1717 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1718 expr 0
1719 } else {
1720 check_runtime_nocache avx_hw_available {
1721 #include "cpuid.h"
1722 int main ()
1724 unsigned int eax, ebx, ecx, edx;
1725 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1726 return ((ecx & (bit_AVX | bit_OSXSAVE))
1727 != (bit_AVX | bit_OSXSAVE));
1728 return 1;
1730 } ""
1735 # Return 1 if the target supports running SSE executables, 0 otherwise.
1737 proc check_effective_target_sse_runtime { } {
1738 if { [check_effective_target_sse]
1739 && [check_sse_hw_available]
1740 && [check_sse_os_support_available] } {
1741 return 1
1743 return 0
1746 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1748 proc check_effective_target_sse2_runtime { } {
1749 if { [check_effective_target_sse2]
1750 && [check_sse2_hw_available]
1751 && [check_sse_os_support_available] } {
1752 return 1
1754 return 0
1757 # Return 1 if the target supports running SSE4 executables, 0 otherwise.
1759 proc check_effective_target_sse4_runtime { } {
1760 if { [check_effective_target_sse4]
1761 && [check_sse4_hw_available]
1762 && [check_sse_os_support_available] } {
1763 return 1
1765 return 0
1768 # Return 1 if the target supports running MIPS Paired-Single
1769 # executables, 0 otherwise.
1771 proc check_effective_target_mpaired_single_runtime { } {
1772 if { [check_effective_target_mpaired_single]
1773 && [check_mpaired_single_hw_available] } {
1774 return 1
1776 return 0
1779 # Return 1 if the target supports running Loongson executables, 0 otherwise.
1781 proc check_effective_target_mips_loongson_runtime { } {
1782 if { [check_effective_target_mips_loongson]
1783 && [check_mips_loongson_hw_available] } {
1784 return 1
1786 return 0
1789 # Return 1 if the target supports running MIPS MSA executables, 0 otherwise.
1791 proc check_effective_target_mips_msa_runtime { } {
1792 if { [check_effective_target_mips_msa]
1793 && [check_mips_msa_hw_available] } {
1794 return 1
1796 return 0
1799 # Return 1 if the target supports running AVX executables, 0 otherwise.
1801 proc check_effective_target_avx_runtime { } {
1802 if { [check_effective_target_avx]
1803 && [check_avx_hw_available]
1804 && [check_avx_os_support_available] } {
1805 return 1
1807 return 0
1810 # Return 1 if we are compiling for 64-bit PowerPC but we do not use direct
1811 # move instructions for moves from GPR to FPR.
1813 proc check_effective_target_powerpc64_no_dm { } {
1814 # The "mulld" checks if we are generating PowerPC64 code. The "lfd"
1815 # checks if we do not use direct moves, but use the old-fashioned
1816 # slower move-via-the-stack.
1817 return [check_no_messages_and_pattern powerpc64_no_dm \
1818 {\mmulld\M.*\mlfd} assembly {
1819 double f(long long x) { return x*x; }
1820 } {-O2}]
1823 # Return 1 if the target supports executing power8 vector instructions, 0
1824 # otherwise. Cache the result.
1826 proc check_p8vector_hw_available { } {
1827 return [check_cached_effective_target p8vector_hw_available {
1828 # Some simulators are known to not support VSX/power8 instructions.
1829 # For now, disable on Darwin
1830 if { [istarget powerpc-*-eabi]
1831 || [istarget powerpc*-*-eabispe]
1832 || [istarget *-*-darwin*]} {
1833 expr 0
1834 } else {
1835 set options "-mpower8-vector"
1836 check_runtime_nocache p8vector_hw_available {
1837 int main()
1839 #ifdef __MACH__
1840 asm volatile ("xxlorc vs0,vs0,vs0");
1841 #else
1842 asm volatile ("xxlorc 0,0,0");
1843 #endif
1844 return 0;
1846 } $options
1851 # Return 1 if the target supports executing power9 vector instructions, 0
1852 # otherwise. Cache the result.
1854 proc check_p9vector_hw_available { } {
1855 return [check_cached_effective_target p9vector_hw_available {
1856 # Some simulators are known to not support VSX/power8/power9
1857 # instructions. For now, disable on Darwin.
1858 if { [istarget powerpc-*-eabi]
1859 || [istarget powerpc*-*-eabispe]
1860 || [istarget *-*-darwin*]} {
1861 expr 0
1862 } else {
1863 set options "-mpower9-vector"
1864 check_runtime_nocache p9vector_hw_available {
1865 int main()
1867 long e = -1;
1868 vector double v = (vector double) { 0.0, 0.0 };
1869 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
1870 return e;
1872 } $options
1877 # Return 1 if the target supports executing power9 modulo instructions, 0
1878 # otherwise. Cache the result.
1880 proc check_p9modulo_hw_available { } {
1881 return [check_cached_effective_target p9modulo_hw_available {
1882 # Some simulators are known to not support VSX/power8/power9
1883 # instructions. For now, disable on Darwin.
1884 if { [istarget powerpc-*-eabi]
1885 || [istarget powerpc*-*-eabispe]
1886 || [istarget *-*-darwin*]} {
1887 expr 0
1888 } else {
1889 set options "-mmodulo"
1890 check_runtime_nocache p9modulo_hw_available {
1891 int main()
1893 int i = 5, j = 3, r = -1;
1894 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
1895 return (r == 2);
1897 } $options
1902 # Return 1 if the target supports executing __float128 on PowerPC via software
1903 # emulation, 0 otherwise. Cache the result.
1905 proc check_ppc_float128_sw_available { } {
1906 return [check_cached_effective_target ppc_float128_sw_available {
1907 # Some simulators are known to not support VSX/power8/power9
1908 # instructions. For now, disable on Darwin.
1909 if { [istarget powerpc-*-eabi]
1910 || [istarget powerpc*-*-eabispe]
1911 || [istarget *-*-darwin*]} {
1912 expr 0
1913 } else {
1914 set options "-mfloat128 -mvsx"
1915 check_runtime_nocache ppc_float128_sw_available {
1916 volatile __float128 x = 1.0q;
1917 volatile __float128 y = 2.0q;
1918 int main()
1920 __float128 z = x + y;
1921 return (z != 3.0q);
1923 } $options
1928 # Return 1 if the target supports executing __float128 on PowerPC via power9
1929 # hardware instructions, 0 otherwise. Cache the result.
1931 proc check_ppc_float128_hw_available { } {
1932 return [check_cached_effective_target ppc_float128_hw_available {
1933 # Some simulators are known to not support VSX/power8/power9
1934 # instructions. For now, disable on Darwin.
1935 if { [istarget powerpc-*-eabi]
1936 || [istarget powerpc*-*-eabispe]
1937 || [istarget *-*-darwin*]} {
1938 expr 0
1939 } else {
1940 set options "-mfloat128 -mvsx -mfloat128-hardware -mpower9-vector"
1941 check_runtime_nocache ppc_float128_hw_available {
1942 volatile __float128 x = 1.0q;
1943 volatile __float128 y = 2.0q;
1944 int main()
1946 __float128 z = x + y;
1947 __float128 w = -1.0q;
1949 __asm__ ("xsaddqp %0,%1,%2" : "+v" (w) : "v" (x), "v" (y));
1950 return ((z != 3.0q) || (z != w);
1952 } $options
1957 # Return 1 if the target supports executing VSX instructions, 0
1958 # otherwise. Cache the result.
1960 proc check_vsx_hw_available { } {
1961 return [check_cached_effective_target vsx_hw_available {
1962 # Some simulators are known to not support VSX instructions.
1963 # For now, disable on Darwin
1964 if { [istarget powerpc-*-eabi]
1965 || [istarget powerpc*-*-eabispe]
1966 || [istarget *-*-darwin*]} {
1967 expr 0
1968 } else {
1969 set options "-mvsx"
1970 check_runtime_nocache vsx_hw_available {
1971 int main()
1973 #ifdef __MACH__
1974 asm volatile ("xxlor vs0,vs0,vs0");
1975 #else
1976 asm volatile ("xxlor 0,0,0");
1977 #endif
1978 return 0;
1980 } $options
1985 # Return 1 if the target supports executing AltiVec instructions, 0
1986 # otherwise. Cache the result.
1988 proc check_vmx_hw_available { } {
1989 return [check_cached_effective_target vmx_hw_available {
1990 # Some simulators are known to not support VMX instructions.
1991 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1992 expr 0
1993 } else {
1994 # Most targets don't require special flags for this test case, but
1995 # Darwin does. Just to be sure, make sure VSX is not enabled for
1996 # the altivec tests.
1997 if { [istarget *-*-darwin*]
1998 || [istarget *-*-aix*] } {
1999 set options "-maltivec -mno-vsx"
2000 } else {
2001 set options "-mno-vsx"
2003 check_runtime_nocache vmx_hw_available {
2004 int main()
2006 #ifdef __MACH__
2007 asm volatile ("vor v0,v0,v0");
2008 #else
2009 asm volatile ("vor 0,0,0");
2010 #endif
2011 return 0;
2013 } $options
2018 proc check_ppc_recip_hw_available { } {
2019 return [check_cached_effective_target ppc_recip_hw_available {
2020 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
2021 # For now, disable on Darwin
2022 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2023 expr 0
2024 } else {
2025 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
2026 check_runtime_nocache ppc_recip_hw_available {
2027 volatile double d_recip, d_rsqrt, d_four = 4.0;
2028 volatile float f_recip, f_rsqrt, f_four = 4.0f;
2029 int main()
2031 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
2032 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
2033 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
2034 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
2035 return 0;
2037 } $options
2042 # Return 1 if the target supports executing AltiVec and Cell PPU
2043 # instructions, 0 otherwise. Cache the result.
2045 proc check_effective_target_cell_hw { } {
2046 return [check_cached_effective_target cell_hw_available {
2047 # Some simulators are known to not support VMX and PPU instructions.
2048 if { [istarget powerpc-*-eabi*] } {
2049 expr 0
2050 } else {
2051 # Most targets don't require special flags for this test
2052 # case, but Darwin and AIX do.
2053 if { [istarget *-*-darwin*]
2054 || [istarget *-*-aix*] } {
2055 set options "-maltivec -mcpu=cell"
2056 } else {
2057 set options "-mcpu=cell"
2059 check_runtime_nocache cell_hw_available {
2060 int main()
2062 #ifdef __MACH__
2063 asm volatile ("vor v0,v0,v0");
2064 asm volatile ("lvlx v0,r0,r0");
2065 #else
2066 asm volatile ("vor 0,0,0");
2067 asm volatile ("lvlx 0,0,0");
2068 #endif
2069 return 0;
2071 } $options
2076 # Return 1 if the target supports executing 64-bit instructions, 0
2077 # otherwise. Cache the result.
2079 proc check_effective_target_powerpc64 { } {
2080 global powerpc64_available_saved
2081 global tool
2083 if [info exists powerpc64_available_saved] {
2084 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
2085 } else {
2086 set powerpc64_available_saved 0
2088 # Some simulators are known to not support powerpc64 instructions.
2089 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
2090 verbose "check_effective_target_powerpc64 returning 0" 2
2091 return $powerpc64_available_saved
2094 # Set up, compile, and execute a test program containing a 64-bit
2095 # instruction. Include the current process ID in the file
2096 # names to prevent conflicts with invocations for multiple
2097 # testsuites.
2098 set src ppc[pid].c
2099 set exe ppc[pid].x
2101 set f [open $src "w"]
2102 puts $f "int main() {"
2103 puts $f "#ifdef __MACH__"
2104 puts $f " asm volatile (\"extsw r0,r0\");"
2105 puts $f "#else"
2106 puts $f " asm volatile (\"extsw 0,0\");"
2107 puts $f "#endif"
2108 puts $f " return 0; }"
2109 close $f
2111 set opts "additional_flags=-mcpu=G5"
2113 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
2114 set lines [${tool}_target_compile $src $exe executable "$opts"]
2115 file delete $src
2117 if [string match "" $lines] then {
2118 # No error message, compilation succeeded.
2119 set result [${tool}_load "./$exe" "" ""]
2120 set status [lindex $result 0]
2121 remote_file build delete $exe
2122 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
2124 if { $status == "pass" } then {
2125 set powerpc64_available_saved 1
2127 } else {
2128 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
2132 return $powerpc64_available_saved
2135 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
2136 # complex float arguments. This affects gfortran tests that call cabsf
2137 # in libm built by an earlier compiler. Return 1 if libm uses the same
2138 # argument passing as the compiler under test, 0 otherwise.
2140 # When the target name changes, replace the cached result.
2142 proc check_effective_target_broken_cplxf_arg { } {
2143 return [check_cached_effective_target broken_cplxf_arg {
2144 # Skip the work for targets known not to be affected.
2145 if { ![istarget powerpc64-*-linux*] } {
2146 expr 0
2147 } elseif { ![is-effective-target lp64] } {
2148 expr 0
2149 } else {
2150 check_runtime_nocache broken_cplxf_arg {
2151 #include <complex.h>
2152 extern void abort (void);
2153 float fabsf (float);
2154 float cabsf (_Complex float);
2155 int main ()
2157 _Complex float cf;
2158 float f;
2159 cf = 3 + 4.0fi;
2160 f = cabsf (cf);
2161 if (fabsf (f - 5.0) > 0.0001)
2162 abort ();
2163 return 0;
2165 } "-lm"
2170 # Return 1 is this is a TI C6X target supporting C67X instructions
2171 proc check_effective_target_ti_c67x { } {
2172 return [check_no_compiler_messages ti_c67x assembly {
2173 #if !defined(_TMS320C6700)
2174 #error !_TMS320C6700
2175 #endif
2179 # Return 1 is this is a TI C6X target supporting C64X+ instructions
2180 proc check_effective_target_ti_c64xp { } {
2181 return [check_no_compiler_messages ti_c64xp assembly {
2182 #if !defined(_TMS320C6400_PLUS)
2183 #error !_TMS320C6400_PLUS
2184 #endif
2189 proc check_alpha_max_hw_available { } {
2190 return [check_runtime alpha_max_hw_available {
2191 int main() { return __builtin_alpha_amask(1<<8) != 0; }
2195 # Returns true iff the FUNCTION is available on the target system.
2196 # (This is essentially a Tcl implementation of Autoconf's
2197 # AC_CHECK_FUNC.)
2199 proc check_function_available { function } {
2200 return [check_no_compiler_messages ${function}_available \
2201 executable [subst {
2202 #ifdef __cplusplus
2203 extern "C"
2204 #endif
2205 char $function ();
2206 int main () { $function (); }
2207 }] "-fno-builtin" ]
2210 # Returns true iff "fork" is available on the target system.
2212 proc check_fork_available {} {
2213 return [check_function_available "fork"]
2216 # Returns true iff "mkfifo" is available on the target system.
2218 proc check_mkfifo_available {} {
2219 if { [istarget *-*-cygwin*] } {
2220 # Cygwin has mkfifo, but support is incomplete.
2221 return 0
2224 return [check_function_available "mkfifo"]
2227 # Returns true iff "__cxa_atexit" is used on the target system.
2229 proc check_cxa_atexit_available { } {
2230 return [check_cached_effective_target cxa_atexit_available {
2231 if { [istarget hppa*-*-hpux10*] } {
2232 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
2233 expr 0
2234 } elseif { [istarget *-*-vxworks] } {
2235 # vxworks doesn't have __cxa_atexit but subsequent test passes.
2236 expr 0
2237 } else {
2238 check_runtime_nocache cxa_atexit_available {
2239 // C++
2240 #include <stdlib.h>
2241 static unsigned int count;
2242 struct X
2244 X() { count = 1; }
2245 ~X()
2247 if (count != 3)
2248 exit(1);
2249 count = 4;
2252 void f()
2254 static X x;
2256 struct Y
2258 Y() { f(); count = 2; }
2259 ~Y()
2261 if (count != 2)
2262 exit(1);
2263 count = 3;
2266 Y y;
2267 int main() { return 0; }
2273 proc check_effective_target_objc2 { } {
2274 return [check_no_compiler_messages objc2 object {
2275 #ifdef __OBJC2__
2276 int dummy[1];
2277 #else
2278 #error !__OBJC2__
2279 #endif
2283 proc check_effective_target_next_runtime { } {
2284 return [check_no_compiler_messages objc2 object {
2285 #ifdef __NEXT_RUNTIME__
2286 int dummy[1];
2287 #else
2288 #error !__NEXT_RUNTIME__
2289 #endif
2293 # Return 1 if we're generating 32-bit code using default options, 0
2294 # otherwise.
2296 proc check_effective_target_ilp32 { } {
2297 return [check_no_compiler_messages ilp32 object {
2298 int dummy[sizeof (int) == 4
2299 && sizeof (void *) == 4
2300 && sizeof (long) == 4 ? 1 : -1];
2304 # Return 1 if we're generating ia32 code using default options, 0
2305 # otherwise.
2307 proc check_effective_target_ia32 { } {
2308 return [check_no_compiler_messages ia32 object {
2309 int dummy[sizeof (int) == 4
2310 && sizeof (void *) == 4
2311 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
2315 # Return 1 if we're generating x32 code using default options, 0
2316 # otherwise.
2318 proc check_effective_target_x32 { } {
2319 return [check_no_compiler_messages x32 object {
2320 int dummy[sizeof (int) == 4
2321 && sizeof (void *) == 4
2322 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
2326 # Return 1 if we're generating 32-bit integers using default
2327 # options, 0 otherwise.
2329 proc check_effective_target_int32 { } {
2330 return [check_no_compiler_messages int32 object {
2331 int dummy[sizeof (int) == 4 ? 1 : -1];
2335 # Return 1 if we're generating 32-bit or larger integers using default
2336 # options, 0 otherwise.
2338 proc check_effective_target_int32plus { } {
2339 return [check_no_compiler_messages int32plus object {
2340 int dummy[sizeof (int) >= 4 ? 1 : -1];
2344 # Return 1 if we're generating 32-bit or larger pointers using default
2345 # options, 0 otherwise.
2347 proc check_effective_target_ptr32plus { } {
2348 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
2349 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
2350 # cannot really hold a 32-bit address, so we always return false here.
2351 if { [istarget msp430-*-*] } {
2352 return 0
2355 return [check_no_compiler_messages ptr32plus object {
2356 int dummy[sizeof (void *) >= 4 ? 1 : -1];
2360 # Return 1 if we support 32-bit or larger array and structure sizes
2361 # using default options, 0 otherwise. Avoid false positive on
2362 # targets with 20 or 24 bit address spaces.
2364 proc check_effective_target_size32plus { } {
2365 return [check_no_compiler_messages size32plus object {
2366 char dummy[16777217L];
2370 # Returns 1 if we're generating 16-bit or smaller integers with the
2371 # default options, 0 otherwise.
2373 proc check_effective_target_int16 { } {
2374 return [check_no_compiler_messages int16 object {
2375 int dummy[sizeof (int) < 4 ? 1 : -1];
2379 # Return 1 if we're generating 64-bit code using default options, 0
2380 # otherwise.
2382 proc check_effective_target_lp64 { } {
2383 return [check_no_compiler_messages lp64 object {
2384 int dummy[sizeof (int) == 4
2385 && sizeof (void *) == 8
2386 && sizeof (long) == 8 ? 1 : -1];
2390 # Return 1 if we're generating 64-bit code using default llp64 options,
2391 # 0 otherwise.
2393 proc check_effective_target_llp64 { } {
2394 return [check_no_compiler_messages llp64 object {
2395 int dummy[sizeof (int) == 4
2396 && sizeof (void *) == 8
2397 && sizeof (long long) == 8
2398 && sizeof (long) == 4 ? 1 : -1];
2402 # Return 1 if long and int have different sizes,
2403 # 0 otherwise.
2405 proc check_effective_target_long_neq_int { } {
2406 return [check_no_compiler_messages long_ne_int object {
2407 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2411 # Return 1 if the target supports long double larger than double,
2412 # 0 otherwise.
2414 proc check_effective_target_large_long_double { } {
2415 return [check_no_compiler_messages large_long_double object {
2416 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2420 # Return 1 if the target supports double larger than float,
2421 # 0 otherwise.
2423 proc check_effective_target_large_double { } {
2424 return [check_no_compiler_messages large_double object {
2425 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2429 # Return 1 if the target supports long double of 128 bits,
2430 # 0 otherwise.
2432 proc check_effective_target_longdouble128 { } {
2433 return [check_no_compiler_messages longdouble128 object {
2434 int dummy[sizeof(long double) == 16 ? 1 : -1];
2438 # Return 1 if the target supports double of 64 bits,
2439 # 0 otherwise.
2441 proc check_effective_target_double64 { } {
2442 return [check_no_compiler_messages double64 object {
2443 int dummy[sizeof(double) == 8 ? 1 : -1];
2447 # Return 1 if the target supports double of at least 64 bits,
2448 # 0 otherwise.
2450 proc check_effective_target_double64plus { } {
2451 return [check_no_compiler_messages double64plus object {
2452 int dummy[sizeof(double) >= 8 ? 1 : -1];
2456 # Return 1 if the target supports 'w' suffix on floating constant
2457 # 0 otherwise.
2459 proc check_effective_target_has_w_floating_suffix { } {
2460 set opts ""
2461 if [check_effective_target_c++] {
2462 append opts "-std=gnu++03"
2464 return [check_no_compiler_messages w_fp_suffix object {
2465 float dummy = 1.0w;
2466 } "$opts"]
2469 # Return 1 if the target supports 'q' suffix on floating constant
2470 # 0 otherwise.
2472 proc check_effective_target_has_q_floating_suffix { } {
2473 set opts ""
2474 if [check_effective_target_c++] {
2475 append opts "-std=gnu++03"
2477 return [check_no_compiler_messages q_fp_suffix object {
2478 float dummy = 1.0q;
2479 } "$opts"]
2482 # Return 1 if the target supports the _FloatN / _FloatNx type
2483 # indicated in the function name, 0 otherwise.
2485 proc check_effective_target_float16 {} {
2486 return [check_no_compiler_messages_nocache float16 object {
2487 _Float16 x;
2491 proc check_effective_target_float32 {} {
2492 return [check_no_compiler_messages_nocache float32 object {
2493 _Float32 x;
2497 proc check_effective_target_float64 {} {
2498 return [check_no_compiler_messages_nocache float64 object {
2499 _Float64 x;
2503 proc check_effective_target_float128 {} {
2504 return [check_no_compiler_messages_nocache float128 object {
2505 _Float128 x;
2509 proc check_effective_target_float32x {} {
2510 return [check_no_compiler_messages_nocache float32x object {
2511 _Float32x x;
2515 proc check_effective_target_float64x {} {
2516 return [check_no_compiler_messages_nocache float64x object {
2517 _Float64x x;
2521 proc check_effective_target_float128x {} {
2522 return [check_no_compiler_messages_nocache float128x object {
2523 _Float128x x;
2527 # Likewise, but runtime support for any special options used as well
2528 # as compile-time support is required.
2530 proc check_effective_target_float16_runtime {} {
2531 return [check_effective_target_float16]
2534 proc check_effective_target_float32_runtime {} {
2535 return [check_effective_target_float32]
2538 proc check_effective_target_float64_runtime {} {
2539 return [check_effective_target_float64]
2542 proc check_effective_target_float128_runtime {} {
2543 if { ![check_effective_target_float128] } {
2544 return 0
2546 if { [istarget powerpc*-*-*] } {
2547 return [check_effective_target_base_quadfloat_support]
2549 return 1
2552 proc check_effective_target_float32x_runtime {} {
2553 return [check_effective_target_float32x]
2556 proc check_effective_target_float64x_runtime {} {
2557 if { ![check_effective_target_float64x] } {
2558 return 0
2560 if { [istarget powerpc*-*-*] } {
2561 return [check_effective_target_base_quadfloat_support]
2563 return 1
2566 proc check_effective_target_float128x_runtime {} {
2567 return [check_effective_target_float128x]
2570 # Return 1 if the target hardware supports any options added for
2571 # _FloatN and _FloatNx types, 0 otherwise.
2573 proc check_effective_target_floatn_nx_runtime {} {
2574 if { [istarget powerpc*-*-aix*] } {
2575 return 0
2577 if { [istarget powerpc*-*-*] } {
2578 return [check_effective_target_base_quadfloat_support]
2580 return 1
2583 # Add options needed to use the _FloatN / _FloatNx type indicated in
2584 # the function name.
2586 proc add_options_for_float16 { flags } {
2587 return "$flags"
2590 proc add_options_for_float32 { flags } {
2591 return "$flags"
2594 proc add_options_for_float64 { flags } {
2595 return "$flags"
2598 proc add_options_for_float128 { flags } {
2599 return [add_options_for___float128 "$flags"]
2602 proc add_options_for_float32x { flags } {
2603 return "$flags"
2606 proc add_options_for_float64x { flags } {
2607 return [add_options_for___float128 "$flags"]
2610 proc add_options_for_float128x { flags } {
2611 return "$flags"
2614 # Return 1 if the target supports __float128,
2615 # 0 otherwise.
2617 proc check_effective_target___float128 { } {
2618 if { [istarget powerpc*-*-*] } {
2619 return [check_ppc_float128_sw_available]
2621 if { [istarget ia64-*-*]
2622 || [istarget i?86-*-*]
2623 || [istarget x86_64-*-*] } {
2624 return 1
2626 return 0
2629 proc add_options_for___float128 { flags } {
2630 if { [istarget powerpc*-*-*] } {
2631 return "$flags -mfloat128 -mvsx"
2633 return "$flags"
2636 # Return 1 if the target supports any special run-time requirements
2637 # for __float128 or _Float128,
2638 # 0 otherwise.
2640 proc check_effective_target_base_quadfloat_support { } {
2641 if { [istarget powerpc*-*-*] } {
2642 return [check_vsx_hw_available]
2644 return 1
2647 # Return 1 if the target supports compiling fixed-point,
2648 # 0 otherwise.
2650 proc check_effective_target_fixed_point { } {
2651 return [check_no_compiler_messages fixed_point object {
2652 _Sat _Fract x; _Sat _Accum y;
2656 # Return 1 if the target supports compiling decimal floating point,
2657 # 0 otherwise.
2659 proc check_effective_target_dfp_nocache { } {
2660 verbose "check_effective_target_dfp_nocache: compiling source" 2
2661 set ret [check_no_compiler_messages_nocache dfp object {
2662 float x __attribute__((mode(DD)));
2664 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2665 return $ret
2668 proc check_effective_target_dfprt_nocache { } {
2669 return [check_runtime_nocache dfprt {
2670 typedef float d64 __attribute__((mode(DD)));
2671 d64 x = 1.2df, y = 2.3dd, z;
2672 int main () { z = x + y; return 0; }
2676 # Return 1 if the target supports compiling Decimal Floating Point,
2677 # 0 otherwise.
2679 # This won't change for different subtargets so cache the result.
2681 proc check_effective_target_dfp { } {
2682 return [check_cached_effective_target dfp {
2683 check_effective_target_dfp_nocache
2687 # Return 1 if the target supports linking and executing Decimal Floating
2688 # Point, 0 otherwise.
2690 # This won't change for different subtargets so cache the result.
2692 proc check_effective_target_dfprt { } {
2693 return [check_cached_effective_target dfprt {
2694 check_effective_target_dfprt_nocache
2698 # Return 1 if the target supports executing DFP hardware instructions,
2699 # 0 otherwise. Cache the result.
2701 proc check_dfp_hw_available { } {
2702 return [check_cached_effective_target dfp_hw_available {
2703 # For now, disable on Darwin
2704 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2705 expr 0
2706 } else {
2707 check_runtime_nocache dfp_hw_available {
2708 volatile _Decimal64 r;
2709 volatile _Decimal64 a = 4.0DD;
2710 volatile _Decimal64 b = 2.0DD;
2711 int main()
2713 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2714 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2715 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2716 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2717 return 0;
2719 } "-mcpu=power6 -mhard-float"
2724 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2726 proc check_effective_target_ucn_nocache { } {
2727 # -std=c99 is only valid for C
2728 if [check_effective_target_c] {
2729 set ucnopts "-std=c99"
2730 } else {
2731 set ucnopts ""
2733 verbose "check_effective_target_ucn_nocache: compiling source" 2
2734 set ret [check_no_compiler_messages_nocache ucn object {
2735 int \u00C0;
2736 } $ucnopts]
2737 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2738 return $ret
2741 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2743 # This won't change for different subtargets, so cache the result.
2745 proc check_effective_target_ucn { } {
2746 return [check_cached_effective_target ucn {
2747 check_effective_target_ucn_nocache
2751 # Return 1 if the target needs a command line argument to enable a SIMD
2752 # instruction set.
2754 proc check_effective_target_vect_cmdline_needed { } {
2755 global et_vect_cmdline_needed_saved
2756 global et_vect_cmdline_needed_target_name
2758 if { ![info exists et_vect_cmdline_needed_target_name] } {
2759 set et_vect_cmdline_needed_target_name ""
2762 # If the target has changed since we set the cached value, clear it.
2763 set current_target [current_target_name]
2764 if { $current_target != $et_vect_cmdline_needed_target_name } {
2765 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2766 set et_vect_cmdline_needed_target_name $current_target
2767 if { [info exists et_vect_cmdline_needed_saved] } {
2768 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
2769 unset et_vect_cmdline_needed_saved
2773 if [info exists et_vect_cmdline_needed_saved] {
2774 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2775 } else {
2776 set et_vect_cmdline_needed_saved 1
2777 if { [istarget alpha*-*-*]
2778 || [istarget ia64-*-*]
2779 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
2780 && ([check_effective_target_x32]
2781 || [check_effective_target_lp64]))
2782 || ([istarget powerpc*-*-*]
2783 && ([check_effective_target_powerpc_spe]
2784 || [check_effective_target_powerpc_altivec]))
2785 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2786 || [istarget spu-*-*]
2787 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2788 || [istarget aarch64*-*-*] } {
2789 set et_vect_cmdline_needed_saved 0
2793 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2794 return $et_vect_cmdline_needed_saved
2797 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2799 # This won't change for different subtargets so cache the result.
2801 proc check_effective_target_vect_int { } {
2802 global et_vect_int_saved
2803 global et_index
2805 if [info exists et_vect_int_saved($et_index)] {
2806 verbose "check_effective_target_vect_int: using cached result" 2
2807 } else {
2808 set et_vect_int_saved($et_index) 0
2809 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2810 || ([istarget powerpc*-*-*]
2811 && ![istarget powerpc-*-linux*paired*])
2812 || [istarget spu-*-*]
2813 || [istarget sparc*-*-*]
2814 || [istarget alpha*-*-*]
2815 || [istarget ia64-*-*]
2816 || [istarget aarch64*-*-*]
2817 || [check_effective_target_arm32]
2818 || ([istarget mips*-*-*]
2819 && ([et-is-effective-target mips_loongson]
2820 || [et-is-effective-target mips_msa])) } {
2821 set et_vect_int_saved($et_index) 1
2825 verbose "check_effective_target_vect_int:\
2826 returning $et_vect_int_saved($et_index)" 2
2827 return $et_vect_int_saved($et_index)
2830 # Return 1 if the target supports signed int->float conversion
2833 proc check_effective_target_vect_intfloat_cvt { } {
2834 global et_vect_intfloat_cvt_saved
2835 global et_index
2837 if [info exists et_vect_intfloat_cvt_saved($et_index)] {
2838 verbose "check_effective_target_vect_intfloat_cvt:\
2839 using cached result" 2
2840 } else {
2841 set et_vect_intfloat_cvt_saved($et_index) 0
2842 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2843 || ([istarget powerpc*-*-*]
2844 && ![istarget powerpc-*-linux*paired*])
2845 || ([istarget arm*-*-*]
2846 && [check_effective_target_arm_neon_ok])
2847 || ([istarget mips*-*-*]
2848 && [et-is-effective-target mips_msa]) } {
2849 set et_vect_intfloat_cvt_saved($et_index) 1
2853 verbose "check_effective_target_vect_intfloat_cvt:\
2854 returning $et_vect_intfloat_cvt_saved($et_index)" 2
2855 return $et_vect_intfloat_cvt_saved($et_index)
2858 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2860 proc check_effective_target_int128 { } {
2861 return [check_no_compiler_messages int128 object {
2862 int dummy[
2863 #ifndef __SIZEOF_INT128__
2865 #else
2867 #endif
2872 # Return 1 if the target supports unsigned int->float conversion
2875 proc check_effective_target_vect_uintfloat_cvt { } {
2876 global et_vect_uintfloat_cvt_saved
2877 global et_index
2879 if [info exists et_vect_uintfloat_cvt_saved($et_index)] {
2880 verbose "check_effective_target_vect_uintfloat_cvt:\
2881 using cached result" 2
2882 } else {
2883 set et_vect_uintfloat_cvt_saved($et_index) 0
2884 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2885 || ([istarget powerpc*-*-*]
2886 && ![istarget powerpc-*-linux*paired*])
2887 || [istarget aarch64*-*-*]
2888 || ([istarget arm*-*-*]
2889 && [check_effective_target_arm_neon_ok])
2890 || ([istarget mips*-*-*]
2891 && [et-is-effective-target mips_msa]) } {
2892 set et_vect_uintfloat_cvt_saved($et_index) 1
2896 verbose "check_effective_target_vect_uintfloat_cvt:\
2897 returning $et_vect_uintfloat_cvt_saved($et_index)" 2
2898 return $et_vect_uintfloat_cvt_saved($et_index)
2902 # Return 1 if the target supports signed float->int conversion
2905 proc check_effective_target_vect_floatint_cvt { } {
2906 global et_vect_floatint_cvt_saved
2907 global et_index
2909 if [info exists et_vect_floatint_cvt_saved($et_index)] {
2910 verbose "check_effective_target_vect_floatint_cvt:\
2911 using cached result" 2
2912 } else {
2913 set et_vect_floatint_cvt_saved($et_index) 0
2914 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2915 || ([istarget powerpc*-*-*]
2916 && ![istarget powerpc-*-linux*paired*])
2917 || ([istarget arm*-*-*]
2918 && [check_effective_target_arm_neon_ok])
2919 || ([istarget mips*-*-*]
2920 && [et-is-effective-target mips_msa]) } {
2921 set et_vect_floatint_cvt_saved($et_index) 1
2925 verbose "check_effective_target_vect_floatint_cvt:\
2926 returning $et_vect_floatint_cvt_saved($et_index)" 2
2927 return $et_vect_floatint_cvt_saved($et_index)
2930 # Return 1 if the target supports unsigned float->int conversion
2933 proc check_effective_target_vect_floatuint_cvt { } {
2934 global et_vect_floatuint_cvt_saved
2935 global et_index
2937 if [info exists et_vect_floatuint_cvt_saved($et_index)] {
2938 verbose "check_effective_target_vect_floatuint_cvt:\
2939 using cached result" 2
2940 } else {
2941 set et_vect_floatuint_cvt_saved($et_index) 0
2942 if { ([istarget powerpc*-*-*]
2943 && ![istarget powerpc-*-linux*paired*])
2944 || ([istarget arm*-*-*]
2945 && [check_effective_target_arm_neon_ok])
2946 || ([istarget mips*-*-*]
2947 && [et-is-effective-target mips_msa]) } {
2948 set et_vect_floatuint_cvt_saved($et_index) 1
2952 verbose "check_effective_target_vect_floatuint_cvt:\
2953 returning $et_vect_floatuint_cvt_saved($et_index)" 2
2954 return $et_vect_floatuint_cvt_saved($et_index)
2957 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2959 # This won't change for different subtargets so cache the result.
2961 proc check_effective_target_vect_simd_clones { } {
2962 global et_vect_simd_clones_saved
2963 global et_index
2965 if [info exists et_vect_simd_clones_saved($et_index)] {
2966 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2967 } else {
2968 set et_vect_simd_clones_saved($et_index) 0
2969 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2970 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx, avx2
2971 # and avx512f clone. Only the right clone for the specified arch
2972 # will be chosen, but still we need to at least be able to assemble
2973 # avx512f.
2974 if { [check_effective_target_avx512f] } {
2975 set et_vect_simd_clones_saved($et_index) 1
2980 verbose "check_effective_target_vect_simd_clones:\
2981 returning $et_vect_simd_clones_saved($et_index)" 2
2982 return $et_vect_simd_clones_saved($et_index)
2985 # Return 1 if this is a AArch64 target supporting big endian
2986 proc check_effective_target_aarch64_big_endian { } {
2987 return [check_no_compiler_messages aarch64_big_endian assembly {
2988 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2989 #error !__aarch64__ || !__AARCH64EB__
2990 #endif
2994 # Return 1 if this is a AArch64 target supporting little endian
2995 proc check_effective_target_aarch64_little_endian { } {
2996 if { ![istarget aarch64*-*-*] } {
2997 return 0
3000 return [check_no_compiler_messages aarch64_little_endian assembly {
3001 #if !defined(__aarch64__) || defined(__AARCH64EB__)
3002 #error FOO
3003 #endif
3007 # Return 1 if this is a compiler supporting ARC atomic operations
3008 proc check_effective_target_arc_atomic { } {
3009 return [check_no_compiler_messages arc_atomic assembly {
3010 #if !defined(__ARC_ATOMIC__)
3011 #error FOO
3012 #endif
3016 # Return 1 if this is an arm target using 32-bit instructions
3017 proc check_effective_target_arm32 { } {
3018 if { ![istarget arm*-*-*] } {
3019 return 0
3022 return [check_no_compiler_messages arm32 assembly {
3023 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
3024 #error !__arm || __thumb__ && !__thumb2__
3025 #endif
3029 # Return 1 if this is an arm target not using Thumb
3030 proc check_effective_target_arm_nothumb { } {
3031 if { ![istarget arm*-*-*] } {
3032 return 0
3035 return [check_no_compiler_messages arm_nothumb assembly {
3036 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
3037 #error !__arm__ || __thumb || __thumb2__
3038 #endif
3042 # Return 1 if this is a little-endian ARM target
3043 proc check_effective_target_arm_little_endian { } {
3044 if { ![istarget arm*-*-*] } {
3045 return 0
3048 return [check_no_compiler_messages arm_little_endian assembly {
3049 #if !defined(__arm__) || !defined(__ARMEL__)
3050 #error !__arm__ || !__ARMEL__
3051 #endif
3055 # Return 1 if this is an ARM target that only supports aligned vector accesses
3056 proc check_effective_target_arm_vect_no_misalign { } {
3057 if { ![istarget arm*-*-*] } {
3058 return 0
3061 return [check_no_compiler_messages arm_vect_no_misalign assembly {
3062 #if !defined(__arm__) \
3063 || (defined(__ARM_FEATURE_UNALIGNED) \
3064 && defined(__ARMEL__))
3065 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
3066 #endif
3071 # Return 1 if this is an ARM target supporting -mfpu=vfp
3072 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
3073 # options.
3075 proc check_effective_target_arm_vfp_ok { } {
3076 if { [check_effective_target_arm32] } {
3077 return [check_no_compiler_messages arm_vfp_ok object {
3078 int dummy;
3079 } "-mfpu=vfp -mfloat-abi=softfp"]
3080 } else {
3081 return 0
3085 # Return 1 if this is an ARM target supporting -mfpu=vfp3
3086 # -mfloat-abi=softfp.
3088 proc check_effective_target_arm_vfp3_ok { } {
3089 if { [check_effective_target_arm32] } {
3090 return [check_no_compiler_messages arm_vfp3_ok object {
3091 int dummy;
3092 } "-mfpu=vfp3 -mfloat-abi=softfp"]
3093 } else {
3094 return 0
3098 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
3099 # -mfloat-abi=softfp.
3100 proc check_effective_target_arm_v8_vfp_ok {} {
3101 if { [check_effective_target_arm32] } {
3102 return [check_no_compiler_messages arm_v8_vfp_ok object {
3103 int foo (void)
3105 __asm__ volatile ("vrinta.f32.f32 s0, s0");
3106 return 0;
3108 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
3109 } else {
3110 return 0
3114 # Return 1 if this is an ARM target supporting -mfpu=vfp
3115 # -mfloat-abi=hard. Some multilibs may be incompatible with these
3116 # options.
3118 proc check_effective_target_arm_hard_vfp_ok { } {
3119 if { [check_effective_target_arm32]
3120 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
3121 return [check_no_compiler_messages arm_hard_vfp_ok executable {
3122 int main() { return 0;}
3123 } "-mfpu=vfp -mfloat-abi=hard"]
3124 } else {
3125 return 0
3129 # Return 1 if this is an ARM target defining __ARM_FP. We may need
3130 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3131 # incompatible with these options. Also set et_arm_fp_flags to the
3132 # best options to add.
3134 proc check_effective_target_arm_fp_ok_nocache { } {
3135 global et_arm_fp_flags
3136 set et_arm_fp_flags ""
3137 if { [check_effective_target_arm32] } {
3138 foreach flags {"" "-mfloat-abi=softfp" "-mfloat-abi=hard"} {
3139 if { [check_no_compiler_messages_nocache arm_fp_ok object {
3140 #ifndef __ARM_FP
3141 #error __ARM_FP not defined
3142 #endif
3143 } "$flags"] } {
3144 set et_arm_fp_flags $flags
3145 return 1
3150 return 0
3153 proc check_effective_target_arm_fp_ok { } {
3154 return [check_cached_effective_target arm_fp_ok \
3155 check_effective_target_arm_fp_ok_nocache]
3158 # Add the options needed to define __ARM_FP. We need either
3159 # -mfloat-abi=softfp or -mfloat-abi=hard, but if one is already
3160 # specified by the multilib, use it.
3162 proc add_options_for_arm_fp { flags } {
3163 if { ! [check_effective_target_arm_fp_ok] } {
3164 return "$flags"
3166 global et_arm_fp_flags
3167 return "$flags $et_arm_fp_flags"
3170 # Return 1 if this is an ARM target that supports DSP multiply with
3171 # current multilib flags.
3173 proc check_effective_target_arm_dsp { } {
3174 return [check_no_compiler_messages arm_dsp assembly {
3175 #ifndef __ARM_FEATURE_DSP
3176 #error not DSP
3177 #endif
3178 int i;
3182 # Return 1 if this is an ARM target that supports unaligned word/halfword
3183 # load/store instructions.
3185 proc check_effective_target_arm_unaligned { } {
3186 return [check_no_compiler_messages arm_unaligned assembly {
3187 #ifndef __ARM_FEATURE_UNALIGNED
3188 #error no unaligned support
3189 #endif
3190 int i;
3194 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
3195 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3196 # incompatible with these options. Also set et_arm_crypto_flags to the
3197 # best options to add.
3199 proc check_effective_target_arm_crypto_ok_nocache { } {
3200 global et_arm_crypto_flags
3201 set et_arm_crypto_flags ""
3202 if { [check_effective_target_arm_v8_neon_ok] } {
3203 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
3204 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
3205 #include "arm_neon.h"
3206 uint8x16_t
3207 foo (uint8x16_t a, uint8x16_t b)
3209 return vaeseq_u8 (a, b);
3211 } "$flags"] } {
3212 set et_arm_crypto_flags $flags
3213 return 1
3218 return 0
3221 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
3223 proc check_effective_target_arm_crypto_ok { } {
3224 return [check_cached_effective_target arm_crypto_ok \
3225 check_effective_target_arm_crypto_ok_nocache]
3228 # Add options for crypto extensions.
3229 proc add_options_for_arm_crypto { flags } {
3230 if { ! [check_effective_target_arm_crypto_ok] } {
3231 return "$flags"
3233 global et_arm_crypto_flags
3234 return "$flags $et_arm_crypto_flags"
3237 # Add the options needed for NEON. We need either -mfloat-abi=softfp
3238 # or -mfloat-abi=hard, but if one is already specified by the
3239 # multilib, use it. Similarly, if a -mfpu option already enables
3240 # NEON, do not add -mfpu=neon.
3242 proc add_options_for_arm_neon { flags } {
3243 if { ! [check_effective_target_arm_neon_ok] } {
3244 return "$flags"
3246 global et_arm_neon_flags
3247 return "$flags $et_arm_neon_flags"
3250 proc add_options_for_arm_v8_vfp { flags } {
3251 if { ! [check_effective_target_arm_v8_vfp_ok] } {
3252 return "$flags"
3254 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
3257 proc add_options_for_arm_v8_neon { flags } {
3258 if { ! [check_effective_target_arm_v8_neon_ok] } {
3259 return "$flags"
3261 global et_arm_v8_neon_flags
3262 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
3265 # Add the options needed for ARMv8.1 Adv.SIMD. Also adds the ARMv8 NEON
3266 # options for AArch64 and for ARM.
3268 proc add_options_for_arm_v8_1a_neon { flags } {
3269 if { ! [check_effective_target_arm_v8_1a_neon_ok] } {
3270 return "$flags"
3272 global et_arm_v8_1a_neon_flags
3273 return "$flags $et_arm_v8_1a_neon_flags -march=armv8.1-a"
3276 # Add the options needed for ARMv8.2 with the scalar FP16 extension.
3277 # Also adds the ARMv8 FP options for ARM and for AArch64.
3279 proc add_options_for_arm_v8_2a_fp16_scalar { flags } {
3280 if { ! [check_effective_target_arm_v8_2a_fp16_scalar_ok] } {
3281 return "$flags"
3283 global et_arm_v8_2a_fp16_scalar_flags
3284 return "$flags $et_arm_v8_2a_fp16_scalar_flags"
3287 # Add the options needed for ARMv8.2 with the FP16 extension. Also adds
3288 # the ARMv8 NEON options for ARM and for AArch64.
3290 proc add_options_for_arm_v8_2a_fp16_neon { flags } {
3291 if { ! [check_effective_target_arm_v8_2a_fp16_neon_ok] } {
3292 return "$flags"
3294 global et_arm_v8_2a_fp16_neon_flags
3295 return "$flags $et_arm_v8_2a_fp16_neon_flags"
3298 proc add_options_for_arm_crc { flags } {
3299 if { ! [check_effective_target_arm_crc_ok] } {
3300 return "$flags"
3302 global et_arm_crc_flags
3303 return "$flags $et_arm_crc_flags"
3306 # Add the options needed for NEON. We need either -mfloat-abi=softfp
3307 # or -mfloat-abi=hard, but if one is already specified by the
3308 # multilib, use it. Similarly, if a -mfpu option already enables
3309 # NEON, do not add -mfpu=neon.
3311 proc add_options_for_arm_neonv2 { flags } {
3312 if { ! [check_effective_target_arm_neonv2_ok] } {
3313 return "$flags"
3315 global et_arm_neonv2_flags
3316 return "$flags $et_arm_neonv2_flags"
3319 # Add the options needed for vfp3.
3320 proc add_options_for_arm_vfp3 { flags } {
3321 if { ! [check_effective_target_arm_vfp3_ok] } {
3322 return "$flags"
3324 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
3327 # Return 1 if this is an ARM target supporting -mfpu=neon
3328 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3329 # incompatible with these options. Also set et_arm_neon_flags to the
3330 # best options to add.
3332 proc check_effective_target_arm_neon_ok_nocache { } {
3333 global et_arm_neon_flags
3334 set et_arm_neon_flags ""
3335 if { [check_effective_target_arm32] } {
3336 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp" "-mfpu=neon -mfloat-abi=softfp -march=armv7-a"} {
3337 if { [check_no_compiler_messages_nocache arm_neon_ok object {
3338 int dummy;
3339 #ifndef __ARM_NEON__
3340 #error not NEON
3341 #endif
3342 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
3343 configured for -mcpu=arm926ej-s, for example. */
3344 #if __ARM_ARCH < 7 || __ARM_ARCH_PROFILE == 'M'
3345 #error Architecture does not support NEON.
3346 #endif
3347 } "$flags"] } {
3348 set et_arm_neon_flags $flags
3349 return 1
3354 return 0
3357 proc check_effective_target_arm_neon_ok { } {
3358 return [check_cached_effective_target arm_neon_ok \
3359 check_effective_target_arm_neon_ok_nocache]
3362 proc check_effective_target_arm_crc_ok_nocache { } {
3363 global et_arm_crc_flags
3364 set et_arm_crc_flags "-march=armv8-a+crc"
3365 return [check_no_compiler_messages_nocache arm_crc_ok object {
3366 #if !defined (__ARM_FEATURE_CRC32)
3367 #error FOO
3368 #endif
3369 } "$et_arm_crc_flags"]
3372 proc check_effective_target_arm_crc_ok { } {
3373 return [check_cached_effective_target arm_crc_ok \
3374 check_effective_target_arm_crc_ok_nocache]
3377 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
3378 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3379 # incompatible with these options. Also set et_arm_neon_fp16_flags to
3380 # the best options to add.
3382 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
3383 global et_arm_neon_fp16_flags
3384 global et_arm_neon_flags
3385 set et_arm_neon_fp16_flags ""
3386 if { [check_effective_target_arm32]
3387 && [check_effective_target_arm_neon_ok] } {
3388 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3389 "-mfpu=neon-fp16 -mfloat-abi=softfp"
3390 "-mfp16-format=ieee"
3391 "-mfloat-abi=softfp -mfp16-format=ieee"
3392 "-mfpu=neon-fp16 -mfp16-format=ieee"
3393 "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
3394 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
3395 #include "arm_neon.h"
3396 float16x4_t
3397 foo (float32x4_t arg)
3399 return vcvt_f16_f32 (arg);
3401 } "$et_arm_neon_flags $flags"] } {
3402 set et_arm_neon_fp16_flags [concat $et_arm_neon_flags $flags]
3403 return 1
3408 return 0
3411 proc check_effective_target_arm_neon_fp16_ok { } {
3412 return [check_cached_effective_target arm_neon_fp16_ok \
3413 check_effective_target_arm_neon_fp16_ok_nocache]
3416 proc check_effective_target_arm_neon_fp16_hw { } {
3417 if {! [check_effective_target_arm_neon_fp16_ok] } {
3418 return 0
3420 global et_arm_neon_fp16_flags
3421 check_runtime_nocache arm_neon_fp16_hw {
3423 main (int argc, char **argv)
3425 asm ("vcvt.f32.f16 q1, d0");
3426 return 0;
3428 } $et_arm_neon_fp16_flags
3431 proc add_options_for_arm_neon_fp16 { flags } {
3432 if { ! [check_effective_target_arm_neon_fp16_ok] } {
3433 return "$flags"
3435 global et_arm_neon_fp16_flags
3436 return "$flags $et_arm_neon_fp16_flags"
3439 # Return 1 if this is an ARM target supporting the FP16 alternative
3440 # format. Some multilibs may be incompatible with the options needed. Also
3441 # set et_arm_neon_fp16_flags to the best options to add.
3443 proc check_effective_target_arm_fp16_alternative_ok_nocache { } {
3444 global et_arm_neon_fp16_flags
3445 set et_arm_neon_fp16_flags ""
3446 if { [check_effective_target_arm32] } {
3447 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3448 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
3449 if { [check_no_compiler_messages_nocache \
3450 arm_fp16_alternative_ok object {
3451 #if !defined (__ARM_FP16_FORMAT_ALTERNATIVE)
3452 #error __ARM_FP16_FORMAT_ALTERNATIVE not defined
3453 #endif
3454 } "$flags -mfp16-format=alternative"] } {
3455 set et_arm_neon_fp16_flags "$flags -mfp16-format=alternative"
3456 return 1
3461 return 0
3464 proc check_effective_target_arm_fp16_alternative_ok { } {
3465 return [check_cached_effective_target arm_fp16_alternative_ok \
3466 check_effective_target_arm_fp16_alternative_ok_nocache]
3469 # Return 1 if this is an ARM target supports specifying the FP16 none
3470 # format. Some multilibs may be incompatible with the options needed.
3472 proc check_effective_target_arm_fp16_none_ok_nocache { } {
3473 if { [check_effective_target_arm32] } {
3474 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3475 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
3476 if { [check_no_compiler_messages_nocache \
3477 arm_fp16_none_ok object {
3478 #if defined (__ARM_FP16_FORMAT_ALTERNATIVE)
3479 #error __ARM_FP16_FORMAT_ALTERNATIVE defined
3480 #endif
3481 #if defined (__ARM_FP16_FORMAT_IEEE)
3482 #error __ARM_FP16_FORMAT_IEEE defined
3483 #endif
3484 } "$flags -mfp16-format=none"] } {
3485 return 1
3490 return 0
3493 proc check_effective_target_arm_fp16_none_ok { } {
3494 return [check_cached_effective_target arm_fp16_none_ok \
3495 check_effective_target_arm_fp16_none_ok_nocache]
3498 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
3499 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3500 # incompatible with these options. Also set et_arm_v8_neon_flags to the
3501 # best options to add.
3503 proc check_effective_target_arm_v8_neon_ok_nocache { } {
3504 global et_arm_v8_neon_flags
3505 set et_arm_v8_neon_flags ""
3506 if { [check_effective_target_arm32] } {
3507 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3508 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
3509 #if __ARM_ARCH < 8
3510 #error not armv8 or later
3511 #endif
3512 #include "arm_neon.h"
3513 void
3514 foo ()
3516 __asm__ volatile ("vrintn.f32 q0, q0");
3518 } "$flags -march=armv8-a"] } {
3519 set et_arm_v8_neon_flags $flags
3520 return 1
3525 return 0
3528 proc check_effective_target_arm_v8_neon_ok { } {
3529 return [check_cached_effective_target arm_v8_neon_ok \
3530 check_effective_target_arm_v8_neon_ok_nocache]
3533 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
3534 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3535 # incompatible with these options. Also set et_arm_neonv2_flags to the
3536 # best options to add.
3538 proc check_effective_target_arm_neonv2_ok_nocache { } {
3539 global et_arm_neonv2_flags
3540 global et_arm_neon_flags
3541 set et_arm_neonv2_flags ""
3542 if { [check_effective_target_arm32]
3543 && [check_effective_target_arm_neon_ok] } {
3544 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
3545 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
3546 #include "arm_neon.h"
3547 float32x2_t
3548 foo (float32x2_t a, float32x2_t b, float32x2_t c)
3550 return vfma_f32 (a, b, c);
3552 } "$et_arm_neon_flags $flags"] } {
3553 set et_arm_neonv2_flags [concat $et_arm_neon_flags $flags]
3554 return 1
3559 return 0
3562 proc check_effective_target_arm_neonv2_ok { } {
3563 return [check_cached_effective_target arm_neonv2_ok \
3564 check_effective_target_arm_neonv2_ok_nocache]
3567 # Add the options needed for VFP FP16 support. We need either
3568 # -mfloat-abi=softfp or -mfloat-abi=hard. If one is already specified by
3569 # the multilib, use it.
3571 proc add_options_for_arm_fp16 { flags } {
3572 if { ! [check_effective_target_arm_fp16_ok] } {
3573 return "$flags"
3575 global et_arm_fp16_flags
3576 return "$flags $et_arm_fp16_flags"
3579 # Add the options needed to enable support for IEEE format
3580 # half-precision support. This is valid for ARM targets.
3582 proc add_options_for_arm_fp16_ieee { flags } {
3583 if { ! [check_effective_target_arm_fp16_ok] } {
3584 return "$flags"
3586 global et_arm_fp16_flags
3587 return "$flags $et_arm_fp16_flags -mfp16-format=ieee"
3590 # Add the options needed to enable support for ARM Alternative format
3591 # half-precision support. This is valid for ARM targets.
3593 proc add_options_for_arm_fp16_alternative { flags } {
3594 if { ! [check_effective_target_arm_fp16_ok] } {
3595 return "$flags"
3597 global et_arm_fp16_flags
3598 return "$flags $et_arm_fp16_flags -mfp16-format=alternative"
3601 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
3602 # Skip multilibs that are incompatible with these options and set
3603 # et_arm_fp16_flags to the best options to add. This test is valid for
3604 # ARM only.
3606 proc check_effective_target_arm_fp16_ok_nocache { } {
3607 global et_arm_fp16_flags
3608 set et_arm_fp16_flags ""
3609 if { ! [check_effective_target_arm32] } {
3610 return 0;
3612 if [check-flags \
3613 [list "" { *-*-* } { "-mfpu=*" } \
3614 { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" \
3615 "-mfpu=*fpv[1-9][0-9]*" "-mfpu=*fp-armv8*" } ]] {
3616 # Multilib flags would override -mfpu.
3617 return 0
3619 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
3620 # Must generate floating-point instructions.
3621 return 0
3623 if [check_effective_target_arm_hf_eabi] {
3624 # Use existing float-abi and force an fpu which supports fp16
3625 set et_arm_fp16_flags "-mfpu=vfpv4"
3626 return 1;
3628 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
3629 # The existing -mfpu value is OK; use it, but add softfp.
3630 set et_arm_fp16_flags "-mfloat-abi=softfp"
3631 return 1;
3633 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
3634 # macro to check for this support.
3635 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
3636 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
3637 int dummy;
3638 } "$flags"] } {
3639 set et_arm_fp16_flags "$flags"
3640 return 1
3643 return 0
3646 proc check_effective_target_arm_fp16_ok { } {
3647 return [check_cached_effective_target arm_fp16_ok \
3648 check_effective_target_arm_fp16_ok_nocache]
3651 # Return 1 if the target supports executing VFP FP16 instructions, 0
3652 # otherwise. This test is valid for ARM only.
3654 proc check_effective_target_arm_fp16_hw { } {
3655 if {! [check_effective_target_arm_fp16_ok] } {
3656 return 0
3658 global et_arm_fp16_flags
3659 check_runtime_nocache arm_fp16_hw {
3661 main (int argc, char **argv)
3663 __fp16 a = 1.0;
3664 float r;
3665 asm ("vcvtb.f32.f16 %0, %1"
3666 : "=w" (r) : "w" (a)
3667 : /* No clobbers. */);
3668 return (r == 1.0) ? 0 : 1;
3670 } "$et_arm_fp16_flags -mfp16-format=ieee"
3673 # Creates a series of routines that return 1 if the given architecture
3674 # can be selected and a routine to give the flags to select that architecture
3675 # Note: Extra flags may be added to disable options from newer compilers
3676 # (Thumb in particular - but others may be added in the future).
3677 # -march=armv7ve is special and is handled explicitly after this loop because
3678 # it needs more than one predefine check to identify.
3679 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
3680 # /* { dg-add-options arm_arch_v5 } */
3681 # /* { dg-require-effective-target arm_arch_v5_multilib } */
3682 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
3683 v4t "-march=armv4t" __ARM_ARCH_4T__
3684 v5 "-march=armv5 -marm" __ARM_ARCH_5__
3685 v5t "-march=armv5t" __ARM_ARCH_5T__
3686 v5te "-march=armv5te" __ARM_ARCH_5TE__
3687 v6 "-march=armv6" __ARM_ARCH_6__
3688 v6k "-march=armv6k" __ARM_ARCH_6K__
3689 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
3690 v6z "-march=armv6z" __ARM_ARCH_6Z__
3691 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
3692 v7a "-march=armv7-a" __ARM_ARCH_7A__
3693 v7r "-march=armv7-r" __ARM_ARCH_7R__
3694 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
3695 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
3696 v8a "-march=armv8-a" __ARM_ARCH_8A__
3697 v8_1a "-march=armv8.1a" __ARM_ARCH_8A__
3698 v8_2a "-march=armv8.2a" __ARM_ARCH_8A__
3699 v8m_base "-march=armv8-m.base -mthumb" __ARM_ARCH_8M_BASE__
3700 v8m_main "-march=armv8-m.main -mthumb" __ARM_ARCH_8M_MAIN__ } {
3701 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
3702 proc check_effective_target_arm_arch_FUNC_ok { } {
3703 if { [ string match "*-marm*" "FLAG" ] &&
3704 ![check_effective_target_arm_arm_ok] } {
3705 return 0
3707 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
3708 #if !defined (DEF)
3709 #error !DEF
3710 #endif
3711 } "FLAG" ]
3714 proc add_options_for_arm_arch_FUNC { flags } {
3715 return "$flags FLAG"
3718 proc check_effective_target_arm_arch_FUNC_multilib { } {
3719 return [check_runtime arm_arch_FUNC_multilib {
3721 main (void)
3723 return 0;
3725 } [add_options_for_arm_arch_FUNC ""]]
3730 # Same functions as above but for -march=armv7ve. To uniquely identify
3731 # -march=armv7ve we need to check for __ARM_ARCH_7A__ as well as
3732 # __ARM_FEATURE_IDIV otherwise it aliases with armv7-a.
3734 proc check_effective_target_arm_arch_v7ve_ok { } {
3735 if { [ string match "*-marm*" "-march=armv7ve" ] &&
3736 ![check_effective_target_arm_arm_ok] } {
3737 return 0
3739 return [check_no_compiler_messages arm_arch_v7ve_ok assembly {
3740 #if !defined (__ARM_ARCH_7A__) || !defined (__ARM_FEATURE_IDIV)
3741 #error !armv7ve
3742 #endif
3743 } "-march=armv7ve" ]
3746 proc add_options_for_arm_arch_v7ve { flags } {
3747 return "$flags -march=armv7ve"
3750 # Return 1 if this is an ARM target where -marm causes ARM to be
3751 # used (not Thumb)
3753 proc check_effective_target_arm_arm_ok { } {
3754 return [check_no_compiler_messages arm_arm_ok assembly {
3755 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
3756 #error !__arm__ || __thumb__ || __thumb2__
3757 #endif
3758 } "-marm"]
3762 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
3763 # used.
3765 proc check_effective_target_arm_thumb1_ok { } {
3766 return [check_no_compiler_messages arm_thumb1_ok assembly {
3767 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3768 #error !__arm__ || !__thumb__ || __thumb2__
3769 #endif
3770 int foo (int i) { return i; }
3771 } "-mthumb"]
3774 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
3775 # used.
3777 proc check_effective_target_arm_thumb2_ok { } {
3778 return [check_no_compiler_messages arm_thumb2_ok assembly {
3779 #if !defined(__thumb2__)
3780 #error !__thumb2__
3781 #endif
3782 int foo (int i) { return i; }
3783 } "-mthumb"]
3786 # Return 1 if this is an ARM target where Thumb-1 is used without options
3787 # added by the test.
3789 proc check_effective_target_arm_thumb1 { } {
3790 return [check_no_compiler_messages arm_thumb1 assembly {
3791 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3792 #error !__arm__ || !__thumb__ || __thumb2__
3793 #endif
3794 int i;
3795 } ""]
3798 # Return 1 if this is an ARM target where Thumb-2 is used without options
3799 # added by the test.
3801 proc check_effective_target_arm_thumb2 { } {
3802 return [check_no_compiler_messages arm_thumb2 assembly {
3803 #if !defined(__thumb2__)
3804 #error !__thumb2__
3805 #endif
3806 int i;
3807 } ""]
3810 # Return 1 if this is an ARM target where conditional execution is available.
3812 proc check_effective_target_arm_cond_exec { } {
3813 return [check_no_compiler_messages arm_cond_exec assembly {
3814 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
3815 #error FOO
3816 #endif
3817 int i;
3818 } ""]
3821 # Return 1 if this is an ARM cortex-M profile cpu
3823 proc check_effective_target_arm_cortex_m { } {
3824 if { ![istarget arm*-*-*] } {
3825 return 0
3827 return [check_no_compiler_messages arm_cortex_m assembly {
3828 #if defined(__ARM_ARCH_ISA_ARM)
3829 #error __ARM_ARCH_ISA_ARM is defined
3830 #endif
3831 int i;
3832 } "-mthumb"]
3835 # Return 1 if this is an ARM target where -mthumb causes Thumb-1 to be
3836 # used and MOVT/MOVW instructions to be available.
3838 proc check_effective_target_arm_thumb1_movt_ok {} {
3839 if [check_effective_target_arm_thumb1_ok] {
3840 return [check_no_compiler_messages arm_movt object {
3842 foo (void)
3844 asm ("movt r0, #42");
3846 } "-mthumb"]
3847 } else {
3848 return 0
3852 # Return 1 if this is an ARM target where -mthumb causes Thumb-1 to be
3853 # used and CBZ and CBNZ instructions are available.
3855 proc check_effective_target_arm_thumb1_cbz_ok {} {
3856 if [check_effective_target_arm_thumb1_ok] {
3857 return [check_no_compiler_messages arm_movt object {
3859 foo (void)
3861 asm ("cbz r0, 2f\n2:");
3863 } "-mthumb"]
3864 } else {
3865 return 0
3869 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3871 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3872 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3873 int foo (void) { return 0; }
3874 } "-O2 -mprint-tune-info" ]
3877 # Return 1 if the target supports executing NEON instructions, 0
3878 # otherwise. Cache the result.
3880 proc check_effective_target_arm_neon_hw { } {
3881 return [check_runtime arm_neon_hw_available {
3883 main (void)
3885 long long a = 0, b = 1;
3886 asm ("vorr %P0, %P1, %P2"
3887 : "=w" (a)
3888 : "0" (a), "w" (b));
3889 return (a != 1);
3891 } [add_options_for_arm_neon ""]]
3894 proc check_effective_target_arm_neonv2_hw { } {
3895 return [check_runtime arm_neon_hwv2_available {
3896 #include "arm_neon.h"
3898 main (void)
3900 float32x2_t a, b, c;
3901 asm ("vfma.f32 %P0, %P1, %P2"
3902 : "=w" (a)
3903 : "w" (b), "w" (c));
3904 return 0;
3906 } [add_options_for_arm_neonv2 ""]]
3909 # Return 1 if the target supports the ARMv8.1 Adv.SIMD extension, 0
3910 # otherwise. The test is valid for AArch64 and ARM. Record the command
3911 # line options needed.
3913 proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
3914 global et_arm_v8_1a_neon_flags
3915 set et_arm_v8_1a_neon_flags ""
3917 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3918 return 0;
3921 # Iterate through sets of options to find the compiler flags that
3922 # need to be added to the -march option. Start with the empty set
3923 # since AArch64 only needs the -march setting.
3924 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
3925 "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3926 if { [check_no_compiler_messages_nocache arm_v8_1a_neon_ok object {
3927 #if !defined (__ARM_FEATURE_QRDMX)
3928 #error "__ARM_FEATURE_QRDMX not defined"
3929 #endif
3930 } "$flags -march=armv8.1-a"] } {
3931 set et_arm_v8_1a_neon_flags "$flags -march=armv8.1-a"
3932 return 1
3936 return 0;
3939 proc check_effective_target_arm_v8_1a_neon_ok { } {
3940 return [check_cached_effective_target arm_v8_1a_neon_ok \
3941 check_effective_target_arm_v8_1a_neon_ok_nocache]
3944 # Return 1 if the target supports ARMv8.2 scalar FP16 arithmetic
3945 # instructions, 0 otherwise. The test is valid for ARM and for AArch64.
3946 # Record the command line options needed.
3948 proc check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
3949 global et_arm_v8_2a_fp16_scalar_flags
3950 set et_arm_v8_2a_fp16_scalar_flags ""
3952 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3953 return 0;
3956 # Iterate through sets of options to find the compiler flags that
3957 # need to be added to the -march option.
3958 foreach flags {"" "-mfpu=fp-armv8" "-mfloat-abi=softfp" \
3959 "-mfpu=fp-armv8 -mfloat-abi=softfp"} {
3960 if { [check_no_compiler_messages_nocache \
3961 arm_v8_2a_fp16_scalar_ok object {
3962 #if !defined (__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
3963 #error "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined"
3964 #endif
3965 } "$flags -march=armv8.2-a+fp16"] } {
3966 set et_arm_v8_2a_fp16_scalar_flags "$flags -march=armv8.2-a+fp16"
3967 return 1
3971 return 0;
3974 proc check_effective_target_arm_v8_2a_fp16_scalar_ok { } {
3975 return [check_cached_effective_target arm_v8_2a_fp16_scalar_ok \
3976 check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache]
3979 # Return 1 if the target supports ARMv8.2 Adv.SIMD FP16 arithmetic
3980 # instructions, 0 otherwise. The test is valid for ARM and for AArch64.
3981 # Record the command line options needed.
3983 proc check_effective_target_arm_v8_2a_fp16_neon_ok_nocache { } {
3984 global et_arm_v8_2a_fp16_neon_flags
3985 set et_arm_v8_2a_fp16_neon_flags ""
3987 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3988 return 0;
3991 # Iterate through sets of options to find the compiler flags that
3992 # need to be added to the -march option.
3993 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
3994 "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3995 if { [check_no_compiler_messages_nocache \
3996 arm_v8_2a_fp16_neon_ok object {
3997 #if !defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
3998 #error "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined"
3999 #endif
4000 } "$flags -march=armv8.2-a+fp16"] } {
4001 set et_arm_v8_2a_fp16_neon_flags "$flags -march=armv8.2-a+fp16"
4002 return 1
4006 return 0;
4009 proc check_effective_target_arm_v8_2a_fp16_neon_ok { } {
4010 return [check_cached_effective_target arm_v8_2a_fp16_neon_ok \
4011 check_effective_target_arm_v8_2a_fp16_neon_ok_nocache]
4014 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
4015 # otherwise.
4017 proc check_effective_target_arm_v8_neon_hw { } {
4018 return [check_runtime arm_v8_neon_hw_available {
4019 #include "arm_neon.h"
4021 main (void)
4023 float32x2_t a = { 1.0f, 2.0f };
4024 #ifdef __ARM_ARCH_ISA_A64
4025 asm ("frinta %0.2s, %1.2s"
4026 : "=w" (a)
4027 : "w" (a));
4028 #else
4029 asm ("vrinta.f32 %P0, %P1"
4030 : "=w" (a)
4031 : "0" (a));
4032 #endif
4033 return a[0] == 2.0f;
4035 } [add_options_for_arm_v8_neon ""]]
4038 # Return 1 if the target supports executing the ARMv8.1 Adv.SIMD extension, 0
4039 # otherwise. The test is valid for AArch64 and ARM.
4041 proc check_effective_target_arm_v8_1a_neon_hw { } {
4042 if { ![check_effective_target_arm_v8_1a_neon_ok] } {
4043 return 0;
4045 return [check_runtime arm_v8_1a_neon_hw_available {
4047 main (void)
4049 #ifdef __ARM_ARCH_ISA_A64
4050 __Int32x2_t a = {0, 1};
4051 __Int32x2_t b = {0, 2};
4052 __Int32x2_t result;
4054 asm ("sqrdmlah %0.2s, %1.2s, %2.2s"
4055 : "=w"(result)
4056 : "w"(a), "w"(b)
4057 : /* No clobbers. */);
4059 #else
4061 __simd64_int32_t a = {0, 1};
4062 __simd64_int32_t b = {0, 2};
4063 __simd64_int32_t result;
4065 asm ("vqrdmlah.s32 %P0, %P1, %P2"
4066 : "=w"(result)
4067 : "w"(a), "w"(b)
4068 : /* No clobbers. */);
4069 #endif
4071 return result[0];
4073 } [add_options_for_arm_v8_1a_neon ""]]
4076 # Return 1 if the target supports executing floating point instructions from
4077 # ARMv8.2 with the FP16 extension, 0 otherwise. The test is valid for ARM and
4078 # for AArch64.
4080 proc check_effective_target_arm_v8_2a_fp16_scalar_hw { } {
4081 if { ![check_effective_target_arm_v8_2a_fp16_scalar_ok] } {
4082 return 0;
4084 return [check_runtime arm_v8_2a_fp16_scalar_hw_available {
4086 main (void)
4088 __fp16 a = 1.0;
4089 __fp16 result;
4091 #ifdef __ARM_ARCH_ISA_A64
4093 asm ("fabs %h0, %h1"
4094 : "=w"(result)
4095 : "w"(a)
4096 : /* No clobbers. */);
4098 #else
4100 asm ("vabs.f16 %0, %1"
4101 : "=w"(result)
4102 : "w"(a)
4103 : /* No clobbers. */);
4105 #endif
4107 return (result == 1.0) ? 0 : 1;
4109 } [add_options_for_arm_v8_2a_fp16_scalar ""]]
4112 # Return 1 if the target supports executing Adv.SIMD instructions from ARMv8.2
4113 # with the FP16 extension, 0 otherwise. The test is valid for ARM and for
4114 # AArch64.
4116 proc check_effective_target_arm_v8_2a_fp16_neon_hw { } {
4117 if { ![check_effective_target_arm_v8_2a_fp16_neon_ok] } {
4118 return 0;
4120 return [check_runtime arm_v8_2a_fp16_neon_hw_available {
4122 main (void)
4124 #ifdef __ARM_ARCH_ISA_A64
4126 __Float16x4_t a = {1.0, -1.0, 1.0, -1.0};
4127 __Float16x4_t result;
4129 asm ("fabs %0.4h, %1.4h"
4130 : "=w"(result)
4131 : "w"(a)
4132 : /* No clobbers. */);
4134 #else
4136 __simd64_float16_t a = {1.0, -1.0, 1.0, -1.0};
4137 __simd64_float16_t result;
4139 asm ("vabs.f16 %P0, %P1"
4140 : "=w"(result)
4141 : "w"(a)
4142 : /* No clobbers. */);
4144 #endif
4146 return (result[0] == 1.0) ? 0 : 1;
4148 } [add_options_for_arm_v8_2a_fp16_neon ""]]
4151 # Return 1 if this is a ARM target with NEON enabled.
4153 proc check_effective_target_arm_neon { } {
4154 if { [check_effective_target_arm32] } {
4155 return [check_no_compiler_messages arm_neon object {
4156 #ifndef __ARM_NEON__
4157 #error not NEON
4158 #else
4159 int dummy;
4160 #endif
4162 } else {
4163 return 0
4167 proc check_effective_target_arm_neonv2 { } {
4168 if { [check_effective_target_arm32] } {
4169 return [check_no_compiler_messages arm_neon object {
4170 #ifndef __ARM_NEON__
4171 #error not NEON
4172 #else
4173 #ifndef __ARM_FEATURE_FMA
4174 #error not NEONv2
4175 #else
4176 int dummy;
4177 #endif
4178 #endif
4180 } else {
4181 return 0
4185 # Return 1 if this is an ARM target with load acquire and store release
4186 # instructions for 8-, 16- and 32-bit types.
4188 proc check_effective_target_arm_acq_rel { } {
4189 return [check_no_compiler_messages arm_acq_rel object {
4190 void
4191 load_acquire_store_release (void)
4193 asm ("lda r0, [r1]\n\t"
4194 "stl r0, [r1]\n\t"
4195 "ldah r0, [r1]\n\t"
4196 "stlh r0, [r1]\n\t"
4197 "ldab r0, [r1]\n\t"
4198 "stlb r0, [r1]"
4199 : : : "r0", "memory");
4204 # Add the options needed for MIPS Paired-Single.
4206 proc add_options_for_mpaired_single { flags } {
4207 if { ! [check_effective_target_mpaired_single] } {
4208 return "$flags"
4210 return "$flags -mpaired-single"
4213 # Add the options needed for MIPS SIMD Architecture.
4215 proc add_options_for_mips_msa { flags } {
4216 if { ! [check_effective_target_mips_msa] } {
4217 return "$flags"
4219 return "$flags -mmsa"
4222 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
4223 # the Loongson vector modes.
4225 proc check_effective_target_mips_loongson { } {
4226 return [check_no_compiler_messages loongson assembly {
4227 #if !defined(__mips_loongson_vector_rev)
4228 #error !__mips_loongson_vector_rev
4229 #endif
4233 # Return 1 if this is a MIPS target that supports the legacy NAN.
4235 proc check_effective_target_mips_nanlegacy { } {
4236 return [check_no_compiler_messages nanlegacy assembly {
4237 #include <stdlib.h>
4238 int main () { return 0; }
4239 } "-mnan=legacy"]
4242 # Return 1 if an MSA program can be compiled to object
4244 proc check_effective_target_mips_msa { } {
4245 if ![check_effective_target_nomips16] {
4246 return 0
4248 return [check_no_compiler_messages msa object {
4249 #if !defined(__mips_msa)
4250 #error "MSA NOT AVAIL"
4251 #else
4252 #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
4253 #error "MSA NOT AVAIL FOR ISA REV < 2"
4254 #endif
4255 #if !defined(__mips_hard_float)
4256 #error "MSA HARD_FLOAT REQUIRED"
4257 #endif
4258 #if __mips_fpr != 64
4259 #error "MSA 64-bit FPR REQUIRED"
4260 #endif
4261 #include <msa.h>
4263 int main()
4265 v8i16 v = __builtin_msa_ldi_h (1);
4267 return v[0];
4269 #endif
4270 } "-mmsa" ]
4273 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
4274 # Architecture.
4276 proc check_effective_target_arm_eabi { } {
4277 return [check_no_compiler_messages arm_eabi object {
4278 #ifndef __ARM_EABI__
4279 #error not EABI
4280 #else
4281 int dummy;
4282 #endif
4286 # Return 1 if this is an ARM target that adheres to the hard-float variant of
4287 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
4289 proc check_effective_target_arm_hf_eabi { } {
4290 return [check_no_compiler_messages arm_hf_eabi object {
4291 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
4292 #error not hard-float EABI
4293 #else
4294 int dummy;
4295 #endif
4299 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
4300 # Some multilibs may be incompatible with this option.
4302 proc check_effective_target_arm_iwmmxt_ok { } {
4303 if { [check_effective_target_arm32] } {
4304 return [check_no_compiler_messages arm_iwmmxt_ok object {
4305 int dummy;
4306 } "-mcpu=iwmmxt"]
4307 } else {
4308 return 0
4312 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
4313 # for an ARM target.
4314 proc check_effective_target_arm_prefer_ldrd_strd { } {
4315 if { ![check_effective_target_arm32] } {
4316 return 0;
4319 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
4320 void foo (int *p) { p[0] = 1; p[1] = 0;}
4321 } "-O2 -mthumb" ]
4324 # Return 1 if this is a PowerPC target supporting -meabi.
4326 proc check_effective_target_powerpc_eabi_ok { } {
4327 if { [istarget powerpc*-*-*] } {
4328 return [check_no_compiler_messages powerpc_eabi_ok object {
4329 int dummy;
4330 } "-meabi"]
4331 } else {
4332 return 0
4336 # Return 1 if this is a PowerPC target with floating-point registers.
4338 proc check_effective_target_powerpc_fprs { } {
4339 if { [istarget powerpc*-*-*]
4340 || [istarget rs6000-*-*] } {
4341 return [check_no_compiler_messages powerpc_fprs object {
4342 #ifdef __NO_FPRS__
4343 #error no FPRs
4344 #else
4345 int dummy;
4346 #endif
4348 } else {
4349 return 0
4353 # Return 1 if this is a PowerPC target with hardware double-precision
4354 # floating point.
4356 proc check_effective_target_powerpc_hard_double { } {
4357 if { [istarget powerpc*-*-*]
4358 || [istarget rs6000-*-*] } {
4359 return [check_no_compiler_messages powerpc_hard_double object {
4360 #ifdef _SOFT_DOUBLE
4361 #error soft double
4362 #else
4363 int dummy;
4364 #endif
4366 } else {
4367 return 0
4371 # Return 1 if this is a PowerPC target supporting -maltivec.
4373 proc check_effective_target_powerpc_altivec_ok { } {
4374 if { ([istarget powerpc*-*-*]
4375 && ![istarget powerpc-*-linux*paired*])
4376 || [istarget rs6000-*-*] } {
4377 # AltiVec is not supported on AIX before 5.3.
4378 if { [istarget powerpc*-*-aix4*]
4379 || [istarget powerpc*-*-aix5.1*]
4380 || [istarget powerpc*-*-aix5.2*] } {
4381 return 0
4383 return [check_no_compiler_messages powerpc_altivec_ok object {
4384 int dummy;
4385 } "-maltivec"]
4386 } else {
4387 return 0
4391 # Return 1 if this is a PowerPC target supporting -mpower8-vector
4393 proc check_effective_target_powerpc_p8vector_ok { } {
4394 if { ([istarget powerpc*-*-*]
4395 && ![istarget powerpc-*-linux*paired*])
4396 || [istarget rs6000-*-*] } {
4397 # AltiVec is not supported on AIX before 5.3.
4398 if { [istarget powerpc*-*-aix4*]
4399 || [istarget powerpc*-*-aix5.1*]
4400 || [istarget powerpc*-*-aix5.2*] } {
4401 return 0
4403 return [check_no_compiler_messages powerpc_p8vector_ok object {
4404 int main (void) {
4405 #ifdef __MACH__
4406 asm volatile ("xxlorc vs0,vs0,vs0");
4407 #else
4408 asm volatile ("xxlorc 0,0,0");
4409 #endif
4410 return 0;
4412 } "-mpower8-vector"]
4413 } else {
4414 return 0
4418 # Return 1 if this is a PowerPC target supporting -mpower9-vector
4420 proc check_effective_target_powerpc_p9vector_ok { } {
4421 if { ([istarget powerpc*-*-*]
4422 && ![istarget powerpc-*-linux*paired*])
4423 || [istarget rs6000-*-*] } {
4424 # AltiVec is not supported on AIX before 5.3.
4425 if { [istarget powerpc*-*-aix4*]
4426 || [istarget powerpc*-*-aix5.1*]
4427 || [istarget powerpc*-*-aix5.2*] } {
4428 return 0
4430 return [check_no_compiler_messages powerpc_p9vector_ok object {
4431 int main (void) {
4432 long e = -1;
4433 vector double v = (vector double) { 0.0, 0.0 };
4434 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
4435 return e;
4437 } "-mpower9-vector"]
4438 } else {
4439 return 0
4443 # Return 1 if this is a PowerPC target supporting -mmodulo
4445 proc check_effective_target_powerpc_p9modulo_ok { } {
4446 if { ([istarget powerpc*-*-*]
4447 && ![istarget powerpc-*-linux*paired*])
4448 || [istarget rs6000-*-*] } {
4449 # AltiVec is not supported on AIX before 5.3.
4450 if { [istarget powerpc*-*-aix4*]
4451 || [istarget powerpc*-*-aix5.1*]
4452 || [istarget powerpc*-*-aix5.2*] } {
4453 return 0
4455 return [check_no_compiler_messages powerpc_p9modulo_ok object {
4456 int main (void) {
4457 int i = 5, j = 3, r = -1;
4458 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
4459 return (r == 2);
4461 } "-mmodulo"]
4462 } else {
4463 return 0
4467 # Return 1 if this is a PowerPC target supporting -mfloat128 via either
4468 # software emulation on power7/power8 systems or hardware support on power9.
4470 proc check_effective_target_powerpc_float128_sw_ok { } {
4471 if { ([istarget powerpc*-*-*]
4472 && ![istarget powerpc-*-linux*paired*])
4473 || [istarget rs6000-*-*] } {
4474 # AltiVec is not supported on AIX before 5.3.
4475 if { [istarget powerpc*-*-aix4*]
4476 || [istarget powerpc*-*-aix5.1*]
4477 || [istarget powerpc*-*-aix5.2*] } {
4478 return 0
4480 return [check_no_compiler_messages powerpc_float128_sw_ok object {
4481 volatile __float128 x = 1.0q;
4482 volatile __float128 y = 2.0q;
4483 int main() {
4484 __float128 z = x + y;
4485 return (z == 3.0q);
4487 } "-mfloat128 -mvsx"]
4488 } else {
4489 return 0
4493 # Return 1 if this is a PowerPC target supporting -mfloat128 via hardware
4494 # support on power9.
4496 proc check_effective_target_powerpc_float128_hw_ok { } {
4497 if { ([istarget powerpc*-*-*]
4498 && ![istarget powerpc-*-linux*paired*])
4499 || [istarget rs6000-*-*] } {
4500 # AltiVec is not supported on AIX before 5.3.
4501 if { [istarget powerpc*-*-aix4*]
4502 || [istarget powerpc*-*-aix5.1*]
4503 || [istarget powerpc*-*-aix5.2*] } {
4504 return 0
4506 return [check_no_compiler_messages powerpc_float128_hw_ok object {
4507 volatile __float128 x = 1.0q;
4508 volatile __float128 y = 2.0q;
4509 int main() {
4510 __float128 z;
4511 __asm__ ("xsaddqp %0,%1,%2" : "=v" (z) : "v" (x), "v" (y));
4512 return (z == 3.0q);
4514 } "-mfloat128-hardware"]
4515 } else {
4516 return 0
4520 # Return 1 if this is a PowerPC target supporting -mvsx
4522 proc check_effective_target_powerpc_vsx_ok { } {
4523 if { ([istarget powerpc*-*-*]
4524 && ![istarget powerpc-*-linux*paired*])
4525 || [istarget rs6000-*-*] } {
4526 # VSX is not supported on AIX before 7.1.
4527 if { [istarget powerpc*-*-aix4*]
4528 || [istarget powerpc*-*-aix5*]
4529 || [istarget powerpc*-*-aix6*] } {
4530 return 0
4532 return [check_no_compiler_messages powerpc_vsx_ok object {
4533 int main (void) {
4534 #ifdef __MACH__
4535 asm volatile ("xxlor vs0,vs0,vs0");
4536 #else
4537 asm volatile ("xxlor 0,0,0");
4538 #endif
4539 return 0;
4541 } "-mvsx"]
4542 } else {
4543 return 0
4547 # Return 1 if this is a PowerPC target supporting -mhtm
4549 proc check_effective_target_powerpc_htm_ok { } {
4550 if { ([istarget powerpc*-*-*]
4551 && ![istarget powerpc-*-linux*paired*])
4552 || [istarget rs6000-*-*] } {
4553 # HTM is not supported on AIX yet.
4554 if { [istarget powerpc*-*-aix*] } {
4555 return 0
4557 return [check_no_compiler_messages powerpc_htm_ok object {
4558 int main (void) {
4559 asm volatile ("tbegin. 0");
4560 return 0;
4562 } "-mhtm"]
4563 } else {
4564 return 0
4568 # Return 1 if the target supports executing HTM hardware instructions,
4569 # 0 otherwise. Cache the result.
4571 proc check_htm_hw_available { } {
4572 return [check_cached_effective_target htm_hw_available {
4573 # For now, disable on Darwin
4574 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
4575 expr 0
4576 } else {
4577 check_runtime_nocache htm_hw_available {
4578 int main()
4580 __builtin_ttest ();
4581 return 0;
4583 } "-mhtm"
4587 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
4589 proc check_effective_target_powerpc_ppu_ok { } {
4590 if [check_effective_target_powerpc_altivec_ok] {
4591 return [check_no_compiler_messages cell_asm_available object {
4592 int main (void) {
4593 #ifdef __MACH__
4594 asm volatile ("lvlx v0,v0,v0");
4595 #else
4596 asm volatile ("lvlx 0,0,0");
4597 #endif
4598 return 0;
4601 } else {
4602 return 0
4606 # Return 1 if this is a PowerPC target that supports SPU.
4608 proc check_effective_target_powerpc_spu { } {
4609 if { [istarget powerpc*-*-linux*] } {
4610 return [check_effective_target_powerpc_altivec_ok]
4611 } else {
4612 return 0
4616 # Return 1 if this is a PowerPC SPE target. The check includes options
4617 # specified by dg-options for this test, so don't cache the result.
4619 proc check_effective_target_powerpc_spe_nocache { } {
4620 if { [istarget powerpc*-*-*] } {
4621 return [check_no_compiler_messages_nocache powerpc_spe object {
4622 #ifndef __SPE__
4623 #error not SPE
4624 #else
4625 int dummy;
4626 #endif
4627 } [current_compiler_flags]]
4628 } else {
4629 return 0
4633 # Return 1 if this is a PowerPC target with SPE enabled.
4635 proc check_effective_target_powerpc_spe { } {
4636 if { [istarget powerpc*-*-*] } {
4637 return [check_no_compiler_messages powerpc_spe object {
4638 #ifndef __SPE__
4639 #error not SPE
4640 #else
4641 int dummy;
4642 #endif
4644 } else {
4645 return 0
4649 # Return 1 if this is a PowerPC target with Altivec enabled.
4651 proc check_effective_target_powerpc_altivec { } {
4652 if { [istarget powerpc*-*-*] } {
4653 return [check_no_compiler_messages powerpc_altivec object {
4654 #ifndef __ALTIVEC__
4655 #error not Altivec
4656 #else
4657 int dummy;
4658 #endif
4660 } else {
4661 return 0
4665 # Return 1 if this is a PowerPC 405 target. The check includes options
4666 # specified by dg-options for this test, so don't cache the result.
4668 proc check_effective_target_powerpc_405_nocache { } {
4669 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
4670 return [check_no_compiler_messages_nocache powerpc_405 object {
4671 #ifdef __PPC405__
4672 int dummy;
4673 #else
4674 #error not a PPC405
4675 #endif
4676 } [current_compiler_flags]]
4677 } else {
4678 return 0
4682 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
4684 proc check_effective_target_powerpc_elfv2 { } {
4685 if { [istarget powerpc*-*-*] } {
4686 return [check_no_compiler_messages powerpc_elfv2 object {
4687 #if _CALL_ELF != 2
4688 #error not ELF v2 ABI
4689 #else
4690 int dummy;
4691 #endif
4693 } else {
4694 return 0
4698 # Return 1 if this is a SPU target with a toolchain that
4699 # supports automatic overlay generation.
4701 proc check_effective_target_spu_auto_overlay { } {
4702 if { [istarget spu*-*-elf*] } {
4703 return [check_no_compiler_messages spu_auto_overlay executable {
4704 int main (void) { }
4705 } "-Wl,--auto-overlay" ]
4706 } else {
4707 return 0
4711 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
4712 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
4713 # test environment appears to run executables on such a simulator.
4715 proc check_effective_target_ultrasparc_hw { } {
4716 return [check_runtime ultrasparc_hw {
4717 int main() { return 0; }
4718 } "-mcpu=ultrasparc"]
4721 # Return 1 if the test environment supports executing UltraSPARC VIS2
4722 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
4724 proc check_effective_target_ultrasparc_vis2_hw { } {
4725 return [check_runtime ultrasparc_vis2_hw {
4726 int main() { __asm__(".word 0x81b00320"); return 0; }
4727 } "-mcpu=ultrasparc3"]
4730 # Return 1 if the test environment supports executing UltraSPARC VIS3
4731 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
4733 proc check_effective_target_ultrasparc_vis3_hw { } {
4734 return [check_runtime ultrasparc_vis3_hw {
4735 int main() { __asm__(".word 0x81b00220"); return 0; }
4736 } "-mcpu=niagara3"]
4739 # Return 1 if this is a SPARC-V9 target.
4741 proc check_effective_target_sparc_v9 { } {
4742 if { [istarget sparc*-*-*] } {
4743 return [check_no_compiler_messages sparc_v9 object {
4744 int main (void) {
4745 asm volatile ("return %i7+8");
4746 return 0;
4749 } else {
4750 return 0
4754 # Return 1 if this is a SPARC target with VIS enabled.
4756 proc check_effective_target_sparc_vis { } {
4757 if { [istarget sparc*-*-*] } {
4758 return [check_no_compiler_messages sparc_vis object {
4759 #ifndef __VIS__
4760 #error not VIS
4761 #else
4762 int dummy;
4763 #endif
4765 } else {
4766 return 0
4770 # Return 1 if the target supports hardware vector shift operation.
4772 proc check_effective_target_vect_shift { } {
4773 global et_vect_shift_saved
4774 global et_index
4776 if [info exists et_vect_shift_saved($et_index)] {
4777 verbose "check_effective_target_vect_shift: using cached result" 2
4778 } else {
4779 set et_vect_shift_saved($et_index) 0
4780 if { ([istarget powerpc*-*-*]
4781 && ![istarget powerpc-*-linux*paired*])
4782 || [istarget ia64-*-*]
4783 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4784 || [istarget aarch64*-*-*]
4785 || [check_effective_target_arm32]
4786 || ([istarget mips*-*-*]
4787 && ([et-is-effective-target mips_msa]
4788 || [et-is-effective-target mips_loongson])) } {
4789 set et_vect_shift_saved($et_index) 1
4793 verbose "check_effective_target_vect_shift:\
4794 returning $et_vect_shift_saved($et_index)" 2
4795 return $et_vect_shift_saved($et_index)
4798 proc check_effective_target_whole_vector_shift { } {
4799 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4800 || [istarget ia64-*-*]
4801 || [istarget aarch64*-*-*]
4802 || [istarget powerpc64*-*-*]
4803 || ([check_effective_target_arm32]
4804 && [check_effective_target_arm_little_endian])
4805 || ([istarget mips*-*-*]
4806 && [et-is-effective-target mips_loongson]) } {
4807 set answer 1
4808 } else {
4809 set answer 0
4812 verbose "check_effective_target_vect_long: returning $answer" 2
4813 return $answer
4816 # Return 1 if the target supports vector bswap operations.
4818 proc check_effective_target_vect_bswap { } {
4819 global et_vect_bswap_saved
4820 global et_index
4822 if [info exists et_vect_bswap_saved($et_index)] {
4823 verbose "check_effective_target_vect_bswap: using cached result" 2
4824 } else {
4825 set et_vect_bswap_saved($et_index) 0
4826 if { [istarget aarch64*-*-*]
4827 || ([istarget arm*-*-*]
4828 && [check_effective_target_arm_neon])
4830 set et_vect_bswap_saved($et_index) 1
4834 verbose "check_effective_target_vect_bswap:\
4835 returning $et_vect_bswap_saved($et_index)" 2
4836 return $et_vect_bswap_saved($et_index)
4839 # Return 1 if the target supports hardware vector shift operation for char.
4841 proc check_effective_target_vect_shift_char { } {
4842 global et_vect_shift_char_saved
4843 global et_index
4845 if [info exists et_vect_shift_char_saved($et_index)] {
4846 verbose "check_effective_target_vect_shift_char: using cached result" 2
4847 } else {
4848 set et_vect_shift_char_saved($et_index) 0
4849 if { ([istarget powerpc*-*-*]
4850 && ![istarget powerpc-*-linux*paired*])
4851 || [check_effective_target_arm32]
4852 || ([istarget mips*-*-*]
4853 && [et-is-effective-target mips_msa]) } {
4854 set et_vect_shift_char_saved($et_index) 1
4858 verbose "check_effective_target_vect_shift_char:\
4859 returning $et_vect_shift_char_saved($et_index)" 2
4860 return $et_vect_shift_char_saved($et_index)
4863 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
4865 # This can change for different subtargets so do not cache the result.
4867 proc check_effective_target_vect_long { } {
4868 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4869 || (([istarget powerpc*-*-*]
4870 && ![istarget powerpc-*-linux*paired*])
4871 && [check_effective_target_ilp32])
4872 || [check_effective_target_arm32]
4873 || ([istarget sparc*-*-*] && [check_effective_target_ilp32])
4874 || [istarget aarch64*-*-*]
4875 || ([istarget mips*-*-*]
4876 && [et-is-effective-target mips_msa]) } {
4877 set answer 1
4878 } else {
4879 set answer 0
4882 verbose "check_effective_target_vect_long: returning $answer" 2
4883 return $answer
4886 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
4888 # This won't change for different subtargets so cache the result.
4890 proc check_effective_target_vect_float { } {
4891 global et_vect_float_saved
4892 global et_index
4894 if [info exists et_vect_float_saved($et_index)] {
4895 verbose "check_effective_target_vect_float: using cached result" 2
4896 } else {
4897 set et_vect_float_saved($et_index) 0
4898 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4899 || [istarget powerpc*-*-*]
4900 || [istarget spu-*-*]
4901 || [istarget mips-sde-elf]
4902 || [istarget mipsisa64*-*-*]
4903 || [istarget ia64-*-*]
4904 || [istarget aarch64*-*-*]
4905 || ([istarget mips*-*-*]
4906 && [et-is-effective-target mips_msa])
4907 || [check_effective_target_arm32] } {
4908 set et_vect_float_saved($et_index) 1
4912 verbose "check_effective_target_vect_float:\
4913 returning $et_vect_float_saved($et_index)" 2
4914 return $et_vect_float_saved($et_index)
4917 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
4919 # This won't change for different subtargets so cache the result.
4921 proc check_effective_target_vect_double { } {
4922 global et_vect_double_saved
4923 global et_index
4925 if [info exists et_vect_double_saved($et_index)] {
4926 verbose "check_effective_target_vect_double: using cached result" 2
4927 } else {
4928 set et_vect_double_saved($et_index) 0
4929 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4930 || [istarget aarch64*-*-*] } {
4931 if { [check_no_compiler_messages vect_double assembly {
4932 #ifdef __tune_atom__
4933 # error No double vectorizer support.
4934 #endif
4935 }] } {
4936 set et_vect_double_saved($et_index) 1
4937 } else {
4938 set et_vect_double_saved($et_index) 0
4940 } elseif { [istarget spu-*-*]
4941 || ([istarget powerpc*-*-*] && [check_vsx_hw_available])
4942 || ([istarget mips*-*-*]
4943 && [et-is-effective-target mips_msa]) } {
4944 set et_vect_double_saved($et_index) 1
4948 verbose "check_effective_target_vect_double:\
4949 returning $et_vect_double_saved($et_index)" 2
4950 return $et_vect_double_saved($et_index)
4953 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
4955 # This won't change for different subtargets so cache the result.
4957 proc check_effective_target_vect_long_long { } {
4958 global et_vect_long_long_saved
4959 global et_index
4961 if [info exists et_vect_long_long_saved($et_index)] {
4962 verbose "check_effective_target_vect_long_long: using cached result" 2
4963 } else {
4964 set et_vect_long_long_saved($et_index) 0
4965 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4966 || ([istarget mips*-*-*]
4967 && [et-is-effective-target mips_msa]) } {
4968 set et_vect_long_long_saved($et_index) 1
4972 verbose "check_effective_target_vect_long_long:\
4973 returning $et_vect_long_long_saved($et_index)" 2
4974 return $et_vect_long_long_saved($et_index)
4978 # Return 1 if the target plus current options does not support a vector
4979 # max instruction on "int", 0 otherwise.
4981 # This won't change for different subtargets so cache the result.
4983 proc check_effective_target_vect_no_int_min_max { } {
4984 global et_vect_no_int_min_max_saved
4985 global et_index
4987 if [info exists et_vect_no_int_min_max_saved($et_index)] {
4988 verbose "check_effective_target_vect_no_int_min_max:\
4989 using cached result" 2
4990 } else {
4991 set et_vect_no_int_min_max_saved($et_index) 0
4992 if { [istarget sparc*-*-*]
4993 || [istarget spu-*-*]
4994 || [istarget alpha*-*-*]
4995 || ([istarget mips*-*-*]
4996 && [et-is-effective-target mips_loongson]) } {
4997 set et_vect_no_int_min_max_saved($et_index) 1
5000 verbose "check_effective_target_vect_no_int_min_max:\
5001 returning $et_vect_no_int_min_max_saved($et_index)" 2
5002 return $et_vect_no_int_min_max_saved($et_index)
5005 # Return 1 if the target plus current options does not support a vector
5006 # add instruction on "int", 0 otherwise.
5008 # This won't change for different subtargets so cache the result.
5010 proc check_effective_target_vect_no_int_add { } {
5011 global et_vect_no_int_add_saved
5012 global et_index
5014 if [info exists et_vect_no_int_add_saved($et_index)] {
5015 verbose "check_effective_target_vect_no_int_add: using cached result" 2
5016 } else {
5017 set et_vect_no_int_add_saved($et_index) 0
5018 # Alpha only supports vector add on V8QI and V4HI.
5019 if { [istarget alpha*-*-*] } {
5020 set et_vect_no_int_add_saved($et_index) 1
5023 verbose "check_effective_target_vect_no_int_add:\
5024 returning $et_vect_no_int_add_saved($et_index)" 2
5025 return $et_vect_no_int_add_saved($et_index)
5028 # Return 1 if the target plus current options does not support vector
5029 # bitwise instructions, 0 otherwise.
5031 # This won't change for different subtargets so cache the result.
5033 proc check_effective_target_vect_no_bitwise { } {
5034 global et_vect_no_bitwise_saved
5035 global et_index
5037 if [info exists et_vect_no_bitwise_saved($et_index)] {
5038 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
5039 } else {
5040 set et_vect_no_bitwise_saved($et_index) 0
5042 verbose "check_effective_target_vect_no_bitwise:\
5043 returning $et_vect_no_bitwise_saved($et_index)" 2
5044 return $et_vect_no_bitwise_saved($et_index)
5047 # Return 1 if the target plus current options supports vector permutation,
5048 # 0 otherwise.
5050 # This won't change for different subtargets so cache the result.
5052 proc check_effective_target_vect_perm { } {
5053 global et_vect_perm_saved
5054 global et_index
5056 if [info exists et_vect_perm_saved($et_index)] {
5057 verbose "check_effective_target_vect_perm: using cached result" 2
5058 } else {
5059 set et_vect_perm_saved($et_index) 0
5060 if { [is-effective-target arm_neon_ok]
5061 || [istarget aarch64*-*-*]
5062 || [istarget powerpc*-*-*]
5063 || [istarget spu-*-*]
5064 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5065 || ([istarget mips*-*-*]
5066 && ([et-is-effective-target mpaired_single]
5067 || [et-is-effective-target mips_msa])) } {
5068 set et_vect_perm_saved($et_index) 1
5071 verbose "check_effective_target_vect_perm:\
5072 returning $et_vect_perm_saved($et_index)" 2
5073 return $et_vect_perm_saved($et_index)
5076 # Return 1 if the target plus current options supports vector permutation
5077 # on byte-sized elements, 0 otherwise.
5079 # This won't change for different subtargets so cache the result.
5081 proc check_effective_target_vect_perm_byte { } {
5082 global et_vect_perm_byte_saved
5083 global et_index
5085 if [info exists et_vect_perm_byte_saved($et_index)] {
5086 verbose "check_effective_target_vect_perm_byte: using cached result" 2
5087 } else {
5088 set et_vect_perm_byte_saved($et_index) 0
5089 if { ([is-effective-target arm_neon_ok]
5090 && [is-effective-target arm_little_endian])
5091 || ([istarget aarch64*-*-*]
5092 && [is-effective-target aarch64_little_endian])
5093 || [istarget powerpc*-*-*]
5094 || [istarget spu-*-*]
5095 || ([istarget mips-*.*]
5096 && [et-is-effective-target mips_msa]) } {
5097 set et_vect_perm_byte_saved($et_index) 1
5100 verbose "check_effective_target_vect_perm_byte:\
5101 returning $et_vect_perm_byte_saved($et_index)" 2
5102 return $et_vect_perm_byte_saved($et_index)
5105 # Return 1 if the target plus current options supports vector permutation
5106 # on short-sized elements, 0 otherwise.
5108 # This won't change for different subtargets so cache the result.
5110 proc check_effective_target_vect_perm_short { } {
5111 global et_vect_perm_short_saved
5112 global et_index
5114 if [info exists et_vect_perm_short_saved($et_index)] {
5115 verbose "check_effective_target_vect_perm_short: using cached result" 2
5116 } else {
5117 set et_vect_perm_short_saved($et_index) 0
5118 if { ([is-effective-target arm_neon_ok]
5119 && [is-effective-target arm_little_endian])
5120 || ([istarget aarch64*-*-*]
5121 && [is-effective-target aarch64_little_endian])
5122 || [istarget powerpc*-*-*]
5123 || [istarget spu-*-*]
5124 || ([istarget mips*-*-*]
5125 && [et-is-effective-target mips_msa]) } {
5126 set et_vect_perm_short_saved($et_index) 1
5129 verbose "check_effective_target_vect_perm_short:\
5130 returning $et_vect_perm_short_saved($et_index)" 2
5131 return $et_vect_perm_short_saved($et_index)
5134 # Return 1 if the target plus current options supports a vector
5135 # widening summation of *short* args into *int* result, 0 otherwise.
5137 # This won't change for different subtargets so cache the result.
5139 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
5140 global et_vect_widen_sum_hi_to_si_pattern_saved
5141 global et_index
5143 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved($et_index)] {
5144 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern:\
5145 using cached result" 2
5146 } else {
5147 set et_vect_widen_sum_hi_to_si_pattern_saved($et_index) 0
5148 if { [istarget powerpc*-*-*]
5149 || [istarget aarch64*-*-*]
5150 || ([istarget arm*-*-*] &&
5151 [check_effective_target_arm_neon_ok])
5152 || [istarget ia64-*-*] } {
5153 set et_vect_widen_sum_hi_to_si_pattern_saved($et_index) 1
5156 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern:\
5157 returning $et_vect_widen_sum_hi_to_si_pattern_saved($et_index)" 2
5158 return $et_vect_widen_sum_hi_to_si_pattern_saved($et_index)
5161 # Return 1 if the target plus current options supports a vector
5162 # widening summation of *short* args into *int* result, 0 otherwise.
5163 # A target can also support this widening summation if it can support
5164 # promotion (unpacking) from shorts to ints.
5166 # This won't change for different subtargets so cache the result.
5168 proc check_effective_target_vect_widen_sum_hi_to_si { } {
5169 global et_vect_widen_sum_hi_to_si_saved
5170 global et_index
5172 if [info exists et_vect_widen_sum_hi_to_si_saved($et_index)] {
5173 verbose "check_effective_target_vect_widen_sum_hi_to_si:\
5174 using cached result" 2
5175 } else {
5176 set et_vect_widen_sum_hi_to_si_saved($et_index) \
5177 [check_effective_target_vect_unpack]
5178 if { [istarget powerpc*-*-*]
5179 || [istarget ia64-*-*] } {
5180 set et_vect_widen_sum_hi_to_si_saved($et_index) 1
5183 verbose "check_effective_target_vect_widen_sum_hi_to_si:\
5184 returning $et_vect_widen_sum_hi_to_si_saved($et_index)" 2
5185 return $et_vect_widen_sum_hi_to_si_saved($et_index)
5188 # Return 1 if the target plus current options supports a vector
5189 # widening summation of *char* args into *short* result, 0 otherwise.
5190 # A target can also support this widening summation if it can support
5191 # promotion (unpacking) from chars to shorts.
5193 # This won't change for different subtargets so cache the result.
5195 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
5196 global et_vect_widen_sum_qi_to_hi_saved
5197 global et_index
5199 if [info exists et_vect_widen_sum_qi_to_hi_saved($et_index)] {
5200 verbose "check_effective_target_vect_widen_sum_qi_to_hi:\
5201 using cached result" 2
5202 } else {
5203 set et_vect_widen_sum_qi_to_hi_saved($et_index) 0
5204 if { [check_effective_target_vect_unpack]
5205 || [check_effective_target_arm_neon_ok]
5206 || [istarget ia64-*-*] } {
5207 set et_vect_widen_sum_qi_to_hi_saved($et_index) 1
5210 verbose "check_effective_target_vect_widen_sum_qi_to_hi:\
5211 returning $et_vect_widen_sum_qi_to_hi_saved($et_index)" 2
5212 return $et_vect_widen_sum_qi_to_hi_saved($et_index)
5215 # Return 1 if the target plus current options supports a vector
5216 # widening summation of *char* args into *int* result, 0 otherwise.
5218 # This won't change for different subtargets so cache the result.
5220 proc check_effective_target_vect_widen_sum_qi_to_si { } {
5221 global et_vect_widen_sum_qi_to_si_saved
5222 global et_index
5224 if [info exists et_vect_widen_sum_qi_to_si_saved($et_index)] {
5225 verbose "check_effective_target_vect_widen_sum_qi_to_si:\
5226 using cached result" 2
5227 } else {
5228 set et_vect_widen_sum_qi_to_si_saved($et_index) 0
5229 if { [istarget powerpc*-*-*] } {
5230 set et_vect_widen_sum_qi_to_si_saved($et_index) 1
5233 verbose "check_effective_target_vect_widen_sum_qi_to_si:\
5234 returning $et_vect_widen_sum_qi_to_si_saved($et_index)" 2
5235 return $et_vect_widen_sum_qi_to_si_saved($et_index)
5238 # Return 1 if the target plus current options supports a vector
5239 # widening multiplication of *char* args into *short* result, 0 otherwise.
5240 # A target can also support this widening multplication if it can support
5241 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
5242 # multiplication of shorts).
5244 # This won't change for different subtargets so cache the result.
5247 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
5248 global et_vect_widen_mult_qi_to_hi_saved
5249 global et_index
5251 if [info exists et_vect_widen_mult_qi_to_hi_saved($et_index)] {
5252 verbose "check_effective_target_vect_widen_mult_qi_to_hi:\
5253 using cached result" 2
5254 } else {
5255 if { [check_effective_target_vect_unpack]
5256 && [check_effective_target_vect_short_mult] } {
5257 set et_vect_widen_mult_qi_to_hi_saved($et_index) 1
5258 } else {
5259 set et_vect_widen_mult_qi_to_hi_saved($et_index) 0
5261 if { [istarget powerpc*-*-*]
5262 || [istarget aarch64*-*-*]
5263 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
5264 set et_vect_widen_mult_qi_to_hi_saved($et_index) 1
5267 verbose "check_effective_target_vect_widen_mult_qi_to_hi:\
5268 returning $et_vect_widen_mult_qi_to_hi_saved($et_index)" 2
5269 return $et_vect_widen_mult_qi_to_hi_saved($et_index)
5272 # Return 1 if the target plus current options supports a vector
5273 # widening multiplication of *short* args into *int* result, 0 otherwise.
5274 # A target can also support this widening multplication if it can support
5275 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
5276 # multiplication of ints).
5278 # This won't change for different subtargets so cache the result.
5281 proc check_effective_target_vect_widen_mult_hi_to_si { } {
5282 global et_vect_widen_mult_hi_to_si_saved
5283 global et_index
5285 if [info exists et_vect_widen_mult_hi_to_si_saved($et_index)] {
5286 verbose "check_effective_target_vect_widen_mult_hi_to_si:\
5287 using cached result" 2
5288 } else {
5289 if { [check_effective_target_vect_unpack]
5290 && [check_effective_target_vect_int_mult] } {
5291 set et_vect_widen_mult_hi_to_si_saved($et_index) 1
5292 } else {
5293 set et_vect_widen_mult_hi_to_si_saved($et_index) 0
5295 if { [istarget powerpc*-*-*]
5296 || [istarget spu-*-*]
5297 || [istarget ia64-*-*]
5298 || [istarget aarch64*-*-*]
5299 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5300 || ([istarget arm*-*-*]
5301 && [check_effective_target_arm_neon_ok]) } {
5302 set et_vect_widen_mult_hi_to_si_saved($et_index) 1
5305 verbose "check_effective_target_vect_widen_mult_hi_to_si:\
5306 returning $et_vect_widen_mult_hi_to_si_saved($et_index)" 2
5307 return $et_vect_widen_mult_hi_to_si_saved($et_index)
5310 # Return 1 if the target plus current options supports a vector
5311 # widening multiplication of *char* args into *short* result, 0 otherwise.
5313 # This won't change for different subtargets so cache the result.
5315 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
5316 global et_vect_widen_mult_qi_to_hi_pattern_saved
5317 global et_index
5319 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)] {
5320 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern:\
5321 using cached result" 2
5322 } else {
5323 set et_vect_widen_mult_qi_to_hi_pattern_saved($et_index) 0
5324 if { [istarget powerpc*-*-*]
5325 || ([istarget arm*-*-*]
5326 && [check_effective_target_arm_neon_ok]
5327 && [check_effective_target_arm_little_endian]) } {
5328 set et_vect_widen_mult_qi_to_hi_pattern_saved($et_index) 1
5331 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern:\
5332 returning $et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)" 2
5333 return $et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)
5336 # Return 1 if the target plus current options supports a vector
5337 # widening multiplication of *short* args into *int* result, 0 otherwise.
5339 # This won't change for different subtargets so cache the result.
5341 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
5342 global et_vect_widen_mult_hi_to_si_pattern_saved
5343 global et_index
5345 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved($et_index)] {
5346 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern:\
5347 using cached result" 2
5348 } else {
5349 set et_vect_widen_mult_hi_to_si_pattern_saved($et_index) 0
5350 if { [istarget powerpc*-*-*]
5351 || [istarget spu-*-*]
5352 || [istarget ia64-*-*]
5353 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5354 || ([istarget arm*-*-*]
5355 && [check_effective_target_arm_neon_ok]
5356 && [check_effective_target_arm_little_endian]) } {
5357 set et_vect_widen_mult_hi_to_si_pattern_saved($et_index) 1
5360 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern:\
5361 returning $et_vect_widen_mult_hi_to_si_pattern_saved($et_index)" 2
5362 return $et_vect_widen_mult_hi_to_si_pattern_saved($et_index)
5365 # Return 1 if the target plus current options supports a vector
5366 # widening multiplication of *int* args into *long* result, 0 otherwise.
5368 # This won't change for different subtargets so cache the result.
5370 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
5371 global et_vect_widen_mult_si_to_di_pattern_saved
5372 global et_index
5374 if [info exists et_vect_widen_mult_si_to_di_pattern_saved($et_index)] {
5375 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern:\
5376 using cached result" 2
5377 } else {
5378 set et_vect_widen_mult_si_to_di_pattern_saved($et_index) 0
5379 if {[istarget ia64-*-*]
5380 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5381 set et_vect_widen_mult_si_to_di_pattern_saved($et_index) 1
5384 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern:\
5385 returning $et_vect_widen_mult_si_to_di_pattern_saved($et_index)" 2
5386 return $et_vect_widen_mult_si_to_di_pattern_saved($et_index)
5389 # Return 1 if the target plus current options supports a vector
5390 # widening shift, 0 otherwise.
5392 # This won't change for different subtargets so cache the result.
5394 proc check_effective_target_vect_widen_shift { } {
5395 global et_vect_widen_shift_saved
5396 global et_index
5398 if [info exists et_vect_shift_saved($et_index)] {
5399 verbose "check_effective_target_vect_widen_shift: using cached result" 2
5400 } else {
5401 set et_vect_widen_shift_saved($et_index) 0
5402 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
5403 set et_vect_widen_shift_saved($et_index) 1
5406 verbose "check_effective_target_vect_widen_shift:\
5407 returning $et_vect_widen_shift_saved($et_index)" 2
5408 return $et_vect_widen_shift_saved($et_index)
5411 # Return 1 if the target plus current options supports a vector
5412 # dot-product of signed chars, 0 otherwise.
5414 # This won't change for different subtargets so cache the result.
5416 proc check_effective_target_vect_sdot_qi { } {
5417 global et_vect_sdot_qi_saved
5418 global et_index
5420 if [info exists et_vect_sdot_qi_saved($et_index)] {
5421 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
5422 } else {
5423 set et_vect_sdot_qi_saved($et_index) 0
5424 if { [istarget ia64-*-*]
5425 || ([istarget mips*-*-*]
5426 && [et-is-effective-target mips_msa]) } {
5427 set et_vect_udot_qi_saved 1
5430 verbose "check_effective_target_vect_sdot_qi:\
5431 returning $et_vect_sdot_qi_saved($et_index)" 2
5432 return $et_vect_sdot_qi_saved($et_index)
5435 # Return 1 if the target plus current options supports a vector
5436 # dot-product of unsigned chars, 0 otherwise.
5438 # This won't change for different subtargets so cache the result.
5440 proc check_effective_target_vect_udot_qi { } {
5441 global et_vect_udot_qi_saved
5442 global et_index
5444 if [info exists et_vect_udot_qi_saved($et_index)] {
5445 verbose "check_effective_target_vect_udot_qi: using cached result" 2
5446 } else {
5447 set et_vect_udot_qi_saved($et_index) 0
5448 if { [istarget powerpc*-*-*]
5449 || [istarget ia64-*-*]
5450 || ([istarget mips*-*-*]
5451 && [et-is-effective-target mips_msa]) } {
5452 set et_vect_udot_qi_saved($et_index) 1
5455 verbose "check_effective_target_vect_udot_qi:\
5456 returning $et_vect_udot_qi_saved($et_index)" 2
5457 return $et_vect_udot_qi_saved($et_index)
5460 # Return 1 if the target plus current options supports a vector
5461 # dot-product of signed shorts, 0 otherwise.
5463 # This won't change for different subtargets so cache the result.
5465 proc check_effective_target_vect_sdot_hi { } {
5466 global et_vect_sdot_hi_saved
5467 global et_index
5469 if [info exists et_vect_sdot_hi_saved($et_index)] {
5470 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
5471 } else {
5472 set et_vect_sdot_hi_saved($et_index) 0
5473 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5474 || [istarget ia64-*-*]
5475 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5476 || ([istarget mips*-*-*]
5477 && [et-is-effective-target mips_msa]) } {
5478 set et_vect_sdot_hi_saved($et_index) 1
5481 verbose "check_effective_target_vect_sdot_hi:\
5482 returning $et_vect_sdot_hi_saved($et_index)" 2
5483 return $et_vect_sdot_hi_saved($et_index)
5486 # Return 1 if the target plus current options supports a vector
5487 # dot-product of unsigned shorts, 0 otherwise.
5489 # This won't change for different subtargets so cache the result.
5491 proc check_effective_target_vect_udot_hi { } {
5492 global et_vect_udot_hi_saved
5493 global et_index
5495 if [info exists et_vect_udot_hi_saved($et_index)] {
5496 verbose "check_effective_target_vect_udot_hi: using cached result" 2
5497 } else {
5498 set et_vect_udot_hi_saved($et_index) 0
5499 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5500 || ([istarget mips*-*-*]
5501 && [et-is-effective-target mips_msa]) } {
5502 set et_vect_udot_hi_saved($et_index) 1
5505 verbose "check_effective_target_vect_udot_hi:\
5506 returning $et_vect_udot_hi_saved($et_index)" 2
5507 return $et_vect_udot_hi_saved($et_index)
5510 # Return 1 if the target plus current options supports a vector
5511 # sad operation of unsigned chars, 0 otherwise.
5513 # This won't change for different subtargets so cache the result.
5515 proc check_effective_target_vect_usad_char { } {
5516 global et_vect_usad_char_saved
5517 global et_index
5519 if [info exists et_vect_usad_char_saved($et_index)] {
5520 verbose "check_effective_target_vect_usad_char: using cached result" 2
5521 } else {
5522 set et_vect_usad_char_saved($et_index) 0
5523 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
5524 set et_vect_usad_char_saved($et_index) 1
5527 verbose "check_effective_target_vect_usad_char:\
5528 returning $et_vect_usad_char_saved($et_index)" 2
5529 return $et_vect_usad_char_saved($et_index)
5532 # Return 1 if the target plus current options supports a vector
5533 # demotion (packing) of shorts (to chars) and ints (to shorts)
5534 # using modulo arithmetic, 0 otherwise.
5536 # This won't change for different subtargets so cache the result.
5538 proc check_effective_target_vect_pack_trunc { } {
5539 global et_vect_pack_trunc_saved
5540 global et_index
5542 if [info exists et_vect_pack_trunc_saved($et_index)] {
5543 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
5544 } else {
5545 set et_vect_pack_trunc_saved($et_index) 0
5546 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5547 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5548 || [istarget aarch64*-*-*]
5549 || [istarget spu-*-*]
5550 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
5551 && [check_effective_target_arm_little_endian])
5552 || ([istarget mips*-*-*]
5553 && [et-is-effective-target mips_msa]) } {
5554 set et_vect_pack_trunc_saved($et_index) 1
5557 verbose "check_effective_target_vect_pack_trunc:\
5558 returning $et_vect_pack_trunc_saved($et_index)" 2
5559 return $et_vect_pack_trunc_saved($et_index)
5562 # Return 1 if the target plus current options supports a vector
5563 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
5565 # This won't change for different subtargets so cache the result.
5567 proc check_effective_target_vect_unpack { } {
5568 global et_vect_unpack_saved
5569 global et_index
5571 if [info exists et_vect_unpack_saved($et_index)] {
5572 verbose "check_effective_target_vect_unpack: using cached result" 2
5573 } else {
5574 set et_vect_unpack_saved($et_index) 0
5575 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
5576 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5577 || [istarget spu-*-*]
5578 || [istarget ia64-*-*]
5579 || [istarget aarch64*-*-*]
5580 || ([istarget mips*-*-*]
5581 && [et-is-effective-target mips_msa])
5582 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
5583 && [check_effective_target_arm_little_endian]) } {
5584 set et_vect_unpack_saved($et_index) 1
5587 verbose "check_effective_target_vect_unpack:\
5588 returning $et_vect_unpack_saved($et_index)" 2
5589 return $et_vect_unpack_saved($et_index)
5592 # Return 1 if the target plus current options does not guarantee
5593 # that its STACK_BOUNDARY is >= the reguired vector alignment.
5595 # This won't change for different subtargets so cache the result.
5597 proc check_effective_target_unaligned_stack { } {
5598 global et_unaligned_stack_saved
5600 if [info exists et_unaligned_stack_saved] {
5601 verbose "check_effective_target_unaligned_stack: using cached result" 2
5602 } else {
5603 set et_unaligned_stack_saved 0
5605 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
5606 return $et_unaligned_stack_saved
5609 # Return 1 if the target plus current options does not support a vector
5610 # alignment mechanism, 0 otherwise.
5612 # This won't change for different subtargets so cache the result.
5614 proc check_effective_target_vect_no_align { } {
5615 global et_vect_no_align_saved
5616 global et_index
5618 if [info exists et_vect_no_align_saved($et_index)] {
5619 verbose "check_effective_target_vect_no_align: using cached result" 2
5620 } else {
5621 set et_vect_no_align_saved($et_index) 0
5622 if { [istarget mipsisa64*-*-*]
5623 || [istarget mips-sde-elf]
5624 || [istarget sparc*-*-*]
5625 || [istarget ia64-*-*]
5626 || [check_effective_target_arm_vect_no_misalign]
5627 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
5628 || ([istarget mips*-*-*]
5629 && [et-is-effective-target mips_loongson]) } {
5630 set et_vect_no_align_saved($et_index) 1
5633 verbose "check_effective_target_vect_no_align:\
5634 returning $et_vect_no_align_saved($et_index)" 2
5635 return $et_vect_no_align_saved($et_index)
5638 # Return 1 if the target supports a vector misalign access, 0 otherwise.
5640 # This won't change for different subtargets so cache the result.
5642 proc check_effective_target_vect_hw_misalign { } {
5643 global et_vect_hw_misalign_saved
5644 global et_index
5646 if [info exists et_vect_hw_misalign_saved($et_index)] {
5647 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
5648 } else {
5649 set et_vect_hw_misalign_saved($et_index) 0
5650 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5651 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
5652 || [istarget aarch64*-*-*]
5653 || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) } {
5654 set et_vect_hw_misalign_saved($et_index) 1
5657 verbose "check_effective_target_vect_hw_misalign:\
5658 returning $et_vect_hw_misalign_saved($et_index)" 2
5659 return $et_vect_hw_misalign_saved($et_index)
5663 # Return 1 if arrays are aligned to the vector alignment
5664 # boundary, 0 otherwise.
5666 proc check_effective_target_vect_aligned_arrays { } {
5667 set et_vect_aligned_arrays 0
5668 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
5669 if { ([is-effective-target lp64]
5670 && ( ![check_avx_available]
5671 || [check_prefer_avx128])) } {
5672 set et_vect_aligned_arrays 1
5675 if [istarget spu-*-*] {
5676 set et_vect_aligned_arrays 1
5678 verbose "check_effective_target_vect_aligned_arrays:\
5679 returning $et_vect_aligned_arrays" 2
5680 return $et_vect_aligned_arrays
5683 # Return 1 if types of size 32 bit or less are naturally aligned
5684 # (aligned to their type-size), 0 otherwise.
5686 # This won't change for different subtargets so cache the result.
5688 proc check_effective_target_natural_alignment_32 { } {
5689 global et_natural_alignment_32
5691 if [info exists et_natural_alignment_32_saved] {
5692 verbose "check_effective_target_natural_alignment_32: using cached result" 2
5693 } else {
5694 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
5695 set et_natural_alignment_32_saved 1
5696 if { ([istarget *-*-darwin*] && [is-effective-target lp64])
5697 || [istarget avr-*-*] } {
5698 set et_natural_alignment_32_saved 0
5701 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
5702 return $et_natural_alignment_32_saved
5705 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
5706 # type-size), 0 otherwise.
5708 # This won't change for different subtargets so cache the result.
5710 proc check_effective_target_natural_alignment_64 { } {
5711 global et_natural_alignment_64
5713 if [info exists et_natural_alignment_64_saved] {
5714 verbose "check_effective_target_natural_alignment_64: using cached result" 2
5715 } else {
5716 set et_natural_alignment_64_saved 0
5717 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
5718 || [istarget spu-*-*] } {
5719 set et_natural_alignment_64_saved 1
5722 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
5723 return $et_natural_alignment_64_saved
5726 # Return 1 if all vector types are naturally aligned (aligned to their
5727 # type-size), 0 otherwise.
5729 proc check_effective_target_vect_natural_alignment { } {
5730 set et_vect_natural_alignment 1
5731 if { [check_effective_target_arm_eabi]
5732 || [istarget nvptx-*-*]
5733 || [istarget s390*-*-*] } {
5734 set et_vect_natural_alignment 0
5736 verbose "check_effective_target_vect_natural_alignment:\
5737 returning $et_vect_natural_alignment" 2
5738 return $et_vect_natural_alignment
5741 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
5743 proc check_effective_target_vector_alignment_reachable { } {
5744 set et_vector_alignment_reachable 0
5745 if { [check_effective_target_vect_aligned_arrays]
5746 || [check_effective_target_natural_alignment_32] } {
5747 set et_vector_alignment_reachable 1
5749 verbose "check_effective_target_vector_alignment_reachable:\
5750 returning $et_vector_alignment_reachable" 2
5751 return $et_vector_alignment_reachable
5754 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
5756 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
5757 set et_vector_alignment_reachable_for_64bit 0
5758 if { [check_effective_target_vect_aligned_arrays]
5759 || [check_effective_target_natural_alignment_64] } {
5760 set et_vector_alignment_reachable_for_64bit 1
5762 verbose "check_effective_target_vector_alignment_reachable_for_64bit:\
5763 returning $et_vector_alignment_reachable_for_64bit" 2
5764 return $et_vector_alignment_reachable_for_64bit
5767 # Return 1 if the target only requires element alignment for vector accesses
5769 proc check_effective_target_vect_element_align { } {
5770 global et_vect_element_align
5771 global et_index
5773 if [info exists et_vect_element_align($et_index)] {
5774 verbose "check_effective_target_vect_element_align:\
5775 using cached result" 2
5776 } else {
5777 set et_vect_element_align($et_index) 0
5778 if { ([istarget arm*-*-*]
5779 && ![check_effective_target_arm_vect_no_misalign])
5780 || [check_effective_target_vect_hw_misalign] } {
5781 set et_vect_element_align($et_index) 1
5785 verbose "check_effective_target_vect_element_align:\
5786 returning $et_vect_element_align($et_index)" 2
5787 return $et_vect_element_align($et_index)
5790 # Return 1 if the target supports vector LOAD_LANES operations, 0 otherwise.
5792 proc check_effective_target_vect_load_lanes { } {
5793 global et_vect_load_lanes
5795 if [info exists et_vect_load_lanes] {
5796 verbose "check_effective_target_vect_load_lanes: using cached result" 2
5797 } else {
5798 set et_vect_load_lanes 0
5799 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])
5800 || [istarget aarch64*-*-*] } {
5801 set et_vect_load_lanes 1
5805 verbose "check_effective_target_vect_load_lanes: returning $et_vect_load_lanes" 2
5806 return $et_vect_load_lanes
5809 # Return 1 if the target supports vector conditional operations, 0 otherwise.
5811 proc check_effective_target_vect_condition { } {
5812 global et_vect_cond_saved
5813 global et_index
5815 if [info exists et_vect_cond_saved($et_index)] {
5816 verbose "check_effective_target_vect_cond: using cached result" 2
5817 } else {
5818 set et_vect_cond_saved($et_index) 0
5819 if { [istarget aarch64*-*-*]
5820 || [istarget powerpc*-*-*]
5821 || [istarget ia64-*-*]
5822 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5823 || [istarget spu-*-*]
5824 || ([istarget mips*-*-*]
5825 && [et-is-effective-target mips_msa])
5826 || ([istarget arm*-*-*]
5827 && [check_effective_target_arm_neon_ok]) } {
5828 set et_vect_cond_saved($et_index) 1
5832 verbose "check_effective_target_vect_cond:\
5833 returning $et_vect_cond_saved($et_index)" 2
5834 return $et_vect_cond_saved($et_index)
5837 # Return 1 if the target supports vector conditional operations where
5838 # the comparison has different type from the lhs, 0 otherwise.
5840 proc check_effective_target_vect_cond_mixed { } {
5841 global et_vect_cond_mixed_saved
5842 global et_index
5844 if [info exists et_vect_cond_mixed_saved($et_index)] {
5845 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
5846 } else {
5847 set et_vect_cond_mixed_saved($et_index) 0
5848 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5849 || [istarget aarch64*-*-*]
5850 || [istarget powerpc*-*-*]
5851 || ([istarget mips*-*-*]
5852 && [et-is-effective-target mips_msa]) } {
5853 set et_vect_cond_mixed_saved($et_index) 1
5857 verbose "check_effective_target_vect_cond_mixed:\
5858 returning $et_vect_cond_mixed_saved($et_index)" 2
5859 return $et_vect_cond_mixed_saved($et_index)
5862 # Return 1 if the target supports vector char multiplication, 0 otherwise.
5864 proc check_effective_target_vect_char_mult { } {
5865 global et_vect_char_mult_saved
5866 global et_index
5868 if [info exists et_vect_char_mult_saved($et_index)] {
5869 verbose "check_effective_target_vect_char_mult: using cached result" 2
5870 } else {
5871 set et_vect_char_mult_saved($et_index) 0
5872 if { [istarget aarch64*-*-*]
5873 || [istarget ia64-*-*]
5874 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5875 || [check_effective_target_arm32]
5876 || [check_effective_target_powerpc_altivec]
5877 || ([istarget mips*-*-*]
5878 && [et-is-effective-target mips_msa]) } {
5879 set et_vect_char_mult_saved($et_index) 1
5883 verbose "check_effective_target_vect_char_mult:\
5884 returning $et_vect_char_mult_saved($et_index)" 2
5885 return $et_vect_char_mult_saved($et_index)
5888 # Return 1 if the target supports vector short multiplication, 0 otherwise.
5890 proc check_effective_target_vect_short_mult { } {
5891 global et_vect_short_mult_saved
5892 global et_index
5894 if [info exists et_vect_short_mult_saved($et_index)] {
5895 verbose "check_effective_target_vect_short_mult: using cached result" 2
5896 } else {
5897 set et_vect_short_mult_saved($et_index) 0
5898 if { [istarget ia64-*-*]
5899 || [istarget spu-*-*]
5900 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5901 || [istarget powerpc*-*-*]
5902 || [istarget aarch64*-*-*]
5903 || [check_effective_target_arm32]
5904 || ([istarget mips*-*-*]
5905 && ([et-is-effective-target mips_msa]
5906 || [et-is-effective-target mips_loongson])) } {
5907 set et_vect_short_mult_saved($et_index) 1
5911 verbose "check_effective_target_vect_short_mult:\
5912 returning $et_vect_short_mult_saved($et_index)" 2
5913 return $et_vect_short_mult_saved($et_index)
5916 # Return 1 if the target supports vector int multiplication, 0 otherwise.
5918 proc check_effective_target_vect_int_mult { } {
5919 global et_vect_int_mult_saved
5920 global et_index
5922 if [info exists et_vect_int_mult_saved($et_index)] {
5923 verbose "check_effective_target_vect_int_mult: using cached result" 2
5924 } else {
5925 set et_vect_int_mult_saved($et_index) 0
5926 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5927 || [istarget spu-*-*]
5928 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5929 || [istarget ia64-*-*]
5930 || [istarget aarch64*-*-*]
5931 || ([istarget mips*-*-*]
5932 && [et-is-effective-target mips_msa])
5933 || [check_effective_target_arm32] } {
5934 set et_vect_int_mult_saved($et_index) 1
5938 verbose "check_effective_target_vect_int_mult:\
5939 returning $et_vect_int_mult_saved($et_index)" 2
5940 return $et_vect_int_mult_saved($et_index)
5943 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
5945 proc check_effective_target_vect_extract_even_odd { } {
5946 global et_vect_extract_even_odd_saved
5947 global et_index
5949 if [info exists et_vect_extract_even_odd_saved($et_index)] {
5950 verbose "check_effective_target_vect_extract_even_odd:\
5951 using cached result" 2
5952 } else {
5953 set et_vect_extract_even_odd_saved($et_index) 0
5954 if { [istarget aarch64*-*-*]
5955 || [istarget powerpc*-*-*]
5956 || [is-effective-target arm_neon_ok]
5957 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5958 || [istarget ia64-*-*]
5959 || [istarget spu-*-*]
5960 || ([istarget mips*-*-*]
5961 && ([et-is-effective-target mips_msa]
5962 || [et-is-effective-target mpaired_single])) } {
5963 set et_vect_extract_even_odd_saved($et_index) 1
5967 verbose "check_effective_target_vect_extract_even_odd:\
5968 returning $et_vect_extract_even_odd_saved($et_index)" 2
5969 return $et_vect_extract_even_odd_saved($et_index)
5972 # Return 1 if the target supports vector interleaving, 0 otherwise.
5974 proc check_effective_target_vect_interleave { } {
5975 global et_vect_interleave_saved
5976 global et_index
5978 if [info exists et_vect_interleave_saved($et_index)] {
5979 verbose "check_effective_target_vect_interleave: using cached result" 2
5980 } else {
5981 set et_vect_interleave_saved($et_index) 0
5982 if { [istarget aarch64*-*-*]
5983 || [istarget powerpc*-*-*]
5984 || [is-effective-target arm_neon_ok]
5985 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5986 || [istarget ia64-*-*]
5987 || [istarget spu-*-*]
5988 || ([istarget mips*-*-*]
5989 && ([et-is-effective-target mpaired_single]
5990 || [et-is-effective-target mips_msa])) } {
5991 set et_vect_interleave_saved($et_index) 1
5995 verbose "check_effective_target_vect_interleave:\
5996 returning $et_vect_interleave_saved($et_index)" 2
5997 return $et_vect_interleave_saved($et_index)
6000 foreach N {2 3 4 8} {
6001 eval [string map [list N $N] {
6002 # Return 1 if the target supports 2-vector interleaving
6003 proc check_effective_target_vect_stridedN { } {
6004 global et_vect_stridedN_saved
6005 global et_index
6007 if [info exists et_vect_stridedN_saved($et_index)] {
6008 verbose "check_effective_target_vect_stridedN:\
6009 using cached result" 2
6010 } else {
6011 set et_vect_stridedN_saved($et_index) 0
6012 if { (N & -N) == N
6013 && [check_effective_target_vect_interleave]
6014 && [check_effective_target_vect_extract_even_odd] } {
6015 set et_vect_stridedN_saved($et_index) 1
6017 if { ([istarget arm*-*-*]
6018 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
6019 set et_vect_stridedN_saved($et_index) 1
6023 verbose "check_effective_target_vect_stridedN:\
6024 returning $et_vect_stridedN_saved($et_index)" 2
6025 return $et_vect_stridedN_saved($et_index)
6030 # Return 1 if the target supports multiple vector sizes
6032 proc check_effective_target_vect_multiple_sizes { } {
6033 global et_vect_multiple_sizes_saved
6034 global et_index
6036 set et_vect_multiple_sizes_saved($et_index) 0
6037 if { ([istarget aarch64*-*-*]
6038 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
6039 set et_vect_multiple_sizes_saved($et_index) 1
6041 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6042 if { ([check_avx_available] && ![check_prefer_avx128]) } {
6043 set et_vect_multiple_sizes_saved($et_index) 1
6047 verbose "check_effective_target_vect_multiple_sizes:\
6048 returning $et_vect_multiple_sizes_saved($et_index)" 2
6049 return $et_vect_multiple_sizes_saved($et_index)
6052 # Return 1 if the target supports vectors of 64 bits.
6054 proc check_effective_target_vect64 { } {
6055 global et_vect64_saved
6056 global et_index
6058 if [info exists et_vect64_saved($et_index)] {
6059 verbose "check_effective_target_vect64: using cached result" 2
6060 } else {
6061 set et_vect64_saved($et_index) 0
6062 if { ([istarget arm*-*-*]
6063 && [check_effective_target_arm_neon_ok]
6064 && [check_effective_target_arm_little_endian])
6065 || [istarget aarch64*-*-*]
6066 || [istarget sparc*-*-*] } {
6067 set et_vect64_saved($et_index) 1
6071 verbose "check_effective_target_vect64:\
6072 returning $et_vect64_saved($et_index)" 2
6073 return $et_vect64_saved($et_index)
6076 # Return 1 if the target supports vector copysignf calls.
6078 proc check_effective_target_vect_call_copysignf { } {
6079 global et_vect_call_copysignf_saved
6080 global et_index
6082 if [info exists et_vect_call_copysignf_saved($et_index)] {
6083 verbose "check_effective_target_vect_call_copysignf:\
6084 using cached result" 2
6085 } else {
6086 set et_vect_call_copysignf_saved($et_index) 0
6087 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
6088 || [istarget powerpc*-*-*] } {
6089 set et_vect_call_copysignf_saved($et_index) 1
6093 verbose "check_effective_target_vect_call_copysignf:\
6094 returning $et_vect_call_copysignf_saved($et_index)" 2
6095 return $et_vect_call_copysignf_saved($et_index)
6098 # Return 1 if the target supports hardware square root instructions.
6100 proc check_effective_target_sqrt_insn { } {
6101 global et_sqrt_insn_saved
6103 if [info exists et_sqrt_insn_saved] {
6104 verbose "check_effective_target_hw_sqrt: using cached result" 2
6105 } else {
6106 set et_sqrt_insn_saved 0
6107 if { [istarget x86_64-*-*]
6108 || [istarget powerpc*-*-*]
6109 || [istarget aarch64*-*-*]
6110 || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok]) } {
6111 set et_sqrt_insn_saved 1
6115 verbose "check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
6116 return $et_sqrt_insn_saved
6119 # Return 1 if the target supports vector sqrtf calls.
6121 proc check_effective_target_vect_call_sqrtf { } {
6122 global et_vect_call_sqrtf_saved
6123 global et_index
6125 if [info exists et_vect_call_sqrtf_saved($et_index)] {
6126 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
6127 } else {
6128 set et_vect_call_sqrtf_saved($et_index) 0
6129 if { [istarget aarch64*-*-*]
6130 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6131 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
6132 set et_vect_call_sqrtf_saved($et_index) 1
6136 verbose "check_effective_target_vect_call_sqrtf:\
6137 returning $et_vect_call_sqrtf_saved($et_index)" 2
6138 return $et_vect_call_sqrtf_saved($et_index)
6141 # Return 1 if the target supports vector lrint calls.
6143 proc check_effective_target_vect_call_lrint { } {
6144 set et_vect_call_lrint 0
6145 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
6146 && [check_effective_target_ilp32] } {
6147 set et_vect_call_lrint 1
6150 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
6151 return $et_vect_call_lrint
6154 # Return 1 if the target supports vector btrunc calls.
6156 proc check_effective_target_vect_call_btrunc { } {
6157 global et_vect_call_btrunc_saved
6158 global et_index
6160 if [info exists et_vect_call_btrunc_saved($et_index)] {
6161 verbose "check_effective_target_vect_call_btrunc:\
6162 using cached result" 2
6163 } else {
6164 set et_vect_call_btrunc_saved($et_index) 0
6165 if { [istarget aarch64*-*-*] } {
6166 set et_vect_call_btrunc_saved($et_index) 1
6170 verbose "check_effective_target_vect_call_btrunc:\
6171 returning $et_vect_call_btrunc_saved($et_index)" 2
6172 return $et_vect_call_btrunc_saved($et_index)
6175 # Return 1 if the target supports vector btruncf calls.
6177 proc check_effective_target_vect_call_btruncf { } {
6178 global et_vect_call_btruncf_saved
6179 global et_index
6181 if [info exists et_vect_call_btruncf_saved($et_index)] {
6182 verbose "check_effective_target_vect_call_btruncf:\
6183 using cached result" 2
6184 } else {
6185 set et_vect_call_btruncf_saved($et_index) 0
6186 if { [istarget aarch64*-*-*] } {
6187 set et_vect_call_btruncf_saved($et_index) 1
6191 verbose "check_effective_target_vect_call_btruncf:\
6192 returning $et_vect_call_btruncf_saved($et_index)" 2
6193 return $et_vect_call_btruncf_saved($et_index)
6196 # Return 1 if the target supports vector ceil calls.
6198 proc check_effective_target_vect_call_ceil { } {
6199 global et_vect_call_ceil_saved
6200 global et_index
6202 if [info exists et_vect_call_ceil_saved($et_index)] {
6203 verbose "check_effective_target_vect_call_ceil: using cached result" 2
6204 } else {
6205 set et_vect_call_ceil_saved($et_index) 0
6206 if { [istarget aarch64*-*-*] } {
6207 set et_vect_call_ceil_saved($et_index) 1
6211 verbose "check_effective_target_vect_call_ceil:\
6212 returning $et_vect_call_ceil_saved($et_index)" 2
6213 return $et_vect_call_ceil_saved($et_index)
6216 # Return 1 if the target supports vector ceilf calls.
6218 proc check_effective_target_vect_call_ceilf { } {
6219 global et_vect_call_ceilf_saved
6220 global et_index
6222 if [info exists et_vect_call_ceilf_saved($et_index)] {
6223 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
6224 } else {
6225 set et_vect_call_ceilf_saved($et_index) 0
6226 if { [istarget aarch64*-*-*] } {
6227 set et_vect_call_ceilf_saved($et_index) 1
6231 verbose "check_effective_target_vect_call_ceilf:\
6232 returning $et_vect_call_ceilf_saved($et_index)" 2
6233 return $et_vect_call_ceilf_saved($et_index)
6236 # Return 1 if the target supports vector floor calls.
6238 proc check_effective_target_vect_call_floor { } {
6239 global et_vect_call_floor_saved
6240 global et_index
6242 if [info exists et_vect_call_floor_saved($et_index)] {
6243 verbose "check_effective_target_vect_call_floor: using cached result" 2
6244 } else {
6245 set et_vect_call_floor_saved($et_index) 0
6246 if { [istarget aarch64*-*-*] } {
6247 set et_vect_call_floor_saved($et_index) 1
6251 verbose "check_effective_target_vect_call_floor:\
6252 returning $et_vect_call_floor_saved($et_index)" 2
6253 return $et_vect_call_floor_saved($et_index)
6256 # Return 1 if the target supports vector floorf calls.
6258 proc check_effective_target_vect_call_floorf { } {
6259 global et_vect_call_floorf_saved
6260 global et_index
6262 if [info exists et_vect_call_floorf_saved($et_index)] {
6263 verbose "check_effective_target_vect_call_floorf: using cached result" 2
6264 } else {
6265 set et_vect_call_floorf_saved($et_index) 0
6266 if { [istarget aarch64*-*-*] } {
6267 set et_vect_call_floorf_saved($et_index) 1
6271 verbose "check_effective_target_vect_call_floorf:\
6272 returning $et_vect_call_floorf_saved($et_index)" 2
6273 return $et_vect_call_floorf_saved($et_index)
6276 # Return 1 if the target supports vector lceil calls.
6278 proc check_effective_target_vect_call_lceil { } {
6279 global et_vect_call_lceil_saved
6280 global et_index
6282 if [info exists et_vect_call_lceil_saved($et_index)] {
6283 verbose "check_effective_target_vect_call_lceil: using cached result" 2
6284 } else {
6285 set et_vect_call_lceil_saved($et_index) 0
6286 if { [istarget aarch64*-*-*] } {
6287 set et_vect_call_lceil_saved($et_index) 1
6291 verbose "check_effective_target_vect_call_lceil:\
6292 returning $et_vect_call_lceil_saved($et_index)" 2
6293 return $et_vect_call_lceil_saved($et_index)
6296 # Return 1 if the target supports vector lfloor calls.
6298 proc check_effective_target_vect_call_lfloor { } {
6299 global et_vect_call_lfloor_saved
6300 global et_index
6302 if [info exists et_vect_call_lfloor_saved($et_index)] {
6303 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
6304 } else {
6305 set et_vect_call_lfloor_saved($et_index) 0
6306 if { [istarget aarch64*-*-*] } {
6307 set et_vect_call_lfloor_saved($et_index) 1
6311 verbose "check_effective_target_vect_call_lfloor:\
6312 returning $et_vect_call_lfloor_saved($et_index)" 2
6313 return $et_vect_call_lfloor_saved($et_index)
6316 # Return 1 if the target supports vector nearbyint calls.
6318 proc check_effective_target_vect_call_nearbyint { } {
6319 global et_vect_call_nearbyint_saved
6320 global et_index
6322 if [info exists et_vect_call_nearbyint_saved($et_index)] {
6323 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
6324 } else {
6325 set et_vect_call_nearbyint_saved($et_index) 0
6326 if { [istarget aarch64*-*-*] } {
6327 set et_vect_call_nearbyint_saved($et_index) 1
6331 verbose "check_effective_target_vect_call_nearbyint:\
6332 returning $et_vect_call_nearbyint_saved($et_index)" 2
6333 return $et_vect_call_nearbyint_saved($et_index)
6336 # Return 1 if the target supports vector nearbyintf calls.
6338 proc check_effective_target_vect_call_nearbyintf { } {
6339 global et_vect_call_nearbyintf_saved
6340 global et_index
6342 if [info exists et_vect_call_nearbyintf_saved($et_index)] {
6343 verbose "check_effective_target_vect_call_nearbyintf:\
6344 using cached result" 2
6345 } else {
6346 set et_vect_call_nearbyintf_saved($et_index) 0
6347 if { [istarget aarch64*-*-*] } {
6348 set et_vect_call_nearbyintf_saved($et_index) 1
6352 verbose "check_effective_target_vect_call_nearbyintf:\
6353 returning $et_vect_call_nearbyintf_saved($et_index)" 2
6354 return $et_vect_call_nearbyintf_saved($et_index)
6357 # Return 1 if the target supports vector round calls.
6359 proc check_effective_target_vect_call_round { } {
6360 global et_vect_call_round_saved
6361 global et_index
6363 if [info exists et_vect_call_round_saved($et_index)] {
6364 verbose "check_effective_target_vect_call_round: using cached result" 2
6365 } else {
6366 set et_vect_call_round_saved($et_index) 0
6367 if { [istarget aarch64*-*-*] } {
6368 set et_vect_call_round_saved($et_index) 1
6372 verbose "check_effective_target_vect_call_round:\
6373 returning $et_vect_call_round_saved($et_index)" 2
6374 return $et_vect_call_round_saved($et_index)
6377 # Return 1 if the target supports vector roundf calls.
6379 proc check_effective_target_vect_call_roundf { } {
6380 global et_vect_call_roundf_saved
6381 global et_index
6383 if [info exists et_vect_call_roundf_saved($et_index)] {
6384 verbose "check_effective_target_vect_call_roundf: using cached result" 2
6385 } else {
6386 set et_vect_call_roundf_saved($et_index) 0
6387 if { [istarget aarch64*-*-*] } {
6388 set et_vect_call_roundf_saved($et_index) 1
6392 verbose "check_effective_target_vect_call_roundf:\
6393 returning $et_vect_call_roundf_saved($et_index)" 2
6394 return $et_vect_call_roundf_saved($et_index)
6397 # Return 1 if the target supports section-anchors
6399 proc check_effective_target_section_anchors { } {
6400 global et_section_anchors_saved
6402 if [info exists et_section_anchors_saved] {
6403 verbose "check_effective_target_section_anchors: using cached result" 2
6404 } else {
6405 set et_section_anchors_saved 0
6406 if { [istarget powerpc*-*-*]
6407 || [istarget arm*-*-*]
6408 || [istarget aarch64*-*-*] } {
6409 set et_section_anchors_saved 1
6413 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
6414 return $et_section_anchors_saved
6417 # Return 1 if the target supports atomic operations on "int_128" values.
6419 proc check_effective_target_sync_int_128 { } {
6420 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
6421 && ![is-effective-target ia32] } {
6422 return 1
6423 } elseif { [istarget spu-*-*] } {
6424 return 1
6425 } else {
6426 return 0
6430 # Return 1 if the target supports atomic operations on "int_128" values
6431 # and can execute them.
6433 proc check_effective_target_sync_int_128_runtime { } {
6434 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
6435 && ![is-effective-target ia32] } {
6436 return [check_cached_effective_target sync_int_128_available {
6437 check_runtime_nocache sync_int_128_available {
6438 #include "cpuid.h"
6439 int main ()
6441 unsigned int eax, ebx, ecx, edx;
6442 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
6443 return !(ecx & bit_CMPXCHG16B);
6444 return 1;
6446 } ""
6448 } elseif { [istarget spu-*-*] } {
6449 return 1
6450 } else {
6451 return 0
6455 # Return 1 if the target supports atomic operations on "long long".
6457 # Note: 32bit x86 targets require -march=pentium in dg-options.
6458 # Note: 32bit s390 targets require -mzarch in dg-options.
6460 proc check_effective_target_sync_long_long { } {
6461 if { [istarget x86_64-*-*] || [istarget i?86-*-*])
6462 || [istarget aarch64*-*-*]
6463 || [istarget arm*-*-*]
6464 || [istarget alpha*-*-*]
6465 || ([istarget sparc*-*-*] && [check_effective_target_lp64])
6466 || [istarget s390*-*-*]
6467 || [istarget spu-*-*] } {
6468 return 1
6469 } else {
6470 return 0
6474 # Return 1 if the target supports atomic operations on "long long"
6475 # and can execute them.
6477 # Note: 32bit x86 targets require -march=pentium in dg-options.
6479 proc check_effective_target_sync_long_long_runtime { } {
6480 if { [istarget x86_64-*-*] || [istarget i?86-*-*] } {
6481 return [check_cached_effective_target sync_long_long_available {
6482 check_runtime_nocache sync_long_long_available {
6483 #include "cpuid.h"
6484 int main ()
6486 unsigned int eax, ebx, ecx, edx;
6487 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
6488 return !(edx & bit_CMPXCHG8B);
6489 return 1;
6491 } ""
6493 } elseif { [istarget aarch64*-*-*] } {
6494 return 1
6495 } elseif { [istarget arm*-*-linux-*] } {
6496 return [check_runtime sync_longlong_runtime {
6497 #include <stdlib.h>
6498 int main ()
6500 long long l1;
6502 if (sizeof (long long) != 8)
6503 exit (1);
6505 /* Just check for native; checking for kernel fallback is tricky. */
6506 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
6508 exit (0);
6510 } "" ]
6511 } elseif { [istarget alpha*-*-*] } {
6512 return 1
6513 } elseif { ([istarget sparc*-*-*]
6514 && [check_effective_target_lp64]
6515 && [check_effective_target_ultrasparc_hw]) } {
6516 return 1
6517 } elseif { [istarget spu-*-*] } {
6518 return 1
6519 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
6520 return 1
6521 } else {
6522 return 0
6526 # Return 1 if the target supports byte swap instructions.
6528 proc check_effective_target_bswap { } {
6529 global et_bswap_saved
6531 if [info exists et_bswap_saved] {
6532 verbose "check_effective_target_bswap: using cached result" 2
6533 } else {
6534 set et_bswap_saved 0
6535 if { [istarget aarch64*-*-*]
6536 || [istarget alpha*-*-*]
6537 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6538 || [istarget m68k-*-*]
6539 || [istarget powerpc*-*-*]
6540 || [istarget rs6000-*-*]
6541 || [istarget s390*-*-*] } {
6542 set et_bswap_saved 1
6543 } else {
6544 if { [istarget arm*-*-*]
6545 && [check_no_compiler_messages_nocache arm_v6_or_later object {
6546 #if __ARM_ARCH < 6
6547 #error not armv6 or later
6548 #endif
6549 int i;
6550 } ""] } {
6551 set et_bswap_saved 1
6556 verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
6557 return $et_bswap_saved
6560 # Return 1 if the target supports 16-bit byte swap instructions.
6562 proc check_effective_target_bswap16 { } {
6563 global et_bswap16_saved
6565 if [info exists et_bswap16_saved] {
6566 verbose "check_effective_target_bswap16: using cached result" 2
6567 } else {
6568 set et_bswap16_saved 0
6569 if { [is-effective-target bswap]
6570 && ![istarget alpha*-*-*]
6571 && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
6572 set et_bswap16_saved 1
6576 verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
6577 return $et_bswap16_saved
6580 # Return 1 if the target supports 32-bit byte swap instructions.
6582 proc check_effective_target_bswap32 { } {
6583 global et_bswap32_saved
6585 if [info exists et_bswap32_saved] {
6586 verbose "check_effective_target_bswap32: using cached result" 2
6587 } else {
6588 set et_bswap32_saved 0
6589 if { [is-effective-target bswap] } {
6590 set et_bswap32_saved 1
6594 verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
6595 return $et_bswap32_saved
6598 # Return 1 if the target supports 64-bit byte swap instructions.
6600 # Note: 32bit s390 targets require -mzarch in dg-options.
6602 proc check_effective_target_bswap64 { } {
6603 global et_bswap64_saved
6605 # expand_unop can expand 64-bit byte swap on 32-bit targets
6606 if { [is-effective-target bswap] && [is-effective-target int32plus] } {
6607 return 1
6609 return 0
6612 # Return 1 if the target supports atomic operations on "int" and "long".
6614 proc check_effective_target_sync_int_long { } {
6615 global et_sync_int_long_saved
6617 if [info exists et_sync_int_long_saved] {
6618 verbose "check_effective_target_sync_int_long: using cached result" 2
6619 } else {
6620 set et_sync_int_long_saved 0
6621 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
6622 # load-reserved/store-conditional instructions.
6623 if { [istarget ia64-*-*]
6624 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6625 || [istarget aarch64*-*-*]
6626 || [istarget alpha*-*-*]
6627 || [istarget arm*-*-linux-*]
6628 || ([istarget arm*-*-*]
6629 && [check_effective_target_arm_acq_rel])
6630 || [istarget bfin*-*linux*]
6631 || [istarget hppa*-*linux*]
6632 || [istarget s390*-*-*]
6633 || [istarget powerpc*-*-*]
6634 || [istarget crisv32-*-*] || [istarget cris-*-*]
6635 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
6636 || [istarget spu-*-*]
6637 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
6638 || [check_effective_target_mips_llsc] } {
6639 set et_sync_int_long_saved 1
6643 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
6644 return $et_sync_int_long_saved
6647 # Return 1 if the target supports atomic operations on "char" and "short".
6649 proc check_effective_target_sync_char_short { } {
6650 global et_sync_char_short_saved
6652 if [info exists et_sync_char_short_saved] {
6653 verbose "check_effective_target_sync_char_short: using cached result" 2
6654 } else {
6655 set et_sync_char_short_saved 0
6656 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
6657 # load-reserved/store-conditional instructions.
6658 if { [istarget aarch64*-*-*]
6659 || [istarget ia64-*-*]
6660 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6661 || [istarget alpha*-*-*]
6662 || [istarget arm*-*-linux-*]
6663 || ([istarget arm*-*-*]
6664 && [check_effective_target_arm_acq_rel])
6665 || [istarget hppa*-*linux*]
6666 || [istarget s390*-*-*]
6667 || [istarget powerpc*-*-*]
6668 || [istarget crisv32-*-*] || [istarget cris-*-*]
6669 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
6670 || [istarget spu-*-*]
6671 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
6672 || [check_effective_target_mips_llsc] } {
6673 set et_sync_char_short_saved 1
6677 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
6678 return $et_sync_char_short_saved
6681 # Return 1 if the target uses a ColdFire FPU.
6683 proc check_effective_target_coldfire_fpu { } {
6684 return [check_no_compiler_messages coldfire_fpu assembly {
6685 #ifndef __mcffpu__
6686 #error !__mcffpu__
6687 #endif
6691 # Return true if this is a uClibc target.
6693 proc check_effective_target_uclibc {} {
6694 return [check_no_compiler_messages uclibc object {
6695 #include <features.h>
6696 #if !defined (__UCLIBC__)
6697 #error !__UCLIBC__
6698 #endif
6702 # Return true if this is a uclibc target and if the uclibc feature
6703 # described by __$feature__ is not present.
6705 proc check_missing_uclibc_feature {feature} {
6706 return [check_no_compiler_messages $feature object "
6707 #include <features.h>
6708 #if !defined (__UCLIBC) || defined (__${feature}__)
6709 #error FOO
6710 #endif
6714 # Return true if this is a Newlib target.
6716 proc check_effective_target_newlib {} {
6717 return [check_no_compiler_messages newlib object {
6718 #include <newlib.h>
6722 # Return true if this is NOT a Bionic target.
6724 proc check_effective_target_non_bionic {} {
6725 return [check_no_compiler_messages non_bionic object {
6726 #include <ctype.h>
6727 #if defined (__BIONIC__)
6728 #error FOO
6729 #endif
6733 # Return true if this target has error.h header.
6735 proc check_effective_target_error_h {} {
6736 return [check_no_compiler_messages error_h object {
6737 #include <error.h>
6741 # Return true if this target has tgmath.h header.
6743 proc check_effective_target_tgmath_h {} {
6744 return [check_no_compiler_messages tgmath_h object {
6745 #include <tgmath.h>
6749 # Return true if target's libc supports complex functions.
6751 proc check_effective_target_libc_has_complex_functions {} {
6752 return [check_no_compiler_messages libc_has_complex_functions object {
6753 #include <complex.h>
6757 # Return 1 if
6758 # (a) an error of a few ULP is expected in string to floating-point
6759 # conversion functions; and
6760 # (b) overflow is not always detected correctly by those functions.
6762 proc check_effective_target_lax_strtofp {} {
6763 # By default, assume that all uClibc targets suffer from this.
6764 return [check_effective_target_uclibc]
6767 # Return 1 if this is a target for which wcsftime is a dummy
6768 # function that always returns 0.
6770 proc check_effective_target_dummy_wcsftime {} {
6771 # By default, assume that all uClibc targets suffer from this.
6772 return [check_effective_target_uclibc]
6775 # Return 1 if constructors with initialization priority arguments are
6776 # supposed on this target.
6778 proc check_effective_target_init_priority {} {
6779 return [check_no_compiler_messages init_priority assembly "
6780 void f() __attribute__((constructor (1000)));
6781 void f() \{\}
6785 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
6786 # This can be used with any check_* proc that takes no argument and
6787 # returns only 1 or 0. It could be used with check_* procs that take
6788 # arguments with keywords that pass particular arguments.
6790 proc is-effective-target { arg } {
6791 global et_index
6792 set selected 0
6793 if { ![info exists et_index] } {
6794 # Initialize the effective target index that is used in some
6795 # check_effective_target_* procs.
6796 set et_index 0
6798 if { [info procs check_effective_target_${arg}] != [list] } {
6799 set selected [check_effective_target_${arg}]
6800 } else {
6801 switch $arg {
6802 "vmx_hw" { set selected [check_vmx_hw_available] }
6803 "vsx_hw" { set selected [check_vsx_hw_available] }
6804 "p8vector_hw" { set selected [check_p8vector_hw_available] }
6805 "p9vector_hw" { set selected [check_p9vector_hw_available] }
6806 "p9modulo_hw" { set selected [check_p9modulo_hw_available] }
6807 "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
6808 "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
6809 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
6810 "dfp_hw" { set selected [check_dfp_hw_available] }
6811 "htm_hw" { set selected [check_htm_hw_available] }
6812 "named_sections" { set selected [check_named_sections_available] }
6813 "gc_sections" { set selected [check_gc_sections_available] }
6814 "cxa_atexit" { set selected [check_cxa_atexit_available] }
6815 default { error "unknown effective target keyword `$arg'" }
6818 verbose "is-effective-target: $arg $selected" 2
6819 return $selected
6822 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
6824 proc is-effective-target-keyword { arg } {
6825 if { [info procs check_effective_target_${arg}] != [list] } {
6826 return 1
6827 } else {
6828 # These have different names for their check_* procs.
6829 switch $arg {
6830 "vmx_hw" { return 1 }
6831 "vsx_hw" { return 1 }
6832 "p8vector_hw" { return 1 }
6833 "p9vector_hw" { return 1 }
6834 "p9modulo_hw" { return 1 }
6835 "ppc_float128_sw" { return 1 }
6836 "ppc_float128_hw" { return 1 }
6837 "ppc_recip_hw" { return 1 }
6838 "dfp_hw" { return 1 }
6839 "htm_hw" { return 1 }
6840 "named_sections" { return 1 }
6841 "gc_sections" { return 1 }
6842 "cxa_atexit" { return 1 }
6843 default { return 0 }
6848 # Execute tests for all targets in EFFECTIVE_TARGETS list. Set et_index to
6849 # indicate what target is currently being processed. This is for
6850 # the vectorizer tests, e.g. vect_int, to keep track what target supports
6851 # a given feature.
6853 proc et-dg-runtest { runtest testcases flags default-extra-flags } {
6854 global dg-do-what-default
6855 global EFFECTIVE_TARGETS
6856 global et_index
6858 if { [llength $EFFECTIVE_TARGETS] > 0 } {
6859 foreach target $EFFECTIVE_TARGETS {
6860 set target_flags $flags
6861 set dg-do-what-default compile
6862 set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
6863 if { [info procs add_options_for_${target}] != [list] } {
6864 set target_flags [add_options_for_${target} "$flags"]
6866 if { [info procs check_effective_target_${target}_runtime]
6867 != [list] && [check_effective_target_${target}_runtime] } {
6868 set dg-do-what-default run
6870 $runtest $testcases $target_flags ${default-extra-flags}
6872 } else {
6873 set et_index 0
6874 $runtest $testcases $flags ${default-extra-flags}
6878 # Return 1 if a target matches the target in EFFECTIVE_TARGETS at index
6879 # et_index, 0 otherwise.
6881 proc et-is-effective-target { target } {
6882 global EFFECTIVE_TARGETS
6883 global et_index
6885 if { [llength $EFFECTIVE_TARGETS] > $et_index
6886 && [lindex $EFFECTIVE_TARGETS $et_index] == $target } {
6887 return 1
6889 return 0
6892 # Return 1 if target default to short enums
6894 proc check_effective_target_short_enums { } {
6895 return [check_no_compiler_messages short_enums assembly {
6896 enum foo { bar };
6897 int s[sizeof (enum foo) == 1 ? 1 : -1];
6901 # Return 1 if target supports merging string constants at link time.
6903 proc check_effective_target_string_merging { } {
6904 return [check_no_messages_and_pattern string_merging \
6905 "rodata\\.str" assembly {
6906 const char *var = "String";
6907 } {-O2}]
6910 # Return 1 if target has the basic signed and unsigned types in
6911 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
6912 # working <stdint.h> for all targets.
6914 proc check_effective_target_stdint_types { } {
6915 return [check_no_compiler_messages stdint_types assembly {
6916 #include <stdint.h>
6917 int8_t a; int16_t b; int32_t c; int64_t d;
6918 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
6922 # Return 1 if target has the basic signed and unsigned types in
6923 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
6924 # these types agree with those in the header, as some systems have
6925 # only <inttypes.h>.
6927 proc check_effective_target_inttypes_types { } {
6928 return [check_no_compiler_messages inttypes_types assembly {
6929 #include <inttypes.h>
6930 int8_t a; int16_t b; int32_t c; int64_t d;
6931 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
6935 # Return 1 if programs are intended to be run on a simulator
6936 # (i.e. slowly) rather than hardware (i.e. fast).
6938 proc check_effective_target_simulator { } {
6940 # All "src/sim" simulators set this one.
6941 if [board_info target exists is_simulator] {
6942 return [board_info target is_simulator]
6945 # The "sid" simulators don't set that one, but at least they set
6946 # this one.
6947 if [board_info target exists slow_simulator] {
6948 return [board_info target slow_simulator]
6951 return 0
6954 # Return 1 if programs are intended to be run on hardware rather than
6955 # on a simulator
6957 proc check_effective_target_hw { } {
6959 # All "src/sim" simulators set this one.
6960 if [board_info target exists is_simulator] {
6961 if [board_info target is_simulator] {
6962 return 0
6963 } else {
6964 return 1
6968 # The "sid" simulators don't set that one, but at least they set
6969 # this one.
6970 if [board_info target exists slow_simulator] {
6971 if [board_info target slow_simulator] {
6972 return 0
6973 } else {
6974 return 1
6978 return 1
6981 # Return 1 if the target is a VxWorks kernel.
6983 proc check_effective_target_vxworks_kernel { } {
6984 return [check_no_compiler_messages vxworks_kernel assembly {
6985 #if !defined __vxworks || defined __RTP__
6986 #error NO
6987 #endif
6991 # Return 1 if the target is a VxWorks RTP.
6993 proc check_effective_target_vxworks_rtp { } {
6994 return [check_no_compiler_messages vxworks_rtp assembly {
6995 #if !defined __vxworks || !defined __RTP__
6996 #error NO
6997 #endif
7001 # Return 1 if the target is expected to provide wide character support.
7003 proc check_effective_target_wchar { } {
7004 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
7005 return 0
7007 return [check_no_compiler_messages wchar assembly {
7008 #include <wchar.h>
7012 # Return 1 if the target has <pthread.h>.
7014 proc check_effective_target_pthread_h { } {
7015 return [check_no_compiler_messages pthread_h assembly {
7016 #include <pthread.h>
7020 # Return 1 if the target can truncate a file from a file-descriptor,
7021 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
7022 # chsize. We test for a trivially functional truncation; no stubs.
7023 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
7024 # different function to be used.
7026 proc check_effective_target_fd_truncate { } {
7027 set prog {
7028 #define _FILE_OFFSET_BITS 64
7029 #include <unistd.h>
7030 #include <stdio.h>
7031 #include <stdlib.h>
7032 #include <string.h>
7033 int main ()
7035 FILE *f = fopen ("tst.tmp", "wb");
7036 int fd;
7037 const char t[] = "test writing more than ten characters";
7038 char s[11];
7039 int status = 0;
7040 fd = fileno (f);
7041 write (fd, t, sizeof (t) - 1);
7042 lseek (fd, 0, 0);
7043 if (ftruncate (fd, 10) != 0)
7044 status = 1;
7045 close (fd);
7046 fclose (f);
7047 if (status)
7049 unlink ("tst.tmp");
7050 exit (status);
7052 f = fopen ("tst.tmp", "rb");
7053 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
7054 status = 1;
7055 fclose (f);
7056 unlink ("tst.tmp");
7057 exit (status);
7061 if { [check_runtime ftruncate $prog] } {
7062 return 1;
7065 regsub "ftruncate" $prog "chsize" prog
7066 return [check_runtime chsize $prog]
7069 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
7071 proc add_options_for_c99_runtime { flags } {
7072 if { [istarget *-*-solaris2*] } {
7073 return "$flags -std=c99"
7075 if { [istarget powerpc-*-darwin*] } {
7076 return "$flags -mmacosx-version-min=10.3"
7078 return $flags
7081 # Add to FLAGS all the target-specific flags needed to enable
7082 # full IEEE compliance mode.
7084 proc add_options_for_ieee { flags } {
7085 if { [istarget alpha*-*-*]
7086 || [istarget sh*-*-*] } {
7087 return "$flags -mieee"
7089 if { [istarget rx-*-*] } {
7090 return "$flags -mnofpu"
7092 return $flags
7095 if {![info exists flags_to_postpone]} {
7096 set flags_to_postpone ""
7099 # Add to FLAGS the flags needed to enable functions to bind locally
7100 # when using pic/PIC passes in the testsuite.
7101 proc add_options_for_bind_pic_locally { flags } {
7102 global flags_to_postpone
7104 # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
7105 # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
7106 # order to make sure that the multilib_flags doesn't override this.
7108 if {[check_no_compiler_messages using_pic2 assembly {
7109 #if __PIC__ != 2
7110 #error __PIC__ != 2
7111 #endif
7112 }]} {
7113 set flags_to_postpone "-fPIE"
7114 return $flags
7116 if {[check_no_compiler_messages using_pic1 assembly {
7117 #if __PIC__ != 1
7118 #error __PIC__ != 1
7119 #endif
7120 }]} {
7121 set flags_to_postpone "-fpie"
7122 return $flags
7124 return $flags
7127 # Add to FLAGS the flags needed to enable 64-bit vectors.
7129 proc add_options_for_double_vectors { flags } {
7130 if [is-effective-target arm_neon_ok] {
7131 return "$flags -mvectorize-with-neon-double"
7134 return $flags
7137 # Return 1 if the target provides a full C99 runtime.
7139 proc check_effective_target_c99_runtime { } {
7140 return [check_cached_effective_target c99_runtime {
7141 global srcdir
7143 set file [open "$srcdir/gcc.dg/builtins-config.h"]
7144 set contents [read $file]
7145 close $file
7146 append contents {
7147 #ifndef HAVE_C99_RUNTIME
7148 #error !HAVE_C99_RUNTIME
7149 #endif
7151 check_no_compiler_messages_nocache c99_runtime assembly \
7152 $contents [add_options_for_c99_runtime ""]
7156 # Return 1 if target wchar_t is at least 4 bytes.
7158 proc check_effective_target_4byte_wchar_t { } {
7159 return [check_no_compiler_messages 4byte_wchar_t object {
7160 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
7164 # Return 1 if the target supports automatic stack alignment.
7166 proc check_effective_target_automatic_stack_alignment { } {
7167 # Ordinarily x86 supports automatic stack alignment ...
7168 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
7169 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
7170 # ... except Win64 SEH doesn't. Succeed for Win32 though.
7171 return [check_effective_target_ilp32];
7173 return 1;
7175 return 0;
7178 # Return true if we are compiling for AVX target.
7180 proc check_avx_available { } {
7181 if { [check_no_compiler_messages avx_available assembly {
7182 #ifndef __AVX__
7183 #error unsupported
7184 #endif
7185 } ""] } {
7186 return 1;
7188 return 0;
7191 # Return true if 32- and 16-bytes vectors are available.
7193 proc check_effective_target_vect_sizes_32B_16B { } {
7194 if { [check_avx_available] && ![check_prefer_avx128] } {
7195 return 1;
7196 } else {
7197 return 0;
7201 # Return true if 128-bits vectors are preferred even if 256-bits vectors
7202 # are available.
7204 proc check_prefer_avx128 { } {
7205 if ![check_avx_available] {
7206 return 0;
7208 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
7209 float a[1024],b[1024],c[1024];
7210 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
7211 } "-O2 -ftree-vectorize"]
7215 # Return 1 if avx512f instructions can be compiled.
7217 proc check_effective_target_avx512f { } {
7218 return [check_no_compiler_messages avx512f object {
7219 typedef double __m512d __attribute__ ((__vector_size__ (64)));
7221 __m512d _mm512_add (__m512d a)
7223 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
7225 } "-O2 -mavx512f" ]
7228 # Return 1 if avx instructions can be compiled.
7230 proc check_effective_target_avx { } {
7231 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
7232 return 0
7234 return [check_no_compiler_messages avx object {
7235 void _mm256_zeroall (void)
7237 __builtin_ia32_vzeroall ();
7239 } "-O2 -mavx" ]
7242 # Return 1 if avx2 instructions can be compiled.
7243 proc check_effective_target_avx2 { } {
7244 return [check_no_compiler_messages avx2 object {
7245 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
7246 __v4di
7247 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
7249 return __builtin_ia32_andnotsi256 (__X, __Y);
7251 } "-O0 -mavx2" ]
7254 # Return 1 if sse instructions can be compiled.
7255 proc check_effective_target_sse { } {
7256 return [check_no_compiler_messages sse object {
7257 int main ()
7259 __builtin_ia32_stmxcsr ();
7260 return 0;
7262 } "-O2 -msse" ]
7265 # Return 1 if sse2 instructions can be compiled.
7266 proc check_effective_target_sse2 { } {
7267 return [check_no_compiler_messages sse2 object {
7268 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
7270 __m128i _mm_srli_si128 (__m128i __A, int __N)
7272 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
7274 } "-O2 -msse2" ]
7277 # Return 1 if sse4.1 instructions can be compiled.
7278 proc check_effective_target_sse4 { } {
7279 return [check_no_compiler_messages sse4.1 object {
7280 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
7281 typedef int __v4si __attribute__ ((__vector_size__ (16)));
7283 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
7285 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
7286 (__v4si)__Y);
7288 } "-O2 -msse4.1" ]
7291 # Return 1 if F16C instructions can be compiled.
7293 proc check_effective_target_f16c { } {
7294 return [check_no_compiler_messages f16c object {
7295 #include "immintrin.h"
7296 float
7297 foo (unsigned short val)
7299 return _cvtsh_ss (val);
7301 } "-O2 -mf16c" ]
7304 # Return 1 if C wchar_t type is compatible with char16_t.
7306 proc check_effective_target_wchar_t_char16_t_compatible { } {
7307 return [check_no_compiler_messages wchar_t_char16_t object {
7308 __WCHAR_TYPE__ wc;
7309 __CHAR16_TYPE__ *p16 = &wc;
7310 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
7314 # Return 1 if C wchar_t type is compatible with char32_t.
7316 proc check_effective_target_wchar_t_char32_t_compatible { } {
7317 return [check_no_compiler_messages wchar_t_char32_t object {
7318 __WCHAR_TYPE__ wc;
7319 __CHAR32_TYPE__ *p32 = &wc;
7320 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
7324 # Return 1 if pow10 function exists.
7326 proc check_effective_target_pow10 { } {
7327 return [check_runtime pow10 {
7328 #include <math.h>
7329 int main () {
7330 double x;
7331 x = pow10 (1);
7332 return 0;
7334 } "-lm" ]
7337 # Return 1 if issignaling function exists.
7338 proc check_effective_target_issignaling {} {
7339 return [check_runtime issignaling {
7340 #define _GNU_SOURCE
7341 #include <math.h>
7342 int main ()
7344 return issignaling (0.0);
7346 } "-lm" ]
7349 # Return 1 if current options generate DFP instructions, 0 otherwise.
7350 proc check_effective_target_hard_dfp {} {
7351 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
7352 typedef float d64 __attribute__((mode(DD)));
7353 d64 x, y, z;
7354 void foo (void) { z = x + y; }
7358 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
7359 # for strchr etc. functions.
7361 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
7362 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
7363 #include <string.h>
7364 #include <wchar.h>
7365 #if !defined(__cplusplus) \
7366 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
7367 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
7368 ISO C++ correct string.h and wchar.h protos not supported.
7369 #else
7370 int i;
7371 #endif
7375 # Return 1 if GNU as is used.
7377 proc check_effective_target_gas { } {
7378 global use_gas_saved
7379 global tool
7381 if {![info exists use_gas_saved]} {
7382 # Check if the as used by gcc is GNU as.
7383 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
7384 # Provide /dev/null as input, otherwise gas times out reading from
7385 # stdin.
7386 set status [remote_exec host "$gcc_as" "-v /dev/null"]
7387 set as_output [lindex $status 1]
7388 if { [ string first "GNU" $as_output ] >= 0 } {
7389 set use_gas_saved 1
7390 } else {
7391 set use_gas_saved 0
7394 return $use_gas_saved
7397 # Return 1 if GNU ld is used.
7399 proc check_effective_target_gld { } {
7400 global use_gld_saved
7401 global tool
7403 if {![info exists use_gld_saved]} {
7404 # Check if the ld used by gcc is GNU ld.
7405 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
7406 set status [remote_exec host "$gcc_ld" "--version"]
7407 set ld_output [lindex $status 1]
7408 if { [ string first "GNU" $ld_output ] >= 0 } {
7409 set use_gld_saved 1
7410 } else {
7411 set use_gld_saved 0
7414 return $use_gld_saved
7417 # Return 1 if the compiler has been configure with link-time optimization
7418 # (LTO) support.
7420 proc check_effective_target_lto { } {
7421 if { [istarget nvptx-*-*] } {
7422 return 0;
7424 return [check_no_compiler_messages lto object {
7425 void foo (void) { }
7426 } "-flto"]
7429 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
7431 proc check_effective_target_maybe_x32 { } {
7432 return [check_no_compiler_messages maybe_x32 object {
7433 void foo (void) {}
7434 } "-mx32 -maddress-mode=short"]
7437 # Return 1 if this target supports the -fsplit-stack option, 0
7438 # otherwise.
7440 proc check_effective_target_split_stack {} {
7441 return [check_no_compiler_messages split_stack object {
7442 void foo (void) { }
7443 } "-fsplit-stack"]
7446 # Return 1 if this target supports the -masm=intel option, 0
7447 # otherwise
7449 proc check_effective_target_masm_intel {} {
7450 return [check_no_compiler_messages masm_intel object {
7451 extern void abort (void);
7452 } "-masm=intel"]
7455 # Return 1 if the language for the compiler under test is C.
7457 proc check_effective_target_c { } {
7458 global tool
7459 if [string match $tool "gcc"] {
7460 return 1
7462 return 0
7465 # Return 1 if the language for the compiler under test is C++.
7467 proc check_effective_target_c++ { } {
7468 global tool
7469 if { [string match $tool "g++"] || [string match $tool "libstdc++"] } {
7470 return 1
7472 return 0
7475 set cxx_default "c++14"
7476 # Check whether the current active language standard supports the features
7477 # of C++11/C++14 by checking for the presence of one of the -std flags.
7478 # This assumes that the default for the compiler is $cxx_default, and that
7479 # there will never be multiple -std= arguments on the command line.
7480 proc check_effective_target_c++11_only { } {
7481 global cxx_default
7482 if ![check_effective_target_c++] {
7483 return 0
7485 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
7486 return 1
7488 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
7489 return 1
7491 return 0
7493 proc check_effective_target_c++11 { } {
7494 if [check_effective_target_c++11_only] {
7495 return 1
7497 return [check_effective_target_c++14]
7499 proc check_effective_target_c++11_down { } {
7500 if ![check_effective_target_c++] {
7501 return 0
7503 return [expr ![check_effective_target_c++14] ]
7506 proc check_effective_target_c++14_only { } {
7507 global cxx_default
7508 if ![check_effective_target_c++] {
7509 return 0
7511 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
7512 return 1
7514 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
7515 return 1
7517 return 0
7520 proc check_effective_target_c++14 { } {
7521 if [check_effective_target_c++14_only] {
7522 return 1
7524 return [check_effective_target_c++1z]
7526 proc check_effective_target_c++14_down { } {
7527 if ![check_effective_target_c++] {
7528 return 0
7530 return [expr ![check_effective_target_c++1z] ]
7533 proc check_effective_target_c++98_only { } {
7534 global cxx_default
7535 if ![check_effective_target_c++] {
7536 return 0
7538 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
7539 return 1
7541 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
7542 return 1
7544 return 0
7547 proc check_effective_target_c++1z_only { } {
7548 global cxx_default
7549 if ![check_effective_target_c++] {
7550 return 0
7552 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
7553 return 1
7555 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
7556 return 1
7558 return 0
7560 proc check_effective_target_c++1z { } {
7561 return [check_effective_target_c++1z_only]
7564 # Check for C++ Concepts TS support, i.e. -fconcepts flag.
7565 proc check_effective_target_concepts { } {
7566 return [check-flags { "" { } { -fconcepts } }]
7569 # Return 1 if expensive testcases should be run.
7571 proc check_effective_target_run_expensive_tests { } {
7572 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
7573 return 1
7575 return 0
7578 # Returns 1 if "mempcpy" is available on the target system.
7580 proc check_effective_target_mempcpy {} {
7581 return [check_function_available "mempcpy"]
7584 # Returns 1 if "stpcpy" is available on the target system.
7586 proc check_effective_target_stpcpy {} {
7587 return [check_function_available "stpcpy"]
7590 # Check whether the vectorizer tests are supported by the target and
7591 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
7592 # If a port wants to execute the tests more than once it should append
7593 # the supported target to EFFECTIVE_TARGETS instead, and the compile flags
7594 # will be added by a call to add_options_for_<target>.
7595 # Set dg-do-what-default to either compile or run, depending on target
7596 # capabilities. Do not set this if the supported target is appended to
7597 # EFFECTIVE_TARGETS. Flags and this variable will be set by et-dg-runtest
7598 # automatically. Return the number of effective targets if vectorizer tests
7599 # are supported, 0 otherwise.
7601 proc check_vect_support_and_set_flags { } {
7602 global DEFAULT_VECTCFLAGS
7603 global dg-do-what-default
7604 global EFFECTIVE_TARGETS
7606 if [istarget powerpc-*paired*] {
7607 lappend DEFAULT_VECTCFLAGS "-mpaired"
7608 if [check_750cl_hw_available] {
7609 set dg-do-what-default run
7610 } else {
7611 set dg-do-what-default compile
7613 } elseif [istarget powerpc*-*-*] {
7614 # Skip targets not supporting -maltivec.
7615 if ![is-effective-target powerpc_altivec_ok] {
7616 return 0
7619 lappend DEFAULT_VECTCFLAGS "-maltivec"
7620 if [check_p9vector_hw_available] {
7621 lappend DEFAULT_VECTCFLAGS "-mpower9-vector"
7622 } elseif [check_p8vector_hw_available] {
7623 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
7624 } elseif [check_vsx_hw_available] {
7625 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
7628 if [check_vmx_hw_available] {
7629 set dg-do-what-default run
7630 } else {
7631 if [is-effective-target ilp32] {
7632 # Specify a cpu that supports VMX for compile-only tests.
7633 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
7635 set dg-do-what-default compile
7637 } elseif { [istarget spu-*-*] } {
7638 set dg-do-what-default run
7639 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
7640 lappend DEFAULT_VECTCFLAGS "-msse2"
7641 if { [check_effective_target_sse2_runtime] } {
7642 set dg-do-what-default run
7643 } else {
7644 set dg-do-what-default compile
7646 } elseif { [istarget mips*-*-*]
7647 && [check_effective_target_nomips16] } {
7648 if { [check_effective_target_mpaired_single] } {
7649 lappend EFFECTIVE_TARGETS mpaired_single
7651 if { [check_effective_target_mips_loongson] } {
7652 lappend EFFECTIVE_TARGETS mips_loongson
7654 if { [check_effective_target_mips_msa] } {
7655 lappend EFFECTIVE_TARGETS mips_msa
7657 return [llength $EFFECTIVE_TARGETS]
7658 } elseif [istarget sparc*-*-*] {
7659 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
7660 if [check_effective_target_ultrasparc_hw] {
7661 set dg-do-what-default run
7662 } else {
7663 set dg-do-what-default compile
7665 } elseif [istarget alpha*-*-*] {
7666 # Alpha's vectorization capabilities are extremely limited.
7667 # It's more effort than its worth disabling all of the tests
7668 # that it cannot pass. But if you actually want to see what
7669 # does work, command out the return.
7670 return 0
7672 lappend DEFAULT_VECTCFLAGS "-mmax"
7673 if [check_alpha_max_hw_available] {
7674 set dg-do-what-default run
7675 } else {
7676 set dg-do-what-default compile
7678 } elseif [istarget ia64-*-*] {
7679 set dg-do-what-default run
7680 } elseif [is-effective-target arm_neon_ok] {
7681 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
7682 # NEON does not support denormals, so is not used for vectorization by
7683 # default to avoid loss of precision. We must pass -ffast-math to test
7684 # vectorization of float operations.
7685 lappend DEFAULT_VECTCFLAGS "-ffast-math"
7686 if [is-effective-target arm_neon_hw] {
7687 set dg-do-what-default run
7688 } else {
7689 set dg-do-what-default compile
7691 } elseif [istarget "aarch64*-*-*"] {
7692 set dg-do-what-default run
7693 } else {
7694 return 0
7697 return 1
7700 # Return 1 if the target does *not* require strict alignment.
7702 proc check_effective_target_non_strict_align {} {
7704 # On ARM, the default is to use STRICT_ALIGNMENT, but there
7705 # are interfaces defined for misaligned access and thus
7706 # depending on the architecture levels unaligned access is
7707 # available.
7708 if [istarget "arm*-*-*"] {
7709 return [check_effective_target_arm_unaligned]
7712 return [check_no_compiler_messages non_strict_align assembly {
7713 char *y;
7714 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
7715 c *z;
7716 void foo(void) { z = (c *) y; }
7717 } "-Wcast-align"]
7720 # Return 1 if the target has <ucontext.h>.
7722 proc check_effective_target_ucontext_h { } {
7723 return [check_no_compiler_messages ucontext_h assembly {
7724 #include <ucontext.h>
7728 proc check_effective_target_aarch64_tiny { } {
7729 if { [istarget aarch64*-*-*] } {
7730 return [check_no_compiler_messages aarch64_tiny object {
7731 #ifdef __AARCH64_CMODEL_TINY__
7732 int dummy;
7733 #else
7734 #error target not AArch64 tiny code model
7735 #endif
7737 } else {
7738 return 0
7742 # Create functions to check that the AArch64 assembler supports the
7743 # various architecture extensions via the .arch_extension pseudo-op.
7745 foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse"} {
7746 eval [string map [list FUNC $aarch64_ext] {
7747 proc check_effective_target_aarch64_asm_FUNC_ok { } {
7748 if { [istarget aarch64*-*-*] } {
7749 return [check_no_compiler_messages aarch64_FUNC_assembler object {
7750 __asm__ (".arch_extension FUNC");
7751 } "-march=armv8-a+FUNC"]
7752 } else {
7753 return 0
7759 proc check_effective_target_aarch64_small { } {
7760 if { [istarget aarch64*-*-*] } {
7761 return [check_no_compiler_messages aarch64_small object {
7762 #ifdef __AARCH64_CMODEL_SMALL__
7763 int dummy;
7764 #else
7765 #error target not AArch64 small code model
7766 #endif
7768 } else {
7769 return 0
7773 proc check_effective_target_aarch64_large { } {
7774 if { [istarget aarch64*-*-*] } {
7775 return [check_no_compiler_messages aarch64_large object {
7776 #ifdef __AARCH64_CMODEL_LARGE__
7777 int dummy;
7778 #else
7779 #error target not AArch64 large code model
7780 #endif
7782 } else {
7783 return 0
7788 # Return 1 if this is a reduced AVR Tiny core. Such cores have different
7789 # register set, instruction set, addressing capabilities and ABI.
7791 proc check_effective_target_avr_tiny { } {
7792 if { [istarget avr*-*-*] } {
7793 return [check_no_compiler_messages avr_tiny object {
7794 #ifdef __AVR_TINY__
7795 int dummy;
7796 #else
7797 #error target not a reduced AVR Tiny core
7798 #endif
7800 } else {
7801 return 0
7805 # Return 1 if <fenv.h> is available with all the standard IEEE
7806 # exceptions and floating-point exceptions are raised by arithmetic
7807 # operations. (If the target requires special options for "inexact"
7808 # exceptions, those need to be specified in the testcases.)
7810 proc check_effective_target_fenv_exceptions {} {
7811 return [check_runtime fenv_exceptions {
7812 #include <fenv.h>
7813 #include <stdlib.h>
7814 #ifndef FE_DIVBYZERO
7815 # error Missing FE_DIVBYZERO
7816 #endif
7817 #ifndef FE_INEXACT
7818 # error Missing FE_INEXACT
7819 #endif
7820 #ifndef FE_INVALID
7821 # error Missing FE_INVALID
7822 #endif
7823 #ifndef FE_OVERFLOW
7824 # error Missing FE_OVERFLOW
7825 #endif
7826 #ifndef FE_UNDERFLOW
7827 # error Missing FE_UNDERFLOW
7828 #endif
7829 volatile float a = 0.0f, r;
7831 main (void)
7833 r = a / a;
7834 if (fetestexcept (FE_INVALID))
7835 exit (0);
7836 else
7837 abort ();
7839 } [add_options_for_ieee "-std=gnu99"]]
7842 proc check_effective_target_tiny {} {
7843 global et_target_tiny_saved
7845 if [info exists et_target_tine_saved] {
7846 verbose "check_effective_target_tiny: using cached result" 2
7847 } else {
7848 set et_target_tiny_saved 0
7849 if { [istarget aarch64*-*-*]
7850 && [check_effective_target_aarch64_tiny] } {
7851 set et_target_tiny_saved 1
7855 return $et_target_tiny_saved
7858 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
7860 proc check_effective_target_logical_op_short_circuit {} {
7861 if { [istarget mips*-*-*]
7862 || [istarget arc*-*-*]
7863 || [istarget avr*-*-*]
7864 || [istarget crisv32-*-*] || [istarget cris-*-*]
7865 || [istarget mmix-*-*]
7866 || [istarget s390*-*-*]
7867 || [istarget powerpc*-*-*]
7868 || [istarget nios2*-*-*]
7869 || [istarget visium-*-*]
7870 || [check_effective_target_arm_cortex_m] } {
7871 return 1
7873 return 0
7876 # Record that dg-final test TEST requires convential compilation.
7878 proc force_conventional_output_for { test } {
7879 if { [info proc $test] == "" } {
7880 perror "$test does not exist"
7881 exit 1
7883 proc ${test}_required_options {} {
7884 global gcc_force_conventional_output
7885 return $gcc_force_conventional_output
7889 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
7890 # otherwise. Cache the result.
7892 proc check_effective_target_pie_copyreloc { } {
7893 global pie_copyreloc_available_saved
7894 global tool
7895 global GCC_UNDER_TEST
7897 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
7898 return 0
7901 # Need auto-host.h to check linker support.
7902 if { ![file exists ../../auto-host.h ] } {
7903 return 0
7906 if [info exists pie_copyreloc_available_saved] {
7907 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
7908 } else {
7909 # Set up and compile to see if linker supports PIE with copy
7910 # reloc. Include the current process ID in the file names to
7911 # prevent conflicts with invocations for multiple testsuites.
7913 set src pie[pid].c
7914 set obj pie[pid].o
7916 set f [open $src "w"]
7917 puts $f "#include \"../../auto-host.h\""
7918 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
7919 puts $f "# error Linker does not support PIE with copy reloc."
7920 puts $f "#endif"
7921 close $f
7923 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
7924 set lines [${tool}_target_compile $src $obj object ""]
7926 file delete $src
7927 file delete $obj
7929 if [string match "" $lines] then {
7930 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
7931 set pie_copyreloc_available_saved 1
7932 } else {
7933 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
7934 set pie_copyreloc_available_saved 0
7938 return $pie_copyreloc_available_saved
7941 # Return 1 if the x86 target supports R_386_GOT32X relocation, 0
7942 # otherwise. Cache the result.
7944 proc check_effective_target_got32x_reloc { } {
7945 global got32x_reloc_available_saved
7946 global tool
7947 global GCC_UNDER_TEST
7949 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
7950 return 0
7953 # Need auto-host.h to check linker support.
7954 if { ![file exists ../../auto-host.h ] } {
7955 return 0
7958 if [info exists got32x_reloc_available_saved] {
7959 verbose "check_effective_target_got32x_reloc returning saved $got32x_reloc_available_saved" 2
7960 } else {
7961 # Include the current process ID in the file names to prevent
7962 # conflicts with invocations for multiple testsuites.
7964 set src got32x[pid].c
7965 set obj got32x[pid].o
7967 set f [open $src "w"]
7968 puts $f "#include \"../../auto-host.h\""
7969 puts $f "#if HAVE_AS_IX86_GOT32X == 0"
7970 puts $f "# error Assembler does not support R_386_GOT32X."
7971 puts $f "#endif"
7972 close $f
7974 verbose "check_effective_target_got32x_reloc compiling testfile $src" 2
7975 set lines [${tool}_target_compile $src $obj object ""]
7977 file delete $src
7978 file delete $obj
7980 if [string match "" $lines] then {
7981 verbose "check_effective_target_got32x_reloc testfile compilation passed" 2
7982 set got32x_reloc_available_saved 1
7983 } else {
7984 verbose "check_effective_target_got32x_reloc testfile compilation failed" 2
7985 set got32x_reloc_available_saved 0
7989 return $got32x_reloc_available_saved
7992 # Return 1 if the x86 target supports calling ___tls_get_addr via GOT,
7993 # 0 otherwise. Cache the result.
7995 proc check_effective_target_tls_get_addr_via_got { } {
7996 global tls_get_addr_via_got_available_saved
7997 global tool
7998 global GCC_UNDER_TEST
8000 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
8001 return 0
8004 # Need auto-host.h to check linker support.
8005 if { ![file exists ../../auto-host.h ] } {
8006 return 0
8009 if [info exists tls_get_addr_via_got_available_saved] {
8010 verbose "check_effective_target_tls_get_addr_via_got returning saved $tls_get_addr_via_got_available_saved" 2
8011 } else {
8012 # Include the current process ID in the file names to prevent
8013 # conflicts with invocations for multiple testsuites.
8015 set src tls_get_addr_via_got[pid].c
8016 set obj tls_get_addr_via_got[pid].o
8018 set f [open $src "w"]
8019 puts $f "#include \"../../auto-host.h\""
8020 puts $f "#if HAVE_AS_IX86_TLS_GET_ADDR_GOT == 0"
8021 puts $f "# error Assembler/linker do not support calling ___tls_get_addr via GOT."
8022 puts $f "#endif"
8023 close $f
8025 verbose "check_effective_target_tls_get_addr_via_got compiling testfile $src" 2
8026 set lines [${tool}_target_compile $src $obj object ""]
8028 file delete $src
8029 file delete $obj
8031 if [string match "" $lines] then {
8032 verbose "check_effective_target_tls_get_addr_via_got testfile compilation passed" 2
8033 set tls_get_addr_via_got_available_saved 1
8034 } else {
8035 verbose "check_effective_target_tls_get_addr_via_got testfile compilation failed" 2
8036 set tls_get_addr_via_got_available_saved 0
8040 return $tls_get_addr_via_got_available_saved
8043 # Return 1 if the target uses comdat groups.
8045 proc check_effective_target_comdat_group {} {
8046 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
8047 // C++
8048 inline int foo () { return 1; }
8049 int (*fn) () = foo;
8053 # Return 1 if target supports __builtin_eh_return
8054 proc check_effective_target_builtin_eh_return { } {
8055 return [check_no_compiler_messages builtin_eh_return object {
8056 void test (long l, void *p)
8058 __builtin_eh_return (l, p);
8060 } "" ]
8063 # Return 1 if the target supports max reduction for vectors.
8065 proc check_effective_target_vect_max_reduc { } {
8066 if { [istarget aarch64*-*-*] || [istarget arm*-*-*] } {
8067 return 1
8069 return 0
8072 # Return 1 if there is an nvptx offload compiler.
8074 proc check_effective_target_offload_nvptx { } {
8075 return [check_no_compiler_messages offload_nvptx object {
8076 int main () {return 0;}
8077 } "-foffload=nvptx-none" ]
8080 # Return 1 if the compiler has been configured with hsa offloading.
8082 proc check_effective_target_offload_hsa { } {
8083 return [check_no_compiler_messages offload_hsa assembly {
8084 int main () {return 0;}
8085 } "-foffload=hsa" ]
8088 # Return 1 if the target support -fprofile-update=atomic
8089 proc check_effective_target_profile_update_atomic {} {
8090 return [check_no_compiler_messages profile_update_atomic assembly {
8091 int main (void) { return 0; }
8092 } "-fprofile-update=atomic -fprofile-generate"]