Merge with gcc-4_3-branch up to revision 175516.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob65f62949f67f3c87dd046480b6c744f7ad71cdfa
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
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. C++ code should contain
33 # "// C++" and Fortran code should contain "! Fortran".
34 proc check_compile {basename type contents args} {
35 global tool
37 if { [llength $args] > 0 } {
38 set options [list "additional_flags=[lindex $args 0]"]
39 } else {
40 set options ""
42 switch -glob -- $contents {
43 "*! Fortran*" { set src ${basename}[pid].f90 }
44 "*// C++*" { set src ${basename}[pid].cc }
45 default { set src ${basename}[pid].c }
47 set compile_type $type
48 switch -glob $type {
49 assembly { set output ${basename}[pid].s }
50 object { set output ${basename}[pid].o }
51 executable { set output ${basename}[pid].exe }
52 "rtl-*" {
53 set output ${basename}[pid].s
54 lappend options "additional_flags=-fdump-$type"
55 set compile_type assembly
58 set f [open $src "w"]
59 puts $f $contents
60 close $f
61 set lines [${tool}_target_compile $src $output $compile_type "$options"]
62 file delete $src
64 set scan_output $output
65 # Don't try folding this into the switch above; calling "glob" before the
66 # file is created won't work.
67 if [regexp "rtl-(.*)" $type dummy rtl_type] {
68 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
69 file delete $output
72 return [list $lines $scan_output]
75 proc current_target_name { } {
76 global target_info
77 if [info exists target_info(target,name)] {
78 set answer $target_info(target,name)
79 } else {
80 set answer ""
82 return $answer
85 # Implement an effective-target check for property PROP by invoking
86 # the Tcl command ARGS and seeing if it returns true.
88 proc check_cached_effective_target { prop args } {
89 global et_cache
91 set target [current_target_name]
92 if {![info exists et_cache($prop,target)]
93 || $et_cache($prop,target) != $target} {
94 verbose "check_cached_effective_target $prop: checking $target" 2
95 set et_cache($prop,target) $target
96 set et_cache($prop,value) [uplevel eval $args]
98 set value $et_cache($prop,value)
99 verbose "check_cached_effective_target $prop: returning $value for $target" 2
100 return $value
103 # Like check_compile, but delete the output file and return true if the
104 # compiler printed no messages.
105 proc check_no_compiler_messages_nocache {args} {
106 set result [eval check_compile $args]
107 set lines [lindex $result 0]
108 set output [lindex $result 1]
109 remote_file build delete $output
110 return [string match "" $lines]
113 # Like check_no_compiler_messages_nocache, but cache the result.
114 # PROP is the property we're checking, and doubles as a prefix for
115 # temporary filenames.
116 proc check_no_compiler_messages {prop args} {
117 return [check_cached_effective_target $prop {
118 eval [list check_no_compiler_messages_nocache $prop] $args
122 # Like check_compile, but return true if the compiler printed no
123 # messages and if the contents of the output file satisfy PATTERN.
124 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
125 # don't match regular expression REGEXP, otherwise they satisfy it
126 # if they do match regular expression PATTERN. (PATTERN can start
127 # with something like "[!]" if the regular expression needs to match
128 # "!" as the first character.)
130 # Delete the output file before returning. The other arguments are
131 # as for check_compile.
132 proc check_no_messages_and_pattern_nocache {basename pattern args} {
133 global tool
135 set result [eval [list check_compile $basename] $args]
136 set lines [lindex $result 0]
137 set output [lindex $result 1]
139 set ok 0
140 if { [string match "" $lines] } {
141 set chan [open "$output"]
142 set invert [regexp {^!(.*)} $pattern dummy pattern]
143 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
144 close $chan
147 remote_file build delete $output
148 return $ok
151 # Like check_no_messages_and_pattern_nocache, but cache the result.
152 # PROP is the property we're checking, and doubles as a prefix for
153 # temporary filenames.
154 proc check_no_messages_and_pattern {prop pattern args} {
155 return [check_cached_effective_target $prop {
156 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
160 # Try to compile and run an executable from code CONTENTS. Return true
161 # if the compiler reports no messages and if execution "passes" in the
162 # usual DejaGNU sense. The arguments are as for check_compile, with
163 # TYPE implicitly being "executable".
164 proc check_runtime_nocache {basename contents args} {
165 global tool
167 set result [eval [list check_compile $basename executable $contents] $args]
168 set lines [lindex $result 0]
169 set output [lindex $result 1]
171 set ok 0
172 if { [string match "" $lines] } {
173 # No error messages, everything is OK.
174 set result [remote_load target "./$output" "" ""]
175 set status [lindex $result 0]
176 verbose "check_runtime_nocache $basename: status is <$status>" 2
177 if { $status == "pass" } {
178 set ok 1
181 remote_file build delete $output
182 return $ok
185 # Like check_runtime_nocache, but cache the result. PROP is the
186 # property we're checking, and doubles as a prefix for temporary
187 # filenames.
188 proc check_runtime {prop args} {
189 global tool
191 return [check_cached_effective_target $prop {
192 eval [list check_runtime_nocache $prop] $args
196 ###############################
197 # proc check_weak_available { }
198 ###############################
200 # weak symbols are only supported in some configs/object formats
201 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
203 proc check_weak_available { } {
204 global target_triplet
205 global target_cpu
207 # All mips targets should support it
209 if { [ string first "mips" $target_cpu ] >= 0 } {
210 return 1
213 # All solaris2 targets should support it
215 if { [regexp ".*-solaris2.*" $target_triplet] } {
216 return 1
219 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
221 if { [regexp "alpha.*osf.*" $target_triplet] } {
222 return 1
225 # Windows targets Cygwin and MingW32 support it
227 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
228 return 1
231 # HP-UX 10.X doesn't support it
233 if { [istarget "hppa*-*-hpux10*"] } {
234 return 0
237 # ELF and ECOFF support it. a.out does with gas/gld but may also with
238 # other linkers, so we should try it
240 set objformat [gcc_target_object_format]
242 switch $objformat {
243 elf { return 1 }
244 ecoff { return 1 }
245 a.out { return 1 }
246 mach-o { return 1 }
247 som { return 1 }
248 unknown { return -1 }
249 default { return 0 }
253 ###############################
254 # proc check_visibility_available { what_kind }
255 ###############################
257 # The visibility attribute is only support in some object formats
258 # This proc returns 1 if it is supported, 0 if not.
259 # The argument is the kind of visibility, default/protected/hidden/internal.
261 proc check_visibility_available { what_kind } {
262 global tool
263 global target_triplet
265 # On NetWare, support makes no sense.
266 if { [istarget *-*-netware*] } {
267 return 0
270 if [string match "" $what_kind] { set what_kind "hidden" }
272 return [check_no_compiler_messages visibility_available_$what_kind object "
273 void f() __attribute__((visibility(\"$what_kind\")));
274 void f() {}
278 ###############################
279 # proc check_alias_available { }
280 ###############################
282 # Determine if the target toolchain supports the alias attribute.
284 # Returns 2 if the target supports aliases. Returns 1 if the target
285 # only supports weak aliased. Returns 0 if the target does not
286 # support aliases at all. Returns -1 if support for aliases could not
287 # be determined.
289 proc check_alias_available { } {
290 global alias_available_saved
291 global tool
293 if [info exists alias_available_saved] {
294 verbose "check_alias_available returning saved $alias_available_saved" 2
295 } else {
296 set src alias[pid].c
297 set obj alias[pid].o
298 verbose "check_alias_available compiling testfile $src" 2
299 set f [open $src "w"]
300 # Compile a small test program. The definition of "g" is
301 # necessary to keep the Solaris assembler from complaining
302 # about the program.
303 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
304 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
305 close $f
306 set lines [${tool}_target_compile $src $obj object ""]
307 file delete $src
308 remote_file build delete $obj
310 if [string match "" $lines] then {
311 # No error messages, everything is OK.
312 set alias_available_saved 2
313 } else {
314 if [regexp "alias definitions not supported" $lines] {
315 verbose "check_alias_available target does not support aliases" 2
317 set objformat [gcc_target_object_format]
319 if { $objformat == "elf" } {
320 verbose "check_alias_available but target uses ELF format, so it ought to" 2
321 set alias_available_saved -1
322 } else {
323 set alias_available_saved 0
325 } else {
326 if [regexp "only weak aliases are supported" $lines] {
327 verbose "check_alias_available target supports only weak aliases" 2
328 set alias_available_saved 1
329 } else {
330 set alias_available_saved -1
335 verbose "check_alias_available returning $alias_available_saved" 2
338 return $alias_available_saved
341 # Returns true if --gc-sections is supported on the target.
343 proc check_gc_sections_available { } {
344 global gc_sections_available_saved
345 global tool
347 if {![info exists gc_sections_available_saved]} {
348 # Some targets don't support gc-sections despite whatever's
349 # advertised by ld's options.
350 if { [istarget alpha*-*-*]
351 || [istarget ia64-*-*] } {
352 set gc_sections_available_saved 0
353 return 0
356 # elf2flt uses -q (--emit-relocs), which is incompatible with
357 # --gc-sections.
358 if { [board_info target exists ldflags]
359 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
360 set gc_sections_available_saved 0
361 return 0
364 # VxWorks kernel modules are relocatable objects linked with -r,
365 # while RTP executables are linked with -q (--emit-relocs).
366 # Both of these options are incompatible with --gc-sections.
367 if { [istarget *-*-vxworks*] } {
368 set gc_sections_available_saved 0
369 return 0
372 # Check if the ld used by gcc supports --gc-sections.
373 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
374 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
375 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
376 set ld_output [remote_exec host "$gcc_ld" "--help"]
377 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
378 set gc_sections_available_saved 1
379 } else {
380 set gc_sections_available_saved 0
383 return $gc_sections_available_saved
386 # Return true if profiling is supported on the target.
388 proc check_profiling_available { test_what } {
389 global profiling_available_saved
391 verbose "Profiling argument is <$test_what>" 1
393 # These conditions depend on the argument so examine them before
394 # looking at the cache variable.
396 # Support for -p on solaris2 relies on mcrt1.o which comes with the
397 # vendor compiler. We cannot reliably predict the directory where the
398 # vendor compiler (and thus mcrt1.o) is installed so we can't
399 # necessarily find mcrt1.o even if we have it.
400 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
401 return 0
404 # Support for -p on irix relies on libprof1.a which doesn't appear to
405 # exist on any irix6 system currently posting testsuite results.
406 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
407 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
408 if { [istarget mips*-*-irix*]
409 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
410 return 0
413 # MinGW does not support -p.
414 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
415 return 0
418 # At present, there is no profiling support on NetWare.
419 if { [istarget *-*-netware*] } {
420 return 0
423 # uClibc does not have gcrt1.o.
424 if { [check_effective_target_uclibc]
425 && ([lindex $test_what 1] == "-p"
426 || [lindex $test_what 1] == "-pg") } {
427 return 0
430 # Now examine the cache variable.
431 if {![info exists profiling_available_saved]} {
432 # Some targets don't have any implementation of __bb_init_func or are
433 # missing other needed machinery.
434 if { [istarget mmix-*-*]
435 || [istarget arm*-*-eabi*]
436 || [istarget arm*-*-elf]
437 || [istarget arm*-*-symbianelf*]
438 || [istarget bfin-*-*]
439 || [istarget powerpc-*-eabi*]
440 || [istarget strongarm*-*-elf]
441 || [istarget xscale*-*-elf]
442 || [istarget cris-*-*]
443 || [istarget crisv32-*-*]
444 || [istarget fido-*-elf]
445 || [istarget h8300-*-*]
446 || [istarget m32c-*-elf]
447 || [istarget m68k-*-elf]
448 || [istarget m68k-*-uclinux*]
449 || [istarget mips*-*-elf*]
450 || [istarget xstormy16-*]
451 || [istarget xtensa-*-elf]
452 || [istarget *-*-vxworks*]
453 || [istarget *-*-windiss] } {
454 set profiling_available_saved 0
455 } else {
456 set profiling_available_saved 1
460 return $profiling_available_saved
463 # Return 1 if target has packed layout of structure members by
464 # default, 0 otherwise. Note that this is slightly different than
465 # whether the target has "natural alignment": both attributes may be
466 # false.
468 proc check_effective_target_default_packed { } {
469 return [check_no_compiler_messages default_packed assembly {
470 struct x { char a; long b; } c;
471 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
475 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
476 # documentation, where the test also comes from.
478 proc check_effective_target_pcc_bitfield_type_matters { } {
479 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
480 # bitfields, but let's stick to the example code from the docs.
481 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
482 struct foo1 { char x; char :0; char y; };
483 struct foo2 { char x; int :0; char y; };
484 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
488 # Return 1 if extended address spaces (__ea) is supported, 0
489 # otherwise.
491 # This won't change for different subtargets so cache the result.
493 proc check_effective_target_ea {} {
494 global et_ea_saved
495 global tool
497 if [info exists et_ea_saved] {
498 verbose "check_effective_target_ea: using cached result" 2
499 } else {
500 set et_ea_saved 1
502 set src ea[pid].c
503 set asm ea[pid].S
504 verbose "check_effective_target_ea: compiling testfile $src" 2
505 set f [open $src "w"]
506 # Compile a small test program.
507 puts $f "extern __ea int i;\n"
508 close $f
510 # Test for extended address space support on the target.
511 set comp_output \
512 [${tool}_target_compile $src $asm assembly ""]
513 file delete $src
514 if { [string match "*not supported*" $comp_output] } {
515 set et_ea_saved 0
517 remove-build-file $asm
519 verbose "check_effective_target_ea: returning $et_ea_saved" 2
520 return $et_ea_saved
523 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
525 # This won't change for different subtargets so cache the result.
527 proc check_effective_target_tls {} {
528 return [check_no_compiler_messages tls assembly {
529 __thread int i;
530 int f (void) { return i; }
531 void g (int j) { i = j; }
535 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
537 # This won't change for different subtargets so cache the result.
539 proc check_effective_target_tls_native {} {
540 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
541 __thread int i;
542 int f (void) { return i; }
543 void g (int j) { i = j; }
547 # Return 1 if TLS executables can run correctly, 0 otherwise.
549 # This won't change for different subtargets so cache the result.
551 proc check_effective_target_tls_runtime {} {
552 return [check_runtime tls_runtime {
553 __thread int thr = 0;
554 int main (void) { return thr; }
558 # Return 1 if compilation with -fopenmp is error-free for trivial
559 # code, 0 otherwise.
561 proc check_effective_target_fopenmp {} {
562 return [check_no_compiler_messages fopenmp object {
563 void foo (void) { }
564 } "-fopenmp"]
567 # Return 1 if compilation with -pthread is error-free for trivial
568 # code, 0 otherwise.
570 proc check_effective_target_pthread {} {
571 return [check_no_compiler_messages pthread object {
572 void foo (void) { }
573 } "-pthread"]
576 # Return 1 if the target supports -static
577 proc check_effective_target_static {} {
578 return [check_no_compiler_messages static executable {
579 int main (void) { return 0; }
580 } "-static"]
583 # Return 1 if the target supports -fstack-protector
584 proc check_effective_target_fstack_protector {} {
585 return [check_runtime fstack_protector {
586 int main (void) { return 0; }
587 } "-fstack-protector"]
590 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
591 # for trivial code, 0 otherwise.
593 proc check_effective_target_freorder {} {
594 return [check_no_compiler_messages freorder object {
595 void foo (void) { }
596 } "-freorder-blocks-and-partition"]
599 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
600 # emitted, 0 otherwise. Whether a shared library can actually be built is
601 # out of scope for this test.
603 proc check_effective_target_fpic { } {
604 # Note that M68K has a multilib that supports -fpic but not
605 # -fPIC, so we need to check both. We test with a program that
606 # requires GOT references.
607 foreach arg {fpic fPIC} {
608 if [check_no_compiler_messages $arg object {
609 extern int foo (void); extern int bar;
610 int baz (void) { return foo () + bar; }
611 } "-$arg"] {
612 return 1
615 return 0
618 # Return true if the target supports -mpaired-single (as used on MIPS).
620 proc check_effective_target_mpaired_single { } {
621 return [check_no_compiler_messages mpaired_single object {
622 void foo (void) { }
623 } "-mpaired-single"]
626 # Return true if the target has access to FPU instructions.
628 proc check_effective_target_hard_float { } {
629 if { [istarget mips*-*-*] } {
630 return [check_no_compiler_messages hard_float assembly {
631 #if (defined __mips_soft_float || defined __mips16)
632 #error FOO
633 #endif
637 # The generic test equates hard_float with "no call for adding doubles".
638 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
639 double a (double b, double c) { return b + c; }
643 # Return true if the target is a 64-bit MIPS target.
645 proc check_effective_target_mips64 { } {
646 return [check_no_compiler_messages mips64 assembly {
647 #ifndef __mips64
648 #error FOO
649 #endif
653 # Return true if the target is a MIPS target that does not produce
654 # MIPS16 code.
656 proc check_effective_target_nomips16 { } {
657 return [check_no_compiler_messages nomips16 object {
658 #ifndef __mips
659 #error FOO
660 #else
661 /* A cheap way of testing for -mflip-mips16. */
662 void foo (void) { asm ("addiu $20,$20,1"); }
663 void bar (void) { asm ("addiu $20,$20,1"); }
664 #endif
668 # Add the options needed for MIPS16 function attributes. At the moment,
669 # we don't support MIPS16 PIC.
671 proc add_options_for_mips16_attribute { flags } {
672 return "$flags -mno-abicalls -fno-pic"
675 # Return true if we can force a mode that allows MIPS16 code generation.
676 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
677 # for o32 and o64.
679 proc check_effective_target_mips16_attribute { } {
680 return [check_no_compiler_messages mips16_attribute assembly {
681 #ifdef PIC
682 #error FOO
683 #endif
684 #if defined __mips_hard_float \
685 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
686 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
687 #error FOO
688 #endif
689 } [add_options_for_mips16_attribute ""]]
692 # Return 1 if the current multilib does not generate PIC by default.
694 proc check_effective_target_nonpic { } {
695 return [check_no_compiler_messages nonpic assembly {
696 #if __PIC__
697 #error FOO
698 #endif
702 # Return 1 if the target does not use a status wrapper.
704 proc check_effective_target_unwrapped { } {
705 if { [target_info needs_status_wrapper] != "" \
706 && [target_info needs_status_wrapper] != "0" } {
707 return 0
709 return 1
712 # Return true if iconv is supported on the target. In particular IBM1047.
714 proc check_iconv_available { test_what } {
715 global libiconv
717 # If the tool configuration file has not set libiconv, try "-liconv"
718 if { ![info exists libiconv] } {
719 set libiconv "-liconv"
721 set test_what [lindex $test_what 1]
722 return [check_runtime_nocache $test_what [subst {
723 #include <iconv.h>
724 int main (void)
726 iconv_t cd;
728 cd = iconv_open ("$test_what", "UTF-8");
729 if (cd == (iconv_t) -1)
730 return 1;
731 return 0;
733 }] $libiconv]
736 # Return true if named sections are supported on this target.
738 proc check_named_sections_available { } {
739 return [check_no_compiler_messages named_sections assembly {
740 int __attribute__ ((section("whatever"))) foo;
744 # Return 1 if the target supports Fortran real kinds larger than real(8),
745 # 0 otherwise.
747 # When the target name changes, replace the cached result.
749 proc check_effective_target_fortran_large_real { } {
750 return [check_no_compiler_messages fortran_large_real executable {
751 ! Fortran
752 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
753 real(kind=k) :: x
754 x = cos (x)
759 # Return 1 if the target supports Fortran integer kinds larger than
760 # integer(8), 0 otherwise.
762 # When the target name changes, replace the cached result.
764 proc check_effective_target_fortran_large_int { } {
765 return [check_no_compiler_messages fortran_large_int executable {
766 ! Fortran
767 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
768 integer(kind=k) :: i
773 # Return 1 if we can statically link libgfortran, 0 otherwise.
775 # When the target name changes, replace the cached result.
777 proc check_effective_target_static_libgfortran { } {
778 return [check_no_compiler_messages static_libgfortran executable {
779 ! Fortran
780 print *, 'test'
782 } "-static"]
785 # Return 1 if the target supports executing 750CL paired-single instructions, 0
786 # otherwise. Cache the result.
788 proc check_750cl_hw_available { } {
789 return [check_cached_effective_target 750cl_hw_available {
790 # If this is not the right target then we can skip the test.
791 if { ![istarget powerpc-*paired*] } {
792 expr 0
793 } else {
794 check_runtime_nocache 750cl_hw_available {
795 int main()
797 #ifdef __MACH__
798 asm volatile ("ps_mul v0,v0,v0");
799 #else
800 asm volatile ("ps_mul 0,0,0");
801 #endif
802 return 0;
804 } "-mpaired"
809 # Return 1 if the target supports executing SSE2 instructions, 0
810 # otherwise. Cache the result.
812 proc check_sse2_hw_available { } {
813 return [check_cached_effective_target sse2_hw_available {
814 # If this is not the right target then we can skip the test.
815 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
816 expr 0
817 } else {
818 check_runtime_nocache sse2_hw_available {
819 #include "cpuid.h"
820 int main ()
822 unsigned int eax, ebx, ecx, edx = 0;
823 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
824 return !(edx & bit_SSE2);
825 return 1;
827 } ""
832 # Return 1 if the target supports executing AltiVec instructions, 0
833 # otherwise. Cache the result.
835 proc check_vmx_hw_available { } {
836 return [check_cached_effective_target vmx_hw_available {
837 # Some simulators are known to not support VMX instructions.
838 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
839 expr 0
840 } else {
841 # Most targets don't require special flags for this test case, but
842 # Darwin does.
843 if { [istarget *-*-darwin*]
844 || [istarget *-*-aix*] } {
845 set options "-maltivec"
846 } else {
847 set options ""
849 check_runtime_nocache vmx_hw_available {
850 int main()
852 #ifdef __MACH__
853 asm volatile ("vor v0,v0,v0");
854 #else
855 asm volatile ("vor 0,0,0");
856 #endif
857 return 0;
859 } $options
864 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
865 # complex float arguments. This affects gfortran tests that call cabsf
866 # in libm built by an earlier compiler. Return 1 if libm uses the same
867 # argument passing as the compiler under test, 0 otherwise.
869 # When the target name changes, replace the cached result.
871 proc check_effective_target_broken_cplxf_arg { } {
872 return [check_cached_effective_target broken_cplxf_arg {
873 # Skip the work for targets known not to be affected.
874 if { ![istarget powerpc64-*-linux*] } {
875 expr 0
876 } elseif { ![is-effective-target lp64] } {
877 expr 0
878 } else {
879 check_runtime_nocache broken_cplxf_arg {
880 #include <complex.h>
881 extern void abort (void);
882 float fabsf (float);
883 float cabsf (_Complex float);
884 int main ()
886 _Complex float cf;
887 float f;
888 cf = 3 + 4.0fi;
889 f = cabsf (cf);
890 if (fabsf (f - 5.0) > 0.0001)
891 abort ();
892 return 0;
894 } "-lm"
899 proc check_alpha_max_hw_available { } {
900 return [check_runtime alpha_max_hw_available {
901 int main() { return __builtin_alpha_amask(1<<8) != 0; }
905 # Returns true iff the FUNCTION is available on the target system.
906 # (This is essentially a Tcl implementation of Autoconf's
907 # AC_CHECK_FUNC.)
909 proc check_function_available { function } {
910 return [check_no_compiler_messages ${function}_available \
911 executable [subst {
912 #ifdef __cplusplus
913 extern "C"
914 #endif
915 char $function ();
916 int main () { $function (); }
920 # Returns true iff "fork" is available on the target system.
922 proc check_fork_available {} {
923 return [check_function_available "fork"]
926 # Returns true iff "mkfifo" is available on the target system.
928 proc check_mkfifo_available {} {
929 if {[istarget *-*-cygwin*]} {
930 # Cygwin has mkfifo, but support is incomplete.
931 return 0
934 return [check_function_available "mkfifo"]
937 # Returns true iff "__cxa_atexit" is used on the target system.
939 proc check_cxa_atexit_available { } {
940 return [check_cached_effective_target cxa_atexit_available {
941 if { [istarget "hppa*-*-hpux10*"] } {
942 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
943 expr 0
944 } else {
945 check_runtime_nocache cxa_atexit_available {
946 // C++
947 #include <stdlib.h>
948 static unsigned int count;
949 struct X
951 X() { count = 1; }
952 ~X()
954 if (count != 3)
955 exit(1);
956 count = 4;
959 void f()
961 static X x;
963 struct Y
965 Y() { f(); count = 2; }
966 ~Y()
968 if (count != 2)
969 exit(1);
970 count = 3;
973 Y y;
974 int main() { return 0; }
981 # Return 1 if we're generating 32-bit code using default options, 0
982 # otherwise.
984 proc check_effective_target_ilp32 { } {
985 return [check_no_compiler_messages ilp32 object {
986 int dummy[sizeof (int) == 4
987 && sizeof (void *) == 4
988 && sizeof (long) == 4 ? 1 : -1];
992 # Return 1 if we're generating 32-bit or larger integers using default
993 # options, 0 otherwise.
995 proc check_effective_target_int32plus { } {
996 return [check_no_compiler_messages int32plus object {
997 int dummy[sizeof (int) >= 4 ? 1 : -1];
1001 # Return 1 if we're generating 32-bit or larger pointers using default
1002 # options, 0 otherwise.
1004 proc check_effective_target_ptr32plus { } {
1005 return [check_no_compiler_messages ptr32plus object {
1006 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1010 # Return 1 if we support 32-bit or larger array and structure sizes
1011 # using default options, 0 otherwise.
1013 proc check_effective_target_size32plus { } {
1014 return [check_no_compiler_messages size32plus object {
1015 char dummy[65537];
1019 # Returns 1 if we're generating 16-bit or smaller integers with the
1020 # default options, 0 otherwise.
1022 proc check_effective_target_int16 { } {
1023 return [check_no_compiler_messages int16 object {
1024 int dummy[sizeof (int) < 4 ? 1 : -1];
1028 # Return 1 if we're generating 64-bit code using default options, 0
1029 # otherwise.
1031 proc check_effective_target_lp64 { } {
1032 return [check_no_compiler_messages lp64 object {
1033 int dummy[sizeof (int) == 4
1034 && sizeof (void *) == 8
1035 && sizeof (long) == 8 ? 1 : -1];
1039 # Return 1 if the target supports long double larger than double,
1040 # 0 otherwise.
1042 proc check_effective_target_large_long_double { } {
1043 return [check_no_compiler_messages large_long_double object {
1044 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1048 # Return 1 if the target supports compiling fixed-point,
1049 # 0 otherwise.
1051 proc check_effective_target_fixed_point { } {
1052 return [check_no_compiler_messages fixed_point object {
1053 _Sat _Fract x; _Sat _Accum y;
1057 # Return 1 if the target supports compiling decimal floating point,
1058 # 0 otherwise.
1060 proc check_effective_target_dfp_nocache { } {
1061 verbose "check_effective_target_dfp_nocache: compiling source" 2
1062 set ret [check_no_compiler_messages_nocache dfp object {
1063 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1065 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1066 return $ret
1069 proc check_effective_target_dfprt_nocache { } {
1070 return [check_runtime_nocache dfprt {
1071 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1072 int main () { z = x + y; return 0; }
1076 # Return 1 if the target supports compiling Decimal Floating Point,
1077 # 0 otherwise.
1079 # This won't change for different subtargets so cache the result.
1081 proc check_effective_target_dfp { } {
1082 return [check_cached_effective_target dfp {
1083 check_effective_target_dfp_nocache
1087 # Return 1 if the target supports linking and executing Decimal Floating
1088 # Point, # 0 otherwise.
1090 # This won't change for different subtargets so cache the result.
1092 proc check_effective_target_dfprt { } {
1093 return [check_cached_effective_target dfprt {
1094 check_effective_target_dfprt_nocache
1098 # Return 1 if the target needs a command line argument to enable a SIMD
1099 # instruction set.
1101 proc check_effective_target_vect_cmdline_needed { } {
1102 global et_vect_cmdline_needed_saved
1103 global et_vect_cmdline_needed_target_name
1105 if { ![info exists et_vect_cmdline_needed_target_name] } {
1106 set et_vect_cmdline_needed_target_name ""
1109 # If the target has changed since we set the cached value, clear it.
1110 set current_target [current_target_name]
1111 if { $current_target != $et_vect_cmdline_needed_target_name } {
1112 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1113 set et_vect_cmdline_needed_target_name $current_target
1114 if { [info exists et_vect_cmdline_needed_saved] } {
1115 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1116 unset et_vect_cmdline_needed_saved
1120 if [info exists et_vect_cmdline_needed_saved] {
1121 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1122 } else {
1123 set et_vect_cmdline_needed_saved 1
1124 if { [istarget alpha*-*-*]
1125 || [istarget ia64-*-*]
1126 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1127 && [check_effective_target_lp64])
1128 || ([istarget powerpc*-*-*]
1129 && ([check_effective_target_powerpc_spe]
1130 || [check_effective_target_powerpc_altivec]))
1131 || [istarget spu-*-*] } {
1132 set et_vect_cmdline_needed_saved 0
1136 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1137 return $et_vect_cmdline_needed_saved
1140 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1142 # This won't change for different subtargets so cache the result.
1144 proc check_effective_target_vect_int { } {
1145 global et_vect_int_saved
1147 if [info exists et_vect_int_saved] {
1148 verbose "check_effective_target_vect_int: using cached result" 2
1149 } else {
1150 set et_vect_int_saved 0
1151 if { [istarget i?86-*-*]
1152 || ([istarget powerpc*-*-*]
1153 && ![istarget powerpc-*-linux*paired*])
1154 || [istarget spu-*-*]
1155 || [istarget x86_64-*-*]
1156 || [istarget sparc*-*-*]
1157 || [istarget alpha*-*-*]
1158 || [istarget ia64-*-*] } {
1159 set et_vect_int_saved 1
1163 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1164 return $et_vect_int_saved
1167 # Return 1 if the target supports signed int->float conversion
1170 proc check_effective_target_vect_intfloat_cvt { } {
1171 global et_vect_intfloat_cvt_saved
1173 if [info exists et_vect_intfloat_cvt_saved] {
1174 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1175 } else {
1176 set et_vect_intfloat_cvt_saved 0
1177 if { [istarget i?86-*-*]
1178 || ([istarget powerpc*-*-*]
1179 && ![istarget powerpc-*-linux*paired*])
1180 || [istarget x86_64-*-*] } {
1181 set et_vect_intfloat_cvt_saved 1
1185 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1186 return $et_vect_intfloat_cvt_saved
1190 # Return 1 if the target supports unsigned int->float conversion
1193 proc check_effective_target_vect_uintfloat_cvt { } {
1194 global et_vect_uintfloat_cvt_saved
1196 if [info exists et_vect_uintfloat_cvt_saved] {
1197 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1198 } else {
1199 set et_vect_uintfloat_cvt_saved 0
1200 if { ([istarget powerpc*-*-*]
1201 && ![istarget powerpc-*-linux*paired*]) } {
1202 set et_vect_uintfloat_cvt_saved 1
1206 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1207 return $et_vect_uintfloat_cvt_saved
1211 # Return 1 if the target supports signed float->int conversion
1214 proc check_effective_target_vect_floatint_cvt { } {
1215 global et_vect_floatint_cvt_saved
1217 if [info exists et_vect_floatint_cvt_saved] {
1218 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1219 } else {
1220 set et_vect_floatint_cvt_saved 0
1221 if { [istarget i?86-*-*]
1222 || [istarget x86_64-*-*] } {
1223 set et_vect_floatint_cvt_saved 1
1227 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1228 return $et_vect_floatint_cvt_saved
1231 # Return 1 if the target supports unsigned float->int conversion
1234 proc check_effective_target_vect_floatuint_cvt { } {
1235 global et_vect_floatuint_cvt_saved
1237 if [info exists et_vect_floatuint_cvt_saved] {
1238 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1239 } else {
1240 set et_vect_floatuint_cvt_saved 0
1241 if { ([istarget powerpc*-*-*]
1242 && ![istarget powerpc-*-linux*paired*]) } {
1243 set et_vect_floatuint_cvt_saved 1
1247 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1248 return $et_vect_floatuint_cvt_saved
1251 # Return 1 is this is an arm target using 32-bit instructions
1252 proc check_effective_target_arm32 { } {
1253 return [check_no_compiler_messages arm32 assembly {
1254 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1255 #error FOO
1256 #endif
1260 # Return 1 if this is an ARM target supporting -mfpu=vfp
1261 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1262 # options.
1264 proc check_effective_target_arm_vfp_ok { } {
1265 if { [check_effective_target_arm32] } {
1266 return [check_no_compiler_messages arm_vfp_ok object {
1267 int dummy;
1268 } "-mfpu=vfp -mfloat-abi=softfp"]
1269 } else {
1270 return 0
1274 # Return 1 if this is an ARM target supporting -mfpu=neon
1275 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1276 # options.
1278 proc check_effective_target_arm_neon_ok { } {
1279 if { [check_effective_target_arm32] } {
1280 return [check_no_compiler_messages arm_neon_ok object {
1281 int dummy;
1282 } "-mfpu=neon -mfloat-abi=softfp"]
1283 } else {
1284 return 0
1288 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1289 # used.
1291 proc check_effective_target_arm_thumb1_ok { } {
1292 return [check_no_compiler_messages arm_thumb1_ok assembly {
1293 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1294 #error FOO
1295 #endif
1296 } "-mthumb"]
1299 # Return 1 if the target supports executing NEON instructions, 0
1300 # otherwise. Cache the result.
1302 proc check_effective_target_arm_neon_hw { } {
1303 return [check_runtime arm_neon_hw_available {
1305 main (void)
1307 long long a = 0, b = 1;
1308 asm ("vorr %P0, %P1, %P2"
1309 : "=w" (a)
1310 : "0" (a), "w" (b));
1311 return (a != 1);
1313 } "-mfpu=neon -mfloat-abi=softfp"]
1316 # Return 1 if this is a PowerPC target with floating-point registers.
1318 proc check_effective_target_powerpc_fprs { } {
1319 if { [istarget powerpc*-*-*]
1320 || [istarget rs6000-*-*] } {
1321 return [check_no_compiler_messages powerpc_fprs object {
1322 #ifdef __NO_FPRS__
1323 #error no FPRs
1324 #else
1325 int dummy;
1326 #endif
1328 } else {
1329 return 0
1333 # Return 1 if this is a PowerPC target with hardware double-precision
1334 # floating point.
1336 proc check_effective_target_powerpc_hard_double { } {
1337 if { [istarget powerpc*-*-*]
1338 || [istarget rs6000-*-*] } {
1339 return [check_no_compiler_messages powerpc_hard_double object {
1340 #ifdef _SOFT_DOUBLE
1341 #error soft double
1342 #else
1343 int dummy;
1344 #endif
1346 } else {
1347 return 0
1351 # Return 1 if this is a PowerPC target supporting -maltivec.
1353 proc check_effective_target_powerpc_altivec_ok { } {
1354 if { ([istarget powerpc*-*-*]
1355 && ![istarget powerpc-*-linux*paired*])
1356 || [istarget rs6000-*-*] } {
1357 # AltiVec is not supported on AIX before 5.3.
1358 if { [istarget powerpc*-*-aix4*]
1359 || [istarget powerpc*-*-aix5.1*]
1360 || [istarget powerpc*-*-aix5.2*] } {
1361 return 0
1363 return [check_no_compiler_messages powerpc_altivec_ok object {
1364 int dummy;
1365 } "-maltivec"]
1366 } else {
1367 return 0
1371 # Return 1 if this is a PowerPC target that supports SPU.
1373 proc check_effective_target_powerpc_spu { } {
1374 if [istarget powerpc*-*-linux*] {
1375 return [check_effective_target_powerpc_altivec_ok]
1376 } else {
1377 return 0
1381 # Return 1 if this is a PowerPC target with SPE enabled.
1383 proc check_effective_target_powerpc_spe { } {
1384 if { [istarget powerpc*-*-*] } {
1385 return [check_no_compiler_messages powerpc_spe object {
1386 #ifndef __SPE__
1387 #error not SPE
1388 #else
1389 int dummy;
1390 #endif
1392 } else {
1393 return 0
1397 # Return 1 if this is a PowerPC target with Altivec enabled.
1399 proc check_effective_target_powerpc_altivec { } {
1400 if { [istarget powerpc*-*-*] } {
1401 return [check_no_compiler_messages powerpc_altivec object {
1402 #ifndef __ALTIVEC__
1403 #error not Altivec
1404 #else
1405 int dummy;
1406 #endif
1408 } else {
1409 return 0
1413 # Return 1 if this is a SPU target with a toolchain that
1414 # supports automatic overlay generation.
1416 proc check_effective_target_spu_auto_overlay { } {
1417 if { [istarget spu*-*-elf*] } {
1418 return [check_no_compiler_messages spu_auto_overlay executable {
1419 int main (void) { }
1420 } "-Wl,--auto-overlay" ]
1421 } else {
1422 return 0
1426 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1427 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1428 # test environment appears to run executables on such a simulator.
1430 proc check_effective_target_ultrasparc_hw { } {
1431 return [check_runtime ultrasparc_hw {
1432 int main() { return 0; }
1433 } "-mcpu=ultrasparc"]
1436 # Return 1 if the target supports hardware vector shift operation.
1438 proc check_effective_target_vect_shift { } {
1439 global et_vect_shift_saved
1441 if [info exists et_vect_shift_saved] {
1442 verbose "check_effective_target_vect_shift: using cached result" 2
1443 } else {
1444 set et_vect_shift_saved 0
1445 if { ([istarget powerpc*-*-*]
1446 && ![istarget powerpc-*-linux*paired*])
1447 || [istarget ia64-*-*]
1448 || [istarget i?86-*-*]
1449 || [istarget x86_64-*-*] } {
1450 set et_vect_shift_saved 1
1454 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1455 return $et_vect_shift_saved
1458 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1460 # This can change for different subtargets so do not cache the result.
1462 proc check_effective_target_vect_long { } {
1463 if { [istarget i?86-*-*]
1464 || (([istarget powerpc*-*-*]
1465 && ![istarget powerpc-*-linux*paired*])
1466 && [check_effective_target_ilp32])
1467 || [istarget x86_64-*-*]
1468 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1469 set answer 1
1470 } else {
1471 set answer 0
1474 verbose "check_effective_target_vect_long: returning $answer" 2
1475 return $answer
1478 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1480 # This won't change for different subtargets so cache the result.
1482 proc check_effective_target_vect_float { } {
1483 global et_vect_float_saved
1485 if [info exists et_vect_float_saved] {
1486 verbose "check_effective_target_vect_float: using cached result" 2
1487 } else {
1488 set et_vect_float_saved 0
1489 if { [istarget i?86-*-*]
1490 || [istarget powerpc*-*-*]
1491 || [istarget spu-*-*]
1492 || [istarget mipsisa64*-*-*]
1493 || [istarget x86_64-*-*]
1494 || [istarget ia64-*-*] } {
1495 set et_vect_float_saved 1
1499 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1500 return $et_vect_float_saved
1503 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1505 # This won't change for different subtargets so cache the result.
1507 proc check_effective_target_vect_double { } {
1508 global et_vect_double_saved
1510 if [info exists et_vect_double_saved] {
1511 verbose "check_effective_target_vect_double: using cached result" 2
1512 } else {
1513 set et_vect_double_saved 0
1514 if { [istarget i?86-*-*]
1515 || [istarget x86_64-*-*]
1516 || [istarget spu-*-*] } {
1517 set et_vect_double_saved 1
1521 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1522 return $et_vect_double_saved
1525 # Return 1 if the target plus current options does not support a vector
1526 # max instruction on "int", 0 otherwise.
1528 # This won't change for different subtargets so cache the result.
1530 proc check_effective_target_vect_no_int_max { } {
1531 global et_vect_no_int_max_saved
1533 if [info exists et_vect_no_int_max_saved] {
1534 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1535 } else {
1536 set et_vect_no_int_max_saved 0
1537 if { [istarget sparc*-*-*]
1538 || [istarget spu-*-*]
1539 || [istarget alpha*-*-*] } {
1540 set et_vect_no_int_max_saved 1
1543 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1544 return $et_vect_no_int_max_saved
1547 # Return 1 if the target plus current options does not support a vector
1548 # add instruction on "int", 0 otherwise.
1550 # This won't change for different subtargets so cache the result.
1552 proc check_effective_target_vect_no_int_add { } {
1553 global et_vect_no_int_add_saved
1555 if [info exists et_vect_no_int_add_saved] {
1556 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1557 } else {
1558 set et_vect_no_int_add_saved 0
1559 # Alpha only supports vector add on V8QI and V4HI.
1560 if { [istarget alpha*-*-*] } {
1561 set et_vect_no_int_add_saved 1
1564 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1565 return $et_vect_no_int_add_saved
1568 # Return 1 if the target plus current options does not support vector
1569 # bitwise instructions, 0 otherwise.
1571 # This won't change for different subtargets so cache the result.
1573 proc check_effective_target_vect_no_bitwise { } {
1574 global et_vect_no_bitwise_saved
1576 if [info exists et_vect_no_bitwise_saved] {
1577 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1578 } else {
1579 set et_vect_no_bitwise_saved 0
1581 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1582 return $et_vect_no_bitwise_saved
1585 # Return 1 if the target plus current options supports a vector
1586 # widening summation of *short* args into *int* result, 0 otherwise.
1587 # A target can also support this widening summation if it can support
1588 # promotion (unpacking) from shorts to ints.
1590 # This won't change for different subtargets so cache the result.
1592 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1593 global et_vect_widen_sum_hi_to_si
1595 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1596 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1597 } else {
1598 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1599 if { [istarget powerpc*-*-*]
1600 || [istarget ia64-*-*] } {
1601 set et_vect_widen_sum_hi_to_si_saved 1
1604 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1605 return $et_vect_widen_sum_hi_to_si_saved
1608 # Return 1 if the target plus current options supports a vector
1609 # widening summation of *char* args into *short* result, 0 otherwise.
1610 # A target can also support this widening summation if it can support
1611 # promotion (unpacking) from chars to shorts.
1613 # This won't change for different subtargets so cache the result.
1615 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1616 global et_vect_widen_sum_qi_to_hi
1618 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1619 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1620 } else {
1621 set et_vect_widen_sum_qi_to_hi_saved 0
1622 if { [check_effective_target_vect_unpack]
1623 || [istarget ia64-*-*] } {
1624 set et_vect_widen_sum_qi_to_hi_saved 1
1627 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1628 return $et_vect_widen_sum_qi_to_hi_saved
1631 # Return 1 if the target plus current options supports a vector
1632 # widening summation of *char* args into *int* result, 0 otherwise.
1634 # This won't change for different subtargets so cache the result.
1636 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1637 global et_vect_widen_sum_qi_to_si
1639 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1640 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1641 } else {
1642 set et_vect_widen_sum_qi_to_si_saved 0
1643 if { [istarget powerpc*-*-*] } {
1644 set et_vect_widen_sum_qi_to_si_saved 1
1647 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1648 return $et_vect_widen_sum_qi_to_si_saved
1651 # Return 1 if the target plus current options supports a vector
1652 # widening multiplication of *char* args into *short* result, 0 otherwise.
1653 # A target can also support this widening multplication if it can support
1654 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1655 # multiplication of shorts).
1657 # This won't change for different subtargets so cache the result.
1660 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1661 global et_vect_widen_mult_qi_to_hi
1663 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1664 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1665 } else {
1666 if { [check_effective_target_vect_unpack]
1667 && [check_effective_target_vect_short_mult] } {
1668 set et_vect_widen_mult_qi_to_hi_saved 1
1669 } else {
1670 set et_vect_widen_mult_qi_to_hi_saved 0
1672 if { [istarget powerpc*-*-*] } {
1673 set et_vect_widen_mult_qi_to_hi_saved 1
1676 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1677 return $et_vect_widen_mult_qi_to_hi_saved
1680 # Return 1 if the target plus current options supports a vector
1681 # widening multiplication of *short* args into *int* result, 0 otherwise.
1682 # A target can also support this widening multplication if it can support
1683 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1684 # multiplication of ints).
1686 # This won't change for different subtargets so cache the result.
1689 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1690 global et_vect_widen_mult_hi_to_si
1692 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1693 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1694 } else {
1695 if { [check_effective_target_vect_unpack]
1696 && [check_effective_target_vect_int_mult] } {
1697 set et_vect_widen_mult_hi_to_si_saved 1
1698 } else {
1699 set et_vect_widen_mult_hi_to_si_saved 0
1701 if { [istarget powerpc*-*-*]
1702 || [istarget spu-*-*]
1703 || [istarget i?86-*-*]
1704 || [istarget x86_64-*-*] } {
1705 set et_vect_widen_mult_hi_to_si_saved 1
1708 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1709 return $et_vect_widen_mult_hi_to_si_saved
1712 # Return 1 if the target plus current options supports a vector
1713 # dot-product of signed chars, 0 otherwise.
1715 # This won't change for different subtargets so cache the result.
1717 proc check_effective_target_vect_sdot_qi { } {
1718 global et_vect_sdot_qi
1720 if [info exists et_vect_sdot_qi_saved] {
1721 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1722 } else {
1723 set et_vect_sdot_qi_saved 0
1725 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1726 return $et_vect_sdot_qi_saved
1729 # Return 1 if the target plus current options supports a vector
1730 # dot-product of unsigned chars, 0 otherwise.
1732 # This won't change for different subtargets so cache the result.
1734 proc check_effective_target_vect_udot_qi { } {
1735 global et_vect_udot_qi
1737 if [info exists et_vect_udot_qi_saved] {
1738 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1739 } else {
1740 set et_vect_udot_qi_saved 0
1741 if { [istarget powerpc*-*-*] } {
1742 set et_vect_udot_qi_saved 1
1745 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1746 return $et_vect_udot_qi_saved
1749 # Return 1 if the target plus current options supports a vector
1750 # dot-product of signed shorts, 0 otherwise.
1752 # This won't change for different subtargets so cache the result.
1754 proc check_effective_target_vect_sdot_hi { } {
1755 global et_vect_sdot_hi
1757 if [info exists et_vect_sdot_hi_saved] {
1758 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1759 } else {
1760 set et_vect_sdot_hi_saved 0
1761 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1762 || [istarget i?86-*-*]
1763 || [istarget x86_64-*-*] } {
1764 set et_vect_sdot_hi_saved 1
1767 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1768 return $et_vect_sdot_hi_saved
1771 # Return 1 if the target plus current options supports a vector
1772 # dot-product of unsigned shorts, 0 otherwise.
1774 # This won't change for different subtargets so cache the result.
1776 proc check_effective_target_vect_udot_hi { } {
1777 global et_vect_udot_hi
1779 if [info exists et_vect_udot_hi_saved] {
1780 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1781 } else {
1782 set et_vect_udot_hi_saved 0
1783 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1784 set et_vect_udot_hi_saved 1
1787 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1788 return $et_vect_udot_hi_saved
1792 # Return 1 if the target plus current options supports a vector
1793 # demotion (packing) of shorts (to chars) and ints (to shorts)
1794 # using modulo arithmetic, 0 otherwise.
1796 # This won't change for different subtargets so cache the result.
1798 proc check_effective_target_vect_pack_trunc { } {
1799 global et_vect_pack_trunc
1801 if [info exists et_vect_pack_trunc_saved] {
1802 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1803 } else {
1804 set et_vect_pack_trunc_saved 0
1805 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1806 || [istarget i?86-*-*]
1807 || [istarget x86_64-*-*] } {
1808 set et_vect_pack_trunc_saved 1
1811 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1812 return $et_vect_pack_trunc_saved
1815 # Return 1 if the target plus current options supports a vector
1816 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1818 # This won't change for different subtargets so cache the result.
1820 proc check_effective_target_vect_unpack { } {
1821 global et_vect_unpack
1823 if [info exists et_vect_unpack_saved] {
1824 verbose "check_effective_target_vect_unpack: using cached result" 2
1825 } else {
1826 set et_vect_unpack_saved 0
1827 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1828 || [istarget i?86-*-*]
1829 || [istarget x86_64-*-*] } {
1830 set et_vect_unpack_saved 1
1833 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1834 return $et_vect_unpack_saved
1837 # Return 1 if the target plus current options does not guarantee
1838 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1840 # This won't change for different subtargets so cache the result.
1842 proc check_effective_target_unaligned_stack { } {
1843 global et_unaligned_stack_saved
1845 if [info exists et_unaligned_stack_saved] {
1846 verbose "check_effective_target_unaligned_stack: using cached result" 2
1847 } else {
1848 set et_unaligned_stack_saved 0
1849 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
1850 && (! [istarget *-*-darwin*] ) } {
1851 set et_unaligned_stack_saved 1
1854 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1855 return $et_unaligned_stack_saved
1858 # Return 1 if the target plus current options does not support a vector
1859 # alignment mechanism, 0 otherwise.
1861 # This won't change for different subtargets so cache the result.
1863 proc check_effective_target_vect_no_align { } {
1864 global et_vect_no_align_saved
1866 if [info exists et_vect_no_align_saved] {
1867 verbose "check_effective_target_vect_no_align: using cached result" 2
1868 } else {
1869 set et_vect_no_align_saved 0
1870 if { [istarget mipsisa64*-*-*]
1871 || [istarget sparc*-*-*]
1872 || [istarget ia64-*-*] } {
1873 set et_vect_no_align_saved 1
1876 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1877 return $et_vect_no_align_saved
1880 # Return 1 if arrays are aligned to the vector alignment
1881 # boundary, 0 otherwise.
1883 # This won't change for different subtargets so cache the result.
1885 proc check_effective_target_vect_aligned_arrays { } {
1886 global et_vect_aligned_arrays
1888 if [info exists et_vect_aligned_arrays_saved] {
1889 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1890 } else {
1891 set et_vect_aligned_arrays_saved 0
1892 if { (([istarget x86_64-*-*]
1893 || [istarget i?86-*-*]) && [is-effective-target lp64])
1894 || [istarget spu-*-*] } {
1895 set et_vect_aligned_arrays_saved 1
1898 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1899 return $et_vect_aligned_arrays_saved
1902 # Return 1 if types of size 32 bit or less are naturally aligned
1903 # (aligned to their type-size), 0 otherwise.
1905 # This won't change for different subtargets so cache the result.
1907 proc check_effective_target_natural_alignment_32 { } {
1908 global et_natural_alignment_32
1910 if [info exists et_natural_alignment_32_saved] {
1911 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1912 } else {
1913 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
1914 set et_natural_alignment_32_saved 1
1915 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
1916 set et_natural_alignment_32_saved 0
1919 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
1920 return $et_natural_alignment_32_saved
1923 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
1924 # type-size), 0 otherwise.
1926 # This won't change for different subtargets so cache the result.
1928 proc check_effective_target_natural_alignment_64 { } {
1929 global et_natural_alignment_64
1931 if [info exists et_natural_alignment_64_saved] {
1932 verbose "check_effective_target_natural_alignment_64: using cached result" 2
1933 } else {
1934 set et_natural_alignment_64_saved 0
1935 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
1936 || [istarget spu-*-*] } {
1937 set et_natural_alignment_64_saved 1
1940 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
1941 return $et_natural_alignment_64_saved
1944 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
1946 # This won't change for different subtargets so cache the result.
1948 proc check_effective_target_vector_alignment_reachable { } {
1949 global et_vector_alignment_reachable
1951 if [info exists et_vector_alignment_reachable_saved] {
1952 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
1953 } else {
1954 if { [check_effective_target_vect_aligned_arrays]
1955 || [check_effective_target_natural_alignment_32] } {
1956 set et_vector_alignment_reachable_saved 1
1957 } else {
1958 set et_vector_alignment_reachable_saved 0
1961 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
1962 return $et_vector_alignment_reachable_saved
1965 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
1967 # This won't change for different subtargets so cache the result.
1969 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
1970 global et_vector_alignment_reachable_for_64bit
1972 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
1973 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
1974 } else {
1975 if { [check_effective_target_vect_aligned_arrays]
1976 || [check_effective_target_natural_alignment_64] } {
1977 set et_vector_alignment_reachable_for_64bit_saved 1
1978 } else {
1979 set et_vector_alignment_reachable_for_64bit_saved 0
1982 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
1983 return $et_vector_alignment_reachable_for_64bit_saved
1986 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1988 proc check_effective_target_vect_condition { } {
1989 global et_vect_cond_saved
1991 if [info exists et_vect_cond_saved] {
1992 verbose "check_effective_target_vect_cond: using cached result" 2
1993 } else {
1994 set et_vect_cond_saved 0
1995 if { [istarget powerpc*-*-*]
1996 || [istarget ia64-*-*]
1997 || [istarget i?86-*-*]
1998 || [istarget spu-*-*]
1999 || [istarget x86_64-*-*] } {
2000 set et_vect_cond_saved 1
2004 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2005 return $et_vect_cond_saved
2008 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2010 proc check_effective_target_vect_char_mult { } {
2011 global et_vect_char_mult_saved
2013 if [info exists et_vect_char_mult_saved] {
2014 verbose "check_effective_target_vect_char_mult: using cached result" 2
2015 } else {
2016 set et_vect_char_mult_saved 0
2017 if { [istarget ia64-*-*]
2018 || [istarget i?86-*-*]
2019 || [istarget x86_64-*-*] } {
2020 set et_vect_char_mult_saved 1
2024 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2025 return $et_vect_char_mult_saved
2028 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2030 proc check_effective_target_vect_short_mult { } {
2031 global et_vect_short_mult_saved
2033 if [info exists et_vect_short_mult_saved] {
2034 verbose "check_effective_target_vect_short_mult: using cached result" 2
2035 } else {
2036 set et_vect_short_mult_saved 0
2037 if { [istarget ia64-*-*]
2038 || [istarget i?86-*-*]
2039 || [istarget x86_64-*-*] } {
2040 set et_vect_short_mult_saved 1
2044 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2045 return $et_vect_short_mult_saved
2048 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2050 proc check_effective_target_vect_int_mult { } {
2051 global et_vect_int_mult_saved
2053 if [info exists et_vect_int_mult_saved] {
2054 verbose "check_effective_target_vect_int_mult: using cached result" 2
2055 } else {
2056 set et_vect_int_mult_saved 0
2057 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2058 || [istarget spu-*-*]
2059 || [istarget i?86-*-*]
2060 || [istarget x86_64-*-*] } {
2061 set et_vect_int_mult_saved 1
2065 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2066 return $et_vect_int_mult_saved
2069 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2071 proc check_effective_target_vect_extract_even_odd { } {
2072 global et_vect_extract_even_odd_saved
2074 if [info exists et_vect_extract_even_odd_saved] {
2075 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2076 } else {
2077 set et_vect_extract_even_odd_saved 0
2078 if { [istarget powerpc*-*-*] } {
2079 set et_vect_extract_even_odd_saved 1
2083 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2084 return $et_vect_extract_even_odd_saved
2087 # Return 1 if the target supports vector interleaving, 0 otherwise.
2089 proc check_effective_target_vect_interleave { } {
2090 global et_vect_interleave_saved
2092 if [info exists et_vect_interleave_saved] {
2093 verbose "check_effective_target_vect_interleave: using cached result" 2
2094 } else {
2095 set et_vect_interleave_saved 0
2096 if { [istarget powerpc*-*-*]
2097 || [istarget i?86-*-*]
2098 || [istarget x86_64-*-*] } {
2099 set et_vect_interleave_saved 1
2103 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2104 return $et_vect_interleave_saved
2107 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2108 proc check_effective_target_vect_strided { } {
2109 global et_vect_strided_saved
2111 if [info exists et_vect_strided_saved] {
2112 verbose "check_effective_target_vect_strided: using cached result" 2
2113 } else {
2114 set et_vect_strided_saved 0
2115 if { [check_effective_target_vect_interleave]
2116 && [check_effective_target_vect_extract_even_odd] } {
2117 set et_vect_strided_saved 1
2121 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2122 return $et_vect_strided_saved
2125 # Return 1 if the target supports section-anchors
2127 proc check_effective_target_section_anchors { } {
2128 global et_section_anchors_saved
2130 if [info exists et_section_anchors_saved] {
2131 verbose "check_effective_target_section_anchors: using cached result" 2
2132 } else {
2133 set et_section_anchors_saved 0
2134 if { [istarget powerpc*-*-*] } {
2135 set et_section_anchors_saved 1
2139 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2140 return $et_section_anchors_saved
2143 # Return 1 if the target supports atomic operations on "int" and "long".
2145 proc check_effective_target_sync_int_long { } {
2146 global et_sync_int_long_saved
2148 if [info exists et_sync_int_long_saved] {
2149 verbose "check_effective_target_sync_int_long: using cached result" 2
2150 } else {
2151 set et_sync_int_long_saved 0
2152 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2153 # load-reserved/store-conditional instructions.
2154 if { [istarget ia64-*-*]
2155 || [istarget i?86-*-*]
2156 || [istarget x86_64-*-*]
2157 || [istarget alpha*-*-*]
2158 || [istarget s390*-*-*]
2159 || [istarget powerpc*-*-*]
2160 || [istarget sparc64-*-*]
2161 || [istarget sparcv9-*-*] } {
2162 set et_sync_int_long_saved 1
2166 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2167 return $et_sync_int_long_saved
2170 # Return 1 if the target supports atomic operations on "char" and "short".
2172 proc check_effective_target_sync_char_short { } {
2173 global et_sync_char_short_saved
2175 if [info exists et_sync_char_short_saved] {
2176 verbose "check_effective_target_sync_char_short: using cached result" 2
2177 } else {
2178 set et_sync_char_short_saved 0
2179 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2180 # load-reserved/store-conditional instructions.
2181 if { [istarget ia64-*-*]
2182 || [istarget i?86-*-*]
2183 || [istarget x86_64-*-*]
2184 || [istarget alpha*-*-*]
2185 || [istarget s390*-*-*]
2186 || [istarget powerpc*-*-*]
2187 || [istarget sparc64-*-*]
2188 || [istarget sparcv9-*-*] } {
2189 set et_sync_char_short_saved 1
2193 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2194 return $et_sync_char_short_saved
2197 # Return 1 if the target uses a ColdFire FPU.
2199 proc check_effective_target_coldfire_fpu { } {
2200 return [check_no_compiler_messages coldfire_fpu assembly {
2201 #ifndef __mcffpu__
2202 #error FOO
2203 #endif
2207 # Return true if this is a uClibc target.
2209 proc check_effective_target_uclibc {} {
2210 return [check_no_compiler_messages uclibc object {
2211 #include <features.h>
2212 #if !defined (__UCLIBC__)
2213 #error FOO
2214 #endif
2218 # Return true if this is a uclibc target and if the uclibc feature
2219 # described by __$feature__ is not present.
2221 proc check_missing_uclibc_feature {feature} {
2222 return [check_no_compiler_messages $feature object "
2223 #include <features.h>
2224 #if !defined (__UCLIBC) || defined (__${feature}__)
2225 #error FOO
2226 #endif
2230 # Return true if this is a Newlib target.
2232 proc check_effective_target_newlib {} {
2233 return [check_no_compiler_messages newlib object {
2234 #include <newlib.h>
2238 # Return 1 if
2239 # (a) an error of a few ULP is expected in string to floating-point
2240 # conversion functions; and
2241 # (b) overflow is not always detected correctly by those functions.
2243 proc check_effective_target_lax_strtofp {} {
2244 # By default, assume that all uClibc targets suffer from this.
2245 return [check_effective_target_uclibc]
2248 # Return 1 if this is a target for which wcsftime is a dummy
2249 # function that always returns 0.
2251 proc check_effective_target_dummy_wcsftime {} {
2252 # By default, assume that all uClibc targets suffer from this.
2253 return [check_effective_target_uclibc]
2256 # Return 1 if constructors with initialization priority arguments are
2257 # supposed on this target.
2259 proc check_effective_target_init_priority {} {
2260 return [check_no_compiler_messages init_priority assembly "
2261 void f() __attribute__((constructor (1000)));
2262 void f() \{\}
2266 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2267 # This can be used with any check_* proc that takes no argument and
2268 # returns only 1 or 0. It could be used with check_* procs that take
2269 # arguments with keywords that pass particular arguments.
2271 proc is-effective-target { arg } {
2272 set selected 0
2273 if { [info procs check_effective_target_${arg}] != [list] } {
2274 set selected [check_effective_target_${arg}]
2275 } else {
2276 switch $arg {
2277 "vmx_hw" { set selected [check_vmx_hw_available] }
2278 "named_sections" { set selected [check_named_sections_available] }
2279 "gc_sections" { set selected [check_gc_sections_available] }
2280 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2281 default { error "unknown effective target keyword `$arg'" }
2284 verbose "is-effective-target: $arg $selected" 2
2285 return $selected
2288 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2290 proc is-effective-target-keyword { arg } {
2291 if { [info procs check_effective_target_${arg}] != [list] } {
2292 return 1
2293 } else {
2294 # These have different names for their check_* procs.
2295 switch $arg {
2296 "vmx_hw" { return 1 }
2297 "named_sections" { return 1 }
2298 "gc_sections" { return 1 }
2299 "cxa_atexit" { return 1 }
2300 default { return 0 }
2305 # Return 1 if target default to short enums
2307 proc check_effective_target_short_enums { } {
2308 return [check_no_compiler_messages short_enums assembly {
2309 enum foo { bar };
2310 int s[sizeof (enum foo) == 1 ? 1 : -1];
2314 # Return 1 if target supports merging string constants at link time.
2316 proc check_effective_target_string_merging { } {
2317 return [check_no_messages_and_pattern string_merging \
2318 "rodata\\.str" assembly {
2319 const char *var = "String";
2320 } {-O2}]
2323 # Return 1 if target has the basic signed and unsigned types in
2324 # <stdint.h>, 0 otherwise.
2326 proc check_effective_target_stdint_types { } {
2327 return [check_no_compiler_messages stdint_types assembly {
2328 #include <stdint.h>
2329 int8_t a; int16_t b; int32_t c; int64_t d;
2330 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2334 # Return 1 if programs are intended to be run on a simulator
2335 # (i.e. slowly) rather than hardware (i.e. fast).
2337 proc check_effective_target_simulator { } {
2339 # All "src/sim" simulators set this one.
2340 if [board_info target exists is_simulator] {
2341 return [board_info target is_simulator]
2344 # The "sid" simulators don't set that one, but at least they set
2345 # this one.
2346 if [board_info target exists slow_simulator] {
2347 return [board_info target slow_simulator]
2350 return 0
2353 # Return 1 if the target is a VxWorks RTP.
2355 proc check_effective_target_vxworks_kernel { } {
2356 return [check_no_compiler_messages vxworks_kernel assembly {
2357 #if !defined __vxworks || defined __RTP__
2358 #error NO
2359 #endif
2363 # Return 1 if the target is expected to provide wide character support.
2365 proc check_effective_target_wchar { } {
2366 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2367 return 0
2369 return [check_no_compiler_messages wchar assembly {
2370 #include <wchar.h>
2374 # Return 1 if the target has <pthread.h>.
2376 proc check_effective_target_pthread_h { } {
2377 return [check_no_compiler_messages pthread_h assembly {
2378 #include <pthread.h>
2382 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2384 proc add_options_for_c99_runtime { flags } {
2385 if { [istarget *-*-solaris2*] } {
2386 return "$flags -std=c99"
2388 if { [istarget powerpc-*-darwin*] } {
2389 return "$flags -mmacosx-version-min=10.3"
2391 return $flags
2394 # Add to FLAGS the flags needed to enable functions to bind locally
2395 # when using pic/PIC passes in the testsuite.
2397 proc add_options_for_bind_pic_locally { flags } {
2398 if {[check_no_compiler_messages using_pic2 assembly {
2399 #if __PIC__ != 2
2400 #error FOO
2401 #endif
2402 }]} {
2403 return "$flags -fPIE"
2405 if {[check_no_compiler_messages using_pic1 assembly {
2406 #if __PIC__ != 1
2407 #error FOO
2408 #endif
2409 }]} {
2410 return "$flags -fpie"
2413 return $flags
2416 # Return 1 if the target provides a full C99 runtime.
2418 proc check_effective_target_c99_runtime { } {
2419 return [check_cached_effective_target c99_runtime {
2420 global srcdir
2422 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2423 set contents [read $file]
2424 close $file
2425 append contents {
2426 #ifndef HAVE_C99_RUNTIME
2427 #error FOO
2428 #endif
2430 check_no_compiler_messages_nocache c99_runtime assembly \
2431 $contents [add_options_for_c99_runtime ""]
2435 # Return 1 if current options generate DFP instructions, 0 otherwise.
2437 proc check_effective_target_hard_dfp {} {
2438 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
2439 _Decimal64 x, y, z;
2440 void foo (void) { z = x + y; }