OSDN Git Service

* lib/target-supports.exp (check_effective_target_mips_soft_float):
[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 3 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 GCC; see the file COPYING3.  If not see
16 # <http://www.gnu.org/licenses/>.
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 Tcl command ARGS and seeing if it returns true.
91
92 proc check_cached_effective_target { prop args } {
93     global et_cache
94
95     set target [current_target_name]
96     if {![info exists et_cache($prop,target)]
97         || $et_cache($prop,target) != $target} {
98         verbose "check_cached_effective_target $prop: checking $target" 2
99         set et_cache($prop,target) $target
100         set et_cache($prop,value) [uplevel eval $args]
101     }
102     set value $et_cache($prop,value)
103     verbose "check_cached_effective_target $prop: returning $value for $target" 2
104     return $value
105 }
106
107 # Implement an effective-target check for property PROP by invoking
108 # the compiler and seeing if it prints any messages.  Assume that the
109 # property holds if the compiler doesn't print anything.  The other
110 # arguments are as for get_compiler_messages, starting with TYPE.
111 proc check_no_compiler_messages {prop args} {
112     return [check_cached_effective_target $prop {
113         string match "" [eval get_compiler_messages $prop 0 $args]
114     }]
115 }
116
117 # Similar to check_no_compiler_messages, but also verify that the regular
118 # expression PATTERN matches the compiler's output.
119 proc check_no_messages_and_pattern {prop pattern args} {
120     return [check_cached_effective_target $prop {
121         set results [eval get_compiler_messages $prop 1 $args]
122         expr { [string match "" [lindex $results 0]]
123                && [regexp $pattern [lindex $results 1]] }
124     }]
125 }
126
127 ###############################
128 # proc check_weak_available { }
129 ###############################
130
131 # weak symbols are only supported in some configs/object formats
132 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
133
134 proc check_weak_available { } {
135     global target_triplet
136     global target_cpu
137
138     # All mips targets should support it
139
140     if { [ string first "mips" $target_cpu ] >= 0 } {
141         return 1
142     }
143
144     # All solaris2 targets should support it
145
146     if { [regexp ".*-solaris2.*" $target_triplet] } {
147         return 1
148     }
149
150     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
151
152     if { [regexp "alpha.*osf.*" $target_triplet] } {
153         return 1
154     }
155
156     # Windows targets Cygwin and MingW32 support it
157
158     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
159         return 1
160     }
161
162     # HP-UX 10.X doesn't support it
163
164     if { [istarget "hppa*-*-hpux10*"] } {
165         return 0
166     }
167
168     # ELF and ECOFF support it. a.out does with gas/gld but may also with
169     # other linkers, so we should try it
170
171     set objformat [gcc_target_object_format]
172
173     switch $objformat {
174         elf      { return 1 }
175         ecoff    { return 1 }
176         a.out    { return 1 }
177         mach-o   { return 1 }
178         som      { return 1 }
179         unknown  { return -1 }
180         default  { return 0 }
181     }
182 }
183
184 ###############################
185 # proc check_visibility_available { what_kind }
186 ###############################
187
188 # The visibility attribute is only support in some object formats
189 # This proc returns 1 if it is supported, 0 if not.
190 # The argument is the kind of visibility, default/protected/hidden/internal.
191
192 proc check_visibility_available { what_kind } {
193     global tool
194     global target_triplet
195
196     # On NetWare, support makes no sense.
197     if { [istarget *-*-netware*] } {
198         return 0
199     }
200
201     if [string match "" $what_kind] { set what_kind "hidden" }
202
203     return [check_no_compiler_messages visibility_available_$what_kind object "
204         void f() __attribute__((visibility(\"$what_kind\")));
205         void f() {}
206     "]
207 }
208
209 ###############################
210 # proc check_alias_available { }
211 ###############################
212
213 # Determine if the target toolchain supports the alias attribute.
214
215 # Returns 2 if the target supports aliases.  Returns 1 if the target
216 # only supports weak aliased.  Returns 0 if the target does not
217 # support aliases at all.  Returns -1 if support for aliases could not
218 # be determined.
219
220 proc check_alias_available { } {
221     global alias_available_saved
222     global tool
223
224     if [info exists alias_available_saved] {
225         verbose "check_alias_available  returning saved $alias_available_saved" 2
226     } else {
227         set src alias[pid].c
228         set obj alias[pid].o
229         verbose "check_alias_available  compiling testfile $src" 2
230         set f [open $src "w"]
231         # Compile a small test program.  The definition of "g" is
232         # necessary to keep the Solaris assembler from complaining
233         # about the program.
234         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
235         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
236         close $f
237         set lines [${tool}_target_compile $src $obj object ""]
238         file delete $src
239         remote_file build delete $obj
240
241         if [string match "" $lines] then {
242             # No error messages, everything is OK.
243             set alias_available_saved 2
244         } else {
245             if [regexp "alias definitions not supported" $lines] {
246                 verbose "check_alias_available  target does not support aliases" 2
247
248                 set objformat [gcc_target_object_format]
249
250                 if { $objformat == "elf" } {
251                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
252                     set alias_available_saved -1
253                 } else {
254                     set alias_available_saved 0
255                 }
256             } else {
257                 if [regexp "only weak aliases are supported" $lines] {
258                 verbose "check_alias_available  target supports only weak aliases" 2
259                 set alias_available_saved 1
260                 } else {
261                     set alias_available_saved -1
262                 }
263             }
264         }
265
266         verbose "check_alias_available  returning $alias_available_saved" 2
267     }
268
269     return $alias_available_saved
270 }
271
272 # Returns true if --gc-sections is supported on the target.
273
274 proc check_gc_sections_available { } {
275     global gc_sections_available_saved
276     global tool
277
278     if {![info exists gc_sections_available_saved]} {
279         # Some targets don't support gc-sections despite whatever's
280         # advertised by ld's options.
281         if { [istarget alpha*-*-*]
282              || [istarget ia64-*-*] } {
283             set gc_sections_available_saved 0
284             return 0
285         }
286
287         # elf2flt uses -q (--emit-relocs), which is incompatible with
288         # --gc-sections.
289         if { [board_info target exists ldflags]
290              && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
291             set gc_sections_available_saved 0
292             return 0
293         }
294
295         # VxWorks kernel modules are relocatable objects linked with -r,
296         # while RTP executables are linked with -q (--emit-relocs).
297         # Both of these options are incompatible with --gc-sections.
298         if { [istarget *-*-vxworks*] } {
299             set gc_sections_available_saved 0
300             return 0
301         }
302
303         # Check if the ld used by gcc supports --gc-sections.
304         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
305         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
306         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
307         set ld_output [remote_exec host "$gcc_ld" "--help"]
308         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
309             set gc_sections_available_saved 1
310         } else {
311             set gc_sections_available_saved 0
312         }
313     }
314     return $gc_sections_available_saved
315 }
316
317 # Return true if profiling is supported on the target.
318
319 proc check_profiling_available { test_what } {
320     global profiling_available_saved
321
322     verbose "Profiling argument is <$test_what>" 1
323
324     # These conditions depend on the argument so examine them before
325     # looking at the cache variable.
326
327     # Support for -p on solaris2 relies on mcrt1.o which comes with the
328     # vendor compiler.  We cannot reliably predict the directory where the
329     # vendor compiler (and thus mcrt1.o) is installed so we can't
330     # necessarily find mcrt1.o even if we have it.
331     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
332         return 0
333     }
334
335     # Support for -p on irix relies on libprof1.a which doesn't appear to
336     # exist on any irix6 system currently posting testsuite results.
337     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
338     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
339     if { [istarget mips*-*-irix*]
340     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
341         return 0
342     }
343
344     # At present, there is no profiling support on NetWare.
345     if { [istarget *-*-netware*] } {
346         return 0
347     }
348
349     # uClibc does not have gcrt1.o.
350     if { [check_effective_target_uclibc]
351          && ([lindex $test_what 1] == "-p"
352              || [lindex $test_what 1] == "-pg") } {
353         return 0
354     }
355
356     # Now examine the cache variable.
357     if {![info exists profiling_available_saved]} {
358         # Some targets don't have any implementation of __bb_init_func or are
359         # missing other needed machinery.
360         if { [istarget mmix-*-*]
361              || [istarget arm*-*-eabi*]
362              || [istarget arm*-*-elf]
363              || [istarget arm*-*-symbianelf*]
364              || [istarget bfin-*-*]
365              || [istarget powerpc-*-eabi*]
366              || [istarget strongarm*-*-elf]
367              || [istarget xscale*-*-elf]
368              || [istarget cris-*-*]
369              || [istarget fido-*-elf]
370              || [istarget h8300-*-*]
371              || [istarget m32c-*-elf]
372              || [istarget m68k-*-elf]
373              || [istarget m68k-*-uclinux*]
374              || [istarget mips*-*-elf*]
375              || [istarget xtensa-*-elf]
376              || [istarget *-*-vxworks*]
377              || [istarget *-*-windiss] } {
378             set profiling_available_saved 0
379         } else {
380             set profiling_available_saved 1
381         }
382     }
383
384     return $profiling_available_saved
385 }
386
387 # Return 1 if target has packed layout of structure members by
388 # default, 0 otherwise.  Note that this is slightly different than
389 # whether the target has "natural alignment": both attributes may be
390 # false.
391
392 proc check_effective_target_default_packed { } {
393     return [check_no_compiler_messages default_packed assembly {
394         struct x { char a; long b; } c;
395         int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
396     }]
397 }
398
399 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
400 # documentation, where the test also comes from.
401
402 proc check_effective_target_pcc_bitfield_type_matters { } {
403     # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
404     # bitfields, but let's stick to the example code from the docs.
405     return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
406         struct foo1 { char x; char :0; char y; };
407         struct foo2 { char x; int :0; char y; };
408         int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
409     }]
410 }
411
412 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
413 #
414 # This won't change for different subtargets so cache the result.
415
416 proc check_effective_target_tls {} {
417     global et_tls_saved
418     global tool
419
420     if [info exists et_tls_saved] {
421         verbose "check_effective_target_tls: using cached result" 2
422     } else {
423         set et_tls_saved 0
424
425         set src tls[pid].c
426         set asm tls[pid].S
427         verbose "check_effective_target_tls: compiling testfile $src" 2
428         set f [open $src "w"]
429         # Compile a small test program.  Make sure that we test accesses
430         # as well as declarations.  
431         puts $f "__thread int i;\n"
432         puts $f "int f (void) { return i; }\n"
433         puts $f "void g (int j) { i = j; }\n"
434         close $f
435
436         # Test for thread-local data supported by the platform.
437         set comp_output \
438             [${tool}_target_compile $src $asm assembly ""]
439         file delete $src
440         if { [string match "" $comp_output] } {
441             # No error messages, everything is OK.
442             set et_tls_saved 1
443         }
444         remove-build-file $asm
445     }
446     verbose "check_effective_target_tls: returning $et_tls_saved" 2
447     return $et_tls_saved
448 }
449
450 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
451 #
452 # This won't change for different subtargets so cache the result.
453
454 proc check_effective_target_tls_native {} {
455     global et_tls_native_saved
456     global tool
457
458     if [info exists et_tls_saved] {
459         verbose "check_effective_target_tls_native: using cached result" 2
460     } else {
461         set et_tls_native_saved 0
462
463         set src tls[pid].c
464         set asm tls[pid].S
465         verbose "check_effective_target_tls_native: compiling testfile $src" 2
466         set f [open $src "w"]
467         # Compile a small test program.  Make sure that we test accesses
468         # as well as declarations.  
469         puts $f "__thread int i;\n"
470         puts $f "int f (void) { return i; }\n"
471         puts $f "void g (int j) { i = j; }\n"
472         close $f
473
474         # Test for thread-local data supported by the platform.
475         set comp_output [${tool}_target_compile $src $asm assembly ""]
476         file delete $src
477         if { [string match "" $comp_output] } {
478             # No error messages, everything is OK.
479             set fd [open $asm r]
480             set text [read $fd]
481             close $fd
482             if { [string match "*emutls*" $text]} {
483                 set et_tls_native_saved 0
484             } else {
485                 set et_tls_native_saved 1
486             }
487         }
488         remove-build-file $asm
489     }
490     verbose "check_effective_target_tls_native: returning $et_tls_native_saved" 2
491     return $et_tls_native_saved
492 }
493
494 # Return 1 if TLS executables can run correctly, 0 otherwise.
495 #
496 # This won't change for different subtargets so cache the result.
497
498 proc check_effective_target_tls_runtime {} {
499     global et_tls_runtime_saved
500     global tool
501
502     if [info exists et_tls_runtime_saved] {
503         verbose "check_effective_target_tls_runtime: using cached result" 2
504     } else {
505         set et_tls_runtime_saved 0
506
507         set src tls_runtime[pid].c
508         set exe tls_runtime[pid].x
509         verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
510         set f [open $src "w"]
511         # Compile a small test program.
512         puts $f "__thread int thr = 0;\n"
513         puts $f "int main(void)\n {\n return thr;\n}"
514         close $f
515
516         set comp_output \
517             [${tool}_target_compile $src $exe executable ""]
518         file delete $src
519
520         if [string match "" $comp_output] then {
521             # No error messages, everything is OK.
522
523             set result [remote_load target "./$exe" "" ""]
524             set status [lindex $result 0]
525             remote_file build delete $exe
526
527             verbose "check_effective_target_tls_runtime status is <$status>" 2
528
529             if { $status == "pass" } {
530                 set et_tls_runtime_saved 1
531             }
532
533             verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
534         }
535     }
536
537     return $et_tls_runtime_saved
538 }
539
540 # Return 1 if compilation with -fopenmp is error-free for trivial
541 # code, 0 otherwise.
542
543 proc check_effective_target_fopenmp {} {
544     return [check_no_compiler_messages fopenmp object {
545         void foo (void) { }
546     } "-fopenmp"]
547 }
548
549 # Return 1 if the target supports -fstack-protector
550 proc check_effective_target_fstack_protector {} {
551     global tool
552     set result ""
553
554     set src stack_prot[pid].c
555     set exe stack_prot[pid].x
556
557     verbose "check_effective_target_fstack_protector compiling testfile $src" 2
558
559     set f [open $src "w"]
560     # Compile a small test program.
561     puts $f "int main (void)\n { return 0; }\n"
562     close $f
563
564     set opts "additional_flags=-fstack-protector"
565     set lines [${tool}_target_compile $src $exe executable "$opts" ]
566     file delete $src
567
568     if [string match "" $lines] then {
569         # No error messages, everything is OK.
570         set result [${tool}_load "./$exe" "" ""]
571         set status [lindex $result 0]
572         remote_file build delete $exe
573         verbose "check_iconv_available status is <$status>" 2
574
575         if { $status == "pass" } then {
576             return 1
577         }
578     }
579     return 0
580 }
581
582 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
583 # for trivial code, 0 otherwise.
584
585 proc check_effective_target_freorder {} {
586     return [check_no_compiler_messages freorder object {
587         void foo (void) { }
588     } "-freorder-blocks-and-partition"]
589 }
590
591 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
592 # emitted, 0 otherwise.  Whether a shared library can actually be built is
593 # out of scope for this test.
594
595 proc check_effective_target_fpic { } {
596     # Note that M68K has a multilib that supports -fpic but not
597     # -fPIC, so we need to check both.  We test with a program that
598     # requires GOT references.
599     foreach arg {fpic fPIC} {
600         if [check_no_compiler_messages $arg object {
601             extern int foo (void); extern int bar;
602             int baz (void) { return foo () + bar; }
603         } "-$arg"] {
604             return 1
605         }
606     }
607     return 0
608 }
609
610 # Return true if the target supports -mpaired-single (as used on MIPS).
611
612 proc check_effective_target_mpaired_single { } {
613     return [check_no_compiler_messages mpaired_single object {
614         void foo (void) { }
615     } "-mpaired-single"]
616 }
617
618 # Return true if the target has access to FPU instructions.
619
620 proc check_effective_target_hard_float { } {
621     return [check_no_compiler_messages hard_float assembly {
622         #if ((defined __mips \
623               && (defined __mips_soft_float || defined __mips16)) \
624              || (defined __xtensa__ && defined __XTENSA_SOFT_FLOAT__))
625         #error FOO
626         #endif
627     }]
628 }
629
630 # Return true if the target is a 64-bit MIPS target.
631
632 proc check_effective_target_mips64 { } {
633     return [check_no_compiler_messages mips64 assembly {
634         #ifndef __mips64
635         #error FOO
636         #endif
637     }]
638 }
639
640 # Return true if the target is a MIPS target that does not produce
641 # MIPS16 code.
642
643 proc check_effective_target_nomips16 { } {
644     return [check_no_compiler_messages nomips16 object {
645         #ifndef __mips
646         #error FOO
647         #else
648         /* A cheap way of testing for -mflip-mips16.  */
649         void foo (void) { asm ("addiu $20,$20,1"); }
650         void bar (void) { asm ("addiu $20,$20,1"); }
651         #endif
652     }]
653 }
654
655 # Add the options needed for MIPS16 function attributes.  At the moment,
656 # we don't support MIPS16 PIC.
657
658 proc add_options_for_mips16_attribute { flags } {
659     return "$flags -mno-abicalls -fno-pic"
660 }
661
662 # Return true if we can force a mode that allows MIPS16 code generation.
663 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
664 # for o32 and o64.
665
666 proc check_effective_target_mips16_attribute { } {
667     return [check_no_compiler_messages mips16_attribute assembly {
668         #ifdef PIC
669         #error FOO
670         #endif
671         #if defined __mips_hard_float \
672             && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
673             && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
674         #error FOO
675         #endif
676     } [add_options_for_mips16_attribute ""]]
677 }
678
679 # Return 1 if the current multilib does not generate PIC by default.
680
681 proc check_effective_target_nonpic { } {
682     return [check_no_compiler_messages nonpic assembly {
683         #if __PIC__
684         #error FOO
685         #endif
686     }]
687 }
688
689 # Return 1 if the target does not use a status wrapper.
690
691 proc check_effective_target_unwrapped { } {
692     if { [target_info needs_status_wrapper] != "" \
693              && [target_info needs_status_wrapper] != "0" } {
694         return 0
695     }
696     return 1
697 }
698
699 # Return true if iconv is supported on the target. In particular IBM1047.
700
701 proc check_iconv_available { test_what } {
702     global tool
703     global libiconv
704
705     set result ""
706
707     set src iconv[pid].c
708     set exe iconv[pid].x
709     verbose "check_iconv_available compiling testfile $src" 2
710     set f [open $src "w"]
711     # Compile a small test program.
712     puts $f "#include <iconv.h>\n"
713     puts $f "int main (void)\n {\n iconv_t cd; \n"
714     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
715     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
716     puts $f "return 0;\n}"
717     close $f
718
719     # If the tool configuration file has not set libiconv, try "-liconv"
720     if { ![info exists libiconv] } {
721         set libiconv "-liconv"
722     }
723     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
724     file delete $src
725
726     if [string match "" $lines] then {
727         # No error messages, everything is OK.
728
729         set result [${tool}_load "./$exe" "" ""]
730         set status [lindex $result 0]
731         remote_file build delete $exe
732
733         verbose "check_iconv_available status is <$status>" 2
734
735         if { $status == "pass" } then {
736             return 1
737         }
738     }
739
740     return 0
741 }
742
743 # Return true if named sections are supported on this target.
744
745 proc check_named_sections_available { } {
746     return [check_no_compiler_messages named_sections assembly {
747         int __attribute__ ((section("whatever"))) foo;
748     }]
749 }
750
751 # Return 1 if the target supports Fortran real kinds larger than real(8),
752 # 0 otherwise.
753 #
754 # When the target name changes, replace the cached result.
755
756 proc check_effective_target_fortran_large_real { } {
757     global et_fortran_large_real_saved
758     global et_fortran_large_real_target_name
759     global tool
760
761     if { ![info exists et_fortran_large_real_target_name] } {
762         set et_fortran_large_real_target_name ""
763     }
764
765     # If the target has changed since we set the cached value, clear it.
766     set current_target [current_target_name]
767     if { $current_target != $et_fortran_large_real_target_name } {
768         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
769         set et_fortran_large_real_target_name $current_target
770         if [info exists et_fortran_large_real_saved] {
771             verbose "check_effective_target_fortran_large_real: removing cached result" 2
772             unset et_fortran_large_real_saved
773         }
774     }
775
776     if [info exists et_fortran_large_real_saved] {
777         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
778     } else {
779         set et_fortran_large_real_saved 0
780
781         # Set up, compile, and execute a test program using large real
782         # kinds.  Include the current process ID in the file names to
783         # prevent conflicts with invocations for multiple testsuites.
784         set src real[pid].f90
785         set exe real[pid].x
786
787         set f [open $src "w"]
788         puts $f "integer,parameter :: k = &"
789         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
790         puts $f "real(kind=k) :: x"
791         puts $f "x = cos (x);"
792         puts $f "end"
793         close $f
794
795         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
796         set lines [${tool}_target_compile $src $exe executable ""]
797         file delete $src
798
799         if [string match "" $lines] then {
800             # No error message, compilation succeeded.
801             remote_file build delete $exe
802             set et_fortran_large_real_saved 1
803         }
804     }
805
806     return $et_fortran_large_real_saved
807 }
808
809 # Return 1 if the target supports Fortran integer kinds larger than
810 # integer(8), 0 otherwise.
811 #
812 # When the target name changes, replace the cached result.
813
814 proc check_effective_target_fortran_large_int { } {
815     global et_fortran_large_int_saved
816     global et_fortran_large_int_target_name
817     global tool
818
819     if { ![info exists et_fortran_large_int_target_name] } {
820         set et_fortran_large_int_target_name ""
821     }
822
823     # If the target has changed since we set the cached value, clear it.
824     set current_target [current_target_name]
825     if { $current_target != $et_fortran_large_int_target_name } {
826         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
827         set et_fortran_large_int_target_name $current_target
828         if [info exists et_fortran_large_int_saved] {
829             verbose "check_effective_target_fortran_large_int: removing cached result" 2
830             unset et_fortran_large_int_saved
831         }
832     }
833
834     if [info exists et_fortran_large_int_saved] {
835         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
836     } else {
837         set et_fortran_large_int_saved 0
838
839         # Set up, compile, and execute a test program using large integer
840         # kinds.  Include the current process ID in the file names to
841         # prevent conflicts with invocations for multiple testsuites.
842         set src int[pid].f90
843         set exe int[pid].x
844
845         set f [open $src "w"]
846         puts $f "integer,parameter :: k = &"
847         puts $f "  selected_int_kind (range (0_8) + 1)"
848         puts $f "integer(kind=k) :: i"
849         puts $f "end"
850         close $f
851
852         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
853         set lines [${tool}_target_compile $src $exe executable ""]
854         file delete $src
855
856         if [string match "" $lines] then {
857             # No error message, compilation succeeded.
858             remote_file build delete $exe
859             set et_fortran_large_int_saved 1
860         }
861     }
862
863     return $et_fortran_large_int_saved
864 }
865
866 # Return 1 if we can statically link libgfortran, 0 otherwise.
867 #
868 # When the target name changes, replace the cached result.
869
870 proc check_effective_target_static_libgfortran { } {
871     global et_static_libgfortran
872     global et_static_libgfortran_target_name
873     global tool
874
875     if { ![info exists et_static_libgfortran_target_name] } {
876        set et_static_libgfortran_target_name ""
877     }
878
879     # If the target has changed since we set the cached value, clear it.
880     set current_target [current_target_name]
881     if { $current_target != $et_static_libgfortran_target_name } {
882        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
883        set et_static_libgfortran_target_name $current_target
884        if [info exists et_static_libgfortran_saved] {
885            verbose "check_effective_target_static_libgfortran: removing cached result" 2
886            unset et_static_libgfortran_saved
887        }
888     }
889
890     if [info exists et_static_libgfortran_saved] {
891        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
892     } else {
893        set et_static_libgfortran_saved 0
894
895        # Set up, compile, and execute a test program using static linking.
896        # Include the current process ID in the file names to prevent
897        # conflicts with invocations for multiple testsuites.
898        set opts "additional_flags=-static"
899        set src static[pid].f
900        set exe static[pid].x
901
902        set f [open $src "w"]
903        puts $f "      print *, 'test'"
904        puts $f "      end"
905        close $f
906
907        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
908        set lines [${tool}_target_compile $src $exe executable "$opts"]
909        file delete $src
910
911        if [string match "" $lines] then {
912            # No error message, compilation succeeded.
913            remote_file build delete $exe
914            set et_static_libgfortran_saved 1
915        }
916     }
917
918     return $et_static_libgfortran_saved
919 }
920
921 # Return 1 if the target supports executing 750CL paired-single instructions, 0
922 # otherwise.  Cache the result.
923
924 proc check_750cl_hw_available { } {
925     global 750cl_hw_available_saved
926     global tool
927
928     if [info exists 750cl_hw_available_saved] {
929         verbose "check_hw_available  returning saved $750cl_hw_available_saved" 2
930     } else {
931         set 750cl_hw_available_saved 0
932
933         # If this is not the right target then we can quit.
934         if { ![istarget powerpc-*paired*] } {
935             verbose "check_hw_available  returning 0" 2
936             return $750cl_hw_available_saved
937         }
938
939         # Set up, compile, and execute a test program containing paired-single
940         # instructions.  Include the current process ID in the file
941         # names to prevent conflicts with invocations for multiple
942         # testsuites.
943         set src 750cl[pid].c
944         set exe 750cl[pid].x
945
946         set f [open $src "w"]
947         puts $f "int main() {"
948         puts $f "#ifdef __MACH__"
949         puts $f "  asm volatile (\"ps_mul v0,v0,v0\");"
950         puts $f "#else"
951         puts $f "  asm volatile (\"ps_mul 0,0,0\");"
952         puts $f "#endif"
953         puts $f "  return 0; }"
954         close $f
955
956         verbose "check_750cl_hw_available  compiling testfile $src" 2
957         set lines [${tool}_target_compile $src $exe executable "-mpaired"]
958         file delete $src
959
960         if [string match "" $lines] then {
961             # No error message, compilation succeeded.
962             set result [${tool}_load "./$exe" "" ""]
963             set status [lindex $result 0]
964             remote_file build delete $exe
965             verbose "check_750cl_hw_available testfile status is <$status>" 2
966
967             if { $status == "pass" } then {
968                 set 750cl_hw_available_saved 1
969             }
970         } else {
971             verbose "check_750cl_hw_availalble testfile compilation failed" 2
972         }
973     }
974     return $750cl_hw_available_saved
975 }
976
977
978 # Return 1 if the target supports executing AltiVec instructions, 0
979 # otherwise.  Cache the result.
980
981 proc check_vmx_hw_available { } {
982     global vmx_hw_available_saved
983     global tool
984
985     if [info exists vmx_hw_available_saved] {
986         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
987     } else {
988         set vmx_hw_available_saved 0
989
990         # Some simulators are known to not support VMX instructions.
991         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
992             verbose "check_hw_available  returning 0" 2
993             return $vmx_hw_available_saved
994         }
995
996         # Set up, compile, and execute a test program containing VMX
997         # instructions.  Include the current process ID in the file
998         # names to prevent conflicts with invocations for multiple
999         # testsuites.
1000         set src vmx[pid].c
1001         set exe vmx[pid].x
1002
1003         set f [open $src "w"]
1004         puts $f "int main() {"
1005         puts $f "#ifdef __MACH__"
1006         puts $f "  asm volatile (\"vor v0,v0,v0\");"
1007         puts $f "#else"
1008         puts $f "  asm volatile (\"vor 0,0,0\");"
1009         puts $f "#endif"
1010         puts $f "  return 0; }"
1011         close $f
1012
1013         # Most targets don't require special flags for this test case, but
1014         # Darwin does.
1015         if { [istarget *-*-darwin*] 
1016              || [istarget *-*-aix*] } {
1017           set opts "additional_flags=-maltivec"
1018         } else {
1019           set opts ""
1020         }
1021
1022         verbose "check_vmx_hw_available  compiling testfile $src" 2
1023         set lines [${tool}_target_compile $src $exe executable "$opts"]
1024         file delete $src
1025
1026         if [string match "" $lines] then {
1027             # No error message, compilation succeeded.
1028             set result [${tool}_load "./$exe" "" ""]
1029             set status [lindex $result 0]
1030             remote_file build delete $exe
1031             verbose "check_vmx_hw_available testfile status is <$status>" 2
1032
1033             if { $status == "pass" } then {
1034                 set vmx_hw_available_saved 1
1035             }
1036         } else {
1037             verbose "check_vmx_hw_availalble testfile compilation failed" 2
1038         }
1039     }
1040
1041     return $vmx_hw_available_saved
1042 }
1043
1044 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1045 # complex float arguments.  This affects gfortran tests that call cabsf
1046 # in libm built by an earlier compiler.  Return 1 if libm uses the same
1047 # argument passing as the compiler under test, 0 otherwise.
1048 #
1049 # When the target name changes, replace the cached result.
1050
1051 proc check_effective_target_broken_cplxf_arg { } {
1052     global et_broken_cplxf_arg_saved
1053     global et_broken_cplxf_arg_target_name
1054     global tool
1055
1056     # Skip the work for targets known not to be affected.
1057     if { ![istarget powerpc64-*-linux*] } {
1058         return 0
1059     } elseif { [is-effective-target ilp32] } {
1060         return 0
1061     }
1062
1063     if { ![info exists et_broken_cplxf_arg_target_name] } {
1064         set et_broken_cplxf_arg_target_name ""
1065     }
1066
1067     # If the target has changed since we set the cached value, clear it.
1068     set current_target [current_target_name]
1069     if { $current_target != $et_broken_cplxf_arg_target_name } {
1070         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
1071         set et_broken_cplxf_arg_target_name $current_target
1072         if [info exists et_broken_cplxf_arg_saved] {
1073             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
1074             unset et_broken_cplxf_arg_saved
1075         }
1076     }
1077
1078     if [info exists et_broken_cplxf_arg_saved] {
1079         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
1080     } else {
1081         set et_broken_cplxf_arg_saved 0
1082         # This is only known to affect one target.
1083         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
1084             set et_broken_cplxf_arg_saved 0
1085             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
1086             return $et_broken_cplxf_arg_saved
1087         }
1088
1089         # Set up, compile, and execute a C test program that calls cabsf.
1090         set src cabsf[pid].c
1091         set exe cabsf[pid].x
1092
1093         set f [open $src "w"]
1094         puts $f "#include <complex.h>"
1095         puts $f "extern void abort (void);"
1096         puts $f "float fabsf (float);"
1097         puts $f "float cabsf (_Complex float);"
1098         puts $f "int main ()"
1099         puts $f "{"
1100         puts $f "  _Complex float cf;"
1101         puts $f "  float f;"
1102         puts $f "  cf = 3 + 4.0fi;"
1103         puts $f "  f = cabsf (cf);"
1104         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
1105         puts $f "  return 0;"
1106         puts $f "}"
1107         close $f
1108
1109         set lines [${tool}_target_compile $src $exe executable "-lm"]
1110         file delete $src
1111
1112         if [string match "" $lines] {
1113             # No error message, compilation succeeded.
1114             set result [${tool}_load "./$exe" "" ""]
1115             set status [lindex $result 0]
1116             remote_file build delete $exe
1117
1118             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1119
1120             if { $status != "pass" } {
1121                 set et_broken_cplxf_arg_saved 1
1122             }
1123         } else {
1124             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1125         }
1126     }
1127     return $et_broken_cplxf_arg_saved
1128 }
1129
1130 proc check_alpha_max_hw_available { } {
1131     global alpha_max_hw_available_saved
1132     global tool
1133
1134     if [info exists alpha_max_hw_available_saved] {
1135         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1136     } else {
1137         set alpha_max_hw_available_saved 0
1138
1139         # Set up, compile, and execute a test program probing bit 8 of the
1140         # architecture mask, which indicates presence of MAX instructions.
1141         set src max[pid].c
1142         set exe max[pid].x
1143
1144         set f [open $src "w"]
1145         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1146         close $f
1147
1148         verbose "check_alpha_max_hw_available compiling testfile $src" 2
1149         set lines [${tool}_target_compile $src $exe executable ""]
1150         file delete $src
1151
1152         if [string match "" $lines] then {
1153             # No error message, compilation succeeded.
1154             set result [${tool}_load "./$exe" "" ""]
1155             set status [lindex $result 0]
1156             remote_file build delete $exe
1157             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1158
1159             if { $status == "pass" } then {
1160                 set alpha_max_hw_available_saved 1
1161             }
1162         } else {
1163             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1164         }
1165     }
1166
1167     return $alpha_max_hw_available_saved
1168 }
1169
1170 # Returns true iff the FUNCTION is available on the target system.
1171 # (This is essentially a Tcl implementation of Autoconf's
1172 # AC_CHECK_FUNC.)
1173
1174 proc check_function_available { function } {
1175     set var "${function}_available_saved"
1176     global $var
1177     global tool
1178
1179     if {![info exists $var]} {
1180         # Assume it exists.
1181         set $var 1
1182         # Check to make sure.
1183         set src "function[pid].c"
1184         set exe "function[pid].exe"
1185
1186         set f [open $src "w"]
1187         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1188         puts $f "char $function ();\n"
1189         puts $f "int main () { $function (); }"
1190         close $f
1191
1192         set lines [${tool}_target_compile $src $exe executable ""]
1193         file delete $src
1194         file delete $exe
1195
1196         if {![string match "" $lines]} then {
1197             set $var 0
1198             verbose -log "$function is not available"
1199         } else {
1200             verbose -log "$function is available"
1201         }
1202     }
1203
1204     eval return \$$var
1205 }
1206
1207 # Returns true iff "fork" is available on the target system.
1208
1209 proc check_fork_available {} {
1210     return [check_function_available "fork"]
1211 }
1212
1213 # Returns true iff "mkfifo" is available on the target system.
1214
1215 proc check_mkfifo_available {} {
1216     if {[istarget *-*-cygwin*]} {
1217        # Cygwin has mkfifo, but support is incomplete.
1218        return 0
1219      }
1220
1221     return [check_function_available "mkfifo"]
1222 }
1223
1224 # Returns true iff "__cxa_atexit" is used on the target system.
1225
1226 proc check_cxa_atexit_available { } {
1227     global et_cxa_atexit
1228     global et_cxa_atexit_target_name
1229     global tool 
1230
1231     if { ![info exists et_cxa_atexit_target_name] } {
1232         set et_cxa_atexit_target_name ""
1233     }
1234
1235     # If the target has changed since we set the cached value, clear it.
1236     set current_target [current_target_name]
1237     if { $current_target != $et_cxa_atexit_target_name } {
1238         verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1239         set et_cxa_atexit_target_name $current_target
1240         if [info exists et_cxa_atexit] {
1241             verbose "check_cxa_atexit_available: removing cached result" 2
1242             unset et_cxa_atexit
1243         }
1244     }
1245
1246     if [info exists et_cxa_atexit] {
1247         verbose "check_cxa_atexit_available: using cached result" 2
1248     } elseif { [istarget "hppa*-*-hpux10*"] } {
1249         # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1250         set et_cxa_atexit 0
1251     } else {
1252         set et_cxa_atexit 0
1253
1254         # Set up, compile, and execute a C++ test program that depends
1255         # on correct ordering of static object destructors. This is
1256         # indicative of the presence and use of __cxa_atexit.
1257         set src cxaatexit[pid].cc
1258         set exe cxaatexit[pid].x
1259
1260         set f [open $src "w"]
1261         puts $f "#include <stdlib.h>"
1262         puts $f "static unsigned int count;"
1263         puts $f "struct X"
1264         puts $f "{"
1265         puts $f "  X() { count = 1; }"
1266         puts $f "  ~X()"
1267         puts $f "  {"
1268         puts $f "    if (count != 3)"
1269         puts $f "      exit(1);"
1270         puts $f "    count = 4;"
1271         puts $f "  }"
1272         puts $f "};"
1273         puts $f "void f()"
1274         puts $f "{"
1275         puts $f "  static X x;"
1276         puts $f "}"
1277         puts $f "struct Y"
1278         puts $f "{"
1279         puts $f "  Y() { f(); count = 2; }"
1280         puts $f "  ~Y()"
1281         puts $f "  {"
1282         puts $f "    if (count != 2)"
1283         puts $f "      exit(1);"
1284         puts $f "    count = 3;"
1285         puts $f "  }"
1286         puts $f "};"
1287         puts $f "Y y;"
1288         puts $f "int main()"
1289         puts $f "{ return 0; }"
1290         close $f
1291
1292         set lines [${tool}_target_compile $src $exe executable ""]
1293         file delete $src
1294
1295         if [string match "" $lines] {
1296             # No error message, compilation succeeded.
1297             set result [${tool}_load "./$exe" "" ""]
1298             set status [lindex $result 0]
1299             remote_file build delete $exe
1300
1301             verbose "check_cxa_atexit_available: status is <$status>" 2
1302
1303             if { $status == "pass" } {
1304                 set et_cxa_atexit 1
1305             }
1306         } else {
1307             verbose "check_cxa_atexit_available: compilation failed" 2
1308         }
1309     }
1310     return $et_cxa_atexit
1311 }
1312
1313
1314 # Return 1 if we're generating 32-bit code using default options, 0
1315 # otherwise.
1316
1317 proc check_effective_target_ilp32 { } {
1318     return [check_no_compiler_messages ilp32 object {
1319         int dummy[sizeof (int) == 4
1320                   && sizeof (void *) == 4
1321                   && sizeof (long) == 4 ? 1 : -1];
1322     }]
1323 }
1324
1325 # Return 1 if we're generating 32-bit or larger integers using default
1326 # options, 0 otherwise.
1327
1328 proc check_effective_target_int32plus { } {
1329     return [check_no_compiler_messages int32plus object {
1330         int dummy[sizeof (int) >= 4 ? 1 : -1];
1331     }]
1332 }
1333
1334 # Return 1 if we're generating 32-bit or larger pointers using default
1335 # options, 0 otherwise.
1336
1337 proc check_effective_target_ptr32plus { } {
1338     return [check_no_compiler_messages ptr32plus object {
1339         int dummy[sizeof (void *) >= 4 ? 1 : -1];
1340     }]
1341 }
1342
1343 # Return 1 if we support 32-bit or larger array and structure sizes
1344 # using default options, 0 otherwise.
1345
1346 proc check_effective_target_size32plus { } {
1347     return [check_no_compiler_messages size32plus object {
1348         char dummy[65537];
1349     }]
1350 }
1351
1352 # Returns 1 if we're generating 16-bit or smaller integers with the
1353 # default options, 0 otherwise.
1354
1355 proc check_effective_target_int16 { } {
1356     return [check_no_compiler_messages int16 object {
1357         int dummy[sizeof (int) < 4 ? 1 : -1];
1358     }]
1359 }
1360
1361 # Return 1 if we're generating 64-bit code using default options, 0
1362 # otherwise.
1363
1364 proc check_effective_target_lp64 { } {
1365     return [check_no_compiler_messages lp64 object {
1366         int dummy[sizeof (int) == 4
1367                   && sizeof (void *) == 8
1368                   && sizeof (long) == 8 ? 1 : -1];
1369     }]
1370 }
1371
1372 # Return 1 if the target supports long double larger than double,
1373 # 0 otherwise.
1374
1375 proc check_effective_target_large_long_double { } {
1376     return [check_no_compiler_messages large_long_double object {
1377         int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1378     }]
1379 }
1380
1381 # Return 1 if the target supports compiling fixed-point,
1382 # 0 otherwise.
1383
1384 proc check_effective_target_fixed_point { } {
1385     return [check_no_compiler_messages fixed_point object {
1386         _Sat _Fract x; _Sat _Accum y;
1387     }]
1388 }
1389
1390 # Return 1 if the target supports compiling decimal floating point,
1391 # 0 otherwise.
1392
1393 proc check_effective_target_dfp_nocache { } {
1394     verbose "check_effective_target_dfp_nocache: compiling source" 2
1395     set ret [string match "" [get_compiler_messages dfp 0 object {
1396         _Decimal32 x; _Decimal64 y; _Decimal128 z;
1397     }]]
1398     verbose "check_effective_target_dfp_nocache: returning $ret" 2
1399     return $ret
1400 }
1401
1402 proc check_effective_target_dfprt_nocache { } {
1403     global tool
1404
1405     set ret 0
1406
1407     verbose "check_effective_target_dfprt_nocache: compiling source" 2
1408     # Set up, compile, and execute a test program containing decimal
1409     # float operations.
1410     set src dfprt[pid].c
1411     set exe dfprt[pid].x
1412
1413     set f [open $src "w"]
1414     puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1415     puts $f "int main () { z = x + y; return 0; }"
1416     close $f
1417
1418     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1419     set lines [${tool}_target_compile $src $exe executable ""]
1420     file delete $src
1421
1422     if [string match "" $lines] then {
1423         # No error message, compilation succeeded.
1424         set result [${tool}_load "./$exe" "" ""]
1425         set status [lindex $result 0]
1426         remote_file build delete $exe
1427         verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1428         if { $status == "pass" } then {
1429             set ret 1
1430         }
1431     }
1432     return $ret
1433     verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1434 }
1435
1436 # Return 1 if the target supports compiling Decimal Floating Point,
1437 # 0 otherwise.
1438 #
1439 # This won't change for different subtargets so cache the result.
1440
1441 proc check_effective_target_dfp { } {
1442     global et_dfp_saved
1443
1444     if [info exists et_dfp_saved] {
1445         verbose "check_effective_target_dfp: using cached result" 2
1446     } else {
1447         set et_dfp_saved [check_effective_target_dfp_nocache]
1448     }
1449     verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1450     return $et_dfp_saved
1451 }
1452
1453 # Return 1 if the target supports linking and executing Decimal Floating
1454 # Point, # 0 otherwise.
1455 #
1456 # This won't change for different subtargets so cache the result.
1457
1458 proc check_effective_target_dfprt { } {
1459     global et_dfprt_saved
1460     global tool
1461
1462     if [info exists et_dfprt_saved] {
1463         verbose "check_effective_target_dfprt: using cached result" 2
1464     } else {
1465         set et_dfprt_saved [check_effective_target_dfprt_nocache]
1466     }
1467     verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1468     return $et_dfprt_saved
1469 }
1470
1471 # Return 1 if the target needs a command line argument to enable a SIMD
1472 # instruction set.
1473
1474 proc check_effective_target_vect_cmdline_needed { } {
1475     global et_vect_cmdline_needed_saved
1476     global et_vect_cmdline_needed_target_name
1477
1478     if { ![info exists et_vect_cmdline_needed_target_name] } {
1479         set et_vect_cmdline_needed_target_name ""
1480     }
1481
1482     # If the target has changed since we set the cached value, clear it.
1483     set current_target [current_target_name]
1484     if { $current_target != $et_vect_cmdline_needed_target_name } {
1485         verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1486         set et_vect_cmdline_needed_target_name $current_target
1487         if { [info exists et_vect_cmdline_needed_saved] } {
1488             verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1489             unset et_vect_cmdline_needed_saved
1490         }
1491     }
1492
1493     if [info exists et_vect_cmdline_needed_saved] {
1494         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1495     } else {
1496         set et_vect_cmdline_needed_saved 1
1497         if { [istarget ia64-*-*]
1498              || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1499                  && [check_effective_target_lp64])
1500              || ([istarget powerpc*-*-*]
1501                  && ([check_effective_target_powerpc_spe]
1502                      || [check_effective_target_powerpc_altivec]))} {
1503            set et_vect_cmdline_needed_saved 0
1504         }
1505     }
1506
1507     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1508     return $et_vect_cmdline_needed_saved
1509 }
1510
1511 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1512 #
1513 # This won't change for different subtargets so cache the result.
1514
1515 proc check_effective_target_vect_int { } {
1516     global et_vect_int_saved
1517
1518     if [info exists et_vect_int_saved] {
1519         verbose "check_effective_target_vect_int: using cached result" 2
1520     } else {
1521         set et_vect_int_saved 0
1522         if { [istarget i?86-*-*]
1523              || ([istarget powerpc*-*-*]
1524                   && ![istarget powerpc-*-linux*paired*])
1525               || [istarget spu-*-*]
1526               || [istarget x86_64-*-*]
1527               || [istarget sparc*-*-*]
1528               || [istarget alpha*-*-*]
1529               || [istarget ia64-*-*] } {
1530            set et_vect_int_saved 1
1531         }
1532     }
1533
1534     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1535     return $et_vect_int_saved
1536 }
1537
1538 # Return 1 if the target supports int->float conversion 
1539 #
1540
1541 proc check_effective_target_vect_intfloat_cvt { } {
1542     global et_vect_intfloat_cvt_saved
1543
1544     if [info exists et_vect_intfloat_cvt_saved] {
1545         verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1546     } else {
1547         set et_vect_intfloat_cvt_saved 0
1548         if { [istarget i?86-*-*]
1549               || ([istarget powerpc*-*-*]
1550                    && ![istarget powerpc-*-linux*paired*])
1551               || [istarget x86_64-*-*] } {
1552            set et_vect_intfloat_cvt_saved 1
1553         }
1554     }
1555
1556     verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1557     return $et_vect_intfloat_cvt_saved
1558 }
1559
1560
1561 # Return 1 if the target supports float->int conversion
1562 #
1563
1564 proc check_effective_target_vect_floatint_cvt { } {
1565     global et_vect_floatint_cvt_saved
1566
1567     if [info exists et_vect_floatint_cvt_saved] {
1568         verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1569     } else {
1570         set et_vect_floatint_cvt_saved 0
1571         if { [istarget i?86-*-*]
1572               || [istarget x86_64-*-*] } {
1573            set et_vect_floatint_cvt_saved 1
1574         }
1575     }
1576
1577     verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1578     return $et_vect_floatint_cvt_saved
1579 }
1580
1581 # Return 1 is this is an arm target using 32-bit instructions
1582 proc check_effective_target_arm32 { } {
1583     return [check_no_compiler_messages arm32 assembly {
1584         #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1585         #error FOO
1586         #endif
1587     }]
1588 }
1589
1590 # Return 1 if this is an ARM target supporting -mfpu=vfp
1591 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1592 # options.
1593
1594 proc check_effective_target_arm_vfp_ok { } {
1595     if { [check_effective_target_arm32] } {
1596         return [check_no_compiler_messages arm_vfp_ok object {
1597             int dummy;
1598         } "-mfpu=vfp -mfloat-abi=softfp"]
1599     } else {
1600         return 0
1601     }
1602 }
1603
1604 # Return 1 if this is an ARM target supporting -mfpu=neon
1605 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1606 # options.
1607
1608 proc check_effective_target_arm_neon_ok { } {
1609     if { [check_effective_target_arm32] } {
1610         return [check_no_compiler_messages arm_neon_ok object {
1611             int dummy;
1612         } "-mfpu=neon -mfloat-abi=softfp"]
1613     } else {
1614         return 0
1615     }
1616 }
1617
1618 # Return 1 if the target supports executing NEON instructions, 0
1619 # otherwise.  Cache the result.
1620
1621 proc check_effective_target_arm_neon_hw { } {
1622     global arm_neon_hw_available_saved
1623     global tool
1624
1625     if [info exists arm_neon_hw_available_saved] {
1626         verbose "check_arm_neon_hw_available  returning saved $arm_neon_hw_avail
1627 able_saved" 2
1628     } else {
1629         set arm_neon_hw_available_saved 0
1630
1631         # Set up, compile, and execute a test program containing NEON
1632         # instructions.  Include the current process ID in the file
1633         # names to prevent conflicts with invocations for multiple
1634         # testsuites.
1635         set src neon[pid].c
1636         set exe neon[pid].x
1637
1638         set f [open $src "w"]
1639         puts $f "int main() {"
1640         puts $f "  long long a = 0, b = 1;"
1641         puts $f "  asm (\"vorr %P0, %P1, %P2\""
1642         puts $f "       : \"=w\" (a)"
1643         puts $f "       : \"0\" (a), \"w\" (b));"
1644         puts $f "  return (a != 1);"
1645         puts $f "}"
1646         close $f
1647
1648         set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1649
1650         verbose "check_arm_neon_hw_available  compiling testfile $src" 2
1651         set lines [${tool}_target_compile $src $exe executable "$opts"]
1652         file delete $src
1653
1654         if [string match "" $lines] then {
1655             # No error message, compilation succeeded.
1656             set result [${tool}_load "./$exe" "" ""]
1657             set status [lindex $result 0]
1658             remote_file build delete $exe
1659             verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1660
1661             if { $status == "pass" } then {
1662                 set arm_neon_hw_available_saved 1
1663             }
1664         } else {
1665             verbose "check_arm_neon_hw_available testfile compilation failed" 2
1666         }
1667     }
1668
1669     return $arm_neon_hw_available_saved
1670 }
1671
1672 # Return 1 if this is a PowerPC target with floating-point registers.
1673
1674 proc check_effective_target_powerpc_fprs { } {
1675     if { [istarget powerpc*-*-*]
1676          || [istarget rs6000-*-*] } {
1677         return [check_no_compiler_messages powerpc_fprs object {
1678             #ifdef __NO_FPRS__
1679             #error no FPRs
1680             #else
1681             int dummy;
1682             #endif
1683         }]
1684     } else {
1685         return 0
1686     }
1687 }
1688
1689 # Return 1 if this is a PowerPC target supporting -maltivec.
1690
1691 proc check_effective_target_powerpc_altivec_ok { } {
1692     if { ([istarget powerpc*-*-*]
1693          && ![istarget powerpc-*-linux*paired*])
1694          || [istarget rs6000-*-*] } {
1695         # AltiVec is not supported on AIX before 5.3.
1696         if { [istarget powerpc*-*-aix4*]
1697              || [istarget powerpc*-*-aix5.1*] 
1698              || [istarget powerpc*-*-aix5.2*] } {
1699             return 0
1700         }
1701         return [check_no_compiler_messages powerpc_altivec_ok object {
1702             int dummy;
1703         } "-maltivec"]
1704     } else {
1705         return 0
1706     }
1707 }
1708
1709 # Return 1 if this is a PowerPC target with SPE enabled.
1710
1711 proc check_effective_target_powerpc_spe { } {
1712     if { [istarget powerpc*-*-*] } {
1713         return [check_no_compiler_messages powerpc_spe object {
1714             #ifndef __SPE__
1715             #error not SPE
1716             #else
1717             int dummy;
1718             #endif
1719         }]
1720     } else {
1721         return 0
1722     }
1723 }
1724
1725 # Return 1 if this is a PowerPC target with Altivec enabled.
1726
1727 proc check_effective_target_powerpc_altivec { } {
1728     if { [istarget powerpc*-*-*] } {
1729         return [check_no_compiler_messages powerpc_altivec object {
1730             #ifndef __ALTIVEC__
1731             #error not Altivec
1732             #else
1733             int dummy;
1734             #endif
1735         }]
1736     } else {
1737         return 0
1738     }
1739 }
1740
1741 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1742 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables.  Return 1 if the
1743 # test environment appears to run executables on such a simulator.
1744
1745 proc check_effective_target_ultrasparc_hw { } {
1746     global et_ultrasparc_hw_saved
1747     global tool
1748
1749     if [info exists et_ultrasparc_hw_saved] {
1750         verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1751     } else {
1752         set et_ultrasparc_hw_saved 0
1753
1754         # Set up, compile, and execute a simple test program.  The
1755         # program will be compiled with -mcpu=ultrasparc to instruct the
1756         # assembler to produce EM_SPARC32PLUS executables.
1757         set src svect[pid].c
1758         set exe svect[pid].x
1759
1760         set f [open $src "w"]
1761         puts $f "int main() { return 0; }"
1762         close $f
1763
1764         verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1765         set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1766         file delete $src
1767
1768         if [string match "" $lines] then {
1769             # No error message, compilation succeeded.
1770             set result [${tool}_load "./$exe" "" ""]
1771             set status [lindex $result 0]
1772             remote_file build delete $exe
1773             verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1774
1775             if { $status == "pass" } then {
1776                 set et_ultrasparc_hw_saved 1
1777             }
1778         } else {
1779             verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1780         }
1781     }
1782
1783     return $et_ultrasparc_hw_saved
1784 }
1785
1786 # Return 1 if the target supports hardware vector shift operation.
1787
1788 proc check_effective_target_vect_shift { } {
1789     global et_vect_shift_saved
1790
1791     if [info exists et_vect_shift_saved] {
1792         verbose "check_effective_target_vect_shift: using cached result" 2
1793     } else {
1794         set et_vect_shift_saved 0
1795         if { ([istarget powerpc*-*-*]
1796              && ![istarget powerpc-*-linux*paired*])
1797              || [istarget ia64-*-*]
1798              || [istarget i?86-*-*]
1799              || [istarget x86_64-*-*] } {
1800            set et_vect_shift_saved 1
1801         }
1802     }
1803
1804     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1805     return $et_vect_shift_saved
1806 }
1807
1808 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1809 #
1810 # This can change for different subtargets so do not cache the result.
1811
1812 proc check_effective_target_vect_long { } {
1813     if { [istarget i?86-*-*]
1814          || (([istarget powerpc*-*-*] 
1815               && ![istarget powerpc-*-linux*paired*]) 
1816               && [check_effective_target_ilp32])
1817          || [istarget x86_64-*-*]
1818          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1819         set answer 1
1820     } else {
1821         set answer 0
1822     }
1823
1824     verbose "check_effective_target_vect_long: returning $answer" 2
1825     return $answer
1826 }
1827
1828 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1829 #
1830 # This won't change for different subtargets so cache the result.
1831
1832 proc check_effective_target_vect_float { } {
1833     global et_vect_float_saved
1834
1835     if [info exists et_vect_float_saved] {
1836         verbose "check_effective_target_vect_float: using cached result" 2
1837     } else {
1838         set et_vect_float_saved 0
1839         if { [istarget i?86-*-*]
1840               || [istarget powerpc*-*-*]
1841               || [istarget spu-*-*]
1842               || [istarget mipsisa64*-*-*]
1843               || [istarget x86_64-*-*]
1844               || [istarget ia64-*-*] } {
1845            set et_vect_float_saved 1
1846         }
1847     }
1848
1849     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1850     return $et_vect_float_saved
1851 }
1852
1853 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1854 #
1855 # This won't change for different subtargets so cache the result.
1856
1857 proc check_effective_target_vect_double { } {
1858     global et_vect_double_saved
1859
1860     if [info exists et_vect_double_saved] {
1861         verbose "check_effective_target_vect_double: using cached result" 2
1862     } else {
1863         set et_vect_double_saved 0
1864         if { [istarget i?86-*-*]
1865               || [istarget x86_64-*-*] 
1866               || [istarget spu-*-*] } {
1867            set et_vect_double_saved 1
1868         }
1869     }
1870
1871     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1872     return $et_vect_double_saved
1873 }
1874
1875 # Return 1 if the target plus current options does not support a vector
1876 # max instruction on "int", 0 otherwise.
1877 #
1878 # This won't change for different subtargets so cache the result.
1879
1880 proc check_effective_target_vect_no_int_max { } {
1881     global et_vect_no_int_max_saved
1882
1883     if [info exists et_vect_no_int_max_saved] {
1884         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1885     } else {
1886         set et_vect_no_int_max_saved 0
1887         if { [istarget sparc*-*-*]
1888              || [istarget spu-*-*]
1889              || [istarget alpha*-*-*] } {
1890             set et_vect_no_int_max_saved 1
1891         }
1892     }
1893     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1894     return $et_vect_no_int_max_saved
1895 }
1896
1897 # Return 1 if the target plus current options does not support a vector
1898 # add instruction on "int", 0 otherwise.
1899 #
1900 # This won't change for different subtargets so cache the result.
1901
1902 proc check_effective_target_vect_no_int_add { } {
1903     global et_vect_no_int_add_saved
1904
1905     if [info exists et_vect_no_int_add_saved] {
1906         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1907     } else {
1908         set et_vect_no_int_add_saved 0
1909         # Alpha only supports vector add on V8QI and V4HI.
1910         if { [istarget alpha*-*-*] } {
1911             set et_vect_no_int_add_saved 1
1912         }
1913     }
1914     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1915     return $et_vect_no_int_add_saved
1916 }
1917
1918 # Return 1 if the target plus current options does not support vector
1919 # bitwise instructions, 0 otherwise.
1920 #
1921 # This won't change for different subtargets so cache the result.
1922
1923 proc check_effective_target_vect_no_bitwise { } {
1924     global et_vect_no_bitwise_saved
1925
1926     if [info exists et_vect_no_bitwise_saved] {
1927         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1928     } else {
1929         set et_vect_no_bitwise_saved 0
1930     }
1931     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1932     return $et_vect_no_bitwise_saved
1933 }
1934
1935 # Return 1 if the target plus current options supports a vector
1936 # widening summation of *short* args into *int* result, 0 otherwise.
1937 # A target can also support this widening summation if it can support
1938 # promotion (unpacking) from shorts to ints.
1939 #
1940 # This won't change for different subtargets so cache the result.
1941                                                                                                 
1942 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1943     global et_vect_widen_sum_hi_to_si
1944
1945     if [info exists et_vect_widen_sum_hi_to_si_saved] {
1946         verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1947     } else {
1948         set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1949         if { [istarget powerpc*-*-*] 
1950              || [istarget ia64-*-*] } {
1951             set et_vect_widen_sum_hi_to_si_saved 1
1952         }
1953     }
1954     verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1955     return $et_vect_widen_sum_hi_to_si_saved
1956 }
1957
1958 # Return 1 if the target plus current options supports a vector
1959 # widening summation of *char* args into *short* result, 0 otherwise.
1960 # A target can also support this widening summation if it can support
1961 # promotion (unpacking) from chars to shorts.
1962 #
1963 # This won't change for different subtargets so cache the result.
1964                                                                                                 
1965 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1966     global et_vect_widen_sum_qi_to_hi
1967
1968     if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1969         verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1970     } else {
1971         set et_vect_widen_sum_qi_to_hi_saved 0
1972         if { [check_effective_target_vect_unpack] 
1973              || [istarget ia64-*-*] } {
1974             set et_vect_widen_sum_qi_to_hi_saved 1
1975         }
1976     }
1977     verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1978     return $et_vect_widen_sum_qi_to_hi_saved
1979 }
1980
1981 # Return 1 if the target plus current options supports a vector
1982 # widening summation of *char* args into *int* result, 0 otherwise.
1983 #
1984 # This won't change for different subtargets so cache the result.
1985                                                                                                 
1986 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1987     global et_vect_widen_sum_qi_to_si
1988
1989     if [info exists et_vect_widen_sum_qi_to_si_saved] {
1990         verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1991     } else {
1992         set et_vect_widen_sum_qi_to_si_saved 0
1993         if { [istarget powerpc*-*-*] } {
1994             set et_vect_widen_sum_qi_to_si_saved 1
1995         }
1996     }
1997     verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1998     return $et_vect_widen_sum_qi_to_si_saved
1999 }
2000
2001 # Return 1 if the target plus current options supports a vector
2002 # widening multiplication of *char* args into *short* result, 0 otherwise.
2003 # A target can also support this widening multplication if it can support
2004 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2005 # multiplication of shorts).
2006 #
2007 # This won't change for different subtargets so cache the result.
2008
2009
2010 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2011     global et_vect_widen_mult_qi_to_hi
2012
2013     if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2014         verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2015     } else {
2016         if { [check_effective_target_vect_unpack]
2017              && [check_effective_target_vect_short_mult] } {
2018             set et_vect_widen_mult_qi_to_hi_saved 1
2019         } else {
2020             set et_vect_widen_mult_qi_to_hi_saved 0
2021         }
2022         if { [istarget powerpc*-*-*] } {
2023             set et_vect_widen_mult_qi_to_hi_saved 1
2024         }
2025     }
2026     verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2027     return $et_vect_widen_mult_qi_to_hi_saved
2028 }
2029
2030 # Return 1 if the target plus current options supports a vector
2031 # widening multiplication of *short* args into *int* result, 0 otherwise.
2032 # A target can also support this widening multplication if it can support
2033 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2034 # multiplication of ints).
2035 #
2036 # This won't change for different subtargets so cache the result.
2037
2038
2039 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2040     global et_vect_widen_mult_hi_to_si
2041
2042     if [info exists et_vect_widen_mult_hi_to_si_saved] {
2043         verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2044     } else {
2045         if { [check_effective_target_vect_unpack]
2046              && [check_effective_target_vect_int_mult] } {
2047           set et_vect_widen_mult_hi_to_si_saved 1
2048         } else {
2049           set et_vect_widen_mult_hi_to_si_saved 0
2050         }
2051         if { [istarget powerpc*-*-*]
2052               || [istarget spu-*-*]
2053               || [istarget i?86-*-*]
2054               || [istarget x86_64-*-*] } {
2055             set et_vect_widen_mult_hi_to_si_saved 1
2056         }
2057     }
2058     verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2059     return $et_vect_widen_mult_hi_to_si_saved
2060 }
2061
2062 # Return 1 if the target plus current options supports a vector
2063 # dot-product of signed chars, 0 otherwise.
2064 #
2065 # This won't change for different subtargets so cache the result.
2066
2067 proc check_effective_target_vect_sdot_qi { } {
2068     global et_vect_sdot_qi
2069
2070     if [info exists et_vect_sdot_qi_saved] {
2071         verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2072     } else {
2073         set et_vect_sdot_qi_saved 0
2074     }
2075     verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2076     return $et_vect_sdot_qi_saved
2077 }
2078
2079 # Return 1 if the target plus current options supports a vector
2080 # dot-product of unsigned chars, 0 otherwise.
2081 #
2082 # This won't change for different subtargets so cache the result.
2083
2084 proc check_effective_target_vect_udot_qi { } {
2085     global et_vect_udot_qi
2086
2087     if [info exists et_vect_udot_qi_saved] {
2088         verbose "check_effective_target_vect_udot_qi: using cached result" 2
2089     } else {
2090         set et_vect_udot_qi_saved 0
2091         if { [istarget powerpc*-*-*] } {
2092             set et_vect_udot_qi_saved 1
2093         }
2094     }
2095     verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2096     return $et_vect_udot_qi_saved
2097 }
2098
2099 # Return 1 if the target plus current options supports a vector
2100 # dot-product of signed shorts, 0 otherwise.
2101 #
2102 # This won't change for different subtargets so cache the result.
2103
2104 proc check_effective_target_vect_sdot_hi { } {
2105     global et_vect_sdot_hi
2106
2107     if [info exists et_vect_sdot_hi_saved] {
2108         verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2109     } else {
2110         set et_vect_sdot_hi_saved 0
2111         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2112              || [istarget i?86-*-*]
2113              || [istarget x86_64-*-*] } {
2114             set et_vect_sdot_hi_saved 1
2115         }
2116     }
2117     verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2118     return $et_vect_sdot_hi_saved
2119 }
2120
2121 # Return 1 if the target plus current options supports a vector
2122 # dot-product of unsigned shorts, 0 otherwise.
2123 #
2124 # This won't change for different subtargets so cache the result.
2125
2126 proc check_effective_target_vect_udot_hi { } {
2127     global et_vect_udot_hi
2128
2129     if [info exists et_vect_udot_hi_saved] {
2130         verbose "check_effective_target_vect_udot_hi: using cached result" 2
2131     } else {
2132         set et_vect_udot_hi_saved 0
2133         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2134             set et_vect_udot_hi_saved 1
2135         }
2136     }
2137     verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2138     return $et_vect_udot_hi_saved
2139 }
2140
2141
2142 # Return 1 if the target plus current options supports a vector
2143 # demotion (packing) of shorts (to chars) and ints (to shorts) 
2144 # using modulo arithmetic, 0 otherwise.
2145 #
2146 # This won't change for different subtargets so cache the result.
2147                                                                                 
2148 proc check_effective_target_vect_pack_trunc { } {
2149     global et_vect_pack_trunc
2150                                                                                 
2151     if [info exists et_vect_pack_trunc_saved] {
2152         verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2153     } else {
2154         set et_vect_pack_trunc_saved 0
2155         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2156              || [istarget i?86-*-*]
2157              || [istarget x86_64-*-*] } {
2158             set et_vect_pack_trunc_saved 1
2159         }
2160     }
2161     verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2162     return $et_vect_pack_trunc_saved
2163 }
2164
2165 # Return 1 if the target plus current options supports a vector
2166 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2167 #
2168 # This won't change for different subtargets so cache the result.
2169                                    
2170 proc check_effective_target_vect_unpack { } {
2171     global et_vect_unpack
2172                                         
2173     if [info exists et_vect_unpack_saved] {
2174         verbose "check_effective_target_vect_unpack: using cached result" 2
2175     } else {
2176         set et_vect_unpack_saved 0
2177         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2178              || [istarget i?86-*-*]
2179              || [istarget x86_64-*-*] } {
2180             set et_vect_unpack_saved 1
2181         }
2182     }
2183     verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2  
2184     return $et_vect_unpack_saved
2185 }
2186
2187 # Return 1 if the target plus current options does not guarantee
2188 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2189 #
2190 # This won't change for different subtargets so cache the result.
2191
2192 proc check_effective_target_unaligned_stack { } {
2193     global et_unaligned_stack_saved
2194
2195     if [info exists et_unaligned_stack_saved] {
2196         verbose "check_effective_target_unaligned_stack: using cached result" 2
2197     } else {
2198         set et_unaligned_stack_saved 0
2199         if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
2200           && (! [istarget *-*-darwin*] ) } {
2201             set et_unaligned_stack_saved 1
2202         }
2203     }
2204     verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2205     return $et_unaligned_stack_saved
2206 }
2207
2208 # Return 1 if the target plus current options does not support a vector
2209 # alignment mechanism, 0 otherwise.
2210 #
2211 # This won't change for different subtargets so cache the result.
2212
2213 proc check_effective_target_vect_no_align { } {
2214     global et_vect_no_align_saved
2215
2216     if [info exists et_vect_no_align_saved] {
2217         verbose "check_effective_target_vect_no_align: using cached result" 2
2218     } else {
2219         set et_vect_no_align_saved 0
2220         if { [istarget mipsisa64*-*-*]
2221              || [istarget sparc*-*-*]
2222              || [istarget ia64-*-*] } { 
2223             set et_vect_no_align_saved 1
2224         }
2225     }
2226     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2227     return $et_vect_no_align_saved
2228 }
2229
2230 # Return 1 if arrays are aligned to the vector alignment
2231 # boundary, 0 otherwise.
2232 #
2233 # This won't change for different subtargets so cache the result.
2234
2235 proc check_effective_target_vect_aligned_arrays { } {
2236     global et_vect_aligned_arrays
2237
2238     if [info exists et_vect_aligned_arrays_saved] {
2239         verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2240     } else {
2241         set et_vect_aligned_arrays_saved 0
2242         if { (([istarget x86_64-*-*]
2243               || [istarget i?86-*-*]) && [is-effective-target lp64])
2244               || [istarget spu-*-*] } {
2245             set et_vect_aligned_arrays_saved 1
2246         }
2247     }
2248     verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2249     return $et_vect_aligned_arrays_saved
2250 }
2251
2252 # Return 1 if types of size 32 bit or less are naturally aligned
2253 # (aligned to their type-size), 0 otherwise.
2254 #
2255 # This won't change for different subtargets so cache the result.
2256
2257 proc check_effective_target_natural_alignment_32 { } {
2258     global et_natural_alignment_32
2259
2260     if [info exists et_natural_alignment_32_saved] {
2261         verbose "check_effective_target_natural_alignment_32: using cached result" 2
2262     } else {
2263         # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2264         set et_natural_alignment_32_saved 1
2265         if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2266             set et_natural_alignment_32_saved 0
2267         }
2268     }
2269     verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2270     return $et_natural_alignment_32_saved
2271 }
2272
2273 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2274 # type-size), 0 otherwise.
2275 #
2276 # This won't change for different subtargets so cache the result.
2277
2278 proc check_effective_target_natural_alignment_64 { } {
2279     global et_natural_alignment_64
2280
2281     if [info exists et_natural_alignment_64_saved] {
2282         verbose "check_effective_target_natural_alignment_64: using cached result" 2
2283     } else {
2284         set et_natural_alignment_64_saved 0
2285         if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2286              || [istarget spu-*-*] } {
2287             set et_natural_alignment_64_saved 1
2288         }
2289     }
2290     verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2291     return $et_natural_alignment_64_saved
2292 }
2293
2294 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2295 #
2296 # This won't change for different subtargets so cache the result.
2297
2298 proc check_effective_target_vector_alignment_reachable { } {
2299     global et_vector_alignment_reachable
2300
2301     if [info exists et_vector_alignment_reachable_saved] {
2302         verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2303     } else {
2304         if { [check_effective_target_vect_aligned_arrays]
2305              || [check_effective_target_natural_alignment_32] } {
2306             set et_vector_alignment_reachable_saved 1
2307         } else {
2308             set et_vector_alignment_reachable_saved 0
2309         }
2310     }
2311     verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2312     return $et_vector_alignment_reachable_saved
2313 }
2314
2315 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2316 #
2317 # This won't change for different subtargets so cache the result.
2318
2319 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2320     global et_vector_alignment_reachable_for_64bit
2321
2322     if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2323         verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2324     } else {
2325         if { [check_effective_target_vect_aligned_arrays] 
2326              || [check_effective_target_natural_alignment_64] } {
2327             set et_vector_alignment_reachable_for_64bit_saved 1
2328         } else {
2329             set et_vector_alignment_reachable_for_64bit_saved 0
2330         }
2331     }
2332     verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2333     return $et_vector_alignment_reachable_for_64bit_saved
2334 }
2335
2336 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2337
2338 proc check_effective_target_vect_condition { } {
2339     global et_vect_cond_saved
2340
2341     if [info exists et_vect_cond_saved] {
2342         verbose "check_effective_target_vect_cond: using cached result" 2
2343     } else {
2344         set et_vect_cond_saved 0
2345         if { [istarget powerpc*-*-*]
2346              || [istarget ia64-*-*]
2347              || [istarget i?86-*-*]
2348              || [istarget spu-*-*]
2349              || [istarget x86_64-*-*] } {
2350            set et_vect_cond_saved 1
2351         }
2352     }
2353
2354     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2355     return $et_vect_cond_saved
2356 }
2357
2358 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2359
2360 proc check_effective_target_vect_char_mult { } {
2361     global et_vect_char_mult_saved
2362
2363     if [info exists et_vect_char_mult_saved] {
2364         verbose "check_effective_target_vect_char_mult: using cached result" 2
2365     } else {
2366         set et_vect_char_mult_saved 0
2367         if { [istarget ia64-*-*]
2368              || [istarget i?86-*-*]
2369              || [istarget x86_64-*-*] } {
2370            set et_vect_char_mult_saved 1
2371         }
2372     }
2373
2374     verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2375     return $et_vect_char_mult_saved
2376 }
2377
2378 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2379
2380 proc check_effective_target_vect_short_mult { } {
2381     global et_vect_short_mult_saved
2382
2383     if [info exists et_vect_short_mult_saved] {
2384         verbose "check_effective_target_vect_short_mult: using cached result" 2
2385     } else {
2386         set et_vect_short_mult_saved 0
2387         if { [istarget ia64-*-*]
2388              || [istarget i?86-*-*]
2389              || [istarget x86_64-*-*] } {
2390            set et_vect_short_mult_saved 1
2391         }
2392     }
2393
2394     verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2395     return $et_vect_short_mult_saved
2396 }
2397
2398 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2399
2400 proc check_effective_target_vect_int_mult { } {
2401     global et_vect_int_mult_saved
2402
2403     if [info exists et_vect_int_mult_saved] {
2404         verbose "check_effective_target_vect_int_mult: using cached result" 2
2405     } else {
2406         set et_vect_int_mult_saved 0
2407         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2408              || [istarget spu-*-*]
2409              || [istarget i?86-*-*]
2410              || [istarget x86_64-*-*] } {
2411            set et_vect_int_mult_saved 1
2412         }
2413     }
2414
2415     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2416     return $et_vect_int_mult_saved
2417 }
2418
2419 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2420
2421 proc check_effective_target_vect_extract_even_odd { } {
2422     global et_vect_extract_even_odd_saved
2423     
2424     if [info exists et_vect_extract_even_odd_saved] {
2425         verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2426     } else {
2427         set et_vect_extract_even_odd_saved 0 
2428         if { [istarget powerpc*-*-*] } {
2429            set et_vect_extract_even_odd_saved 1
2430         }
2431     }
2432
2433     verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2434     return $et_vect_extract_even_odd_saved
2435 }
2436
2437 # Return 1 if the target supports vector interleaving, 0 otherwise.
2438
2439 proc check_effective_target_vect_interleave { } {
2440     global et_vect_interleave_saved
2441     
2442     if [info exists et_vect_interleave_saved] {
2443         verbose "check_effective_target_vect_interleave: using cached result" 2
2444     } else {
2445         set et_vect_interleave_saved 0
2446         if { [istarget powerpc*-*-*]
2447              || [istarget i?86-*-*]
2448              || [istarget x86_64-*-*] } {
2449            set et_vect_interleave_saved 1
2450         }
2451     }
2452
2453     verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2454     return $et_vect_interleave_saved
2455 }
2456
2457 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2458 proc check_effective_target_vect_strided { } {
2459     global et_vect_strided_saved
2460
2461     if [info exists et_vect_strided_saved] {
2462         verbose "check_effective_target_vect_strided: using cached result" 2
2463     } else {
2464         set et_vect_strided_saved 0
2465         if { [check_effective_target_vect_interleave]
2466              && [check_effective_target_vect_extract_even_odd] } {
2467            set et_vect_strided_saved 1
2468         }
2469     }
2470
2471     verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2472     return $et_vect_strided_saved
2473 }
2474
2475 # Return 1 if the target supports section-anchors
2476
2477 proc check_effective_target_section_anchors { } {
2478     global et_section_anchors_saved
2479
2480     if [info exists et_section_anchors_saved] {
2481         verbose "check_effective_target_section_anchors: using cached result" 2
2482     } else {
2483         set et_section_anchors_saved 0
2484         if { [istarget powerpc*-*-*] } {
2485            set et_section_anchors_saved 1
2486         }
2487     }
2488
2489     verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2490     return $et_section_anchors_saved
2491 }
2492
2493 # Return 1 if the target supports atomic operations on "int" and "long".
2494
2495 proc check_effective_target_sync_int_long { } {
2496     global et_sync_int_long_saved
2497
2498     if [info exists et_sync_int_long_saved] {
2499         verbose "check_effective_target_sync_int_long: using cached result" 2
2500     } else {
2501         set et_sync_int_long_saved 0
2502 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2503 # load-reserved/store-conditional instructions.
2504         if { [istarget ia64-*-*]
2505              || [istarget i?86-*-*]
2506              || [istarget x86_64-*-*]
2507              || [istarget alpha*-*-*] 
2508              || [istarget s390*-*-*] 
2509              || [istarget powerpc*-*-*]
2510              || [istarget sparc64-*-*]
2511              || [istarget sparcv9-*-*] } {
2512            set et_sync_int_long_saved 1
2513         }
2514     }
2515
2516     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2517     return $et_sync_int_long_saved
2518 }
2519
2520 # Return 1 if the target supports atomic operations on "char" and "short".
2521
2522 proc check_effective_target_sync_char_short { } {
2523     global et_sync_char_short_saved
2524
2525     if [info exists et_sync_char_short_saved] {
2526         verbose "check_effective_target_sync_char_short: using cached result" 2
2527     } else {
2528         set et_sync_char_short_saved 0
2529 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2530 # load-reserved/store-conditional instructions.
2531         if { [istarget ia64-*-*]
2532              || [istarget i?86-*-*]
2533              || [istarget x86_64-*-*]
2534              || [istarget alpha*-*-*] 
2535              || [istarget s390*-*-*] 
2536              || [istarget powerpc*-*-*]
2537              || [istarget sparc64-*-*]
2538              || [istarget sparcv9-*-*] } {
2539            set et_sync_char_short_saved 1
2540         }
2541     }
2542
2543     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2544     return $et_sync_char_short_saved
2545 }
2546
2547 # Return 1 if the target uses a ColdFire FPU.
2548
2549 proc check_effective_target_coldfire_fpu { } {
2550     return [check_no_compiler_messages coldfire_fpu assembly {
2551         #ifndef __mcffpu__
2552         #error FOO
2553         #endif
2554     }]
2555 }
2556
2557 # Return true if this is a uClibc target.
2558
2559 proc check_effective_target_uclibc {} {
2560     return [check_no_compiler_messages uclibc object {
2561         #include <features.h>
2562         #if !defined (__UCLIBC__)
2563         #error FOO
2564         #endif
2565     }]
2566 }
2567
2568 # Return true if this is a uclibc target and if the uclibc feature
2569 # described by __$feature__ is not present.
2570
2571 proc check_missing_uclibc_feature {feature} {
2572     return [check_no_compiler_messages $feature object "
2573         #include <features.h>
2574         #if !defined (__UCLIBC) || defined (__${feature}__)
2575         #error FOO
2576         #endif
2577     "]
2578 }
2579
2580 # Return true if this is a Newlib target.
2581
2582 proc check_effective_target_newlib {} {
2583     return [check_no_compiler_messages newlib object {
2584         #include <newlib.h>
2585     }]
2586 }
2587
2588 # Return 1 if
2589 #   (a) an error of a few ULP is expected in string to floating-point
2590 #       conversion functions; and
2591 #   (b) overflow is not always detected correctly by those functions.
2592
2593 proc check_effective_target_lax_strtofp {} {
2594     # By default, assume that all uClibc targets suffer from this.
2595     return [check_effective_target_uclibc]
2596 }
2597
2598 # Return 1 if this is a target for which wcsftime is a dummy
2599 # function that always returns 0.
2600
2601 proc check_effective_target_dummy_wcsftime {} {
2602     # By default, assume that all uClibc targets suffer from this.
2603     return [check_effective_target_uclibc]
2604 }
2605
2606 # Return 1 if constructors with initialization priority arguments are
2607 # supposed on this target.
2608
2609 proc check_effective_target_init_priority {} {
2610     return [check_no_compiler_messages init_priority assembly "
2611         void f() __attribute__((constructor (1000)));
2612         void f() \{\}
2613     "]
2614 }
2615
2616 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2617 # This can be used with any check_* proc that takes no argument and
2618 # returns only 1 or 0.  It could be used with check_* procs that take
2619 # arguments with keywords that pass particular arguments.
2620
2621 proc is-effective-target { arg } {
2622     set selected 0
2623     if { [info procs check_effective_target_${arg}] != [list] } {
2624         set selected [check_effective_target_${arg}]
2625     } else {
2626         switch $arg {
2627           "vmx_hw"         { set selected [check_vmx_hw_available] }
2628           "named_sections" { set selected [check_named_sections_available] }
2629           "gc_sections"    { set selected [check_gc_sections_available] }
2630           "cxa_atexit"     { set selected [check_cxa_atexit_available] }
2631           default          { error "unknown effective target keyword `$arg'" }
2632         }
2633     }
2634     verbose "is-effective-target: $arg $selected" 2
2635     return $selected
2636 }
2637
2638 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2639
2640 proc is-effective-target-keyword { arg } {
2641     if { [info procs check_effective_target_${arg}] != [list] } {
2642         return 1
2643     } else {
2644         # These have different names for their check_* procs.
2645         switch $arg {
2646           "vmx_hw"         { return 1 }
2647           "named_sections" { return 1 }
2648           "gc_sections"    { return 1 }
2649           "cxa_atexit"     { return 1 }
2650           default          { return 0 }
2651         }
2652     }
2653 }
2654
2655 # Return 1 if target default to short enums
2656
2657 proc check_effective_target_short_enums { } {
2658     return [check_no_compiler_messages short_enums assembly {
2659         enum foo { bar };
2660         int s[sizeof (enum foo) == 1 ? 1 : -1];
2661     }]
2662 }
2663
2664 # Return 1 if target supports merging string constants at link time.
2665
2666 proc check_effective_target_string_merging { } {
2667     return [check_no_messages_and_pattern string_merging \
2668                 "rodata\\.str" assembly {
2669                     const char *var = "String";
2670                 } {-O2}]
2671 }
2672
2673 # Return 1 if target has the basic signed and unsigned types in
2674 # <stdint.h>, 0 otherwise.
2675
2676 proc check_effective_target_stdint_types { } {
2677     return [check_no_compiler_messages stdint_types assembly {
2678         #include <stdint.h>
2679         int8_t a; int16_t b; int32_t c; int64_t d;
2680         uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2681     }]
2682 }
2683
2684 # Return 1 if programs are intended to be run on a simulator
2685 # (i.e. slowly) rather than hardware (i.e. fast).
2686
2687 proc check_effective_target_simulator { } {
2688
2689     # All "src/sim" simulators set this one.
2690     if [board_info target exists is_simulator] {
2691         return [board_info target is_simulator]
2692     }
2693
2694     # The "sid" simulators don't set that one, but at least they set
2695     # this one.
2696     if [board_info target exists slow_simulator] {
2697         return [board_info target slow_simulator]
2698     }
2699
2700     return 0
2701 }
2702
2703 # Return 1 if the target is a VxWorks RTP.
2704
2705 proc check_effective_target_vxworks_kernel { } {
2706     return [check_no_compiler_messages vxworks_kernel assembly {
2707         #if !defined __vxworks || defined __RTP__
2708         #error NO
2709         #endif
2710     }]
2711 }
2712
2713 # Return 1 if the target is expected to provide wide character support.
2714
2715 proc check_effective_target_wchar { } {
2716     if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2717         return 0
2718     }
2719     return [check_no_compiler_messages wchar assembly {
2720         #include <wchar.h>
2721     }]
2722 }
2723
2724 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2725
2726 proc add_options_for_c99_runtime { flags } {
2727     if { [istarget *-*-solaris2*] } {
2728         return "$flags -std=c99"
2729     }
2730     if { [istarget powerpc-*-darwin*] } {
2731         return "$flags -mmacosx-version-min=10.3"
2732     }
2733     return $flags
2734 }
2735
2736 # Return 1 if the target provides a full C99 runtime.
2737
2738 proc check_effective_target_c99_runtime { } {
2739     return [check_cached_effective_target c99_runtime {
2740         global srcdir
2741
2742         set file [open "$srcdir/gcc.dg/builtins-config.h"]
2743         set contents [read $file]
2744         close $file
2745         append contents {
2746             #ifndef HAVE_C99_RUNTIME
2747             #error FOO
2748             #endif
2749         }
2750         string match "" [get_compiler_messages c99_runtime 0 assembly \
2751                              $contents [add_options_for_c99_runtime ""]]
2752     }]
2753 }