OSDN Git Service

* lib/target-supports.exp (check_effective_target_unwrapped): New.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / target-supports.exp
1 #   Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
2 #   Free Software Foundation, Inc.
3
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 2 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
20
21 # This file defines procs for determining features supported by the target.
22
23 # Try to compile some code and return the messages printed by the compiler,
24 # and optionally the contents for assembly files.  Either a string or
25 # a list of two strings are returned, depending on WANT_OUTPUT.
26 #
27 # BASENAME is a basename to use for temporary files.
28 # WANT_OUTPUT is a flag which is 0 to request returning just the
29 #   compiler messages, or 1 to return the messages and the contents
30 #   of the assembly file.  TYPE should be "assembly" if WANT_OUTPUT
31 #   is set.
32 # TYPE is the type of compilation to perform (see target_compile).
33 # CONTENTS gives the contents of the input file.
34 # The rest is optional:
35 # OPTIONS: additional compiler options to use.
36 proc get_compiler_messages {basename want_output type contents args} {
37     global tool
38
39     if { [llength $args] > 0 } {
40         set options [list "additional_flags=[lindex $args 0]"]
41     } else {
42         set options ""
43     }
44
45     set src ${basename}[pid].c
46     switch $type {
47         assembly { set output ${basename}[pid].s }
48         object { set output ${basename}[pid].o }
49     }
50     set f [open $src "w"]
51     puts $f $contents
52     close $f
53     set lines [${tool}_target_compile $src $output $type "$options"]
54     file delete $src
55
56     if { $want_output } {
57         if { $type != "assembly" } {
58             error "WANT_OUTPUT can only be used with assembly output"
59         } elseif { ![string match "" $lines] } {
60             # An error occurred.
61             set result [list $lines ""]
62         } else {
63             set text ""
64             set chan [open "$output"]
65             while {[gets $chan line] >= 0} {
66                 append text "$line\n"
67             }
68             close $chan
69             set result [list $lines $text]
70         }
71     } else {
72         set result $lines
73     }
74
75     remote_file build delete $output
76     return $result
77 }
78
79 proc current_target_name { } {
80     global target_info
81     if [info exists target_info(target,name)] {
82         set answer $target_info(target,name)
83     } else {
84         set answer ""
85     }
86     return $answer
87 }
88
89 # Implement an effective-target check for property PROP by invoking
90 # the compiler and seeing if it prints any messages.  Assume that the
91 # property holds if the compiler doesn't print anything.  The other
92 # arguments are as for get_compiler_messages, starting with TYPE.
93 proc check_no_compiler_messages {prop args} {
94     global et_cache
95
96     set target [current_target_name]
97     if {![info exists et_cache($prop,target)]
98         || $et_cache($prop,target) != $target} {
99         verbose "check_no_compiler_messages $prop: compiling source for $target" 2
100         set et_cache($prop,target) $target
101         set et_cache($prop,value) \
102             [string match "" [eval get_compiler_messages $prop 0 $args]]
103     }
104     set value $et_cache($prop,value)
105     verbose "check_no_compiler_messages $prop: returning $value for $target" 2
106     return $value
107 }
108
109 # Similar to check_no_compiler_messages, but also verify that the regular
110 # expression PATTERN matches the compiler's output.
111 proc check_no_messages_and_pattern {prop pattern args} {
112     global et_cache
113
114     set target [current_target_name]
115     if {![info exists et_cache($prop,target)]
116         || $et_cache($prop,target) != $target} {
117         verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
118         set et_cache($prop,target) $target
119         set results [eval get_compiler_messages $prop 1 $args]
120         set et_cache($prop,value) \
121             [expr [string match "" [lindex $results 0]] \
122                  && [regexp $pattern [lindex $results 1]]]
123     }
124     set value $et_cache($prop,value)
125     verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
126     return $value
127 }
128
129 ###############################
130 # proc check_weak_available { }
131 ###############################
132
133 # weak symbols are only supported in some configs/object formats
134 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
135
136 proc check_weak_available { } {
137     global target_triplet
138     global target_cpu
139
140     # All mips targets should support it
141
142     if { [ string first "mips" $target_cpu ] >= 0 } {
143         return 1
144     }
145
146     # All solaris2 targets should support it
147
148     if { [regexp ".*-solaris2.*" $target_triplet] } {
149         return 1
150     }
151
152     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
153
154     if { [regexp "alpha.*osf.*" $target_triplet] } {
155         return 1
156     }
157
158     # Windows targets Cygwin and MingW32 support it
159
160     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
161         return 1
162     }
163
164     # HP-UX 10.X doesn't support it
165
166     if { [istarget "hppa*-*-hpux10*"] } {
167         return 0
168     }
169
170     # ELF and ECOFF support it. a.out does with gas/gld but may also with
171     # other linkers, so we should try it
172
173     set objformat [gcc_target_object_format]
174
175     switch $objformat {
176         elf      { return 1 }
177         ecoff    { return 1 }
178         a.out    { return 1 }
179         mach-o   { return 1 }
180         som      { return 1 }
181         unknown  { return -1 }
182         default  { return 0 }
183     }
184 }
185
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
189
190 # The visibility attribute is only support in some object formats
191 # This proc returns 1 if it is supported, 0 if not.
192 # The argument is the kind of visibility, default/protected/hidden/internal.
193
194 proc check_visibility_available { what_kind } {
195     global tool
196     global target_triplet
197
198     # On NetWare, support makes no sense.
199     if { [istarget *-*-netware*] } {
200         return 0
201     }
202
203     if [string match "" $what_kind] { set what_kind "hidden" }
204
205     return [check_no_compiler_messages visibility_available_$what_kind object "
206         void f() __attribute__((visibility(\"$what_kind\")));
207         void f() {}
208     "]
209 }
210
211 ###############################
212 # proc check_alias_available { }
213 ###############################
214
215 # Determine if the target toolchain supports the alias attribute.
216
217 # Returns 2 if the target supports aliases.  Returns 1 if the target
218 # only supports weak aliased.  Returns 0 if the target does not
219 # support aliases at all.  Returns -1 if support for aliases could not
220 # be determined.
221
222 proc check_alias_available { } {
223     global alias_available_saved
224     global tool
225
226     if [info exists alias_available_saved] {
227         verbose "check_alias_available  returning saved $alias_available_saved" 2
228     } else {
229         set src alias[pid].c
230         set obj alias[pid].o
231         verbose "check_alias_available  compiling testfile $src" 2
232         set f [open $src "w"]
233         # Compile a small test program.  The definition of "g" is
234         # necessary to keep the Solaris assembler from complaining
235         # about the program.
236         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
238         close $f
239         set lines [${tool}_target_compile $src $obj object ""]
240         file delete $src
241         remote_file build delete $obj
242
243         if [string match "" $lines] then {
244             # No error messages, everything is OK.
245             set alias_available_saved 2
246         } else {
247             if [regexp "alias definitions not supported" $lines] {
248                 verbose "check_alias_available  target does not support aliases" 2
249
250                 set objformat [gcc_target_object_format]
251
252                 if { $objformat == "elf" } {
253                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
254                     set alias_available_saved -1
255                 } else {
256                     set alias_available_saved 0
257                 }
258             } else {
259                 if [regexp "only weak aliases are supported" $lines] {
260                 verbose "check_alias_available  target supports only weak aliases" 2
261                 set alias_available_saved 1
262                 } else {
263                     set alias_available_saved -1
264                 }
265             }
266         }
267
268         verbose "check_alias_available  returning $alias_available_saved" 2
269     }
270
271     return $alias_available_saved
272 }
273
274 # Returns true if --gc-sections is supported on the target.
275
276 proc check_gc_sections_available { } {
277     global gc_sections_available_saved
278     global tool
279
280     if {![info exists gc_sections_available_saved]} {
281         # Some targets don't support gc-sections despite whatever's
282         # advertised by ld's options.
283         if { [istarget alpha*-*-*]
284              || [istarget ia64-*-*] } {
285             set gc_sections_available_saved 0
286             return 0
287         }
288
289         # Check if the ld used by gcc supports --gc-sections.
290         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
291         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
292         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
293         set ld_output [remote_exec host "$gcc_ld" "--help"]
294         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
295             set gc_sections_available_saved 1
296         } else {
297             set gc_sections_available_saved 0
298         }
299     }
300     return $gc_sections_available_saved
301 }
302
303 # Return true if profiling is supported on the target.
304
305 proc check_profiling_available { test_what } {
306     global profiling_available_saved
307
308     verbose "Profiling argument is <$test_what>" 1
309
310     # These conditions depend on the argument so examine them before
311     # looking at the cache variable.
312
313     # Support for -p on solaris2 relies on mcrt1.o which comes with the
314     # vendor compiler.  We cannot reliably predict the directory where the
315     # vendor compiler (and thus mcrt1.o) is installed so we can't
316     # necessarily find mcrt1.o even if we have it.
317     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
318         return 0
319     }
320
321     # Support for -p on irix relies on libprof1.a which doesn't appear to
322     # exist on any irix6 system currently posting testsuite results.
323     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
324     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
325     if { [istarget mips*-*-irix*]
326     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
327         return 0
328     }
329
330     # At present, there is no profiling support on NetWare.
331     if { [istarget *-*-netware*] } {
332         return 0
333     }
334
335     # Now examine the cache variable.
336     if {![info exists profiling_available_saved]} {
337         # Some targets don't have any implementation of __bb_init_func or are
338         # missing other needed machinery.
339         if { [istarget mmix-*-*]
340              || [istarget arm*-*-eabi*]
341              || [istarget arm*-*-elf]
342              || [istarget arm*-*-symbianelf*]
343              || [istarget powerpc-*-eabi*]
344              || [istarget strongarm*-*-elf]
345              || [istarget xscale*-*-elf]
346              || [istarget cris-*-*]
347              || [istarget h8300-*-*]
348              || [istarget m32c-*-elf]
349              || [istarget m68k-*-elf]
350              || [istarget mips*-*-elf]
351              || [istarget xtensa-*-elf]
352              || [istarget *-*-windiss] } {
353             set profiling_available_saved 0
354         } else {
355             set profiling_available_saved 1
356         }
357     }
358
359     return $profiling_available_saved
360 }
361
362 # Return 1 if target has packed layout of structure members by
363 # default, 0 otherwise.  Note that this is slightly different than
364 # whether the target has "natural alignment": both attributes may be
365 # false.
366
367 proc check_effective_target_default_packed { } {
368     return [check_no_compiler_messages default_packed assembly {
369         struct x { char a; long b; } c;
370         int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
371     }]
372 }
373
374 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
375 # documentation, where the test also comes from.
376
377 proc check_effective_target_pcc_bitfield_type_matters { } {
378     # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
379     # bitfields, but let's stick to the example code from the docs.
380     return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
381         struct foo1 { char x; char :0; char y; };
382         struct foo2 { char x; int :0; char y; };
383         int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
384     }]
385 }
386
387 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
388 #
389 # This won't change for different subtargets so cache the result.
390
391 proc check_effective_target_tls {} {
392     global et_tls_saved
393     global tool
394
395     if [info exists et_tls_saved] {
396         verbose "check_effective_target_tls: using cached result" 2
397     } else {
398         set et_tls_saved 1
399
400         set src tls[pid].c
401         set asm tls[pid].S
402         verbose "check_effective_target_tls: compiling testfile $src" 2
403         set f [open $src "w"]
404         # Compile a small test program.
405         puts $f "__thread int i;\n"
406         close $f
407
408         # Test for thread-local data supported by the platform.
409         set comp_output [${tool}_target_compile $src $asm assembly ""]
410         file delete $src
411         if { [string match "*not supported*" $comp_output] } {
412             set et_tls_saved 0
413         } else {
414             set fd [open $asm r]
415             set text [read $fd]
416             close $fd
417             if { [string match "*emutls*" $text]} {
418                 set et_tls_saved 0
419             } else {
420                 set et_tls_saved 1
421             }
422         }
423         remove-build-file $asm
424     }
425     verbose "check_effective_target_tls: returning $et_tls_saved" 2
426     return $et_tls_saved
427 }
428
429 # Return 1 if TLS executables can run correctly, 0 otherwise.
430 #
431 # This won't change for different subtargets so cache the result.
432
433 proc check_effective_target_tls_runtime {} {
434     global et_tls_runtime_saved
435     global tool
436
437     if [info exists et_tls_runtime_saved] {
438         verbose "check_effective_target_tls_runtime: using cached result" 2
439     } else {
440         set et_tls_runtime_saved 0
441
442         set src tls_runtime[pid].c
443         set exe tls_runtime[pid].x
444         verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
445         set f [open $src "w"]
446         # Compile a small test program.
447         puts $f "__thread int thr = 0;\n"
448         puts $f "int main(void)\n {\n return thr;\n}"
449         close $f
450
451         set comp_output \
452             [${tool}_target_compile $src $exe executable ""]
453         file delete $src
454
455         if [string match "" $comp_output] then {
456             # No error messages, everything is OK.
457
458             set result [remote_load target "./$exe" "" ""]
459             set status [lindex $result 0]
460             remote_file build delete $exe
461
462             verbose "check_effective_target_tls_runtime status is <$status>" 2
463
464             if { $status == "pass" } {
465                 set et_tls_runtime_saved 1
466             }
467
468             verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
469         }
470     }
471
472     return $et_tls_runtime_saved
473 }
474
475 # Return 1 if compilation with -fopenmp is error-free for trivial
476 # code, 0 otherwise.
477
478 proc check_effective_target_fopenmp {} {
479     return [check_no_compiler_messages fopenmp object {
480         void foo (void) { }
481     } "-fopenmp"]
482 }
483
484 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
485 # for trivial code, 0 otherwise.
486
487 proc check_effective_target_freorder {} {
488     return [check_no_compiler_messages freorder object {
489         void foo (void) { }
490     } "-freorder-blocks-and-partition"]
491 }
492
493 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
494 # emitted, 0 otherwise.  Whether a shared library can actually be built is
495 # out of scope for this test.
496
497 proc check_effective_target_fpic { } {
498     # Note that M68K has a multilib that supports -fpic but not
499     # -fPIC, so we need to check both.  We test with a program that
500     # requires GOT references.
501     foreach arg {fpic fPIC} {
502         if [check_no_compiler_messages $arg object {
503             extern int foo (void); extern int bar;
504             int baz (void) { return foo () + bar; }
505         } "-$arg"] {
506             return 1
507         }
508     }
509     return 0
510 }
511
512 # Return true if the target supports -mpaired-single (as used on MIPS).
513
514 proc check_effective_target_mpaired_single { } {
515     return [check_no_compiler_messages mpaired_single object {
516         void foo (void) { }
517     } "-mpaired-single"]
518 }
519
520 # Return 1 if the target does not use a status wrapper.
521
522 proc check_effective_target_unwrapped { } {
523     if { [target_info needs_status_wrapper] != "" \
524              && [target_info needs_status_wrapper] != "0" } {
525         return 0
526     }
527     return 1
528 }
529
530 # Return true if iconv is supported on the target. In particular IBM1047.
531
532 proc check_iconv_available { test_what } {
533     global tool
534     global libiconv
535
536     set result ""
537
538     set src iconv[pid].c
539     set exe iconv[pid].x
540     verbose "check_iconv_available compiling testfile $src" 2
541     set f [open $src "w"]
542     # Compile a small test program.
543     puts $f "#include <iconv.h>\n"
544     puts $f "int main (void)\n {\n iconv_t cd; \n"
545     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
546     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
547     puts $f "return 0;\n}"
548     close $f
549
550     # If the tool configuration file has not set libiconv, try "-liconv"
551     if { ![info exists libiconv] } {
552         set libiconv "-liconv"
553     }
554     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
555     file delete $src
556
557     if [string match "" $lines] then {
558         # No error messages, everything is OK.
559
560         set result [${tool}_load "./$exe" "" ""]
561         set status [lindex $result 0]
562         remote_file build delete $exe
563
564         verbose "check_iconv_available status is <$status>" 2
565
566         if { $status == "pass" } then {
567             return 1
568         }
569     }
570
571     return 0
572 }
573
574 # Return true if named sections are supported on this target.
575
576 proc check_named_sections_available { } {
577     return [check_no_compiler_messages named_sections assembly {
578         int __attribute__ ((section("whatever"))) foo;
579     }]
580 }
581
582 # Return 1 if the target supports Fortran real kinds larger than real(8),
583 # 0 otherwise.
584 #
585 # When the target name changes, replace the cached result.
586
587 proc check_effective_target_fortran_large_real { } {
588     global et_fortran_large_real_saved
589     global et_fortran_large_real_target_name
590     global tool
591
592     if { ![info exists et_fortran_large_real_target_name] } {
593         set et_fortran_large_real_target_name ""
594     }
595
596     # If the target has changed since we set the cached value, clear it.
597     set current_target [current_target_name]
598     if { $current_target != $et_fortran_large_real_target_name } {
599         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
600         set et_fortran_large_real_target_name $current_target
601         if [info exists et_fortran_large_real_saved] {
602             verbose "check_effective_target_fortran_large_real: removing cached result" 2
603             unset et_fortran_large_real_saved
604         }
605     }
606
607     if [info exists et_fortran_large_real_saved] {
608         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
609     } else {
610         set et_fortran_large_real_saved 0
611
612         # Set up, compile, and execute a test program using large real
613         # kinds.  Include the current process ID in the file names to
614         # prevent conflicts with invocations for multiple testsuites.
615         set src real[pid].f90
616         set exe real[pid].x
617
618         set f [open $src "w"]
619         puts $f "integer,parameter :: k = &"
620         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
621         puts $f "real(kind=k) :: x"
622         puts $f "x = cos (x);"
623         puts $f "end"
624         close $f
625
626         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
627         set lines [${tool}_target_compile $src $exe executable ""]
628         file delete $src
629
630         if [string match "" $lines] then {
631             # No error message, compilation succeeded.
632             set et_fortran_large_real_saved 1
633         }
634     }
635
636     return $et_fortran_large_real_saved
637 }
638
639 # Return 1 if the target supports Fortran integer kinds larger than
640 # integer(8), 0 otherwise.
641 #
642 # When the target name changes, replace the cached result.
643
644 proc check_effective_target_fortran_large_int { } {
645     global et_fortran_large_int_saved
646     global et_fortran_large_int_target_name
647     global tool
648
649     if { ![info exists et_fortran_large_int_target_name] } {
650         set et_fortran_large_int_target_name ""
651     }
652
653     # If the target has changed since we set the cached value, clear it.
654     set current_target [current_target_name]
655     if { $current_target != $et_fortran_large_int_target_name } {
656         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
657         set et_fortran_large_int_target_name $current_target
658         if [info exists et_fortran_large_int_saved] {
659             verbose "check_effective_target_fortran_large_int: removing cached result" 2
660             unset et_fortran_large_int_saved
661         }
662     }
663
664     if [info exists et_fortran_large_int_saved] {
665         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
666     } else {
667         set et_fortran_large_int_saved 0
668
669         # Set up, compile, and execute a test program using large integer
670         # kinds.  Include the current process ID in the file names to
671         # prevent conflicts with invocations for multiple testsuites.
672         set src int[pid].f90
673         set exe int[pid].x
674
675         set f [open $src "w"]
676         puts $f "integer,parameter :: k = &"
677         puts $f "  selected_int_kind (range (0_8) + 1)"
678         puts $f "integer(kind=k) :: i"
679         puts $f "end"
680         close $f
681
682         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
683         set lines [${tool}_target_compile $src $exe executable ""]
684         file delete $src
685
686         if [string match "" $lines] then {
687             # No error message, compilation succeeded.
688             set et_fortran_large_int_saved 1
689         }
690     }
691
692     return $et_fortran_large_int_saved
693 }
694
695 # Return 1 if we can statically link libgfortran, 0 otherwise.
696 #
697 # When the target name changes, replace the cached result.
698
699 proc check_effective_target_static_libgfortran { } {
700     global et_static_libgfortran
701     global et_static_libgfortran_target_name
702     global tool
703
704     if { ![info exists et_static_libgfortran_target_name] } {
705        set et_static_libgfortran_target_name ""
706     }
707
708     # If the target has changed since we set the cached value, clear it.
709     set current_target [current_target_name]
710     if { $current_target != $et_static_libgfortran_target_name } {
711        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
712        set et_static_libgfortran_target_name $current_target
713        if [info exists et_static_libgfortran_saved] {
714            verbose "check_effective_target_static_libgfortran: removing cached result" 2
715            unset et_static_libgfortran_saved
716        }
717     }
718
719     if [info exists et_static_libgfortran_saved] {
720        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
721     } else {
722        set et_static_libgfortran_saved 0
723
724        # Set up, compile, and execute a test program using static linking.
725        # Include the current process ID in the file names to prevent
726        # conflicts with invocations for multiple testsuites.
727        set opts "additional_flags=-static"
728        set src static[pid].f
729        set exe static[pid].x
730
731        set f [open $src "w"]
732        puts $f "      print *, 'test'"
733        puts $f "      end"
734        close $f
735
736        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
737        set lines [${tool}_target_compile $src $exe executable "$opts"]
738        file delete $src
739
740        if [string match "" $lines] then {
741            # No error message, compilation succeeded.
742            set et_static_libgfortran_saved 1
743        }
744     }
745
746     return $et_static_libgfortran_saved
747 }
748
749 # Return 1 if the target supports executing AltiVec instructions, 0
750 # otherwise.  Cache the result.
751
752 proc check_vmx_hw_available { } {
753     global vmx_hw_available_saved
754     global tool
755
756     if [info exists vmx_hw_available_saved] {
757         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
758     } else {
759         set vmx_hw_available_saved 0
760
761         # Some simulators are known to not support VMX instructions.
762         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
763             verbose "check_hw_available  returning 0" 2
764             return $vmx_hw_available_saved
765         }
766
767         # Set up, compile, and execute a test program containing VMX
768         # instructions.  Include the current process ID in the file
769         # names to prevent conflicts with invocations for multiple
770         # testsuites.
771         set src vmx[pid].c
772         set exe vmx[pid].x
773
774         set f [open $src "w"]
775         puts $f "int main() {"
776         puts $f "#ifdef __MACH__"
777         puts $f "  asm volatile (\"vor v0,v0,v0\");"
778         puts $f "#else"
779         puts $f "  asm volatile (\"vor 0,0,0\");"
780         puts $f "#endif"
781         puts $f "  return 0; }"
782         close $f
783
784         # Most targets don't require special flags for this test case, but
785         # Darwin does.
786         if [istarget *-*-darwin*] {
787           set opts "additional_flags=-maltivec"
788         } else {
789           set opts ""
790         }
791
792         verbose "check_vmx_hw_available  compiling testfile $src" 2
793         set lines [${tool}_target_compile $src $exe executable "$opts"]
794         file delete $src
795
796         if [string match "" $lines] then {
797             # No error message, compilation succeeded.
798             set result [${tool}_load "./$exe" "" ""]
799             set status [lindex $result 0]
800             remote_file build delete $exe
801             verbose "check_vmx_hw_available testfile status is <$status>" 2
802
803             if { $status == "pass" } then {
804                 set vmx_hw_available_saved 1
805             }
806         } else {
807             verbose "check_vmx_hw_availalble testfile compilation failed" 2
808         }
809     }
810
811     return $vmx_hw_available_saved
812 }
813
814 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
815 # complex float arguments.  This affects gfortran tests that call cabsf
816 # in libm built by an earlier compiler.  Return 1 if libm uses the same
817 # argument passing as the compiler under test, 0 otherwise.
818 #
819 # When the target name changes, replace the cached result.
820
821 proc check_effective_target_broken_cplxf_arg { } {
822     global et_broken_cplxf_arg_saved
823     global et_broken_cplxf_arg_target_name
824     global tool
825
826     # Skip the work for targets known not to be affected.
827     if { ![istarget powerpc64-*-linux*] } {
828         return 0
829     } elseif { [is-effective-target ilp32] } {
830         return 0
831     }
832
833     if { ![info exists et_broken_cplxf_arg_target_name] } {
834         set et_broken_cplxf_arg_target_name ""
835     }
836
837     # If the target has changed since we set the cached value, clear it.
838     set current_target [current_target_name]
839     if { $current_target != $et_broken_cplxf_arg_target_name } {
840         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
841         set et_broken_cplxf_arg_target_name $current_target
842         if [info exists et_broken_cplxf_arg_saved] {
843             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
844             unset et_broken_cplxf_arg_saved
845         }
846     }
847
848     if [info exists et_broken_cplxf_arg_saved] {
849         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
850     } else {
851         set et_broken_cplxf_arg_saved 0
852         # This is only known to affect one target.
853         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
854             set et_broken_cplxf_arg_saved 0
855             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
856             return $et_broken_cplxf_arg_saved
857         }
858
859         # Set up, compile, and execute a C test program that calls cabsf.
860         set src cabsf[pid].c
861         set exe cabsf[pid].x
862
863         set f [open $src "w"]
864         puts $f "#include <complex.h>"
865         puts $f "extern void abort (void);"
866         puts $f "float fabsf (float);"
867         puts $f "float cabsf (_Complex float);"
868         puts $f "int main ()"
869         puts $f "{"
870         puts $f "  _Complex float cf;"
871         puts $f "  float f;"
872         puts $f "  cf = 3 + 4.0fi;"
873         puts $f "  f = cabsf (cf);"
874         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
875         puts $f "  return 0;"
876         puts $f "}"
877         close $f
878
879         set lines [${tool}_target_compile $src $exe executable "-lm"]
880         file delete $src
881
882         if [string match "" $lines] {
883             # No error message, compilation succeeded.
884             set result [${tool}_load "./$exe" "" ""]
885             set status [lindex $result 0]
886             remote_file build delete $exe
887
888             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
889
890             if { $status != "pass" } {
891                 set et_broken_cplxf_arg_saved 1
892             }
893         } else {
894             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
895         }
896     }
897     return $et_broken_cplxf_arg_saved
898 }
899
900 proc check_alpha_max_hw_available { } {
901     global alpha_max_hw_available_saved
902     global tool
903
904     if [info exists alpha_max_hw_available_saved] {
905         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
906     } else {
907         set alpha_max_hw_available_saved 0
908
909         # Set up, compile, and execute a test program probing bit 8 of the
910         # architecture mask, which indicates presence of MAX instructions.
911         set src max[pid].c
912         set exe max[pid].x
913
914         set f [open $src "w"]
915         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
916         close $f
917
918         verbose "check_alpha_max_hw_available compiling testfile $src" 2
919         set lines [${tool}_target_compile $src $exe executable ""]
920         file delete $src
921
922         if [string match "" $lines] then {
923             # No error message, compilation succeeded.
924             set result [${tool}_load "./$exe" "" ""]
925             set status [lindex $result 0]
926             remote_file build delete $exe
927             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
928
929             if { $status == "pass" } then {
930                 set alpha_max_hw_available_saved 1
931             }
932         } else {
933             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
934         }
935     }
936
937     return $alpha_max_hw_available_saved
938 }
939
940 # Returns true iff the FUNCTION is available on the target system.
941 # (This is essentially a Tcl implementation of Autoconf's
942 # AC_CHECK_FUNC.)
943
944 proc check_function_available { function } {
945     set var "${function}_available_saved"
946     global $var
947     global tool
948
949     if {![info exists $var]} {
950         # Assume it exists.
951         set $var 1
952         # Check to make sure.
953         set src "function[pid].c"
954         set exe "function[pid].exe"
955
956         set f [open $src "w"]
957         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
958         puts $f "char $function ();\n"
959         puts $f "int main () { $function (); }"
960         close $f
961
962         set lines [${tool}_target_compile $src $exe executable ""]
963         file delete $src
964         file delete $exe
965
966         if {![string match "" $lines]} then {
967             set $var 0
968             verbose -log "$function is not available"
969         } else {
970             verbose -log "$function is available"
971         }
972     }
973
974     eval return \$$var
975 }
976
977 # Returns true iff "fork" is available on the target system.
978
979 proc check_fork_available {} {
980     return [check_function_available "fork"]
981 }
982
983 # Returns true iff "mkfifo" is available on the target system.
984
985 proc check_mkfifo_available {} {
986     if {[istarget *-*-cygwin*]} {
987        # Cygwin has mkfifo, but support is incomplete.
988        return 0
989      }
990
991     return [check_function_available "mkfifo"]
992 }
993
994 # Returns true iff "__cxa_atexit" is used on the target system.
995
996 proc check_cxa_atexit_available { } {
997     global et_cxa_atexit
998     global et_cxa_atexit_target_name
999     global tool 
1000
1001     if { ![info exists et_cxa_atexit_target_name] } {
1002         set et_cxa_atexit_target_name ""
1003     }
1004
1005     # If the target has changed since we set the cached value, clear it.
1006     set current_target [current_target_name]
1007     if { $current_target != $et_cxa_atexit_target_name } {
1008         verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1009         set et_cxa_atexit_target_name $current_target
1010         if [info exists et_cxa_atexit] {
1011             verbose "check_cxa_atexit_available: removing cached result" 2
1012             unset et_cxa_atexit
1013         }
1014     }
1015
1016     if [info exists et_cxa_atexit] {
1017         verbose "check_cxa_atexit_available: using cached result" 2
1018     } elseif { [istarget "hppa*-*-hpux10*"] } {
1019         # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1020         set et_cxa_atexit 0
1021     } else {
1022         set et_cxa_atexit 0
1023
1024         # Set up, compile, and execute a C++ test program that depends
1025         # on correct ordering of static object destructors. This is
1026         # indicative of the presence and use of __cxa_atexit.
1027         set src cxaatexit[pid].cc
1028         set exe cxaatexit[pid].x
1029
1030         set f [open $src "w"]
1031         puts $f "#include <stdlib.h>"
1032         puts $f "static unsigned int count;"
1033         puts $f "struct X"
1034         puts $f "{"
1035         puts $f "  X() { count = 1; }"
1036         puts $f "  ~X()"
1037         puts $f "  {"
1038         puts $f "    if (count != 3)"
1039         puts $f "      exit(1);"
1040         puts $f "    count = 4;"
1041         puts $f "  }"
1042         puts $f "};"
1043         puts $f "void f()"
1044         puts $f "{"
1045         puts $f "  static X x;"
1046         puts $f "}"
1047         puts $f "struct Y"
1048         puts $f "{"
1049         puts $f "  Y() { f(); count = 2; }"
1050         puts $f "  ~Y()"
1051         puts $f "  {"
1052         puts $f "    if (count != 2)"
1053         puts $f "      exit(1);"
1054         puts $f "    count = 3;"
1055         puts $f "  }"
1056         puts $f "};"
1057         puts $f "Y y;"
1058         puts $f "int main()"
1059         puts $f "{ return 0; }"
1060         close $f
1061
1062         set lines [${tool}_target_compile $src $exe executable ""]
1063         file delete $src
1064
1065         if [string match "" $lines] {
1066             # No error message, compilation succeeded.
1067             set result [${tool}_load "./$exe" "" ""]
1068             set status [lindex $result 0]
1069             remote_file build delete $exe
1070
1071             verbose "check_cxa_atexit_available: status is <$status>" 2
1072
1073             if { $status == "pass" } {
1074                 set et_cxa_atexit 1
1075             }
1076         } else {
1077             verbose "check_cxa_atexit_available: compilation failed" 2
1078         }
1079     }
1080     return $et_cxa_atexit
1081 }
1082
1083
1084 # Return 1 if we're generating 32-bit code using default options, 0
1085 # otherwise.
1086
1087 proc check_effective_target_ilp32 { } {
1088     return [check_no_compiler_messages ilp32 object {
1089         int dummy[sizeof (int) == 4
1090                   && sizeof (void *) == 4
1091                   && sizeof (long) == 4 ? 1 : -1];
1092     }]
1093 }
1094
1095 # Return 1 if we're generating 32-bit or larger integers using default
1096 # options, 0 otherwise.
1097
1098 proc check_effective_target_int32plus { } {
1099     return [check_no_compiler_messages int32plus object {
1100         int dummy[sizeof (int) >= 4 ? 1 : -1];
1101     }]
1102 }
1103
1104 # Return 1 if we're generating 32-bit or larger pointers using default
1105 # options, 0 otherwise.
1106
1107 proc check_effective_target_ptr32plus { } {
1108     return [check_no_compiler_messages ptr32plus object {
1109         int dummy[sizeof (void *) >= 4 ? 1 : -1];
1110     }]
1111 }
1112
1113 # Return 1 if we support 32-bit or larger array and structure sizes
1114 # using default options, 0 otherwise.
1115
1116 proc check_effective_target_size32plus { } {
1117     return [check_no_compiler_messages size32plus object {
1118         char dummy[65537];
1119     }]
1120 }
1121
1122 # Returns 1 if we're generating 16-bit or smaller integers with the
1123 # default options, 0 otherwise.
1124
1125 proc check_effective_target_int16 { } {
1126     return [check_no_compiler_messages int16 object {
1127         int dummy[sizeof (int) < 4 ? 1 : -1];
1128     }]
1129 }
1130
1131 # Return 1 if we're generating 64-bit code using default options, 0
1132 # otherwise.
1133
1134 proc check_effective_target_lp64 { } {
1135     return [check_no_compiler_messages lp64 object {
1136         int dummy[sizeof (int) == 4
1137                   && sizeof (void *) == 8
1138                   && sizeof (long) == 8 ? 1 : -1];
1139     }]
1140 }
1141
1142 # Return 1 if the target supports long double larger than double,
1143 # 0 otherwise.
1144
1145 proc check_effective_target_large_long_double { } {
1146     return [check_no_compiler_messages large_long_double object {
1147         int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1148     }]
1149 }
1150
1151
1152 # Return 1 if the target supports compiling decimal floating point,
1153 # 0 otherwise.
1154
1155 proc check_effective_target_dfp_nocache { } {
1156     verbose "check_effective_target_dfp_nocache: compiling source" 2
1157     set ret [string match "" [get_compiler_messages dfp 0 object {
1158         _Decimal32 x; _Decimal64 y; _Decimal128 z;
1159     }]]
1160     verbose "check_effective_target_dfp_nocache: returning $ret" 2
1161     return $ret
1162 }
1163
1164 proc check_effective_target_dfprt_nocache { } {
1165     global tool
1166
1167     set ret 0
1168
1169     verbose "check_effective_target_dfprt_nocache: compiling source" 2
1170     # Set up, compile, and execute a test program containing decimal
1171     # float operations.
1172     set src dfprt[pid].c
1173     set exe dfprt[pid].x
1174
1175     set f [open $src "w"]
1176     puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1177     puts $f "int main () { z = x + y; return 0; }"
1178     close $f
1179
1180     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1181     set lines [${tool}_target_compile $src $exe executable ""]
1182     file delete $src
1183
1184     if [string match "" $lines] then {
1185         # No error message, compilation succeeded.
1186         set result [${tool}_load "./$exe" "" ""]
1187         set status [lindex $result 0]
1188         remote_file build delete $exe
1189         verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1190         if { $status == "pass" } then {
1191             set ret 1
1192         }
1193     }
1194     return $ret
1195     verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1196 }
1197
1198 # Return 1 if the target supports compiling Decimal Floating Point,
1199 # 0 otherwise.
1200 #
1201 # This won't change for different subtargets so cache the result.
1202
1203 proc check_effective_target_dfp { } {
1204     global et_dfp_saved
1205
1206     if [info exists et_dfp_saved] {
1207         verbose "check_effective_target_dfp: using cached result" 2
1208     } else {
1209         set et_dfp_saved [check_effective_target_dfp_nocache]
1210     }
1211     verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1212     return $et_dfp_saved
1213 }
1214
1215 # Return 1 if the target supports linking and executing Decimal Floating
1216 # Point, # 0 otherwise.
1217 #
1218 # This won't change for different subtargets so cache the result.
1219
1220 proc check_effective_target_dfprt { } {
1221     global et_dfprt_saved
1222     global tool
1223
1224     if [info exists et_dfprt_saved] {
1225         verbose "check_effective_target_dfprt: using cached result" 2
1226     } else {
1227         set et_dfprt_saved [check_effective_target_dfprt_nocache]
1228     }
1229     verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1230     return $et_dfprt_saved
1231 }
1232
1233 # Return 1 if the target needs a command line argument to enable a SIMD
1234 # instruction set.
1235
1236 proc check_effective_target_vect_cmdline_needed { } {
1237     global et_vect_cmdline_needed_saved
1238     global et_vect_cmdline_needed_target_name
1239
1240     if { ![info exists et_vect_cmdline_needed_target_name] } {
1241         set et_vect_cmdline_needed_target_name ""
1242     }
1243
1244     # If the target has changed since we set the cached value, clear it.
1245     set current_target [current_target_name]
1246     if { $current_target != $et_vect_cmdline_needed_target_name } {
1247         verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1248         set et_vect_cmdline_needed_target_name $current_target
1249         if { [info exists et_vect_cmdline_needed_saved] } {
1250             verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1251             unset et_vect_cmdline_needed_saved
1252         }
1253     }
1254
1255     if [info exists et_vect_cmdline_needed_saved] {
1256         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1257     } else {
1258         set et_vect_cmdline_needed_saved 1
1259         if { [istarget ia64-*-*]
1260              || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1261                  && [check_effective_target_lp64])
1262              || ([istarget powerpc*-*-*]
1263                  && ([check_effective_target_powerpc_spe]
1264                      || [check_effective_target_powerpc_altivec]))} {
1265            set et_vect_cmdline_needed_saved 0
1266         }
1267     }
1268
1269     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1270     return $et_vect_cmdline_needed_saved
1271 }
1272
1273 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1274 #
1275 # This won't change for different subtargets so cache the result.
1276
1277 proc check_effective_target_vect_int { } {
1278     global et_vect_int_saved
1279
1280     if [info exists et_vect_int_saved] {
1281         verbose "check_effective_target_vect_int: using cached result" 2
1282     } else {
1283         set et_vect_int_saved 0
1284         if { [istarget i?86-*-*]
1285               || [istarget powerpc*-*-*]
1286               || [istarget spu-*-*]
1287               || [istarget x86_64-*-*]
1288               || [istarget sparc*-*-*]
1289               || [istarget alpha*-*-*]
1290               || [istarget ia64-*-*] } {
1291            set et_vect_int_saved 1
1292         }
1293     }
1294
1295     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1296     return $et_vect_int_saved
1297 }
1298
1299 # Return 1 is this is an arm target using 32-bit instructions
1300 proc check_effective_target_arm32 { } {
1301     global et_arm32_saved
1302     global et_arm32_target_name
1303     global compiler_flags
1304
1305     if { ![info exists et_arm32_target_name] } {
1306         set et_arm32_target_name ""
1307     }
1308
1309     # If the target has changed since we set the cached value, clear it.
1310     set current_target [current_target_name]
1311     if { $current_target != $et_arm32_target_name } {
1312         verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1313         set et_arm32_target_name $current_target
1314         if { [info exists et_arm32_saved] } {
1315             verbose "check_effective_target_arm32: removing cached result" 2
1316             unset et_arm32_saved
1317         }
1318     }
1319
1320     if [info exists et_arm32_saved] {
1321         verbose "check-effective_target_arm32: using cached result" 2
1322     } else {
1323         set et_arm32_saved 0
1324         if { [istarget arm-*-*]
1325               || [istarget strongarm*-*-*]
1326               || [istarget xscale-*-*] } {
1327             if ![string match "*-mthumb *" $compiler_flags] {
1328                 set et_arm32_saved 1
1329             }
1330         }
1331     }
1332     verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1333     return $et_arm32_saved
1334 }
1335
1336 # Return 1 if this is an ARM target supporting -mfpu=vfp
1337 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1338 # options.
1339
1340 proc check_effective_target_arm_vfp_ok { } {
1341     if { [check_effective_target_arm32] } {
1342         return [check_no_compiler_messages arm_vfp_ok object {
1343             int dummy;
1344         } "-mfpu=vfp -mfloat-abi=softfp"]
1345     } else {
1346         return 0
1347     }
1348 }
1349
1350 # Return 1 if this is a PowerPC target with floating-point registers.
1351
1352 proc check_effective_target_powerpc_fprs { } {
1353     if { [istarget powerpc*-*-*]
1354          || [istarget rs6000-*-*] } {
1355         return [check_no_compiler_messages powerpc_fprs object {
1356             #ifdef __NO_FPRS__
1357             #error no FPRs
1358             #else
1359             int dummy;
1360             #endif
1361         }]
1362     } else {
1363         return 0
1364     }
1365 }
1366
1367 # Return 1 if this is a PowerPC target supporting -maltivec.
1368
1369 proc check_effective_target_powerpc_altivec_ok { } {
1370     if { [istarget powerpc*-*-*]
1371          || [istarget rs6000-*-*] } {
1372         # AltiVec is not supported on Aix.
1373         if { [istarget powerpc*-*-aix*] } {
1374             return 0
1375         }
1376         return [check_no_compiler_messages powerpc_altivec_ok object {
1377             int dummy;
1378         } "-maltivec"]
1379     } else {
1380         return 0
1381     }
1382 }
1383
1384 # Return 1 if this is a PowerPC target with SPE enabled.
1385
1386 proc check_effective_target_powerpc_spe { } {
1387     if { [istarget powerpc*-*-*] } {
1388         return [check_no_compiler_messages powerpc_spe object {
1389             #ifndef __SPE__
1390             #error not SPE
1391             #else
1392             int dummy;
1393             #endif
1394         }]
1395     } else {
1396         return 0
1397     }
1398 }
1399
1400 # Return 1 if this is a PowerPC target with Altivec enabled.
1401
1402 proc check_effective_target_powerpc_altivec { } {
1403     if { [istarget powerpc*-*-*] } {
1404         return [check_no_compiler_messages powerpc_altivec object {
1405             #ifndef __ALTIVEC__
1406             #error not Altivec
1407             #else
1408             int dummy;
1409             #endif
1410         }]
1411     } else {
1412         return 0
1413     }
1414 }
1415
1416 # Return 1 if the target supports hardware vector shift operation.
1417
1418 proc check_effective_target_vect_shift { } {
1419     global et_vect_shift_saved
1420
1421     if [info exists et_vect_shift_saved] {
1422         verbose "check_effective_target_vect_shift: using cached result" 2
1423     } else {
1424         set et_vect_shift_saved 0
1425         if { [istarget powerpc*-*-*]
1426              || [istarget ia64-*-*]
1427              || [istarget i?86-*-*]
1428              || [istarget x86_64-*-*] } {
1429            set et_vect_shift_saved 1
1430         }
1431     }
1432
1433     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1434     return $et_vect_shift_saved
1435 }
1436
1437 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1438 #
1439 # This can change for different subtargets so do not cache the result.
1440
1441 proc check_effective_target_vect_long { } {
1442     if { [istarget i?86-*-*]
1443          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1444          || [istarget x86_64-*-*]
1445          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1446         set answer 1
1447     } else {
1448         set answer 0
1449     }
1450
1451     verbose "check_effective_target_vect_long: returning $answer" 2
1452     return $answer
1453 }
1454
1455 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1456 #
1457 # This won't change for different subtargets so cache the result.
1458
1459 proc check_effective_target_vect_float { } {
1460     global et_vect_float_saved
1461
1462     if [info exists et_vect_float_saved] {
1463         verbose "check_effective_target_vect_float: using cached result" 2
1464     } else {
1465         set et_vect_float_saved 0
1466         if { [istarget i?86-*-*]
1467               || [istarget powerpc*-*-*]
1468               || [istarget spu-*-*]
1469               || [istarget mipsisa64*-*-*]
1470               || [istarget x86_64-*-*]
1471               || [istarget ia64-*-*] } {
1472            set et_vect_float_saved 1
1473         }
1474     }
1475
1476     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1477     return $et_vect_float_saved
1478 }
1479
1480 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1481 #
1482 # This won't change for different subtargets so cache the result.
1483
1484 proc check_effective_target_vect_double { } {
1485     global et_vect_double_saved
1486
1487     if [info exists et_vect_double_saved] {
1488         verbose "check_effective_target_vect_double: using cached result" 2
1489     } else {
1490         set et_vect_double_saved 0
1491         if { [istarget i?86-*-*]
1492               || [istarget x86_64-*-*] 
1493               || [istarget spu-*-*] } {
1494            set et_vect_double_saved 1
1495         }
1496     }
1497
1498     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1499     return $et_vect_double_saved
1500 }
1501
1502 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1503 #
1504 # This won't change for different subtargets so cache the result.
1505
1506 proc check_effective_target_vect_no_compare_double { } {
1507     global et_vect_no_compare_double_saved
1508
1509     if [info exists et_vect_no_compare_double_saved] {
1510         verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1511     } else {
1512         set et_vect_no_compare_double_saved 0
1513         if { [istarget spu-*-*] } {
1514            set et_vect_no_compare_double_saved 1
1515         }
1516     }
1517
1518     verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1519     return $et_vect_no_compare_double_saved
1520 }
1521
1522 # Return 1 if the target plus current options does not support a vector
1523 # max instruction on "int", 0 otherwise.
1524 #
1525 # This won't change for different subtargets so cache the result.
1526
1527 proc check_effective_target_vect_no_int_max { } {
1528     global et_vect_no_int_max_saved
1529
1530     if [info exists et_vect_no_int_max_saved] {
1531         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1532     } else {
1533         set et_vect_no_int_max_saved 0
1534         if { [istarget sparc*-*-*]
1535              || [istarget spu-*-*]
1536              || [istarget alpha*-*-*] } {
1537             set et_vect_no_int_max_saved 1
1538         }
1539     }
1540     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1541     return $et_vect_no_int_max_saved
1542 }
1543
1544 # Return 1 if the target plus current options does not support a vector
1545 # add instruction on "int", 0 otherwise.
1546 #
1547 # This won't change for different subtargets so cache the result.
1548
1549 proc check_effective_target_vect_no_int_add { } {
1550     global et_vect_no_int_add_saved
1551
1552     if [info exists et_vect_no_int_add_saved] {
1553         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1554     } else {
1555         set et_vect_no_int_add_saved 0
1556         # Alpha only supports vector add on V8QI and V4HI.
1557         if { [istarget alpha*-*-*] } {
1558             set et_vect_no_int_add_saved 1
1559         }
1560     }
1561     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1562     return $et_vect_no_int_add_saved
1563 }
1564
1565 # Return 1 if the target plus current options does not support vector
1566 # bitwise instructions, 0 otherwise.
1567 #
1568 # This won't change for different subtargets so cache the result.
1569
1570 proc check_effective_target_vect_no_bitwise { } {
1571     global et_vect_no_bitwise_saved
1572
1573     if [info exists et_vect_no_bitwise_saved] {
1574         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1575     } else {
1576         set et_vect_no_bitwise_saved 0
1577     }
1578     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1579     return $et_vect_no_bitwise_saved
1580 }
1581
1582 # Return 1 if the target plus current options supports a vector
1583 # widening summation of *short* args into *int* result, 0 otherwise.
1584 # A target can also support this widening summation if it can support
1585 # promotion (unpacking) from shorts to ints.
1586 #
1587 # This won't change for different subtargets so cache the result.
1588                                                                                                 
1589 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1590     global et_vect_widen_sum_hi_to_si
1591
1592     if [info exists et_vect_widen_sum_hi_to_si_saved] {
1593         verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1594     } else {
1595         set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1596         if { [istarget powerpc*-*-*] } {
1597             set et_vect_widen_sum_hi_to_si_saved 1
1598         }
1599     }
1600     verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1601     return $et_vect_widen_sum_hi_to_si_saved
1602 }
1603
1604 # Return 1 if the target plus current options supports a vector
1605 # widening summation of *char* args into *short* result, 0 otherwise.
1606 # A target can also support this widening summation if it can support
1607 # promotion (unpacking) from chars to shorts.
1608 #
1609 # This won't change for different subtargets so cache the result.
1610                                                                                                 
1611 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1612     global et_vect_widen_sum_qi_to_hi
1613
1614     if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1615         verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1616     } else {
1617         set et_vect_widen_sum_qi_to_hi_saved 0
1618         if { [check_effective_target_vect_unpack] } {
1619             set et_vect_widen_sum_qi_to_hi_saved 1
1620         }
1621     }
1622     verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1623     return $et_vect_widen_sum_qi_to_hi_saved
1624 }
1625
1626 # Return 1 if the target plus current options supports a vector
1627 # widening summation of *char* args into *int* result, 0 otherwise.
1628 #
1629 # This won't change for different subtargets so cache the result.
1630                                                                                                 
1631 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1632     global et_vect_widen_sum_qi_to_si
1633
1634     if [info exists et_vect_widen_sum_qi_to_si_saved] {
1635         verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1636     } else {
1637         set et_vect_widen_sum_qi_to_si_saved 0
1638         if { [istarget powerpc*-*-*] } {
1639             set et_vect_widen_sum_qi_to_si_saved 1
1640         }
1641     }
1642     verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1643     return $et_vect_widen_sum_qi_to_si_saved
1644 }
1645
1646 # Return 1 if the target plus current options supports a vector
1647 # widening multiplication of *char* args into *short* result, 0 otherwise.
1648 # A target can also support this widening multplication if it can support
1649 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1650 # multiplication of shorts).
1651 #
1652 # This won't change for different subtargets so cache the result.
1653
1654
1655 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1656     global et_vect_widen_mult_qi_to_hi
1657
1658     if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1659         verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1660     } else {
1661         if { [check_effective_target_vect_unpack]
1662              && [check_effective_target_vect_short_mult] } {
1663             set et_vect_widen_mult_qi_to_hi_saved 1
1664         } else {
1665             set et_vect_widen_mult_qi_to_hi_saved 0
1666         }
1667         if { [istarget powerpc*-*-*] } {
1668             set et_vect_widen_mult_qi_to_hi_saved 1
1669         }
1670     }
1671     verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1672     return $et_vect_widen_mult_qi_to_hi_saved
1673 }
1674
1675 # Return 1 if the target plus current options supports a vector
1676 # widening multiplication of *short* args into *int* result, 0 otherwise.
1677 # A target can also support this widening multplication if it can support
1678 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1679 # multiplication of ints).
1680 #
1681 # This won't change for different subtargets so cache the result.
1682
1683
1684 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1685     global et_vect_widen_mult_hi_to_si
1686
1687     if [info exists et_vect_widen_mult_hi_to_si_saved] {
1688         verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1689     } else {
1690         if { [check_effective_target_vect_unpack]
1691              && [check_effective_target_vect_int_mult] } {
1692           set et_vect_widen_mult_hi_to_si_saved 1
1693         } else {
1694           set et_vect_widen_mult_hi_to_si_saved 0
1695         }
1696         if { [istarget powerpc*-*-*]
1697               || [istarget spu-*-*]
1698               || [istarget i?86-*-*]
1699               || [istarget x86_64-*-*] } {
1700             set et_vect_widen_mult_hi_to_si_saved 1
1701         }
1702     }
1703     verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1704     return $et_vect_widen_mult_hi_to_si_saved
1705 }
1706
1707 # Return 1 if the target plus current options supports a vector
1708 # dot-product of signed chars, 0 otherwise.
1709 #
1710 # This won't change for different subtargets so cache the result.
1711
1712 proc check_effective_target_vect_sdot_qi { } {
1713     global et_vect_sdot_qi
1714
1715     if [info exists et_vect_sdot_qi_saved] {
1716         verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1717     } else {
1718         set et_vect_sdot_qi_saved 0
1719     }
1720     verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1721     return $et_vect_sdot_qi_saved
1722 }
1723
1724 # Return 1 if the target plus current options supports a vector
1725 # dot-product of unsigned chars, 0 otherwise.
1726 #
1727 # This won't change for different subtargets so cache the result.
1728
1729 proc check_effective_target_vect_udot_qi { } {
1730     global et_vect_udot_qi
1731
1732     if [info exists et_vect_udot_qi_saved] {
1733         verbose "check_effective_target_vect_udot_qi: using cached result" 2
1734     } else {
1735         set et_vect_udot_qi_saved 0
1736         if { [istarget powerpc*-*-*] } {
1737             set et_vect_udot_qi_saved 1
1738         }
1739     }
1740     verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1741     return $et_vect_udot_qi_saved
1742 }
1743
1744 # Return 1 if the target plus current options supports a vector
1745 # dot-product of signed shorts, 0 otherwise.
1746 #
1747 # This won't change for different subtargets so cache the result.
1748
1749 proc check_effective_target_vect_sdot_hi { } {
1750     global et_vect_sdot_hi
1751
1752     if [info exists et_vect_sdot_hi_saved] {
1753         verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1754     } else {
1755         set et_vect_sdot_hi_saved 0
1756         if { [istarget powerpc*-*-*] 
1757              || [istarget i?86-*-*]
1758              || [istarget x86_64-*-*] } {
1759             set et_vect_sdot_hi_saved 1
1760         }
1761     }
1762     verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1763     return $et_vect_sdot_hi_saved
1764 }
1765
1766 # Return 1 if the target plus current options supports a vector
1767 # dot-product of unsigned shorts, 0 otherwise.
1768 #
1769 # This won't change for different subtargets so cache the result.
1770
1771 proc check_effective_target_vect_udot_hi { } {
1772     global et_vect_udot_hi
1773
1774     if [info exists et_vect_udot_hi_saved] {
1775         verbose "check_effective_target_vect_udot_hi: using cached result" 2
1776     } else {
1777         set et_vect_udot_hi_saved 0
1778         if { [istarget powerpc*-*-*] } {
1779             set et_vect_udot_hi_saved 1
1780         }
1781     }
1782     verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1783     return $et_vect_udot_hi_saved
1784 }
1785
1786
1787 # Return 1 if the target plus current options supports a vector
1788 # demotion (packing) of shorts (to chars) and ints (to shorts) 
1789 # using modulo arithmetic, 0 otherwise.
1790 #
1791 # This won't change for different subtargets so cache the result.
1792                                                                                 
1793 proc check_effective_target_vect_pack_mod { } {
1794     global et_vect_pack_mod
1795                                                                                 
1796     if [info exists et_vect_pack_mod_saved] {
1797         verbose "check_effective_target_vect_pack_mod: using cached result" 2
1798     } else {
1799         set et_vect_pack_mod_saved 0
1800         if { [istarget powerpc*-*-*]
1801              || [istarget i?86-*-*]
1802              || [istarget x86_64-*-*] } {
1803             set et_vect_pack_mod_saved 1
1804         }
1805     }
1806     verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1807     return $et_vect_pack_mod_saved
1808 }
1809
1810 # Return 1 if the target plus current options supports a vector
1811 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1812 #
1813 # This won't change for different subtargets so cache the result.
1814                                    
1815 proc check_effective_target_vect_unpack { } {
1816     global et_vect_unpack
1817                                         
1818     if [info exists et_vect_unpack_saved] {
1819         verbose "check_effective_target_vect_unpack: using cached result" 2
1820     } else {
1821         set et_vect_unpack_saved 0
1822         if { [istarget powerpc*-*-*]
1823              || [istarget i?86-*-*]
1824              || [istarget x86_64-*-*] } {
1825             set et_vect_unpack_saved 1
1826         }
1827     }
1828     verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2  
1829     return $et_vect_unpack_saved
1830 }
1831
1832 # Return 1 if the target plus current options does not support a vector
1833 # alignment mechanism, 0 otherwise.
1834 #
1835 # This won't change for different subtargets so cache the result.
1836
1837 proc check_effective_target_vect_no_align { } {
1838     global et_vect_no_align_saved
1839
1840     if [info exists et_vect_no_align_saved] {
1841         verbose "check_effective_target_vect_no_align: using cached result" 2
1842     } else {
1843         set et_vect_no_align_saved 0
1844         if { [istarget mipsisa64*-*-*]
1845              || [istarget sparc*-*-*]
1846              || [istarget ia64-*-*] } {
1847             set et_vect_no_align_saved 1
1848         }
1849     }
1850     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1851     return $et_vect_no_align_saved
1852 }
1853
1854 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1855
1856 proc check_effective_target_vect_condition { } {
1857     global et_vect_cond_saved
1858
1859     if [info exists et_vect_cond_saved] {
1860         verbose "check_effective_target_vect_cond: using cached result" 2
1861     } else {
1862         set et_vect_cond_saved 0
1863         if { [istarget powerpc*-*-*]
1864              || [istarget ia64-*-*]
1865              || [istarget i?86-*-*]
1866              || [istarget x86_64-*-*] } {
1867            set et_vect_cond_saved 1
1868         }
1869     }
1870
1871     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1872     return $et_vect_cond_saved
1873 }
1874
1875 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1876
1877 proc check_effective_target_vect_char_mult { } {
1878     global et_vect_char_mult_saved
1879
1880     if [info exists et_vect_char_mult_saved] {
1881         verbose "check_effective_target_vect_char_mult: using cached result" 2
1882     } else {
1883         set et_vect_char_mult_saved 0
1884         if { [istarget ia64-*-*]
1885              || [istarget i?86-*-*]
1886              || [istarget x86_64-*-*] } {
1887            set et_vect_char_mult_saved 1
1888         }
1889     }
1890
1891     verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1892     return $et_vect_char_mult_saved
1893 }
1894
1895 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1896
1897 proc check_effective_target_vect_short_mult { } {
1898     global et_vect_short_mult_saved
1899
1900     if [info exists et_vect_short_mult_saved] {
1901         verbose "check_effective_target_vect_short_mult: using cached result" 2
1902     } else {
1903         set et_vect_short_mult_saved 0
1904         if { [istarget ia64-*-*]
1905              || [istarget i?86-*-*]
1906              || [istarget x86_64-*-*] } {
1907            set et_vect_short_mult_saved 1
1908         }
1909     }
1910
1911     verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1912     return $et_vect_short_mult_saved
1913 }
1914
1915 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1916
1917 proc check_effective_target_vect_int_mult { } {
1918     global et_vect_int_mult_saved
1919
1920     if [info exists et_vect_int_mult_saved] {
1921         verbose "check_effective_target_vect_int_mult: using cached result" 2
1922     } else {
1923         set et_vect_int_mult_saved 0
1924         if { [istarget powerpc*-*-*]
1925              || [istarget i?86-*-*]
1926              || [istarget x86_64-*-*] } {
1927            set et_vect_int_mult_saved 1
1928         }
1929     }
1930
1931     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1932     return $et_vect_int_mult_saved
1933 }
1934
1935 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1936
1937 proc check_effective_target_vect_extract_even_odd { } {
1938     global et_vect_extract_even_odd_saved
1939     
1940     if [info exists et_vect_extract_even_odd_saved] {
1941         verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1942     } else {
1943         set et_vect_extract_even_odd_saved 0 
1944         if { [istarget powerpc*-*-*] } {
1945            set et_vect_extract_even_odd_saved 1
1946         }
1947     }
1948
1949     verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1950     return $et_vect_extract_even_odd_saved
1951 }
1952
1953 # Return 1 if the target supports vector interleaving, 0 otherwise.
1954
1955 proc check_effective_target_vect_interleave { } {
1956     global et_vect_interleave_saved
1957     
1958     if [info exists et_vect_interleave_saved] {
1959         verbose "check_effective_target_vect_interleave: using cached result" 2
1960     } else {
1961         set et_vect_interleave_saved 0
1962         if { [istarget powerpc*-*-*]
1963              || [istarget i?86-*-*]
1964              || [istarget x86_64-*-*] } {
1965            set et_vect_interleave_saved 1
1966         }
1967     }
1968
1969     verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1970     return $et_vect_interleave_saved
1971 }
1972
1973 # Return 1 if the target supports section-anchors
1974
1975 proc check_effective_target_section_anchors { } {
1976     global et_section_anchors_saved
1977
1978     if [info exists et_section_anchors_saved] {
1979         verbose "check_effective_target_section_anchors: using cached result" 2
1980     } else {
1981         set et_section_anchors_saved 0
1982         if { [istarget powerpc*-*-*] } {
1983            set et_section_anchors_saved 1
1984         }
1985     }
1986
1987     verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1988     return $et_section_anchors_saved
1989 }
1990
1991 # Return 1 if the target supports atomic operations on "int" and "long".
1992
1993 proc check_effective_target_sync_int_long { } {
1994     global et_sync_int_long_saved
1995
1996     if [info exists et_sync_int_long_saved] {
1997         verbose "check_effective_target_sync_int_long: using cached result" 2
1998     } else {
1999         set et_sync_int_long_saved 0
2000 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2001 # load-reserved/store-conditional instructions.
2002         if { [istarget ia64-*-*]
2003              || [istarget i?86-*-*]
2004              || [istarget x86_64-*-*]
2005              || [istarget alpha*-*-*] 
2006              || [istarget s390*-*-*] 
2007              || [istarget powerpc*-*-*]
2008              || [istarget sparc64-*-*]
2009              || [istarget sparcv9-*-*] } {
2010            set et_sync_int_long_saved 1
2011         }
2012     }
2013
2014     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2015     return $et_sync_int_long_saved
2016 }
2017
2018 # Return 1 if the target supports atomic operations on "char" and "short".
2019
2020 proc check_effective_target_sync_char_short { } {
2021     global et_sync_char_short_saved
2022
2023     if [info exists et_sync_char_short_saved] {
2024         verbose "check_effective_target_sync_char_short: using cached result" 2
2025     } else {
2026         set et_sync_char_short_saved 0
2027 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2028 # load-reserved/store-conditional instructions.
2029         if { [istarget ia64-*-*]
2030              || [istarget i?86-*-*]
2031              || [istarget x86_64-*-*]
2032              || [istarget alpha*-*-*] 
2033              || [istarget s390*-*-*] 
2034              || [istarget powerpc*-*-*]
2035              || [istarget sparc64-*-*]
2036              || [istarget sparcv9-*-*] } {
2037            set et_sync_char_short_saved 1
2038         }
2039     }
2040
2041     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2042     return $et_sync_char_short_saved
2043 }
2044
2045 # Return 1 if the target uses a ColdFire FPU.
2046
2047 proc check_effective_target_coldfire_fpu { } {
2048     return [check_no_compiler_messages coldfire_fpu assembly {
2049         #ifndef __mcffpu__
2050         #error FOO
2051         #endif
2052     }]
2053 }
2054
2055 # Return true if this is a uClibc target.
2056
2057 proc check_effective_target_uclibc {} {
2058     return [check_no_compiler_messages uclibc object {
2059         #include <features.h>
2060         #if !defined (__UCLIBC__)
2061         #error FOO
2062         #endif
2063     }]
2064 }
2065
2066 # Return true if this is a Newlib target.
2067
2068 proc check_effective_target_newlib {} {
2069     return [check_no_compiler_messages newlib object {
2070         #include <newlib.h>
2071     }]
2072 }
2073
2074 # Return 1 if
2075 #   (a) an error of a few ULP is expected in string to floating-point
2076 #       conversion functions; and
2077 #   (b) overflow is not always detected correctly by those functions.
2078
2079 proc check_effective_target_lax_strtofp {} {
2080     # By default, assume that all uClibc targets suffer from this.
2081     return [check_effective_target_uclibc]
2082 }
2083
2084 # Return 1 if this is a target for which wcsftime is a dummy
2085 # function that always returns 0.
2086
2087 proc check_effective_target_dummy_wcsftime {} {
2088     # By default, assume that all uClibc targets suffer from this.
2089     return [check_effective_target_uclibc]
2090 }
2091
2092 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2093 # This can be used with any check_* proc that takes no argument and
2094 # returns only 1 or 0.  It could be used with check_* procs that take
2095 # arguments with keywords that pass particular arguments.
2096
2097 proc is-effective-target { arg } {
2098     set selected 0
2099     if { [info procs check_effective_target_${arg}] != [list] } {
2100         set selected [check_effective_target_${arg}]
2101     } else {
2102         switch $arg {
2103           "vmx_hw"         { set selected [check_vmx_hw_available] }
2104           "named_sections" { set selected [check_named_sections_available] }
2105           "gc_sections"    { set selected [check_gc_sections_available] }
2106           "cxa_atexit"     { set selected [check_cxa_atexit_available] }
2107           default          { error "unknown effective target keyword `$arg'" }
2108         }
2109     }
2110     verbose "is-effective-target: $arg $selected" 2
2111     return $selected
2112 }
2113
2114 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2115
2116 proc is-effective-target-keyword { arg } {
2117     if { [info procs check_effective_target_${arg}] != [list] } {
2118         return 1
2119     } else {
2120         # These have different names for their check_* procs.
2121         switch $arg {
2122           "vmx_hw"         { return 1 }
2123           "named_sections" { return 1 }
2124           "gc_sections"    { return 1 }
2125           "cxa_atexit"     { return 1 }
2126           default          { return 0 }
2127         }
2128     }
2129 }
2130
2131 # Return 1 if target default to short enums
2132
2133 proc check_effective_target_short_enums { } {
2134     return [check_no_compiler_messages short_enums assembly {
2135         enum foo { bar };
2136         int s[sizeof (enum foo) == 1 ? 1 : -1];
2137     }]
2138 }
2139
2140 # Return 1 if target supports merging string constants at link time.
2141
2142 proc check_effective_target_string_merging { } {
2143     return [check_no_messages_and_pattern string_merging \
2144                 "rodata\\.str" assembly {
2145                     const char *var = "String";
2146                 } {-O2}]
2147 }
2148
2149 # Return 1 if target has the basic signed and unsigned types in
2150 # <stdint.h>, 0 otherwise.
2151
2152 proc check_effective_target_stdint_types { } {
2153     return [check_no_compiler_messages stdint_types assembly {
2154         #include <stdint.h>
2155         int8_t a; int16_t b; int32_t c; int64_t d;
2156         uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2157     }]
2158 }
2159
2160 # Return 1 if programs are intended to be run on a simulator
2161 # (i.e. slowly) rather than hardware (i.e. fast).
2162
2163 proc check_effective_target_simulator { } {
2164
2165     # All "src/sim" simulators set this one.
2166     if [board_info target exists is_simulator] {
2167         return [board_info target is_simulator]
2168     }
2169
2170     # The "sid" simulators don't set that one, but at least they set
2171     # this one.
2172     if [board_info target exists slow_simulator] {
2173         return [board_info target slow_simulator]
2174     }
2175
2176     return 0
2177 }