OSDN Git Service

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