1 # Copyright
(C
) 1999-2015 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # gcc
-patches@gcc.gnu.org
20 # This file defines procs
for determining features supported by the target.
22 # Try to
compile the code given by CONTENTS into an output file of
23 # type TYPE
, where TYPE is as
for target_compile.
Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the
name of the output file.
27 # BASENAME is a prefix to use
for source and output files.
28 #
If ARGS is not empty
, its first element is a string that
29 # should be added to the command line.
31 # Assume by default that CONTENTS is C code.
32 # Otherwise
, code should contain
:
34 #
"! Fortran" for Fortran code,
36 #
"// ObjC++" for ObjC++
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} {
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]"]
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 }
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
74 assembly
{ set output $
{basename
}[pid
].s
}
75 object
{ set output $
{basename
}[pid
].o
}
76 executable
{ set output $
{basename
}[pid
].exe
}
78 set output $
{basename
}[pid
].s
79 lappend options
"additional_flags=-fdump-$type"
80 set compile_type assembly
86 set lines
[$
{tool
}_target_compile $src $output $compile_type
"$options"]
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]"
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
{ } {
107 if [info exists target_info
(target
,name)] {
108 set answer $target_info
(target
,name)
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 } {
121 set target
[current_target_name
]
122 if {![info exists et_cache
($prop
,target
)]
123 || $et_cache
($prop
,target
) != $target
} {
124 verbose
"check_cached_effective_target $prop: checking $target" 2
125 set et_cache
($prop
,target
) $target
126 set et_cache
($prop
,value
) [uplevel eval $
args]
128 set value $et_cache
($prop
,value
)
129 verbose
"check_cached_effective_target $prop: returning $value for $target" 2
133 # Like check_compile
, but
delete the output file and
return true
if the
134 # compiler printed no messages.
135 proc check_no_compiler_messages_nocache
{args} {
136 set result
[eval check_compile $
args]
137 set lines
[lindex $result
0]
138 set output
[lindex $result
1]
139 remote_file build
delete $output
140 return [string match
"" $lines]
143 # Like check_no_compiler_messages_nocache
, but
cache the result.
144 # PROP is the
property we
're checking, and doubles as a prefix for
145 # temporary filenames.
146 proc check_no_compiler_messages {prop args} {
147 return [check_cached_effective_target $prop {
148 eval [list check_no_compiler_messages_nocache $prop] $args
152 # Like check_compile, but return true if the compiler printed no
153 # messages and if the contents of the output file satisfy PATTERN.
154 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
155 # don't match regular expression REGEXP
, otherwise they satisfy it
156 #
if they
do match regular expression PATTERN.
(PATTERN can start
157 # with something like
"[!]" if the regular expression needs to match
158 #
"!" as the first character.)
160 #
Delete the output file before returning. The other arguments are
161 # as
for check_compile.
162 proc check_no_messages_and_pattern_nocache
{basename pattern
args} {
165 set result
[eval
[list check_compile $basename
] $
args]
166 set lines
[lindex $result
0]
167 set output
[lindex $result
1]
170 if { [string match
"" $lines] } {
171 set chan
[open
"$output"]
172 set invert
[regexp
{^
!(.
*)} $pattern dummy pattern
]
173 set ok
[expr
{ [regexp $pattern
[read $chan
]] != $invert
}]
177 remote_file build
delete $output
181 # Like check_no_messages_and_pattern_nocache
, but
cache the result.
182 # PROP is the
property we
're checking, and doubles as a prefix for
183 # temporary filenames.
184 proc check_no_messages_and_pattern {prop pattern args} {
185 return [check_cached_effective_target $prop {
186 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
190 # Try to compile and run an executable from code CONTENTS. Return true
191 # if the compiler reports no messages and if execution "passes" in the
192 # usual DejaGNU sense. The arguments are as for check_compile, with
193 # TYPE implicitly being "executable".
194 proc check_runtime_nocache {basename contents args} {
197 set result [eval [list check_compile $basename executable $contents] $args]
198 set lines [lindex $result 0]
199 set output [lindex $result 1]
202 if { [string match "" $lines] } {
203 # No error messages, everything is OK.
204 set result [remote_load target "./$output" "" ""]
205 set status [lindex $result 0]
206 verbose "check_runtime_nocache $basename: status is <$status>" 2
207 if { $status == "pass" } {
211 remote_file build delete $output
215 # Like check_runtime_nocache, but cache the result. PROP is the
216 # property we're checking
, and doubles as a prefix
for temporary
218 proc check_runtime
{prop
args} {
221 return [check_cached_effective_target $prop
{
222 eval
[list check_runtime_nocache $prop
] $
args
226 ###############################
227 # proc check_weak_available
{ }
228 ###############################
230 # weak symbols are only supported in some configs
/object formats
231 # this proc returns
1 if they
're supported, 0 if they're not
, or
-1 if unsure
233 proc check_weak_available
{ } {
236 # All mips targets should support it
238 if { [ string first
"mips" $target_cpu ] >= 0 } {
242 # All AIX targets should support it
244 if { [istarget
*-*-aix
*] } {
248 # All solaris2 targets should support it
250 if { [istarget
*-*-solaris2
*] } {
254 # Windows targets Cygwin and MingW32 support it
256 if { [istarget
*-*-cygwin
*] ||
[istarget
*-*-mingw
*] } {
260 # HP
-UX
10.X doesn
't support it
262 if { [istarget hppa*-*-hpux10*] } {
266 # ELF and ECOFF support it. a.out does with gas/gld but may also with
267 # other linkers, so we should try it
269 set objformat [gcc_target_object_format]
277 unknown { return -1 }
282 ###############################
283 # proc check_weak_override_available { }
284 ###############################
286 # Like check_weak_available, but return 0 if weak symbol definitions
287 # cannot be overridden.
289 proc check_weak_override_available { } {
290 if { [istarget *-*-mingw*] } {
293 return [check_weak_available]
296 ###############################
297 # proc check_visibility_available { what_kind }
298 ###############################
300 # The visibility attribute is only support in some object formats
301 # This proc returns 1 if it is supported, 0 if not.
302 # The argument is the kind of visibility, default/protected/hidden/internal.
304 proc check_visibility_available { what_kind } {
305 if [string match "" $what_kind] { set what_kind "hidden" }
307 return [check_no_compiler_messages visibility_available_$what_kind object "
308 void f() __attribute__((visibility(\"$what_kind\")));
313 ###############################
314 # proc check_alias_available { }
315 ###############################
317 # Determine if the target toolchain supports the alias attribute.
319 # Returns 2 if the target supports aliases. Returns 1 if the target
320 # only supports weak aliased. Returns 0 if the target does not
321 # support aliases at all. Returns -1 if support for aliases could not
324 proc check_alias_available { } {
325 global alias_available_saved
328 if [info exists alias_available_saved] {
329 verbose "check_alias_available returning saved $alias_available_saved" 2
333 verbose "check_alias_available compiling testfile $src" 2
334 set f [open $src "w"]
335 # Compile a small test program. The definition of "g" is
336 # necessary to keep the Solaris assembler from complaining
338 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
339 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
341 set lines [${tool}_target_compile $src $obj object ""]
343 remote_file build delete $obj
345 if [string match "" $lines] then {
346 # No error messages, everything is OK.
347 set alias_available_saved 2
349 if [regexp "alias definitions not supported" $lines] {
350 verbose "check_alias_available target does not support aliases" 2
352 set objformat [gcc_target_object_format]
354 if { $objformat == "elf" } {
355 verbose "check_alias_available but target uses ELF format, so it ought to" 2
356 set alias_available_saved -1
358 set alias_available_saved 0
361 if [regexp "only weak aliases are supported" $lines] {
362 verbose "check_alias_available target supports only weak aliases" 2
363 set alias_available_saved 1
365 set alias_available_saved -1
370 verbose "check_alias_available returning $alias_available_saved" 2
373 return $alias_available_saved
376 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
378 proc check_effective_target_alias { } {
379 if { [check_alias_available] < 2 } {
386 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
388 proc check_ifunc_available { } {
389 return [check_no_compiler_messages ifunc_available object {
394 void f() __attribute__((ifunc("g")));
398 # Returns true if --gc-sections is supported on the target.
400 proc check_gc_sections_available { } {
401 global gc_sections_available_saved
404 if {![info exists gc_sections_available_saved]} {
405 # Some targets don't support gc
-sections despite whatever
's
406 # advertised by ld's options.
407 if { [istarget alpha
*-*-*]
408 ||
[istarget ia64
-*-*] } {
409 set gc_sections_available_saved
0
413 # elf2flt uses
-q
(--emit
-relocs
), which is incompatible with
415 if { [board_info target
exists ldflags
]
416 && [regexp
" -elf2flt\[ =\]" " [board_info target ldflags] "] } {
417 set gc_sections_available_saved
0
421 # VxWorks kernel modules are relocatable objects linked with
-r
,
422 #
while RTP executables are linked with
-q
(--emit
-relocs
).
423 # Both of these options are incompatible with
--gc
-sections.
424 if { [istarget
*-*-vxworks
*] } {
425 set gc_sections_available_saved
0
429 # Check
if the
ld used by gcc supports
--gc
-sections.
430 set gcc_spec
[$
{tool
}_target_compile
"-dumpspecs" "" "none" ""]
431 regsub
".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
432 set gcc_ld
[lindex
[$
{tool
}_target_compile
"-print-prog-name=$linker" "" "none" ""] 0]
433 set ld_output
[remote_exec host
"$gcc_ld" "--help"]
434 if { [ string first
"--gc-sections" $ld_output ] >= 0 } {
435 set gc_sections_available_saved
1
437 set gc_sections_available_saved
0
440 return $gc_sections_available_saved
443 #
Return 1 if according to target_info struct and explicit target list
444 # target is supposed to support trampolines.
446 proc check_effective_target_trampolines
{ } {
447 if [target_info
exists no_trampolines
] {
450 if { [istarget avr
-*-*]
451 ||
[istarget msp430
-*-*]
452 ||
[istarget nvptx
-*-*]
453 ||
[istarget hppa2.0w
-hp
-hpux11.23
]
454 ||
[istarget hppa64
-hp
-hpux11.23
] } {
460 #
Return 1 if according to target_info struct and explicit target list
461 # target disables
-fdelete
-null
-pointer
-checks. Targets should
return 0
462 #
if they simply default to
-fno
-delete-null
-pointer
-checks but obey
463 #
-fdelete
-null
-pointer
-checks when passed explicitly
(and tests that
464 # depend
on this option should
do that
).
466 proc check_effective_target_keeps_null_pointer_checks
{ } {
467 if [target_info
exists keeps_null_pointer_checks
] {
470 if { [istarget avr
-*-*] } {
476 #
Return true
if profiling is supported
on the target.
478 proc check_profiling_available
{ test_what
} {
479 global profiling_available_saved
481 verbose
"Profiling argument is <$test_what>" 1
483 # These conditions depend
on the
argument so examine them before
484 # looking at the
cache variable.
486 # Tree profiling requires TLS runtime support.
487 if { $test_what
== "-fprofile-generate" } {
488 if { ![check_effective_target_tls_runtime
] } {
493 # Support
for -p
on solaris2 relies
on mcrt1.o which comes with the
494 # vendor compiler. We cannot reliably predict the directory where the
495 # vendor compiler
(and thus mcrt1.o
) is installed so we can
't
496 # necessarily find mcrt1.o even if we have it.
497 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
501 # We don't yet support profiling
for MIPS16.
502 if { [istarget mips
*-*-*]
503 && ![check_effective_target_nomips16
]
504 && ($test_what
== "-p" || $test_what == "-pg") } {
508 # MinGW does not support
-p.
509 if { [istarget
*-*-mingw
*] && $test_what
== "-p" } {
513 # cygwin does not support
-p.
514 if { [istarget
*-*-cygwin
*] && $test_what
== "-p" } {
518 # uClibc does not have gcrt1.o.
519 if { [check_effective_target_uclibc
]
520 && ($test_what
== "-p" || $test_what == "-pg") } {
524 # Now examine the
cache variable.
525 if {![info exists profiling_available_saved
]} {
526 # Some targets don
't have any implementation of __bb_init_func or are
527 # missing other needed machinery.
528 if {[istarget aarch64*-*-elf]
529 || [istarget am3*-*-linux*]
530 || [istarget arm*-*-eabi*]
531 || [istarget arm*-*-elf]
532 || [istarget arm*-*-symbianelf*]
533 || [istarget avr-*-*]
534 || [istarget bfin-*-*]
535 || [istarget cris-*-*]
536 || [istarget crisv32-*-*]
537 || [istarget fido-*-elf]
538 || [istarget h8300-*-*]
539 || [istarget lm32-*-*]
540 || [istarget m32c-*-elf]
541 || [istarget m68k-*-elf]
542 || [istarget m68k-*-uclinux*]
543 || [istarget mep-*-elf]
544 || [istarget mips*-*-elf*]
545 || [istarget mmix-*-*]
546 || [istarget mn10300-*-elf*]
547 || [istarget moxie-*-elf*]
548 || [istarget msp430-*-*]
549 || [istarget nds32*-*-elf]
550 || [istarget nios2-*-elf]
551 || [istarget nvptx-*-*]
552 || [istarget powerpc-*-eabi*]
553 || [istarget powerpc-*-elf]
555 || [istarget tic6x-*-elf]
556 || [istarget visium-*-*]
557 || [istarget xstormy16-*]
558 || [istarget xtensa*-*-elf]
559 || [istarget *-*-rtems*]
560 || [istarget *-*-vxworks*] } {
561 set profiling_available_saved 0
563 set profiling_available_saved 1
567 # -pg link test result can't be cached since it may change between
569 set profiling_working $profiling_available_saved
570 if { $profiling_available_saved
== 1
571 && ![check_no_compiler_messages_nocache profiling executable
{
572 int main
() { return 0; } } "-pg"] } {
573 set profiling_working
0
576 return $profiling_working
579 # Check to see
if a target is
"freestanding". This is as per the definition
580 # in Section
4 of C99 standard. Effectively
, it is a target which supports no
581 # extra headers or libraries other than what is considered essential.
582 proc check_effective_target_freestanding
{ } {
586 #
Return 1 if target has packed layout of structure members by
587 # default
, 0 otherwise. Note that this is slightly different than
588 # whether the target has
"natural alignment": both attributes may be
591 proc check_effective_target_default_packed
{ } {
592 return [check_no_compiler_messages default_packed assembly
{
593 struct x
{ char a
; long b
; } c
;
594 int s
[sizeof
(c
) == sizeof
(char
) + sizeof
(long
) ?
1 : -1];
598 #
Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
599 # documentation
, where the test also comes from.
601 proc check_effective_target_pcc_bitfield_type_matters
{ } {
602 # PCC_BITFIELD_TYPE_MATTERS isn
't just about unnamed or empty
603 # bitfields, but let's stick to the example code from the docs.
604 return [check_no_compiler_messages pcc_bitfield_type_matters assembly
{
605 struct foo1
{ char x
; char
:0; char y
; };
606 struct foo2
{ char x
; int :0; char y
; };
607 int s
[sizeof
(struct foo1
) != sizeof
(struct foo2
) ?
1 : -1];
611 # Add to FLAGS all the target
-specific flags needed to use thread
-local storage.
613 proc add_options_for_tls
{ flags
} {
614 #
On Solaris
9, __tls_get_addr
/___tls_get_addr only lives in
615 # libthread
, so always pass
-pthread
for native TLS. Same
for AIX.
616 # Need to duplicate native TLS check from
617 # check_effective_target_tls_native to avoid recursion.
618 if { ([istarget powerpc
-ibm
-aix
*]) &&
619 [check_no_messages_and_pattern tls_native
"!emutls" assembly {
621 int f
(void
) { return i
; }
622 void g
(int j
) { i
= j
; }
624 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
629 #
Return 1 if indirect jumps are supported
, 0 otherwise.
631 proc check_effective_target_indirect_jumps
{} {
632 if { [istarget nvptx
-*-*] } {
638 #
Return 1 if nonlocal
goto is supported
, 0 otherwise.
640 proc check_effective_target_nonlocal_goto
{} {
641 if { [istarget nvptx
-*-*] } {
647 #
Return 1 if taking label
values is supported
, 0 otherwise.
649 proc check_effective_target_label_values
{} {
650 if { [istarget nvptx
-*-*] } {
653 return [check_no_compiler_messages label_values assembly
{
654 #ifdef NO_LABEL_VALUES
660 #
Return 1 if builtin_return_address and builtin_frame_address are
661 # supported
, 0 otherwise.
663 proc check_effective_target_return_address
{} {
664 if { [istarget nvptx
-*-*] } {
670 #
Return 1 if the assembler does not verify function types against
671 # calls
, 0 otherwise. Such verification will typically
show up problems
672 # with K
&R C function declarations.
674 proc check_effective_target_untyped_assembly
{} {
675 if { [istarget nvptx
-*-*] } {
681 #
Return 1 if alloca is supported
, 0 otherwise.
683 proc check_effective_target_alloca
{} {
684 if { [istarget nvptx
-*-*] } {
690 #
Return 1 if thread local storage
(TLS
) is supported
, 0 otherwise.
692 proc check_effective_target_tls
{} {
693 return [check_no_compiler_messages tls assembly
{
695 int f
(void
) { return i
; }
696 void g
(int j
) { i
= j
; }
700 #
Return 1 if *native
* thread local storage
(TLS
) is supported
, 0 otherwise.
702 proc check_effective_target_tls_native
{} {
703 # VxWorks uses emulated TLS machinery
, but with non
-standard helper
704 # functions
, so we fail to automatically detect it.
705 if { [istarget
*-*-vxworks
*] } {
709 return [check_no_messages_and_pattern tls_native
"!emutls" assembly {
711 int f
(void
) { return i
; }
712 void g
(int j
) { i
= j
; }
716 #
Return 1 if *emulated
* thread local storage
(TLS
) is supported
, 0 otherwise.
718 proc check_effective_target_tls_emulated
{} {
719 # VxWorks uses emulated TLS machinery
, but with non
-standard helper
720 # functions
, so we fail to automatically detect it.
721 if { [istarget
*-*-vxworks
*] } {
725 return [check_no_messages_and_pattern tls_emulated
"emutls" assembly {
727 int f
(void
) { return i
; }
728 void g
(int j
) { i
= j
; }
732 #
Return 1 if TLS executables can run correctly
, 0 otherwise.
734 proc check_effective_target_tls_runtime
{} {
735 # The runtime does not have TLS support
, but just
736 # running the test below is insufficient to
show this.
737 if { [istarget msp430
-*-*] ||
[istarget visium
-*-*] } {
740 return [check_runtime tls_runtime
{
741 __thread
int thr
= 0;
742 int main
(void
) { return thr
; }
743 } [add_options_for_tls
""]]
746 #
Return 1 if atomic compare
-and
-swap is supported
on 'int'
748 proc check_effective_target_cas_char
{} {
749 return [check_no_compiler_messages cas_char assembly
{
750 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
756 proc check_effective_target_cas_int
{} {
757 return [check_no_compiler_messages cas_int assembly
{
758 #
if __INT_MAX__
== 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
760 #elif __INT_MAX__
== 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
768 #
Return 1 if -ffunction
-sections is supported
, 0 otherwise.
770 proc check_effective_target_function_sections
{} {
771 # Darwin has its own scheme and silently accepts
-ffunction
-sections.
772 if { [istarget
*-*-darwin
*] } {
776 return [check_no_compiler_messages functionsections assembly
{
778 } "-ffunction-sections"]
781 #
Return 1 if instruction scheduling is available
, 0 otherwise.
783 proc check_effective_target_scheduling
{} {
784 return [check_no_compiler_messages scheduling object
{
786 } "-fschedule-insns"]
789 #
Return 1 if trapping arithmetic is available
, 0 otherwise.
791 proc check_effective_target_trapping
{} {
792 return [check_no_compiler_messages trapping object
{
793 int add
(int a
, int b
) { return a
+ b
; }
797 #
Return 1 if compilation with
-fgraphite is error
-free
for trivial
800 proc check_effective_target_fgraphite
{} {
801 return [check_no_compiler_messages fgraphite object
{
806 #
Return 1 if compilation with
-fopenacc is error
-free
for trivial
809 proc check_effective_target_fopenacc
{} {
810 return [check_no_compiler_messages fopenacc object
{
815 #
Return 1 if compilation with
-fopenmp is error
-free
for trivial
818 proc check_effective_target_fopenmp
{} {
819 return [check_no_compiler_messages fopenmp object
{
824 #
Return 1 if compilation with
-fgnu
-tm is error
-free
for trivial
827 proc check_effective_target_fgnu_tm
{} {
828 return [check_no_compiler_messages fgnu_tm object
{
833 #
Return 1 if the target supports mmap
, 0 otherwise.
835 proc check_effective_target_mmap
{} {
836 return [check_function_available
"mmap"]
839 #
Return 1 if the target supports dlopen
, 0 otherwise.
840 proc check_effective_target_dlopen
{} {
841 return [check_no_compiler_messages dlopen executable
{
843 int main
(void
) { dlopen
("dummy.so", RTLD_NOW); }
844 } [add_options_for_dlopen
""]]
847 proc add_options_for_dlopen
{ flags
} {
851 #
Return 1 if the target supports clone
, 0 otherwise.
852 proc check_effective_target_clone
{} {
853 return [check_function_available
"clone"]
856 #
Return 1 if the target supports setrlimit
, 0 otherwise.
857 proc check_effective_target_setrlimit
{} {
858 # Darwin has non
-posix compliant RLIMIT_AS
859 if { [istarget
*-*-darwin
*] } {
862 return [check_function_available
"setrlimit"]
865 #
Return 1 if the target supports swapcontext
, 0 otherwise.
866 proc check_effective_target_swapcontext
{} {
867 return [check_no_compiler_messages swapcontext executable
{
868 #
include <ucontext.h
>
871 ucontext_t orig_context
,child_context
;
872 if (swapcontext
(&child_context
, &orig_context
) < 0) { }
877 #
Return 1 if compilation with
-pthread is error
-free
for trivial
880 proc check_effective_target_pthread
{} {
881 return [check_no_compiler_messages pthread object
{
886 #
Return 1 if compilation with
-mpe
-aligned
-commons is error
-free
887 #
for trivial code
, 0 otherwise.
889 proc check_effective_target_pe_aligned_commons
{} {
890 if { [istarget
*-*-cygwin
*] ||
[istarget
*-*-mingw
*] } {
891 return [check_no_compiler_messages pe_aligned_commons object
{
893 } "-mpe-aligned-commons"]
898 #
Return 1 if the target supports
-static
899 proc check_effective_target_static
{} {
900 return [check_no_compiler_messages static executable
{
901 int main
(void
) { return 0; }
905 #
Return 1 if the target supports
-fstack
-protector
906 proc check_effective_target_fstack_protector
{} {
907 return [check_runtime fstack_protector
{
908 int main
(void
) { return 0; }
909 } "-fstack-protector"]
912 #
Return 1 if compilation with
-freorder
-blocks
-and
-partition is error
-free
913 #
for trivial code
, 0 otherwise.
915 proc check_effective_target_freorder
{} {
916 return [check_no_compiler_messages freorder object
{
918 } "-freorder-blocks-and-partition"]
921 #
Return 1 if -fpic and
-fPIC are supported
, as in no warnings or errors
922 # emitted
, 0 otherwise. Whether a shared library can actually be built is
923 # out of scope
for this test.
925 proc check_effective_target_fpic
{ } {
926 # Note that M68K has a multilib that supports
-fpic but not
927 #
-fPIC
, so we need to check both. We test with a
program that
928 # requires GOT references.
929 foreach
arg {fpic fPIC
} {
930 if [check_no_compiler_messages $
arg object
{
931 extern
int foo
(void
); extern
int bar
;
932 int baz
(void
) { return foo
() + bar
; }
940 #
On AArch64
, if -fpic is not supported
, then we will fall
back to
-fPIC
941 # silently. So
, we can
't rely on above "check_effective_target_fpic" as it
942 # assumes compiler will give warning if -fpic not supported. Here we check
943 # whether binutils supports those new -fpic relocation modifiers, and assume
944 # -fpic is supported if there is binutils support. GCC configuration will
945 # enable -fpic for AArch64 in this case.
947 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
948 # memory model -fpic relocation types.
950 proc check_effective_target_aarch64_small_fpic { } {
951 if { [istarget aarch64*-*-*] } {
952 return [check_no_compiler_messages aarch64_small_fpic object {
953 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
960 # Return 1 if -shared is supported, as in no warnings or errors
961 # emitted, 0 otherwise.
963 proc check_effective_target_shared { } {
964 # Note that M68K has a multilib that supports -fpic but not
965 # -fPIC, so we need to check both. We test with a program that
966 # requires GOT references.
967 return [check_no_compiler_messages shared executable {
968 extern int foo (void); extern int bar;
969 int baz (void) { return foo () + bar; }
973 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
975 proc check_effective_target_pie { } {
976 if { [istarget *-*-darwin\[912\]*]
977 || [istarget *-*-freebsd*]
978 || [istarget *-*-linux*]
979 || [istarget *-*-gnu*] } {
985 # Return true if the target supports -mpaired-single (as used on MIPS).
987 proc check_effective_target_mpaired_single { } {
988 return [check_no_compiler_messages mpaired_single object {
993 # Return true if the target has access to FPU instructions.
995 proc check_effective_target_hard_float { } {
996 if { [istarget mips*-*-*] } {
997 return [check_no_compiler_messages hard_float assembly {
998 #if (defined __mips_soft_float || defined __mips16)
999 #error __mips_soft_float || __mips16
1004 # This proc is actually checking the availabilty of FPU
1005 # support for doubles, so on the RX we must fail if the
1006 # 64-bit double multilib has been selected.
1007 if { [istarget rx-*-*] } {
1009 # return [check_no_compiler_messages hard_float assembly {
1010 #if defined __RX_64_BIT_DOUBLES__
1011 #error __RX_64_BIT_DOUBLES__
1016 # The generic test equates hard_float with "no call for adding doubles".
1017 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1018 double a (double b, double c) { return b + c; }
1022 # Return true if the target is a 64-bit MIPS target.
1024 proc check_effective_target_mips64 { } {
1025 return [check_no_compiler_messages mips64 assembly {
1032 # Return true if the target is a MIPS target that does not produce
1035 proc check_effective_target_nomips16 { } {
1036 return [check_no_compiler_messages nomips16 object {
1040 /* A cheap way of testing for -mflip-mips16. */
1041 void foo (void) { asm ("addiu $20,$20,1"); }
1042 void bar (void) { asm ("addiu $20,$20,1"); }
1047 # Add the options needed for MIPS16 function attributes. At the moment,
1048 # we don't support MIPS16 PIC.
1050 proc add_options_for_mips16_attribute
{ flags
} {
1051 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1054 #
Return true
if we can force a
mode that allows MIPS16 code generation.
1055 # We don
't support MIPS16 PIC, and only support MIPS16 -mhard-float
1058 proc check_effective_target_mips16_attribute { } {
1059 return [check_no_compiler_messages mips16_attribute assembly {
1063 #if defined __mips_hard_float \
1064 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1065 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1066 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1068 } [add_options_for_mips16_attribute ""]]
1071 # Return 1 if the target supports long double larger than double when
1072 # using the new ABI, 0 otherwise.
1074 proc check_effective_target_mips_newabi_large_long_double { } {
1075 return [check_no_compiler_messages mips_newabi_large_long_double object {
1076 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1080 # Return true if the target is a MIPS target that has access
1081 # to the LL and SC instructions.
1083 proc check_effective_target_mips_llsc { } {
1084 if { ![istarget mips*-*-*] } {
1087 # Assume that these instructions are always implemented for
1088 # non-elf* targets, via emulation if necessary.
1089 if { ![istarget *-*-elf*] } {
1092 # Otherwise assume LL/SC support for everything but MIPS I.
1093 return [check_no_compiler_messages mips_llsc assembly {
1100 # Return true if the target is a MIPS target that uses in-place relocations.
1102 proc check_effective_target_mips_rel { } {
1103 if { ![istarget mips*-*-*] } {
1106 return [check_no_compiler_messages mips_rel object {
1107 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1108 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1109 #error _ABIN32 && (_ABIN32 || _ABI64)
1114 # Return true if the target is a MIPS target that uses the EABI.
1116 proc check_effective_target_mips_eabi { } {
1117 if { ![istarget mips*-*-*] } {
1120 return [check_no_compiler_messages mips_eabi object {
1127 # Return 1 if the current multilib does not generate PIC by default.
1129 proc check_effective_target_nonpic { } {
1130 return [check_no_compiler_messages nonpic assembly {
1137 # Return 1 if the current multilib generates PIE by default.
1139 proc check_effective_target_pie_enabled { } {
1140 return [check_no_compiler_messages pie_enabled assembly {
1147 # Return 1 if the target does not use a status wrapper.
1149 proc check_effective_target_unwrapped { } {
1150 if { [target_info needs_status_wrapper] != "" \
1151 && [target_info needs_status_wrapper] != "0" } {
1157 # Return true if iconv is supported on the target. In particular IBM1047.
1159 proc check_iconv_available { test_what } {
1162 # If the tool configuration file has not set libiconv, try "-liconv"
1163 if { ![info exists libiconv] } {
1164 set libiconv "-liconv"
1166 set test_what [lindex $test_what 1]
1167 return [check_runtime_nocache $test_what [subst {
1173 cd = iconv_open ("$test_what", "UTF-8");
1174 if (cd == (iconv_t) -1)
1181 # Return true if Cilk Library is supported on the target.
1182 proc check_libcilkrts_available { } {
1183 return [ check_no_compiler_messages_nocache libcilkrts_available executable {
1187 int __cilkrts_set_param (const char *, const char *);
1189 int x = __cilkrts_set_param ("nworkers", "0");
1192 } "-fcilkplus -lcilkrts" ]
1195 # Return true if the atomic library is supported on the target.
1196 proc check_effective_target_libatomic_available { } {
1197 return [check_no_compiler_messages libatomic_available executable {
1198 int main (void) { return 0; }
1202 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1204 proc check_ascii_locale_available { } {
1208 # Return true if named sections are supported on this target.
1210 proc check_named_sections_available { } {
1211 return [check_no_compiler_messages named_sections assembly {
1212 int __attribute__ ((section("whatever"))) foo;
1216 # Return true if the "naked" function attribute is supported on this target.
1218 proc check_effective_target_naked_functions { } {
1219 return [check_no_compiler_messages naked_functions assembly {
1220 void f() __attribute__((naked));
1224 # Return 1 if the target supports Fortran real kinds larger than real(8),
1227 # When the target name changes, replace the cached result.
1229 proc check_effective_target_fortran_large_real { } {
1230 return [check_no_compiler_messages fortran_large_real executable {
1232 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1239 # Return 1 if the target supports Fortran real kind real(16),
1240 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1241 # this checks for Real(16) only; the other returned real(10) if
1242 # both real(10) and real(16) are available.
1244 # When the target name changes, replace the cached result.
1246 proc check_effective_target_fortran_real_16 { } {
1247 return [check_no_compiler_messages fortran_real_16 executable {
1256 # Return 1 if the target supports Fortran's IEEE modules
,
1259 # When the target
name changes
, replace the cached result.
1261 proc check_effective_target_fortran_ieee
{ flags
} {
1262 return [check_no_compiler_messages fortran_ieee executable
{
1264 use
, intrinsic
:: ieee_features
1270 #
Return 1 if the target supports
SQRT for the
largest floating
-point
1271 # type.
(Some targets lack the libm support
for this FP type.
)
1272 #
On most targets
, this check effectively checks either whether sqrtl is
1273 # available or
on __float128 systems whether libquadmath is installed
,
1274 # which provides sqrtq.
1276 # When the target
name changes
, replace the cached result.
1278 proc check_effective_target_fortran_largest_fp_has_sqrt
{ } {
1279 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable
{
1281 use iso_fortran_env
, only
: real_kinds
1282 integer,parameter
:: maxFP
= real_kinds
(ubound
(real_kinds
,dim
=1))
1283 real
(kind
=maxFP
), volatile
:: x
1291 #
Return 1 if the target supports Fortran
integer kinds larger than
1292 #
integer(8), 0 otherwise.
1294 # When the target
name changes
, replace the cached result.
1296 proc check_effective_target_fortran_large_int
{ } {
1297 return [check_no_compiler_messages fortran_large_int executable
{
1299 integer,parameter
:: k
= selected_int_kind
(range
(0_8
) + 1)
1300 integer(kind
=k
) :: i
1305 #
Return 1 if the target supports Fortran
integer(16), 0 otherwise.
1307 # When the target
name changes
, replace the cached result.
1309 proc check_effective_target_fortran_integer_16
{ } {
1310 return [check_no_compiler_messages fortran_integer_16 executable
{
1317 #
Return 1 if we can statically link libgfortran
, 0 otherwise.
1319 # When the target
name changes
, replace the cached result.
1321 proc check_effective_target_static_libgfortran
{ } {
1322 return [check_no_compiler_messages static_libgfortran executable
{
1329 #
Return 1 if cilk
-plus is supported by the target
, 0 otherwise.
1331 proc check_effective_target_cilkplus
{ } {
1332 # Skip cilk
-plus tests
on int16 and size16 targets
for now.
1333 # The cilk
-plus tests are not generic enough to cover these
1334 # cases and would throw hundreds of FAILs.
1335 if { [check_effective_target_int16
]
1336 ||
![check_effective_target_size32plus
] } {
1340 # Skip AVR
, its RAM is too small and too many tests would fail.
1341 if { [istarget avr
-*-*] } {
1347 proc check_linker_plugin_available
{ } {
1348 return [check_no_compiler_messages_nocache linker_plugin executable
{
1349 int main
() { return 0; }
1350 } "-flto -fuse-linker-plugin"]
1353 #
Return 1 if the target supports executing
750CL paired
-single instructions
, 0
1354 # otherwise.
Cache the result.
1356 proc check_750cl_hw_available
{ } {
1357 return [check_cached_effective_target
750cl_hw_available
{
1358 #
If this is not the right target
then we can skip the test.
1359 if { ![istarget powerpc
-*paired
*] } {
1362 check_runtime_nocache
750cl_hw_available
{
1366 asm volatile
("ps_mul v0,v0,v0");
1368 asm volatile
("ps_mul 0,0,0");
1377 #
Return 1 if the target OS supports running SSE executables
, 0
1378 # otherwise.
Cache the result.
1380 proc check_sse_os_support_available
{ } {
1381 return [check_cached_effective_target sse_os_support_available
{
1382 #
If this is not the right target
then we can skip the test.
1383 if { !([istarget x86_64
-*-*] ||
[istarget i?
86-*-*]) } {
1385 } elseif
{ [istarget i?
86-*-solaris2
*] } {
1386 # The Solaris
2 kernel doesn
't save and restore SSE registers
1387 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1388 check_runtime_nocache sse_os_support_available {
1391 asm volatile ("movaps %xmm0,%xmm0");
1401 # Return 1 if the target OS supports running AVX executables, 0
1402 # otherwise. Cache the result.
1404 proc check_avx_os_support_available { } {
1405 return [check_cached_effective_target avx_os_support_available {
1406 # If this is not the right target then we can skip the test.
1407 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1410 # Check that OS has AVX and SSE saving enabled.
1411 check_runtime_nocache avx_os_support_available {
1414 unsigned int eax, edx;
1416 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1417 return (eax & 6) != 6;
1424 # Return 1 if the target supports executing SSE instructions, 0
1425 # otherwise. Cache the result.
1427 proc check_sse_hw_available { } {
1428 return [check_cached_effective_target sse_hw_available {
1429 # If this is not the right target then we can skip the test.
1430 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1433 check_runtime_nocache sse_hw_available {
1437 unsigned int eax, ebx, ecx, edx;
1438 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1439 return !(edx & bit_SSE);
1447 # Return 1 if the target supports executing SSE2 instructions, 0
1448 # otherwise. Cache the result.
1450 proc check_sse2_hw_available { } {
1451 return [check_cached_effective_target sse2_hw_available {
1452 # If this is not the right target then we can skip the test.
1453 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1456 check_runtime_nocache sse2_hw_available {
1460 unsigned int eax, ebx, ecx, edx;
1461 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1462 return !(edx & bit_SSE2);
1470 # Return 1 if the target supports executing AVX instructions, 0
1471 # otherwise. Cache the result.
1473 proc check_avx_hw_available { } {
1474 return [check_cached_effective_target avx_hw_available {
1475 # If this is not the right target then we can skip the test.
1476 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1479 check_runtime_nocache avx_hw_available {
1483 unsigned int eax, ebx, ecx, edx;
1484 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1485 return ((ecx & (bit_AVX | bit_OSXSAVE))
1486 != (bit_AVX | bit_OSXSAVE));
1494 # Return 1 if the target supports running SSE executables, 0 otherwise.
1496 proc check_effective_target_sse_runtime { } {
1497 if { [check_effective_target_sse]
1498 && [check_sse_hw_available]
1499 && [check_sse_os_support_available] } {
1505 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1507 proc check_effective_target_sse2_runtime { } {
1508 if { [check_effective_target_sse2]
1509 && [check_sse2_hw_available]
1510 && [check_sse_os_support_available] } {
1516 # Return 1 if the target supports running AVX executables, 0 otherwise.
1518 proc check_effective_target_avx_runtime { } {
1519 if { [check_effective_target_avx]
1520 && [check_avx_hw_available]
1521 && [check_avx_os_support_available] } {
1527 # Return 1 if the target supports executing power8 vector instructions, 0
1528 # otherwise. Cache the result.
1530 proc check_p8vector_hw_available { } {
1531 return [check_cached_effective_target p8vector_hw_available {
1532 # Some simulators are known to not support VSX/power8 instructions.
1533 # For now, disable on Darwin
1534 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1537 set options "-mpower8-vector"
1538 check_runtime_nocache p8vector_hw_available {
1542 asm volatile ("xxlorc vs0,vs0,vs0");
1544 asm volatile ("xxlorc 0,0,0");
1553 # Return 1 if the target supports executing VSX instructions, 0
1554 # otherwise. Cache the result.
1556 proc check_vsx_hw_available { } {
1557 return [check_cached_effective_target vsx_hw_available {
1558 # Some simulators are known to not support VSX instructions.
1559 # For now, disable on Darwin
1560 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1564 check_runtime_nocache vsx_hw_available {
1568 asm volatile ("xxlor vs0,vs0,vs0");
1570 asm volatile ("xxlor 0,0,0");
1579 # Return 1 if the target supports executing AltiVec instructions, 0
1580 # otherwise. Cache the result.
1582 proc check_vmx_hw_available { } {
1583 return [check_cached_effective_target vmx_hw_available {
1584 # Some simulators are known to not support VMX instructions.
1585 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1588 # Most targets don't require special flags
for this test case
, but
1589 # Darwin does. Just to be sure
, make sure VSX is not enabled
for
1590 # the altivec tests.
1591 if { [istarget
*-*-darwin
*]
1592 ||
[istarget
*-*-aix
*] } {
1593 set options
"-maltivec -mno-vsx"
1595 set options
"-mno-vsx"
1597 check_runtime_nocache vmx_hw_available
{
1601 asm volatile
("vor v0,v0,v0");
1603 asm volatile
("vor 0,0,0");
1612 proc check_ppc_recip_hw_available
{ } {
1613 return [check_cached_effective_target ppc_recip_hw_available
{
1614 # Some simulators may not support FRE
/FRES
/FRSQRTE
/FRSQRTES
1615 #
For now
, disable
on Darwin
1616 if { [istarget powerpc
-*-eabi
] ||
[istarget powerpc
*-*-eabispe
] ||
[istarget
*-*-darwin
*]} {
1619 set options
"-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1620 check_runtime_nocache ppc_recip_hw_available
{
1621 volatile double d_recip
, d_rsqrt
, d_four
= 4.0;
1622 volatile float f_recip
, f_rsqrt
, f_four
= 4.0f
;
1625 asm volatile
("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1626 asm volatile
("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1627 asm volatile
("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1628 asm volatile
("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1636 #
Return 1 if the target supports executing AltiVec and Cell PPU
1637 # instructions
, 0 otherwise.
Cache the result.
1639 proc check_effective_target_cell_hw
{ } {
1640 return [check_cached_effective_target cell_hw_available
{
1641 # Some simulators are known to not support VMX and PPU instructions.
1642 if { [istarget powerpc
-*-eabi
*] } {
1645 # Most targets don
't require special flags for this test
1646 # case, but Darwin and AIX do.
1647 if { [istarget *-*-darwin*]
1648 || [istarget *-*-aix*] } {
1649 set options "-maltivec -mcpu=cell"
1651 set options "-mcpu=cell"
1653 check_runtime_nocache cell_hw_available {
1657 asm volatile ("vor v0,v0,v0");
1658 asm volatile ("lvlx v0,r0,r0");
1660 asm volatile ("vor 0,0,0");
1661 asm volatile ("lvlx 0,0,0");
1670 # Return 1 if the target supports executing 64-bit instructions, 0
1671 # otherwise. Cache the result.
1673 proc check_effective_target_powerpc64 { } {
1674 global powerpc64_available_saved
1677 if [info exists powerpc64_available_saved] {
1678 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1680 set powerpc64_available_saved 0
1682 # Some simulators are known to not support powerpc64 instructions.
1683 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1684 verbose "check_effective_target_powerpc64 returning 0" 2
1685 return $powerpc64_available_saved
1688 # Set up, compile, and execute a test program containing a 64-bit
1689 # instruction. Include the current process ID in the file
1690 # names to prevent conflicts with invocations for multiple
1695 set f [open $src "w"]
1696 puts $f "int main() {"
1697 puts $f "#ifdef __MACH__"
1698 puts $f " asm volatile (\"extsw r0,r0\");"
1700 puts $f " asm volatile (\"extsw 0,0\");"
1702 puts $f " return 0; }"
1705 set opts "additional_flags=-mcpu=G5"
1707 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1708 set lines [${tool}_target_compile $src $exe executable "$opts"]
1711 if [string match "" $lines] then {
1712 # No error message, compilation succeeded.
1713 set result [${tool}_load "./$exe" "" ""]
1714 set status [lindex $result 0]
1715 remote_file build delete $exe
1716 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1718 if { $status == "pass" } then {
1719 set powerpc64_available_saved 1
1722 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1726 return $powerpc64_available_saved
1729 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1730 # complex float arguments. This affects gfortran tests that call cabsf
1731 # in libm built by an earlier compiler. Return 1 if libm uses the same
1732 # argument passing as the compiler under test, 0 otherwise.
1734 # When the target name changes, replace the cached result.
1736 proc check_effective_target_broken_cplxf_arg { } {
1737 return [check_cached_effective_target broken_cplxf_arg {
1738 # Skip the work for targets known not to be affected.
1739 if { ![istarget powerpc64-*-linux*] } {
1741 } elseif { ![is-effective-target lp64] } {
1744 check_runtime_nocache broken_cplxf_arg {
1745 #include <complex.h>
1746 extern void abort (void);
1747 float fabsf (float);
1748 float cabsf (_Complex float);
1755 if (fabsf (f - 5.0) > 0.0001)
1764 # Return 1 is this is a TI C6X target supporting C67X instructions
1765 proc check_effective_target_ti_c67x { } {
1766 return [check_no_compiler_messages ti_c67x assembly {
1767 #if !defined(_TMS320C6700)
1768 #error !_TMS320C6700
1773 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1774 proc check_effective_target_ti_c64xp { } {
1775 return [check_no_compiler_messages ti_c64xp assembly {
1776 #if !defined(_TMS320C6400_PLUS)
1777 #error !_TMS320C6400_PLUS
1783 proc check_alpha_max_hw_available { } {
1784 return [check_runtime alpha_max_hw_available {
1785 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1789 # Returns true iff the FUNCTION is available on the target system.
1790 # (This is essentially a Tcl implementation of Autoconf's
1793 proc check_function_available
{ function
} {
1794 return [check_no_compiler_messages $
{function
}_available \
1800 int main
() { $function
(); }
1804 # Returns true iff
"fork" is available on the target system.
1806 proc check_fork_available
{} {
1807 return [check_function_available
"fork"]
1810 # Returns true iff
"mkfifo" is available on the target system.
1812 proc check_mkfifo_available
{} {
1813 if { [istarget
*-*-cygwin
*] } {
1814 # Cygwin has mkfifo
, but support is incomplete.
1818 return [check_function_available
"mkfifo"]
1821 # Returns true iff
"__cxa_atexit" is used on the target system.
1823 proc check_cxa_atexit_available
{ } {
1824 return [check_cached_effective_target cxa_atexit_available
{
1825 if { [istarget hppa
*-*-hpux10
*] } {
1826 # HP
-UX
10 doesn
't have __cxa_atexit but subsequent test passes.
1828 } elseif { [istarget *-*-vxworks] } {
1829 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1832 check_runtime_nocache cxa_atexit_available
{
1835 static unsigned
int count;
1852 Y
() { f
(); count = 2; }
1861 int main
() { return 0; }
1867 proc check_effective_target_objc2
{ } {
1868 return [check_no_compiler_messages objc2 object
{
1877 proc check_effective_target_next_runtime
{ } {
1878 return [check_no_compiler_messages objc2 object
{
1879 #ifdef __NEXT_RUNTIME__
1882 #error
!__NEXT_RUNTIME__
1887 #
Return 1 if we
're generating 32-bit code using default options, 0
1890 proc check_effective_target_ilp32 { } {
1891 return [check_no_compiler_messages ilp32 object {
1892 int dummy[sizeof (int) == 4
1893 && sizeof (void *) == 4
1894 && sizeof (long) == 4 ? 1 : -1];
1898 # Return 1 if we're generating ia32 code using default options
, 0
1901 proc check_effective_target_ia32
{ } {
1902 return [check_no_compiler_messages ia32 object
{
1903 int dummy
[sizeof
(int) == 4
1904 && sizeof
(void
*) == 4
1905 && sizeof
(long
) == 4 ?
1 : -1] = { __i386__
};
1909 #
Return 1 if we
're generating x32 code using default options, 0
1912 proc check_effective_target_x32 { } {
1913 return [check_no_compiler_messages x32 object {
1914 int dummy[sizeof (int) == 4
1915 && sizeof (void *) == 4
1916 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1920 # Return 1 if we're generating
32-bit integers using default
1921 # options
, 0 otherwise.
1923 proc check_effective_target_int32
{ } {
1924 return [check_no_compiler_messages int32 object
{
1925 int dummy
[sizeof
(int) == 4 ?
1 : -1];
1929 #
Return 1 if we
're generating 32-bit or larger integers using default
1930 # options, 0 otherwise.
1932 proc check_effective_target_int32plus { } {
1933 return [check_no_compiler_messages int32plus object {
1934 int dummy[sizeof (int) >= 4 ? 1 : -1];
1938 # Return 1 if we're generating
32-bit or larger pointers using default
1939 # options
, 0 otherwise.
1941 proc check_effective_target_ptr32plus
{ } {
1942 # The msp430 has
16-bit or
20-bit pointers. The
20-bit pointer is stored
1943 # in a
32-bit slot when in memory
, so sizeof
(void
*) returns
4, but it
1944 # cannot really hold a
32-bit address
, so we always
return false here.
1945 if { [istarget msp430
-*-*] } {
1949 return [check_no_compiler_messages ptr32plus object
{
1950 int dummy
[sizeof
(void
*) >= 4 ?
1 : -1];
1954 #
Return 1 if we support
32-bit or larger array and structure sizes
1955 # using default options
, 0 otherwise. Avoid false positive
on
1956 # targets with
20 or
24 bit address spaces.
1958 proc check_effective_target_size32plus
{ } {
1959 return [check_no_compiler_messages size32plus object
{
1960 char dummy
[16777217L];
1964 # Returns
1 if we
're generating 16-bit or smaller integers with the
1965 # default options, 0 otherwise.
1967 proc check_effective_target_int16 { } {
1968 return [check_no_compiler_messages int16 object {
1969 int dummy[sizeof (int) < 4 ? 1 : -1];
1973 # Return 1 if we're generating
64-bit code using default options
, 0
1976 proc check_effective_target_lp64
{ } {
1977 return [check_no_compiler_messages lp64 object
{
1978 int dummy
[sizeof
(int) == 4
1979 && sizeof
(void
*) == 8
1980 && sizeof
(long
) == 8 ?
1 : -1];
1984 #
Return 1 if we
're generating 64-bit code using default llp64 options,
1987 proc check_effective_target_llp64 { } {
1988 return [check_no_compiler_messages llp64 object {
1989 int dummy[sizeof (int) == 4
1990 && sizeof (void *) == 8
1991 && sizeof (long long) == 8
1992 && sizeof (long) == 4 ? 1 : -1];
1996 # Return 1 if long and int have different sizes,
1999 proc check_effective_target_long_neq_int { } {
2000 return [check_no_compiler_messages long_ne_int object {
2001 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2005 # Return 1 if the target supports long double larger than double,
2008 proc check_effective_target_large_long_double { } {
2009 return [check_no_compiler_messages large_long_double object {
2010 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2014 # Return 1 if the target supports double larger than float,
2017 proc check_effective_target_large_double { } {
2018 return [check_no_compiler_messages large_double object {
2019 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2023 # Return 1 if the target supports long double of 128 bits,
2026 proc check_effective_target_longdouble128 { } {
2027 return [check_no_compiler_messages longdouble128 object {
2028 int dummy[sizeof(long double) == 16 ? 1 : -1];
2032 # Return 1 if the target supports double of 64 bits,
2035 proc check_effective_target_double64 { } {
2036 return [check_no_compiler_messages double64 object {
2037 int dummy[sizeof(double) == 8 ? 1 : -1];
2041 # Return 1 if the target supports double of at least 64 bits,
2044 proc check_effective_target_double64plus { } {
2045 return [check_no_compiler_messages double64plus object {
2046 int dummy[sizeof(double) >= 8 ? 1 : -1];
2050 # Return 1 if the target supports 'w
' suffix on floating constant
2053 proc check_effective_target_has_w_floating_suffix { } {
2055 if [check_effective_target_c++] {
2056 append opts "-std=gnu++03"
2058 return [check_no_compiler_messages w_fp_suffix object {
2063 # Return 1 if the target supports 'q
' suffix on floating constant
2066 proc check_effective_target_has_q_floating_suffix { } {
2068 if [check_effective_target_c++] {
2069 append opts "-std=gnu++03"
2071 return [check_no_compiler_messages q_fp_suffix object {
2075 # Return 1 if the target supports compiling fixed-point,
2078 proc check_effective_target_fixed_point { } {
2079 return [check_no_compiler_messages fixed_point object {
2080 _Sat _Fract x; _Sat _Accum y;
2084 # Return 1 if the target supports compiling decimal floating point,
2087 proc check_effective_target_dfp_nocache { } {
2088 verbose "check_effective_target_dfp_nocache: compiling source" 2
2089 set ret [check_no_compiler_messages_nocache dfp object {
2090 float x __attribute__((mode(DD)));
2092 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2096 proc check_effective_target_dfprt_nocache { } {
2097 return [check_runtime_nocache dfprt {
2098 typedef float d64 __attribute__((mode(DD)));
2099 d64 x = 1.2df, y = 2.3dd, z;
2100 int main () { z = x + y; return 0; }
2104 # Return 1 if the target supports compiling Decimal Floating Point,
2107 # This won't change
for different subtargets so
cache the result.
2109 proc check_effective_target_dfp
{ } {
2110 return [check_cached_effective_target dfp
{
2111 check_effective_target_dfp_nocache
2115 #
Return 1 if the target supports linking and executing Decimal Floating
2116 # Point
, 0 otherwise.
2118 # This won
't change for different subtargets so cache the result.
2120 proc check_effective_target_dfprt { } {
2121 return [check_cached_effective_target dfprt {
2122 check_effective_target_dfprt_nocache
2126 # Return 1 if the target supports executing DFP hardware instructions,
2127 # 0 otherwise. Cache the result.
2129 proc check_dfp_hw_available { } {
2130 return [check_cached_effective_target dfp_hw_available {
2131 # For now, disable on Darwin
2132 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2135 check_runtime_nocache dfp_hw_available {
2136 volatile _Decimal64 r;
2137 volatile _Decimal64 a = 4.0DD;
2138 volatile _Decimal64 b = 2.0DD;
2141 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2142 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2143 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2144 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2147 } "-mcpu=power6 -mhard-float"
2152 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2154 proc check_effective_target_ucn_nocache { } {
2155 # -std=c99 is only valid for C
2156 if [check_effective_target_c] {
2157 set ucnopts "-std=c99"
2161 verbose "check_effective_target_ucn_nocache: compiling source" 2
2162 set ret [check_no_compiler_messages_nocache ucn object {
2165 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2169 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2171 # This won't change
for different subtargets
, so
cache the result.
2173 proc check_effective_target_ucn
{ } {
2174 return [check_cached_effective_target ucn
{
2175 check_effective_target_ucn_nocache
2179 #
Return 1 if the target needs a command line
argument to enable a SIMD
2182 proc check_effective_target_vect_cmdline_needed
{ } {
2183 global et_vect_cmdline_needed_saved
2184 global et_vect_cmdline_needed_target_name
2186 if { ![info exists et_vect_cmdline_needed_target_name
] } {
2187 set et_vect_cmdline_needed_target_name
""
2190 #
If the target has changed since we
set the cached value
, clear it.
2191 set current_target
[current_target_name
]
2192 if { $current_target
!= $et_vect_cmdline_needed_target_name
} {
2193 verbose
"check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2194 set et_vect_cmdline_needed_target_name $current_target
2195 if { [info exists et_vect_cmdline_needed_saved
] } {
2196 verbose
"check_effective_target_vect_cmdline_needed: removing cached result" 2
2197 unset et_vect_cmdline_needed_saved
2201 if [info exists et_vect_cmdline_needed_saved
] {
2202 verbose
"check_effective_target_vect_cmdline_needed: using cached result" 2
2204 set et_vect_cmdline_needed_saved
1
2205 if { [istarget alpha
*-*-*]
2206 ||
[istarget ia64
-*-*]
2207 ||
(([istarget x86_64
-*-*] ||
[istarget i?
86-*-*])
2208 && ([check_effective_target_x32
]
2209 ||
[check_effective_target_lp64
]))
2210 ||
([istarget powerpc
*-*-*]
2211 && ([check_effective_target_powerpc_spe
]
2212 ||
[check_effective_target_powerpc_altivec
]))
2213 ||
([istarget sparc
*-*-*] && [check_effective_target_sparc_vis
])
2214 ||
[istarget spu
-*-*]
2215 ||
([istarget arm
*-*-*] && [check_effective_target_arm_neon
])
2216 ||
[istarget aarch64
*-*-*] } {
2217 set et_vect_cmdline_needed_saved
0
2221 verbose
"check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2222 return $et_vect_cmdline_needed_saved
2225 #
Return 1 if the target supports hardware vectors of
int, 0 otherwise.
2227 # This won
't change for different subtargets so cache the result.
2229 proc check_effective_target_vect_int { } {
2230 global et_vect_int_saved
2232 if [info exists et_vect_int_saved] {
2233 verbose "check_effective_target_vect_int: using cached result" 2
2235 set et_vect_int_saved 0
2236 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2237 || ([istarget powerpc*-*-*]
2238 && ![istarget powerpc-*-linux*paired*])
2239 || [istarget spu-*-*]
2240 || [istarget sparc*-*-*]
2241 || [istarget alpha*-*-*]
2242 || [istarget ia64-*-*]
2243 || [istarget aarch64*-*-*]
2244 || [check_effective_target_arm32]
2245 || ([istarget mips*-*-*]
2246 && [check_effective_target_mips_loongson]) } {
2247 set et_vect_int_saved 1
2251 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2252 return $et_vect_int_saved
2255 # Return 1 if the target supports signed int->float conversion
2258 proc check_effective_target_vect_intfloat_cvt { } {
2259 global et_vect_intfloat_cvt_saved
2261 if [info exists et_vect_intfloat_cvt_saved] {
2262 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2264 set et_vect_intfloat_cvt_saved 0
2265 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2266 || ([istarget powerpc*-*-*]
2267 && ![istarget powerpc-*-linux*paired*])
2268 || ([istarget arm*-*-*]
2269 && [check_effective_target_arm_neon_ok])} {
2270 set et_vect_intfloat_cvt_saved 1
2274 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2275 return $et_vect_intfloat_cvt_saved
2278 #Return 1 if we're supporting __int128
for target
, 0 otherwise.
2280 proc check_effective_target_int128
{ } {
2281 return [check_no_compiler_messages int128 object
{
2283 #ifndef __SIZEOF_INT128__
2292 #
Return 1 if the target supports unsigned
int->float conversion
2295 proc check_effective_target_vect_uintfloat_cvt
{ } {
2296 global et_vect_uintfloat_cvt_saved
2298 if [info exists et_vect_uintfloat_cvt_saved
] {
2299 verbose
"check_effective_target_vect_uintfloat_cvt: using cached result" 2
2301 set et_vect_uintfloat_cvt_saved
0
2302 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
2303 ||
([istarget powerpc
*-*-*]
2304 && ![istarget powerpc
-*-linux
*paired
*])
2305 ||
[istarget aarch64
*-*-*]
2306 ||
([istarget arm
*-*-*]
2307 && [check_effective_target_arm_neon_ok
])} {
2308 set et_vect_uintfloat_cvt_saved
1
2312 verbose
"check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2313 return $et_vect_uintfloat_cvt_saved
2317 #
Return 1 if the target supports signed float
->int conversion
2320 proc check_effective_target_vect_floatint_cvt
{ } {
2321 global et_vect_floatint_cvt_saved
2323 if [info exists et_vect_floatint_cvt_saved
] {
2324 verbose
"check_effective_target_vect_floatint_cvt: using cached result" 2
2326 set et_vect_floatint_cvt_saved
0
2327 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
2328 ||
([istarget powerpc
*-*-*]
2329 && ![istarget powerpc
-*-linux
*paired
*])
2330 ||
([istarget arm
*-*-*]
2331 && [check_effective_target_arm_neon_ok
])} {
2332 set et_vect_floatint_cvt_saved
1
2336 verbose
"check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2337 return $et_vect_floatint_cvt_saved
2340 #
Return 1 if the target supports unsigned float
->int conversion
2343 proc check_effective_target_vect_floatuint_cvt
{ } {
2344 global et_vect_floatuint_cvt_saved
2346 if [info exists et_vect_floatuint_cvt_saved
] {
2347 verbose
"check_effective_target_vect_floatuint_cvt: using cached result" 2
2349 set et_vect_floatuint_cvt_saved
0
2350 if { ([istarget powerpc
*-*-*]
2351 && ![istarget powerpc
-*-linux
*paired
*])
2352 ||
([istarget arm
*-*-*]
2353 && [check_effective_target_arm_neon_ok
])} {
2354 set et_vect_floatuint_cvt_saved
1
2358 verbose
"check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2359 return $et_vect_floatuint_cvt_saved
2362 #
Return 1 if the target supports #pragma omp declare simd
, 0 otherwise.
2364 # This won
't change for different subtargets so cache the result.
2366 proc check_effective_target_vect_simd_clones { } {
2367 global et_vect_simd_clones_saved
2369 if [info exists et_vect_simd_clones_saved] {
2370 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2372 set et_vect_simd_clones_saved 0
2373 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2374 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and
2375 # avx2 clone. Only the right clone for the specified arch will be
2376 # chosen, but still we need to at least be able to assemble
2378 if { [check_effective_target_avx2] } {
2379 set et_vect_simd_clones_saved 1
2384 verbose "check_effective_target_vect_simd_clones: returning $et_vect_simd_clones_saved" 2
2385 return $et_vect_simd_clones_saved
2388 # Return 1 if this is a AArch64 target supporting big endian
2389 proc check_effective_target_aarch64_big_endian { } {
2390 return [check_no_compiler_messages aarch64_big_endian assembly {
2391 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2392 #error !__aarch64__ || !__AARCH64EB__
2397 # Return 1 if this is a AArch64 target supporting little endian
2398 proc check_effective_target_aarch64_little_endian { } {
2399 if { ![istarget aarch64*-*-*] } {
2403 return [check_no_compiler_messages aarch64_little_endian assembly {
2404 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2410 # Return 1 if this is an arm target using 32-bit instructions
2411 proc check_effective_target_arm32 { } {
2412 if { ![istarget arm*-*-*] } {
2416 return [check_no_compiler_messages arm32 assembly {
2417 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2418 #error !__arm || __thumb__ && !__thumb2__
2423 # Return 1 if this is an arm target not using Thumb
2424 proc check_effective_target_arm_nothumb { } {
2425 if { ![istarget arm*-*-*] } {
2429 return [check_no_compiler_messages arm_nothumb assembly {
2430 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
2431 #error !__arm__ || __thumb || __thumb2__
2436 # Return 1 if this is a little-endian ARM target
2437 proc check_effective_target_arm_little_endian { } {
2438 if { ![istarget arm*-*-*] } {
2442 return [check_no_compiler_messages arm_little_endian assembly {
2443 #if !defined(__arm__) || !defined(__ARMEL__)
2444 #error !__arm__ || !__ARMEL__
2449 # Return 1 if this is an ARM target that only supports aligned vector accesses
2450 proc check_effective_target_arm_vect_no_misalign { } {
2451 if { ![istarget arm*-*-*] } {
2455 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2456 #if !defined(__arm__) \
2457 || (defined(__ARM_FEATURE_UNALIGNED) \
2458 && defined(__ARMEL__))
2459 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
2465 # Return 1 if this is an ARM target supporting -mfpu=vfp
2466 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2469 proc check_effective_target_arm_vfp_ok { } {
2470 if { [check_effective_target_arm32] } {
2471 return [check_no_compiler_messages arm_vfp_ok object {
2473 } "-mfpu=vfp -mfloat-abi=softfp"]
2479 # Return 1 if this is an ARM target supporting -mfpu=vfp3
2480 # -mfloat-abi=softfp.
2482 proc check_effective_target_arm_vfp3_ok { } {
2483 if { [check_effective_target_arm32] } {
2484 return [check_no_compiler_messages arm_vfp3_ok object {
2486 } "-mfpu=vfp3 -mfloat-abi=softfp"]
2492 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2493 # -mfloat-abi=softfp.
2494 proc check_effective_target_arm_v8_vfp_ok {} {
2495 if { [check_effective_target_arm32] } {
2496 return [check_no_compiler_messages arm_v8_vfp_ok object {
2499 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2502 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2508 # Return 1 if this is an ARM target supporting -mfpu=vfp
2509 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2512 proc check_effective_target_arm_hard_vfp_ok { } {
2513 if { [check_effective_target_arm32]
2514 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2515 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2516 int main() { return 0;}
2517 } "-mfpu=vfp -mfloat-abi=hard"]
2523 # Return 1 if this is an ARM target that supports DSP multiply with
2524 # current multilib flags.
2526 proc check_effective_target_arm_dsp { } {
2527 return [check_no_compiler_messages arm_dsp assembly {
2528 #ifndef __ARM_FEATURE_DSP
2535 # Return 1 if this is an ARM target that supports unaligned word/halfword
2536 # load/store instructions.
2538 proc check_effective_target_arm_unaligned { } {
2539 return [check_no_compiler_messages arm_unaligned assembly {
2540 #ifndef __ARM_FEATURE_UNALIGNED
2541 #error no unaligned support
2547 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2548 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2549 # incompatible with these options. Also set et_arm_crypto_flags to the
2550 # best options to add.
2552 proc check_effective_target_arm_crypto_ok_nocache { } {
2553 global et_arm_crypto_flags
2554 set et_arm_crypto_flags ""
2555 if { [check_effective_target_arm32] } {
2556 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2557 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2558 #include "arm_neon.h"
2560 foo (uint8x16_t a, uint8x16_t b)
2562 return vaeseq_u8 (a, b);
2565 set et_arm_crypto_flags $flags
2574 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2576 proc check_effective_target_arm_crypto_ok { } {
2577 return [check_cached_effective_target arm_crypto_ok \
2578 check_effective_target_arm_crypto_ok_nocache]
2581 # Add options for crypto extensions.
2582 proc add_options_for_arm_crypto { flags } {
2583 if { ! [check_effective_target_arm_crypto_ok] } {
2586 global et_arm_crypto_flags
2587 return "$flags $et_arm_crypto_flags"
2590 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2591 # or -mfloat-abi=hard, but if one is already specified by the
2592 # multilib, use it. Similarly, if a -mfpu option already enables
2593 # NEON, do not add -mfpu=neon.
2595 proc add_options_for_arm_neon { flags } {
2596 if { ! [check_effective_target_arm_neon_ok] } {
2599 global et_arm_neon_flags
2600 return "$flags $et_arm_neon_flags"
2603 proc add_options_for_arm_v8_vfp { flags } {
2604 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2607 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2610 proc add_options_for_arm_v8_neon { flags } {
2611 if { ! [check_effective_target_arm_v8_neon_ok] } {
2614 global et_arm_v8_neon_flags
2615 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2618 proc add_options_for_arm_crc { flags } {
2619 if { ! [check_effective_target_arm_crc_ok] } {
2622 global et_arm_crc_flags
2623 return "$flags $et_arm_crc_flags"
2626 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2627 # or -mfloat-abi=hard, but if one is already specified by the
2628 # multilib, use it. Similarly, if a -mfpu option already enables
2629 # NEON, do not add -mfpu=neon.
2631 proc add_options_for_arm_neonv2 { flags } {
2632 if { ! [check_effective_target_arm_neonv2_ok] } {
2635 global et_arm_neonv2_flags
2636 return "$flags $et_arm_neonv2_flags"
2639 # Add the options needed for vfp3.
2640 proc add_options_for_arm_vfp3 { flags } {
2641 if { ! [check_effective_target_arm_vfp3_ok] } {
2644 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
2647 # Return 1 if this is an ARM target supporting -mfpu=neon
2648 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2649 # incompatible with these options. Also set et_arm_neon_flags to the
2650 # best options to add.
2652 proc check_effective_target_arm_neon_ok_nocache { } {
2653 global et_arm_neon_flags
2654 set et_arm_neon_flags ""
2655 if { [check_effective_target_arm32] } {
2656 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2657 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2658 #include "arm_neon.h"
2660 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
2661 configured for -mcpu=arm926ej-s, for example. */
2663 #error Architecture too old for NEON.
2666 set et_arm_neon_flags $flags
2675 proc check_effective_target_arm_neon_ok { } {
2676 return [check_cached_effective_target arm_neon_ok \
2677 check_effective_target_arm_neon_ok_nocache]
2680 proc check_effective_target_arm_crc_ok_nocache { } {
2681 global et_arm_crc_flags
2682 set et_arm_crc_flags "-march=armv8-a+crc"
2683 return [check_no_compiler_messages_nocache arm_crc_ok object {
2684 #if !defined (__ARM_FEATURE_CRC32)
2687 } "$et_arm_crc_flags"]
2690 proc check_effective_target_arm_crc_ok { } {
2691 return [check_cached_effective_target arm_crc_ok \
2692 check_effective_target_arm_crc_ok_nocache]
2695 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2696 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2697 # incompatible with these options. Also set et_arm_neon_flags to the
2698 # best options to add.
2700 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2701 global et_arm_neon_fp16_flags
2702 set et_arm_neon_fp16_flags ""
2703 if { [check_effective_target_arm32] } {
2704 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2705 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
2706 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2707 #include "arm_neon.h"
2709 foo (float32x4_t arg)
2711 return vcvt_f16_f32 (arg);
2714 set et_arm_neon_fp16_flags $flags
2723 proc check_effective_target_arm_neon_fp16_ok { } {
2724 return [check_cached_effective_target arm_neon_fp16_ok \
2725 check_effective_target_arm_neon_fp16_ok_nocache]
2728 proc add_options_for_arm_neon_fp16 { flags } {
2729 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2732 global et_arm_neon_fp16_flags
2733 return "$flags $et_arm_neon_fp16_flags"
2736 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2737 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2738 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2739 # best options to add.
2741 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2742 global et_arm_v8_neon_flags
2743 set et_arm_v8_neon_flags ""
2744 if { [check_effective_target_arm32] } {
2745 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2746 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2748 #error not armv8 or later
2750 #include "arm_neon.h"
2754 __asm__ volatile ("vrintn.f32 q0, q0");
2756 } "$flags -march=armv8-a"] } {
2757 set et_arm_v8_neon_flags $flags
2766 proc check_effective_target_arm_v8_neon_ok { } {
2767 return [check_cached_effective_target arm_v8_neon_ok \
2768 check_effective_target_arm_v8_neon_ok_nocache]
2771 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2772 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2773 # incompatible with these options. Also set et_arm_neonv2_flags to the
2774 # best options to add.
2776 proc check_effective_target_arm_neonv2_ok_nocache { } {
2777 global et_arm_neonv2_flags
2778 set et_arm_neonv2_flags ""
2779 if { [check_effective_target_arm32] } {
2780 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2781 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2782 #include "arm_neon.h"
2784 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2786 return vfma_f32 (a, b, c);
2789 set et_arm_neonv2_flags $flags
2798 proc check_effective_target_arm_neonv2_ok { } {
2799 return [check_cached_effective_target arm_neonv2_ok \
2800 check_effective_target_arm_neonv2_ok_nocache]
2803 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2804 # or -mfloat-abi=hard, but if one is already specified by the
2807 proc add_options_for_arm_fp16 { flags } {
2808 if { ! [check_effective_target_arm_fp16_ok] } {
2811 global et_arm_fp16_flags
2812 return "$flags $et_arm_fp16_flags"
2815 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2816 # Skip multilibs that are incompatible with these options and set
2817 # et_arm_fp16_flags to the best options to add.
2819 proc check_effective_target_arm_fp16_ok_nocache { } {
2820 global et_arm_fp16_flags
2821 set et_arm_fp16_flags ""
2822 if { ! [check_effective_target_arm32] } {
2825 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2826 # Multilib flags would override -mfpu.
2829 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2830 # Must generate floating-point instructions.
2833 if [check_effective_target_arm_hf_eabi] {
2834 # Use existing float-abi and force an fpu which supports fp16
2835 set et_arm_fp16_flags "-mfpu=vfpv4"
2838 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2839 # The existing -mfpu value is OK; use it, but add softfp.
2840 set et_arm_fp16_flags "-mfloat-abi=softfp"
2843 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2844 # macro to check for this support.
2845 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2846 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2849 set et_arm_fp16_flags "$flags"
2856 proc check_effective_target_arm_fp16_ok { } {
2857 return [check_cached_effective_target arm_fp16_ok \
2858 check_effective_target_arm_fp16_ok_nocache]
2861 # Creates a series of routines that return 1 if the given architecture
2862 # can be selected and a routine to give the flags to select that architecture
2863 # Note: Extra flags may be added to disable options from newer compilers
2864 # (Thumb in particular - but others may be added in the future)
2865 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2866 # /* { dg-add-options arm_arch_v5 } */
2867 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2868 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2869 v4t "-march=armv4t" __ARM_ARCH_4T__
2870 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2871 v5t "-march=armv5t" __ARM_ARCH_5T__
2872 v5te "-march=armv5te" __ARM_ARCH_5TE__
2873 v6 "-march=armv6" __ARM_ARCH_6__
2874 v6k "-march=armv6k" __ARM_ARCH_6K__
2875 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2876 v6z "-march=armv6z" __ARM_ARCH_6Z__
2877 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2878 v7a "-march=armv7-a" __ARM_ARCH_7A__
2879 v7ve "-march=armv7ve" __ARM_ARCH_7A__
2880 v7r "-march=armv7-r" __ARM_ARCH_7R__
2881 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2882 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2883 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2884 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2885 proc check_effective_target_arm_arch_FUNC_ok { } {
2886 if { [ string match "*-marm*" "FLAG" ] &&
2887 ![check_effective_target_arm_arm_ok] } {
2890 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2897 proc add_options_for_arm_arch_FUNC { flags } {
2898 return "$flags FLAG"
2901 proc check_effective_target_arm_arch_FUNC_multilib { } {
2902 return [check_runtime arm_arch_FUNC_multilib {
2908 } [add_options_for_arm_arch_FUNC ""]]
2913 # Return 1 if this is an ARM target where -marm causes ARM to be
2916 proc check_effective_target_arm_arm_ok { } {
2917 return [check_no_compiler_messages arm_arm_ok assembly {
2918 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2919 #error !__arm__ || __thumb__ || __thumb2__
2925 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2928 proc check_effective_target_arm_thumb1_ok { } {
2929 return [check_no_compiler_messages arm_thumb1_ok assembly {
2930 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2931 #error !__arm__ || !__thumb__ || __thumb2__
2933 int foo (int i) { return i; }
2937 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2940 proc check_effective_target_arm_thumb2_ok { } {
2941 return [check_no_compiler_messages arm_thumb2_ok assembly {
2942 #if !defined(__thumb2__)
2945 int foo (int i) { return i; }
2949 # Return 1 if this is an ARM target where Thumb-1 is used without options
2950 # added by the test.
2952 proc check_effective_target_arm_thumb1 { } {
2953 return [check_no_compiler_messages arm_thumb1 assembly {
2954 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2955 #error !__arm__ || !__thumb__ || __thumb2__
2961 # Return 1 if this is an ARM target where Thumb-2 is used without options
2962 # added by the test.
2964 proc check_effective_target_arm_thumb2 { } {
2965 return [check_no_compiler_messages arm_thumb2 assembly {
2966 #if !defined(__thumb2__)
2973 # Return 1 if this is an ARM target where conditional execution is available.
2975 proc check_effective_target_arm_cond_exec { } {
2976 return [check_no_compiler_messages arm_cond_exec assembly {
2977 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
2984 # Return 1 if this is an ARM cortex-M profile cpu
2986 proc check_effective_target_arm_cortex_m { } {
2987 if { ![istarget arm*-*-*] } {
2990 return [check_no_compiler_messages arm_cortex_m assembly {
2991 #if !defined(__ARM_ARCH_7M__) \
2992 && !defined (__ARM_ARCH_7EM__) \
2993 && !defined (__ARM_ARCH_6M__)
2994 #error !__ARM_ARCH_7M__ && !__ARM_ARCH_7EM__ && !__ARM_ARCH_6M__
3000 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3002 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3003 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3004 int foo (void) { return 0; }
3005 } "-O2 -mprint-tune-info" ]
3008 # Return 1 if the target supports executing NEON instructions, 0
3009 # otherwise. Cache the result.
3011 proc check_effective_target_arm_neon_hw { } {
3012 return [check_runtime arm_neon_hw_available {
3016 long long a = 0, b = 1;
3017 asm ("vorr %P0, %P1, %P2"
3019 : "0" (a), "w" (b));
3022 } [add_options_for_arm_neon ""]]
3025 proc check_effective_target_arm_neonv2_hw { } {
3026 return [check_runtime arm_neon_hwv2_available {
3027 #include "arm_neon.h"
3031 float32x2_t a, b, c;
3032 asm ("vfma.f32 %P0, %P1, %P2"
3034 : "w" (b), "w" (c));
3037 } [add_options_for_arm_neonv2 ""]]
3040 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
3043 proc check_effective_target_arm_v8_neon_hw { } {
3044 return [check_runtime arm_v8_neon_hw_available {
3045 #include "arm_neon.h"
3050 asm ("vrinta.f32 %P0, %P1"
3055 } [add_options_for_arm_v8_neon ""]]
3058 # Return 1 if this is a ARM target with NEON enabled.
3060 proc check_effective_target_arm_neon { } {
3061 if { [check_effective_target_arm32] } {
3062 return [check_no_compiler_messages arm_neon object {
3063 #ifndef __ARM_NEON__
3074 proc check_effective_target_arm_neonv2 { } {
3075 if { [check_effective_target_arm32] } {
3076 return [check_no_compiler_messages arm_neon object {
3077 #ifndef __ARM_NEON__
3080 #ifndef __ARM_FEATURE_FMA
3092 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
3093 # the Loongson vector modes.
3095 proc check_effective_target_mips_loongson { } {
3096 return [check_no_compiler_messages loongson assembly {
3097 #if !defined(__mips_loongson_vector_rev)
3098 #error !__mips_loongson_vector_rev
3103 # Return 1 if this is a MIPS target that supports the legacy NAN.
3105 proc check_effective_target_mips_nanlegacy { } {
3106 return [check_no_compiler_messages nanlegacy assembly {
3108 int main () { return 0; }
3112 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
3115 proc check_effective_target_arm_eabi { } {
3116 return [check_no_compiler_messages arm_eabi object {
3117 #ifndef __ARM_EABI__
3125 # Return 1 if this is an ARM target that adheres to the hard-float variant of
3126 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
3128 proc check_effective_target_arm_hf_eabi { } {
3129 return [check_no_compiler_messages arm_hf_eabi object {
3130 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
3131 #error not hard-float EABI
3138 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
3139 # Some multilibs may be incompatible with this option.
3141 proc check_effective_target_arm_iwmmxt_ok { } {
3142 if { [check_effective_target_arm32] } {
3143 return [check_no_compiler_messages arm_iwmmxt_ok object {
3151 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
3152 # for an ARM target.
3153 proc check_effective_target_arm_prefer_ldrd_strd { } {
3154 if { ![check_effective_target_arm32] } {
3158 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
3159 void foo (int *p) { p[0] = 1; p[1] = 0;}
3163 # Return 1 if this is a PowerPC target supporting -meabi.
3165 proc check_effective_target_powerpc_eabi_ok { } {
3166 if { [istarget powerpc*-*-*] } {
3167 return [check_no_compiler_messages powerpc_eabi_ok object {
3175 # Return 1 if this is a PowerPC target with floating-point registers.
3177 proc check_effective_target_powerpc_fprs { } {
3178 if { [istarget powerpc*-*-*]
3179 || [istarget rs6000-*-*] } {
3180 return [check_no_compiler_messages powerpc_fprs object {
3192 # Return 1 if this is a PowerPC target with hardware double-precision
3195 proc check_effective_target_powerpc_hard_double { } {
3196 if { [istarget powerpc*-*-*]
3197 || [istarget rs6000-*-*] } {
3198 return [check_no_compiler_messages powerpc_hard_double object {
3210 # Return 1 if this is a PowerPC target supporting -maltivec.
3212 proc check_effective_target_powerpc_altivec_ok { } {
3213 if { ([istarget powerpc*-*-*]
3214 && ![istarget powerpc-*-linux*paired*])
3215 || [istarget rs6000-*-*] } {
3216 # AltiVec is not supported on AIX before 5.3.
3217 if { [istarget powerpc*-*-aix4*]
3218 || [istarget powerpc*-*-aix5.1*]
3219 || [istarget powerpc*-*-aix5.2*] } {
3222 return [check_no_compiler_messages powerpc_altivec_ok object {
3230 # Return 1 if this is a PowerPC target supporting -mpower8-vector
3232 proc check_effective_target_powerpc_p8vector_ok { } {
3233 if { ([istarget powerpc*-*-*]
3234 && ![istarget powerpc-*-linux*paired*])
3235 || [istarget rs6000-*-*] } {
3236 # AltiVec is not supported on AIX before 5.3.
3237 if { [istarget powerpc*-*-aix4*]
3238 || [istarget powerpc*-*-aix5.1*]
3239 || [istarget powerpc*-*-aix5.2*] } {
3242 return [check_no_compiler_messages powerpc_p8vector_ok object {
3245 asm volatile ("xxlorc vs0,vs0,vs0");
3247 asm volatile ("xxlorc 0,0,0");
3251 } "-mpower8-vector"]
3257 # Return 1 if this is a PowerPC target supporting -mvsx
3259 proc check_effective_target_powerpc_vsx_ok { } {
3260 if { ([istarget powerpc*-*-*]
3261 && ![istarget powerpc-*-linux*paired*])
3262 || [istarget rs6000-*-*] } {
3263 # VSX is not supported on AIX before 7.1.
3264 if { [istarget powerpc*-*-aix4*]
3265 || [istarget powerpc*-*-aix5*]
3266 || [istarget powerpc*-*-aix6*] } {
3269 return [check_no_compiler_messages powerpc_vsx_ok object {
3272 asm volatile ("xxlor vs0,vs0,vs0");
3274 asm volatile ("xxlor 0,0,0");
3284 # Return 1 if this is a PowerPC target supporting -mhtm
3286 proc check_effective_target_powerpc_htm_ok { } {
3287 if { ([istarget powerpc*-*-*]
3288 && ![istarget powerpc-*-linux*paired*])
3289 || [istarget rs6000-*-*] } {
3290 # HTM is not supported on AIX yet.
3291 if { [istarget powerpc*-*-aix*] } {
3294 return [check_no_compiler_messages powerpc_htm_ok object {
3296 asm volatile ("tbegin. 0");
3305 # Return 1 if the target supports executing HTM hardware instructions,
3306 # 0 otherwise. Cache the result.
3308 proc check_htm_hw_available { } {
3309 return [check_cached_effective_target htm_hw_available {
3310 # For now, disable on Darwin
3311 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
3314 check_runtime_nocache htm_hw_available {
3324 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
3326 proc check_effective_target_powerpc_ppu_ok { } {
3327 if [check_effective_target_powerpc_altivec_ok] {
3328 return [check_no_compiler_messages cell_asm_available object {
3331 asm volatile ("lvlx v0,v0,v0");
3333 asm volatile ("lvlx 0,0,0");
3343 # Return 1 if this is a PowerPC target that supports SPU.
3345 proc check_effective_target_powerpc_spu { } {
3346 if { [istarget powerpc*-*-linux*] } {
3347 return [check_effective_target_powerpc_altivec_ok]
3353 # Return 1 if this is a PowerPC SPE target. The check includes options
3354 # specified by dg-options for this test, so don't
cache the result.
3356 proc check_effective_target_powerpc_spe_nocache
{ } {
3357 if { [istarget powerpc
*-*-*] } {
3358 return [check_no_compiler_messages_nocache powerpc_spe object
{
3364 } [current_compiler_flags
]]
3370 #
Return 1 if this is a PowerPC target with SPE enabled.
3372 proc check_effective_target_powerpc_spe
{ } {
3373 if { [istarget powerpc
*-*-*] } {
3374 return [check_no_compiler_messages powerpc_spe object
{
3386 #
Return 1 if this is a PowerPC target with Altivec enabled.
3388 proc check_effective_target_powerpc_altivec
{ } {
3389 if { [istarget powerpc
*-*-*] } {
3390 return [check_no_compiler_messages powerpc_altivec object
{
3402 #
Return 1 if this is a PowerPC
405 target. The check includes options
3403 # specified by dg
-options
for this test
, so don
't cache the result.
3405 proc check_effective_target_powerpc_405_nocache { } {
3406 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3407 return [check_no_compiler_messages_nocache powerpc_405 object {
3413 } [current_compiler_flags]]
3419 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3421 proc check_effective_target_powerpc_elfv2 { } {
3422 if { [istarget powerpc*-*-*] } {
3423 return [check_no_compiler_messages powerpc_elfv2 object {
3425 #error not ELF v2 ABI
3435 # Return 1 if this is a SPU target with a toolchain that
3436 # supports automatic overlay generation.
3438 proc check_effective_target_spu_auto_overlay { } {
3439 if { [istarget spu*-*-elf*] } {
3440 return [check_no_compiler_messages spu_auto_overlay executable {
3442 } "-Wl,--auto-overlay" ]
3448 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3449 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3450 # test environment appears to run executables on such a simulator.
3452 proc check_effective_target_ultrasparc_hw { } {
3453 return [check_runtime ultrasparc_hw {
3454 int main() { return 0; }
3455 } "-mcpu=ultrasparc"]
3458 # Return 1 if the test environment supports executing UltraSPARC VIS2
3459 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3461 proc check_effective_target_ultrasparc_vis2_hw { } {
3462 return [check_runtime ultrasparc_vis2_hw {
3463 int main() { __asm__(".word 0x81b00320"); return 0; }
3464 } "-mcpu=ultrasparc3"]
3467 # Return 1 if the test environment supports executing UltraSPARC VIS3
3468 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3470 proc check_effective_target_ultrasparc_vis3_hw { } {
3471 return [check_runtime ultrasparc_vis3_hw {
3472 int main() { __asm__(".word 0x81b00220"); return 0; }
3476 # Return 1 if this is a SPARC-V9 target.
3478 proc check_effective_target_sparc_v9 { } {
3479 if { [istarget sparc*-*-*] } {
3480 return [check_no_compiler_messages sparc_v9 object {
3482 asm volatile ("return %i7+8");
3491 # Return 1 if this is a SPARC target with VIS enabled.
3493 proc check_effective_target_sparc_vis { } {
3494 if { [istarget sparc*-*-*] } {
3495 return [check_no_compiler_messages sparc_vis object {
3507 # Return 1 if the target supports hardware vector shift operation.
3509 proc check_effective_target_vect_shift { } {
3510 global et_vect_shift_saved
3512 if [info exists et_vect_shift_saved] {
3513 verbose "check_effective_target_vect_shift: using cached result" 2
3515 set et_vect_shift_saved 0
3516 if { ([istarget powerpc*-*-*]
3517 && ![istarget powerpc-*-linux*paired*])
3518 || [istarget ia64-*-*]
3519 || [istarget i?86-*-*] || [istarget x86_64-*-*]
3520 || [istarget aarch64*-*-*]
3521 || [check_effective_target_arm32]
3522 || ([istarget mips*-*-*]
3523 && [check_effective_target_mips_loongson]) } {
3524 set et_vect_shift_saved 1
3528 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3529 return $et_vect_shift_saved
3532 proc check_effective_target_whole_vector_shift { } {
3533 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3534 || [istarget ia64-*-*]
3535 || [istarget aarch64*-*-*]
3536 || ([check_effective_target_arm32]
3537 && [check_effective_target_arm_little_endian])
3538 || ([istarget mips*-*-*]
3539 && [check_effective_target_mips_loongson]) } {
3545 verbose "check_effective_target_vect_long: returning $answer" 2
3549 # Return 1 if the target supports vector bswap operations.
3551 proc check_effective_target_vect_bswap { } {
3552 global et_vect_bswap_saved
3554 if [info exists et_vect_bswap_saved] {
3555 verbose "check_effective_target_vect_bswap: using cached result" 2
3557 set et_vect_bswap_saved 0
3558 if { [istarget aarch64*-*-*]
3559 || ([istarget arm*-*-*]
3560 && [check_effective_target_arm_neon])
3562 set et_vect_bswap_saved 1
3566 verbose "check_effective_target_vect_bswap: returning $et_vect_bswap_saved" 2
3567 return $et_vect_bswap_saved
3570 # Return 1 if the target supports hardware vector shift operation for char.
3572 proc check_effective_target_vect_shift_char { } {
3573 global et_vect_shift_char_saved
3575 if [info exists et_vect_shift_char_saved] {
3576 verbose "check_effective_target_vect_shift_char: using cached result" 2
3578 set et_vect_shift_char_saved 0
3579 if { ([istarget powerpc*-*-*]
3580 && ![istarget powerpc-*-linux*paired*])
3581 || [check_effective_target_arm32] } {
3582 set et_vect_shift_char_saved 1
3586 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3587 return $et_vect_shift_char_saved
3590 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3592 # This can change for different subtargets so do not cache the result.
3594 proc check_effective_target_vect_long { } {
3595 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3596 || (([istarget powerpc*-*-*]
3597 && ![istarget powerpc-*-linux*paired*])
3598 && [check_effective_target_ilp32])
3599 || [check_effective_target_arm32]
3600 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3606 verbose "check_effective_target_vect_long: returning $answer" 2
3610 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3612 # This won't change
for different subtargets so
cache the result.
3614 proc check_effective_target_vect_float
{ } {
3615 global et_vect_float_saved
3617 if [info exists et_vect_float_saved
] {
3618 verbose
"check_effective_target_vect_float: using cached result" 2
3620 set et_vect_float_saved
0
3621 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
3622 ||
[istarget powerpc
*-*-*]
3623 ||
[istarget spu
-*-*]
3624 ||
[istarget mips
-sde
-elf
]
3625 ||
[istarget mipsisa64
*-*-*]
3626 ||
[istarget ia64
-*-*]
3627 ||
[istarget aarch64
*-*-*]
3628 ||
[check_effective_target_arm32
] } {
3629 set et_vect_float_saved
1
3633 verbose
"check_effective_target_vect_float: returning $et_vect_float_saved" 2
3634 return $et_vect_float_saved
3637 #
Return 1 if the target supports hardware vectors of double
, 0 otherwise.
3639 # This won
't change for different subtargets so cache the result.
3641 proc check_effective_target_vect_double { } {
3642 global et_vect_double_saved
3644 if [info exists et_vect_double_saved] {
3645 verbose "check_effective_target_vect_double: using cached result" 2
3647 set et_vect_double_saved 0
3648 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
3649 || [istarget aarch64*-*-*] } {
3650 if { [check_no_compiler_messages vect_double assembly {
3651 #ifdef __tune_atom__
3652 # error No double vectorizer support.
3655 set et_vect_double_saved 1
3657 set et_vect_double_saved 0
3659 } elseif { [istarget spu-*-*] } {
3660 set et_vect_double_saved 1
3664 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3665 return $et_vect_double_saved
3668 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3670 # This won't change
for different subtargets so
cache the result.
3672 proc check_effective_target_vect_long_long
{ } {
3673 global et_vect_long_long_saved
3675 if [info exists et_vect_long_long_saved
] {
3676 verbose
"check_effective_target_vect_long_long: using cached result" 2
3678 set et_vect_long_long_saved
0
3679 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*] } {
3680 set et_vect_long_long_saved
1
3684 verbose
"check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3685 return $et_vect_long_long_saved
3689 #
Return 1 if the target plus current options does not support a vector
3690 #
max instruction
on "int", 0 otherwise.
3692 # This won
't change for different subtargets so cache the result.
3694 proc check_effective_target_vect_no_int_max { } {
3695 global et_vect_no_int_max_saved
3697 if [info exists et_vect_no_int_max_saved] {
3698 verbose "check_effective_target_vect_no_int_max: using cached result" 2
3700 set et_vect_no_int_max_saved 0
3701 if { [istarget sparc*-*-*]
3702 || [istarget spu-*-*]
3703 || [istarget alpha*-*-*]
3704 || ([istarget mips*-*-*]
3705 && [check_effective_target_mips_loongson]) } {
3706 set et_vect_no_int_max_saved 1
3709 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
3710 return $et_vect_no_int_max_saved
3713 # Return 1 if the target plus current options does not support a vector
3714 # add instruction on "int", 0 otherwise.
3716 # This won't change
for different subtargets so
cache the result.
3718 proc check_effective_target_vect_no_int_add
{ } {
3719 global et_vect_no_int_add_saved
3721 if [info exists et_vect_no_int_add_saved
] {
3722 verbose
"check_effective_target_vect_no_int_add: using cached result" 2
3724 set et_vect_no_int_add_saved
0
3725 # Alpha only supports vector add
on V8QI and V4HI.
3726 if { [istarget alpha
*-*-*] } {
3727 set et_vect_no_int_add_saved
1
3730 verbose
"check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3731 return $et_vect_no_int_add_saved
3734 #
Return 1 if the target plus current options does not support vector
3735 # bitwise instructions
, 0 otherwise.
3737 # This won
't change for different subtargets so cache the result.
3739 proc check_effective_target_vect_no_bitwise { } {
3740 global et_vect_no_bitwise_saved
3742 if [info exists et_vect_no_bitwise_saved] {
3743 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3745 set et_vect_no_bitwise_saved 0
3747 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3748 return $et_vect_no_bitwise_saved
3751 # Return 1 if the target plus current options supports vector permutation,
3754 # This won't change
for different subtargets so
cache the result.
3756 proc check_effective_target_vect_perm
{ } {
3759 if [info exists et_vect_perm_saved
] {
3760 verbose
"check_effective_target_vect_perm: using cached result" 2
3762 set et_vect_perm_saved
0
3763 if { [is
-effective
-target arm_neon_ok
]
3764 ||
[istarget aarch64
*-*-*]
3765 ||
[istarget powerpc
*-*-*]
3766 ||
[istarget spu
-*-*]
3767 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
3768 ||
([istarget mips
*-*-*]
3769 && [check_effective_target_mpaired_single
]) } {
3770 set et_vect_perm_saved
1
3773 verbose
"check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3774 return $et_vect_perm_saved
3777 #
Return 1 if the target plus current options supports vector permutation
3778 #
on byte
-sized elements
, 0 otherwise.
3780 # This won
't change for different subtargets so cache the result.
3782 proc check_effective_target_vect_perm_byte { } {
3783 global et_vect_perm_byte
3785 if [info exists et_vect_perm_byte_saved] {
3786 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3788 set et_vect_perm_byte_saved 0
3789 if { ([is-effective-target arm_neon_ok]
3790 && [is-effective-target arm_little_endian])
3791 || ([istarget aarch64*-*-*]
3792 && [is-effective-target aarch64_little_endian])
3793 || [istarget powerpc*-*-*]
3794 || [istarget spu-*-*] } {
3795 set et_vect_perm_byte_saved 1
3798 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3799 return $et_vect_perm_byte_saved
3802 # Return 1 if the target plus current options supports vector permutation
3803 # on short-sized elements, 0 otherwise.
3805 # This won't change
for different subtargets so
cache the result.
3807 proc check_effective_target_vect_perm_short
{ } {
3808 global et_vect_perm_short
3810 if [info exists et_vect_perm_short_saved
] {
3811 verbose
"check_effective_target_vect_perm_short: using cached result" 2
3813 set et_vect_perm_short_saved
0
3814 if { ([is
-effective
-target arm_neon_ok
]
3815 && [is
-effective
-target arm_little_endian
])
3816 ||
([istarget aarch64
*-*-*]
3817 && [is
-effective
-target aarch64_little_endian
])
3818 ||
[istarget powerpc
*-*-*]
3819 ||
[istarget spu
-*-*] } {
3820 set et_vect_perm_short_saved
1
3823 verbose
"check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3824 return $et_vect_perm_short_saved
3827 #
Return 1 if the target plus current options supports a vector
3828 # widening summation of
*short
* args into
*int* result
, 0 otherwise.
3830 # This won
't change for different subtargets so cache the result.
3832 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3833 global et_vect_widen_sum_hi_to_si_pattern
3835 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3836 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3838 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3839 if { [istarget powerpc*-*-*]
3840 || [istarget ia64-*-*] } {
3841 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3844 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3845 return $et_vect_widen_sum_hi_to_si_pattern_saved
3848 # Return 1 if the target plus current options supports a vector
3849 # widening summation of *short* args into *int* result, 0 otherwise.
3850 # A target can also support this widening summation if it can support
3851 # promotion (unpacking) from shorts to ints.
3853 # This won't change
for different subtargets so
cache the result.
3855 proc check_effective_target_vect_widen_sum_hi_to_si
{ } {
3856 global et_vect_widen_sum_hi_to_si
3858 if [info exists et_vect_widen_sum_hi_to_si_saved
] {
3859 verbose
"check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3861 set et_vect_widen_sum_hi_to_si_saved
[check_effective_target_vect_unpack
]
3862 if { [istarget powerpc
*-*-*]
3863 ||
[istarget ia64
-*-*] } {
3864 set et_vect_widen_sum_hi_to_si_saved
1
3867 verbose
"check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3868 return $et_vect_widen_sum_hi_to_si_saved
3871 #
Return 1 if the target plus current options supports a vector
3872 # widening summation of
*char
* args into
*short
* result
, 0 otherwise.
3873 # A target can also support this widening summation
if it can support
3874 # promotion
(unpacking
) from chars to shorts.
3876 # This won
't change for different subtargets so cache the result.
3878 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3879 global et_vect_widen_sum_qi_to_hi
3881 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3882 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3884 set et_vect_widen_sum_qi_to_hi_saved 0
3885 if { [check_effective_target_vect_unpack]
3886 || [check_effective_target_arm_neon_ok]
3887 || [istarget ia64-*-*] } {
3888 set et_vect_widen_sum_qi_to_hi_saved 1
3891 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3892 return $et_vect_widen_sum_qi_to_hi_saved
3895 # Return 1 if the target plus current options supports a vector
3896 # widening summation of *char* args into *int* result, 0 otherwise.
3898 # This won't change
for different subtargets so
cache the result.
3900 proc check_effective_target_vect_widen_sum_qi_to_si
{ } {
3901 global et_vect_widen_sum_qi_to_si
3903 if [info exists et_vect_widen_sum_qi_to_si_saved
] {
3904 verbose
"check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3906 set et_vect_widen_sum_qi_to_si_saved
0
3907 if { [istarget powerpc
*-*-*] } {
3908 set et_vect_widen_sum_qi_to_si_saved
1
3911 verbose
"check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3912 return $et_vect_widen_sum_qi_to_si_saved
3915 #
Return 1 if the target plus current options supports a vector
3916 # widening multiplication of
*char
* args into
*short
* result
, 0 otherwise.
3917 # A target can also support this widening multplication
if it can support
3918 # promotion
(unpacking
) from chars to shorts
, and vect_short_mult
(non
-widening
3919 # multiplication of shorts
).
3921 # This won
't change for different subtargets so cache the result.
3924 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3925 global et_vect_widen_mult_qi_to_hi
3927 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3928 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3930 if { [check_effective_target_vect_unpack]
3931 && [check_effective_target_vect_short_mult] } {
3932 set et_vect_widen_mult_qi_to_hi_saved 1
3934 set et_vect_widen_mult_qi_to_hi_saved 0
3936 if { [istarget powerpc*-*-*]
3937 || [istarget aarch64*-*-*]
3938 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3939 set et_vect_widen_mult_qi_to_hi_saved 1
3942 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3943 return $et_vect_widen_mult_qi_to_hi_saved
3946 # Return 1 if the target plus current options supports a vector
3947 # widening multiplication of *short* args into *int* result, 0 otherwise.
3948 # A target can also support this widening multplication if it can support
3949 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3950 # multiplication of ints).
3952 # This won't change
for different subtargets so
cache the result.
3955 proc check_effective_target_vect_widen_mult_hi_to_si
{ } {
3956 global et_vect_widen_mult_hi_to_si
3958 if [info exists et_vect_widen_mult_hi_to_si_saved
] {
3959 verbose
"check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3961 if { [check_effective_target_vect_unpack
]
3962 && [check_effective_target_vect_int_mult
] } {
3963 set et_vect_widen_mult_hi_to_si_saved
1
3965 set et_vect_widen_mult_hi_to_si_saved
0
3967 if { [istarget powerpc
*-*-*]
3968 ||
[istarget spu
-*-*]
3969 ||
[istarget ia64
-*-*]
3970 ||
[istarget aarch64
*-*-*]
3971 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
3972 ||
([istarget arm
*-*-*] && [check_effective_target_arm_neon_ok
]) } {
3973 set et_vect_widen_mult_hi_to_si_saved
1
3976 verbose
"check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3977 return $et_vect_widen_mult_hi_to_si_saved
3980 #
Return 1 if the target plus current options supports a vector
3981 # widening multiplication of
*char
* args into
*short
* result
, 0 otherwise.
3983 # This won
't change for different subtargets so cache the result.
3985 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3986 global et_vect_widen_mult_qi_to_hi_pattern
3988 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3989 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3991 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3992 if { [istarget powerpc*-*-*]
3993 || ([istarget arm*-*-*]
3994 && [check_effective_target_arm_neon_ok]
3995 && [check_effective_target_arm_little_endian]) } {
3996 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3999 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
4000 return $et_vect_widen_mult_qi_to_hi_pattern_saved
4003 # Return 1 if the target plus current options supports a vector
4004 # widening multiplication of *short* args into *int* result, 0 otherwise.
4006 # This won't change
for different subtargets so
cache the result.
4008 proc check_effective_target_vect_widen_mult_hi_to_si_pattern
{ } {
4009 global et_vect_widen_mult_hi_to_si_pattern
4011 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved
] {
4012 verbose
"check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
4014 set et_vect_widen_mult_hi_to_si_pattern_saved
0
4015 if { [istarget powerpc
*-*-*]
4016 ||
[istarget spu
-*-*]
4017 ||
[istarget ia64
-*-*]
4018 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4019 ||
([istarget arm
*-*-*]
4020 && [check_effective_target_arm_neon_ok
]
4021 && [check_effective_target_arm_little_endian
]) } {
4022 set et_vect_widen_mult_hi_to_si_pattern_saved
1
4025 verbose
"check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
4026 return $et_vect_widen_mult_hi_to_si_pattern_saved
4029 #
Return 1 if the target plus current options supports a vector
4030 # widening multiplication of
*int* args into
*long
* result
, 0 otherwise.
4032 # This won
't change for different subtargets so cache the result.
4034 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
4035 global et_vect_widen_mult_si_to_di_pattern
4037 if [info exists et_vect_widen_mult_si_to_di_pattern_saved] {
4038 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: using cached result" 2
4040 set et_vect_widen_mult_si_to_di_pattern_saved 0
4041 if {[istarget ia64-*-*]
4042 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4043 set et_vect_widen_mult_si_to_di_pattern_saved 1
4046 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: returning $et_vect_widen_mult_si_to_di_pattern_saved" 2
4047 return $et_vect_widen_mult_si_to_di_pattern_saved
4050 # Return 1 if the target plus current options supports a vector
4051 # widening shift, 0 otherwise.
4053 # This won't change
for different subtargets so
cache the result.
4055 proc check_effective_target_vect_widen_shift
{ } {
4056 global et_vect_widen_shift_saved
4058 if [info exists et_vect_shift_saved
] {
4059 verbose
"check_effective_target_vect_widen_shift: using cached result" 2
4061 set et_vect_widen_shift_saved
0
4062 if { ([istarget arm
*-*-*] && [check_effective_target_arm_neon_ok
]) } {
4063 set et_vect_widen_shift_saved
1
4066 verbose
"check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
4067 return $et_vect_widen_shift_saved
4070 #
Return 1 if the target plus current options supports a vector
4071 # dot
-product of signed chars
, 0 otherwise.
4073 # This won
't change for different subtargets so cache the result.
4075 proc check_effective_target_vect_sdot_qi { } {
4076 global et_vect_sdot_qi
4078 if [info exists et_vect_sdot_qi_saved] {
4079 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
4081 set et_vect_sdot_qi_saved 0
4082 if { [istarget ia64-*-*] } {
4083 set et_vect_udot_qi_saved 1
4086 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
4087 return $et_vect_sdot_qi_saved
4090 # Return 1 if the target plus current options supports a vector
4091 # dot-product of unsigned chars, 0 otherwise.
4093 # This won't change
for different subtargets so
cache the result.
4095 proc check_effective_target_vect_udot_qi
{ } {
4096 global et_vect_udot_qi
4098 if [info exists et_vect_udot_qi_saved
] {
4099 verbose
"check_effective_target_vect_udot_qi: using cached result" 2
4101 set et_vect_udot_qi_saved
0
4102 if { [istarget powerpc
*-*-*]
4103 ||
[istarget ia64
-*-*] } {
4104 set et_vect_udot_qi_saved
1
4107 verbose
"check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
4108 return $et_vect_udot_qi_saved
4111 #
Return 1 if the target plus current options supports a vector
4112 # dot
-product of signed shorts
, 0 otherwise.
4114 # This won
't change for different subtargets so cache the result.
4116 proc check_effective_target_vect_sdot_hi { } {
4117 global et_vect_sdot_hi
4119 if [info exists et_vect_sdot_hi_saved] {
4120 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
4122 set et_vect_sdot_hi_saved 0
4123 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4124 || [istarget ia64-*-*]
4125 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4126 set et_vect_sdot_hi_saved 1
4129 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
4130 return $et_vect_sdot_hi_saved
4133 # Return 1 if the target plus current options supports a vector
4134 # dot-product of unsigned shorts, 0 otherwise.
4136 # This won't change
for different subtargets so
cache the result.
4138 proc check_effective_target_vect_udot_hi
{ } {
4139 global et_vect_udot_hi
4141 if [info exists et_vect_udot_hi_saved
] {
4142 verbose
"check_effective_target_vect_udot_hi: using cached result" 2
4144 set et_vect_udot_hi_saved
0
4145 if { ([istarget powerpc
*-*-*] && ![istarget powerpc
-*-linux
*paired
*]) } {
4146 set et_vect_udot_hi_saved
1
4149 verbose
"check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
4150 return $et_vect_udot_hi_saved
4153 #
Return 1 if the target plus current options supports a vector
4154 # sad operation of unsigned chars
, 0 otherwise.
4156 # This won
't change for different subtargets so cache the result.
4158 proc check_effective_target_vect_usad_char { } {
4159 global et_vect_usad_char
4161 if [info exists et_vect_usad_char_saved] {
4162 verbose "check_effective_target_vect_usad_char: using cached result" 2
4164 set et_vect_usad_char_saved 0
4165 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
4166 set et_vect_usad_char_saved 1
4169 verbose "check_effective_target_vect_usad_char: returning $et_vect_usad_char_saved" 2
4170 return $et_vect_usad_char_saved
4173 # Return 1 if the target plus current options supports a vector
4174 # demotion (packing) of shorts (to chars) and ints (to shorts)
4175 # using modulo arithmetic, 0 otherwise.
4177 # This won't change
for different subtargets so
cache the result.
4179 proc check_effective_target_vect_pack_trunc
{ } {
4180 global et_vect_pack_trunc
4182 if [info exists et_vect_pack_trunc_saved
] {
4183 verbose
"check_effective_target_vect_pack_trunc: using cached result" 2
4185 set et_vect_pack_trunc_saved
0
4186 if { ([istarget powerpc
*-*-*] && ![istarget powerpc
-*-linux
*paired
*])
4187 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4188 ||
[istarget aarch64
*-*-*]
4189 ||
[istarget spu
-*-*]
4190 ||
([istarget arm
*-*-*] && [check_effective_target_arm_neon_ok
]
4191 && [check_effective_target_arm_little_endian
]) } {
4192 set et_vect_pack_trunc_saved
1
4195 verbose
"check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
4196 return $et_vect_pack_trunc_saved
4199 #
Return 1 if the target plus current options supports a vector
4200 # promotion
(unpacking
) of chars
(to shorts
) and shorts
(to ints
), 0 otherwise.
4202 # This won
't change for different subtargets so cache the result.
4204 proc check_effective_target_vect_unpack { } {
4205 global et_vect_unpack
4207 if [info exists et_vect_unpack_saved] {
4208 verbose "check_effective_target_vect_unpack: using cached result" 2
4210 set et_vect_unpack_saved 0
4211 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
4212 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4213 || [istarget spu-*-*]
4214 || [istarget ia64-*-*]
4215 || [istarget aarch64*-*-*]
4216 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4217 && [check_effective_target_arm_little_endian]) } {
4218 set et_vect_unpack_saved 1
4221 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
4222 return $et_vect_unpack_saved
4225 # Return 1 if the target plus current options does not guarantee
4226 # that its STACK_BOUNDARY is >= the reguired vector alignment.
4228 # This won't change
for different subtargets so
cache the result.
4230 proc check_effective_target_unaligned_stack
{ } {
4231 global et_unaligned_stack_saved
4233 if [info exists et_unaligned_stack_saved
] {
4234 verbose
"check_effective_target_unaligned_stack: using cached result" 2
4236 set et_unaligned_stack_saved
0
4238 verbose
"check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
4239 return $et_unaligned_stack_saved
4242 #
Return 1 if the target plus current options does not support a vector
4243 # alignment mechanism
, 0 otherwise.
4245 # This won
't change for different subtargets so cache the result.
4247 proc check_effective_target_vect_no_align { } {
4248 global et_vect_no_align_saved
4250 if [info exists et_vect_no_align_saved] {
4251 verbose "check_effective_target_vect_no_align: using cached result" 2
4253 set et_vect_no_align_saved 0
4254 if { [istarget mipsisa64*-*-*]
4255 || [istarget mips-sde-elf]
4256 || [istarget sparc*-*-*]
4257 || [istarget ia64-*-*]
4258 || [check_effective_target_arm_vect_no_misalign]
4259 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4260 || ([istarget mips*-*-*]
4261 && [check_effective_target_mips_loongson]) } {
4262 set et_vect_no_align_saved 1
4265 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
4266 return $et_vect_no_align_saved
4269 # Return 1 if the target supports a vector misalign access, 0 otherwise.
4271 # This won't change
for different subtargets so
cache the result.
4273 proc check_effective_target_vect_hw_misalign
{ } {
4274 global et_vect_hw_misalign_saved
4276 if [info exists et_vect_hw_misalign_saved
] {
4277 verbose
"check_effective_target_vect_hw_misalign: using cached result" 2
4279 set et_vect_hw_misalign_saved
0
4280 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4281 ||
([istarget powerpc
*-*-*] && [check_p8vector_hw_available
])
4282 ||
[istarget aarch64
*-*-*] } {
4283 set et_vect_hw_misalign_saved
1
4286 verbose
"check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
4287 return $et_vect_hw_misalign_saved
4291 #
Return 1 if arrays are aligned to the vector alignment
4292 # boundary
, 0 otherwise.
4294 # This won
't change for different subtargets so cache the result.
4296 proc check_effective_target_vect_aligned_arrays { } {
4297 global et_vect_aligned_arrays
4299 if [info exists et_vect_aligned_arrays_saved] {
4300 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
4302 set et_vect_aligned_arrays_saved 0
4303 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4304 if { ([is-effective-target lp64]
4305 && ( ![check_avx_available]
4306 || [check_prefer_avx128])) } {
4307 set et_vect_aligned_arrays_saved 1
4310 if [istarget spu-*-*] {
4311 set et_vect_aligned_arrays_saved 1
4314 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
4315 return $et_vect_aligned_arrays_saved
4318 # Return 1 if types of size 32 bit or less are naturally aligned
4319 # (aligned to their type-size), 0 otherwise.
4321 # This won't change
for different subtargets so
cache the result.
4323 proc check_effective_target_natural_alignment_32
{ } {
4324 global et_natural_alignment_32
4326 if [info exists et_natural_alignment_32_saved
] {
4327 verbose
"check_effective_target_natural_alignment_32: using cached result" 2
4329 # FIXME
: 32bit powerpc
: guaranteed only
if MASK_ALIGN_NATURAL
/POWER.
4330 set et_natural_alignment_32_saved
1
4331 if { ([istarget
*-*-darwin
*] && [is
-effective
-target lp64
]) } {
4332 set et_natural_alignment_32_saved
0
4335 verbose
"check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
4336 return $et_natural_alignment_32_saved
4339 #
Return 1 if types of size
64 bit or less are naturally aligned
(aligned to their
4340 # type
-size
), 0 otherwise.
4342 # This won
't change for different subtargets so cache the result.
4344 proc check_effective_target_natural_alignment_64 { } {
4345 global et_natural_alignment_64
4347 if [info exists et_natural_alignment_64_saved] {
4348 verbose "check_effective_target_natural_alignment_64: using cached result" 2
4350 set et_natural_alignment_64_saved 0
4351 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
4352 || [istarget spu-*-*] } {
4353 set et_natural_alignment_64_saved 1
4356 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
4357 return $et_natural_alignment_64_saved
4360 # Return 1 if all vector types are naturally aligned (aligned to their
4361 # type-size), 0 otherwise.
4363 # This won't change
for different subtargets so
cache the result.
4365 proc check_effective_target_vect_natural_alignment
{ } {
4366 global et_vect_natural_alignment
4368 if [info exists et_vect_natural_alignment_saved
] {
4369 verbose
"check_effective_target_vect_natural_alignment: using cached result" 2
4371 set et_vect_natural_alignment_saved
1
4372 if { [check_effective_target_arm_eabi
]
4373 ||
[istarget nvptx
-*-*]
4374 ||
[istarget s390
*-*-*] } {
4375 set et_vect_natural_alignment_saved
0
4378 verbose
"check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
4379 return $et_vect_natural_alignment_saved
4382 #
Return 1 if vector alignment
(for types of size
32 bit or less
) is reachable
, 0 otherwise.
4384 # This won
't change for different subtargets so cache the result.
4386 proc check_effective_target_vector_alignment_reachable { } {
4387 global et_vector_alignment_reachable
4389 if [info exists et_vector_alignment_reachable_saved] {
4390 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
4392 if { [check_effective_target_vect_aligned_arrays]
4393 || [check_effective_target_natural_alignment_32] } {
4394 set et_vector_alignment_reachable_saved 1
4396 set et_vector_alignment_reachable_saved 0
4399 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
4400 return $et_vector_alignment_reachable_saved
4403 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
4405 # This won't change
for different subtargets so
cache the result.
4407 proc check_effective_target_vector_alignment_reachable_for_64bit
{ } {
4408 global et_vector_alignment_reachable_for_64bit
4410 if [info exists et_vector_alignment_reachable_for_64bit_saved
] {
4411 verbose
"check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
4413 if { [check_effective_target_vect_aligned_arrays
]
4414 ||
[check_effective_target_natural_alignment_64
] } {
4415 set et_vector_alignment_reachable_for_64bit_saved
1
4417 set et_vector_alignment_reachable_for_64bit_saved
0
4420 verbose
"check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
4421 return $et_vector_alignment_reachable_for_64bit_saved
4424 #
Return 1 if the target only requires element alignment
for vector accesses
4426 proc check_effective_target_vect_element_align
{ } {
4427 global et_vect_element_align
4429 if [info exists et_vect_element_align
] {
4430 verbose
"check_effective_target_vect_element_align: using cached result" 2
4432 set et_vect_element_align
0
4433 if { ([istarget arm
*-*-*]
4434 && ![check_effective_target_arm_vect_no_misalign
])
4435 ||
[check_effective_target_vect_hw_misalign
] } {
4436 set et_vect_element_align
1
4440 verbose
"check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4441 return $et_vect_element_align
4444 #
Return 1 if the target supports vector conditional operations
, 0 otherwise.
4446 proc check_effective_target_vect_condition
{ } {
4447 global et_vect_cond_saved
4449 if [info exists et_vect_cond_saved
] {
4450 verbose
"check_effective_target_vect_cond: using cached result" 2
4452 set et_vect_cond_saved
0
4453 if { [istarget aarch64
*-*-*]
4454 ||
[istarget powerpc
*-*-*]
4455 ||
[istarget ia64
-*-*]
4456 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4457 ||
[istarget spu
-*-*]
4458 ||
([istarget arm
*-*-*] && [check_effective_target_arm_neon_ok
]) } {
4459 set et_vect_cond_saved
1
4463 verbose
"check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
4464 return $et_vect_cond_saved
4467 #
Return 1 if the target supports vector conditional operations where
4468 # the comparison has different type from the lhs
, 0 otherwise.
4470 proc check_effective_target_vect_cond_mixed
{ } {
4471 global et_vect_cond_mixed_saved
4473 if [info exists et_vect_cond_mixed_saved
] {
4474 verbose
"check_effective_target_vect_cond_mixed: using cached result" 2
4476 set et_vect_cond_mixed_saved
0
4477 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4478 ||
[istarget powerpc
*-*-*] } {
4479 set et_vect_cond_mixed_saved
1
4483 verbose
"check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
4484 return $et_vect_cond_mixed_saved
4487 #
Return 1 if the target supports vector char multiplication
, 0 otherwise.
4489 proc check_effective_target_vect_char_mult
{ } {
4490 global et_vect_char_mult_saved
4492 if [info exists et_vect_char_mult_saved
] {
4493 verbose
"check_effective_target_vect_char_mult: using cached result" 2
4495 set et_vect_char_mult_saved
0
4496 if { [istarget aarch64
*-*-*]
4497 ||
[istarget ia64
-*-*]
4498 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4499 ||
[check_effective_target_arm32
] } {
4500 set et_vect_char_mult_saved
1
4504 verbose
"check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4505 return $et_vect_char_mult_saved
4508 #
Return 1 if the target supports vector short multiplication
, 0 otherwise.
4510 proc check_effective_target_vect_short_mult
{ } {
4511 global et_vect_short_mult_saved
4513 if [info exists et_vect_short_mult_saved
] {
4514 verbose
"check_effective_target_vect_short_mult: using cached result" 2
4516 set et_vect_short_mult_saved
0
4517 if { [istarget ia64
-*-*]
4518 ||
[istarget spu
-*-*]
4519 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4520 ||
[istarget powerpc
*-*-*]
4521 ||
[istarget aarch64
*-*-*]
4522 ||
[check_effective_target_arm32
]
4523 ||
([istarget mips
*-*-*]
4524 && [check_effective_target_mips_loongson
]) } {
4525 set et_vect_short_mult_saved
1
4529 verbose
"check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4530 return $et_vect_short_mult_saved
4533 #
Return 1 if the target supports vector
int multiplication
, 0 otherwise.
4535 proc check_effective_target_vect_int_mult
{ } {
4536 global et_vect_int_mult_saved
4538 if [info exists et_vect_int_mult_saved
] {
4539 verbose
"check_effective_target_vect_int_mult: using cached result" 2
4541 set et_vect_int_mult_saved
0
4542 if { ([istarget powerpc
*-*-*] && ![istarget powerpc
-*-linux
*paired
*])
4543 ||
[istarget spu
-*-*]
4544 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4545 ||
[istarget ia64
-*-*]
4546 ||
[istarget aarch64
*-*-*]
4547 ||
[check_effective_target_arm32
] } {
4548 set et_vect_int_mult_saved
1
4552 verbose
"check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4553 return $et_vect_int_mult_saved
4556 #
Return 1 if the target supports vector even
/odd elements extraction
, 0 otherwise.
4558 proc check_effective_target_vect_extract_even_odd
{ } {
4559 global et_vect_extract_even_odd_saved
4561 if [info exists et_vect_extract_even_odd_saved
] {
4562 verbose
"check_effective_target_vect_extract_even_odd: using cached result" 2
4564 set et_vect_extract_even_odd_saved
0
4565 if { [istarget aarch64
*-*-*]
4566 ||
[istarget powerpc
*-*-*]
4567 ||
[is
-effective
-target arm_neon_ok
]
4568 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4569 ||
[istarget ia64
-*-*]
4570 ||
[istarget spu
-*-*]
4571 ||
([istarget mips
*-*-*]
4572 && [check_effective_target_mpaired_single
]) } {
4573 set et_vect_extract_even_odd_saved
1
4577 verbose
"check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4578 return $et_vect_extract_even_odd_saved
4581 #
Return 1 if the target supports vector interleaving
, 0 otherwise.
4583 proc check_effective_target_vect_interleave
{ } {
4584 global et_vect_interleave_saved
4586 if [info exists et_vect_interleave_saved
] {
4587 verbose
"check_effective_target_vect_interleave: using cached result" 2
4589 set et_vect_interleave_saved
0
4590 if { [istarget aarch64
*-*-*]
4591 ||
[istarget powerpc
*-*-*]
4592 ||
[is
-effective
-target arm_neon_ok
]
4593 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4594 ||
[istarget ia64
-*-*]
4595 ||
[istarget spu
-*-*]
4596 ||
([istarget mips
*-*-*]
4597 && [check_effective_target_mpaired_single
]) } {
4598 set et_vect_interleave_saved
1
4602 verbose
"check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4603 return $et_vect_interleave_saved
4606 foreach N
{2 3 4 8} {
4607 eval
[string map
[list N $N
] {
4608 #
Return 1 if the target supports
2-vector interleaving
4609 proc check_effective_target_vect_stridedN
{ } {
4610 global et_vect_stridedN_saved
4612 if [info exists et_vect_stridedN_saved
] {
4613 verbose
"check_effective_target_vect_stridedN: using cached result" 2
4615 set et_vect_stridedN_saved
0
4617 && [check_effective_target_vect_interleave
]
4618 && [check_effective_target_vect_extract_even_odd
] } {
4619 set et_vect_stridedN_saved
1
4621 if { ([istarget arm
*-*-*]
4622 ||
[istarget aarch64
*-*-*]) && N
>= 2 && N
<= 4 } {
4623 set et_vect_stridedN_saved
1
4627 verbose
"check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4628 return $et_vect_stridedN_saved
4633 #
Return 1 if the target supports multiple vector sizes
4635 proc check_effective_target_vect_multiple_sizes
{ } {
4636 global et_vect_multiple_sizes_saved
4638 set et_vect_multiple_sizes_saved
0
4639 if { ([istarget aarch64
*-*-*]
4640 ||
([istarget arm
*-*-*] && [check_effective_target_arm_neon_ok
])) } {
4641 set et_vect_multiple_sizes_saved
1
4643 if { ([istarget x86_64
-*-*] ||
[istarget i?
86-*-*]) } {
4644 if { ([check_avx_available
] && ![check_prefer_avx128
]) } {
4645 set et_vect_multiple_sizes_saved
1
4649 verbose
"check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4650 return $et_vect_multiple_sizes_saved
4653 #
Return 1 if the target supports vectors of
64 bits.
4655 proc check_effective_target_vect64
{ } {
4656 global et_vect64_saved
4658 if [info exists et_vect64_saved
] {
4659 verbose
"check_effective_target_vect64: using cached result" 2
4661 set et_vect64_saved
0
4662 if { ([istarget arm
*-*-*]
4663 && [check_effective_target_arm_neon_ok
]
4664 && [check_effective_target_arm_little_endian
])
4665 ||
[istarget sparc
*-*-*] } {
4666 set et_vect64_saved
1
4670 verbose
"check_effective_target_vect64: returning $et_vect64_saved" 2
4671 return $et_vect64_saved
4674 #
Return 1 if the target supports vector copysignf calls.
4676 proc check_effective_target_vect_call_copysignf
{ } {
4677 global et_vect_call_copysignf_saved
4679 if [info exists et_vect_call_copysignf_saved
] {
4680 verbose
"check_effective_target_vect_call_copysignf: using cached result" 2
4682 set et_vect_call_copysignf_saved
0
4683 if { [istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4684 ||
[istarget powerpc
*-*-*] } {
4685 set et_vect_call_copysignf_saved
1
4689 verbose
"check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4690 return $et_vect_call_copysignf_saved
4693 #
Return 1 if the target supports hardware square root instructions.
4695 proc check_effective_target_sqrt_insn
{ } {
4696 global et_sqrt_insn_saved
4698 if [info exists et_sqrt_insn_saved
] {
4699 verbose
"check_effective_target_hw_sqrt: using cached result" 2
4701 set et_sqrt_insn_saved
0
4702 if { [istarget x86_64
-*-*]
4703 ||
[istarget powerpc
*-*-*]
4704 ||
[istarget aarch64
*-*-*]
4705 ||
([istarget arm
*-*-*] && [check_effective_target_arm_vfp_ok
]) } {
4706 set et_sqrt_insn_saved
1
4710 verbose
"check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
4711 return $et_sqrt_insn_saved
4714 #
Return 1 if the target supports vector sqrtf calls.
4716 proc check_effective_target_vect_call_sqrtf
{ } {
4717 global et_vect_call_sqrtf_saved
4719 if [info exists et_vect_call_sqrtf_saved
] {
4720 verbose
"check_effective_target_vect_call_sqrtf: using cached result" 2
4722 set et_vect_call_sqrtf_saved
0
4723 if { [istarget aarch64
*-*-*]
4724 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
4725 ||
([istarget powerpc
*-*-*] && [check_vsx_hw_available
]) } {
4726 set et_vect_call_sqrtf_saved
1
4730 verbose
"check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4731 return $et_vect_call_sqrtf_saved
4734 #
Return 1 if the target supports vector lrint calls.
4736 proc check_effective_target_vect_call_lrint
{ } {
4737 set et_vect_call_lrint
0
4738 if { ([istarget i?
86-*-*] ||
[istarget x86_64
-*-*])
4739 && [check_effective_target_ilp32
] } {
4740 set et_vect_call_lrint
1
4743 verbose
"check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4744 return $et_vect_call_lrint
4747 #
Return 1 if the target supports vector btrunc calls.
4749 proc check_effective_target_vect_call_btrunc
{ } {
4750 global et_vect_call_btrunc_saved
4752 if [info exists et_vect_call_btrunc_saved
] {
4753 verbose
"check_effective_target_vect_call_btrunc: using cached result" 2
4755 set et_vect_call_btrunc_saved
0
4756 if { [istarget aarch64
*-*-*] } {
4757 set et_vect_call_btrunc_saved
1
4761 verbose
"check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4762 return $et_vect_call_btrunc_saved
4765 #
Return 1 if the target supports vector btruncf calls.
4767 proc check_effective_target_vect_call_btruncf
{ } {
4768 global et_vect_call_btruncf_saved
4770 if [info exists et_vect_call_btruncf_saved
] {
4771 verbose
"check_effective_target_vect_call_btruncf: using cached result" 2
4773 set et_vect_call_btruncf_saved
0
4774 if { [istarget aarch64
*-*-*] } {
4775 set et_vect_call_btruncf_saved
1
4779 verbose
"check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4780 return $et_vect_call_btruncf_saved
4783 #
Return 1 if the target supports vector ceil calls.
4785 proc check_effective_target_vect_call_ceil
{ } {
4786 global et_vect_call_ceil_saved
4788 if [info exists et_vect_call_ceil_saved
] {
4789 verbose
"check_effective_target_vect_call_ceil: using cached result" 2
4791 set et_vect_call_ceil_saved
0
4792 if { [istarget aarch64
*-*-*] } {
4793 set et_vect_call_ceil_saved
1
4797 verbose
"check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4798 return $et_vect_call_ceil_saved
4801 #
Return 1 if the target supports vector ceilf calls.
4803 proc check_effective_target_vect_call_ceilf
{ } {
4804 global et_vect_call_ceilf_saved
4806 if [info exists et_vect_call_ceilf_saved
] {
4807 verbose
"check_effective_target_vect_call_ceilf: using cached result" 2
4809 set et_vect_call_ceilf_saved
0
4810 if { [istarget aarch64
*-*-*] } {
4811 set et_vect_call_ceilf_saved
1
4815 verbose
"check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4816 return $et_vect_call_ceilf_saved
4819 #
Return 1 if the target supports vector floor calls.
4821 proc check_effective_target_vect_call_floor
{ } {
4822 global et_vect_call_floor_saved
4824 if [info exists et_vect_call_floor_saved
] {
4825 verbose
"check_effective_target_vect_call_floor: using cached result" 2
4827 set et_vect_call_floor_saved
0
4828 if { [istarget aarch64
*-*-*] } {
4829 set et_vect_call_floor_saved
1
4833 verbose
"check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4834 return $et_vect_call_floor_saved
4837 #
Return 1 if the target supports vector floorf calls.
4839 proc check_effective_target_vect_call_floorf
{ } {
4840 global et_vect_call_floorf_saved
4842 if [info exists et_vect_call_floorf_saved
] {
4843 verbose
"check_effective_target_vect_call_floorf: using cached result" 2
4845 set et_vect_call_floorf_saved
0
4846 if { [istarget aarch64
*-*-*] } {
4847 set et_vect_call_floorf_saved
1
4851 verbose
"check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4852 return $et_vect_call_floorf_saved
4855 #
Return 1 if the target supports vector lceil calls.
4857 proc check_effective_target_vect_call_lceil
{ } {
4858 global et_vect_call_lceil_saved
4860 if [info exists et_vect_call_lceil_saved
] {
4861 verbose
"check_effective_target_vect_call_lceil: using cached result" 2
4863 set et_vect_call_lceil_saved
0
4864 if { [istarget aarch64
*-*-*] } {
4865 set et_vect_call_lceil_saved
1
4869 verbose
"check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4870 return $et_vect_call_lceil_saved
4873 #
Return 1 if the target supports vector lfloor calls.
4875 proc check_effective_target_vect_call_lfloor
{ } {
4876 global et_vect_call_lfloor_saved
4878 if [info exists et_vect_call_lfloor_saved
] {
4879 verbose
"check_effective_target_vect_call_lfloor: using cached result" 2
4881 set et_vect_call_lfloor_saved
0
4882 if { [istarget aarch64
*-*-*] } {
4883 set et_vect_call_lfloor_saved
1
4887 verbose
"check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4888 return $et_vect_call_lfloor_saved
4891 #
Return 1 if the target supports vector nearbyint calls.
4893 proc check_effective_target_vect_call_nearbyint
{ } {
4894 global et_vect_call_nearbyint_saved
4896 if [info exists et_vect_call_nearbyint_saved
] {
4897 verbose
"check_effective_target_vect_call_nearbyint: using cached result" 2
4899 set et_vect_call_nearbyint_saved
0
4900 if { [istarget aarch64
*-*-*] } {
4901 set et_vect_call_nearbyint_saved
1
4905 verbose
"check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4906 return $et_vect_call_nearbyint_saved
4909 #
Return 1 if the target supports vector nearbyintf calls.
4911 proc check_effective_target_vect_call_nearbyintf
{ } {
4912 global et_vect_call_nearbyintf_saved
4914 if [info exists et_vect_call_nearbyintf_saved
] {
4915 verbose
"check_effective_target_vect_call_nearbyintf: using cached result" 2
4917 set et_vect_call_nearbyintf_saved
0
4918 if { [istarget aarch64
*-*-*] } {
4919 set et_vect_call_nearbyintf_saved
1
4923 verbose
"check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4924 return $et_vect_call_nearbyintf_saved
4927 #
Return 1 if the target supports vector
round calls.
4929 proc check_effective_target_vect_call_round
{ } {
4930 global et_vect_call_round_saved
4932 if [info exists et_vect_call_round_saved
] {
4933 verbose
"check_effective_target_vect_call_round: using cached result" 2
4935 set et_vect_call_round_saved
0
4936 if { [istarget aarch64
*-*-*] } {
4937 set et_vect_call_round_saved
1
4941 verbose
"check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
4942 return $et_vect_call_round_saved
4945 #
Return 1 if the target supports vector roundf calls.
4947 proc check_effective_target_vect_call_roundf
{ } {
4948 global et_vect_call_roundf_saved
4950 if [info exists et_vect_call_roundf_saved
] {
4951 verbose
"check_effective_target_vect_call_roundf: using cached result" 2
4953 set et_vect_call_roundf_saved
0
4954 if { [istarget aarch64
*-*-*] } {
4955 set et_vect_call_roundf_saved
1
4959 verbose
"check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
4960 return $et_vect_call_roundf_saved
4963 #
Return 1 if the target supports section
-anchors
4965 proc check_effective_target_section_anchors
{ } {
4966 global et_section_anchors_saved
4968 if [info exists et_section_anchors_saved
] {
4969 verbose
"check_effective_target_section_anchors: using cached result" 2
4971 set et_section_anchors_saved
0
4972 if { [istarget powerpc
*-*-*]
4973 ||
[istarget arm
*-*-*] } {
4974 set et_section_anchors_saved
1
4978 verbose
"check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
4979 return $et_section_anchors_saved
4982 #
Return 1 if the target supports atomic operations
on "int_128" values.
4984 proc check_effective_target_sync_int_128
{ } {
4985 if { ([istarget x86_64
-*-*] ||
[istarget i?
86-*-*])
4986 && ![is
-effective
-target ia32
] } {
4993 #
Return 1 if the target supports atomic operations
on "int_128" values
4994 # and can
execute them.
4996 proc check_effective_target_sync_int_128_runtime
{ } {
4997 if { ([istarget x86_64
-*-*] ||
[istarget i?
86-*-*])
4998 && ![is
-effective
-target ia32
] } {
4999 return [check_cached_effective_target sync_int_128_available
{
5000 check_runtime_nocache sync_int_128_available
{
5004 unsigned
int eax
, ebx
, ecx
, edx
;
5005 if (__get_cpuid
(1, &eax
, &ebx
, &ecx
, &edx
))
5006 return !(ecx
& bit_CMPXCHG16B
);
5016 #
Return 1 if the target supports atomic operations
on "long long".
5018 # Note
: 32bit x86 targets require
-march
=pentium in dg
-options.
5020 proc check_effective_target_sync_long_long
{ } {
5021 if { [istarget x86_64
-*-*] ||
[istarget i?
86-*-*])
5022 ||
[istarget aarch64
*-*-*]
5023 ||
[istarget arm
*-*-*]
5024 ||
[istarget alpha
*-*-*]
5025 ||
([istarget sparc
*-*-*] && [check_effective_target_lp64
]) } {
5032 #
Return 1 if the target supports atomic operations
on "long long"
5033 # and can
execute them.
5035 # Note
: 32bit x86 targets require
-march
=pentium in dg
-options.
5037 proc check_effective_target_sync_long_long_runtime
{ } {
5038 if { [istarget x86_64
-*-*] ||
[istarget i?
86-*-*] } {
5039 return [check_cached_effective_target sync_long_long_available
{
5040 check_runtime_nocache sync_long_long_available
{
5044 unsigned
int eax
, ebx
, ecx
, edx
;
5045 if (__get_cpuid
(1, &eax
, &ebx
, &ecx
, &edx
))
5046 return !(edx
& bit_CMPXCHG8B
);
5051 } elseif
{ [istarget aarch64
*-*-*] } {
5053 } elseif
{ [istarget arm
*-*-linux
-*] } {
5054 return [check_runtime sync_longlong_runtime
{
5060 if (sizeof
(long long
) != 8)
5063 /* Just check
for native
; checking
for kernel fallback is tricky.
*/
5064 asm volatile
("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
5069 } elseif
{ [istarget alpha
*-*-*] } {
5071 } elseif
{ ([istarget sparc
*-*-*]
5072 && [check_effective_target_lp64
]
5073 && [check_effective_target_ultrasparc_hw
]) } {
5075 } elseif
{ [istarget powerpc
*-*-*] && [check_effective_target_lp64
] } {
5082 #
Return 1 if the target supports byte swap instructions.
5084 proc check_effective_target_bswap
{ } {
5085 global et_bswap_saved
5087 if [info exists et_bswap_saved
] {
5088 verbose
"check_effective_target_bswap: using cached result" 2
5090 set et_bswap_saved
0
5091 if { [istarget aarch64
*-*-*]
5092 ||
[istarget alpha
*-*-*]
5093 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
5094 ||
[istarget m68k
-*-*]
5095 ||
[istarget powerpc
*-*-*]
5096 ||
[istarget rs6000
-*-*]
5097 ||
[istarget s390
*-*-*] } {
5098 set et_bswap_saved
1
5100 if { [istarget arm
*-*-*]
5101 && [check_no_compiler_messages_nocache arm_v6_or_later object
{
5103 #error not armv6 or later
5107 set et_bswap_saved
1
5112 verbose
"check_effective_target_bswap: returning $et_bswap_saved" 2
5113 return $et_bswap_saved
5116 #
Return 1 if the target supports
16-bit byte swap instructions.
5118 proc check_effective_target_bswap16
{ } {
5119 global et_bswap16_saved
5121 if [info exists et_bswap16_saved
] {
5122 verbose
"check_effective_target_bswap16: using cached result" 2
5124 set et_bswap16_saved
0
5125 if { [is
-effective
-target bswap
]
5126 && ![istarget alpha
*-*-*]
5127 && !([istarget i?
86-*-*] ||
[istarget x86_64
-*-*]) } {
5128 set et_bswap16_saved
1
5132 verbose
"check_effective_target_bswap16: returning $et_bswap16_saved" 2
5133 return $et_bswap16_saved
5136 #
Return 1 if the target supports
32-bit byte swap instructions.
5138 proc check_effective_target_bswap32
{ } {
5139 global et_bswap32_saved
5141 if [info exists et_bswap32_saved
] {
5142 verbose
"check_effective_target_bswap32: using cached result" 2
5144 set et_bswap32_saved
0
5145 if { [is
-effective
-target bswap
] } {
5146 set et_bswap32_saved
1
5150 verbose
"check_effective_target_bswap32: returning $et_bswap32_saved" 2
5151 return $et_bswap32_saved
5154 #
Return 1 if the target supports
64-bit byte swap instructions.
5156 proc check_effective_target_bswap64
{ } {
5157 global et_bswap64_saved
5159 # expand_unop can expand
64-bit byte swap
on 32-bit targets
5160 if { [is
-effective
-target bswap
] && [is
-effective
-target int32plus
] } {
5166 #
Return 1 if the target supports atomic operations
on "int" and "long".
5168 proc check_effective_target_sync_int_long
{ } {
5169 global et_sync_int_long_saved
5171 if [info exists et_sync_int_long_saved
] {
5172 verbose
"check_effective_target_sync_int_long: using cached result" 2
5174 set et_sync_int_long_saved
0
5175 # This is intentionally powerpc but not rs6000
, rs6000 doesn
't have the
5176 # load-reserved/store-conditional instructions.
5177 if { [istarget ia64-*-*]
5178 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5179 || [istarget aarch64*-*-*]
5180 || [istarget alpha*-*-*]
5181 || [istarget arm*-*-linux-*]
5182 || [istarget bfin*-*linux*]
5183 || [istarget hppa*-*linux*]
5184 || [istarget s390*-*-*]
5185 || [istarget powerpc*-*-*]
5186 || [istarget crisv32-*-*] || [istarget cris-*-*]
5187 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5188 || [check_effective_target_mips_llsc] } {
5189 set et_sync_int_long_saved 1
5193 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
5194 return $et_sync_int_long_saved
5197 # Return 1 if the target supports atomic operations on "char" and "short".
5199 proc check_effective_target_sync_char_short { } {
5200 global et_sync_char_short_saved
5202 if [info exists et_sync_char_short_saved] {
5203 verbose "check_effective_target_sync_char_short: using cached result" 2
5205 set et_sync_char_short_saved 0
5206 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5207 #
load-reserved/store
-conditional instructions.
5208 if { [istarget aarch64
*-*-*]
5209 ||
[istarget ia64
-*-*]
5210 ||
[istarget i?
86-*-*] ||
[istarget x86_64
-*-*]
5211 ||
[istarget alpha
*-*-*]
5212 ||
[istarget arm
*-*-linux
-*]
5213 ||
[istarget hppa
*-*linux
*]
5214 ||
[istarget s390
*-*-*]
5215 ||
[istarget powerpc
*-*-*]
5216 ||
[istarget crisv32
-*-*] ||
[istarget cris
-*-*]
5217 ||
([istarget sparc
*-*-*] && [check_effective_target_sparc_v9
])
5218 ||
[check_effective_target_mips_llsc
] } {
5219 set et_sync_char_short_saved
1
5223 verbose
"check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
5224 return $et_sync_char_short_saved
5227 #
Return 1 if the target uses a ColdFire FPU.
5229 proc check_effective_target_coldfire_fpu
{ } {
5230 return [check_no_compiler_messages coldfire_fpu assembly
{
5237 #
Return true
if this is a uClibc target.
5239 proc check_effective_target_uclibc
{} {
5240 return [check_no_compiler_messages uclibc object
{
5241 #
include <features.h
>
5242 #
if !defined
(__UCLIBC__
)
5248 #
Return true
if this is a uclibc target and
if the uclibc feature
5249 # described by __$feature__ is not present.
5251 proc check_missing_uclibc_feature
{feature
} {
5252 return [check_no_compiler_messages $feature object
"
5253 #
include <features.h
>
5254 #
if !defined
(__UCLIBC
) || defined
(__$
{feature
}__
)
5260 #
Return true
if this is a Newlib target.
5262 proc check_effective_target_newlib
{} {
5263 return [check_no_compiler_messages newlib object
{
5268 #
Return true
if this is NOT a Bionic target.
5270 proc check_effective_target_non_bionic
{} {
5271 return [check_no_compiler_messages non_bionic object
{
5273 #
if defined
(__BIONIC__
)
5279 #
Return true
if this target has error.h header.
5281 proc check_effective_target_error_h
{} {
5282 return [check_no_compiler_messages error_h object
{
5287 #
Return true
if this target has tgmath.h header.
5289 proc check_effective_target_tgmath_h
{} {
5290 return [check_no_compiler_messages tgmath_h object
{
5295 #
Return true
if target
's libc supports complex functions.
5297 proc check_effective_target_libc_has_complex_functions {} {
5298 return [check_no_compiler_messages libc_has_complex_functions object {
5299 #include <complex.h>
5304 # (a) an error of a few ULP is expected in string to floating-point
5305 # conversion functions; and
5306 # (b) overflow is not always detected correctly by those functions.
5308 proc check_effective_target_lax_strtofp {} {
5309 # By default, assume that all uClibc targets suffer from this.
5310 return [check_effective_target_uclibc]
5313 # Return 1 if this is a target for which wcsftime is a dummy
5314 # function that always returns 0.
5316 proc check_effective_target_dummy_wcsftime {} {
5317 # By default, assume that all uClibc targets suffer from this.
5318 return [check_effective_target_uclibc]
5321 # Return 1 if constructors with initialization priority arguments are
5322 # supposed on this target.
5324 proc check_effective_target_init_priority {} {
5325 return [check_no_compiler_messages init_priority assembly "
5326 void f() __attribute__((constructor (1000)));
5331 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
5332 # This can be used with any check_* proc that takes no argument and
5333 # returns only 1 or 0. It could be used with check_* procs that take
5334 # arguments with keywords that pass particular arguments.
5336 proc is-effective-target { arg } {
5338 if { [info procs check_effective_target_${arg}] != [list] } {
5339 set selected [check_effective_target_${arg}]
5342 "vmx_hw" { set selected [check_vmx_hw_available] }
5343 "vsx_hw" { set selected [check_vsx_hw_available] }
5344 "p8vector_hw" { set selected [check_p8vector_hw_available] }
5345 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
5346 "dfp_hw" { set selected [check_dfp_hw_available] }
5347 "htm_hw" { set selected [check_htm_hw_available] }
5348 "named_sections" { set selected [check_named_sections_available] }
5349 "gc_sections" { set selected [check_gc_sections_available] }
5350 "cxa_atexit" { set selected [check_cxa_atexit_available] }
5351 default { error "unknown effective target keyword `$arg'" }
5354 verbose
"is-effective-target: $arg $selected" 2
5358 #
Return 1 if the
argument is an effective
-target keyword
, 0 otherwise.
5360 proc is
-effective
-target
-keyword
{ arg } {
5361 if { [info procs check_effective_target_$
{arg}] != [list
] } {
5364 # These have different names
for their check_
* procs.
5366 "vmx_hw" { return 1 }
5367 "vsx_hw" { return 1 }
5368 "p8vector_hw" { return 1 }
5369 "ppc_recip_hw" { return 1 }
5370 "dfp_hw" { return 1 }
5371 "htm_hw" { return 1 }
5372 "named_sections" { return 1 }
5373 "gc_sections" { return 1 }
5374 "cxa_atexit" { return 1 }
5375 default
{ return 0 }
5380 #
Return 1 if target default to short enums
5382 proc check_effective_target_short_enums
{ } {
5383 return [check_no_compiler_messages short_enums assembly
{
5385 int s
[sizeof
(enum foo
) == 1 ?
1 : -1];
5389 #
Return 1 if target supports merging string constants at link time.
5391 proc check_effective_target_string_merging
{ } {
5392 return [check_no_messages_and_pattern string_merging \
5393 "rodata\\.str" assembly {
5394 const char
*var
= "String";
5398 #
Return 1 if target has the basic signed and unsigned types in
5399 #
<stdint.h
>, 0 otherwise. This will be obsolete when GCC ensures a
5400 # working
<stdint.h
> for all targets.
5402 proc check_effective_target_stdint_types
{ } {
5403 return [check_no_compiler_messages stdint_types assembly
{
5405 int8_t a
; int16_t b
; int32_t c
; int64_t d
;
5406 uint8_t e
; uint16_t f
; uint32_t g
; uint64_t h
;
5410 #
Return 1 if target has the basic signed and unsigned types in
5411 #
<inttypes.h
>, 0 otherwise. This is
for tests that GCC
's notions of
5412 # these types agree with those in the header, as some systems have
5413 # only <inttypes.h>.
5415 proc check_effective_target_inttypes_types { } {
5416 return [check_no_compiler_messages inttypes_types assembly {
5417 #include <inttypes.h>
5418 int8_t a; int16_t b; int32_t c; int64_t d;
5419 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5423 # Return 1 if programs are intended to be run on a simulator
5424 # (i.e. slowly) rather than hardware (i.e. fast).
5426 proc check_effective_target_simulator { } {
5428 # All "src/sim" simulators set this one.
5429 if [board_info target exists is_simulator] {
5430 return [board_info target is_simulator]
5433 # The "sid" simulators don't
set that one
, but at least they
set
5435 if [board_info target
exists slow_simulator
] {
5436 return [board_info target slow_simulator
]
5442 #
Return 1 if programs are intended to be run
on hardware rather than
5445 proc check_effective_target_hw
{ } {
5447 # All
"src/sim" simulators set this one.
5448 if [board_info target
exists is_simulator
] {
5449 if [board_info target is_simulator
] {
5456 # The
"sid" simulators don't set that one, but at least they set
5458 if [board_info target
exists slow_simulator
] {
5459 if [board_info target slow_simulator
] {
5469 #
Return 1 if the target is a VxWorks kernel.
5471 proc check_effective_target_vxworks_kernel
{ } {
5472 return [check_no_compiler_messages vxworks_kernel assembly
{
5473 #
if !defined __vxworks || defined __RTP__
5479 #
Return 1 if the target is a VxWorks RTP.
5481 proc check_effective_target_vxworks_rtp
{ } {
5482 return [check_no_compiler_messages vxworks_rtp assembly
{
5483 #
if !defined __vxworks ||
!defined __RTP__
5489 #
Return 1 if the target is expected to provide wide character support.
5491 proc check_effective_target_wchar
{ } {
5492 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR
]} {
5495 return [check_no_compiler_messages wchar assembly
{
5500 #
Return 1 if the target has
<pthread.h
>.
5502 proc check_effective_target_pthread_h
{ } {
5503 return [check_no_compiler_messages pthread_h assembly
{
5504 #
include <pthread.h
>
5508 #
Return 1 if the target can truncate a file from a file
-descriptor
,
5509 # as used by libgfortran
/io
/unix.c
:fd_truncate
; i.e. ftruncate or
5510 # chsize. We test
for a trivially functional truncation
; no stubs.
5511 # As libgfortran uses _FILE_OFFSET_BITS
64, we
do too
; it
'll cause a
5512 # different function to be used.
5514 proc check_effective_target_fd_truncate { } {
5516 #define _FILE_OFFSET_BITS 64
5523 FILE *f = fopen ("tst.tmp", "wb");
5525 const char t[] = "test writing more than ten characters";
5529 write (fd, t, sizeof (t) - 1);
5531 if (ftruncate (fd, 10) != 0)
5540 f = fopen ("tst.tmp", "rb");
5541 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
5549 if { [check_runtime ftruncate $prog] } {
5553 regsub "ftruncate" $prog "chsize" prog
5554 return [check_runtime chsize $prog]
5557 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
5559 proc add_options_for_c99_runtime { flags } {
5560 if { [istarget *-*-solaris2*] } {
5561 return "$flags -std=c99"
5563 if { [istarget powerpc-*-darwin*] } {
5564 return "$flags -mmacosx-version-min=10.3"
5569 # Add to FLAGS all the target-specific flags needed to enable
5570 # full IEEE compliance mode.
5572 proc add_options_for_ieee { flags } {
5573 if { [istarget alpha*-*-*]
5574 || [istarget sh*-*-*] } {
5575 return "$flags -mieee"
5577 if { [istarget rx-*-*] } {
5578 return "$flags -mnofpu"
5583 if {![info exists flags_to_postpone]} {
5584 set flags_to_postpone ""
5587 # Add to FLAGS the flags needed to enable functions to bind locally
5588 # when using pic/PIC passes in the testsuite.
5589 proc add_options_for_bind_pic_locally { flags } {
5590 global flags_to_postpone
5592 # Instead of returning 'flags
' with the -fPIE or -fpie appended, we save it
5593 # in 'flags_to_postpone
' and append it later in gcc_target_compile procedure in
5594 # order to make sure that the multilib_flags doesn't override this.
5596 if {[check_no_compiler_messages using_pic2 assembly
{
5601 set flags_to_postpone
"-fPIE"
5604 if {[check_no_compiler_messages using_pic1 assembly
{
5609 set flags_to_postpone
"-fpie"
5615 # Add to FLAGS the flags needed to enable
64-bit vectors.
5617 proc add_options_for_double_vectors
{ flags
} {
5618 if [is
-effective
-target arm_neon_ok
] {
5619 return "$flags -mvectorize-with-neon-double"
5625 #
Return 1 if the target provides a full C99 runtime.
5627 proc check_effective_target_c99_runtime
{ } {
5628 return [check_cached_effective_target c99_runtime
{
5631 set file
[open
"$srcdir/gcc.dg/builtins-config.h"]
5632 set contents
[read $file
]
5635 #ifndef HAVE_C99_RUNTIME
5636 #error
!HAVE_C99_RUNTIME
5639 check_no_compiler_messages_nocache c99_runtime assembly \
5640 $contents
[add_options_for_c99_runtime
""]
5644 #
Return 1 if target wchar_t is at least
4 bytes.
5646 proc check_effective_target_4byte_wchar_t
{ } {
5647 return [check_no_compiler_messages
4byte_wchar_t object
{
5648 int dummy
[sizeof
(__WCHAR_TYPE__
) >= 4 ?
1 : -1];
5652 #
Return 1 if the target supports automatic stack alignment.
5654 proc check_effective_target_automatic_stack_alignment
{ } {
5655 # Ordinarily x86 supports automatic stack alignment ...
5656 if { [istarget i?
86*-*-*] ||
[istarget x86_64
-*-*] } then {
5657 if { [istarget
*-*-mingw
*] ||
[istarget
*-*-cygwin
*] } {
5658 # ... except Win64 SEH doesn
't. Succeed for Win32 though.
5659 return [check_effective_target_ilp32];
5666 # Return true if we are compiling for AVX target.
5668 proc check_avx_available { } {
5669 if { [check_no_compiler_messages avx_available assembly {
5679 # Return true if 32- and 16-bytes vectors are available.
5681 proc check_effective_target_vect_sizes_32B_16B { } {
5682 if { [check_avx_available] && ![check_prefer_avx128] } {
5689 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5692 proc check_prefer_avx128 { } {
5693 if ![check_avx_available] {
5696 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5697 float a[1024],b[1024],c[1024];
5698 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5699 } "-O2 -ftree-vectorize"]
5703 # Return 1 if avx512f instructions can be compiled.
5705 proc check_effective_target_avx512f { } {
5706 return [check_no_compiler_messages avx512f object {
5707 typedef double __m512d __attribute__ ((__vector_size__ (64)));
5709 __m512d _mm512_add (__m512d a)
5711 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
5716 # Return 1 if avx instructions can be compiled.
5718 proc check_effective_target_avx { } {
5719 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
5722 return [check_no_compiler_messages avx object {
5723 void _mm256_zeroall (void)
5725 __builtin_ia32_vzeroall ();
5730 # Return 1 if avx2 instructions can be compiled.
5731 proc check_effective_target_avx2 { } {
5732 return [check_no_compiler_messages avx2 object {
5733 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
5735 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
5737 return __builtin_ia32_andnotsi256 (__X, __Y);
5742 # Return 1 if sse instructions can be compiled.
5743 proc check_effective_target_sse { } {
5744 return [check_no_compiler_messages sse object {
5747 __builtin_ia32_stmxcsr ();
5753 # Return 1 if sse2 instructions can be compiled.
5754 proc check_effective_target_sse2 { } {
5755 return [check_no_compiler_messages sse2 object {
5756 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5758 __m128i _mm_srli_si128 (__m128i __A, int __N)
5760 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5765 # Return 1 if F16C instructions can be compiled.
5767 proc check_effective_target_f16c { } {
5768 return [check_no_compiler_messages f16c object {
5769 #include "immintrin.h"
5771 foo (unsigned short val)
5773 return _cvtsh_ss (val);
5778 # Return 1 if C wchar_t type is compatible with char16_t.
5780 proc check_effective_target_wchar_t_char16_t_compatible { } {
5781 return [check_no_compiler_messages wchar_t_char16_t object {
5783 __CHAR16_TYPE__ *p16 = &wc;
5784 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5788 # Return 1 if C wchar_t type is compatible with char32_t.
5790 proc check_effective_target_wchar_t_char32_t_compatible { } {
5791 return [check_no_compiler_messages wchar_t_char32_t object {
5793 __CHAR32_TYPE__ *p32 = &wc;
5794 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5798 # Return 1 if pow10 function exists.
5800 proc check_effective_target_pow10 { } {
5801 return [check_runtime pow10 {
5811 # Return 1 if current options generate DFP instructions, 0 otherwise.
5813 proc check_effective_target_hard_dfp {} {
5814 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5815 typedef float d64 __attribute__((mode(DD)));
5817 void foo (void) { z = x + y; }
5821 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5822 # for strchr etc. functions.
5824 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5825 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5828 #if !defined(__cplusplus) \
5829 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5830 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5831 ISO C++ correct string.h and wchar.h protos not supported.
5838 # Return 1 if GNU as is used.
5840 proc check_effective_target_gas { } {
5841 global use_gas_saved
5844 if {![info exists use_gas_saved]} {
5845 # Check if the as used by gcc is GNU as.
5846 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5847 # Provide /dev/null as input, otherwise gas times out reading from
5849 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5850 set as_output [lindex $status 1]
5851 if { [ string first "GNU" $as_output ] >= 0 } {
5857 return $use_gas_saved
5860 # Return 1 if GNU ld is used.
5862 proc check_effective_target_gld { } {
5863 global use_gld_saved
5866 if {![info exists use_gld_saved]} {
5867 # Check if the ld used by gcc is GNU ld.
5868 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5869 set status [remote_exec host "$gcc_ld" "--version"]
5870 set ld_output [lindex $status 1]
5871 if { [ string first "GNU" $ld_output ] >= 0 } {
5877 return $use_gld_saved
5880 # Return 1 if the compiler has been configure with link-time optimization
5883 proc check_effective_target_lto { } {
5884 if { [istarget nvptx-*-*] } {
5887 return [check_no_compiler_messages lto object {
5892 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
5894 proc check_effective_target_maybe_x32 { } {
5895 return [check_no_compiler_messages maybe_x32 object {
5897 } "-mx32 -maddress-mode=short"]
5900 # Return 1 if this target supports the -fsplit-stack option, 0
5903 proc check_effective_target_split_stack {} {
5904 return [check_no_compiler_messages split_stack object {
5909 # Return 1 if this target supports the -masm=intel option, 0
5912 proc check_effective_target_masm_intel {} {
5913 return [check_no_compiler_messages masm_intel object {
5914 extern void abort (void);
5918 # Return 1 if the language for the compiler under test is C.
5920 proc check_effective_target_c { } {
5922 if [string match $tool "gcc"] {
5928 # Return 1 if the language for the compiler under test is C++.
5930 proc check_effective_target_c++ { } {
5932 if [string match $tool "g++"] {
5938 set cxx_default "c++14"
5939 # Check whether the current active language standard supports the features
5940 # of C++11/C++14 by checking for the presence of one of the -std flags.
5941 # This assumes that the default for the compiler is $cxx_default, and that
5942 # there will never be multiple -std= arguments on the command line.
5943 proc check_effective_target_c++11_only { } {
5945 if ![check_effective_target_c++] {
5948 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
5951 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
5956 proc check_effective_target_c++11 { } {
5957 if [check_effective_target_c++11_only] {
5960 return [check_effective_target_c++14]
5962 proc check_effective_target_c++11_down { } {
5963 if ![check_effective_target_c++] {
5966 return [expr ![check_effective_target_c++14] ]
5969 proc check_effective_target_c++14_only { } {
5971 if ![check_effective_target_c++] {
5974 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
5977 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
5983 proc check_effective_target_c++14 { } {
5984 if [check_effective_target_c++14_only] {
5987 return [check_effective_target_c++1z]
5989 proc check_effective_target_c++14_down { } {
5990 if ![check_effective_target_c++] {
5993 return [expr ![check_effective_target_c++1z] ]
5996 proc check_effective_target_c++98_only { } {
5998 if ![check_effective_target_c++] {
6001 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
6004 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
6010 proc check_effective_target_c++1z_only { } {
6012 if ![check_effective_target_c++] {
6015 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
6018 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
6023 proc check_effective_target_c++1z { } {
6024 return [check_effective_target_c++1z_only]
6027 # Return 1 if expensive testcases should be run.
6029 proc check_effective_target_run_expensive_tests { } {
6030 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
6036 # Returns 1 if "mempcpy" is available on the target system.
6038 proc check_effective_target_mempcpy {} {
6039 return [check_function_available "mempcpy"]
6042 # Returns 1 if "stpcpy" is available on the target system.
6044 proc check_effective_target_stpcpy {} {
6045 return [check_function_available "stpcpy"]
6048 # Check whether the vectorizer tests are supported by the target and
6049 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
6050 # Set dg-do-what-default to either compile or run, depending on target
6051 # capabilities. Return 1 if vectorizer tests are supported by
6052 # target, 0 otherwise.
6054 proc check_vect_support_and_set_flags { } {
6055 global DEFAULT_VECTCFLAGS
6056 global dg-do-what-default
6058 if [istarget powerpc-*paired*] {
6059 lappend DEFAULT_VECTCFLAGS "-mpaired"
6060 if [check_750cl_hw_available] {
6061 set dg-do-what-default run
6063 set dg-do-what-default compile
6065 } elseif [istarget powerpc*-*-*] {
6066 # Skip targets not supporting -maltivec.
6067 if ![is-effective-target powerpc_altivec_ok] {
6071 lappend DEFAULT_VECTCFLAGS "-maltivec"
6072 if [check_p8vector_hw_available] {
6073 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
6074 } elseif [check_vsx_hw_available] {
6075 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
6078 if [check_vmx_hw_available] {
6079 set dg-do-what-default run
6081 if [is-effective-target ilp32] {
6082 # Specify a cpu that supports VMX for compile-only tests.
6083 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
6085 set dg-do-what-default compile
6087 } elseif { [istarget spu-*-*] } {
6088 set dg-do-what-default run
6089 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
6090 lappend DEFAULT_VECTCFLAGS "-msse2"
6091 if { [check_effective_target_sse2_runtime] } {
6092 set dg-do-what-default run
6094 set dg-do-what-default compile
6096 } elseif { [istarget mips*-*-*]
6097 && ([check_effective_target_mpaired_single]
6098 || [check_effective_target_mips_loongson])
6099 && [check_effective_target_nomips16] } {
6100 if { [check_effective_target_mpaired_single] } {
6101 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
6103 set dg-do-what-default run
6104 } elseif [istarget sparc*-*-*] {
6105 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
6106 if [check_effective_target_ultrasparc_hw] {
6107 set dg-do-what-default run
6109 set dg-do-what-default compile
6111 } elseif [istarget alpha*-*-*] {
6112 # Alpha's vectorization capabilities are extremely limited.
6113 # It
's more effort than its worth disabling all of the tests
6114 # that it cannot pass. But if you actually want to see what
6115 # does work, command out the return.
6118 lappend DEFAULT_VECTCFLAGS "-mmax"
6119 if [check_alpha_max_hw_available] {
6120 set dg-do-what-default run
6122 set dg-do-what-default compile
6124 } elseif [istarget ia64-*-*] {
6125 set dg-do-what-default run
6126 } elseif [is-effective-target arm_neon_ok] {
6127 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
6128 # NEON does not support denormals, so is not used for vectorization by
6129 # default to avoid loss of precision. We must pass -ffast-math to test
6130 # vectorization of float operations.
6131 lappend DEFAULT_VECTCFLAGS "-ffast-math"
6132 if [is-effective-target arm_neon_hw] {
6133 set dg-do-what-default run
6135 set dg-do-what-default compile
6137 } elseif [istarget "aarch64*-*-*"] {
6138 set dg-do-what-default run
6146 # Return 1 if the target does *not* require strict alignment.
6148 proc check_effective_target_non_strict_align {} {
6149 return [check_no_compiler_messages non_strict_align assembly {
6151 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
6153 void foo(void) { z = (c *) y; }
6157 # Return 1 if the target has <ucontext.h>.
6159 proc check_effective_target_ucontext_h { } {
6160 return [check_no_compiler_messages ucontext_h assembly {
6161 #include <ucontext.h>
6165 proc check_effective_target_aarch64_tiny { } {
6166 if { [istarget aarch64*-*-*] } {
6167 return [check_no_compiler_messages aarch64_tiny object {
6168 #ifdef __AARCH64_CMODEL_TINY__
6171 #error target not AArch64 tiny code model
6179 proc check_effective_target_aarch64_small { } {
6180 if { [istarget aarch64*-*-*] } {
6181 return [check_no_compiler_messages aarch64_small object {
6182 #ifdef __AARCH64_CMODEL_SMALL__
6185 #error target not AArch64 small code model
6193 proc check_effective_target_aarch64_large { } {
6194 if { [istarget aarch64*-*-*] } {
6195 return [check_no_compiler_messages aarch64_large object {
6196 #ifdef __AARCH64_CMODEL_LARGE__
6199 #error target not AArch64 large code model
6207 # Return 1 if <fenv.h> is available with all the standard IEEE
6208 # exceptions and floating-point exceptions are raised by arithmetic
6209 # operations. (If the target requires special options for "inexact"
6210 # exceptions, those need to be specified in the testcases.)
6212 proc check_effective_target_fenv_exceptions {} {
6213 return [check_runtime fenv_exceptions {
6216 #ifndef FE_DIVBYZERO
6217 # error Missing FE_DIVBYZERO
6220 # error Missing FE_INEXACT
6223 # error Missing FE_INVALID
6226 # error Missing FE_OVERFLOW
6228 #ifndef FE_UNDERFLOW
6229 # error Missing FE_UNDERFLOW
6231 volatile float a = 0.0f, r;
6236 if (fetestexcept (FE_INVALID))
6241 } [add_options_for_ieee "-std=gnu99"]]
6244 proc check_effective_target_tiny {} {
6245 global et_target_tiny_saved
6247 if [info exists et_target_tine_saved] {
6248 verbose "check_effective_target_tiny: using cached result" 2
6250 set et_target_tiny_saved 0
6251 if { [istarget aarch64*-*-*]
6252 && [check_effective_target_aarch64_tiny] } {
6253 set et_target_tiny_saved 1
6257 return $et_target_tiny_saved
6260 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
6262 proc check_effective_target_logical_op_short_circuit {} {
6263 if { [istarget mips*-*-*]
6264 || [istarget arc*-*-*]
6265 || [istarget avr*-*-*]
6266 || [istarget crisv32-*-*] || [istarget cris-*-*]
6267 || [istarget mmix-*-*]
6268 || [istarget s390*-*-*]
6269 || [istarget powerpc*-*-*]
6270 || [istarget nios2*-*-*]
6271 || [istarget visium-*-*]
6272 || [check_effective_target_arm_cortex_m] } {
6278 # Record that dg-final test TEST requires convential compilation.
6280 proc force_conventional_output_for { test } {
6281 if { [info proc $test] == "" } {
6282 perror "$test does not exist"
6285 proc ${test}_required_options {} {
6286 global gcc_force_conventional_output
6287 return $gcc_force_conventional_output
6291 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
6292 # otherwise. Cache the result.
6294 proc check_effective_target_pie_copyreloc { } {
6295 global pie_copyreloc_available_saved
6297 global GCC_UNDER_TEST
6299 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6303 # Need auto-host.h to check linker support.
6304 if { ![file exists ../../auto-host.h ] } {
6308 if [info exists pie_copyreloc_available_saved] {
6309 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
6311 # Set up and compile to see if linker supports PIE with copy
6312 # reloc. Include the current process ID in the file names to
6313 # prevent conflicts with invocations for multiple testsuites.
6318 set f [open $src "w"]
6319 puts $f "#include \"../../auto-host.h\""
6320 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
6321 puts $f "# error Linker does not support PIE with copy reloc."
6325 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
6326 set lines [${tool}_target_compile $src $obj object ""]
6331 if [string match "" $lines] then {
6332 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
6333 set pie_copyreloc_available_saved 1
6335 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
6336 set pie_copyreloc_available_saved 0
6340 return $pie_copyreloc_available_saved
6343 # Return 1 if the target uses comdat groups.
6345 proc check_effective_target_comdat_group {} {
6346 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
6348 inline int foo () { return 1; }