Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob04717c6f099c72299c1e7a9d3ded53bbd5d89371
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 1 if according to target_info struct and explicit target list
387 # target is supposed to support trampolines.
389 proc check_effective_target_trampolines { } {
390 if [target_info exists no_trampolines] {
391 return 0
393 if { [istarget avr-*-*]
394 || [istarget hppa2.0w-hp-hpux11.23]
395 || [istarget hppa64-hp-hpux11.23] } {
396 return 0;
398 return 1
401 # Return true if profiling is supported on the target.
403 proc check_profiling_available { test_what } {
404 global profiling_available_saved
406 verbose "Profiling argument is <$test_what>" 1
408 # These conditions depend on the argument so examine them before
409 # looking at the cache variable.
411 # Support for -p on solaris2 relies on mcrt1.o which comes with the
412 # vendor compiler. We cannot reliably predict the directory where the
413 # vendor compiler (and thus mcrt1.o) is installed so we can't
414 # necessarily find mcrt1.o even if we have it.
415 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
416 return 0
419 # Support for -p on irix relies on libprof1.a which doesn't appear to
420 # exist on any irix6 system currently posting testsuite results.
421 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
422 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
423 if { [istarget mips*-*-irix*]
424 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
425 return 0
428 # MinGW does not support -p.
429 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
430 return 0
433 # At present, there is no profiling support on NetWare.
434 if { [istarget *-*-netware*] } {
435 return 0
438 # uClibc does not have gcrt1.o.
439 if { [check_effective_target_uclibc]
440 && ([lindex $test_what 1] == "-p"
441 || [lindex $test_what 1] == "-pg") } {
442 return 0
445 # Now examine the cache variable.
446 if {![info exists profiling_available_saved]} {
447 # Some targets don't have any implementation of __bb_init_func or are
448 # missing other needed machinery.
449 if { [istarget mmix-*-*]
450 || [istarget arm*-*-eabi*]
451 || [istarget arm*-*-elf]
452 || [istarget arm*-*-symbianelf*]
453 || [istarget avr-*-*]
454 || [istarget bfin-*-*]
455 || [istarget powerpc-*-eabi*]
456 || [istarget cris-*-*]
457 || [istarget crisv32-*-*]
458 || [istarget fido-*-elf]
459 || [istarget h8300-*-*]
460 || [istarget m32c-*-elf]
461 || [istarget m68k-*-elf]
462 || [istarget m68k-*-uclinux*]
463 || [istarget mips*-*-elf*]
464 || [istarget xstormy16-*]
465 || [istarget xtensa-*-elf]
466 || [istarget *-*-vxworks*] } {
467 set profiling_available_saved 0
468 } else {
469 set profiling_available_saved 1
473 return $profiling_available_saved
476 # Return 1 if target has packed layout of structure members by
477 # default, 0 otherwise. Note that this is slightly different than
478 # whether the target has "natural alignment": both attributes may be
479 # false.
481 proc check_effective_target_default_packed { } {
482 return [check_no_compiler_messages default_packed assembly {
483 struct x { char a; long b; } c;
484 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
488 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
489 # documentation, where the test also comes from.
491 proc check_effective_target_pcc_bitfield_type_matters { } {
492 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
493 # bitfields, but let's stick to the example code from the docs.
494 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
495 struct foo1 { char x; char :0; char y; };
496 struct foo2 { char x; int :0; char y; };
497 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
501 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
503 # This won't change for different subtargets so cache the result.
505 proc check_effective_target_tls {} {
506 return [check_no_compiler_messages tls assembly {
507 __thread int i;
508 int f (void) { return i; }
509 void g (int j) { i = j; }
513 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
515 # This won't change for different subtargets so cache the result.
517 proc check_effective_target_tls_native {} {
518 # VxWorks uses emulated TLS machinery, but with non-standard helper
519 # functions, so we fail to automatically detect it.
520 global target_triplet
521 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
522 return 0
525 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
526 __thread int i;
527 int f (void) { return i; }
528 void g (int j) { i = j; }
532 # Return 1 if TLS executables can run correctly, 0 otherwise.
534 # This won't change for different subtargets so cache the result.
536 proc check_effective_target_tls_runtime {} {
537 return [check_runtime tls_runtime {
538 __thread int thr = 0;
539 int main (void) { return thr; }
543 # Return 1 if compilation with -fopenmp is error-free for trivial
544 # code, 0 otherwise.
546 proc check_effective_target_fopenmp {} {
547 return [check_no_compiler_messages fopenmp object {
548 void foo (void) { }
549 } "-fopenmp"]
552 # Return 1 if compilation with -pthread is error-free for trivial
553 # code, 0 otherwise.
555 proc check_effective_target_pthread {} {
556 return [check_no_compiler_messages pthread object {
557 void foo (void) { }
558 } "-pthread"]
561 # Return 1 if the target supports -fstack-protector
562 proc check_effective_target_fstack_protector {} {
563 return [check_runtime fstack_protector {
564 int main (void) { return 0; }
565 } "-fstack-protector"]
568 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
569 # for trivial code, 0 otherwise.
571 proc check_effective_target_freorder {} {
572 return [check_no_compiler_messages freorder object {
573 void foo (void) { }
574 } "-freorder-blocks-and-partition"]
577 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
578 # emitted, 0 otherwise. Whether a shared library can actually be built is
579 # out of scope for this test.
581 proc check_effective_target_fpic { } {
582 # Note that M68K has a multilib that supports -fpic but not
583 # -fPIC, so we need to check both. We test with a program that
584 # requires GOT references.
585 foreach arg {fpic fPIC} {
586 if [check_no_compiler_messages $arg object {
587 extern int foo (void); extern int bar;
588 int baz (void) { return foo () + bar; }
589 } "-$arg"] {
590 return 1
593 return 0
596 # Return true if the target supports -mpaired-single (as used on MIPS).
598 proc check_effective_target_mpaired_single { } {
599 return [check_no_compiler_messages mpaired_single object {
600 void foo (void) { }
601 } "-mpaired-single"]
604 # Return true if the target has access to FPU instructions.
606 proc check_effective_target_hard_float { } {
607 if { [istarget mips*-*-*] } {
608 return [check_no_compiler_messages hard_float assembly {
609 #if (defined __mips_soft_float || defined __mips16)
610 #error FOO
611 #endif
615 # The generic test equates hard_float with "no call for adding doubles".
616 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
617 double a (double b, double c) { return b + c; }
621 # Return true if the target is a 64-bit MIPS target.
623 proc check_effective_target_mips64 { } {
624 return [check_no_compiler_messages mips64 assembly {
625 #ifndef __mips64
626 #error FOO
627 #endif
631 # Return true if the target is a MIPS target that does not produce
632 # MIPS16 code.
634 proc check_effective_target_nomips16 { } {
635 return [check_no_compiler_messages nomips16 object {
636 #ifndef __mips
637 #error FOO
638 #else
639 /* A cheap way of testing for -mflip-mips16. */
640 void foo (void) { asm ("addiu $20,$20,1"); }
641 void bar (void) { asm ("addiu $20,$20,1"); }
642 #endif
646 # Add the options needed for MIPS16 function attributes. At the moment,
647 # we don't support MIPS16 PIC.
649 proc add_options_for_mips16_attribute { flags } {
650 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
653 # Return true if we can force a mode that allows MIPS16 code generation.
654 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
655 # for o32 and o64.
657 proc check_effective_target_mips16_attribute { } {
658 return [check_no_compiler_messages mips16_attribute assembly {
659 #ifdef PIC
660 #error FOO
661 #endif
662 #if defined __mips_hard_float \
663 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
664 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
665 #error FOO
666 #endif
667 } [add_options_for_mips16_attribute ""]]
670 # Return 1 if the current multilib does not generate PIC by default.
672 proc check_effective_target_nonpic { } {
673 return [check_no_compiler_messages nonpic assembly {
674 #if __PIC__
675 #error FOO
676 #endif
680 # Return 1 if the target does not use a status wrapper.
682 proc check_effective_target_unwrapped { } {
683 if { [target_info needs_status_wrapper] != "" \
684 && [target_info needs_status_wrapper] != "0" } {
685 return 0
687 return 1
690 # Return true if iconv is supported on the target. In particular IBM1047.
692 proc check_iconv_available { test_what } {
693 global libiconv
695 # If the tool configuration file has not set libiconv, try "-liconv"
696 if { ![info exists libiconv] } {
697 set libiconv "-liconv"
699 set test_what [lindex $test_what 1]
700 return [check_runtime_nocache $test_what [subst {
701 #include <iconv.h>
702 int main (void)
704 iconv_t cd;
706 cd = iconv_open ("$test_what", "UTF-8");
707 if (cd == (iconv_t) -1)
708 return 1;
709 return 0;
711 }] $libiconv]
714 # Return true if named sections are supported on this target.
716 proc check_named_sections_available { } {
717 return [check_no_compiler_messages named_sections assembly {
718 int __attribute__ ((section("whatever"))) foo;
722 # Return 1 if the target supports Fortran real kinds larger than real(8),
723 # 0 otherwise.
725 # When the target name changes, replace the cached result.
727 proc check_effective_target_fortran_large_real { } {
728 return [check_no_compiler_messages fortran_large_real executable {
729 ! Fortran
730 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
731 real(kind=k) :: x
732 x = cos (x)
737 # Return 1 if the target supports Fortran integer kinds larger than
738 # integer(8), 0 otherwise.
740 # When the target name changes, replace the cached result.
742 proc check_effective_target_fortran_large_int { } {
743 return [check_no_compiler_messages fortran_large_int executable {
744 ! Fortran
745 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
746 integer(kind=k) :: i
751 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
753 # When the target name changes, replace the cached result.
755 proc check_effective_target_fortran_integer_16 { } {
756 return [check_no_compiler_messages fortran_integer_16 executable {
757 ! Fortran
758 integer(16) :: i
763 # Return 1 if we can statically link libgfortran, 0 otherwise.
765 # When the target name changes, replace the cached result.
767 proc check_effective_target_static_libgfortran { } {
768 return [check_no_compiler_messages static_libgfortran executable {
769 ! Fortran
770 print *, 'test'
772 } "-static"]
775 # Return 1 if the target supports executing 750CL paired-single instructions, 0
776 # otherwise. Cache the result.
778 proc check_750cl_hw_available { } {
779 return [check_cached_effective_target 750cl_hw_available {
780 # If this is not the right target then we can skip the test.
781 if { ![istarget powerpc-*paired*] } {
782 expr 0
783 } else {
784 check_runtime_nocache 750cl_hw_available {
785 int main()
787 #ifdef __MACH__
788 asm volatile ("ps_mul v0,v0,v0");
789 #else
790 asm volatile ("ps_mul 0,0,0");
791 #endif
792 return 0;
794 } "-mpaired"
799 # Return 1 if the target supports executing SSE2 instructions, 0
800 # otherwise. Cache the result.
802 proc check_sse2_hw_available { } {
803 return [check_cached_effective_target sse2_hw_available {
804 # If this is not the right target then we can skip the test.
805 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
806 expr 0
807 } else {
808 check_runtime_nocache sse2_hw_available {
809 #include "cpuid.h"
810 int main ()
812 unsigned int eax, ebx, ecx, edx = 0;
813 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
814 return !(edx & bit_SSE2);
815 return 1;
817 } ""
822 # Return 1 if the target supports executing AltiVec instructions, 0
823 # otherwise. Cache the result.
825 proc check_vmx_hw_available { } {
826 return [check_cached_effective_target vmx_hw_available {
827 # Some simulators are known to not support VMX instructions.
828 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
829 expr 0
830 } else {
831 # Most targets don't require special flags for this test case, but
832 # Darwin does.
833 if { [istarget *-*-darwin*]
834 || [istarget *-*-aix*] } {
835 set options "-maltivec"
836 } else {
837 set options ""
839 check_runtime_nocache vmx_hw_available {
840 int main()
842 #ifdef __MACH__
843 asm volatile ("vor v0,v0,v0");
844 #else
845 asm volatile ("vor 0,0,0");
846 #endif
847 return 0;
849 } $options
854 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
855 # complex float arguments. This affects gfortran tests that call cabsf
856 # in libm built by an earlier compiler. Return 1 if libm uses the same
857 # argument passing as the compiler under test, 0 otherwise.
859 # When the target name changes, replace the cached result.
861 proc check_effective_target_broken_cplxf_arg { } {
862 return [check_cached_effective_target broken_cplxf_arg {
863 # Skip the work for targets known not to be affected.
864 if { ![istarget powerpc64-*-linux*] } {
865 expr 0
866 } elseif { ![is-effective-target lp64] } {
867 expr 0
868 } else {
869 check_runtime_nocache broken_cplxf_arg {
870 #include <complex.h>
871 extern void abort (void);
872 float fabsf (float);
873 float cabsf (_Complex float);
874 int main ()
876 _Complex float cf;
877 float f;
878 cf = 3 + 4.0fi;
879 f = cabsf (cf);
880 if (fabsf (f - 5.0) > 0.0001)
881 abort ();
882 return 0;
884 } "-lm"
889 proc check_alpha_max_hw_available { } {
890 return [check_runtime alpha_max_hw_available {
891 int main() { return __builtin_alpha_amask(1<<8) != 0; }
895 # Returns true iff the FUNCTION is available on the target system.
896 # (This is essentially a Tcl implementation of Autoconf's
897 # AC_CHECK_FUNC.)
899 proc check_function_available { function } {
900 return [check_no_compiler_messages ${function}_available \
901 executable [subst {
902 #ifdef __cplusplus
903 extern "C"
904 #endif
905 char $function ();
906 int main () { $function (); }
910 # Returns true iff "fork" is available on the target system.
912 proc check_fork_available {} {
913 return [check_function_available "fork"]
916 # Returns true iff "mkfifo" is available on the target system.
918 proc check_mkfifo_available {} {
919 if {[istarget *-*-cygwin*]} {
920 # Cygwin has mkfifo, but support is incomplete.
921 return 0
924 return [check_function_available "mkfifo"]
927 # Returns true iff "__cxa_atexit" is used on the target system.
929 proc check_cxa_atexit_available { } {
930 return [check_cached_effective_target cxa_atexit_available {
931 if { [istarget "hppa*-*-hpux10*"] } {
932 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
933 expr 0
934 } else {
935 check_runtime_nocache cxa_atexit_available {
936 // C++
937 #include <stdlib.h>
938 static unsigned int count;
939 struct X
941 X() { count = 1; }
942 ~X()
944 if (count != 3)
945 exit(1);
946 count = 4;
949 void f()
951 static X x;
953 struct Y
955 Y() { f(); count = 2; }
956 ~Y()
958 if (count != 2)
959 exit(1);
960 count = 3;
963 Y y;
964 int main() { return 0; }
971 # Return 1 if we're generating 32-bit code using default options, 0
972 # otherwise.
974 proc check_effective_target_ilp32 { } {
975 return [check_no_compiler_messages ilp32 object {
976 int dummy[sizeof (int) == 4
977 && sizeof (void *) == 4
978 && sizeof (long) == 4 ? 1 : -1];
982 # Return 1 if we're generating 32-bit or larger integers using default
983 # options, 0 otherwise.
985 proc check_effective_target_int32plus { } {
986 return [check_no_compiler_messages int32plus object {
987 int dummy[sizeof (int) >= 4 ? 1 : -1];
991 # Return 1 if we're generating 32-bit or larger pointers using default
992 # options, 0 otherwise.
994 proc check_effective_target_ptr32plus { } {
995 return [check_no_compiler_messages ptr32plus object {
996 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1000 # Return 1 if we support 32-bit or larger array and structure sizes
1001 # using default options, 0 otherwise.
1003 proc check_effective_target_size32plus { } {
1004 return [check_no_compiler_messages size32plus object {
1005 char dummy[65537];
1009 # Returns 1 if we're generating 16-bit or smaller integers with the
1010 # default options, 0 otherwise.
1012 proc check_effective_target_int16 { } {
1013 return [check_no_compiler_messages int16 object {
1014 int dummy[sizeof (int) < 4 ? 1 : -1];
1018 # Return 1 if we're generating 64-bit code using default options, 0
1019 # otherwise.
1021 proc check_effective_target_lp64 { } {
1022 return [check_no_compiler_messages lp64 object {
1023 int dummy[sizeof (int) == 4
1024 && sizeof (void *) == 8
1025 && sizeof (long) == 8 ? 1 : -1];
1029 # Return 1 if the target supports long double larger than double,
1030 # 0 otherwise.
1032 proc check_effective_target_large_long_double { } {
1033 return [check_no_compiler_messages large_long_double object {
1034 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1038 # Return 1 if the target supports compiling fixed-point,
1039 # 0 otherwise.
1041 proc check_effective_target_fixed_point { } {
1042 return [check_no_compiler_messages fixed_point object {
1043 _Sat _Fract x; _Sat _Accum y;
1047 # Return 1 if the target supports compiling decimal floating point,
1048 # 0 otherwise.
1050 proc check_effective_target_dfp_nocache { } {
1051 verbose "check_effective_target_dfp_nocache: compiling source" 2
1052 set ret [check_no_compiler_messages_nocache dfp object {
1053 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1055 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1056 return $ret
1059 proc check_effective_target_dfprt_nocache { } {
1060 return [check_runtime_nocache dfprt {
1061 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1062 int main () { z = x + y; return 0; }
1066 # Return 1 if the target supports compiling Decimal Floating Point,
1067 # 0 otherwise.
1069 # This won't change for different subtargets so cache the result.
1071 proc check_effective_target_dfp { } {
1072 return [check_cached_effective_target dfp {
1073 check_effective_target_dfp_nocache
1077 # Return 1 if the target supports linking and executing Decimal Floating
1078 # Point, # 0 otherwise.
1080 # This won't change for different subtargets so cache the result.
1082 proc check_effective_target_dfprt { } {
1083 return [check_cached_effective_target dfprt {
1084 check_effective_target_dfprt_nocache
1088 # Return 1 if the target needs a command line argument to enable a SIMD
1089 # instruction set.
1091 proc check_effective_target_vect_cmdline_needed { } {
1092 global et_vect_cmdline_needed_saved
1093 global et_vect_cmdline_needed_target_name
1095 if { ![info exists et_vect_cmdline_needed_target_name] } {
1096 set et_vect_cmdline_needed_target_name ""
1099 # If the target has changed since we set the cached value, clear it.
1100 set current_target [current_target_name]
1101 if { $current_target != $et_vect_cmdline_needed_target_name } {
1102 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1103 set et_vect_cmdline_needed_target_name $current_target
1104 if { [info exists et_vect_cmdline_needed_saved] } {
1105 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1106 unset et_vect_cmdline_needed_saved
1110 if [info exists et_vect_cmdline_needed_saved] {
1111 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1112 } else {
1113 set et_vect_cmdline_needed_saved 1
1114 if { [istarget ia64-*-*]
1115 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1116 && [check_effective_target_lp64])
1117 || ([istarget powerpc*-*-*]
1118 && ([check_effective_target_powerpc_spe]
1119 || [check_effective_target_powerpc_altivec]))} {
1120 set et_vect_cmdline_needed_saved 0
1124 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1125 return $et_vect_cmdline_needed_saved
1128 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1130 # This won't change for different subtargets so cache the result.
1132 proc check_effective_target_vect_int { } {
1133 global et_vect_int_saved
1135 if [info exists et_vect_int_saved] {
1136 verbose "check_effective_target_vect_int: using cached result" 2
1137 } else {
1138 set et_vect_int_saved 0
1139 if { [istarget i?86-*-*]
1140 || ([istarget powerpc*-*-*]
1141 && ![istarget powerpc-*-linux*paired*])
1142 || [istarget spu-*-*]
1143 || [istarget x86_64-*-*]
1144 || [istarget sparc*-*-*]
1145 || [istarget alpha*-*-*]
1146 || [istarget ia64-*-*] } {
1147 set et_vect_int_saved 1
1151 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1152 return $et_vect_int_saved
1155 # Return 1 if the target supports int->float conversion
1158 proc check_effective_target_vect_intfloat_cvt { } {
1159 global et_vect_intfloat_cvt_saved
1161 if [info exists et_vect_intfloat_cvt_saved] {
1162 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1163 } else {
1164 set et_vect_intfloat_cvt_saved 0
1165 if { [istarget i?86-*-*]
1166 || ([istarget powerpc*-*-*]
1167 && ![istarget powerpc-*-linux*paired*])
1168 || [istarget x86_64-*-*] } {
1169 set et_vect_intfloat_cvt_saved 1
1173 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1174 return $et_vect_intfloat_cvt_saved
1178 # Return 1 if the target supports float->int conversion
1181 proc check_effective_target_vect_floatint_cvt { } {
1182 global et_vect_floatint_cvt_saved
1184 if [info exists et_vect_floatint_cvt_saved] {
1185 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1186 } else {
1187 set et_vect_floatint_cvt_saved 0
1188 if { [istarget i?86-*-*]
1189 || [istarget x86_64-*-*] } {
1190 set et_vect_floatint_cvt_saved 1
1194 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1195 return $et_vect_floatint_cvt_saved
1198 # Return 1 is this is an arm target using 32-bit instructions
1199 proc check_effective_target_arm32 { } {
1200 return [check_no_compiler_messages arm32 assembly {
1201 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1202 #error FOO
1203 #endif
1207 # Return 1 if this is an ARM target supporting -mfpu=vfp
1208 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1209 # options.
1211 proc check_effective_target_arm_vfp_ok { } {
1212 if { [check_effective_target_arm32] } {
1213 return [check_no_compiler_messages arm_vfp_ok object {
1214 int dummy;
1215 } "-mfpu=vfp -mfloat-abi=softfp"]
1216 } else {
1217 return 0
1221 # Return 1 if this is an ARM target supporting -mfpu=neon
1222 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1223 # options.
1225 proc check_effective_target_arm_neon_ok { } {
1226 if { [check_effective_target_arm32] } {
1227 return [check_no_compiler_messages arm_neon_ok object {
1228 int dummy;
1229 } "-mfpu=neon -mfloat-abi=softfp"]
1230 } else {
1231 return 0
1235 # Return 1 if the target supports executing NEON instructions, 0
1236 # otherwise. Cache the result.
1238 proc check_effective_target_arm_neon_hw { } {
1239 return [check_runtime arm_neon_hw_available {
1241 main (void)
1243 long long a = 0, b = 1;
1244 asm ("vorr %P0, %P1, %P2"
1245 : "=w" (a)
1246 : "0" (a), "w" (b));
1247 return (a != 1);
1249 } "-mfpu=neon -mfloat-abi=softfp"]
1252 # Return 1 if this is a PowerPC target with floating-point registers.
1254 proc check_effective_target_powerpc_fprs { } {
1255 if { [istarget powerpc*-*-*]
1256 || [istarget rs6000-*-*] } {
1257 return [check_no_compiler_messages powerpc_fprs object {
1258 #ifdef __NO_FPRS__
1259 #error no FPRs
1260 #else
1261 int dummy;
1262 #endif
1264 } else {
1265 return 0
1269 # Return 1 if this is a PowerPC target supporting -maltivec.
1271 proc check_effective_target_powerpc_altivec_ok { } {
1272 if { ([istarget powerpc*-*-*]
1273 && ![istarget powerpc-*-linux*paired*])
1274 || [istarget rs6000-*-*] } {
1275 # AltiVec is not supported on AIX before 5.3.
1276 if { [istarget powerpc*-*-aix4*]
1277 || [istarget powerpc*-*-aix5.1*]
1278 || [istarget powerpc*-*-aix5.2*] } {
1279 return 0
1281 return [check_no_compiler_messages powerpc_altivec_ok object {
1282 int dummy;
1283 } "-maltivec"]
1284 } else {
1285 return 0
1289 # Return 1 if this is a PowerPC target that supports SPU.
1291 proc check_effective_target_powerpc_spu { } {
1292 if [istarget powerpc*-*-linux*] {
1293 return [check_effective_target_powerpc_altivec_ok]
1294 } else {
1295 return 0
1299 # Return 1 if this is a PowerPC target with SPE enabled.
1301 proc check_effective_target_powerpc_spe { } {
1302 if { [istarget powerpc*-*-*] } {
1303 return [check_no_compiler_messages powerpc_spe object {
1304 #ifndef __SPE__
1305 #error not SPE
1306 #else
1307 int dummy;
1308 #endif
1310 } else {
1311 return 0
1315 # Return 1 if this is a PowerPC target with Altivec enabled.
1317 proc check_effective_target_powerpc_altivec { } {
1318 if { [istarget powerpc*-*-*] } {
1319 return [check_no_compiler_messages powerpc_altivec object {
1320 #ifndef __ALTIVEC__
1321 #error not Altivec
1322 #else
1323 int dummy;
1324 #endif
1326 } else {
1327 return 0
1331 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1332 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1333 # test environment appears to run executables on such a simulator.
1335 proc check_effective_target_ultrasparc_hw { } {
1336 return [check_runtime ultrasparc_hw {
1337 int main() { return 0; }
1338 } "-mcpu=ultrasparc"]
1341 # Return 1 if the target supports hardware vector shift operation.
1343 proc check_effective_target_vect_shift { } {
1344 global et_vect_shift_saved
1346 if [info exists et_vect_shift_saved] {
1347 verbose "check_effective_target_vect_shift: using cached result" 2
1348 } else {
1349 set et_vect_shift_saved 0
1350 if { ([istarget powerpc*-*-*]
1351 && ![istarget powerpc-*-linux*paired*])
1352 || [istarget ia64-*-*]
1353 || [istarget i?86-*-*]
1354 || [istarget x86_64-*-*] } {
1355 set et_vect_shift_saved 1
1359 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1360 return $et_vect_shift_saved
1363 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1365 # This can change for different subtargets so do not cache the result.
1367 proc check_effective_target_vect_long { } {
1368 if { [istarget i?86-*-*]
1369 || (([istarget powerpc*-*-*]
1370 && ![istarget powerpc-*-linux*paired*])
1371 && [check_effective_target_ilp32])
1372 || [istarget x86_64-*-*]
1373 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1374 set answer 1
1375 } else {
1376 set answer 0
1379 verbose "check_effective_target_vect_long: returning $answer" 2
1380 return $answer
1383 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1385 # This won't change for different subtargets so cache the result.
1387 proc check_effective_target_vect_float { } {
1388 global et_vect_float_saved
1390 if [info exists et_vect_float_saved] {
1391 verbose "check_effective_target_vect_float: using cached result" 2
1392 } else {
1393 set et_vect_float_saved 0
1394 if { [istarget i?86-*-*]
1395 || [istarget powerpc*-*-*]
1396 || [istarget spu-*-*]
1397 || [istarget mipsisa64*-*-*]
1398 || [istarget x86_64-*-*]
1399 || [istarget ia64-*-*] } {
1400 set et_vect_float_saved 1
1404 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1405 return $et_vect_float_saved
1408 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1410 # This won't change for different subtargets so cache the result.
1412 proc check_effective_target_vect_double { } {
1413 global et_vect_double_saved
1415 if [info exists et_vect_double_saved] {
1416 verbose "check_effective_target_vect_double: using cached result" 2
1417 } else {
1418 set et_vect_double_saved 0
1419 if { [istarget i?86-*-*]
1420 || [istarget x86_64-*-*]
1421 || [istarget spu-*-*] } {
1422 set et_vect_double_saved 1
1426 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1427 return $et_vect_double_saved
1430 # Return 1 if the target plus current options does not support a vector
1431 # max instruction on "int", 0 otherwise.
1433 # This won't change for different subtargets so cache the result.
1435 proc check_effective_target_vect_no_int_max { } {
1436 global et_vect_no_int_max_saved
1438 if [info exists et_vect_no_int_max_saved] {
1439 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1440 } else {
1441 set et_vect_no_int_max_saved 0
1442 if { [istarget sparc*-*-*]
1443 || [istarget spu-*-*]
1444 || [istarget alpha*-*-*] } {
1445 set et_vect_no_int_max_saved 1
1448 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1449 return $et_vect_no_int_max_saved
1452 # Return 1 if the target plus current options does not support a vector
1453 # add instruction on "int", 0 otherwise.
1455 # This won't change for different subtargets so cache the result.
1457 proc check_effective_target_vect_no_int_add { } {
1458 global et_vect_no_int_add_saved
1460 if [info exists et_vect_no_int_add_saved] {
1461 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1462 } else {
1463 set et_vect_no_int_add_saved 0
1464 # Alpha only supports vector add on V8QI and V4HI.
1465 if { [istarget alpha*-*-*] } {
1466 set et_vect_no_int_add_saved 1
1469 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1470 return $et_vect_no_int_add_saved
1473 # Return 1 if the target plus current options does not support vector
1474 # bitwise instructions, 0 otherwise.
1476 # This won't change for different subtargets so cache the result.
1478 proc check_effective_target_vect_no_bitwise { } {
1479 global et_vect_no_bitwise_saved
1481 if [info exists et_vect_no_bitwise_saved] {
1482 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1483 } else {
1484 set et_vect_no_bitwise_saved 0
1486 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1487 return $et_vect_no_bitwise_saved
1490 # Return 1 if the target plus current options supports a vector
1491 # widening summation of *short* args into *int* result, 0 otherwise.
1492 # A target can also support this widening summation if it can support
1493 # promotion (unpacking) from shorts to ints.
1495 # This won't change for different subtargets so cache the result.
1497 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1498 global et_vect_widen_sum_hi_to_si
1500 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1501 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1502 } else {
1503 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1504 if { [istarget powerpc*-*-*]
1505 || [istarget ia64-*-*] } {
1506 set et_vect_widen_sum_hi_to_si_saved 1
1509 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1510 return $et_vect_widen_sum_hi_to_si_saved
1513 # Return 1 if the target plus current options supports a vector
1514 # widening summation of *char* args into *short* result, 0 otherwise.
1515 # A target can also support this widening summation if it can support
1516 # promotion (unpacking) from chars to shorts.
1518 # This won't change for different subtargets so cache the result.
1520 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1521 global et_vect_widen_sum_qi_to_hi
1523 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1524 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1525 } else {
1526 set et_vect_widen_sum_qi_to_hi_saved 0
1527 if { [check_effective_target_vect_unpack]
1528 || [istarget ia64-*-*] } {
1529 set et_vect_widen_sum_qi_to_hi_saved 1
1532 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1533 return $et_vect_widen_sum_qi_to_hi_saved
1536 # Return 1 if the target plus current options supports a vector
1537 # widening summation of *char* args into *int* result, 0 otherwise.
1539 # This won't change for different subtargets so cache the result.
1541 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1542 global et_vect_widen_sum_qi_to_si
1544 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1545 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1546 } else {
1547 set et_vect_widen_sum_qi_to_si_saved 0
1548 if { [istarget powerpc*-*-*] } {
1549 set et_vect_widen_sum_qi_to_si_saved 1
1552 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1553 return $et_vect_widen_sum_qi_to_si_saved
1556 # Return 1 if the target plus current options supports a vector
1557 # widening multiplication of *char* args into *short* result, 0 otherwise.
1558 # A target can also support this widening multplication if it can support
1559 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1560 # multiplication of shorts).
1562 # This won't change for different subtargets so cache the result.
1565 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1566 global et_vect_widen_mult_qi_to_hi
1568 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1569 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1570 } else {
1571 if { [check_effective_target_vect_unpack]
1572 && [check_effective_target_vect_short_mult] } {
1573 set et_vect_widen_mult_qi_to_hi_saved 1
1574 } else {
1575 set et_vect_widen_mult_qi_to_hi_saved 0
1577 if { [istarget powerpc*-*-*] } {
1578 set et_vect_widen_mult_qi_to_hi_saved 1
1581 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1582 return $et_vect_widen_mult_qi_to_hi_saved
1585 # Return 1 if the target plus current options supports a vector
1586 # widening multiplication of *short* args into *int* result, 0 otherwise.
1587 # A target can also support this widening multplication if it can support
1588 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1589 # multiplication of ints).
1591 # This won't change for different subtargets so cache the result.
1594 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1595 global et_vect_widen_mult_hi_to_si
1597 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1598 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1599 } else {
1600 if { [check_effective_target_vect_unpack]
1601 && [check_effective_target_vect_int_mult] } {
1602 set et_vect_widen_mult_hi_to_si_saved 1
1603 } else {
1604 set et_vect_widen_mult_hi_to_si_saved 0
1606 if { [istarget powerpc*-*-*]
1607 || [istarget spu-*-*]
1608 || [istarget i?86-*-*]
1609 || [istarget x86_64-*-*] } {
1610 set et_vect_widen_mult_hi_to_si_saved 1
1613 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1614 return $et_vect_widen_mult_hi_to_si_saved
1617 # Return 1 if the target plus current options supports a vector
1618 # dot-product of signed chars, 0 otherwise.
1620 # This won't change for different subtargets so cache the result.
1622 proc check_effective_target_vect_sdot_qi { } {
1623 global et_vect_sdot_qi
1625 if [info exists et_vect_sdot_qi_saved] {
1626 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1627 } else {
1628 set et_vect_sdot_qi_saved 0
1630 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1631 return $et_vect_sdot_qi_saved
1634 # Return 1 if the target plus current options supports a vector
1635 # dot-product of unsigned chars, 0 otherwise.
1637 # This won't change for different subtargets so cache the result.
1639 proc check_effective_target_vect_udot_qi { } {
1640 global et_vect_udot_qi
1642 if [info exists et_vect_udot_qi_saved] {
1643 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1644 } else {
1645 set et_vect_udot_qi_saved 0
1646 if { [istarget powerpc*-*-*] } {
1647 set et_vect_udot_qi_saved 1
1650 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1651 return $et_vect_udot_qi_saved
1654 # Return 1 if the target plus current options supports a vector
1655 # dot-product of signed shorts, 0 otherwise.
1657 # This won't change for different subtargets so cache the result.
1659 proc check_effective_target_vect_sdot_hi { } {
1660 global et_vect_sdot_hi
1662 if [info exists et_vect_sdot_hi_saved] {
1663 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1664 } else {
1665 set et_vect_sdot_hi_saved 0
1666 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1667 || [istarget i?86-*-*]
1668 || [istarget x86_64-*-*] } {
1669 set et_vect_sdot_hi_saved 1
1672 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1673 return $et_vect_sdot_hi_saved
1676 # Return 1 if the target plus current options supports a vector
1677 # dot-product of unsigned shorts, 0 otherwise.
1679 # This won't change for different subtargets so cache the result.
1681 proc check_effective_target_vect_udot_hi { } {
1682 global et_vect_udot_hi
1684 if [info exists et_vect_udot_hi_saved] {
1685 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1686 } else {
1687 set et_vect_udot_hi_saved 0
1688 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1689 set et_vect_udot_hi_saved 1
1692 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1693 return $et_vect_udot_hi_saved
1697 # Return 1 if the target plus current options supports a vector
1698 # demotion (packing) of shorts (to chars) and ints (to shorts)
1699 # using modulo arithmetic, 0 otherwise.
1701 # This won't change for different subtargets so cache the result.
1703 proc check_effective_target_vect_pack_trunc { } {
1704 global et_vect_pack_trunc
1706 if [info exists et_vect_pack_trunc_saved] {
1707 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1708 } else {
1709 set et_vect_pack_trunc_saved 0
1710 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1711 || [istarget i?86-*-*]
1712 || [istarget x86_64-*-*] } {
1713 set et_vect_pack_trunc_saved 1
1716 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1717 return $et_vect_pack_trunc_saved
1720 # Return 1 if the target plus current options supports a vector
1721 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1723 # This won't change for different subtargets so cache the result.
1725 proc check_effective_target_vect_unpack { } {
1726 global et_vect_unpack
1728 if [info exists et_vect_unpack_saved] {
1729 verbose "check_effective_target_vect_unpack: using cached result" 2
1730 } else {
1731 set et_vect_unpack_saved 0
1732 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1733 || [istarget i?86-*-*]
1734 || [istarget x86_64-*-*]
1735 || [istarget spu-*-*] } {
1736 set et_vect_unpack_saved 1
1739 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1740 return $et_vect_unpack_saved
1743 # Return 1 if the target plus current options does not guarantee
1744 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1746 # This won't change for different subtargets so cache the result.
1748 proc check_effective_target_unaligned_stack { } {
1749 global et_unaligned_stack_saved
1751 if [info exists et_unaligned_stack_saved] {
1752 verbose "check_effective_target_unaligned_stack: using cached result" 2
1753 } else {
1754 set et_unaligned_stack_saved 0
1755 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
1756 && (! [istarget *-*-darwin*] ) } {
1757 set et_unaligned_stack_saved 1
1760 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1761 return $et_unaligned_stack_saved
1764 # Return 1 if the target plus current options does not support a vector
1765 # alignment mechanism, 0 otherwise.
1767 # This won't change for different subtargets so cache the result.
1769 proc check_effective_target_vect_no_align { } {
1770 global et_vect_no_align_saved
1772 if [info exists et_vect_no_align_saved] {
1773 verbose "check_effective_target_vect_no_align: using cached result" 2
1774 } else {
1775 set et_vect_no_align_saved 0
1776 if { [istarget mipsisa64*-*-*]
1777 || [istarget sparc*-*-*]
1778 || [istarget ia64-*-*] } {
1779 set et_vect_no_align_saved 1
1782 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1783 return $et_vect_no_align_saved
1786 # Return 1 if arrays are aligned to the vector alignment
1787 # boundary, 0 otherwise.
1789 # This won't change for different subtargets so cache the result.
1791 proc check_effective_target_vect_aligned_arrays { } {
1792 global et_vect_aligned_arrays
1794 if [info exists et_vect_aligned_arrays_saved] {
1795 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1796 } else {
1797 set et_vect_aligned_arrays_saved 0
1798 if { (([istarget x86_64-*-*]
1799 || [istarget i?86-*-*]) && [is-effective-target lp64])
1800 || [istarget spu-*-*] } {
1801 set et_vect_aligned_arrays_saved 1
1804 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1805 return $et_vect_aligned_arrays_saved
1808 # Return 1 if types of size 32 bit or less are naturally aligned
1809 # (aligned to their type-size), 0 otherwise.
1811 # This won't change for different subtargets so cache the result.
1813 proc check_effective_target_natural_alignment_32 { } {
1814 global et_natural_alignment_32
1816 if [info exists et_natural_alignment_32_saved] {
1817 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1818 } else {
1819 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
1820 set et_natural_alignment_32_saved 1
1821 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
1822 set et_natural_alignment_32_saved 0
1825 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
1826 return $et_natural_alignment_32_saved
1829 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
1830 # type-size), 0 otherwise.
1832 # This won't change for different subtargets so cache the result.
1834 proc check_effective_target_natural_alignment_64 { } {
1835 global et_natural_alignment_64
1837 if [info exists et_natural_alignment_64_saved] {
1838 verbose "check_effective_target_natural_alignment_64: using cached result" 2
1839 } else {
1840 set et_natural_alignment_64_saved 0
1841 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
1842 || [istarget spu-*-*] } {
1843 set et_natural_alignment_64_saved 1
1846 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
1847 return $et_natural_alignment_64_saved
1850 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
1852 # This won't change for different subtargets so cache the result.
1854 proc check_effective_target_vector_alignment_reachable { } {
1855 global et_vector_alignment_reachable
1857 if [info exists et_vector_alignment_reachable_saved] {
1858 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
1859 } else {
1860 if { [check_effective_target_vect_aligned_arrays]
1861 || [check_effective_target_natural_alignment_32] } {
1862 set et_vector_alignment_reachable_saved 1
1863 } else {
1864 set et_vector_alignment_reachable_saved 0
1867 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
1868 return $et_vector_alignment_reachable_saved
1871 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
1873 # This won't change for different subtargets so cache the result.
1875 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
1876 global et_vector_alignment_reachable_for_64bit
1878 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
1879 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
1880 } else {
1881 if { [check_effective_target_vect_aligned_arrays]
1882 || [check_effective_target_natural_alignment_64] } {
1883 set et_vector_alignment_reachable_for_64bit_saved 1
1884 } else {
1885 set et_vector_alignment_reachable_for_64bit_saved 0
1888 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
1889 return $et_vector_alignment_reachable_for_64bit_saved
1892 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1894 proc check_effective_target_vect_condition { } {
1895 global et_vect_cond_saved
1897 if [info exists et_vect_cond_saved] {
1898 verbose "check_effective_target_vect_cond: using cached result" 2
1899 } else {
1900 set et_vect_cond_saved 0
1901 if { [istarget powerpc*-*-*]
1902 || [istarget ia64-*-*]
1903 || [istarget i?86-*-*]
1904 || [istarget spu-*-*]
1905 || [istarget x86_64-*-*] } {
1906 set et_vect_cond_saved 1
1910 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1911 return $et_vect_cond_saved
1914 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1916 proc check_effective_target_vect_char_mult { } {
1917 global et_vect_char_mult_saved
1919 if [info exists et_vect_char_mult_saved] {
1920 verbose "check_effective_target_vect_char_mult: using cached result" 2
1921 } else {
1922 set et_vect_char_mult_saved 0
1923 if { [istarget ia64-*-*]
1924 || [istarget i?86-*-*]
1925 || [istarget x86_64-*-*] } {
1926 set et_vect_char_mult_saved 1
1930 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1931 return $et_vect_char_mult_saved
1934 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1936 proc check_effective_target_vect_short_mult { } {
1937 global et_vect_short_mult_saved
1939 if [info exists et_vect_short_mult_saved] {
1940 verbose "check_effective_target_vect_short_mult: using cached result" 2
1941 } else {
1942 set et_vect_short_mult_saved 0
1943 if { [istarget ia64-*-*]
1944 || [istarget spu-*-*]
1945 || [istarget i?86-*-*]
1946 || [istarget x86_64-*-*] } {
1947 set et_vect_short_mult_saved 1
1951 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1952 return $et_vect_short_mult_saved
1955 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1957 proc check_effective_target_vect_int_mult { } {
1958 global et_vect_int_mult_saved
1960 if [info exists et_vect_int_mult_saved] {
1961 verbose "check_effective_target_vect_int_mult: using cached result" 2
1962 } else {
1963 set et_vect_int_mult_saved 0
1964 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1965 || [istarget spu-*-*]
1966 || [istarget i?86-*-*]
1967 || [istarget x86_64-*-*] } {
1968 set et_vect_int_mult_saved 1
1972 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1973 return $et_vect_int_mult_saved
1976 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1978 proc check_effective_target_vect_extract_even_odd { } {
1979 global et_vect_extract_even_odd_saved
1981 if [info exists et_vect_extract_even_odd_saved] {
1982 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1983 } else {
1984 set et_vect_extract_even_odd_saved 0
1985 if { [istarget powerpc*-*-*] } {
1986 set et_vect_extract_even_odd_saved 1
1990 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1991 return $et_vect_extract_even_odd_saved
1994 # Return 1 if the target supports vector interleaving, 0 otherwise.
1996 proc check_effective_target_vect_interleave { } {
1997 global et_vect_interleave_saved
1999 if [info exists et_vect_interleave_saved] {
2000 verbose "check_effective_target_vect_interleave: using cached result" 2
2001 } else {
2002 set et_vect_interleave_saved 0
2003 if { [istarget powerpc*-*-*]
2004 || [istarget i?86-*-*]
2005 || [istarget x86_64-*-*] } {
2006 set et_vect_interleave_saved 1
2010 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2011 return $et_vect_interleave_saved
2014 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2015 proc check_effective_target_vect_strided { } {
2016 global et_vect_strided_saved
2018 if [info exists et_vect_strided_saved] {
2019 verbose "check_effective_target_vect_strided: using cached result" 2
2020 } else {
2021 set et_vect_strided_saved 0
2022 if { [check_effective_target_vect_interleave]
2023 && [check_effective_target_vect_extract_even_odd] } {
2024 set et_vect_strided_saved 1
2028 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2029 return $et_vect_strided_saved
2032 # Return 1 if the target supports section-anchors
2034 proc check_effective_target_section_anchors { } {
2035 global et_section_anchors_saved
2037 if [info exists et_section_anchors_saved] {
2038 verbose "check_effective_target_section_anchors: using cached result" 2
2039 } else {
2040 set et_section_anchors_saved 0
2041 if { [istarget powerpc*-*-*] } {
2042 set et_section_anchors_saved 1
2046 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2047 return $et_section_anchors_saved
2050 # Return 1 if the target supports atomic operations on "int" and "long".
2052 proc check_effective_target_sync_int_long { } {
2053 global et_sync_int_long_saved
2055 if [info exists et_sync_int_long_saved] {
2056 verbose "check_effective_target_sync_int_long: using cached result" 2
2057 } else {
2058 set et_sync_int_long_saved 0
2059 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2060 # load-reserved/store-conditional instructions.
2061 if { [istarget ia64-*-*]
2062 || [istarget i?86-*-*]
2063 || [istarget x86_64-*-*]
2064 || [istarget alpha*-*-*]
2065 || [istarget s390*-*-*]
2066 || [istarget powerpc*-*-*]
2067 || [istarget sparc64-*-*]
2068 || [istarget sparcv9-*-*]
2069 || [istarget mips*-*-*] } {
2070 set et_sync_int_long_saved 1
2074 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2075 return $et_sync_int_long_saved
2078 # Return 1 if the target supports atomic operations on "char" and "short".
2080 proc check_effective_target_sync_char_short { } {
2081 global et_sync_char_short_saved
2083 if [info exists et_sync_char_short_saved] {
2084 verbose "check_effective_target_sync_char_short: using cached result" 2
2085 } else {
2086 set et_sync_char_short_saved 0
2087 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2088 # load-reserved/store-conditional instructions.
2089 if { [istarget ia64-*-*]
2090 || [istarget i?86-*-*]
2091 || [istarget x86_64-*-*]
2092 || [istarget alpha*-*-*]
2093 || [istarget s390*-*-*]
2094 || [istarget powerpc*-*-*]
2095 || [istarget sparc64-*-*]
2096 || [istarget sparcv9-*-*]
2097 || [istarget mips*-*-*] } {
2098 set et_sync_char_short_saved 1
2102 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2103 return $et_sync_char_short_saved
2106 # Return 1 if the target uses a ColdFire FPU.
2108 proc check_effective_target_coldfire_fpu { } {
2109 return [check_no_compiler_messages coldfire_fpu assembly {
2110 #ifndef __mcffpu__
2111 #error FOO
2112 #endif
2116 # Return true if this is a uClibc target.
2118 proc check_effective_target_uclibc {} {
2119 return [check_no_compiler_messages uclibc object {
2120 #include <features.h>
2121 #if !defined (__UCLIBC__)
2122 #error FOO
2123 #endif
2127 # Return true if this is a uclibc target and if the uclibc feature
2128 # described by __$feature__ is not present.
2130 proc check_missing_uclibc_feature {feature} {
2131 return [check_no_compiler_messages $feature object "
2132 #include <features.h>
2133 #if !defined (__UCLIBC) || defined (__${feature}__)
2134 #error FOO
2135 #endif
2139 # Return true if this is a Newlib target.
2141 proc check_effective_target_newlib {} {
2142 return [check_no_compiler_messages newlib object {
2143 #include <newlib.h>
2147 # Return 1 if
2148 # (a) an error of a few ULP is expected in string to floating-point
2149 # conversion functions; and
2150 # (b) overflow is not always detected correctly by those functions.
2152 proc check_effective_target_lax_strtofp {} {
2153 # By default, assume that all uClibc targets suffer from this.
2154 return [check_effective_target_uclibc]
2157 # Return 1 if this is a target for which wcsftime is a dummy
2158 # function that always returns 0.
2160 proc check_effective_target_dummy_wcsftime {} {
2161 # By default, assume that all uClibc targets suffer from this.
2162 return [check_effective_target_uclibc]
2165 # Return 1 if constructors with initialization priority arguments are
2166 # supposed on this target.
2168 proc check_effective_target_init_priority {} {
2169 return [check_no_compiler_messages init_priority assembly "
2170 void f() __attribute__((constructor (1000)));
2171 void f() \{\}
2175 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2176 # This can be used with any check_* proc that takes no argument and
2177 # returns only 1 or 0. It could be used with check_* procs that take
2178 # arguments with keywords that pass particular arguments.
2180 proc is-effective-target { arg } {
2181 set selected 0
2182 if { [info procs check_effective_target_${arg}] != [list] } {
2183 set selected [check_effective_target_${arg}]
2184 } else {
2185 switch $arg {
2186 "vmx_hw" { set selected [check_vmx_hw_available] }
2187 "named_sections" { set selected [check_named_sections_available] }
2188 "gc_sections" { set selected [check_gc_sections_available] }
2189 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2190 default { error "unknown effective target keyword `$arg'" }
2193 verbose "is-effective-target: $arg $selected" 2
2194 return $selected
2197 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2199 proc is-effective-target-keyword { arg } {
2200 if { [info procs check_effective_target_${arg}] != [list] } {
2201 return 1
2202 } else {
2203 # These have different names for their check_* procs.
2204 switch $arg {
2205 "vmx_hw" { return 1 }
2206 "named_sections" { return 1 }
2207 "gc_sections" { return 1 }
2208 "cxa_atexit" { return 1 }
2209 default { return 0 }
2214 # Return 1 if target default to short enums
2216 proc check_effective_target_short_enums { } {
2217 return [check_no_compiler_messages short_enums assembly {
2218 enum foo { bar };
2219 int s[sizeof (enum foo) == 1 ? 1 : -1];
2223 # Return 1 if target supports merging string constants at link time.
2225 proc check_effective_target_string_merging { } {
2226 return [check_no_messages_and_pattern string_merging \
2227 "rodata\\.str" assembly {
2228 const char *var = "String";
2229 } {-O2}]
2232 # Return 1 if target has the basic signed and unsigned types in
2233 # <stdint.h>, 0 otherwise.
2235 proc check_effective_target_stdint_types { } {
2236 return [check_no_compiler_messages stdint_types assembly {
2237 #include <stdint.h>
2238 int8_t a; int16_t b; int32_t c; int64_t d;
2239 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2243 # Return 1 if programs are intended to be run on a simulator
2244 # (i.e. slowly) rather than hardware (i.e. fast).
2246 proc check_effective_target_simulator { } {
2248 # All "src/sim" simulators set this one.
2249 if [board_info target exists is_simulator] {
2250 return [board_info target is_simulator]
2253 # The "sid" simulators don't set that one, but at least they set
2254 # this one.
2255 if [board_info target exists slow_simulator] {
2256 return [board_info target slow_simulator]
2259 return 0
2262 # Return 1 if the target is a VxWorks kernel.
2264 proc check_effective_target_vxworks_kernel { } {
2265 return [check_no_compiler_messages vxworks_kernel assembly {
2266 #if !defined __vxworks || defined __RTP__
2267 #error NO
2268 #endif
2272 # Return 1 if the target is a VxWorks RTP.
2274 proc check_effective_target_vxworks_rtp { } {
2275 return [check_no_compiler_messages vxworks_rtp assembly {
2276 #if !defined __vxworks || !defined __RTP__
2277 #error NO
2278 #endif
2282 # Return 1 if the target is expected to provide wide character support.
2284 proc check_effective_target_wchar { } {
2285 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2286 return 0
2288 return [check_no_compiler_messages wchar assembly {
2289 #include <wchar.h>
2293 # Return 1 if the target has <pthread.h>.
2295 proc check_effective_target_pthread_h { } {
2296 return [check_no_compiler_messages pthread_h assembly {
2297 #include <pthread.h>
2301 # Return 1 if the target can truncate a file from a file-descriptor,
2302 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2303 # chsize. We test for a trivially functional truncation; no stubs.
2304 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2305 # different function to be used.
2307 proc check_effective_target_fd_truncate { } {
2308 set prog {
2309 #define _FILE_OFFSET_BITS 64
2310 #include <unistd.h>
2311 #include <stdio.h>
2312 #include <stdlib.h>
2313 int main ()
2315 FILE *f = fopen ("tst.tmp", "wb");
2316 int fd;
2317 const char t[] = "test writing more than ten characters";
2318 char s[11];
2319 fd = fileno (f);
2320 write (fd, t, sizeof (t) - 1);
2321 lseek (fd, 0, 0);
2322 if (ftruncate (fd, 10) != 0)
2323 exit (1);
2324 close (fd);
2325 f = fopen ("tst.tmp", "rb");
2326 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2327 exit (1);
2328 exit (0);
2332 if { [check_runtime ftruncate $prog] } {
2333 return 1;
2336 regsub "ftruncate" $prog "chsize" prog
2337 return [check_runtime chsize $prog]
2340 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2342 proc add_options_for_c99_runtime { flags } {
2343 if { [istarget *-*-solaris2*] } {
2344 return "$flags -std=c99"
2346 if { [istarget powerpc-*-darwin*] } {
2347 return "$flags -mmacosx-version-min=10.3"
2349 return $flags
2352 # Return 1 if the target provides a full C99 runtime.
2354 proc check_effective_target_c99_runtime { } {
2355 return [check_cached_effective_target c99_runtime {
2356 global srcdir
2358 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2359 set contents [read $file]
2360 close $file
2361 append contents {
2362 #ifndef HAVE_C99_RUNTIME
2363 #error FOO
2364 #endif
2366 check_no_compiler_messages_nocache c99_runtime assembly \
2367 $contents [add_options_for_c99_runtime ""]
2371 # Return 1 if target wchar_t is at least 4 bytes.
2373 proc check_effective_target_4byte_wchar_t { } {
2374 return [check_no_compiler_messages 4byte_wchar_t object {
2375 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];