OSDN Git Service

Fix check_750cl_hw_available function
[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 is a 64-bit MIPS target.
619
620 proc check_effective_target_mips64 { } {
621     return [check_no_compiler_messages mips64 assembly {
622         #ifndef __mips64
623         #error FOO
624         #endif
625     }]
626 }
627
628 # Return true if the target is a MIPS target that does not produce
629 # MIPS16 code.
630
631 proc check_effective_target_nomips16 { } {
632     return [check_no_compiler_messages nomips16 object {
633         #ifndef __mips
634         #error FOO
635         #else
636         /* A cheap way of testing for -mflip-mips16.  */
637         void foo (void) { asm ("addiu $20,$20,1"); }
638         void bar (void) { asm ("addiu $20,$20,1"); }
639         #endif
640     }]
641 }
642
643 # Add the options needed for MIPS16 function attributes.  At the moment,
644 # we don't support MIPS16 PIC.
645
646 proc add_options_for_mips16_attribute { flags } {
647     return "$flags -mno-abicalls -fno-pic"
648 }
649
650 # Return true if we can force a mode that allows MIPS16 code generation.
651 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
652 # for o32 and o64.
653
654 proc check_effective_target_mips16_attribute { } {
655     return [check_no_compiler_messages mips16_attribute assembly {
656         #ifdef PIC
657         #error FOO
658         #endif
659         #if defined __mips_hard_float \
660             && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
661             && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
662         #error FOO
663         #endif
664     } [add_options_for_mips16_attribute ""]]
665 }
666
667 # Return 1 if the current multilib does not generate PIC by default.
668
669 proc check_effective_target_nonpic { } {
670     return [check_no_compiler_messages nonpic assembly {
671         #if __PIC__
672         #error FOO
673         #endif
674     }]
675 }
676
677 # Return 1 if the target does not use a status wrapper.
678
679 proc check_effective_target_unwrapped { } {
680     if { [target_info needs_status_wrapper] != "" \
681              && [target_info needs_status_wrapper] != "0" } {
682         return 0
683     }
684     return 1
685 }
686
687 # Return true if iconv is supported on the target. In particular IBM1047.
688
689 proc check_iconv_available { test_what } {
690     global tool
691     global libiconv
692
693     set result ""
694
695     set src iconv[pid].c
696     set exe iconv[pid].x
697     verbose "check_iconv_available compiling testfile $src" 2
698     set f [open $src "w"]
699     # Compile a small test program.
700     puts $f "#include <iconv.h>\n"
701     puts $f "int main (void)\n {\n iconv_t cd; \n"
702     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
703     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
704     puts $f "return 0;\n}"
705     close $f
706
707     # If the tool configuration file has not set libiconv, try "-liconv"
708     if { ![info exists libiconv] } {
709         set libiconv "-liconv"
710     }
711     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
712     file delete $src
713
714     if [string match "" $lines] then {
715         # No error messages, everything is OK.
716
717         set result [${tool}_load "./$exe" "" ""]
718         set status [lindex $result 0]
719         remote_file build delete $exe
720
721         verbose "check_iconv_available status is <$status>" 2
722
723         if { $status == "pass" } then {
724             return 1
725         }
726     }
727
728     return 0
729 }
730
731 # Return true if named sections are supported on this target.
732
733 proc check_named_sections_available { } {
734     return [check_no_compiler_messages named_sections assembly {
735         int __attribute__ ((section("whatever"))) foo;
736     }]
737 }
738
739 # Return 1 if the target supports Fortran real kinds larger than real(8),
740 # 0 otherwise.
741 #
742 # When the target name changes, replace the cached result.
743
744 proc check_effective_target_fortran_large_real { } {
745     global et_fortran_large_real_saved
746     global et_fortran_large_real_target_name
747     global tool
748
749     if { ![info exists et_fortran_large_real_target_name] } {
750         set et_fortran_large_real_target_name ""
751     }
752
753     # If the target has changed since we set the cached value, clear it.
754     set current_target [current_target_name]
755     if { $current_target != $et_fortran_large_real_target_name } {
756         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
757         set et_fortran_large_real_target_name $current_target
758         if [info exists et_fortran_large_real_saved] {
759             verbose "check_effective_target_fortran_large_real: removing cached result" 2
760             unset et_fortran_large_real_saved
761         }
762     }
763
764     if [info exists et_fortran_large_real_saved] {
765         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
766     } else {
767         set et_fortran_large_real_saved 0
768
769         # Set up, compile, and execute a test program using large real
770         # kinds.  Include the current process ID in the file names to
771         # prevent conflicts with invocations for multiple testsuites.
772         set src real[pid].f90
773         set exe real[pid].x
774
775         set f [open $src "w"]
776         puts $f "integer,parameter :: k = &"
777         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
778         puts $f "real(kind=k) :: x"
779         puts $f "x = cos (x);"
780         puts $f "end"
781         close $f
782
783         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
784         set lines [${tool}_target_compile $src $exe executable ""]
785         file delete $src
786
787         if [string match "" $lines] then {
788             # No error message, compilation succeeded.
789             remote_file build delete $exe
790             set et_fortran_large_real_saved 1
791         }
792     }
793
794     return $et_fortran_large_real_saved
795 }
796
797 # Return 1 if the target supports Fortran integer kinds larger than
798 # integer(8), 0 otherwise.
799 #
800 # When the target name changes, replace the cached result.
801
802 proc check_effective_target_fortran_large_int { } {
803     global et_fortran_large_int_saved
804     global et_fortran_large_int_target_name
805     global tool
806
807     if { ![info exists et_fortran_large_int_target_name] } {
808         set et_fortran_large_int_target_name ""
809     }
810
811     # If the target has changed since we set the cached value, clear it.
812     set current_target [current_target_name]
813     if { $current_target != $et_fortran_large_int_target_name } {
814         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
815         set et_fortran_large_int_target_name $current_target
816         if [info exists et_fortran_large_int_saved] {
817             verbose "check_effective_target_fortran_large_int: removing cached result" 2
818             unset et_fortran_large_int_saved
819         }
820     }
821
822     if [info exists et_fortran_large_int_saved] {
823         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
824     } else {
825         set et_fortran_large_int_saved 0
826
827         # Set up, compile, and execute a test program using large integer
828         # kinds.  Include the current process ID in the file names to
829         # prevent conflicts with invocations for multiple testsuites.
830         set src int[pid].f90
831         set exe int[pid].x
832
833         set f [open $src "w"]
834         puts $f "integer,parameter :: k = &"
835         puts $f "  selected_int_kind (range (0_8) + 1)"
836         puts $f "integer(kind=k) :: i"
837         puts $f "end"
838         close $f
839
840         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
841         set lines [${tool}_target_compile $src $exe executable ""]
842         file delete $src
843
844         if [string match "" $lines] then {
845             # No error message, compilation succeeded.
846             remote_file build delete $exe
847             set et_fortran_large_int_saved 1
848         }
849     }
850
851     return $et_fortran_large_int_saved
852 }
853
854 # Return 1 if we can statically link libgfortran, 0 otherwise.
855 #
856 # When the target name changes, replace the cached result.
857
858 proc check_effective_target_static_libgfortran { } {
859     global et_static_libgfortran
860     global et_static_libgfortran_target_name
861     global tool
862
863     if { ![info exists et_static_libgfortran_target_name] } {
864        set et_static_libgfortran_target_name ""
865     }
866
867     # If the target has changed since we set the cached value, clear it.
868     set current_target [current_target_name]
869     if { $current_target != $et_static_libgfortran_target_name } {
870        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
871        set et_static_libgfortran_target_name $current_target
872        if [info exists et_static_libgfortran_saved] {
873            verbose "check_effective_target_static_libgfortran: removing cached result" 2
874            unset et_static_libgfortran_saved
875        }
876     }
877
878     if [info exists et_static_libgfortran_saved] {
879        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
880     } else {
881        set et_static_libgfortran_saved 0
882
883        # Set up, compile, and execute a test program using static linking.
884        # Include the current process ID in the file names to prevent
885        # conflicts with invocations for multiple testsuites.
886        set opts "additional_flags=-static"
887        set src static[pid].f
888        set exe static[pid].x
889
890        set f [open $src "w"]
891        puts $f "      print *, 'test'"
892        puts $f "      end"
893        close $f
894
895        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
896        set lines [${tool}_target_compile $src $exe executable "$opts"]
897        file delete $src
898
899        if [string match "" $lines] then {
900            # No error message, compilation succeeded.
901            remote_file build delete $exe
902            set et_static_libgfortran_saved 1
903        }
904     }
905
906     return $et_static_libgfortran_saved
907 }
908
909 # Return 1 if the target supports executing 750CL paired-single instructions, 0
910 # otherwise.  Cache the result.
911
912 proc check_750cl_hw_available { } {
913     global 750cl_hw_available_saved
914     global tool
915
916     if [info exists 750cl_hw_available_saved] {
917         verbose "check_hw_available  returning saved $750cl_hw_available_saved" 2
918     } else {
919         set 750cl_hw_available_saved 0
920
921         # If this is not the right target then we can quit.
922         if { ![istarget powerpc-*paired*] } {
923             verbose "check_hw_available  returning 0" 2
924             return $750cl_hw_available_saved
925         }
926
927         # Set up, compile, and execute a test program containing paired-single
928         # instructions.  Include the current process ID in the file
929         # names to prevent conflicts with invocations for multiple
930         # testsuites.
931         set src 750cl[pid].c
932         set exe 750cl[pid].x
933
934         set f [open $src "w"]
935         puts $f "int main() {"
936         puts $f "#ifdef __MACH__"
937         puts $f "  asm volatile (\"ps_mul v0,v0,v0\");"
938         puts $f "#else"
939         puts $f "  asm volatile (\"ps_mul 0,0,0\");"
940         puts $f "#endif"
941         puts $f "  return 0; }"
942         close $f
943
944         verbose "check_750cl_hw_available  compiling testfile $src" 2
945         set lines [${tool}_target_compile $src $exe executable "-mpaired"]
946         file delete $src
947
948         if [string match "" $lines] then {
949             # No error message, compilation succeeded.
950             set result [${tool}_load "./$exe" "" ""]
951             set status [lindex $result 0]
952             remote_file build delete $exe
953             verbose "check_750cl_hw_available testfile status is <$status>" 2
954
955             if { $status == "pass" } then {
956                 set 750cl_hw_available_saved 1
957             }
958         } else {
959             verbose "check_750cl_hw_availalble testfile compilation failed" 2
960         }
961     }
962     return $750cl_hw_available_saved
963 }
964
965
966 # Return 1 if the target supports executing AltiVec instructions, 0
967 # otherwise.  Cache the result.
968
969 proc check_vmx_hw_available { } {
970     global vmx_hw_available_saved
971     global tool
972
973     if [info exists vmx_hw_available_saved] {
974         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
975     } else {
976         set vmx_hw_available_saved 0
977
978         # Some simulators are known to not support VMX instructions.
979         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
980             verbose "check_hw_available  returning 0" 2
981             return $vmx_hw_available_saved
982         }
983
984         # Set up, compile, and execute a test program containing VMX
985         # instructions.  Include the current process ID in the file
986         # names to prevent conflicts with invocations for multiple
987         # testsuites.
988         set src vmx[pid].c
989         set exe vmx[pid].x
990
991         set f [open $src "w"]
992         puts $f "int main() {"
993         puts $f "#ifdef __MACH__"
994         puts $f "  asm volatile (\"vor v0,v0,v0\");"
995         puts $f "#else"
996         puts $f "  asm volatile (\"vor 0,0,0\");"
997         puts $f "#endif"
998         puts $f "  return 0; }"
999         close $f
1000
1001         # Most targets don't require special flags for this test case, but
1002         # Darwin does.
1003         if { [istarget *-*-darwin*] 
1004              || [istarget *-*-aix*] } {
1005           set opts "additional_flags=-maltivec"
1006         } else {
1007           set opts ""
1008         }
1009
1010         verbose "check_vmx_hw_available  compiling testfile $src" 2
1011         set lines [${tool}_target_compile $src $exe executable "$opts"]
1012         file delete $src
1013
1014         if [string match "" $lines] then {
1015             # No error message, compilation succeeded.
1016             set result [${tool}_load "./$exe" "" ""]
1017             set status [lindex $result 0]
1018             remote_file build delete $exe
1019             verbose "check_vmx_hw_available testfile status is <$status>" 2
1020
1021             if { $status == "pass" } then {
1022                 set vmx_hw_available_saved 1
1023             }
1024         } else {
1025             verbose "check_vmx_hw_availalble testfile compilation failed" 2
1026         }
1027     }
1028
1029     return $vmx_hw_available_saved
1030 }
1031
1032 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1033 # complex float arguments.  This affects gfortran tests that call cabsf
1034 # in libm built by an earlier compiler.  Return 1 if libm uses the same
1035 # argument passing as the compiler under test, 0 otherwise.
1036 #
1037 # When the target name changes, replace the cached result.
1038
1039 proc check_effective_target_broken_cplxf_arg { } {
1040     global et_broken_cplxf_arg_saved
1041     global et_broken_cplxf_arg_target_name
1042     global tool
1043
1044     # Skip the work for targets known not to be affected.
1045     if { ![istarget powerpc64-*-linux*] } {
1046         return 0
1047     } elseif { [is-effective-target ilp32] } {
1048         return 0
1049     }
1050
1051     if { ![info exists et_broken_cplxf_arg_target_name] } {
1052         set et_broken_cplxf_arg_target_name ""
1053     }
1054
1055     # If the target has changed since we set the cached value, clear it.
1056     set current_target [current_target_name]
1057     if { $current_target != $et_broken_cplxf_arg_target_name } {
1058         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
1059         set et_broken_cplxf_arg_target_name $current_target
1060         if [info exists et_broken_cplxf_arg_saved] {
1061             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
1062             unset et_broken_cplxf_arg_saved
1063         }
1064     }
1065
1066     if [info exists et_broken_cplxf_arg_saved] {
1067         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
1068     } else {
1069         set et_broken_cplxf_arg_saved 0
1070         # This is only known to affect one target.
1071         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
1072             set et_broken_cplxf_arg_saved 0
1073             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
1074             return $et_broken_cplxf_arg_saved
1075         }
1076
1077         # Set up, compile, and execute a C test program that calls cabsf.
1078         set src cabsf[pid].c
1079         set exe cabsf[pid].x
1080
1081         set f [open $src "w"]
1082         puts $f "#include <complex.h>"
1083         puts $f "extern void abort (void);"
1084         puts $f "float fabsf (float);"
1085         puts $f "float cabsf (_Complex float);"
1086         puts $f "int main ()"
1087         puts $f "{"
1088         puts $f "  _Complex float cf;"
1089         puts $f "  float f;"
1090         puts $f "  cf = 3 + 4.0fi;"
1091         puts $f "  f = cabsf (cf);"
1092         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
1093         puts $f "  return 0;"
1094         puts $f "}"
1095         close $f
1096
1097         set lines [${tool}_target_compile $src $exe executable "-lm"]
1098         file delete $src
1099
1100         if [string match "" $lines] {
1101             # No error message, compilation succeeded.
1102             set result [${tool}_load "./$exe" "" ""]
1103             set status [lindex $result 0]
1104             remote_file build delete $exe
1105
1106             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1107
1108             if { $status != "pass" } {
1109                 set et_broken_cplxf_arg_saved 1
1110             }
1111         } else {
1112             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1113         }
1114     }
1115     return $et_broken_cplxf_arg_saved
1116 }
1117
1118 proc check_alpha_max_hw_available { } {
1119     global alpha_max_hw_available_saved
1120     global tool
1121
1122     if [info exists alpha_max_hw_available_saved] {
1123         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1124     } else {
1125         set alpha_max_hw_available_saved 0
1126
1127         # Set up, compile, and execute a test program probing bit 8 of the
1128         # architecture mask, which indicates presence of MAX instructions.
1129         set src max[pid].c
1130         set exe max[pid].x
1131
1132         set f [open $src "w"]
1133         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1134         close $f
1135
1136         verbose "check_alpha_max_hw_available compiling testfile $src" 2
1137         set lines [${tool}_target_compile $src $exe executable ""]
1138         file delete $src
1139
1140         if [string match "" $lines] then {
1141             # No error message, compilation succeeded.
1142             set result [${tool}_load "./$exe" "" ""]
1143             set status [lindex $result 0]
1144             remote_file build delete $exe
1145             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1146
1147             if { $status == "pass" } then {
1148                 set alpha_max_hw_available_saved 1
1149             }
1150         } else {
1151             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1152         }
1153     }
1154
1155     return $alpha_max_hw_available_saved
1156 }
1157
1158 # Returns true iff the FUNCTION is available on the target system.
1159 # (This is essentially a Tcl implementation of Autoconf's
1160 # AC_CHECK_FUNC.)
1161
1162 proc check_function_available { function } {
1163     set var "${function}_available_saved"
1164     global $var
1165     global tool
1166
1167     if {![info exists $var]} {
1168         # Assume it exists.
1169         set $var 1
1170         # Check to make sure.
1171         set src "function[pid].c"
1172         set exe "function[pid].exe"
1173
1174         set f [open $src "w"]
1175         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1176         puts $f "char $function ();\n"
1177         puts $f "int main () { $function (); }"
1178         close $f
1179
1180         set lines [${tool}_target_compile $src $exe executable ""]
1181         file delete $src
1182         file delete $exe
1183
1184         if {![string match "" $lines]} then {
1185             set $var 0
1186             verbose -log "$function is not available"
1187         } else {
1188             verbose -log "$function is available"
1189         }
1190     }
1191
1192     eval return \$$var
1193 }
1194
1195 # Returns true iff "fork" is available on the target system.
1196
1197 proc check_fork_available {} {
1198     return [check_function_available "fork"]
1199 }
1200
1201 # Returns true iff "mkfifo" is available on the target system.
1202
1203 proc check_mkfifo_available {} {
1204     if {[istarget *-*-cygwin*]} {
1205        # Cygwin has mkfifo, but support is incomplete.
1206        return 0
1207      }
1208
1209     return [check_function_available "mkfifo"]
1210 }
1211
1212 # Returns true iff "__cxa_atexit" is used on the target system.
1213
1214 proc check_cxa_atexit_available { } {
1215     global et_cxa_atexit
1216     global et_cxa_atexit_target_name
1217     global tool 
1218
1219     if { ![info exists et_cxa_atexit_target_name] } {
1220         set et_cxa_atexit_target_name ""
1221     }
1222
1223     # If the target has changed since we set the cached value, clear it.
1224     set current_target [current_target_name]
1225     if { $current_target != $et_cxa_atexit_target_name } {
1226         verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1227         set et_cxa_atexit_target_name $current_target
1228         if [info exists et_cxa_atexit] {
1229             verbose "check_cxa_atexit_available: removing cached result" 2
1230             unset et_cxa_atexit
1231         }
1232     }
1233
1234     if [info exists et_cxa_atexit] {
1235         verbose "check_cxa_atexit_available: using cached result" 2
1236     } elseif { [istarget "hppa*-*-hpux10*"] } {
1237         # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1238         set et_cxa_atexit 0
1239     } else {
1240         set et_cxa_atexit 0
1241
1242         # Set up, compile, and execute a C++ test program that depends
1243         # on correct ordering of static object destructors. This is
1244         # indicative of the presence and use of __cxa_atexit.
1245         set src cxaatexit[pid].cc
1246         set exe cxaatexit[pid].x
1247
1248         set f [open $src "w"]
1249         puts $f "#include <stdlib.h>"
1250         puts $f "static unsigned int count;"
1251         puts $f "struct X"
1252         puts $f "{"
1253         puts $f "  X() { count = 1; }"
1254         puts $f "  ~X()"
1255         puts $f "  {"
1256         puts $f "    if (count != 3)"
1257         puts $f "      exit(1);"
1258         puts $f "    count = 4;"
1259         puts $f "  }"
1260         puts $f "};"
1261         puts $f "void f()"
1262         puts $f "{"
1263         puts $f "  static X x;"
1264         puts $f "}"
1265         puts $f "struct Y"
1266         puts $f "{"
1267         puts $f "  Y() { f(); count = 2; }"
1268         puts $f "  ~Y()"
1269         puts $f "  {"
1270         puts $f "    if (count != 2)"
1271         puts $f "      exit(1);"
1272         puts $f "    count = 3;"
1273         puts $f "  }"
1274         puts $f "};"
1275         puts $f "Y y;"
1276         puts $f "int main()"
1277         puts $f "{ return 0; }"
1278         close $f
1279
1280         set lines [${tool}_target_compile $src $exe executable ""]
1281         file delete $src
1282
1283         if [string match "" $lines] {
1284             # No error message, compilation succeeded.
1285             set result [${tool}_load "./$exe" "" ""]
1286             set status [lindex $result 0]
1287             remote_file build delete $exe
1288
1289             verbose "check_cxa_atexit_available: status is <$status>" 2
1290
1291             if { $status == "pass" } {
1292                 set et_cxa_atexit 1
1293             }
1294         } else {
1295             verbose "check_cxa_atexit_available: compilation failed" 2
1296         }
1297     }
1298     return $et_cxa_atexit
1299 }
1300
1301
1302 # Return 1 if we're generating 32-bit code using default options, 0
1303 # otherwise.
1304
1305 proc check_effective_target_ilp32 { } {
1306     return [check_no_compiler_messages ilp32 object {
1307         int dummy[sizeof (int) == 4
1308                   && sizeof (void *) == 4
1309                   && sizeof (long) == 4 ? 1 : -1];
1310     }]
1311 }
1312
1313 # Return 1 if we're generating 32-bit or larger integers using default
1314 # options, 0 otherwise.
1315
1316 proc check_effective_target_int32plus { } {
1317     return [check_no_compiler_messages int32plus object {
1318         int dummy[sizeof (int) >= 4 ? 1 : -1];
1319     }]
1320 }
1321
1322 # Return 1 if we're generating 32-bit or larger pointers using default
1323 # options, 0 otherwise.
1324
1325 proc check_effective_target_ptr32plus { } {
1326     return [check_no_compiler_messages ptr32plus object {
1327         int dummy[sizeof (void *) >= 4 ? 1 : -1];
1328     }]
1329 }
1330
1331 # Return 1 if we support 32-bit or larger array and structure sizes
1332 # using default options, 0 otherwise.
1333
1334 proc check_effective_target_size32plus { } {
1335     return [check_no_compiler_messages size32plus object {
1336         char dummy[65537];
1337     }]
1338 }
1339
1340 # Returns 1 if we're generating 16-bit or smaller integers with the
1341 # default options, 0 otherwise.
1342
1343 proc check_effective_target_int16 { } {
1344     return [check_no_compiler_messages int16 object {
1345         int dummy[sizeof (int) < 4 ? 1 : -1];
1346     }]
1347 }
1348
1349 # Return 1 if we're generating 64-bit code using default options, 0
1350 # otherwise.
1351
1352 proc check_effective_target_lp64 { } {
1353     return [check_no_compiler_messages lp64 object {
1354         int dummy[sizeof (int) == 4
1355                   && sizeof (void *) == 8
1356                   && sizeof (long) == 8 ? 1 : -1];
1357     }]
1358 }
1359
1360 # Return 1 if the target supports long double larger than double,
1361 # 0 otherwise.
1362
1363 proc check_effective_target_large_long_double { } {
1364     return [check_no_compiler_messages large_long_double object {
1365         int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1366     }]
1367 }
1368
1369 # Return 1 if the target supports compiling fixed-point,
1370 # 0 otherwise.
1371
1372 proc check_effective_target_fixed_point { } {
1373     return [check_no_compiler_messages fixed_point object {
1374         _Sat _Fract x; _Sat _Accum y;
1375     }]
1376 }
1377
1378 # Return 1 if the target supports compiling decimal floating point,
1379 # 0 otherwise.
1380
1381 proc check_effective_target_dfp_nocache { } {
1382     verbose "check_effective_target_dfp_nocache: compiling source" 2
1383     set ret [string match "" [get_compiler_messages dfp 0 object {
1384         _Decimal32 x; _Decimal64 y; _Decimal128 z;
1385     }]]
1386     verbose "check_effective_target_dfp_nocache: returning $ret" 2
1387     return $ret
1388 }
1389
1390 proc check_effective_target_dfprt_nocache { } {
1391     global tool
1392
1393     set ret 0
1394
1395     verbose "check_effective_target_dfprt_nocache: compiling source" 2
1396     # Set up, compile, and execute a test program containing decimal
1397     # float operations.
1398     set src dfprt[pid].c
1399     set exe dfprt[pid].x
1400
1401     set f [open $src "w"]
1402     puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1403     puts $f "int main () { z = x + y; return 0; }"
1404     close $f
1405
1406     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1407     set lines [${tool}_target_compile $src $exe executable ""]
1408     file delete $src
1409
1410     if [string match "" $lines] then {
1411         # No error message, compilation succeeded.
1412         set result [${tool}_load "./$exe" "" ""]
1413         set status [lindex $result 0]
1414         remote_file build delete $exe
1415         verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1416         if { $status == "pass" } then {
1417             set ret 1
1418         }
1419     }
1420     return $ret
1421     verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1422 }
1423
1424 # Return 1 if the target supports compiling Decimal Floating Point,
1425 # 0 otherwise.
1426 #
1427 # This won't change for different subtargets so cache the result.
1428
1429 proc check_effective_target_dfp { } {
1430     global et_dfp_saved
1431
1432     if [info exists et_dfp_saved] {
1433         verbose "check_effective_target_dfp: using cached result" 2
1434     } else {
1435         set et_dfp_saved [check_effective_target_dfp_nocache]
1436     }
1437     verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1438     return $et_dfp_saved
1439 }
1440
1441 # Return 1 if the target supports linking and executing Decimal Floating
1442 # Point, # 0 otherwise.
1443 #
1444 # This won't change for different subtargets so cache the result.
1445
1446 proc check_effective_target_dfprt { } {
1447     global et_dfprt_saved
1448     global tool
1449
1450     if [info exists et_dfprt_saved] {
1451         verbose "check_effective_target_dfprt: using cached result" 2
1452     } else {
1453         set et_dfprt_saved [check_effective_target_dfprt_nocache]
1454     }
1455     verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1456     return $et_dfprt_saved
1457 }
1458
1459 # Return 1 if the target needs a command line argument to enable a SIMD
1460 # instruction set.
1461
1462 proc check_effective_target_vect_cmdline_needed { } {
1463     global et_vect_cmdline_needed_saved
1464     global et_vect_cmdline_needed_target_name
1465
1466     if { ![info exists et_vect_cmdline_needed_target_name] } {
1467         set et_vect_cmdline_needed_target_name ""
1468     }
1469
1470     # If the target has changed since we set the cached value, clear it.
1471     set current_target [current_target_name]
1472     if { $current_target != $et_vect_cmdline_needed_target_name } {
1473         verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1474         set et_vect_cmdline_needed_target_name $current_target
1475         if { [info exists et_vect_cmdline_needed_saved] } {
1476             verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1477             unset et_vect_cmdline_needed_saved
1478         }
1479     }
1480
1481     if [info exists et_vect_cmdline_needed_saved] {
1482         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1483     } else {
1484         set et_vect_cmdline_needed_saved 1
1485         if { [istarget ia64-*-*]
1486              || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1487                  && [check_effective_target_lp64])
1488              || ([istarget powerpc*-*-*]
1489                  && ([check_effective_target_powerpc_spe]
1490                      || [check_effective_target_powerpc_altivec]))} {
1491            set et_vect_cmdline_needed_saved 0
1492         }
1493     }
1494
1495     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1496     return $et_vect_cmdline_needed_saved
1497 }
1498
1499 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1500 #
1501 # This won't change for different subtargets so cache the result.
1502
1503 proc check_effective_target_vect_int { } {
1504     global et_vect_int_saved
1505
1506     if [info exists et_vect_int_saved] {
1507         verbose "check_effective_target_vect_int: using cached result" 2
1508     } else {
1509         set et_vect_int_saved 0
1510         if { [istarget i?86-*-*]
1511              || ([istarget powerpc*-*-*]
1512                   && ![istarget powerpc-*-linux*paired*])
1513               || [istarget spu-*-*]
1514               || [istarget x86_64-*-*]
1515               || [istarget sparc*-*-*]
1516               || [istarget alpha*-*-*]
1517               || [istarget ia64-*-*] } {
1518            set et_vect_int_saved 1
1519         }
1520     }
1521
1522     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1523     return $et_vect_int_saved
1524 }
1525
1526 # Return 1 if the target supports int->float conversion 
1527 #
1528
1529 proc check_effective_target_vect_intfloat_cvt { } {
1530     global et_vect_intfloat_cvt_saved
1531
1532     if [info exists et_vect_intfloat_cvt_saved] {
1533         verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1534     } else {
1535         set et_vect_intfloat_cvt_saved 0
1536         if { [istarget i?86-*-*]
1537               || ([istarget powerpc*-*-*]
1538                    && ![istarget powerpc-*-linux*paired*])
1539               || [istarget x86_64-*-*] } {
1540            set et_vect_intfloat_cvt_saved 1
1541         }
1542     }
1543
1544     verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1545     return $et_vect_intfloat_cvt_saved
1546 }
1547
1548
1549 # Return 1 if the target supports float->int conversion
1550 #
1551
1552 proc check_effective_target_vect_floatint_cvt { } {
1553     global et_vect_floatint_cvt_saved
1554
1555     if [info exists et_vect_floatint_cvt_saved] {
1556         verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1557     } else {
1558         set et_vect_floatint_cvt_saved 0
1559         if { [istarget i?86-*-*]
1560               || [istarget x86_64-*-*] } {
1561            set et_vect_floatint_cvt_saved 1
1562         }
1563     }
1564
1565     verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1566     return $et_vect_floatint_cvt_saved
1567 }
1568
1569 # Return 1 is this is an arm target using 32-bit instructions
1570 proc check_effective_target_arm32 { } {
1571     return [check_no_compiler_messages arm32 assembly {
1572         #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1573         #error FOO
1574         #endif
1575     }]
1576 }
1577
1578 # Return 1 if this is an ARM target supporting -mfpu=vfp
1579 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1580 # options.
1581
1582 proc check_effective_target_arm_vfp_ok { } {
1583     if { [check_effective_target_arm32] } {
1584         return [check_no_compiler_messages arm_vfp_ok object {
1585             int dummy;
1586         } "-mfpu=vfp -mfloat-abi=softfp"]
1587     } else {
1588         return 0
1589     }
1590 }
1591
1592 # Return 1 if this is an ARM target supporting -mfpu=neon
1593 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1594 # options.
1595
1596 proc check_effective_target_arm_neon_ok { } {
1597     if { [check_effective_target_arm32] } {
1598         return [check_no_compiler_messages arm_neon_ok object {
1599             int dummy;
1600         } "-mfpu=neon -mfloat-abi=softfp"]
1601     } else {
1602         return 0
1603     }
1604 }
1605
1606 # Return 1 if the target supports executing NEON instructions, 0
1607 # otherwise.  Cache the result.
1608
1609 proc check_effective_target_arm_neon_hw { } {
1610     global arm_neon_hw_available_saved
1611     global tool
1612
1613     if [info exists arm_neon_hw_available_saved] {
1614         verbose "check_arm_neon_hw_available  returning saved $arm_neon_hw_avail
1615 able_saved" 2
1616     } else {
1617         set arm_neon_hw_available_saved 0
1618
1619         # Set up, compile, and execute a test program containing NEON
1620         # instructions.  Include the current process ID in the file
1621         # names to prevent conflicts with invocations for multiple
1622         # testsuites.
1623         set src neon[pid].c
1624         set exe neon[pid].x
1625
1626         set f [open $src "w"]
1627         puts $f "int main() {"
1628         puts $f "  long long a = 0, b = 1;"
1629         puts $f "  asm (\"vorr %P0, %P1, %P2\""
1630         puts $f "       : \"=w\" (a)"
1631         puts $f "       : \"0\" (a), \"w\" (b));"
1632         puts $f "  return (a != 1);"
1633         puts $f "}"
1634         close $f
1635
1636         set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1637
1638         verbose "check_arm_neon_hw_available  compiling testfile $src" 2
1639         set lines [${tool}_target_compile $src $exe executable "$opts"]
1640         file delete $src
1641
1642         if [string match "" $lines] then {
1643             # No error message, compilation succeeded.
1644             set result [${tool}_load "./$exe" "" ""]
1645             set status [lindex $result 0]
1646             remote_file build delete $exe
1647             verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1648
1649             if { $status == "pass" } then {
1650                 set arm_neon_hw_available_saved 1
1651             }
1652         } else {
1653             verbose "check_arm_neon_hw_available testfile compilation failed" 2
1654         }
1655     }
1656
1657     return $arm_neon_hw_available_saved
1658 }
1659
1660 # Return 1 if this is a PowerPC target with floating-point registers.
1661
1662 proc check_effective_target_powerpc_fprs { } {
1663     if { [istarget powerpc*-*-*]
1664          || [istarget rs6000-*-*] } {
1665         return [check_no_compiler_messages powerpc_fprs object {
1666             #ifdef __NO_FPRS__
1667             #error no FPRs
1668             #else
1669             int dummy;
1670             #endif
1671         }]
1672     } else {
1673         return 0
1674     }
1675 }
1676
1677 # Return 1 if this is a PowerPC target supporting -maltivec.
1678
1679 proc check_effective_target_powerpc_altivec_ok { } {
1680     if { ([istarget powerpc*-*-*]
1681          && ![istarget powerpc-*-linux*paired*])
1682          || [istarget rs6000-*-*] } {
1683         # AltiVec is not supported on AIX before 5.3.
1684         if { [istarget powerpc*-*-aix4*]
1685              || [istarget powerpc*-*-aix5.1*] 
1686              || [istarget powerpc*-*-aix5.2*] } {
1687             return 0
1688         }
1689         return [check_no_compiler_messages powerpc_altivec_ok object {
1690             int dummy;
1691         } "-maltivec"]
1692     } else {
1693         return 0
1694     }
1695 }
1696
1697 # Return 1 if this is a PowerPC target with SPE enabled.
1698
1699 proc check_effective_target_powerpc_spe { } {
1700     if { [istarget powerpc*-*-*] } {
1701         return [check_no_compiler_messages powerpc_spe object {
1702             #ifndef __SPE__
1703             #error not SPE
1704             #else
1705             int dummy;
1706             #endif
1707         }]
1708     } else {
1709         return 0
1710     }
1711 }
1712
1713 # Return 1 if this is a PowerPC target with Altivec enabled.
1714
1715 proc check_effective_target_powerpc_altivec { } {
1716     if { [istarget powerpc*-*-*] } {
1717         return [check_no_compiler_messages powerpc_altivec object {
1718             #ifndef __ALTIVEC__
1719             #error not Altivec
1720             #else
1721             int dummy;
1722             #endif
1723         }]
1724     } else {
1725         return 0
1726     }
1727 }
1728
1729 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1730 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables.  Return 1 if the
1731 # test environment appears to run executables on such a simulator.
1732
1733 proc check_effective_target_ultrasparc_hw { } {
1734     global et_ultrasparc_hw_saved
1735     global tool
1736
1737     if [info exists et_ultrasparc_hw_saved] {
1738         verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1739     } else {
1740         set et_ultrasparc_hw_saved 0
1741
1742         # Set up, compile, and execute a simple test program.  The
1743         # program will be compiled with -mcpu=ultrasparc to instruct the
1744         # assembler to produce EM_SPARC32PLUS executables.
1745         set src svect[pid].c
1746         set exe svect[pid].x
1747
1748         set f [open $src "w"]
1749         puts $f "int main() { return 0; }"
1750         close $f
1751
1752         verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1753         set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1754         file delete $src
1755
1756         if [string match "" $lines] then {
1757             # No error message, compilation succeeded.
1758             set result [${tool}_load "./$exe" "" ""]
1759             set status [lindex $result 0]
1760             remote_file build delete $exe
1761             verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1762
1763             if { $status == "pass" } then {
1764                 set et_ultrasparc_hw_saved 1
1765             }
1766         } else {
1767             verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1768         }
1769     }
1770
1771     return $et_ultrasparc_hw_saved
1772 }
1773
1774 # Return 1 if the target supports hardware vector shift operation.
1775
1776 proc check_effective_target_vect_shift { } {
1777     global et_vect_shift_saved
1778
1779     if [info exists et_vect_shift_saved] {
1780         verbose "check_effective_target_vect_shift: using cached result" 2
1781     } else {
1782         set et_vect_shift_saved 0
1783         if { ([istarget powerpc*-*-*]
1784              && ![istarget powerpc-*-linux*paired*])
1785              || [istarget ia64-*-*]
1786              || [istarget i?86-*-*]
1787              || [istarget x86_64-*-*] } {
1788            set et_vect_shift_saved 1
1789         }
1790     }
1791
1792     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1793     return $et_vect_shift_saved
1794 }
1795
1796 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1797 #
1798 # This can change for different subtargets so do not cache the result.
1799
1800 proc check_effective_target_vect_long { } {
1801     if { [istarget i?86-*-*]
1802          || (([istarget powerpc*-*-*] 
1803               && ![istarget powerpc-*-linux*paired*]) 
1804               && [check_effective_target_ilp32])
1805          || [istarget x86_64-*-*]
1806          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1807         set answer 1
1808     } else {
1809         set answer 0
1810     }
1811
1812     verbose "check_effective_target_vect_long: returning $answer" 2
1813     return $answer
1814 }
1815
1816 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1817 #
1818 # This won't change for different subtargets so cache the result.
1819
1820 proc check_effective_target_vect_float { } {
1821     global et_vect_float_saved
1822
1823     if [info exists et_vect_float_saved] {
1824         verbose "check_effective_target_vect_float: using cached result" 2
1825     } else {
1826         set et_vect_float_saved 0
1827         if { [istarget i?86-*-*]
1828               || [istarget powerpc*-*-*]
1829               || [istarget spu-*-*]
1830               || [istarget mipsisa64*-*-*]
1831               || [istarget x86_64-*-*]
1832               || [istarget ia64-*-*] } {
1833            set et_vect_float_saved 1
1834         }
1835     }
1836
1837     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1838     return $et_vect_float_saved
1839 }
1840
1841 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1842 #
1843 # This won't change for different subtargets so cache the result.
1844
1845 proc check_effective_target_vect_double { } {
1846     global et_vect_double_saved
1847
1848     if [info exists et_vect_double_saved] {
1849         verbose "check_effective_target_vect_double: using cached result" 2
1850     } else {
1851         set et_vect_double_saved 0
1852         if { [istarget i?86-*-*]
1853               || [istarget x86_64-*-*] 
1854               || [istarget spu-*-*] } {
1855            set et_vect_double_saved 1
1856         }
1857     }
1858
1859     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1860     return $et_vect_double_saved
1861 }
1862
1863 # Return 1 if the target plus current options does not support a vector
1864 # max instruction on "int", 0 otherwise.
1865 #
1866 # This won't change for different subtargets so cache the result.
1867
1868 proc check_effective_target_vect_no_int_max { } {
1869     global et_vect_no_int_max_saved
1870
1871     if [info exists et_vect_no_int_max_saved] {
1872         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1873     } else {
1874         set et_vect_no_int_max_saved 0
1875         if { [istarget sparc*-*-*]
1876              || [istarget spu-*-*]
1877              || [istarget alpha*-*-*] } {
1878             set et_vect_no_int_max_saved 1
1879         }
1880     }
1881     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1882     return $et_vect_no_int_max_saved
1883 }
1884
1885 # Return 1 if the target plus current options does not support a vector
1886 # add instruction on "int", 0 otherwise.
1887 #
1888 # This won't change for different subtargets so cache the result.
1889
1890 proc check_effective_target_vect_no_int_add { } {
1891     global et_vect_no_int_add_saved
1892
1893     if [info exists et_vect_no_int_add_saved] {
1894         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1895     } else {
1896         set et_vect_no_int_add_saved 0
1897         # Alpha only supports vector add on V8QI and V4HI.
1898         if { [istarget alpha*-*-*] } {
1899             set et_vect_no_int_add_saved 1
1900         }
1901     }
1902     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1903     return $et_vect_no_int_add_saved
1904 }
1905
1906 # Return 1 if the target plus current options does not support vector
1907 # bitwise instructions, 0 otherwise.
1908 #
1909 # This won't change for different subtargets so cache the result.
1910
1911 proc check_effective_target_vect_no_bitwise { } {
1912     global et_vect_no_bitwise_saved
1913
1914     if [info exists et_vect_no_bitwise_saved] {
1915         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1916     } else {
1917         set et_vect_no_bitwise_saved 0
1918     }
1919     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1920     return $et_vect_no_bitwise_saved
1921 }
1922
1923 # Return 1 if the target plus current options supports a vector
1924 # widening summation of *short* args into *int* result, 0 otherwise.
1925 # A target can also support this widening summation if it can support
1926 # promotion (unpacking) from shorts to ints.
1927 #
1928 # This won't change for different subtargets so cache the result.
1929                                                                                                 
1930 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1931     global et_vect_widen_sum_hi_to_si
1932
1933     if [info exists et_vect_widen_sum_hi_to_si_saved] {
1934         verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1935     } else {
1936         set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1937         if { [istarget powerpc*-*-*] 
1938              || [istarget ia64-*-*] } {
1939             set et_vect_widen_sum_hi_to_si_saved 1
1940         }
1941     }
1942     verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1943     return $et_vect_widen_sum_hi_to_si_saved
1944 }
1945
1946 # Return 1 if the target plus current options supports a vector
1947 # widening summation of *char* args into *short* result, 0 otherwise.
1948 # A target can also support this widening summation if it can support
1949 # promotion (unpacking) from chars to shorts.
1950 #
1951 # This won't change for different subtargets so cache the result.
1952                                                                                                 
1953 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1954     global et_vect_widen_sum_qi_to_hi
1955
1956     if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1957         verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1958     } else {
1959         set et_vect_widen_sum_qi_to_hi_saved 0
1960         if { [check_effective_target_vect_unpack] 
1961              || [istarget ia64-*-*] } {
1962             set et_vect_widen_sum_qi_to_hi_saved 1
1963         }
1964     }
1965     verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1966     return $et_vect_widen_sum_qi_to_hi_saved
1967 }
1968
1969 # Return 1 if the target plus current options supports a vector
1970 # widening summation of *char* args into *int* result, 0 otherwise.
1971 #
1972 # This won't change for different subtargets so cache the result.
1973                                                                                                 
1974 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1975     global et_vect_widen_sum_qi_to_si
1976
1977     if [info exists et_vect_widen_sum_qi_to_si_saved] {
1978         verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1979     } else {
1980         set et_vect_widen_sum_qi_to_si_saved 0
1981         if { [istarget powerpc*-*-*] } {
1982             set et_vect_widen_sum_qi_to_si_saved 1
1983         }
1984     }
1985     verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1986     return $et_vect_widen_sum_qi_to_si_saved
1987 }
1988
1989 # Return 1 if the target plus current options supports a vector
1990 # widening multiplication of *char* args into *short* result, 0 otherwise.
1991 # A target can also support this widening multplication if it can support
1992 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1993 # multiplication of shorts).
1994 #
1995 # This won't change for different subtargets so cache the result.
1996
1997
1998 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1999     global et_vect_widen_mult_qi_to_hi
2000
2001     if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2002         verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2003     } else {
2004         if { [check_effective_target_vect_unpack]
2005              && [check_effective_target_vect_short_mult] } {
2006             set et_vect_widen_mult_qi_to_hi_saved 1
2007         } else {
2008             set et_vect_widen_mult_qi_to_hi_saved 0
2009         }
2010         if { [istarget powerpc*-*-*] } {
2011             set et_vect_widen_mult_qi_to_hi_saved 1
2012         }
2013     }
2014     verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2015     return $et_vect_widen_mult_qi_to_hi_saved
2016 }
2017
2018 # Return 1 if the target plus current options supports a vector
2019 # widening multiplication of *short* args into *int* result, 0 otherwise.
2020 # A target can also support this widening multplication if it can support
2021 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2022 # multiplication of ints).
2023 #
2024 # This won't change for different subtargets so cache the result.
2025
2026
2027 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2028     global et_vect_widen_mult_hi_to_si
2029
2030     if [info exists et_vect_widen_mult_hi_to_si_saved] {
2031         verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2032     } else {
2033         if { [check_effective_target_vect_unpack]
2034              && [check_effective_target_vect_int_mult] } {
2035           set et_vect_widen_mult_hi_to_si_saved 1
2036         } else {
2037           set et_vect_widen_mult_hi_to_si_saved 0
2038         }
2039         if { [istarget powerpc*-*-*]
2040               || [istarget spu-*-*]
2041               || [istarget i?86-*-*]
2042               || [istarget x86_64-*-*] } {
2043             set et_vect_widen_mult_hi_to_si_saved 1
2044         }
2045     }
2046     verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2047     return $et_vect_widen_mult_hi_to_si_saved
2048 }
2049
2050 # Return 1 if the target plus current options supports a vector
2051 # dot-product of signed chars, 0 otherwise.
2052 #
2053 # This won't change for different subtargets so cache the result.
2054
2055 proc check_effective_target_vect_sdot_qi { } {
2056     global et_vect_sdot_qi
2057
2058     if [info exists et_vect_sdot_qi_saved] {
2059         verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2060     } else {
2061         set et_vect_sdot_qi_saved 0
2062     }
2063     verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2064     return $et_vect_sdot_qi_saved
2065 }
2066
2067 # Return 1 if the target plus current options supports a vector
2068 # dot-product of unsigned chars, 0 otherwise.
2069 #
2070 # This won't change for different subtargets so cache the result.
2071
2072 proc check_effective_target_vect_udot_qi { } {
2073     global et_vect_udot_qi
2074
2075     if [info exists et_vect_udot_qi_saved] {
2076         verbose "check_effective_target_vect_udot_qi: using cached result" 2
2077     } else {
2078         set et_vect_udot_qi_saved 0
2079         if { [istarget powerpc*-*-*] } {
2080             set et_vect_udot_qi_saved 1
2081         }
2082     }
2083     verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2084     return $et_vect_udot_qi_saved
2085 }
2086
2087 # Return 1 if the target plus current options supports a vector
2088 # dot-product of signed shorts, 0 otherwise.
2089 #
2090 # This won't change for different subtargets so cache the result.
2091
2092 proc check_effective_target_vect_sdot_hi { } {
2093     global et_vect_sdot_hi
2094
2095     if [info exists et_vect_sdot_hi_saved] {
2096         verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2097     } else {
2098         set et_vect_sdot_hi_saved 0
2099         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2100              || [istarget i?86-*-*]
2101              || [istarget x86_64-*-*] } {
2102             set et_vect_sdot_hi_saved 1
2103         }
2104     }
2105     verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2106     return $et_vect_sdot_hi_saved
2107 }
2108
2109 # Return 1 if the target plus current options supports a vector
2110 # dot-product of unsigned shorts, 0 otherwise.
2111 #
2112 # This won't change for different subtargets so cache the result.
2113
2114 proc check_effective_target_vect_udot_hi { } {
2115     global et_vect_udot_hi
2116
2117     if [info exists et_vect_udot_hi_saved] {
2118         verbose "check_effective_target_vect_udot_hi: using cached result" 2
2119     } else {
2120         set et_vect_udot_hi_saved 0
2121         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2122             set et_vect_udot_hi_saved 1
2123         }
2124     }
2125     verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2126     return $et_vect_udot_hi_saved
2127 }
2128
2129
2130 # Return 1 if the target plus current options supports a vector
2131 # demotion (packing) of shorts (to chars) and ints (to shorts) 
2132 # using modulo arithmetic, 0 otherwise.
2133 #
2134 # This won't change for different subtargets so cache the result.
2135                                                                                 
2136 proc check_effective_target_vect_pack_trunc { } {
2137     global et_vect_pack_trunc
2138                                                                                 
2139     if [info exists et_vect_pack_trunc_saved] {
2140         verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2141     } else {
2142         set et_vect_pack_trunc_saved 0
2143         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2144              || [istarget i?86-*-*]
2145              || [istarget x86_64-*-*] } {
2146             set et_vect_pack_trunc_saved 1
2147         }
2148     }
2149     verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2150     return $et_vect_pack_trunc_saved
2151 }
2152
2153 # Return 1 if the target plus current options supports a vector
2154 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2155 #
2156 # This won't change for different subtargets so cache the result.
2157                                    
2158 proc check_effective_target_vect_unpack { } {
2159     global et_vect_unpack
2160                                         
2161     if [info exists et_vect_unpack_saved] {
2162         verbose "check_effective_target_vect_unpack: using cached result" 2
2163     } else {
2164         set et_vect_unpack_saved 0
2165         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2166              || [istarget i?86-*-*]
2167              || [istarget x86_64-*-*] } {
2168             set et_vect_unpack_saved 1
2169         }
2170     }
2171     verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2  
2172     return $et_vect_unpack_saved
2173 }
2174
2175 # Return 1 if the target plus current options does not guarantee
2176 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2177 #
2178 # This won't change for different subtargets so cache the result.
2179
2180 proc check_effective_target_unaligned_stack { } {
2181     global et_unaligned_stack_saved
2182
2183     if [info exists et_unaligned_stack_saved] {
2184         verbose "check_effective_target_unaligned_stack: using cached result" 2
2185     } else {
2186         set et_unaligned_stack_saved 0
2187         if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
2188           && (! [istarget *-*-darwin*] ) } {
2189             set et_unaligned_stack_saved 1
2190         }
2191     }
2192     verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2193     return $et_unaligned_stack_saved
2194 }
2195
2196 # Return 1 if the target plus current options does not support a vector
2197 # alignment mechanism, 0 otherwise.
2198 #
2199 # This won't change for different subtargets so cache the result.
2200
2201 proc check_effective_target_vect_no_align { } {
2202     global et_vect_no_align_saved
2203
2204     if [info exists et_vect_no_align_saved] {
2205         verbose "check_effective_target_vect_no_align: using cached result" 2
2206     } else {
2207         set et_vect_no_align_saved 0
2208         if { [istarget mipsisa64*-*-*]
2209              || [istarget sparc*-*-*]
2210              || [istarget ia64-*-*] } { 
2211             set et_vect_no_align_saved 1
2212         }
2213     }
2214     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2215     return $et_vect_no_align_saved
2216 }
2217
2218 # Return 1 if arrays are aligned to the vector alignment
2219 # boundary, 0 otherwise.
2220 #
2221 # This won't change for different subtargets so cache the result.
2222
2223 proc check_effective_target_vect_aligned_arrays { } {
2224     global et_vect_aligned_arrays
2225
2226     if [info exists et_vect_aligned_arrays_saved] {
2227         verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2228     } else {
2229         set et_vect_aligned_arrays_saved 0
2230         if { (([istarget x86_64-*-*]
2231               || [istarget i?86-*-*]) && [is-effective-target lp64])
2232               || [istarget spu-*-*] } {
2233             set et_vect_aligned_arrays_saved 1
2234         }
2235     }
2236     verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2237     return $et_vect_aligned_arrays_saved
2238 }
2239
2240 # Return 1 if types of size 32 bit or less are naturally aligned
2241 # (aligned to their type-size), 0 otherwise.
2242 #
2243 # This won't change for different subtargets so cache the result.
2244
2245 proc check_effective_target_natural_alignment_32 { } {
2246     global et_natural_alignment_32
2247
2248     if [info exists et_natural_alignment_32_saved] {
2249         verbose "check_effective_target_natural_alignment_32: using cached result" 2
2250     } else {
2251         # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2252         set et_natural_alignment_32_saved 1
2253         if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2254             set et_natural_alignment_32_saved 0
2255         }
2256     }
2257     verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2258     return $et_natural_alignment_32_saved
2259 }
2260
2261 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2262 # type-size), 0 otherwise.
2263 #
2264 # This won't change for different subtargets so cache the result.
2265
2266 proc check_effective_target_natural_alignment_64 { } {
2267     global et_natural_alignment_64
2268
2269     if [info exists et_natural_alignment_64_saved] {
2270         verbose "check_effective_target_natural_alignment_64: using cached result" 2
2271     } else {
2272         set et_natural_alignment_64_saved 0
2273         if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2274              || [istarget spu-*-*] } {
2275             set et_natural_alignment_64_saved 1
2276         }
2277     }
2278     verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2279     return $et_natural_alignment_64_saved
2280 }
2281
2282 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2283 #
2284 # This won't change for different subtargets so cache the result.
2285
2286 proc check_effective_target_vector_alignment_reachable { } {
2287     global et_vector_alignment_reachable
2288
2289     if [info exists et_vector_alignment_reachable_saved] {
2290         verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2291     } else {
2292         if { [check_effective_target_vect_aligned_arrays]
2293              || [check_effective_target_natural_alignment_32] } {
2294             set et_vector_alignment_reachable_saved 1
2295         } else {
2296             set et_vector_alignment_reachable_saved 0
2297         }
2298     }
2299     verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2300     return $et_vector_alignment_reachable_saved
2301 }
2302
2303 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2304 #
2305 # This won't change for different subtargets so cache the result.
2306
2307 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2308     global et_vector_alignment_reachable_for_64bit
2309
2310     if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2311         verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2312     } else {
2313         if { [check_effective_target_vect_aligned_arrays] 
2314              || [check_effective_target_natural_alignment_64] } {
2315             set et_vector_alignment_reachable_for_64bit_saved 1
2316         } else {
2317             set et_vector_alignment_reachable_for_64bit_saved 0
2318         }
2319     }
2320     verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2321     return $et_vector_alignment_reachable_for_64bit_saved
2322 }
2323
2324 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2325
2326 proc check_effective_target_vect_condition { } {
2327     global et_vect_cond_saved
2328
2329     if [info exists et_vect_cond_saved] {
2330         verbose "check_effective_target_vect_cond: using cached result" 2
2331     } else {
2332         set et_vect_cond_saved 0
2333         if { [istarget powerpc*-*-*]
2334              || [istarget ia64-*-*]
2335              || [istarget i?86-*-*]
2336              || [istarget spu-*-*]
2337              || [istarget x86_64-*-*] } {
2338            set et_vect_cond_saved 1
2339         }
2340     }
2341
2342     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2343     return $et_vect_cond_saved
2344 }
2345
2346 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2347
2348 proc check_effective_target_vect_char_mult { } {
2349     global et_vect_char_mult_saved
2350
2351     if [info exists et_vect_char_mult_saved] {
2352         verbose "check_effective_target_vect_char_mult: using cached result" 2
2353     } else {
2354         set et_vect_char_mult_saved 0
2355         if { [istarget ia64-*-*]
2356              || [istarget i?86-*-*]
2357              || [istarget x86_64-*-*] } {
2358            set et_vect_char_mult_saved 1
2359         }
2360     }
2361
2362     verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2363     return $et_vect_char_mult_saved
2364 }
2365
2366 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2367
2368 proc check_effective_target_vect_short_mult { } {
2369     global et_vect_short_mult_saved
2370
2371     if [info exists et_vect_short_mult_saved] {
2372         verbose "check_effective_target_vect_short_mult: using cached result" 2
2373     } else {
2374         set et_vect_short_mult_saved 0
2375         if { [istarget ia64-*-*]
2376              || [istarget i?86-*-*]
2377              || [istarget x86_64-*-*] } {
2378            set et_vect_short_mult_saved 1
2379         }
2380     }
2381
2382     verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2383     return $et_vect_short_mult_saved
2384 }
2385
2386 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2387
2388 proc check_effective_target_vect_int_mult { } {
2389     global et_vect_int_mult_saved
2390
2391     if [info exists et_vect_int_mult_saved] {
2392         verbose "check_effective_target_vect_int_mult: using cached result" 2
2393     } else {
2394         set et_vect_int_mult_saved 0
2395         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2396              || [istarget spu-*-*]
2397              || [istarget i?86-*-*]
2398              || [istarget x86_64-*-*] } {
2399            set et_vect_int_mult_saved 1
2400         }
2401     }
2402
2403     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2404     return $et_vect_int_mult_saved
2405 }
2406
2407 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2408
2409 proc check_effective_target_vect_extract_even_odd { } {
2410     global et_vect_extract_even_odd_saved
2411     
2412     if [info exists et_vect_extract_even_odd_saved] {
2413         verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2414     } else {
2415         set et_vect_extract_even_odd_saved 0 
2416         if { [istarget powerpc*-*-*] } {
2417            set et_vect_extract_even_odd_saved 1
2418         }
2419     }
2420
2421     verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2422     return $et_vect_extract_even_odd_saved
2423 }
2424
2425 # Return 1 if the target supports vector interleaving, 0 otherwise.
2426
2427 proc check_effective_target_vect_interleave { } {
2428     global et_vect_interleave_saved
2429     
2430     if [info exists et_vect_interleave_saved] {
2431         verbose "check_effective_target_vect_interleave: using cached result" 2
2432     } else {
2433         set et_vect_interleave_saved 0
2434         if { [istarget powerpc*-*-*]
2435              || [istarget i?86-*-*]
2436              || [istarget x86_64-*-*] } {
2437            set et_vect_interleave_saved 1
2438         }
2439     }
2440
2441     verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2442     return $et_vect_interleave_saved
2443 }
2444
2445 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2446 proc check_effective_target_vect_strided { } {
2447     global et_vect_strided_saved
2448
2449     if [info exists et_vect_strided_saved] {
2450         verbose "check_effective_target_vect_strided: using cached result" 2
2451     } else {
2452         set et_vect_strided_saved 0
2453         if { [check_effective_target_vect_interleave]
2454              && [check_effective_target_vect_extract_even_odd] } {
2455            set et_vect_strided_saved 1
2456         }
2457     }
2458
2459     verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2460     return $et_vect_strided_saved
2461 }
2462
2463 # Return 1 if the target supports section-anchors
2464
2465 proc check_effective_target_section_anchors { } {
2466     global et_section_anchors_saved
2467
2468     if [info exists et_section_anchors_saved] {
2469         verbose "check_effective_target_section_anchors: using cached result" 2
2470     } else {
2471         set et_section_anchors_saved 0
2472         if { [istarget powerpc*-*-*] } {
2473            set et_section_anchors_saved 1
2474         }
2475     }
2476
2477     verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2478     return $et_section_anchors_saved
2479 }
2480
2481 # Return 1 if the target supports atomic operations on "int" and "long".
2482
2483 proc check_effective_target_sync_int_long { } {
2484     global et_sync_int_long_saved
2485
2486     if [info exists et_sync_int_long_saved] {
2487         verbose "check_effective_target_sync_int_long: using cached result" 2
2488     } else {
2489         set et_sync_int_long_saved 0
2490 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2491 # load-reserved/store-conditional instructions.
2492         if { [istarget ia64-*-*]
2493              || [istarget i?86-*-*]
2494              || [istarget x86_64-*-*]
2495              || [istarget alpha*-*-*] 
2496              || [istarget s390*-*-*] 
2497              || [istarget powerpc*-*-*]
2498              || [istarget sparc64-*-*]
2499              || [istarget sparcv9-*-*] } {
2500            set et_sync_int_long_saved 1
2501         }
2502     }
2503
2504     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2505     return $et_sync_int_long_saved
2506 }
2507
2508 # Return 1 if the target supports atomic operations on "char" and "short".
2509
2510 proc check_effective_target_sync_char_short { } {
2511     global et_sync_char_short_saved
2512
2513     if [info exists et_sync_char_short_saved] {
2514         verbose "check_effective_target_sync_char_short: using cached result" 2
2515     } else {
2516         set et_sync_char_short_saved 0
2517 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2518 # load-reserved/store-conditional instructions.
2519         if { [istarget ia64-*-*]
2520              || [istarget i?86-*-*]
2521              || [istarget x86_64-*-*]
2522              || [istarget alpha*-*-*] 
2523              || [istarget s390*-*-*] 
2524              || [istarget powerpc*-*-*]
2525              || [istarget sparc64-*-*]
2526              || [istarget sparcv9-*-*] } {
2527            set et_sync_char_short_saved 1
2528         }
2529     }
2530
2531     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2532     return $et_sync_char_short_saved
2533 }
2534
2535 # Return 1 if the target uses a ColdFire FPU.
2536
2537 proc check_effective_target_coldfire_fpu { } {
2538     return [check_no_compiler_messages coldfire_fpu assembly {
2539         #ifndef __mcffpu__
2540         #error FOO
2541         #endif
2542     }]
2543 }
2544
2545 # Return true if this is a uClibc target.
2546
2547 proc check_effective_target_uclibc {} {
2548     return [check_no_compiler_messages uclibc object {
2549         #include <features.h>
2550         #if !defined (__UCLIBC__)
2551         #error FOO
2552         #endif
2553     }]
2554 }
2555
2556 # Return true if this is a uclibc target and if the uclibc feature
2557 # described by __$feature__ is not present.
2558
2559 proc check_missing_uclibc_feature {feature} {
2560     return [check_no_compiler_messages $feature object "
2561         #include <features.h>
2562         #if !defined (__UCLIBC) || defined (__${feature}__)
2563         #error FOO
2564         #endif
2565     "]
2566 }
2567
2568 # Return true if this is a Newlib target.
2569
2570 proc check_effective_target_newlib {} {
2571     return [check_no_compiler_messages newlib object {
2572         #include <newlib.h>
2573     }]
2574 }
2575
2576 # Return 1 if
2577 #   (a) an error of a few ULP is expected in string to floating-point
2578 #       conversion functions; and
2579 #   (b) overflow is not always detected correctly by those functions.
2580
2581 proc check_effective_target_lax_strtofp {} {
2582     # By default, assume that all uClibc targets suffer from this.
2583     return [check_effective_target_uclibc]
2584 }
2585
2586 # Return 1 if this is a target for which wcsftime is a dummy
2587 # function that always returns 0.
2588
2589 proc check_effective_target_dummy_wcsftime {} {
2590     # By default, assume that all uClibc targets suffer from this.
2591     return [check_effective_target_uclibc]
2592 }
2593
2594 # Return 1 if constructors with initialization priority arguments are
2595 # supposed on this target.
2596
2597 proc check_effective_target_init_priority {} {
2598     return [check_no_compiler_messages init_priority assembly "
2599         void f() __attribute__((constructor (1000)));
2600         void f() \{\}
2601     "]
2602 }
2603
2604 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2605 # This can be used with any check_* proc that takes no argument and
2606 # returns only 1 or 0.  It could be used with check_* procs that take
2607 # arguments with keywords that pass particular arguments.
2608
2609 proc is-effective-target { arg } {
2610     set selected 0
2611     if { [info procs check_effective_target_${arg}] != [list] } {
2612         set selected [check_effective_target_${arg}]
2613     } else {
2614         switch $arg {
2615           "vmx_hw"         { set selected [check_vmx_hw_available] }
2616           "named_sections" { set selected [check_named_sections_available] }
2617           "gc_sections"    { set selected [check_gc_sections_available] }
2618           "cxa_atexit"     { set selected [check_cxa_atexit_available] }
2619           default          { error "unknown effective target keyword `$arg'" }
2620         }
2621     }
2622     verbose "is-effective-target: $arg $selected" 2
2623     return $selected
2624 }
2625
2626 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2627
2628 proc is-effective-target-keyword { arg } {
2629     if { [info procs check_effective_target_${arg}] != [list] } {
2630         return 1
2631     } else {
2632         # These have different names for their check_* procs.
2633         switch $arg {
2634           "vmx_hw"         { return 1 }
2635           "named_sections" { return 1 }
2636           "gc_sections"    { return 1 }
2637           "cxa_atexit"     { return 1 }
2638           default          { return 0 }
2639         }
2640     }
2641 }
2642
2643 # Return 1 if target default to short enums
2644
2645 proc check_effective_target_short_enums { } {
2646     return [check_no_compiler_messages short_enums assembly {
2647         enum foo { bar };
2648         int s[sizeof (enum foo) == 1 ? 1 : -1];
2649     }]
2650 }
2651
2652 # Return 1 if target supports merging string constants at link time.
2653
2654 proc check_effective_target_string_merging { } {
2655     return [check_no_messages_and_pattern string_merging \
2656                 "rodata\\.str" assembly {
2657                     const char *var = "String";
2658                 } {-O2}]
2659 }
2660
2661 # Return 1 if target has the basic signed and unsigned types in
2662 # <stdint.h>, 0 otherwise.
2663
2664 proc check_effective_target_stdint_types { } {
2665     return [check_no_compiler_messages stdint_types assembly {
2666         #include <stdint.h>
2667         int8_t a; int16_t b; int32_t c; int64_t d;
2668         uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2669     }]
2670 }
2671
2672 # Return 1 if programs are intended to be run on a simulator
2673 # (i.e. slowly) rather than hardware (i.e. fast).
2674
2675 proc check_effective_target_simulator { } {
2676
2677     # All "src/sim" simulators set this one.
2678     if [board_info target exists is_simulator] {
2679         return [board_info target is_simulator]
2680     }
2681
2682     # The "sid" simulators don't set that one, but at least they set
2683     # this one.
2684     if [board_info target exists slow_simulator] {
2685         return [board_info target slow_simulator]
2686     }
2687
2688     return 0
2689 }
2690
2691 # Return 1 if the target is a VxWorks RTP.
2692
2693 proc check_effective_target_vxworks_kernel { } {
2694     return [check_no_compiler_messages vxworks_kernel assembly {
2695         #if !defined __vxworks || defined __RTP__
2696         #error NO
2697         #endif
2698     }]
2699 }
2700
2701 # Return 1 if the target is expected to provide wide character support.
2702
2703 proc check_effective_target_wchar { } {
2704     if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2705         return 0
2706     }
2707     return [check_no_compiler_messages wchar assembly {
2708         #include <wchar.h>
2709     }]
2710 }
2711
2712 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2713
2714 proc add_options_for_c99_runtime { flags } {
2715     if { [istarget *-*-solaris2*] } {
2716         return "$flags -std=c99"
2717     }
2718     if { [istarget powerpc-*-darwin*] } {
2719         return "$flags -mmacosx-version-min=10.3"
2720     }
2721     return $flags
2722 }
2723
2724 # Return 1 if the target provides a full C99 runtime.
2725
2726 proc check_effective_target_c99_runtime { } {
2727     return [check_cached_effective_target c99_runtime {
2728         global srcdir
2729
2730         set file [open "$srcdir/gcc.dg/builtins-config.h"]
2731         set contents [read $file]
2732         close $file
2733         append contents {
2734             #ifndef HAVE_C99_RUNTIME
2735             #error FOO
2736             #endif
2737         }
2738         string match "" [get_compiler_messages c99_runtime 0 assembly \
2739                              $contents [add_options_for_c99_runtime ""]]
2740     }]
2741 }