1 # Copyright
(C
) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 # Free Software Foundation
, Inc.
4 # This
program is free software
; you can redistribute it and
/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation
; either version
3 of the License
, or
7 #
(at your option
) any later version.
9 # This
program is distributed in the hope that it will be useful
,
10 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License
for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC
; see the file COPYING3.
If not see
16 #
<http
://www.gnu.org
/licenses
/>.
18 # Please email
any bugs
, comments
, and
/or additions to this file to
:
19 # gcc
-patches@gcc.gnu.org
21 # This file defines procs
for determining features supported by the target.
23 # Try to
compile the code given by CONTENTS into an output file of
24 # type TYPE
, where TYPE is as
for target_compile.
Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the
name of the output file.
28 # BASENAME is a prefix to use
for source and output files.
29 #
If ARGS is not empty
, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code.
33 # Otherwise
, code should contain
:
35 #
"! Fortran" for Fortran code,
37 # and
"// 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 if { [llength $
args] > 0 } {
45 set options
[list
"additional_flags=[lindex $args 0]"]
49 switch -glob
-- $contents
{
50 "*! Fortran*" { set src ${basename}[pid].f90 }
51 "*// C++*" { set src ${basename}[pid].cc }
52 "*// ObjC++*" { set src ${basename}[pid].mm }
53 "*/* ObjC*" { set src ${basename}[pid].m }
56 "objc" { set src ${basename}[pid].m }
57 "obj-c++" { set src ${basename}[pid].mm }
58 default
{ set src $
{basename
}[pid
].c
}
63 set compile_type $type
65 assembly
{ set output $
{basename
}[pid
].s
}
66 object
{ set output $
{basename
}[pid
].o
}
67 executable
{ set output $
{basename
}[pid
].exe
}
69 set output $
{basename
}[pid
].s
70 lappend options
"additional_flags=-fdump-$type"
71 set compile_type assembly
77 set lines
[$
{tool
}_target_compile $src $output $compile_type
"$options"]
80 set scan_output $output
81 # Don
't try folding this into the switch above; calling "glob" before the
82 # file is created won't work.
83 if [regexp
"rtl-(.*)" $type dummy rtl_type] {
84 set scan_output
"[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
88 return [list $lines $scan_output
]
91 proc current_target_name
{ } {
93 if [info exists target_info
(target
,name)] {
94 set answer $target_info
(target
,name)
101 # Implement an effective
-target check
for property PROP by invoking
102 # the Tcl command
ARGS and seeing
if it returns true.
104 proc check_cached_effective_target
{ prop
args } {
107 set target
[current_target_name
]
108 if {![info exists et_cache
($prop
,target
)]
109 || $et_cache
($prop
,target
) != $target
} {
110 verbose
"check_cached_effective_target $prop: checking $target" 2
111 set et_cache
($prop
,target
) $target
112 set et_cache
($prop
,value
) [uplevel eval $
args]
114 set value $et_cache
($prop
,value
)
115 verbose
"check_cached_effective_target $prop: returning $value for $target" 2
119 # Like check_compile
, but
delete the output file and
return true
if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache
{args} {
122 set result
[eval check_compile $
args]
123 set lines
[lindex $result
0]
124 set output
[lindex $result
1]
125 remote_file build
delete $output
126 return [string match
"" $lines]
129 # Like check_no_compiler_messages_nocache
, but
cache the result.
130 # PROP is the
property we
're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133 return [check_cached_effective_target $prop {
134 eval [list check_no_compiler_messages_nocache $prop] $args
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP
, otherwise they satisfy it
142 #
if they
do match regular expression PATTERN.
(PATTERN can start
143 # with something like
"[!]" if the regular expression needs to match
144 #
"!" as the first character.)
146 #
Delete the output file before returning. The other arguments are
147 # as
for check_compile.
148 proc check_no_messages_and_pattern_nocache
{basename pattern
args} {
151 set result
[eval
[list check_compile $basename
] $
args]
152 set lines
[lindex $result
0]
153 set output
[lindex $result
1]
156 if { [string match
"" $lines] } {
157 set chan
[open
"$output"]
158 set invert
[regexp
{^
!(.
*)} $pattern dummy pattern
]
159 set ok
[expr
{ [regexp $pattern
[read $chan
]] != $invert
}]
163 remote_file build
delete $output
167 # Like check_no_messages_and_pattern_nocache
, but
cache the result.
168 # PROP is the
property we
're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171 return [check_cached_effective_target $prop {
172 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
176 # Try to compile and run an executable from code CONTENTS. Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense. The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
183 set result [eval [list check_compile $basename executable $contents] $args]
184 set lines [lindex $result 0]
185 set output [lindex $result 1]
188 if { [string match "" $lines] } {
189 # No error messages, everything is OK.
190 set result [remote_load target "./$output" "" ""]
191 set status [lindex $result 0]
192 verbose "check_runtime_nocache $basename: status is <$status>" 2
193 if { $status == "pass" } {
197 remote_file build delete $output
201 # Like check_runtime_nocache, but cache the result. PROP is the
202 # property we're checking
, and doubles as a prefix
for temporary
204 proc check_runtime
{prop
args} {
207 return [check_cached_effective_target $prop
{
208 eval
[list check_runtime_nocache $prop
] $
args
212 ###############################
213 # proc check_weak_available
{ }
214 ###############################
216 # weak symbols are only supported in some configs
/object formats
217 # this proc returns
1 if they
're supported, 0 if they're not
, or
-1 if unsure
219 proc check_weak_available
{ } {
220 global target_triplet
223 # All mips targets should support it
225 if { [ string first
"mips" $target_cpu ] >= 0 } {
229 # All solaris2 targets should support it
231 if { [regexp
".*-solaris2.*" $target_triplet] } {
235 # DEC OSF
/1/Digital UNIX
/Tru64 UNIX supports it
237 if { [regexp
"alpha.*osf.*" $target_triplet] } {
241 # Windows targets Cygwin and MingW32 support it
243 if { [regexp
".*mingw32|.*cygwin" $target_triplet] } {
247 # HP
-UX
10.X doesn
't support it
249 if { [istarget "hppa*-*-hpux10*"] } {
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
256 set objformat [gcc_target_object_format]
264 unknown { return -1 }
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
276 proc check_weak_override_available { } {
277 if { [istarget "*-*-mingw*"] } {
280 return [check_weak_available]
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
291 proc check_visibility_available { what_kind } {
293 global target_triplet
295 # On NetWare, support makes no sense.
296 if { [istarget *-*-netware*] } {
300 if [string match "" $what_kind] { set what_kind "hidden" }
302 return [check_no_compiler_messages visibility_available_$what_kind object "
303 void f() __attribute__((visibility(\"$what_kind\")));
308 ###############################
309 # proc check_alias_available { }
310 ###############################
312 # Determine if the target toolchain supports the alias attribute.
314 # Returns 2 if the target supports aliases. Returns 1 if the target
315 # only supports weak aliased. Returns 0 if the target does not
316 # support aliases at all. Returns -1 if support for aliases could not
319 proc check_alias_available { } {
320 global alias_available_saved
323 if [info exists alias_available_saved] {
324 verbose "check_alias_available returning saved $alias_available_saved" 2
328 verbose "check_alias_available compiling testfile $src" 2
329 set f [open $src "w"]
330 # Compile a small test program. The definition of "g" is
331 # necessary to keep the Solaris assembler from complaining
333 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
336 set lines [${tool}_target_compile $src $obj object ""]
338 remote_file build delete $obj
340 if [string match "" $lines] then {
341 # No error messages, everything is OK.
342 set alias_available_saved 2
344 if [regexp "alias definitions not supported" $lines] {
345 verbose "check_alias_available target does not support aliases" 2
347 set objformat [gcc_target_object_format]
349 if { $objformat == "elf" } {
350 verbose "check_alias_available but target uses ELF format, so it ought to" 2
351 set alias_available_saved -1
353 set alias_available_saved 0
356 if [regexp "only weak aliases are supported" $lines] {
357 verbose "check_alias_available target supports only weak aliases" 2
358 set alias_available_saved 1
360 set alias_available_saved -1
365 verbose "check_alias_available returning $alias_available_saved" 2
368 return $alias_available_saved
371 # Returns true if --gc-sections is supported on the target.
373 proc check_gc_sections_available { } {
374 global gc_sections_available_saved
377 if {![info exists gc_sections_available_saved]} {
378 # Some targets don't support gc
-sections despite whatever
's
379 # advertised by ld's options.
380 if { [istarget alpha
*-*-*]
381 ||
[istarget ia64
-*-*] } {
382 set gc_sections_available_saved
0
386 # elf2flt uses
-q
(--emit
-relocs
), which is incompatible with
388 if { [board_info target
exists ldflags
]
389 && [regexp
" -elf2flt\[ =\]" " [board_info target ldflags] "] } {
390 set gc_sections_available_saved
0
394 # VxWorks kernel modules are relocatable objects linked with
-r
,
395 #
while RTP executables are linked with
-q
(--emit
-relocs
).
396 # Both of these options are incompatible with
--gc
-sections.
397 if { [istarget
*-*-vxworks
*] } {
398 set gc_sections_available_saved
0
402 # Check
if the
ld used by gcc supports
--gc
-sections.
403 set gcc_spec
[$
{tool
}_target_compile
"-dumpspecs" "" "none" ""]
404 regsub
".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
405 set gcc_ld
[lindex
[$
{tool
}_target_compile
"-print-prog-name=$linker" "" "none" ""] 0]
406 set ld_output
[remote_exec host
"$gcc_ld" "--help"]
407 if { [ string first
"--gc-sections" $ld_output ] >= 0 } {
408 set gc_sections_available_saved
1
410 set gc_sections_available_saved
0
413 return $gc_sections_available_saved
416 #
Return 1 if according to target_info struct and explicit target list
417 # target is supposed to support trampolines.
419 proc check_effective_target_trampolines
{ } {
420 if [target_info
exists no_trampolines
] {
423 if { [istarget avr
-*-*]
424 ||
[istarget hppa2.0w
-hp
-hpux11.23
]
425 ||
[istarget hppa64
-hp
-hpux11.23
] } {
431 #
Return 1 if according to target_info struct and explicit target list
432 # target is supposed to keep null pointer checks. This could be due to
433 # use of option fno
-delete-null
-pointer
-checks or hardwired in target.
435 proc check_effective_target_keeps_null_pointer_checks
{ } {
436 if [target_info
exists keeps_null_pointer_checks
] {
439 if { [istarget avr
-*-*] } {
445 #
Return true
if profiling is supported
on the target.
447 proc check_profiling_available
{ test_what
} {
448 global profiling_available_saved
450 verbose
"Profiling argument is <$test_what>" 1
452 # These conditions depend
on the
argument so examine them before
453 # looking at the
cache variable.
455 # Support
for -p
on solaris2 relies
on mcrt1.o which comes with the
456 # vendor compiler. We cannot reliably predict the directory where the
457 # vendor compiler
(and thus mcrt1.o
) is installed so we can
't
458 # necessarily find mcrt1.o even if we have it.
459 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
463 # Support for -p on irix relies on libprof1.a which doesn't appear to
464 # exist
on any irix6
system currently posting testsuite results.
465 # Support
for -pg
on irix relies
on gcrt1.o which doesn
't exist yet.
466 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
467 if { [istarget mips*-*-irix*]
468 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
472 # We don't yet support profiling
for MIPS16.
473 if { [istarget mips
*-*-*]
474 && ![check_effective_target_nomips16
]
475 && ([lindex $test_what
1] == "-p"
476 ||
[lindex $test_what
1] == "-pg") } {
480 # MinGW does not support
-p.
481 if { [istarget
*-*-mingw
*] && [lindex $test_what
1] == "-p" } {
485 # cygwin does not support
-p.
486 if { [istarget
*-*-cygwin
*] && [lindex $test_what
1] == "-p" } {
490 # uClibc does not have gcrt1.o.
491 if { [check_effective_target_uclibc
]
492 && ([lindex $test_what
1] == "-p"
493 ||
[lindex $test_what
1] == "-pg") } {
497 # Now examine the
cache variable.
498 if {![info exists profiling_available_saved
]} {
499 # Some targets don
't have any implementation of __bb_init_func or are
500 # missing other needed machinery.
501 if { [istarget mmix-*-*]
502 || [istarget arm*-*-eabi*]
503 || [istarget picochip-*-*]
504 || [istarget *-*-netware*]
505 || [istarget arm*-*-elf]
506 || [istarget arm*-*-symbianelf*]
507 || [istarget avr-*-*]
508 || [istarget bfin-*-*]
509 || [istarget powerpc-*-eabi*]
510 || [istarget powerpc-*-elf]
511 || [istarget cris-*-*]
512 || [istarget crisv32-*-*]
513 || [istarget fido-*-elf]
514 || [istarget h8300-*-*]
515 || [istarget lm32-*-*]
516 || [istarget m32c-*-elf]
517 || [istarget m68k-*-elf]
518 || [istarget m68k-*-uclinux*]
519 || [istarget mep-*-elf]
520 || [istarget mips*-*-elf*]
521 || [istarget moxie-*-elf*]
523 || [istarget xstormy16-*]
524 || [istarget xtensa*-*-elf]
525 || [istarget *-*-rtems*]
526 || [istarget *-*-vxworks*] } {
527 set profiling_available_saved 0
529 set profiling_available_saved 1
533 return $profiling_available_saved
536 # Check to see if a target is "freestanding". This is as per the definition
537 # in Section 4 of C99 standard. Effectively, it is a target which supports no
538 # extra headers or libraries other than what is considered essential.
539 proc check_effective_target_freestanding { } {
540 if { [istarget picochip-*-*] } then {
547 # Return 1 if target has packed layout of structure members by
548 # default, 0 otherwise. Note that this is slightly different than
549 # whether the target has "natural alignment": both attributes may be
552 proc check_effective_target_default_packed { } {
553 return [check_no_compiler_messages default_packed assembly {
554 struct x { char a; long b; } c;
555 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
559 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
560 # documentation, where the test also comes from.
562 proc check_effective_target_pcc_bitfield_type_matters { } {
563 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
564 # bitfields
, but let
's stick to the example code from the docs.
565 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
566 struct foo1 { char x; char :0; char y; };
567 struct foo2 { char x; int :0; char y; };
568 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
572 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
574 proc check_effective_target_tls {} {
575 return [check_no_compiler_messages tls assembly {
577 int f (void) { return i; }
578 void g (int j) { i = j; }
582 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
584 proc check_effective_target_tls_native {} {
585 # VxWorks uses emulated TLS machinery, but with non-standard helper
586 # functions, so we fail to automatically detect it.
587 global target_triplet
588 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
592 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
594 int f (void) { return i; }
595 void g (int j) { i = j; }
599 # Return 1 if TLS executables can run correctly, 0 otherwise.
601 proc check_effective_target_tls_runtime {} {
602 return [check_runtime tls_runtime {
603 __thread int thr = 0;
604 int main (void) { return thr; }
608 # Return 1 if compilation with -fgraphite is error-free for trivial
611 proc check_effective_target_fgraphite {} {
612 return [check_no_compiler_messages fgraphite object {
617 # Return 1 if compilation with -fopenmp is error-free for trivial
620 proc check_effective_target_fopenmp {} {
621 return [check_no_compiler_messages fopenmp object {
626 # Return 1 if compilation with -pthread is error-free for trivial
629 proc check_effective_target_pthread {} {
630 return [check_no_compiler_messages pthread object {
635 # Return 1 if compilation with -mpe-aligned-commons is error-free
636 # for trivial code, 0 otherwise.
638 proc check_effective_target_pe_aligned_commons {} {
639 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
640 return [check_no_compiler_messages pe_aligned_commons object {
642 } "-mpe-aligned-commons"]
647 # Return 1 if the target supports -static
648 proc check_effective_target_static {} {
649 return [check_no_compiler_messages static executable {
650 int main (void) { return 0; }
654 # Return 1 if the target supports -fstack-protector
655 proc check_effective_target_fstack_protector {} {
656 return [check_runtime fstack_protector {
657 int main (void) { return 0; }
658 } "-fstack-protector"]
661 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
662 # for trivial code, 0 otherwise.
664 proc check_effective_target_freorder {} {
665 return [check_no_compiler_messages freorder object {
667 } "-freorder-blocks-and-partition"]
670 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
671 # emitted, 0 otherwise. Whether a shared library can actually be built is
672 # out of scope for this test.
674 proc check_effective_target_fpic { } {
675 # Note that M68K has a multilib that supports -fpic but not
676 # -fPIC, so we need to check both. We test with a program that
677 # requires GOT references.
678 foreach arg {fpic fPIC} {
679 if [check_no_compiler_messages $arg object {
680 extern int foo (void); extern int bar;
681 int baz (void) { return foo () + bar; }
689 # Return true if the target supports -mpaired-single (as used on MIPS).
691 proc check_effective_target_mpaired_single { } {
692 return [check_no_compiler_messages mpaired_single object {
697 # Return true if the target has access to FPU instructions.
699 proc check_effective_target_hard_float { } {
700 if { [istarget mips*-*-*] } {
701 return [check_no_compiler_messages hard_float assembly {
702 #if (defined __mips_soft_float || defined __mips16)
708 # This proc is actually checking the availabilty of FPU
709 # support for doubles, so on the RX we must fail if the
710 # 64-bit double multilib has been selected.
711 if { [istarget rx-*-*] } {
713 # return [check_no_compiler_messages hard_float assembly {
714 #if defined __RX_64_BIT_DOUBLES__
720 # The generic test equates hard_float with "no call for adding doubles".
721 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
722 double a (double b, double c) { return b + c; }
726 # Return true if the target is a 64-bit MIPS target.
728 proc check_effective_target_mips64 { } {
729 return [check_no_compiler_messages mips64 assembly {
736 # Return true if the target is a MIPS target that does not produce
739 proc check_effective_target_nomips16 { } {
740 return [check_no_compiler_messages nomips16 object {
744 /* A cheap way of testing for -mflip-mips16. */
745 void foo (void) { asm ("addiu $20,$20,1"); }
746 void bar (void) { asm ("addiu $20,$20,1"); }
751 # Add the options needed for MIPS16 function attributes. At the moment,
752 # we don't support MIPS16 PIC.
754 proc add_options_for_mips16_attribute
{ flags
} {
755 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
758 #
Return true
if we can force a
mode that allows MIPS16 code generation.
759 # We don
't support MIPS16 PIC, and only support MIPS16 -mhard-float
762 proc check_effective_target_mips16_attribute { } {
763 return [check_no_compiler_messages mips16_attribute assembly {
767 #if defined __mips_hard_float \
768 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
769 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
772 } [add_options_for_mips16_attribute ""]]
775 # Return 1 if the target supports long double larger than double when
776 # using the new ABI, 0 otherwise.
778 proc check_effective_target_mips_newabi_large_long_double { } {
779 return [check_no_compiler_messages mips_newabi_large_long_double object {
780 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
784 # Return 1 if the current multilib does not generate PIC by default.
786 proc check_effective_target_nonpic { } {
787 return [check_no_compiler_messages nonpic assembly {
794 # Return 1 if the target does not use a status wrapper.
796 proc check_effective_target_unwrapped { } {
797 if { [target_info needs_status_wrapper] != "" \
798 && [target_info needs_status_wrapper] != "0" } {
804 # Return true if iconv is supported on the target. In particular IBM1047.
806 proc check_iconv_available { test_what } {
809 # If the tool configuration file has not set libiconv, try "-liconv"
810 if { ![info exists libiconv] } {
811 set libiconv "-liconv"
813 set test_what [lindex $test_what 1]
814 return [check_runtime_nocache $test_what [subst {
820 cd = iconv_open ("$test_what", "UTF-8");
821 if (cd == (iconv_t) -1)
828 # Return true if named sections are supported on this target.
830 proc check_named_sections_available { } {
831 return [check_no_compiler_messages named_sections assembly {
832 int __attribute__ ((section("whatever"))) foo;
836 # Return 1 if the target supports Fortran real kinds larger than real(8),
839 # When the target name changes, replace the cached result.
841 proc check_effective_target_fortran_large_real { } {
842 return [check_no_compiler_messages fortran_large_real executable {
844 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
851 # Return 1 if the target supports Fortran integer kinds larger than
852 # integer(8), 0 otherwise.
854 # When the target name changes, replace the cached result.
856 proc check_effective_target_fortran_large_int { } {
857 return [check_no_compiler_messages fortran_large_int executable {
859 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
865 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
867 # When the target name changes, replace the cached result.
869 proc check_effective_target_fortran_integer_16 { } {
870 return [check_no_compiler_messages fortran_integer_16 executable {
877 # Return 1 if we can statically link libgfortran, 0 otherwise.
879 # When the target name changes, replace the cached result.
881 proc check_effective_target_static_libgfortran { } {
882 return [check_no_compiler_messages static_libgfortran executable {
889 # Return 1 if the target supports executing 750CL paired-single instructions, 0
890 # otherwise. Cache the result.
892 proc check_750cl_hw_available { } {
893 return [check_cached_effective_target 750cl_hw_available {
894 # If this is not the right target then we can skip the test.
895 if { ![istarget powerpc-*paired*] } {
898 check_runtime_nocache 750cl_hw_available {
902 asm volatile ("ps_mul v0,v0,v0");
904 asm volatile ("ps_mul 0,0,0");
913 # Return 1 if the target supports executing SSE2 instructions, 0
914 # otherwise. Cache the result.
916 proc check_sse2_hw_available { } {
917 return [check_cached_effective_target sse2_hw_available {
918 # If this is not the right target then we can skip the test.
919 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
922 check_runtime_nocache sse2_hw_available {
926 unsigned int eax, ebx, ecx, edx = 0;
927 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
928 return !(edx & bit_SSE2);
936 # Return 1 if the target supports executing VSX instructions, 0
937 # otherwise. Cache the result.
939 proc check_vsx_hw_available { } {
940 return [check_cached_effective_target vsx_hw_available {
941 # Some simulators are known to not support VSX instructions.
942 # For now, disable on Darwin
943 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
947 check_runtime_nocache vsx_hw_available {
951 asm volatile ("xxlor vs0,vs0,vs0");
953 asm volatile ("xxlor 0,0,0");
962 # Return 1 if the target supports executing AltiVec instructions, 0
963 # otherwise. Cache the result.
965 proc check_vmx_hw_available { } {
966 return [check_cached_effective_target vmx_hw_available {
967 # Some simulators are known to not support VMX instructions.
968 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
971 # Most targets don't require special flags
for this test case
, but
972 # Darwin does. Just to be sure
, make sure VSX is not enabled
for
974 if { [istarget
*-*-darwin
*]
975 ||
[istarget
*-*-aix
*] } {
976 set options
"-maltivec -mno-vsx"
978 set options
"-mno-vsx"
980 check_runtime_nocache vmx_hw_available
{
984 asm volatile
("vor v0,v0,v0");
986 asm volatile
("vor 0,0,0");
995 #
Return 1 if the target supports executing AltiVec and Cell PPU
996 # instructions
, 0 otherwise.
Cache the result.
998 proc check_effective_target_cell_hw
{ } {
999 return [check_cached_effective_target cell_hw_available
{
1000 # Some simulators are known to not support VMX and PPU instructions.
1001 if { [istarget powerpc
-*-eabi
*] } {
1004 # Most targets don
't require special flags for this test
1005 # case, but Darwin and AIX do.
1006 if { [istarget *-*-darwin*]
1007 || [istarget *-*-aix*] } {
1008 set options "-maltivec -mcpu=cell"
1010 set options "-mcpu=cell"
1012 check_runtime_nocache cell_hw_available {
1016 asm volatile ("vor v0,v0,v0");
1017 asm volatile ("lvlx v0,r0,r0");
1019 asm volatile ("vor 0,0,0");
1020 asm volatile ("lvlx 0,0,0");
1029 # Return 1 if the target supports executing 64-bit instructions, 0
1030 # otherwise. Cache the result.
1032 proc check_effective_target_powerpc64 { } {
1033 global powerpc64_available_saved
1036 if [info exists powerpc64_available_saved] {
1037 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1039 set powerpc64_available_saved 0
1041 # Some simulators are known to not support powerpc64 instructions.
1042 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1043 verbose "check_effective_target_powerpc64 returning 0" 2
1044 return $powerpc64_available_saved
1047 # Set up, compile, and execute a test program containing a 64-bit
1048 # instruction. Include the current process ID in the file
1049 # names to prevent conflicts with invocations for multiple
1054 set f [open $src "w"]
1055 puts $f "int main() {"
1056 puts $f "#ifdef __MACH__"
1057 puts $f " asm volatile (\"extsw r0,r0\");"
1059 puts $f " asm volatile (\"extsw 0,0\");"
1061 puts $f " return 0; }"
1064 set opts "additional_flags=-mcpu=G5"
1066 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1067 set lines [${tool}_target_compile $src $exe executable "$opts"]
1070 if [string match "" $lines] then {
1071 # No error message, compilation succeeded.
1072 set result [${tool}_load "./$exe" "" ""]
1073 set status [lindex $result 0]
1074 remote_file build delete $exe
1075 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1077 if { $status == "pass" } then {
1078 set powerpc64_available_saved 1
1081 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1085 return $powerpc64_available_saved
1088 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1089 # complex float arguments. This affects gfortran tests that call cabsf
1090 # in libm built by an earlier compiler. Return 1 if libm uses the same
1091 # argument passing as the compiler under test, 0 otherwise.
1093 # When the target name changes, replace the cached result.
1095 proc check_effective_target_broken_cplxf_arg { } {
1096 return [check_cached_effective_target broken_cplxf_arg {
1097 # Skip the work for targets known not to be affected.
1098 if { ![istarget powerpc64-*-linux*] } {
1100 } elseif { ![is-effective-target lp64] } {
1103 check_runtime_nocache broken_cplxf_arg {
1104 #include <complex.h>
1105 extern void abort (void);
1106 float fabsf (float);
1107 float cabsf (_Complex float);
1114 if (fabsf (f - 5.0) > 0.0001)
1123 proc check_alpha_max_hw_available { } {
1124 return [check_runtime alpha_max_hw_available {
1125 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1129 # Returns true iff the FUNCTION is available on the target system.
1130 # (This is essentially a Tcl implementation of Autoconf's
1133 proc check_function_available
{ function
} {
1134 return [check_no_compiler_messages $
{function
}_available \
1140 int main
() { $function
(); }
1144 # Returns true iff
"fork" is available on the target system.
1146 proc check_fork_available
{} {
1147 return [check_function_available
"fork"]
1150 # Returns true iff
"mkfifo" is available on the target system.
1152 proc check_mkfifo_available
{} {
1153 if {[istarget
*-*-cygwin
*]} {
1154 # Cygwin has mkfifo
, but support is incomplete.
1158 return [check_function_available
"mkfifo"]
1161 # Returns true iff
"__cxa_atexit" is used on the target system.
1163 proc check_cxa_atexit_available
{ } {
1164 return [check_cached_effective_target cxa_atexit_available
{
1165 if { [istarget
"hppa*-*-hpux10*"] } {
1166 # HP
-UX
10 doesn
't have __cxa_atexit but subsequent test passes.
1168 } elseif { [istarget "*-*-vxworks"] } {
1169 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1172 check_runtime_nocache cxa_atexit_available
{
1175 static unsigned
int count;
1192 Y
() { f
(); count = 2; }
1201 int main
() { return 0; }
1207 proc check_effective_target_objc2
{ } {
1208 return [check_no_compiler_messages objc2 object
{
1217 proc check_effective_target_next_runtime
{ } {
1218 return [check_no_compiler_messages objc2 object
{
1219 #ifdef __NEXT_RUNTIME__
1227 #
Return 1 if we
're generating 32-bit code using default options, 0
1230 proc check_effective_target_ilp32 { } {
1231 return [check_no_compiler_messages ilp32 object {
1232 int dummy[sizeof (int) == 4
1233 && sizeof (void *) == 4
1234 && sizeof (long) == 4 ? 1 : -1];
1238 # Return 1 if we're generating
32-bit or larger integers using default
1239 # options
, 0 otherwise.
1241 proc check_effective_target_int32plus
{ } {
1242 return [check_no_compiler_messages int32plus object
{
1243 int dummy
[sizeof
(int) >= 4 ?
1 : -1];
1247 #
Return 1 if we
're generating 32-bit or larger pointers using default
1248 # options, 0 otherwise.
1250 proc check_effective_target_ptr32plus { } {
1251 return [check_no_compiler_messages ptr32plus object {
1252 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1256 # Return 1 if we support 32-bit or larger array and structure sizes
1257 # using default options, 0 otherwise.
1259 proc check_effective_target_size32plus { } {
1260 return [check_no_compiler_messages size32plus object {
1265 # Returns 1 if we're generating
16-bit or smaller integers with the
1266 # default options
, 0 otherwise.
1268 proc check_effective_target_int16
{ } {
1269 return [check_no_compiler_messages int16 object
{
1270 int dummy
[sizeof
(int) < 4 ?
1 : -1];
1274 #
Return 1 if we
're generating 64-bit code using default options, 0
1277 proc check_effective_target_lp64 { } {
1278 return [check_no_compiler_messages lp64 object {
1279 int dummy[sizeof (int) == 4
1280 && sizeof (void *) == 8
1281 && sizeof (long) == 8 ? 1 : -1];
1285 # Return 1 if we're generating
64-bit code using default llp64 options
,
1288 proc check_effective_target_llp64
{ } {
1289 return [check_no_compiler_messages llp64 object
{
1290 int dummy
[sizeof
(int) == 4
1291 && sizeof
(void
*) == 8
1292 && sizeof
(long long
) == 8
1293 && sizeof
(long
) == 4 ?
1 : -1];
1297 #
Return 1 if the target supports long double larger than double
,
1300 proc check_effective_target_large_long_double
{ } {
1301 return [check_no_compiler_messages large_long_double object
{
1302 int dummy
[sizeof
(long double
) > sizeof
(double
) ?
1 : -1];
1306 #
Return 1 if the target supports double larger than float
,
1309 proc check_effective_target_large_double
{ } {
1310 return [check_no_compiler_messages large_double object
{
1311 int dummy
[sizeof
(double
) > sizeof
(float
) ?
1 : -1];
1315 #
Return 1 if the target supports double of
64 bits
,
1318 proc check_effective_target_double64
{ } {
1319 return [check_no_compiler_messages double64 object
{
1320 int dummy
[sizeof
(double
) == 8 ?
1 : -1];
1324 #
Return 1 if the target supports double of at least
64 bits
,
1327 proc check_effective_target_double64plus
{ } {
1328 return [check_no_compiler_messages double64plus object
{
1329 int dummy
[sizeof
(double
) >= 8 ?
1 : -1];
1333 #
Return 1 if the target supports compiling fixed
-point
,
1336 proc check_effective_target_fixed_point
{ } {
1337 return [check_no_compiler_messages fixed_point object
{
1338 _Sat _Fract x
; _Sat _Accum y
;
1342 #
Return 1 if the target supports compiling decimal floating point
,
1345 proc check_effective_target_dfp_nocache
{ } {
1346 verbose
"check_effective_target_dfp_nocache: compiling source" 2
1347 set ret
[check_no_compiler_messages_nocache dfp object
{
1348 float x __attribute__
((mode(DD
)));
1350 verbose
"check_effective_target_dfp_nocache: returning $ret" 2
1354 proc check_effective_target_dfprt_nocache
{ } {
1355 return [check_runtime_nocache dfprt
{
1356 typedef float d64 __attribute__
((mode(DD
)));
1357 d64 x
= 1.2df
, y
= 2.3dd
, z
;
1358 int main
() { z
= x
+ y
; return 0; }
1362 #
Return 1 if the target supports compiling Decimal Floating Point
,
1365 # This won
't change for different subtargets so cache the result.
1367 proc check_effective_target_dfp { } {
1368 return [check_cached_effective_target dfp {
1369 check_effective_target_dfp_nocache
1373 # Return 1 if the target supports linking and executing Decimal Floating
1374 # Point, 0 otherwise.
1376 # This won't change
for different subtargets so
cache the result.
1378 proc check_effective_target_dfprt
{ } {
1379 return [check_cached_effective_target dfprt
{
1380 check_effective_target_dfprt_nocache
1384 #
Return 1 if the target supports compiling and assembling UCN
, 0 otherwise.
1386 proc check_effective_target_ucn_nocache
{ } {
1387 #
-std
=c99 is only valid
for C
1388 if [check_effective_target_c
] {
1389 set ucnopts
"-std=c99"
1391 append ucnopts
" -fextended-identifiers"
1392 verbose
"check_effective_target_ucn_nocache: compiling source" 2
1393 set ret
[check_no_compiler_messages_nocache ucn object
{
1396 verbose
"check_effective_target_ucn_nocache: returning $ret" 2
1400 #
Return 1 if the target supports compiling and assembling UCN
, 0 otherwise.
1402 # This won
't change for different subtargets, so cache the result.
1404 proc check_effective_target_ucn { } {
1405 return [check_cached_effective_target ucn {
1406 check_effective_target_ucn_nocache
1410 # Return 1 if the target needs a command line argument to enable a SIMD
1413 proc check_effective_target_vect_cmdline_needed { } {
1414 global et_vect_cmdline_needed_saved
1415 global et_vect_cmdline_needed_target_name
1417 if { ![info exists et_vect_cmdline_needed_target_name] } {
1418 set et_vect_cmdline_needed_target_name ""
1421 # If the target has changed since we set the cached value, clear it.
1422 set current_target [current_target_name]
1423 if { $current_target != $et_vect_cmdline_needed_target_name } {
1424 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target
'" 2
1425 set et_vect_cmdline_needed_target_name $current_target
1426 if { [info exists et_vect_cmdline_needed_saved] } {
1427 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1428 unset et_vect_cmdline_needed_saved
1432 if [info exists et_vect_cmdline_needed_saved] {
1433 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1435 set et_vect_cmdline_needed_saved 1
1436 if { [istarget alpha*-*-*]
1437 || [istarget ia64-*-*]
1438 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1439 && [check_effective_target_lp64])
1440 || ([istarget powerpc*-*-*]
1441 && ([check_effective_target_powerpc_spe]
1442 || [check_effective_target_powerpc_altivec]))
1443 || [istarget spu-*-*]
1444 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1445 set et_vect_cmdline_needed_saved 0
1449 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1450 return $et_vect_cmdline_needed_saved
1453 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1455 # This won't change
for different subtargets so
cache the result.
1457 proc check_effective_target_vect_int
{ } {
1458 global et_vect_int_saved
1460 if [info exists et_vect_int_saved
] {
1461 verbose
"check_effective_target_vect_int: using cached result" 2
1463 set et_vect_int_saved
0
1464 if { [istarget i?
86-*-*]
1465 ||
([istarget powerpc
*-*-*]
1466 && ![istarget powerpc
-*-linux
*paired
*])
1467 ||
[istarget spu
-*-*]
1468 ||
[istarget x86_64
-*-*]
1469 ||
[istarget sparc
*-*-*]
1470 ||
[istarget alpha
*-*-*]
1471 ||
[istarget ia64
-*-*]
1472 ||
[check_effective_target_arm32
] } {
1473 set et_vect_int_saved
1
1477 verbose
"check_effective_target_vect_int: returning $et_vect_int_saved" 2
1478 return $et_vect_int_saved
1481 #
Return 1 if the target supports signed
int->float conversion
1484 proc check_effective_target_vect_intfloat_cvt
{ } {
1485 global et_vect_intfloat_cvt_saved
1487 if [info exists et_vect_intfloat_cvt_saved
] {
1488 verbose
"check_effective_target_vect_intfloat_cvt: using cached result" 2
1490 set et_vect_intfloat_cvt_saved
0
1491 if { [istarget i?
86-*-*]
1492 ||
([istarget powerpc
*-*-*]
1493 && ![istarget powerpc
-*-linux
*paired
*])
1494 ||
[istarget x86_64
-*-*] } {
1495 set et_vect_intfloat_cvt_saved
1
1499 verbose
"check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1500 return $et_vect_intfloat_cvt_saved
1504 #
Return 1 if the target supports unsigned
int->float conversion
1507 proc check_effective_target_vect_uintfloat_cvt
{ } {
1508 global et_vect_uintfloat_cvt_saved
1510 if [info exists et_vect_uintfloat_cvt_saved
] {
1511 verbose
"check_effective_target_vect_uintfloat_cvt: using cached result" 2
1513 set et_vect_uintfloat_cvt_saved
0
1514 if { [istarget i?
86-*-*]
1515 ||
([istarget powerpc
*-*-*]
1516 && ![istarget powerpc
-*-linux
*paired
*])
1517 ||
[istarget x86_64
-*-*] } {
1518 set et_vect_uintfloat_cvt_saved
1
1522 verbose
"check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1523 return $et_vect_uintfloat_cvt_saved
1527 #
Return 1 if the target supports signed float
->int conversion
1530 proc check_effective_target_vect_floatint_cvt
{ } {
1531 global et_vect_floatint_cvt_saved
1533 if [info exists et_vect_floatint_cvt_saved
] {
1534 verbose
"check_effective_target_vect_floatint_cvt: using cached result" 2
1536 set et_vect_floatint_cvt_saved
0
1537 if { [istarget i?
86-*-*]
1538 ||
([istarget powerpc
*-*-*]
1539 && ![istarget powerpc
-*-linux
*paired
*])
1540 ||
[istarget x86_64
-*-*] } {
1541 set et_vect_floatint_cvt_saved
1
1545 verbose
"check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1546 return $et_vect_floatint_cvt_saved
1549 #
Return 1 if the target supports unsigned float
->int conversion
1552 proc check_effective_target_vect_floatuint_cvt
{ } {
1553 global et_vect_floatuint_cvt_saved
1555 if [info exists et_vect_floatuint_cvt_saved
] {
1556 verbose
"check_effective_target_vect_floatuint_cvt: using cached result" 2
1558 set et_vect_floatuint_cvt_saved
0
1559 if { ([istarget powerpc
*-*-*]
1560 && ![istarget powerpc
-*-linux
*paired
*]) } {
1561 set et_vect_floatuint_cvt_saved
1
1565 verbose
"check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1566 return $et_vect_floatuint_cvt_saved
1569 #
Return 1 is this is an arm target using
32-bit instructions
1570 proc check_effective_target_arm32
{ } {
1571 return [check_no_compiler_messages arm32 assembly
{
1572 #
if !defined
(__arm__
) ||
(defined
(__thumb__
) && !defined
(__thumb2__
))
1578 #
Return 1 if this is an ARM target supporting
-mfpu
=vfp
1579 #
-mfloat
-abi
=softfp. Some multilibs may be incompatible with these
1582 proc check_effective_target_arm_vfp_ok
{ } {
1583 if { [check_effective_target_arm32
] } {
1584 return [check_no_compiler_messages arm_vfp_ok object
{
1586 } "-mfpu=vfp -mfloat-abi=softfp"]
1592 #
Return 1 if this is an ARM target supporting
-mfpu
=vfp
1593 #
-mfloat
-abi
=hard. Some multilibs may be incompatible with these
1596 proc check_effective_target_arm_hard_vfp_ok
{ } {
1597 if { [check_effective_target_arm32
] } {
1598 return [check_no_compiler_messages arm_hard_vfp_ok executable
{
1599 int main
() { return 0;}
1600 } "-mfpu=vfp -mfloat-abi=hard"]
1606 #
Return 1 if this is an ARM target supporting
-mfpu
=neon
1607 #
-mfloat
-abi
=softfp. Some multilibs may be incompatible with these
1610 proc check_effective_target_arm_neon_ok
{ } {
1611 if { [check_effective_target_arm32
] } {
1612 return [check_no_compiler_messages arm_neon_ok object
{
1613 #
include "arm_neon.h"
1615 } "-mfpu=neon -mfloat-abi=softfp"]
1621 #
Return 1 is this is an ARM target where
-mthumb causes Thumb
-1 to be
1624 proc check_effective_target_arm_thumb1_ok
{ } {
1625 return [check_no_compiler_messages arm_thumb1_ok assembly
{
1626 #
if !defined
(__arm__
) ||
!defined
(__thumb__
) || defined
(__thumb2__
)
1632 #
Return 1 is this is an ARM target where
-mthumb causes Thumb
-2 to be
1635 proc check_effective_target_arm_thumb2_ok
{ } {
1636 return [check_no_compiler_messages arm_thumb2_ok assembly
{
1637 #
if !defined
(__thumb2__
)
1643 #
Return 1 if the target supports executing NEON instructions
, 0
1644 # otherwise.
Cache the result.
1646 proc check_effective_target_arm_neon_hw
{ } {
1647 return [check_runtime arm_neon_hw_available
{
1651 long long a
= 0, b
= 1;
1652 asm
("vorr %P0, %P1, %P2"
1654 : "0" (a), "w" (b));
1657 } "-mfpu=neon -mfloat-abi=softfp"]
1660 #
Return 1 if this is a ARM target with NEON enabled.
1662 proc check_effective_target_arm_neon
{ } {
1663 if { [check_effective_target_arm32
] } {
1664 return [check_no_compiler_messages arm_neon object
{
1665 #ifndef __ARM_NEON__
1676 #
Return 1 if this a Loongson
-2E or
-2F target using an ABI that supports
1677 # the Loongson vector modes.
1679 proc check_effective_target_mips_loongson
{ } {
1680 return [check_no_compiler_messages loongson assembly
{
1681 #
if !defined
(__mips_loongson_vector_rev
)
1687 #
Return 1 if this is an ARM target that adheres to the ABI
for the ARM
1690 proc check_effective_target_arm_eabi
{ } {
1691 return [check_no_compiler_messages arm_eabi object
{
1692 #ifndef __ARM_EABI__
1700 #
Return 1 if this is an ARM target supporting
-mcpu
=iwmmxt.
1701 # Some multilibs may be incompatible with this option.
1703 proc check_effective_target_arm_iwmmxt_ok
{ } {
1704 if { [check_effective_target_arm32
] } {
1705 return [check_no_compiler_messages arm_iwmmxt_ok object
{
1713 #
Return 1 if this is a PowerPC target with floating
-point registers.
1715 proc check_effective_target_powerpc_fprs
{ } {
1716 if { [istarget powerpc
*-*-*]
1717 ||
[istarget rs6000
-*-*] } {
1718 return [check_no_compiler_messages powerpc_fprs object
{
1730 #
Return 1 if this is a PowerPC target with hardware double
-precision
1733 proc check_effective_target_powerpc_hard_double
{ } {
1734 if { [istarget powerpc
*-*-*]
1735 ||
[istarget rs6000
-*-*] } {
1736 return [check_no_compiler_messages powerpc_hard_double object
{
1748 #
Return 1 if this is a PowerPC target supporting
-maltivec.
1750 proc check_effective_target_powerpc_altivec_ok
{ } {
1751 if { ([istarget powerpc
*-*-*]
1752 && ![istarget powerpc
-*-linux
*paired
*])
1753 ||
[istarget rs6000
-*-*] } {
1754 # AltiVec is not supported
on AIX before
5.3.
1755 if { [istarget powerpc
*-*-aix4
*]
1756 ||
[istarget powerpc
*-*-aix5.1
*]
1757 ||
[istarget powerpc
*-*-aix5.2
*] } {
1760 return [check_no_compiler_messages powerpc_altivec_ok object
{
1768 #
Return 1 if this is a PowerPC target supporting
-mvsx
1770 proc check_effective_target_powerpc_vsx_ok
{ } {
1771 if { ([istarget powerpc
*-*-*]
1772 && ![istarget powerpc
-*-linux
*paired
*])
1773 ||
[istarget rs6000
-*-*] } {
1774 # AltiVec is not supported
on AIX before
5.3.
1775 if { [istarget powerpc
*-*-aix4
*]
1776 ||
[istarget powerpc
*-*-aix5.1
*]
1777 ||
[istarget powerpc
*-*-aix5.2
*] } {
1780 return [check_no_compiler_messages powerpc_vsx_ok object
{
1783 asm volatile
("xxlor vs0,vs0,vs0");
1785 asm volatile
("xxlor 0,0,0");
1795 #
Return 1 if this is a PowerPC target supporting
-mcpu
=cell.
1797 proc check_effective_target_powerpc_ppu_ok
{ } {
1798 if [check_effective_target_powerpc_altivec_ok
] {
1799 return [check_no_compiler_messages cell_asm_available object
{
1802 asm volatile
("lvlx v0,v0,v0");
1804 asm volatile
("lvlx 0,0,0");
1814 #
Return 1 if this is a PowerPC target that supports SPU.
1816 proc check_effective_target_powerpc_spu
{ } {
1817 if [istarget powerpc
*-*-linux
*] {
1818 return [check_effective_target_powerpc_altivec_ok
]
1824 #
Return 1 if this is a PowerPC SPE target. The check includes options
1825 # specified by dg
-options
for this test
, so don
't cache the result.
1827 proc check_effective_target_powerpc_spe_nocache { } {
1828 if { [istarget powerpc*-*-*] } {
1829 return [check_no_compiler_messages_nocache powerpc_spe object {
1835 } [current_compiler_flags]]
1841 # Return 1 if this is a PowerPC target with SPE enabled.
1843 proc check_effective_target_powerpc_spe { } {
1844 if { [istarget powerpc*-*-*] } {
1845 return [check_no_compiler_messages powerpc_spe object {
1857 # Return 1 if this is a PowerPC target with Altivec enabled.
1859 proc check_effective_target_powerpc_altivec { } {
1860 if { [istarget powerpc*-*-*] } {
1861 return [check_no_compiler_messages powerpc_altivec object {
1873 # Return 1 if this is a PowerPC 405 target. The check includes options
1874 # specified by dg-options for this test, so don't
cache the result.
1876 proc check_effective_target_powerpc_405_nocache
{ } {
1877 if { [istarget powerpc
*-*-*] ||
[istarget rs6000
-*-*] } {
1878 return [check_no_compiler_messages_nocache powerpc_405 object
{
1884 } [current_compiler_flags
]]
1890 #
Return 1 if this is a SPU target with a toolchain that
1891 # supports automatic overlay generation.
1893 proc check_effective_target_spu_auto_overlay
{ } {
1894 if { [istarget spu
*-*-elf
*] } {
1895 return [check_no_compiler_messages spu_auto_overlay executable
{
1897 } "-Wl,--auto-overlay" ]
1903 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1904 # chokes
on EM_SPARC32PLUS or EM_SPARCV9 executables.
Return 1 if the
1905 # test environment appears to run executables
on such a simulator.
1907 proc check_effective_target_ultrasparc_hw
{ } {
1908 return [check_runtime ultrasparc_hw
{
1909 int main
() { return 0; }
1910 } "-mcpu=ultrasparc"]
1913 #
Return 1 if the target supports hardware vector shift operation.
1915 proc check_effective_target_vect_shift
{ } {
1916 global et_vect_shift_saved
1918 if [info exists et_vect_shift_saved
] {
1919 verbose
"check_effective_target_vect_shift: using cached result" 2
1921 set et_vect_shift_saved
0
1922 if { ([istarget powerpc
*-*-*]
1923 && ![istarget powerpc
-*-linux
*paired
*])
1924 ||
[istarget ia64
-*-*]
1925 ||
[istarget i?
86-*-*]
1926 ||
[istarget x86_64
-*-*]
1927 ||
[check_effective_target_arm32
] } {
1928 set et_vect_shift_saved
1
1932 verbose
"check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1933 return $et_vect_shift_saved
1936 #
Return 1 if the target supports hardware vectors of long
, 0 otherwise.
1938 # This can change
for different subtargets so
do not
cache the result.
1940 proc check_effective_target_vect_long
{ } {
1941 if { [istarget i?
86-*-*]
1942 ||
(([istarget powerpc
*-*-*]
1943 && ![istarget powerpc
-*-linux
*paired
*])
1944 && [check_effective_target_ilp32
])
1945 ||
[istarget x86_64
-*-*]
1946 ||
[check_effective_target_arm32
]
1947 ||
([istarget sparc
*-*-*] && [check_effective_target_ilp32
]) } {
1953 verbose
"check_effective_target_vect_long: returning $answer" 2
1957 #
Return 1 if the target supports hardware vectors of float
, 0 otherwise.
1959 # This won
't change for different subtargets so cache the result.
1961 proc check_effective_target_vect_float { } {
1962 global et_vect_float_saved
1964 if [info exists et_vect_float_saved] {
1965 verbose "check_effective_target_vect_float: using cached result" 2
1967 set et_vect_float_saved 0
1968 if { [istarget i?86-*-*]
1969 || [istarget powerpc*-*-*]
1970 || [istarget spu-*-*]
1971 || [istarget mipsisa64*-*-*]
1972 || [istarget x86_64-*-*]
1973 || [istarget ia64-*-*]
1974 || [check_effective_target_arm32] } {
1975 set et_vect_float_saved 1
1979 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1980 return $et_vect_float_saved
1983 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1985 # This won't change
for different subtargets so
cache the result.
1987 proc check_effective_target_vect_double
{ } {
1988 global et_vect_double_saved
1990 if [info exists et_vect_double_saved
] {
1991 verbose
"check_effective_target_vect_double: using cached result" 2
1993 set et_vect_double_saved
0
1994 if { [istarget i?
86-*-*]
1995 ||
[istarget x86_64
-*-*]
1996 ||
[istarget spu
-*-*] } {
1997 set et_vect_double_saved
1
2001 verbose
"check_effective_target_vect_double: returning $et_vect_double_saved" 2
2002 return $et_vect_double_saved
2005 #
Return 1 if the target supports hardware vectors of long long
, 0 otherwise.
2007 # This won
't change for different subtargets so cache the result.
2009 proc check_effective_target_vect_long_long { } {
2010 global et_vect_long_long_saved
2012 if [info exists et_vect_long_long_saved] {
2013 verbose "check_effective_target_vect_long_long: using cached result" 2
2015 set et_vect_long_long_saved 0
2016 if { [istarget i?86-*-*]
2017 || [istarget x86_64-*-*] } {
2018 set et_vect_long_long_saved 1
2022 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2023 return $et_vect_long_long_saved
2027 # Return 1 if the target plus current options does not support a vector
2028 # max instruction on "int", 0 otherwise.
2030 # This won't change
for different subtargets so
cache the result.
2032 proc check_effective_target_vect_no_int_max
{ } {
2033 global et_vect_no_int_max_saved
2035 if [info exists et_vect_no_int_max_saved
] {
2036 verbose
"check_effective_target_vect_no_int_max: using cached result" 2
2038 set et_vect_no_int_max_saved
0
2039 if { [istarget sparc
*-*-*]
2040 ||
[istarget spu
-*-*]
2041 ||
[istarget alpha
*-*-*] } {
2042 set et_vect_no_int_max_saved
1
2045 verbose
"check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2046 return $et_vect_no_int_max_saved
2049 #
Return 1 if the target plus current options does not support a vector
2050 # add instruction
on "int", 0 otherwise.
2052 # This won
't change for different subtargets so cache the result.
2054 proc check_effective_target_vect_no_int_add { } {
2055 global et_vect_no_int_add_saved
2057 if [info exists et_vect_no_int_add_saved] {
2058 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2060 set et_vect_no_int_add_saved 0
2061 # Alpha only supports vector add on V8QI and V4HI.
2062 if { [istarget alpha*-*-*] } {
2063 set et_vect_no_int_add_saved 1
2066 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2067 return $et_vect_no_int_add_saved
2070 # Return 1 if the target plus current options does not support vector
2071 # bitwise instructions, 0 otherwise.
2073 # This won't change
for different subtargets so
cache the result.
2075 proc check_effective_target_vect_no_bitwise
{ } {
2076 global et_vect_no_bitwise_saved
2078 if [info exists et_vect_no_bitwise_saved
] {
2079 verbose
"check_effective_target_vect_no_bitwise: using cached result" 2
2081 set et_vect_no_bitwise_saved
0
2083 verbose
"check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2084 return $et_vect_no_bitwise_saved
2087 #
Return 1 if the target plus current options supports vector permutation
,
2090 # This won
't change for different subtargets so cache the result.
2092 proc check_effective_target_vect_perm { } {
2095 if [info exists et_vect_perm_saved] {
2096 verbose "check_effective_target_vect_perm: using cached result" 2
2098 set et_vect_perm_saved 0
2099 if { [istarget powerpc*-*-*]
2100 || [istarget spu-*-*] } {
2101 set et_vect_perm_saved 1
2104 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2105 return $et_vect_perm_saved
2108 # Return 1 if the target plus current options supports a vector
2109 # widening summation of *short* args into *int* result, 0 otherwise.
2111 # This won't change
for different subtargets so
cache the result.
2113 proc check_effective_target_vect_widen_sum_hi_to_si_pattern
{ } {
2114 global et_vect_widen_sum_hi_to_si_pattern
2116 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved
] {
2117 verbose
"check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2119 set et_vect_widen_sum_hi_to_si_pattern_saved
0
2120 if { [istarget powerpc
*-*-*] } {
2121 set et_vect_widen_sum_hi_to_si_pattern_saved
1
2124 verbose
"check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2125 return $et_vect_widen_sum_hi_to_si_pattern_saved
2128 #
Return 1 if the target plus current options supports a vector
2129 # widening summation of
*short
* args into
*int* result
, 0 otherwise.
2130 # A target can also support this widening summation
if it can support
2131 # promotion
(unpacking
) from shorts to ints.
2133 # This won
't change for different subtargets so cache the result.
2135 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2136 global et_vect_widen_sum_hi_to_si
2138 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2139 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2141 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2142 if { [istarget powerpc*-*-*]
2143 || [istarget ia64-*-*] } {
2144 set et_vect_widen_sum_hi_to_si_saved 1
2147 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2148 return $et_vect_widen_sum_hi_to_si_saved
2151 # Return 1 if the target plus current options supports a vector
2152 # widening summation of *char* args into *short* result, 0 otherwise.
2153 # A target can also support this widening summation if it can support
2154 # promotion (unpacking) from chars to shorts.
2156 # This won't change
for different subtargets so
cache the result.
2158 proc check_effective_target_vect_widen_sum_qi_to_hi
{ } {
2159 global et_vect_widen_sum_qi_to_hi
2161 if [info exists et_vect_widen_sum_qi_to_hi_saved
] {
2162 verbose
"check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2164 set et_vect_widen_sum_qi_to_hi_saved
0
2165 if { [check_effective_target_vect_unpack
]
2166 ||
[istarget ia64
-*-*] } {
2167 set et_vect_widen_sum_qi_to_hi_saved
1
2170 verbose
"check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2171 return $et_vect_widen_sum_qi_to_hi_saved
2174 #
Return 1 if the target plus current options supports a vector
2175 # widening summation of
*char
* args into
*int* result
, 0 otherwise.
2177 # This won
't change for different subtargets so cache the result.
2179 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2180 global et_vect_widen_sum_qi_to_si
2182 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2183 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2185 set et_vect_widen_sum_qi_to_si_saved 0
2186 if { [istarget powerpc*-*-*] } {
2187 set et_vect_widen_sum_qi_to_si_saved 1
2190 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2191 return $et_vect_widen_sum_qi_to_si_saved
2194 # Return 1 if the target plus current options supports a vector
2195 # widening multiplication of *char* args into *short* result, 0 otherwise.
2196 # A target can also support this widening multplication if it can support
2197 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2198 # multiplication of shorts).
2200 # This won't change
for different subtargets so
cache the result.
2203 proc check_effective_target_vect_widen_mult_qi_to_hi
{ } {
2204 global et_vect_widen_mult_qi_to_hi
2206 if [info exists et_vect_widen_mult_qi_to_hi_saved
] {
2207 verbose
"check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2209 if { [check_effective_target_vect_unpack
]
2210 && [check_effective_target_vect_short_mult
] } {
2211 set et_vect_widen_mult_qi_to_hi_saved
1
2213 set et_vect_widen_mult_qi_to_hi_saved
0
2215 if { [istarget powerpc
*-*-*] } {
2216 set et_vect_widen_mult_qi_to_hi_saved
1
2219 verbose
"check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2220 return $et_vect_widen_mult_qi_to_hi_saved
2223 #
Return 1 if the target plus current options supports a vector
2224 # widening multiplication of
*short
* args into
*int* result
, 0 otherwise.
2225 # A target can also support this widening multplication
if it can support
2226 # promotion
(unpacking
) from shorts to ints
, and vect_int_mult
(non
-widening
2227 # multiplication of ints
).
2229 # This won
't change for different subtargets so cache the result.
2232 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2233 global et_vect_widen_mult_hi_to_si
2235 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2236 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2238 if { [check_effective_target_vect_unpack]
2239 && [check_effective_target_vect_int_mult] } {
2240 set et_vect_widen_mult_hi_to_si_saved 1
2242 set et_vect_widen_mult_hi_to_si_saved 0
2244 if { [istarget powerpc*-*-*]
2245 || [istarget spu-*-*]
2246 || [istarget i?86-*-*]
2247 || [istarget x86_64-*-*] } {
2248 set et_vect_widen_mult_hi_to_si_saved 1
2251 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2252 return $et_vect_widen_mult_hi_to_si_saved
2255 # Return 1 if the target plus current options supports a vector
2256 # dot-product of signed chars, 0 otherwise.
2258 # This won't change
for different subtargets so
cache the result.
2260 proc check_effective_target_vect_sdot_qi
{ } {
2261 global et_vect_sdot_qi
2263 if [info exists et_vect_sdot_qi_saved
] {
2264 verbose
"check_effective_target_vect_sdot_qi: using cached result" 2
2266 set et_vect_sdot_qi_saved
0
2268 verbose
"check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2269 return $et_vect_sdot_qi_saved
2272 #
Return 1 if the target plus current options supports a vector
2273 # dot
-product of unsigned chars
, 0 otherwise.
2275 # This won
't change for different subtargets so cache the result.
2277 proc check_effective_target_vect_udot_qi { } {
2278 global et_vect_udot_qi
2280 if [info exists et_vect_udot_qi_saved] {
2281 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2283 set et_vect_udot_qi_saved 0
2284 if { [istarget powerpc*-*-*] } {
2285 set et_vect_udot_qi_saved 1
2288 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2289 return $et_vect_udot_qi_saved
2292 # Return 1 if the target plus current options supports a vector
2293 # dot-product of signed shorts, 0 otherwise.
2295 # This won't change
for different subtargets so
cache the result.
2297 proc check_effective_target_vect_sdot_hi
{ } {
2298 global et_vect_sdot_hi
2300 if [info exists et_vect_sdot_hi_saved
] {
2301 verbose
"check_effective_target_vect_sdot_hi: using cached result" 2
2303 set et_vect_sdot_hi_saved
0
2304 if { ([istarget powerpc
*-*-*] && ![istarget powerpc
-*-linux
*paired
*])
2305 ||
[istarget i?
86-*-*]
2306 ||
[istarget x86_64
-*-*] } {
2307 set et_vect_sdot_hi_saved
1
2310 verbose
"check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2311 return $et_vect_sdot_hi_saved
2314 #
Return 1 if the target plus current options supports a vector
2315 # dot
-product of unsigned shorts
, 0 otherwise.
2317 # This won
't change for different subtargets so cache the result.
2319 proc check_effective_target_vect_udot_hi { } {
2320 global et_vect_udot_hi
2322 if [info exists et_vect_udot_hi_saved] {
2323 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2325 set et_vect_udot_hi_saved 0
2326 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2327 set et_vect_udot_hi_saved 1
2330 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2331 return $et_vect_udot_hi_saved
2335 # Return 1 if the target plus current options supports a vector
2336 # demotion (packing) of shorts (to chars) and ints (to shorts)
2337 # using modulo arithmetic, 0 otherwise.
2339 # This won't change
for different subtargets so
cache the result.
2341 proc check_effective_target_vect_pack_trunc
{ } {
2342 global et_vect_pack_trunc
2344 if [info exists et_vect_pack_trunc_saved
] {
2345 verbose
"check_effective_target_vect_pack_trunc: using cached result" 2
2347 set et_vect_pack_trunc_saved
0
2348 if { ([istarget powerpc
*-*-*] && ![istarget powerpc
-*-linux
*paired
*])
2349 ||
[istarget i?
86-*-*]
2350 ||
[istarget x86_64
-*-*]
2351 ||
[istarget spu
-*-*] } {
2352 set et_vect_pack_trunc_saved
1
2355 verbose
"check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2356 return $et_vect_pack_trunc_saved
2359 #
Return 1 if the target plus current options supports a vector
2360 # promotion
(unpacking
) of chars
(to shorts
) and shorts
(to ints
), 0 otherwise.
2362 # This won
't change for different subtargets so cache the result.
2364 proc check_effective_target_vect_unpack { } {
2365 global et_vect_unpack
2367 if [info exists et_vect_unpack_saved] {
2368 verbose "check_effective_target_vect_unpack: using cached result" 2
2370 set et_vect_unpack_saved 0
2371 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2372 || [istarget i?86-*-*]
2373 || [istarget x86_64-*-*]
2374 || [istarget spu-*-*] } {
2375 set et_vect_unpack_saved 1
2378 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2379 return $et_vect_unpack_saved
2382 # Return 1 if the target plus current options does not guarantee
2383 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2385 # This won't change
for different subtargets so
cache the result.
2387 proc check_effective_target_unaligned_stack
{ } {
2388 global et_unaligned_stack_saved
2390 if [info exists et_unaligned_stack_saved
] {
2391 verbose
"check_effective_target_unaligned_stack: using cached result" 2
2393 set et_unaligned_stack_saved
0
2395 verbose
"check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2396 return $et_unaligned_stack_saved
2399 #
Return 1 if the target plus current options does not support a vector
2400 # alignment mechanism
, 0 otherwise.
2402 # This won
't change for different subtargets so cache the result.
2404 proc check_effective_target_vect_no_align { } {
2405 global et_vect_no_align_saved
2407 if [info exists et_vect_no_align_saved] {
2408 verbose "check_effective_target_vect_no_align: using cached result" 2
2410 set et_vect_no_align_saved 0
2411 if { [istarget mipsisa64*-*-*]
2412 || [istarget sparc*-*-*]
2413 || [istarget ia64-*-*]
2414 || [check_effective_target_arm32] } {
2415 set et_vect_no_align_saved 1
2418 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2419 return $et_vect_no_align_saved
2422 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2424 # This won't change
for different subtargets so
cache the result.
2426 proc check_effective_target_vect_hw_misalign
{ } {
2427 global et_vect_hw_misalign_saved
2429 if [info exists et_vect_hw_misalign_saved
] {
2430 verbose
"check_effective_target_vect_hw_misalign: using cached result" 2
2432 set et_vect_hw_misalign_saved
0
2433 if { ([istarget x86_64
-*-*]
2434 ||
[istarget i?
86-*-*]) } {
2435 set et_vect_hw_misalign_saved
1
2438 verbose
"check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2439 return $et_vect_hw_misalign_saved
2443 #
Return 1 if arrays are aligned to the vector alignment
2444 # boundary
, 0 otherwise.
2446 # This won
't change for different subtargets so cache the result.
2448 proc check_effective_target_vect_aligned_arrays { } {
2449 global et_vect_aligned_arrays
2451 if [info exists et_vect_aligned_arrays_saved] {
2452 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2454 set et_vect_aligned_arrays_saved 0
2455 if { (([istarget x86_64-*-*]
2456 || [istarget i?86-*-*]) && [is-effective-target lp64])
2457 || [istarget spu-*-*] } {
2458 set et_vect_aligned_arrays_saved 1
2461 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2462 return $et_vect_aligned_arrays_saved
2465 # Return 1 if types of size 32 bit or less are naturally aligned
2466 # (aligned to their type-size), 0 otherwise.
2468 # This won't change
for different subtargets so
cache the result.
2470 proc check_effective_target_natural_alignment_32
{ } {
2471 global et_natural_alignment_32
2473 if [info exists et_natural_alignment_32_saved
] {
2474 verbose
"check_effective_target_natural_alignment_32: using cached result" 2
2476 # FIXME
: 32bit powerpc
: guaranteed only
if MASK_ALIGN_NATURAL
/POWER.
2477 set et_natural_alignment_32_saved
1
2478 if { ([istarget
*-*-darwin
*] && [is
-effective
-target lp64
]) } {
2479 set et_natural_alignment_32_saved
0
2482 verbose
"check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2483 return $et_natural_alignment_32_saved
2486 #
Return 1 if types of size
64 bit or less are naturally aligned
(aligned to their
2487 # type
-size
), 0 otherwise.
2489 # This won
't change for different subtargets so cache the result.
2491 proc check_effective_target_natural_alignment_64 { } {
2492 global et_natural_alignment_64
2494 if [info exists et_natural_alignment_64_saved] {
2495 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2497 set et_natural_alignment_64_saved 0
2498 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2499 || [istarget spu-*-*] } {
2500 set et_natural_alignment_64_saved 1
2503 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2504 return $et_natural_alignment_64_saved
2507 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2509 # This won't change
for different subtargets so
cache the result.
2511 proc check_effective_target_vector_alignment_reachable
{ } {
2512 global et_vector_alignment_reachable
2514 if [info exists et_vector_alignment_reachable_saved
] {
2515 verbose
"check_effective_target_vector_alignment_reachable: using cached result" 2
2517 if { [check_effective_target_vect_aligned_arrays
]
2518 ||
[check_effective_target_natural_alignment_32
] } {
2519 set et_vector_alignment_reachable_saved
1
2521 set et_vector_alignment_reachable_saved
0
2524 verbose
"check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2525 return $et_vector_alignment_reachable_saved
2528 #
Return 1 if vector alignment
for 64 bit is reachable
, 0 otherwise.
2530 # This won
't change for different subtargets so cache the result.
2532 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2533 global et_vector_alignment_reachable_for_64bit
2535 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2536 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2538 if { [check_effective_target_vect_aligned_arrays]
2539 || [check_effective_target_natural_alignment_64] } {
2540 set et_vector_alignment_reachable_for_64bit_saved 1
2542 set et_vector_alignment_reachable_for_64bit_saved 0
2545 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2546 return $et_vector_alignment_reachable_for_64bit_saved
2549 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2551 proc check_effective_target_vect_condition { } {
2552 global et_vect_cond_saved
2554 if [info exists et_vect_cond_saved] {
2555 verbose "check_effective_target_vect_cond: using cached result" 2
2557 set et_vect_cond_saved 0
2558 if { [istarget powerpc*-*-*]
2559 || [istarget ia64-*-*]
2560 || [istarget i?86-*-*]
2561 || [istarget spu-*-*]
2562 || [istarget x86_64-*-*] } {
2563 set et_vect_cond_saved 1
2567 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2568 return $et_vect_cond_saved
2571 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2573 proc check_effective_target_vect_char_mult { } {
2574 global et_vect_char_mult_saved
2576 if [info exists et_vect_char_mult_saved] {
2577 verbose "check_effective_target_vect_char_mult: using cached result" 2
2579 set et_vect_char_mult_saved 0
2580 if { [istarget ia64-*-*]
2581 || [istarget i?86-*-*]
2582 || [istarget x86_64-*-*] } {
2583 set et_vect_char_mult_saved 1
2587 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2588 return $et_vect_char_mult_saved
2591 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2593 proc check_effective_target_vect_short_mult { } {
2594 global et_vect_short_mult_saved
2596 if [info exists et_vect_short_mult_saved] {
2597 verbose "check_effective_target_vect_short_mult: using cached result" 2
2599 set et_vect_short_mult_saved 0
2600 if { [istarget ia64-*-*]
2601 || [istarget spu-*-*]
2602 || [istarget i?86-*-*]
2603 || [istarget x86_64-*-*]
2604 || [istarget powerpc*-*-*]
2605 || [check_effective_target_arm32] } {
2606 set et_vect_short_mult_saved 1
2610 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2611 return $et_vect_short_mult_saved
2614 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2616 proc check_effective_target_vect_int_mult { } {
2617 global et_vect_int_mult_saved
2619 if [info exists et_vect_int_mult_saved] {
2620 verbose "check_effective_target_vect_int_mult: using cached result" 2
2622 set et_vect_int_mult_saved 0
2623 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2624 || [istarget spu-*-*]
2625 || [istarget i?86-*-*]
2626 || [istarget x86_64-*-*]
2627 || [check_effective_target_arm32] } {
2628 set et_vect_int_mult_saved 1
2632 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2633 return $et_vect_int_mult_saved
2636 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2638 proc check_effective_target_vect_extract_even_odd { } {
2639 global et_vect_extract_even_odd_saved
2641 if [info exists et_vect_extract_even_odd_saved] {
2642 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2644 set et_vect_extract_even_odd_saved 0
2645 if { [istarget powerpc*-*-*]
2646 || [istarget i?86-*-*]
2647 || [istarget x86_64-*-*]
2648 || [istarget spu-*-*] } {
2649 set et_vect_extract_even_odd_saved 1
2653 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2654 return $et_vect_extract_even_odd_saved
2657 # Return 1 if the target supports vector even/odd elements extraction of
2658 # vectors with SImode elements or larger, 0 otherwise.
2660 proc check_effective_target_vect_extract_even_odd_wide { } {
2661 global et_vect_extract_even_odd_wide_saved
2663 if [info exists et_vect_extract_even_odd_wide_saved] {
2664 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2666 set et_vect_extract_even_odd_wide_saved 0
2667 if { [istarget powerpc*-*-*]
2668 || [istarget i?86-*-*]
2669 || [istarget x86_64-*-*]
2670 || [istarget spu-*-*] } {
2671 set et_vect_extract_even_odd_wide_saved 1
2675 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2676 return $et_vect_extract_even_odd_wide_saved
2679 # Return 1 if the target supports vector interleaving, 0 otherwise.
2681 proc check_effective_target_vect_interleave { } {
2682 global et_vect_interleave_saved
2684 if [info exists et_vect_interleave_saved] {
2685 verbose "check_effective_target_vect_interleave: using cached result" 2
2687 set et_vect_interleave_saved 0
2688 if { [istarget powerpc*-*-*]
2689 || [istarget i?86-*-*]
2690 || [istarget x86_64-*-*]
2691 || [istarget spu-*-*] } {
2692 set et_vect_interleave_saved 1
2696 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2697 return $et_vect_interleave_saved
2700 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2701 proc check_effective_target_vect_strided { } {
2702 global et_vect_strided_saved
2704 if [info exists et_vect_strided_saved] {
2705 verbose "check_effective_target_vect_strided: using cached result" 2
2707 set et_vect_strided_saved 0
2708 if { [check_effective_target_vect_interleave]
2709 && [check_effective_target_vect_extract_even_odd] } {
2710 set et_vect_strided_saved 1
2714 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2715 return $et_vect_strided_saved
2718 # Return 1 if the target supports vector interleaving and extract even/odd
2719 # for wide element types, 0 otherwise.
2720 proc check_effective_target_vect_strided_wide { } {
2721 global et_vect_strided_wide_saved
2723 if [info exists et_vect_strided_wide_saved] {
2724 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2726 set et_vect_strided_wide_saved 0
2727 if { [check_effective_target_vect_interleave]
2728 && [check_effective_target_vect_extract_even_odd_wide] } {
2729 set et_vect_strided_wide_saved 1
2733 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2734 return $et_vect_strided_wide_saved
2737 # Return 1 if the target supports section-anchors
2739 proc check_effective_target_section_anchors { } {
2740 global et_section_anchors_saved
2742 if [info exists et_section_anchors_saved] {
2743 verbose "check_effective_target_section_anchors: using cached result" 2
2745 set et_section_anchors_saved 0
2746 if { [istarget powerpc*-*-*]
2747 || [istarget arm*-*-*] } {
2748 set et_section_anchors_saved 1
2752 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2753 return $et_section_anchors_saved
2756 # Return 1 if the target supports atomic operations on "int" and "long".
2758 proc check_effective_target_sync_int_long { } {
2759 global et_sync_int_long_saved
2761 if [info exists et_sync_int_long_saved] {
2762 verbose "check_effective_target_sync_int_long: using cached result" 2
2764 set et_sync_int_long_saved 0
2765 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2766 #
load-reserved/store
-conditional instructions.
2767 if { [istarget ia64
-*-*]
2768 ||
[istarget i?
86-*-*]
2769 ||
[istarget x86_64
-*-*]
2770 ||
[istarget alpha
*-*-*]
2771 ||
[istarget bfin
*-*linux
*]
2772 ||
[istarget s390
*-*-*]
2773 ||
[istarget powerpc
*-*-*]
2774 ||
[istarget sparc64
-*-*]
2775 ||
[istarget sparcv9
-*-*]
2776 ||
[istarget mips
*-*-*] } {
2777 set et_sync_int_long_saved
1
2781 verbose
"check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2782 return $et_sync_int_long_saved
2785 #
Return 1 if the target supports atomic operations
on "char" and "short".
2787 proc check_effective_target_sync_char_short
{ } {
2788 global et_sync_char_short_saved
2790 if [info exists et_sync_char_short_saved
] {
2791 verbose
"check_effective_target_sync_char_short: using cached result" 2
2793 set et_sync_char_short_saved
0
2794 # This is intentionally powerpc but not rs6000
, rs6000 doesn
't have the
2795 # load-reserved/store-conditional instructions.
2796 if { [istarget ia64-*-*]
2797 || [istarget i?86-*-*]
2798 || [istarget x86_64-*-*]
2799 || [istarget alpha*-*-*]
2800 || [istarget s390*-*-*]
2801 || [istarget powerpc*-*-*]
2802 || [istarget sparc64-*-*]
2803 || [istarget sparcv9-*-*]
2804 || [istarget mips*-*-*] } {
2805 set et_sync_char_short_saved 1
2809 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2810 return $et_sync_char_short_saved
2813 # Return 1 if the target uses a ColdFire FPU.
2815 proc check_effective_target_coldfire_fpu { } {
2816 return [check_no_compiler_messages coldfire_fpu assembly {
2823 # Return true if this is a uClibc target.
2825 proc check_effective_target_uclibc {} {
2826 return [check_no_compiler_messages uclibc object {
2827 #include <features.h>
2828 #if !defined (__UCLIBC__)
2834 # Return true if this is a uclibc target and if the uclibc feature
2835 # described by __$feature__ is not present.
2837 proc check_missing_uclibc_feature {feature} {
2838 return [check_no_compiler_messages $feature object "
2839 #include <features.h>
2840 #if !defined (__UCLIBC) || defined (__${feature}__)
2846 # Return true if this is a Newlib target.
2848 proc check_effective_target_newlib {} {
2849 return [check_no_compiler_messages newlib object {
2855 # (a) an error of a few ULP is expected in string to floating-point
2856 # conversion functions; and
2857 # (b) overflow is not always detected correctly by those functions.
2859 proc check_effective_target_lax_strtofp {} {
2860 # By default, assume that all uClibc targets suffer from this.
2861 return [check_effective_target_uclibc]
2864 # Return 1 if this is a target for which wcsftime is a dummy
2865 # function that always returns 0.
2867 proc check_effective_target_dummy_wcsftime {} {
2868 # By default, assume that all uClibc targets suffer from this.
2869 return [check_effective_target_uclibc]
2872 # Return 1 if constructors with initialization priority arguments are
2873 # supposed on this target.
2875 proc check_effective_target_init_priority {} {
2876 return [check_no_compiler_messages init_priority assembly "
2877 void f() __attribute__((constructor (1000)));
2882 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2883 # This can be used with any check_* proc that takes no argument and
2884 # returns only 1 or 0. It could be used with check_* procs that take
2885 # arguments with keywords that pass particular arguments.
2887 proc is-effective-target { arg } {
2889 if { [info procs check_effective_target_${arg}] != [list] } {
2890 set selected [check_effective_target_${arg}]
2893 "vmx_hw" { set selected [check_vmx_hw_available] }
2894 "named_sections" { set selected [check_named_sections_available] }
2895 "gc_sections" { set selected [check_gc_sections_available] }
2896 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2897 default { error "unknown effective target keyword `$arg'" }
2900 verbose
"is-effective-target: $arg $selected" 2
2904 #
Return 1 if the
argument is an effective
-target keyword
, 0 otherwise.
2906 proc is
-effective
-target
-keyword
{ arg } {
2907 if { [info procs check_effective_target_$
{arg}] != [list
] } {
2910 # These have different names
for their check_
* procs.
2912 "vmx_hw" { return 1 }
2913 "named_sections" { return 1 }
2914 "gc_sections" { return 1 }
2915 "cxa_atexit" { return 1 }
2916 default
{ return 0 }
2921 #
Return 1 if target default to short enums
2923 proc check_effective_target_short_enums
{ } {
2924 return [check_no_compiler_messages short_enums assembly
{
2926 int s
[sizeof
(enum foo
) == 1 ?
1 : -1];
2930 #
Return 1 if target supports merging string constants at link time.
2932 proc check_effective_target_string_merging
{ } {
2933 return [check_no_messages_and_pattern string_merging \
2934 "rodata\\.str" assembly {
2935 const char
*var
= "String";
2939 #
Return 1 if target has the basic signed and unsigned types in
2940 #
<stdint.h
>, 0 otherwise. This will be obsolete when GCC ensures a
2941 # working
<stdint.h
> for all targets.
2943 proc check_effective_target_stdint_types
{ } {
2944 return [check_no_compiler_messages stdint_types assembly
{
2946 int8_t a
; int16_t b
; int32_t c
; int64_t d
;
2947 uint8_t e
; uint16_t f
; uint32_t g
; uint64_t h
;
2951 #
Return 1 if target has the basic signed and unsigned types in
2952 #
<inttypes.h
>, 0 otherwise. This is
for tests that GCC
's notions of
2953 # these types agree with those in the header, as some systems have
2954 # only <inttypes.h>.
2956 proc check_effective_target_inttypes_types { } {
2957 return [check_no_compiler_messages inttypes_types assembly {
2958 #include <inttypes.h>
2959 int8_t a; int16_t b; int32_t c; int64_t d;
2960 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2964 # Return 1 if programs are intended to be run on a simulator
2965 # (i.e. slowly) rather than hardware (i.e. fast).
2967 proc check_effective_target_simulator { } {
2969 # All "src/sim" simulators set this one.
2970 if [board_info target exists is_simulator] {
2971 return [board_info target is_simulator]
2974 # The "sid" simulators don't
set that one
, but at least they
set
2976 if [board_info target
exists slow_simulator
] {
2977 return [board_info target slow_simulator
]
2983 #
Return 1 if the target is a VxWorks kernel.
2985 proc check_effective_target_vxworks_kernel
{ } {
2986 return [check_no_compiler_messages vxworks_kernel assembly
{
2987 #
if !defined __vxworks || defined __RTP__
2993 #
Return 1 if the target is a VxWorks RTP.
2995 proc check_effective_target_vxworks_rtp
{ } {
2996 return [check_no_compiler_messages vxworks_rtp assembly
{
2997 #
if !defined __vxworks ||
!defined __RTP__
3003 #
Return 1 if the target is expected to provide wide character support.
3005 proc check_effective_target_wchar
{ } {
3006 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR
]} {
3009 return [check_no_compiler_messages wchar assembly
{
3014 #
Return 1 if the target has
<pthread.h
>.
3016 proc check_effective_target_pthread_h
{ } {
3017 return [check_no_compiler_messages pthread_h assembly
{
3018 #
include <pthread.h
>
3022 #
Return 1 if the target can truncate a file from a file
-descriptor
,
3023 # as used by libgfortran
/io
/unix.c
:fd_truncate
; i.e. ftruncate or
3024 # chsize. We test
for a trivially functional truncation
; no stubs.
3025 # As libgfortran uses _FILE_OFFSET_BITS
64, we
do too
; it
'll cause a
3026 # different function to be used.
3028 proc check_effective_target_fd_truncate { } {
3030 #define _FILE_OFFSET_BITS 64
3036 FILE *f = fopen ("tst.tmp", "wb");
3038 const char t[] = "test writing more than ten characters";
3041 write (fd, t, sizeof (t) - 1);
3043 if (ftruncate (fd, 10) != 0)
3046 f = fopen ("tst.tmp", "rb");
3047 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3053 if { [check_runtime ftruncate $prog] } {
3057 regsub "ftruncate" $prog "chsize" prog
3058 return [check_runtime chsize $prog]
3061 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3063 proc add_options_for_c99_runtime { flags } {
3064 if { [istarget *-*-solaris2*] } {
3065 return "$flags -std=c99"
3067 if { [istarget powerpc-*-darwin*] } {
3068 return "$flags -mmacosx-version-min=10.3"
3073 # Add to FLAGS all the target-specific flags needed to enable
3074 # full IEEE compliance mode.
3076 proc add_options_for_ieee { flags } {
3077 if { [istarget "alpha*-*-*"]
3078 || [istarget "sh*-*-*"] } {
3079 return "$flags -mieee"
3084 # Add to FLAGS the flags needed to enable functions to bind locally
3085 # when using pic/PIC passes in the testsuite.
3087 proc add_options_for_bind_pic_locally { flags } {
3088 if {[check_no_compiler_messages using_pic2 assembly {
3093 return "$flags -fPIE"
3095 if {[check_no_compiler_messages using_pic1 assembly {
3100 return "$flags -fpie"
3106 # Return 1 if the target provides a full C99 runtime.
3108 proc check_effective_target_c99_runtime { } {
3109 return [check_cached_effective_target c99_runtime {
3112 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3113 set contents [read $file]
3116 #ifndef HAVE_C99_RUNTIME
3120 check_no_compiler_messages_nocache c99_runtime assembly \
3121 $contents [add_options_for_c99_runtime ""]
3125 # Return 1 if target wchar_t is at least 4 bytes.
3127 proc check_effective_target_4byte_wchar_t { } {
3128 return [check_no_compiler_messages 4byte_wchar_t object {
3129 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3133 # Return 1 if the target supports automatic stack alignment.
3135 proc check_effective_target_automatic_stack_alignment { } {
3136 if { [istarget i?86*-*-*]
3137 || [istarget x86_64-*-*] } then {
3144 # Return 1 if avx instructions can be compiled.
3146 proc check_effective_target_avx { } {
3147 return [check_no_compiler_messages avx object {
3148 void _mm256_zeroall (void)
3150 __builtin_ia32_vzeroall ();
3155 # Return 1 if C wchar_t type is compatible with char16_t.
3157 proc check_effective_target_wchar_t_char16_t_compatible { } {
3158 return [check_no_compiler_messages wchar_t_char16_t object {
3160 __CHAR16_TYPE__ *p16 = &wc;
3161 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3165 # Return 1 if C wchar_t type is compatible with char32_t.
3167 proc check_effective_target_wchar_t_char32_t_compatible { } {
3168 return [check_no_compiler_messages wchar_t_char32_t object {
3170 __CHAR32_TYPE__ *p32 = &wc;
3171 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3175 # Return 1 if pow10 function exists.
3177 proc check_effective_target_pow10 { } {
3178 return [check_runtime pow10 {
3188 # Return 1 if current options generate DFP instructions, 0 otherwise.
3190 proc check_effective_target_hard_dfp {} {
3191 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3192 typedef float d64 __attribute__((mode(DD)));
3194 void foo (void) { z = x + y; }
3198 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3199 # for strchr etc. functions.
3201 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3202 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3205 #if !defined(__cplusplus) \
3206 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3207 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3208 ISO C++ correct string.h and wchar.h protos not supported.
3215 # Return 1 if the compiler has been configure with link-time optimization
3218 proc check_effective_target_lto { } {
3220 return [info exists ENABLE_LTO]
3223 # Return 1 if the language for the compiler under test is C.
3225 proc check_effective_target_c { } {
3227 if [string match $tool "gcc"] {
3233 # Return 1 if the language for the compiler under test is C++.
3235 proc check_effective_target_c++ { } {
3237 if [string match $tool "g++"] {