OSDN Git Service

gcc:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / target-supports.exp
1 #   Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile.  Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
27 #
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
31 #
32 # Assume by default that CONTENTS is C code.  
33 # Otherwise, code should contain:
34 # "// C++" for c++,
35 # "! Fortran" for Fortran code,
36 # "/* ObjC", for ObjC
37 # and "// ObjC++" for ObjC++
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to 
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41     global tool
42     verbose "check_compile tool: $tool for $basename" 
43
44     if { [llength $args] > 0 } {
45         set options [list "additional_flags=[lindex $args 0]"]
46     } else {
47         set options ""
48     }
49     switch -glob -- $contents {
50         "*! Fortran*" { set src ${basename}[pid].f90 }
51         "*// C++*" { set src ${basename}[pid].cc }
52         "*// ObjC++*" { set src ${basename}[pid].mm }
53         "*/* ObjC*" { set src ${basename}[pid].m }
54         default {
55             switch -- $tool {
56                 "objc" { set src ${basename}[pid].m }
57                 "obj-c++" { set src ${basename}[pid].mm }
58                 default { set src ${basename}[pid].c }
59             }
60         }
61     }
62
63     set compile_type $type
64     switch -glob $type {
65         assembly { set output ${basename}[pid].s }
66         object { set output ${basename}[pid].o }
67         executable { set output ${basename}[pid].exe }
68         "rtl-*" {
69             set output ${basename}[pid].s
70             lappend options "additional_flags=-fdump-$type"
71             set compile_type assembly
72         }
73     }
74     set f [open $src "w"]
75     puts $f $contents
76     close $f
77     set lines [${tool}_target_compile $src $output $compile_type "$options"]
78     file delete $src
79
80     set scan_output $output
81     # Don't try folding this into the switch above; calling "glob" before the
82     # file is created won't work.
83     if [regexp "rtl-(.*)" $type dummy rtl_type] {
84         set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
85         file delete $output
86     }
87
88     return [list $lines $scan_output]
89 }
90
91 proc current_target_name { } {
92     global target_info
93     if [info exists target_info(target,name)] {
94         set answer $target_info(target,name)
95     } else {
96         set answer ""
97     }
98     return $answer
99 }
100
101 # Implement an effective-target check for property PROP by invoking
102 # the Tcl command ARGS and seeing if it returns true.
103
104 proc check_cached_effective_target { prop args } {
105     global et_cache
106
107     set target [current_target_name]
108     if {![info exists et_cache($prop,target)]
109         || $et_cache($prop,target) != $target} {
110         verbose "check_cached_effective_target $prop: checking $target" 2
111         set et_cache($prop,target) $target
112         set et_cache($prop,value) [uplevel eval $args]
113     }
114     set value $et_cache($prop,value)
115     verbose "check_cached_effective_target $prop: returning $value for $target" 2
116     return $value
117 }
118
119 # Like check_compile, but delete the output file and return true if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache {args} {
122     set result [eval check_compile $args]
123     set lines [lindex $result 0]
124     set output [lindex $result 1]
125     remote_file build delete $output
126     return [string match "" $lines]
127 }
128
129 # Like check_no_compiler_messages_nocache, but cache the result.
130 # PROP is the property we're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133     return [check_cached_effective_target $prop {
134         eval [list check_no_compiler_messages_nocache $prop] $args
135     }]
136 }
137
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP, otherwise they satisfy it
142 # if they do match regular expression PATTERN.  (PATTERN can start
143 # with something like "[!]" if the regular expression needs to match
144 # "!" as the first character.)
145 #
146 # Delete the output file before returning.  The other arguments are
147 # as for check_compile.
148 proc check_no_messages_and_pattern_nocache {basename pattern args} {
149     global tool
150
151     set result [eval [list check_compile $basename] $args]
152     set lines [lindex $result 0]
153     set output [lindex $result 1]
154
155     set ok 0
156     if { [string match "" $lines] } {
157         set chan [open "$output"]
158         set invert [regexp {^!(.*)} $pattern dummy pattern]
159         set ok [expr { [regexp $pattern [read $chan]] != $invert }]
160         close $chan
161     }
162
163     remote_file build delete $output
164     return $ok
165 }
166
167 # Like check_no_messages_and_pattern_nocache, but cache the result.
168 # PROP is the property we're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171     return [check_cached_effective_target $prop {
172         eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
173     }]
174 }
175
176 # Try to compile and run an executable from code CONTENTS.  Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense.  The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
181     global tool
182
183     set result [eval [list check_compile $basename executable $contents] $args]
184     set lines [lindex $result 0]
185     set output [lindex $result 1]
186
187     set ok 0
188     if { [string match "" $lines] } {
189         # No error messages, everything is OK.
190         set result [remote_load target "./$output" "" ""]
191         set status [lindex $result 0]
192         verbose "check_runtime_nocache $basename: status is <$status>" 2
193         if { $status == "pass" } {
194             set ok 1
195         }
196     }
197     remote_file build delete $output
198     return $ok
199 }
200
201 # Like check_runtime_nocache, but cache the result.  PROP is the
202 # property we're checking, and doubles as a prefix for temporary
203 # filenames.
204 proc check_runtime {prop args} {
205     global tool
206
207     return [check_cached_effective_target $prop {
208         eval [list check_runtime_nocache $prop] $args
209     }]
210 }
211
212 ###############################
213 # proc check_weak_available { }
214 ###############################
215
216 # weak symbols are only supported in some configs/object formats
217 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
218
219 proc check_weak_available { } {
220     global target_triplet
221     global target_cpu
222
223     # All mips targets should support it
224
225     if { [ string first "mips" $target_cpu ] >= 0 } {
226         return 1
227     }
228
229     # All solaris2 targets should support it
230
231     if { [regexp ".*-solaris2.*" $target_triplet] } {
232         return 1
233     }
234
235     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
236
237     if { [regexp "alpha.*osf.*" $target_triplet] } {
238         return 1
239     }
240
241     # Windows targets Cygwin and MingW32 support it
242
243     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
244         return 1
245     }
246
247     # HP-UX 10.X doesn't support it
248
249     if { [istarget "hppa*-*-hpux10*"] } {
250         return 0
251     }
252
253     # ELF and ECOFF support it. a.out does with gas/gld but may also with
254     # other linkers, so we should try it
255
256     set objformat [gcc_target_object_format]
257
258     switch $objformat {
259         elf      { return 1 }
260         ecoff    { return 1 }
261         a.out    { return 1 }
262         mach-o   { return 1 }
263         som      { return 1 }
264         unknown  { return -1 }
265         default  { return 0 }
266     }
267 }
268
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
272
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
275
276 proc check_weak_override_available { } {
277     if { [istarget "*-*-mingw*"] } {
278         return 0
279     }
280     return [check_weak_available]
281 }
282
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
286
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
290
291 proc check_visibility_available { what_kind } {
292     global tool
293     global target_triplet
294
295     # On NetWare, support makes no sense.
296     if { [istarget *-*-netware*] } {
297         return 0
298     }
299
300     if [string match "" $what_kind] { set what_kind "hidden" }
301
302     return [check_no_compiler_messages visibility_available_$what_kind object "
303         void f() __attribute__((visibility(\"$what_kind\")));
304         void f() {}
305     "]
306 }
307
308 ###############################
309 # proc check_alias_available { }
310 ###############################
311
312 # Determine if the target toolchain supports the alias attribute.
313
314 # Returns 2 if the target supports aliases.  Returns 1 if the target
315 # only supports weak aliased.  Returns 0 if the target does not
316 # support aliases at all.  Returns -1 if support for aliases could not
317 # be determined.
318
319 proc check_alias_available { } {
320     global alias_available_saved
321     global tool
322
323     if [info exists alias_available_saved] {
324         verbose "check_alias_available  returning saved $alias_available_saved" 2
325     } else {
326         set src alias[pid].c
327         set obj alias[pid].o
328         verbose "check_alias_available  compiling testfile $src" 2
329         set f [open $src "w"]
330         # Compile a small test program.  The definition of "g" is
331         # necessary to keep the Solaris assembler from complaining
332         # about the program.
333         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
335         close $f
336         set lines [${tool}_target_compile $src $obj object ""]
337         file delete $src
338         remote_file build delete $obj
339
340         if [string match "" $lines] then {
341             # No error messages, everything is OK.
342             set alias_available_saved 2
343         } else {
344             if [regexp "alias definitions not supported" $lines] {
345                 verbose "check_alias_available  target does not support aliases" 2
346
347                 set objformat [gcc_target_object_format]
348
349                 if { $objformat == "elf" } {
350                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
351                     set alias_available_saved -1
352                 } else {
353                     set alias_available_saved 0
354                 }
355             } else {
356                 if [regexp "only weak aliases are supported" $lines] {
357                 verbose "check_alias_available  target supports only weak aliases" 2
358                 set alias_available_saved 1
359                 } else {
360                     set alias_available_saved -1
361                 }
362             }
363         }
364
365         verbose "check_alias_available  returning $alias_available_saved" 2
366     }
367
368     return $alias_available_saved
369 }
370
371 # Returns true if --gc-sections is supported on the target.
372
373 proc check_gc_sections_available { } {
374     global gc_sections_available_saved
375     global tool
376
377     if {![info exists gc_sections_available_saved]} {
378         # Some targets don't support gc-sections despite whatever's
379         # advertised by ld's options.
380         if { [istarget alpha*-*-*]
381              || [istarget ia64-*-*] } {
382             set gc_sections_available_saved 0
383             return 0
384         }
385
386         # elf2flt uses -q (--emit-relocs), which is incompatible with
387         # --gc-sections.
388         if { [board_info target exists ldflags]
389              && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
390             set gc_sections_available_saved 0
391             return 0
392         }
393
394         # VxWorks kernel modules are relocatable objects linked with -r,
395         # while RTP executables are linked with -q (--emit-relocs).
396         # Both of these options are incompatible with --gc-sections.
397         if { [istarget *-*-vxworks*] } {
398             set gc_sections_available_saved 0
399             return 0
400         }
401
402         # Check if the ld used by gcc supports --gc-sections.
403         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
404         regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
405         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
406         set ld_output [remote_exec host "$gcc_ld" "--help"]
407         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
408             set gc_sections_available_saved 1
409         } else {
410             set gc_sections_available_saved 0
411         }
412     }
413     return $gc_sections_available_saved
414 }
415
416 # Return 1 if according to target_info struct and explicit target list
417 # target is supposed to support trampolines.
418  
419 proc check_effective_target_trampolines { } {
420     if [target_info exists no_trampolines] {
421       return 0
422     }
423     if { [istarget avr-*-*]
424          || [istarget hppa2.0w-hp-hpux11.23]
425         || [istarget hppa64-hp-hpux11.23] } {
426         return 0;   
427     }
428     return 1
429 }
430
431 # Return 1 if according to target_info struct and explicit target list
432 # target is supposed to keep null pointer checks. This could be due to 
433 # use of option fno-delete-null-pointer-checks or hardwired in target.
434  
435 proc check_effective_target_keeps_null_pointer_checks { } {
436     if [target_info exists keeps_null_pointer_checks] {
437       return 1
438     }
439     if { [istarget avr-*-*] } {
440         return 1;   
441     }
442     return 0
443 }
444
445 # Return true if profiling is supported on the target.
446
447 proc check_profiling_available { test_what } {
448     global profiling_available_saved
449
450     verbose "Profiling argument is <$test_what>" 1
451
452     # These conditions depend on the argument so examine them before
453     # looking at the cache variable.
454
455     # Support for -p on solaris2 relies on mcrt1.o which comes with the
456     # vendor compiler.  We cannot reliably predict the directory where the
457     # vendor compiler (and thus mcrt1.o) is installed so we can't
458     # necessarily find mcrt1.o even if we have it.
459     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
460         return 0
461     }
462
463     # Support for -p on irix relies on libprof1.a which doesn't appear to
464     # exist on any irix6 system currently posting testsuite results.
465     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
466     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
467     if { [istarget mips*-*-irix*]
468     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
469         return 0
470     }
471
472     # We don't yet support profiling for MIPS16.
473     if { [istarget mips*-*-*]
474          && ![check_effective_target_nomips16]
475          && ([lindex $test_what 1] == "-p"
476              || [lindex $test_what 1] == "-pg") } {
477         return 0
478     }
479
480     # MinGW does not support -p.
481     if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
482         return 0
483     }
484
485     # cygwin does not support -p.
486     if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
487         return 0
488     }
489
490     # uClibc does not have gcrt1.o.
491     if { [check_effective_target_uclibc]
492          && ([lindex $test_what 1] == "-p"
493              || [lindex $test_what 1] == "-pg") } {
494         return 0
495     }
496
497     # Now examine the cache variable.
498     if {![info exists profiling_available_saved]} {
499         # Some targets don't have any implementation of __bb_init_func or are
500         # missing other needed machinery.
501         if { [istarget mmix-*-*]
502              || [istarget arm*-*-eabi*]
503              || [istarget picochip-*-*]
504              || [istarget *-*-netware*]
505              || [istarget arm*-*-elf]
506              || [istarget arm*-*-symbianelf*]
507              || [istarget avr-*-*]
508              || [istarget bfin-*-*]
509              || [istarget powerpc-*-eabi*]
510              || [istarget powerpc-*-elf]
511              || [istarget cris-*-*]
512              || [istarget crisv32-*-*]
513              || [istarget fido-*-elf]
514              || [istarget h8300-*-*]
515              || [istarget lm32-*-*]
516              || [istarget m32c-*-elf]
517              || [istarget m68k-*-elf]
518              || [istarget m68k-*-uclinux*]
519              || [istarget mep-*-elf]
520              || [istarget mips*-*-elf*]
521              || [istarget moxie-*-elf*]
522              || [istarget rx-*-*]       
523              || [istarget xstormy16-*]
524              || [istarget xtensa*-*-elf]
525              || [istarget *-*-rtems*]
526              || [istarget *-*-vxworks*] } {
527             set profiling_available_saved 0
528         } else {
529             set profiling_available_saved 1
530         }
531     }
532
533     return $profiling_available_saved
534 }
535
536 # Check to see if a target is "freestanding". This is as per the definition
537 # in Section 4 of C99 standard. Effectively, it is a target which supports no
538 # extra headers or libraries other than what is considered essential.
539 proc check_effective_target_freestanding { } {
540     if { [istarget picochip-*-*] } then {
541         return 1
542     } else {
543         return 0
544     }
545 }
546
547 # Return 1 if target has packed layout of structure members by
548 # default, 0 otherwise.  Note that this is slightly different than
549 # whether the target has "natural alignment": both attributes may be
550 # false.
551
552 proc check_effective_target_default_packed { } {
553     return [check_no_compiler_messages default_packed assembly {
554         struct x { char a; long b; } c;
555         int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
556     }]
557 }
558
559 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
560 # documentation, where the test also comes from.
561
562 proc check_effective_target_pcc_bitfield_type_matters { } {
563     # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
564     # bitfields, but let's stick to the example code from the docs.
565     return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
566         struct foo1 { char x; char :0; char y; };
567         struct foo2 { char x; int :0; char y; };
568         int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
569     }]
570 }
571
572 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
573
574 proc check_effective_target_tls {} {
575     return [check_no_compiler_messages tls assembly {
576         __thread int i;
577         int f (void) { return i; }
578         void g (int j) { i = j; }
579     }]
580 }
581
582 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
583
584 proc check_effective_target_tls_native {} {
585     # VxWorks uses emulated TLS machinery, but with non-standard helper
586     # functions, so we fail to automatically detect it.
587     global target_triplet
588     if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
589         return 0
590     }
591     
592     return [check_no_messages_and_pattern tls_native "!emutls" assembly {
593         __thread int i;
594         int f (void) { return i; }
595         void g (int j) { i = j; }
596     }]
597 }
598
599 # Return 1 if TLS executables can run correctly, 0 otherwise.
600
601 proc check_effective_target_tls_runtime {} {
602     return [check_runtime tls_runtime {
603         __thread int thr = 0;
604         int main (void) { return thr; }
605     }]
606 }
607
608 # Return 1 if compilation with -fgraphite is error-free for trivial 
609 # code, 0 otherwise.
610
611 proc check_effective_target_fgraphite {} {
612     return [check_no_compiler_messages fgraphite object {
613         void foo (void) { }
614     } "-O1 -fgraphite"]
615 }
616
617 # Return 1 if compilation with -fopenmp is error-free for trivial
618 # code, 0 otherwise.
619
620 proc check_effective_target_fopenmp {} {
621     return [check_no_compiler_messages fopenmp object {
622         void foo (void) { }
623     } "-fopenmp"]
624 }
625
626 # Return 1 if compilation with -pthread is error-free for trivial
627 # code, 0 otherwise.
628
629 proc check_effective_target_pthread {} {
630     return [check_no_compiler_messages pthread object {
631         void foo (void) { }
632     } "-pthread"]
633 }
634
635 # Return 1 if compilation with -mpe-aligned-commons is error-free
636 # for trivial code, 0 otherwise.
637
638 proc check_effective_target_pe_aligned_commons {} {
639     if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
640         return [check_no_compiler_messages pe_aligned_commons object {
641             int foo;
642         } "-mpe-aligned-commons"]
643     }
644     return 0
645 }
646
647 # Return 1 if the target supports -static
648 proc check_effective_target_static {} {
649     return [check_no_compiler_messages static executable {
650         int main (void) { return 0; }
651     } "-static"]
652 }
653
654 # Return 1 if the target supports -fstack-protector
655 proc check_effective_target_fstack_protector {} {
656     return [check_runtime fstack_protector {
657         int main (void) { return 0; }
658     } "-fstack-protector"]
659 }
660
661 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
662 # for trivial code, 0 otherwise.
663
664 proc check_effective_target_freorder {} {
665     return [check_no_compiler_messages freorder object {
666         void foo (void) { }
667     } "-freorder-blocks-and-partition"]
668 }
669
670 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
671 # emitted, 0 otherwise.  Whether a shared library can actually be built is
672 # out of scope for this test.
673
674 proc check_effective_target_fpic { } {
675     # Note that M68K has a multilib that supports -fpic but not
676     # -fPIC, so we need to check both.  We test with a program that
677     # requires GOT references.
678     foreach arg {fpic fPIC} {
679         if [check_no_compiler_messages $arg object {
680             extern int foo (void); extern int bar;
681             int baz (void) { return foo () + bar; }
682         } "-$arg"] {
683             return 1
684         }
685     }
686     return 0
687 }
688
689 # Return true if the target supports -mpaired-single (as used on MIPS).
690
691 proc check_effective_target_mpaired_single { } {
692     return [check_no_compiler_messages mpaired_single object {
693         void foo (void) { }
694     } "-mpaired-single"]
695 }
696
697 # Return true if the target has access to FPU instructions.
698
699 proc check_effective_target_hard_float { } {
700     if { [istarget mips*-*-*] } {
701         return [check_no_compiler_messages hard_float assembly {
702                 #if (defined __mips_soft_float || defined __mips16)
703                 #error FOO
704                 #endif
705         }]
706     }
707
708     # This proc is actually checking the availabilty of FPU
709     # support for doubles, so on the RX we must fail if the
710     # 64-bit double multilib has been selected.
711     if { [istarget rx-*-*] } {
712         return 0
713         # return [check_no_compiler_messages hard_float assembly {
714                 #if defined __RX_64_BIT_DOUBLES__
715                 #error FOO
716                 #endif
717         # }]
718     }
719
720     # The generic test equates hard_float with "no call for adding doubles".
721     return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
722         double a (double b, double c) { return b + c; }
723     }]
724 }
725
726 # Return true if the target is a 64-bit MIPS target.
727
728 proc check_effective_target_mips64 { } {
729     return [check_no_compiler_messages mips64 assembly {
730         #ifndef __mips64
731         #error FOO
732         #endif
733     }]
734 }
735
736 # Return true if the target is a MIPS target that does not produce
737 # MIPS16 code.
738
739 proc check_effective_target_nomips16 { } {
740     return [check_no_compiler_messages nomips16 object {
741         #ifndef __mips
742         #error FOO
743         #else
744         /* A cheap way of testing for -mflip-mips16.  */
745         void foo (void) { asm ("addiu $20,$20,1"); }
746         void bar (void) { asm ("addiu $20,$20,1"); }
747         #endif
748     }]
749 }
750
751 # Add the options needed for MIPS16 function attributes.  At the moment,
752 # we don't support MIPS16 PIC.
753
754 proc add_options_for_mips16_attribute { flags } {
755     return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
756 }
757
758 # Return true if we can force a mode that allows MIPS16 code generation.
759 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
760 # for o32 and o64.
761
762 proc check_effective_target_mips16_attribute { } {
763     return [check_no_compiler_messages mips16_attribute assembly {
764         #ifdef PIC
765         #error FOO
766         #endif
767         #if defined __mips_hard_float \
768             && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
769             && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
770         #error FOO
771         #endif
772     } [add_options_for_mips16_attribute ""]]
773 }
774
775 # Return 1 if the target supports long double larger than double when
776 # using the new ABI, 0 otherwise.
777
778 proc check_effective_target_mips_newabi_large_long_double { } {
779     return [check_no_compiler_messages mips_newabi_large_long_double object {
780         int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
781     } "-mabi=64"]
782 }
783
784 # Return 1 if the current multilib does not generate PIC by default.
785
786 proc check_effective_target_nonpic { } {
787     return [check_no_compiler_messages nonpic assembly {
788         #if __PIC__
789         #error FOO
790         #endif
791     }]
792 }
793
794 # Return 1 if the target does not use a status wrapper.
795
796 proc check_effective_target_unwrapped { } {
797     if { [target_info needs_status_wrapper] != "" \
798              && [target_info needs_status_wrapper] != "0" } {
799         return 0
800     }
801     return 1
802 }
803
804 # Return true if iconv is supported on the target. In particular IBM1047.
805
806 proc check_iconv_available { test_what } {
807     global libiconv
808
809     # If the tool configuration file has not set libiconv, try "-liconv"
810     if { ![info exists libiconv] } {
811         set libiconv "-liconv"
812     }
813     set test_what [lindex $test_what 1]
814     return [check_runtime_nocache $test_what [subst {
815         #include <iconv.h>
816         int main (void)
817         {
818           iconv_t cd;
819
820           cd = iconv_open ("$test_what", "UTF-8");
821           if (cd == (iconv_t) -1)
822             return 1;
823           return 0;
824         }
825     }] $libiconv]
826 }
827
828 # Return true if named sections are supported on this target.
829
830 proc check_named_sections_available { } {
831     return [check_no_compiler_messages named_sections assembly {
832         int __attribute__ ((section("whatever"))) foo;
833     }]
834 }
835
836 # Return 1 if the target supports Fortran real kinds larger than real(8),
837 # 0 otherwise.
838 #
839 # When the target name changes, replace the cached result.
840
841 proc check_effective_target_fortran_large_real { } {
842     return [check_no_compiler_messages fortran_large_real executable {
843         ! Fortran
844         integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
845         real(kind=k) :: x
846         x = cos (x)
847         end
848     }]
849 }
850
851 # Return 1 if the target supports Fortran integer kinds larger than
852 # integer(8), 0 otherwise.
853 #
854 # When the target name changes, replace the cached result.
855
856 proc check_effective_target_fortran_large_int { } {
857     return [check_no_compiler_messages fortran_large_int executable {
858         ! Fortran
859         integer,parameter :: k = selected_int_kind (range (0_8) + 1)
860         integer(kind=k) :: i
861         end
862     }]
863 }
864
865 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
866 #
867 # When the target name changes, replace the cached result.
868
869 proc check_effective_target_fortran_integer_16 { } {
870     return [check_no_compiler_messages fortran_integer_16 executable {
871         ! Fortran
872         integer(16) :: i
873         end
874     }]
875 }
876
877 # Return 1 if we can statically link libgfortran, 0 otherwise.
878 #
879 # When the target name changes, replace the cached result.
880
881 proc check_effective_target_static_libgfortran { } {
882     return [check_no_compiler_messages static_libgfortran executable {
883         ! Fortran
884         print *, 'test'
885         end
886     } "-static"]
887 }
888
889 # Return 1 if the target supports executing 750CL paired-single instructions, 0
890 # otherwise.  Cache the result.
891
892 proc check_750cl_hw_available { } {
893     return [check_cached_effective_target 750cl_hw_available {
894         # If this is not the right target then we can skip the test.
895         if { ![istarget powerpc-*paired*] } {
896             expr 0
897         } else {
898             check_runtime_nocache 750cl_hw_available {
899                  int main()
900                  {
901                  #ifdef __MACH__
902                    asm volatile ("ps_mul v0,v0,v0");
903                  #else
904                    asm volatile ("ps_mul 0,0,0");
905                  #endif
906                    return 0;
907                  }
908             } "-mpaired"
909         }
910     }]
911 }
912
913 # Return 1 if the target OS supports running SSE executables, 0
914 # otherwise.  Cache the result.
915
916 proc check_sse_os_support_available { } {
917     return [check_cached_effective_target sse_os_support_available {
918         # If this is not the right target then we can skip the test.
919         if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
920             expr 0
921         } elseif { [istarget i?86-*-solaris2*] } {
922             # The Solaris 2 kernel doesn't save and restore SSE registers
923             # before Solaris 9 4/04.  Before that, executables die with SIGILL.
924             check_runtime_nocache sse_os_support_available {
925                 int main ()
926                 {
927                     __asm__ volatile ("movss %xmm2,%xmm1");
928                     return 0;
929                 }
930             } "-msse"
931         } else {
932             expr 1
933         }
934     }]
935 }
936
937 # Return 1 if the target supports executing SSE instructions, 0
938 # otherwise.  Cache the result.
939
940 proc check_sse_hw_available { } {
941     return [check_cached_effective_target sse_hw_available {
942         # If this is not the right target then we can skip the test.
943         if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
944             expr 0
945         } else {
946             check_runtime_nocache sse_hw_available {
947                 #include "cpuid.h"
948                 int main ()
949                 {
950                   unsigned int eax, ebx, ecx, edx = 0;
951                   if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
952                     return !(edx & bit_SSE);
953                   return 1;
954                 }
955             } ""
956         }
957     }]
958 }
959
960 # Return 1 if the target supports executing SSE2 instructions, 0
961 # otherwise.  Cache the result.
962
963 proc check_sse2_hw_available { } {
964     return [check_cached_effective_target sse2_hw_available {
965         # If this is not the right target then we can skip the test.
966         if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
967             expr 0
968         } else {
969             check_runtime_nocache sse2_hw_available {
970                 #include "cpuid.h"
971                 int main ()
972                 {
973                   unsigned int eax, ebx, ecx, edx = 0;
974                   if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
975                     return !(edx & bit_SSE2);
976                   return 1;
977                 }
978             } ""
979         }
980     }]
981 }
982
983 # Return 1 if the target supports running SSE executables, 0 otherwise.
984
985 proc check_effective_target_sse_runtime { } {
986     if { [check_sse_hw_available] && [check_sse_os_support_available] } {
987         return 1
988     } else {
989         return 0
990     }
991 }
992
993 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
994
995 proc check_effective_target_sse2_runtime { } {
996     if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
997         return 1
998     } else {
999         return 0
1000     }
1001 }
1002
1003 # Return 1 if the target supports executing VSX instructions, 0
1004 # otherwise.  Cache the result.
1005
1006 proc check_vsx_hw_available { } {
1007     return [check_cached_effective_target vsx_hw_available {
1008         # Some simulators are known to not support VSX instructions.
1009         # For now, disable on Darwin
1010         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1011             expr 0
1012         } else {
1013             set options "-mvsx"
1014             check_runtime_nocache vsx_hw_available {
1015                 int main()
1016                 {
1017                 #ifdef __MACH__
1018                   asm volatile ("xxlor vs0,vs0,vs0");
1019                 #else
1020                   asm volatile ("xxlor 0,0,0");
1021                 #endif
1022                   return 0;
1023                 }
1024             } $options
1025         }
1026     }]
1027 }
1028
1029 # Return 1 if the target supports executing AltiVec instructions, 0
1030 # otherwise.  Cache the result.
1031
1032 proc check_vmx_hw_available { } {
1033     return [check_cached_effective_target vmx_hw_available {
1034         # Some simulators are known to not support VMX instructions.
1035         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1036             expr 0
1037         } else {
1038             # Most targets don't require special flags for this test case, but
1039             # Darwin does.  Just to be sure, make sure VSX is not enabled for
1040             # the altivec tests.
1041             if { [istarget *-*-darwin*]
1042                  || [istarget *-*-aix*] } {
1043                 set options "-maltivec -mno-vsx"
1044             } else {
1045                 set options "-mno-vsx"
1046             }
1047             check_runtime_nocache vmx_hw_available {
1048                 int main()
1049                 {
1050                 #ifdef __MACH__
1051                   asm volatile ("vor v0,v0,v0");
1052                 #else
1053                   asm volatile ("vor 0,0,0");
1054                 #endif
1055                   return 0;
1056                 }
1057             } $options
1058         }
1059     }]
1060 }
1061
1062 proc check_ppc_recip_hw_available { } {
1063     return [check_cached_effective_target ppc_recip_hw_available {
1064         # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1065         # For now, disable on Darwin
1066         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1067             expr 0
1068         } else {
1069             set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1070             check_runtime_nocache ppc_recip_hw_available {
1071                 volatile double d_recip, d_rsqrt, d_four = 4.0;
1072                 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1073                 int main()
1074                 {
1075                   asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1076                   asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1077                   asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1078                   asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1079                   return 0;
1080                 }
1081             } $options
1082         }
1083     }]
1084 }
1085
1086 # Return 1 if the target supports executing AltiVec and Cell PPU
1087 # instructions, 0 otherwise.  Cache the result.
1088
1089 proc check_effective_target_cell_hw { } {
1090     return [check_cached_effective_target cell_hw_available {
1091         # Some simulators are known to not support VMX and PPU instructions.
1092         if { [istarget powerpc-*-eabi*] } {
1093             expr 0
1094         } else {
1095             # Most targets don't require special flags for this test
1096             # case, but Darwin and AIX do.
1097             if { [istarget *-*-darwin*]
1098                  || [istarget *-*-aix*] } {
1099                 set options "-maltivec -mcpu=cell"
1100             } else {
1101                 set options "-mcpu=cell"
1102             }
1103             check_runtime_nocache cell_hw_available {
1104                 int main()
1105                 {
1106                 #ifdef __MACH__
1107                   asm volatile ("vor v0,v0,v0");
1108                   asm volatile ("lvlx v0,r0,r0");
1109                 #else
1110                   asm volatile ("vor 0,0,0");
1111                   asm volatile ("lvlx 0,0,0");
1112                 #endif
1113                   return 0;
1114                 }
1115             } $options
1116         }
1117     }]
1118 }
1119
1120 # Return 1 if the target supports executing 64-bit instructions, 0
1121 # otherwise.  Cache the result.
1122
1123 proc check_effective_target_powerpc64 { } {
1124     global powerpc64_available_saved
1125     global tool
1126
1127     if [info exists powerpc64_available_saved] {
1128         verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1129     } else {
1130         set powerpc64_available_saved 0
1131
1132         # Some simulators are known to not support powerpc64 instructions.
1133         if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1134             verbose "check_effective_target_powerpc64 returning 0" 2
1135             return $powerpc64_available_saved
1136         }
1137
1138         # Set up, compile, and execute a test program containing a 64-bit
1139         # instruction.  Include the current process ID in the file
1140         # names to prevent conflicts with invocations for multiple
1141         # testsuites.
1142         set src ppc[pid].c
1143         set exe ppc[pid].x
1144
1145         set f [open $src "w"]
1146         puts $f "int main() {"
1147         puts $f "#ifdef __MACH__"
1148         puts $f "  asm volatile (\"extsw r0,r0\");"
1149         puts $f "#else"
1150         puts $f "  asm volatile (\"extsw 0,0\");"
1151         puts $f "#endif"
1152         puts $f "  return 0; }"
1153         close $f
1154
1155         set opts "additional_flags=-mcpu=G5"
1156
1157         verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1158         set lines [${tool}_target_compile $src $exe executable "$opts"]
1159         file delete $src
1160
1161         if [string match "" $lines] then {
1162             # No error message, compilation succeeded.
1163             set result [${tool}_load "./$exe" "" ""]
1164             set status [lindex $result 0]
1165             remote_file build delete $exe
1166             verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1167
1168             if { $status == "pass" } then {
1169                 set powerpc64_available_saved 1
1170             }
1171         } else {
1172             verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1173         }
1174     }
1175
1176     return $powerpc64_available_saved
1177 }
1178
1179 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1180 # complex float arguments.  This affects gfortran tests that call cabsf
1181 # in libm built by an earlier compiler.  Return 1 if libm uses the same
1182 # argument passing as the compiler under test, 0 otherwise.
1183 #
1184 # When the target name changes, replace the cached result.
1185
1186 proc check_effective_target_broken_cplxf_arg { } {
1187     return [check_cached_effective_target broken_cplxf_arg {
1188         # Skip the work for targets known not to be affected.
1189         if { ![istarget powerpc64-*-linux*] } {
1190             expr 0
1191         } elseif { ![is-effective-target lp64] } {
1192             expr 0
1193         } else {
1194             check_runtime_nocache broken_cplxf_arg {
1195                 #include <complex.h>
1196                 extern void abort (void);
1197                 float fabsf (float);
1198                 float cabsf (_Complex float);
1199                 int main ()
1200                 {
1201                   _Complex float cf;
1202                   float f;
1203                   cf = 3 + 4.0fi;
1204                   f = cabsf (cf);
1205                   if (fabsf (f - 5.0) > 0.0001)
1206                     abort ();
1207                   return 0;
1208                 }
1209             } "-lm"
1210         }
1211     }]
1212 }
1213
1214 proc check_alpha_max_hw_available { } {
1215     return [check_runtime alpha_max_hw_available {
1216         int main() { return __builtin_alpha_amask(1<<8) != 0; }
1217     }]
1218 }
1219
1220 # Returns true iff the FUNCTION is available on the target system.
1221 # (This is essentially a Tcl implementation of Autoconf's
1222 # AC_CHECK_FUNC.)
1223
1224 proc check_function_available { function } {
1225     return [check_no_compiler_messages ${function}_available \
1226                 executable [subst {
1227         #ifdef __cplusplus
1228         extern "C"
1229         #endif
1230         char $function ();
1231         int main () { $function (); }
1232     }]]
1233 }
1234
1235 # Returns true iff "fork" is available on the target system.
1236
1237 proc check_fork_available {} {
1238     return [check_function_available "fork"]
1239 }
1240
1241 # Returns true iff "mkfifo" is available on the target system.
1242
1243 proc check_mkfifo_available {} {
1244     if {[istarget *-*-cygwin*]} {
1245        # Cygwin has mkfifo, but support is incomplete.
1246        return 0
1247      }
1248
1249     return [check_function_available "mkfifo"]
1250 }
1251
1252 # Returns true iff "__cxa_atexit" is used on the target system.
1253
1254 proc check_cxa_atexit_available { } {
1255     return [check_cached_effective_target cxa_atexit_available {
1256         if { [istarget "hppa*-*-hpux10*"] } {
1257             # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1258             expr 0
1259         } elseif { [istarget "*-*-vxworks"] } {
1260             # vxworks doesn't have __cxa_atexit but subsequent test passes.
1261             expr 0
1262         } else {
1263             check_runtime_nocache cxa_atexit_available {
1264                 // C++
1265                 #include <stdlib.h>
1266                 static unsigned int count;
1267                 struct X
1268                 {
1269                   X() { count = 1; }
1270                   ~X()
1271                   {
1272                     if (count != 3)
1273                       exit(1);
1274                     count = 4;
1275                   }
1276                 };
1277                 void f()
1278                 {
1279                   static X x;
1280                 }
1281                 struct Y
1282                 {
1283                   Y() { f(); count = 2; }
1284                   ~Y()
1285                   {
1286                     if (count != 2)
1287                       exit(1);
1288                     count = 3;
1289                   }
1290                 };
1291                 Y y;
1292                 int main() { return 0; }
1293             }
1294         }
1295     }]
1296 }
1297
1298 proc check_effective_target_objc2 { } {
1299     return [check_no_compiler_messages objc2 object {
1300         #ifdef __OBJC2__
1301         int dummy[1];
1302         #else
1303         #error
1304         #endif 
1305     }]
1306 }
1307
1308 proc check_effective_target_next_runtime { } {
1309     return [check_no_compiler_messages objc2 object {
1310         #ifdef __NEXT_RUNTIME__
1311         int dummy[1];
1312         #else
1313         #error
1314         #endif 
1315     }]
1316 }
1317
1318 # Return 1 if we're generating 32-bit code using default options, 0
1319 # otherwise.
1320
1321 proc check_effective_target_ilp32 { } {
1322     return [check_no_compiler_messages ilp32 object {
1323         int dummy[sizeof (int) == 4
1324                   && sizeof (void *) == 4
1325                   && sizeof (long) == 4 ? 1 : -1];
1326     }]
1327 }
1328
1329 # Return 1 if we're generating 32-bit or larger integers using default
1330 # options, 0 otherwise.
1331
1332 proc check_effective_target_int32plus { } {
1333     return [check_no_compiler_messages int32plus object {
1334         int dummy[sizeof (int) >= 4 ? 1 : -1];
1335     }]
1336 }
1337
1338 # Return 1 if we're generating 32-bit or larger pointers using default
1339 # options, 0 otherwise.
1340
1341 proc check_effective_target_ptr32plus { } {
1342     return [check_no_compiler_messages ptr32plus object {
1343         int dummy[sizeof (void *) >= 4 ? 1 : -1];
1344     }]
1345 }
1346
1347 # Return 1 if we support 32-bit or larger array and structure sizes
1348 # using default options, 0 otherwise.
1349
1350 proc check_effective_target_size32plus { } {
1351     return [check_no_compiler_messages size32plus object {
1352         char dummy[65537];
1353     }]
1354 }
1355
1356 # Returns 1 if we're generating 16-bit or smaller integers with the
1357 # default options, 0 otherwise.
1358
1359 proc check_effective_target_int16 { } {
1360     return [check_no_compiler_messages int16 object {
1361         int dummy[sizeof (int) < 4 ? 1 : -1];
1362     }]
1363 }
1364
1365 # Return 1 if we're generating 64-bit code using default options, 0
1366 # otherwise.
1367
1368 proc check_effective_target_lp64 { } {
1369     return [check_no_compiler_messages lp64 object {
1370         int dummy[sizeof (int) == 4
1371                   && sizeof (void *) == 8
1372                   && sizeof (long) == 8 ? 1 : -1];
1373     }]
1374 }
1375
1376 # Return 1 if we're generating 64-bit code using default llp64 options,
1377 # 0 otherwise.
1378
1379 proc check_effective_target_llp64 { } {
1380     return [check_no_compiler_messages llp64 object {
1381         int dummy[sizeof (int) == 4
1382                   && sizeof (void *) == 8
1383                   && sizeof (long long) == 8
1384                   && sizeof (long) == 4 ? 1 : -1];
1385     }]
1386 }
1387
1388 # Return 1 if the target supports long double larger than double,
1389 # 0 otherwise.
1390
1391 proc check_effective_target_large_long_double { } {
1392     return [check_no_compiler_messages large_long_double object {
1393         int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1394     }]
1395 }
1396
1397 # Return 1 if the target supports double larger than float,
1398 # 0 otherwise.
1399
1400 proc check_effective_target_large_double { } {
1401     return [check_no_compiler_messages large_double object {
1402         int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1403     }]
1404 }
1405
1406 # Return 1 if the target supports double of 64 bits,
1407 # 0 otherwise.
1408
1409 proc check_effective_target_double64 { } {
1410     return [check_no_compiler_messages double64 object {
1411         int dummy[sizeof(double) == 8 ? 1 : -1];
1412     }]
1413 }
1414
1415 # Return 1 if the target supports double of at least 64 bits,
1416 # 0 otherwise.
1417
1418 proc check_effective_target_double64plus { } {
1419     return [check_no_compiler_messages double64plus object {
1420         int dummy[sizeof(double) >= 8 ? 1 : -1];
1421     }]
1422 }
1423
1424 # Return 1 if the target supports compiling fixed-point,
1425 # 0 otherwise.
1426
1427 proc check_effective_target_fixed_point { } {
1428     return [check_no_compiler_messages fixed_point object {
1429         _Sat _Fract x; _Sat _Accum y;
1430     }]
1431 }
1432
1433 # Return 1 if the target supports compiling decimal floating point,
1434 # 0 otherwise.
1435
1436 proc check_effective_target_dfp_nocache { } {
1437     verbose "check_effective_target_dfp_nocache: compiling source" 2
1438     set ret [check_no_compiler_messages_nocache dfp object {
1439         float x __attribute__((mode(DD)));
1440     }]
1441     verbose "check_effective_target_dfp_nocache: returning $ret" 2
1442     return $ret
1443 }
1444
1445 proc check_effective_target_dfprt_nocache { } {
1446     return [check_runtime_nocache dfprt {
1447         typedef float d64 __attribute__((mode(DD)));
1448         d64 x = 1.2df, y = 2.3dd, z;
1449         int main () { z = x + y; return 0; }
1450     }]
1451 }
1452
1453 # Return 1 if the target supports compiling Decimal Floating Point,
1454 # 0 otherwise.
1455 #
1456 # This won't change for different subtargets so cache the result.
1457
1458 proc check_effective_target_dfp { } {
1459     return [check_cached_effective_target dfp {
1460         check_effective_target_dfp_nocache
1461     }]
1462 }
1463
1464 # Return 1 if the target supports linking and executing Decimal Floating
1465 # Point, 0 otherwise.
1466 #
1467 # This won't change for different subtargets so cache the result.
1468
1469 proc check_effective_target_dfprt { } {
1470     return [check_cached_effective_target dfprt {
1471         check_effective_target_dfprt_nocache
1472     }]
1473 }
1474
1475 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1476
1477 proc check_effective_target_ucn_nocache { } {
1478     # -std=c99 is only valid for C
1479     if [check_effective_target_c] {
1480         set ucnopts "-std=c99"
1481     }
1482     append ucnopts " -fextended-identifiers"
1483     verbose "check_effective_target_ucn_nocache: compiling source" 2
1484     set ret [check_no_compiler_messages_nocache ucn object {
1485         int \u00C0;
1486     } $ucnopts]
1487     verbose "check_effective_target_ucn_nocache: returning $ret" 2
1488     return $ret
1489 }
1490
1491 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1492 #
1493 # This won't change for different subtargets, so cache the result.
1494
1495 proc check_effective_target_ucn { } {
1496     return [check_cached_effective_target ucn {
1497         check_effective_target_ucn_nocache
1498     }]
1499 }
1500
1501 # Return 1 if the target needs a command line argument to enable a SIMD
1502 # instruction set.
1503
1504 proc check_effective_target_vect_cmdline_needed { } {
1505     global et_vect_cmdline_needed_saved
1506     global et_vect_cmdline_needed_target_name
1507
1508     if { ![info exists et_vect_cmdline_needed_target_name] } {
1509         set et_vect_cmdline_needed_target_name ""
1510     }
1511
1512     # If the target has changed since we set the cached value, clear it.
1513     set current_target [current_target_name]
1514     if { $current_target != $et_vect_cmdline_needed_target_name } {
1515         verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1516         set et_vect_cmdline_needed_target_name $current_target
1517         if { [info exists et_vect_cmdline_needed_saved] } {
1518             verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1519             unset et_vect_cmdline_needed_saved
1520         }
1521     }
1522
1523     if [info exists et_vect_cmdline_needed_saved] {
1524         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1525     } else {
1526         set et_vect_cmdline_needed_saved 1
1527         if { [istarget alpha*-*-*]
1528              || [istarget ia64-*-*]
1529              || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1530                  && [check_effective_target_lp64])
1531              || ([istarget powerpc*-*-*]
1532                  && ([check_effective_target_powerpc_spe]
1533                      || [check_effective_target_powerpc_altivec]))
1534              || [istarget spu-*-*]
1535              || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1536            set et_vect_cmdline_needed_saved 0
1537         }
1538     }
1539
1540     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1541     return $et_vect_cmdline_needed_saved
1542 }
1543
1544 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1545 #
1546 # This won't change for different subtargets so cache the result.
1547
1548 proc check_effective_target_vect_int { } {
1549     global et_vect_int_saved
1550
1551     if [info exists et_vect_int_saved] {
1552         verbose "check_effective_target_vect_int: using cached result" 2
1553     } else {
1554         set et_vect_int_saved 0
1555         if { [istarget i?86-*-*]
1556              || ([istarget powerpc*-*-*]
1557                   && ![istarget powerpc-*-linux*paired*])
1558               || [istarget spu-*-*]
1559               || [istarget x86_64-*-*]
1560               || [istarget sparc*-*-*]
1561               || [istarget alpha*-*-*]
1562               || [istarget ia64-*-*] 
1563               || [check_effective_target_arm32] } {
1564            set et_vect_int_saved 1
1565         }
1566     }
1567
1568     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1569     return $et_vect_int_saved
1570 }
1571
1572 # Return 1 if the target supports signed int->float conversion 
1573 #
1574
1575 proc check_effective_target_vect_intfloat_cvt { } {
1576     global et_vect_intfloat_cvt_saved
1577
1578     if [info exists et_vect_intfloat_cvt_saved] {
1579         verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1580     } else {
1581         set et_vect_intfloat_cvt_saved 0
1582         if { [istarget i?86-*-*]
1583               || ([istarget powerpc*-*-*]
1584                    && ![istarget powerpc-*-linux*paired*])
1585               || [istarget x86_64-*-*] } {
1586            set et_vect_intfloat_cvt_saved 1
1587         }
1588     }
1589
1590     verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1591     return $et_vect_intfloat_cvt_saved
1592 }
1593
1594 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1595
1596 proc check_effective_target_int128 { } {
1597     return [check_no_compiler_messages int128 object {
1598         int dummy[
1599         #ifndef __SIZEOF_INT128__
1600         -1
1601         #else
1602         1
1603         #endif
1604         ];
1605     }]
1606 }
1607
1608 # Return 1 if the target supports unsigned int->float conversion 
1609 #
1610
1611 proc check_effective_target_vect_uintfloat_cvt { } {
1612     global et_vect_uintfloat_cvt_saved
1613
1614     if [info exists et_vect_uintfloat_cvt_saved] {
1615         verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1616     } else {
1617         set et_vect_uintfloat_cvt_saved 0
1618         if { [istarget i?86-*-*]
1619               || ([istarget powerpc*-*-*]
1620                   && ![istarget powerpc-*-linux*paired*])
1621               || [istarget x86_64-*-*] } {
1622            set et_vect_uintfloat_cvt_saved 1
1623         }
1624     }
1625
1626     verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1627     return $et_vect_uintfloat_cvt_saved
1628 }
1629
1630
1631 # Return 1 if the target supports signed float->int conversion
1632 #
1633
1634 proc check_effective_target_vect_floatint_cvt { } {
1635     global et_vect_floatint_cvt_saved
1636
1637     if [info exists et_vect_floatint_cvt_saved] {
1638         verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1639     } else {
1640         set et_vect_floatint_cvt_saved 0
1641         if { [istarget i?86-*-*]
1642               || ([istarget powerpc*-*-*]
1643                    && ![istarget powerpc-*-linux*paired*])
1644               || [istarget x86_64-*-*] } {
1645            set et_vect_floatint_cvt_saved 1
1646         }
1647     }
1648
1649     verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1650     return $et_vect_floatint_cvt_saved
1651 }
1652
1653 # Return 1 if the target supports unsigned float->int conversion
1654 #
1655
1656 proc check_effective_target_vect_floatuint_cvt { } {
1657     global et_vect_floatuint_cvt_saved
1658
1659     if [info exists et_vect_floatuint_cvt_saved] {
1660         verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1661     } else {
1662         set et_vect_floatuint_cvt_saved 0
1663         if { ([istarget powerpc*-*-*]
1664               && ![istarget powerpc-*-linux*paired*]) } {
1665            set et_vect_floatuint_cvt_saved 1
1666         }
1667     }
1668
1669     verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1670     return $et_vect_floatuint_cvt_saved
1671 }
1672
1673 # Return 1 is this is an arm target using 32-bit instructions
1674 proc check_effective_target_arm32 { } {
1675     return [check_no_compiler_messages arm32 assembly {
1676         #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1677         #error FOO
1678         #endif
1679     }]
1680 }
1681
1682 # Return 1 if this is an ARM target supporting -mfpu=vfp
1683 # -mfloat-abi=softfp.  Some multilibs may be incompatible with these
1684 # options.
1685
1686 proc check_effective_target_arm_vfp_ok { } {
1687     if { [check_effective_target_arm32] } {
1688         return [check_no_compiler_messages arm_vfp_ok object {
1689             int dummy;
1690         } "-mfpu=vfp -mfloat-abi=softfp"]
1691     } else {
1692         return 0
1693     }
1694 }
1695
1696 # Return 1 if this is an ARM target supporting -mfpu=vfp
1697 # -mfloat-abi=hard.  Some multilibs may be incompatible with these
1698 # options.
1699
1700 proc check_effective_target_arm_hard_vfp_ok { } {
1701     if { [check_effective_target_arm32] } {
1702         return [check_no_compiler_messages arm_hard_vfp_ok executable {
1703             int main() { return 0;}
1704         } "-mfpu=vfp -mfloat-abi=hard"]
1705     } else {
1706         return 0
1707     }
1708 }
1709
1710 # Add the options needed for NEON.  We need either -mfloat-abi=softfp
1711 # or -mfloat-abi=hard, but if one is already specified by the
1712 # multilib, use it.  Similarly, if a -mfpu option already enables
1713 # NEON, do not add -mfpu=neon.
1714
1715 proc add_options_for_arm_neon { flags } {
1716     if { ! [check_effective_target_arm_neon_ok] } {
1717         return "$flags"
1718     }
1719     global et_arm_neon_flags
1720     return "$flags $et_arm_neon_flags"
1721 }
1722
1723 # Return 1 if this is an ARM target supporting -mfpu=neon
1724 # -mfloat-abi=softfp or equivalent options.  Some multilibs may be
1725 # incompatible with these options.  Also set et_arm_neon_flags to the
1726 # best options to add.
1727
1728 proc check_effective_target_arm_neon_ok_nocache { } {
1729     global et_arm_neon_flags
1730     set et_arm_neon_flags ""
1731     if { [check_effective_target_arm32] } {
1732         foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1733             if { [check_no_compiler_messages_nocache arm_neon_ok object {
1734                 #include "arm_neon.h"
1735                 int dummy;
1736             } "$flags"] } {
1737                 set et_arm_neon_flags $flags
1738                 return 1
1739             }
1740         }
1741     }
1742
1743     return 0
1744 }
1745
1746 proc check_effective_target_arm_neon_ok { } {
1747     return [check_cached_effective_target arm_neon_ok \
1748                 check_effective_target_arm_neon_ok_nocache]
1749 }
1750
1751 # Add the options needed for NEON.  We need either -mfloat-abi=softfp
1752 # or -mfloat-abi=hard, but if one is already specified by the
1753 # multilib, use it.
1754
1755 proc add_options_for_arm_neon_fp16 { flags } {
1756     if { ! [check_effective_target_arm_neon_fp16_ok] } {
1757         return "$flags"
1758     }
1759     global et_arm_neon_fp16_flags
1760     return "$flags $et_arm_neon_fp16_flags"
1761 }
1762
1763 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1764 # -mfloat-abi=softfp or equivalent options.  Some multilibs may be
1765 # incompatible with these options.  Also set et_arm_neon_flags to the
1766 # best options to add.
1767
1768 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1769     global et_arm_neon_fp16_flags
1770     set et_arm_neon_fp16_flags ""
1771     if { [check_effective_target_arm32] } {
1772         # Always add -mfpu=neon-fp16, since there is no preprocessor
1773         # macro for FP16 support.
1774         foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1775             if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1776                 #include "arm_neon.h"
1777                 int dummy;
1778             } "$flags"] } {
1779                 set et_arm_neon_fp16_flags $flags
1780                 return 1
1781             }
1782         }
1783     }
1784
1785     return 0
1786 }
1787
1788 proc check_effective_target_arm_neon_fp16_ok { } {
1789     return [check_cached_effective_target arm_neon_fp16_ok \
1790                 check_effective_target_arm_neon_fp16_ok_nocache]
1791 }
1792
1793 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1794 # used.
1795
1796 proc check_effective_target_arm_thumb1_ok { } {
1797     return [check_no_compiler_messages arm_thumb1_ok assembly {
1798         #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1799         #error FOO
1800         #endif
1801     } "-mthumb"]
1802 }
1803
1804 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1805 # used.
1806
1807 proc check_effective_target_arm_thumb2_ok { } {
1808     return [check_no_compiler_messages arm_thumb2_ok assembly {
1809         #if !defined(__thumb2__)
1810         #error FOO
1811         #endif
1812     } "-mthumb"]
1813 }
1814
1815 # Return 1 if the target supports executing NEON instructions, 0
1816 # otherwise.  Cache the result.
1817
1818 proc check_effective_target_arm_neon_hw { } {
1819     return [check_runtime arm_neon_hw_available {
1820         int
1821         main (void)
1822         {
1823           long long a = 0, b = 1;
1824           asm ("vorr %P0, %P1, %P2"
1825                : "=w" (a)
1826                : "0" (a), "w" (b));
1827           return (a != 1);
1828         }
1829     } [add_options_for_arm_neon ""]]
1830 }
1831
1832 # Return 1 if this is a ARM target with NEON enabled.
1833
1834 proc check_effective_target_arm_neon { } {
1835     if { [check_effective_target_arm32] } {
1836         return [check_no_compiler_messages arm_neon object {
1837             #ifndef __ARM_NEON__
1838             #error not NEON
1839             #else
1840             int dummy;
1841             #endif
1842         }]
1843     } else {
1844         return 0
1845     }
1846 }
1847
1848 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1849 # the Loongson vector modes.
1850
1851 proc check_effective_target_mips_loongson { } {
1852     return [check_no_compiler_messages loongson assembly {
1853         #if !defined(__mips_loongson_vector_rev)
1854         #error FOO
1855         #endif
1856     }]
1857 }
1858
1859 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1860 # Architecture.
1861
1862 proc check_effective_target_arm_eabi { } {
1863     return [check_no_compiler_messages arm_eabi object {
1864         #ifndef __ARM_EABI__
1865         #error not EABI
1866         #else
1867         int dummy;
1868         #endif
1869     }]
1870 }
1871
1872 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
1873 # Some multilibs may be incompatible with this option.
1874
1875 proc check_effective_target_arm_iwmmxt_ok { } {
1876     if { [check_effective_target_arm32] } {
1877         return [check_no_compiler_messages arm_iwmmxt_ok object {
1878             int dummy;
1879         } "-mcpu=iwmmxt"]
1880     } else {
1881         return 0
1882     }
1883 }
1884
1885 # Return 1 if this is a PowerPC target with floating-point registers.
1886
1887 proc check_effective_target_powerpc_fprs { } {
1888     if { [istarget powerpc*-*-*]
1889          || [istarget rs6000-*-*] } {
1890         return [check_no_compiler_messages powerpc_fprs object {
1891             #ifdef __NO_FPRS__
1892             #error no FPRs
1893             #else
1894             int dummy;
1895             #endif
1896         }]
1897     } else {
1898         return 0
1899     }
1900 }
1901
1902 # Return 1 if this is a PowerPC target with hardware double-precision
1903 # floating point.
1904
1905 proc check_effective_target_powerpc_hard_double { } {
1906     if { [istarget powerpc*-*-*]
1907          || [istarget rs6000-*-*] } {
1908         return [check_no_compiler_messages powerpc_hard_double object {
1909             #ifdef _SOFT_DOUBLE
1910             #error soft double
1911             #else
1912             int dummy;
1913             #endif
1914         }]
1915     } else {
1916         return 0
1917     }
1918 }
1919
1920 # Return 1 if this is a PowerPC target supporting -maltivec.
1921
1922 proc check_effective_target_powerpc_altivec_ok { } {
1923     if { ([istarget powerpc*-*-*]
1924          && ![istarget powerpc-*-linux*paired*])
1925          || [istarget rs6000-*-*] } {
1926         # AltiVec is not supported on AIX before 5.3.
1927         if { [istarget powerpc*-*-aix4*]
1928              || [istarget powerpc*-*-aix5.1*] 
1929              || [istarget powerpc*-*-aix5.2*] } {
1930             return 0
1931         }
1932         return [check_no_compiler_messages powerpc_altivec_ok object {
1933             int dummy;
1934         } "-maltivec"]
1935     } else {
1936         return 0
1937     }
1938 }
1939
1940 # Return 1 if this is a PowerPC target supporting -mvsx
1941
1942 proc check_effective_target_powerpc_vsx_ok { } {
1943     if { ([istarget powerpc*-*-*]
1944          && ![istarget powerpc-*-linux*paired*])
1945          || [istarget rs6000-*-*] } {
1946         # AltiVec is not supported on AIX before 5.3.
1947         if { [istarget powerpc*-*-aix4*]
1948              || [istarget powerpc*-*-aix5.1*] 
1949              || [istarget powerpc*-*-aix5.2*] } {
1950             return 0
1951         }
1952         return [check_no_compiler_messages powerpc_vsx_ok object {
1953             int main (void) {
1954 #ifdef __MACH__
1955                 asm volatile ("xxlor vs0,vs0,vs0");
1956 #else
1957                 asm volatile ("xxlor 0,0,0");
1958 #endif
1959                 return 0;
1960             }
1961         } "-mvsx"]
1962     } else {
1963         return 0
1964     }
1965 }
1966
1967 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1968
1969 proc check_effective_target_powerpc_ppu_ok { } {
1970     if [check_effective_target_powerpc_altivec_ok] {
1971         return [check_no_compiler_messages cell_asm_available object {
1972             int main (void) {
1973 #ifdef __MACH__
1974                 asm volatile ("lvlx v0,v0,v0");
1975 #else
1976                 asm volatile ("lvlx 0,0,0");
1977 #endif
1978                 return 0;
1979             }
1980         }]
1981     } else {
1982         return 0
1983     }
1984 }
1985
1986 # Return 1 if this is a PowerPC target that supports SPU.
1987
1988 proc check_effective_target_powerpc_spu { } {
1989     if [istarget powerpc*-*-linux*] {
1990         return [check_effective_target_powerpc_altivec_ok]
1991     } else {
1992         return 0
1993     }
1994 }
1995
1996 # Return 1 if this is a PowerPC SPE target.  The check includes options
1997 # specified by dg-options for this test, so don't cache the result.
1998
1999 proc check_effective_target_powerpc_spe_nocache { } {
2000     if { [istarget powerpc*-*-*] } {
2001         return [check_no_compiler_messages_nocache powerpc_spe object {
2002             #ifndef __SPE__
2003             #error not SPE
2004             #else
2005             int dummy;
2006             #endif
2007         } [current_compiler_flags]]
2008     } else {
2009         return 0
2010     }
2011 }
2012
2013 # Return 1 if this is a PowerPC target with SPE enabled.
2014
2015 proc check_effective_target_powerpc_spe { } {
2016     if { [istarget powerpc*-*-*] } {
2017         return [check_no_compiler_messages powerpc_spe object {
2018             #ifndef __SPE__
2019             #error not SPE
2020             #else
2021             int dummy;
2022             #endif
2023         }]
2024     } else {
2025         return 0
2026     }
2027 }
2028
2029 # Return 1 if this is a PowerPC target with Altivec enabled.
2030
2031 proc check_effective_target_powerpc_altivec { } {
2032     if { [istarget powerpc*-*-*] } {
2033         return [check_no_compiler_messages powerpc_altivec object {
2034             #ifndef __ALTIVEC__
2035             #error not Altivec
2036             #else
2037             int dummy;
2038             #endif
2039         }]
2040     } else {
2041         return 0
2042     }
2043 }
2044
2045 # Return 1 if this is a PowerPC 405 target.  The check includes options
2046 # specified by dg-options for this test, so don't cache the result.
2047
2048 proc check_effective_target_powerpc_405_nocache { } {
2049     if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2050         return [check_no_compiler_messages_nocache powerpc_405 object {
2051             #ifdef __PPC405__
2052             int dummy;
2053             #else
2054             #error not a PPC405
2055             #endif
2056         } [current_compiler_flags]]
2057     } else {
2058         return 0
2059     }
2060 }
2061
2062 # Return 1 if this is a SPU target with a toolchain that
2063 # supports automatic overlay generation.
2064
2065 proc check_effective_target_spu_auto_overlay { } {
2066     if { [istarget spu*-*-elf*] } {
2067         return [check_no_compiler_messages spu_auto_overlay executable {
2068                 int main (void) { }
2069                 } "-Wl,--auto-overlay" ]
2070     } else {
2071         return 0
2072     }
2073 }
2074
2075 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2076 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables.  Return 1 if the
2077 # test environment appears to run executables on such a simulator.
2078
2079 proc check_effective_target_ultrasparc_hw { } {
2080     return [check_runtime ultrasparc_hw {
2081         int main() { return 0; }
2082     } "-mcpu=ultrasparc"]
2083 }
2084
2085 # Return 1 if the target supports hardware vector shift operation.
2086
2087 proc check_effective_target_vect_shift { } {
2088     global et_vect_shift_saved
2089
2090     if [info exists et_vect_shift_saved] {
2091         verbose "check_effective_target_vect_shift: using cached result" 2
2092     } else {
2093         set et_vect_shift_saved 0
2094         if { ([istarget powerpc*-*-*]
2095              && ![istarget powerpc-*-linux*paired*])
2096              || [istarget ia64-*-*]
2097              || [istarget i?86-*-*]
2098              || [istarget x86_64-*-*]
2099              || [check_effective_target_arm32] } {
2100            set et_vect_shift_saved 1
2101         }
2102     }
2103
2104     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2105     return $et_vect_shift_saved
2106 }
2107
2108 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2109 #
2110 # This can change for different subtargets so do not cache the result.
2111
2112 proc check_effective_target_vect_long { } {
2113     if { [istarget i?86-*-*]
2114          || (([istarget powerpc*-*-*] 
2115               && ![istarget powerpc-*-linux*paired*]) 
2116               && [check_effective_target_ilp32])
2117          || [istarget x86_64-*-*]
2118          || [check_effective_target_arm32]
2119          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2120         set answer 1
2121     } else {
2122         set answer 0
2123     }
2124
2125     verbose "check_effective_target_vect_long: returning $answer" 2
2126     return $answer
2127 }
2128
2129 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2130 #
2131 # This won't change for different subtargets so cache the result.
2132
2133 proc check_effective_target_vect_float { } {
2134     global et_vect_float_saved
2135
2136     if [info exists et_vect_float_saved] {
2137         verbose "check_effective_target_vect_float: using cached result" 2
2138     } else {
2139         set et_vect_float_saved 0
2140         if { [istarget i?86-*-*]
2141               || [istarget powerpc*-*-*]
2142               || [istarget spu-*-*]
2143               || [istarget mipsisa64*-*-*]
2144               || [istarget x86_64-*-*]
2145               || [istarget ia64-*-*]
2146               || [check_effective_target_arm32] } {
2147            set et_vect_float_saved 1
2148         }
2149     }
2150
2151     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2152     return $et_vect_float_saved
2153 }
2154
2155 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2156 #
2157 # This won't change for different subtargets so cache the result.
2158
2159 proc check_effective_target_vect_double { } {
2160     global et_vect_double_saved
2161
2162     if [info exists et_vect_double_saved] {
2163         verbose "check_effective_target_vect_double: using cached result" 2
2164     } else {
2165         set et_vect_double_saved 0
2166         if { [istarget i?86-*-*]
2167               || [istarget x86_64-*-*] 
2168               || [istarget spu-*-*] } {
2169            set et_vect_double_saved 1
2170         }
2171     }
2172
2173     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2174     return $et_vect_double_saved
2175 }
2176
2177 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2178 #
2179 # This won't change for different subtargets so cache the result.
2180
2181 proc check_effective_target_vect_long_long { } {
2182     global et_vect_long_long_saved
2183
2184     if [info exists et_vect_long_long_saved] {
2185         verbose "check_effective_target_vect_long_long: using cached result" 2
2186     } else {
2187         set et_vect_long_long_saved 0
2188         if { [istarget i?86-*-*]
2189               || [istarget x86_64-*-*] } {
2190            set et_vect_long_long_saved 1
2191         }
2192     }
2193
2194     verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2195     return $et_vect_long_long_saved
2196 }
2197
2198
2199 # Return 1 if the target plus current options does not support a vector
2200 # max instruction on "int", 0 otherwise.
2201 #
2202 # This won't change for different subtargets so cache the result.
2203
2204 proc check_effective_target_vect_no_int_max { } {
2205     global et_vect_no_int_max_saved
2206
2207     if [info exists et_vect_no_int_max_saved] {
2208         verbose "check_effective_target_vect_no_int_max: using cached result" 2
2209     } else {
2210         set et_vect_no_int_max_saved 0
2211         if { [istarget sparc*-*-*]
2212              || [istarget spu-*-*]
2213              || [istarget alpha*-*-*] } {
2214             set et_vect_no_int_max_saved 1
2215         }
2216     }
2217     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2218     return $et_vect_no_int_max_saved
2219 }
2220
2221 # Return 1 if the target plus current options does not support a vector
2222 # add instruction on "int", 0 otherwise.
2223 #
2224 # This won't change for different subtargets so cache the result.
2225
2226 proc check_effective_target_vect_no_int_add { } {
2227     global et_vect_no_int_add_saved
2228
2229     if [info exists et_vect_no_int_add_saved] {
2230         verbose "check_effective_target_vect_no_int_add: using cached result" 2
2231     } else {
2232         set et_vect_no_int_add_saved 0
2233         # Alpha only supports vector add on V8QI and V4HI.
2234         if { [istarget alpha*-*-*] } {
2235             set et_vect_no_int_add_saved 1
2236         }
2237     }
2238     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2239     return $et_vect_no_int_add_saved
2240 }
2241
2242 # Return 1 if the target plus current options does not support vector
2243 # bitwise instructions, 0 otherwise.
2244 #
2245 # This won't change for different subtargets so cache the result.
2246
2247 proc check_effective_target_vect_no_bitwise { } {
2248     global et_vect_no_bitwise_saved
2249
2250     if [info exists et_vect_no_bitwise_saved] {
2251         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2252     } else {
2253         set et_vect_no_bitwise_saved 0
2254     }
2255     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2256     return $et_vect_no_bitwise_saved
2257 }
2258
2259 # Return 1 if the target plus current options supports vector permutation,
2260 # 0 otherwise.
2261 #
2262 # This won't change for different subtargets so cache the result.
2263
2264 proc check_effective_target_vect_perm { } {
2265     global et_vect_perm
2266
2267     if [info exists et_vect_perm_saved] {
2268         verbose "check_effective_target_vect_perm: using cached result" 2
2269     } else {
2270         set et_vect_perm_saved 0
2271         if { [istarget powerpc*-*-*]
2272              || [istarget spu-*-*] } {
2273             set et_vect_perm_saved 1
2274         }
2275     }
2276     verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2277     return $et_vect_perm_saved
2278 }
2279
2280 # Return 1 if the target plus current options supports a vector
2281 # widening summation of *short* args into *int* result, 0 otherwise.
2282 #
2283 # This won't change for different subtargets so cache the result.
2284
2285 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2286     global et_vect_widen_sum_hi_to_si_pattern
2287
2288     if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2289         verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2290     } else {
2291         set et_vect_widen_sum_hi_to_si_pattern_saved 0
2292         if { [istarget powerpc*-*-*] } {
2293             set et_vect_widen_sum_hi_to_si_pattern_saved 1
2294         }
2295     }
2296     verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2297     return $et_vect_widen_sum_hi_to_si_pattern_saved
2298 }
2299
2300 # Return 1 if the target plus current options supports a vector
2301 # widening summation of *short* args into *int* result, 0 otherwise.
2302 # A target can also support this widening summation if it can support
2303 # promotion (unpacking) from shorts to ints.
2304 #
2305 # This won't change for different subtargets so cache the result.
2306                                                                                                 
2307 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2308     global et_vect_widen_sum_hi_to_si
2309
2310     if [info exists et_vect_widen_sum_hi_to_si_saved] {
2311         verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2312     } else {
2313         set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2314         if { [istarget powerpc*-*-*] 
2315              || [istarget ia64-*-*] } {
2316             set et_vect_widen_sum_hi_to_si_saved 1
2317         }
2318     }
2319     verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2320     return $et_vect_widen_sum_hi_to_si_saved
2321 }
2322
2323 # Return 1 if the target plus current options supports a vector
2324 # widening summation of *char* args into *short* result, 0 otherwise.
2325 # A target can also support this widening summation if it can support
2326 # promotion (unpacking) from chars to shorts.
2327 #
2328 # This won't change for different subtargets so cache the result.
2329                                                                                                 
2330 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2331     global et_vect_widen_sum_qi_to_hi
2332
2333     if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2334         verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2335     } else {
2336         set et_vect_widen_sum_qi_to_hi_saved 0
2337         if { [check_effective_target_vect_unpack] 
2338              || [istarget ia64-*-*] } {
2339             set et_vect_widen_sum_qi_to_hi_saved 1
2340         }
2341     }
2342     verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2343     return $et_vect_widen_sum_qi_to_hi_saved
2344 }
2345
2346 # Return 1 if the target plus current options supports a vector
2347 # widening summation of *char* args into *int* result, 0 otherwise.
2348 #
2349 # This won't change for different subtargets so cache the result.
2350                                                                                                 
2351 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2352     global et_vect_widen_sum_qi_to_si
2353
2354     if [info exists et_vect_widen_sum_qi_to_si_saved] {
2355         verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2356     } else {
2357         set et_vect_widen_sum_qi_to_si_saved 0
2358         if { [istarget powerpc*-*-*] } {
2359             set et_vect_widen_sum_qi_to_si_saved 1
2360         }
2361     }
2362     verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2363     return $et_vect_widen_sum_qi_to_si_saved
2364 }
2365
2366 # Return 1 if the target plus current options supports a vector
2367 # widening multiplication of *char* args into *short* result, 0 otherwise.
2368 # A target can also support this widening multplication if it can support
2369 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2370 # multiplication of shorts).
2371 #
2372 # This won't change for different subtargets so cache the result.
2373
2374
2375 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2376     global et_vect_widen_mult_qi_to_hi
2377
2378     if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2379         verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2380     } else {
2381         if { [check_effective_target_vect_unpack]
2382              && [check_effective_target_vect_short_mult] } {
2383             set et_vect_widen_mult_qi_to_hi_saved 1
2384         } else {
2385             set et_vect_widen_mult_qi_to_hi_saved 0
2386         }
2387         if { [istarget powerpc*-*-*] } {
2388             set et_vect_widen_mult_qi_to_hi_saved 1
2389         }
2390     }
2391     verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2392     return $et_vect_widen_mult_qi_to_hi_saved
2393 }
2394
2395 # Return 1 if the target plus current options supports a vector
2396 # widening multiplication of *short* args into *int* result, 0 otherwise.
2397 # A target can also support this widening multplication if it can support
2398 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2399 # multiplication of ints).
2400 #
2401 # This won't change for different subtargets so cache the result.
2402
2403
2404 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2405     global et_vect_widen_mult_hi_to_si
2406
2407     if [info exists et_vect_widen_mult_hi_to_si_saved] {
2408         verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2409     } else {
2410         if { [check_effective_target_vect_unpack]
2411              && [check_effective_target_vect_int_mult] } {
2412           set et_vect_widen_mult_hi_to_si_saved 1
2413         } else {
2414           set et_vect_widen_mult_hi_to_si_saved 0
2415         }
2416         if { [istarget powerpc*-*-*]
2417               || [istarget spu-*-*]
2418               || [istarget i?86-*-*]
2419               || [istarget x86_64-*-*] } {
2420             set et_vect_widen_mult_hi_to_si_saved 1
2421         }
2422     }
2423     verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2424     return $et_vect_widen_mult_hi_to_si_saved
2425 }
2426
2427 # Return 1 if the target plus current options supports a vector
2428 # dot-product of signed chars, 0 otherwise.
2429 #
2430 # This won't change for different subtargets so cache the result.
2431
2432 proc check_effective_target_vect_sdot_qi { } {
2433     global et_vect_sdot_qi
2434
2435     if [info exists et_vect_sdot_qi_saved] {
2436         verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2437     } else {
2438         set et_vect_sdot_qi_saved 0
2439     }
2440     verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2441     return $et_vect_sdot_qi_saved
2442 }
2443
2444 # Return 1 if the target plus current options supports a vector
2445 # dot-product of unsigned chars, 0 otherwise.
2446 #
2447 # This won't change for different subtargets so cache the result.
2448
2449 proc check_effective_target_vect_udot_qi { } {
2450     global et_vect_udot_qi
2451
2452     if [info exists et_vect_udot_qi_saved] {
2453         verbose "check_effective_target_vect_udot_qi: using cached result" 2
2454     } else {
2455         set et_vect_udot_qi_saved 0
2456         if { [istarget powerpc*-*-*] } {
2457             set et_vect_udot_qi_saved 1
2458         }
2459     }
2460     verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2461     return $et_vect_udot_qi_saved
2462 }
2463
2464 # Return 1 if the target plus current options supports a vector
2465 # dot-product of signed shorts, 0 otherwise.
2466 #
2467 # This won't change for different subtargets so cache the result.
2468
2469 proc check_effective_target_vect_sdot_hi { } {
2470     global et_vect_sdot_hi
2471
2472     if [info exists et_vect_sdot_hi_saved] {
2473         verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2474     } else {
2475         set et_vect_sdot_hi_saved 0
2476         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2477              || [istarget i?86-*-*]
2478              || [istarget x86_64-*-*] } {
2479             set et_vect_sdot_hi_saved 1
2480         }
2481     }
2482     verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2483     return $et_vect_sdot_hi_saved
2484 }
2485
2486 # Return 1 if the target plus current options supports a vector
2487 # dot-product of unsigned shorts, 0 otherwise.
2488 #
2489 # This won't change for different subtargets so cache the result.
2490
2491 proc check_effective_target_vect_udot_hi { } {
2492     global et_vect_udot_hi
2493
2494     if [info exists et_vect_udot_hi_saved] {
2495         verbose "check_effective_target_vect_udot_hi: using cached result" 2
2496     } else {
2497         set et_vect_udot_hi_saved 0
2498         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2499             set et_vect_udot_hi_saved 1
2500         }
2501     }
2502     verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2503     return $et_vect_udot_hi_saved
2504 }
2505
2506
2507 # Return 1 if the target plus current options supports a vector
2508 # demotion (packing) of shorts (to chars) and ints (to shorts) 
2509 # using modulo arithmetic, 0 otherwise.
2510 #
2511 # This won't change for different subtargets so cache the result.
2512                                                                                 
2513 proc check_effective_target_vect_pack_trunc { } {
2514     global et_vect_pack_trunc
2515                                                                                 
2516     if [info exists et_vect_pack_trunc_saved] {
2517         verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2518     } else {
2519         set et_vect_pack_trunc_saved 0
2520         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2521              || [istarget i?86-*-*]
2522              || [istarget x86_64-*-*]
2523              || [istarget spu-*-*] } {
2524             set et_vect_pack_trunc_saved 1
2525         }
2526     }
2527     verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2528     return $et_vect_pack_trunc_saved
2529 }
2530
2531 # Return 1 if the target plus current options supports a vector
2532 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2533 #
2534 # This won't change for different subtargets so cache the result.
2535                                    
2536 proc check_effective_target_vect_unpack { } {
2537     global et_vect_unpack
2538                                         
2539     if [info exists et_vect_unpack_saved] {
2540         verbose "check_effective_target_vect_unpack: using cached result" 2
2541     } else {
2542         set et_vect_unpack_saved 0
2543         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2544              || [istarget i?86-*-*]
2545              || [istarget x86_64-*-*] 
2546              || [istarget spu-*-*] } {
2547             set et_vect_unpack_saved 1
2548         }
2549     }
2550     verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2  
2551     return $et_vect_unpack_saved
2552 }
2553
2554 # Return 1 if the target plus current options does not guarantee
2555 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2556 #
2557 # This won't change for different subtargets so cache the result.
2558
2559 proc check_effective_target_unaligned_stack { } {
2560     global et_unaligned_stack_saved
2561
2562     if [info exists et_unaligned_stack_saved] {
2563         verbose "check_effective_target_unaligned_stack: using cached result" 2
2564     } else {
2565         set et_unaligned_stack_saved 0
2566     }
2567     verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2568     return $et_unaligned_stack_saved
2569 }
2570
2571 # Return 1 if the target plus current options does not support a vector
2572 # alignment mechanism, 0 otherwise.
2573 #
2574 # This won't change for different subtargets so cache the result.
2575
2576 proc check_effective_target_vect_no_align { } {
2577     global et_vect_no_align_saved
2578
2579     if [info exists et_vect_no_align_saved] {
2580         verbose "check_effective_target_vect_no_align: using cached result" 2
2581     } else {
2582         set et_vect_no_align_saved 0
2583         if { [istarget mipsisa64*-*-*]
2584              || [istarget sparc*-*-*]
2585              || [istarget ia64-*-*]
2586              || [check_effective_target_arm32] } { 
2587             set et_vect_no_align_saved 1
2588         }
2589     }
2590     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2591     return $et_vect_no_align_saved
2592 }
2593
2594 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2595 #
2596 # This won't change for different subtargets so cache the result.
2597
2598 proc check_effective_target_vect_hw_misalign { } {
2599     global et_vect_hw_misalign_saved
2600
2601     if [info exists et_vect_hw_misalign_saved] {
2602         verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2603     } else {
2604         set et_vect_hw_misalign_saved 0
2605        if { ([istarget x86_64-*-*] 
2606             || [istarget i?86-*-*]) } {
2607           set et_vect_hw_misalign_saved 1
2608        }
2609     }
2610     verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2611     return $et_vect_hw_misalign_saved
2612 }
2613
2614
2615 # Return 1 if arrays are aligned to the vector alignment
2616 # boundary, 0 otherwise.
2617 #
2618 # This won't change for different subtargets so cache the result.
2619
2620 proc check_effective_target_vect_aligned_arrays { } {
2621     global et_vect_aligned_arrays
2622
2623     if [info exists et_vect_aligned_arrays_saved] {
2624         verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2625     } else {
2626         set et_vect_aligned_arrays_saved 0
2627         if { (([istarget x86_64-*-*]
2628               || [istarget i?86-*-*]) && [is-effective-target lp64])
2629               || [istarget spu-*-*] } {
2630             set et_vect_aligned_arrays_saved 1
2631         }
2632     }
2633     verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2634     return $et_vect_aligned_arrays_saved
2635 }
2636
2637 # Return 1 if types of size 32 bit or less are naturally aligned
2638 # (aligned to their type-size), 0 otherwise.
2639 #
2640 # This won't change for different subtargets so cache the result.
2641
2642 proc check_effective_target_natural_alignment_32 { } {
2643     global et_natural_alignment_32
2644
2645     if [info exists et_natural_alignment_32_saved] {
2646         verbose "check_effective_target_natural_alignment_32: using cached result" 2
2647     } else {
2648         # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2649         set et_natural_alignment_32_saved 1
2650         if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2651             set et_natural_alignment_32_saved 0
2652         }
2653     }
2654     verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2655     return $et_natural_alignment_32_saved
2656 }
2657
2658 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2659 # type-size), 0 otherwise.
2660 #
2661 # This won't change for different subtargets so cache the result.
2662
2663 proc check_effective_target_natural_alignment_64 { } {
2664     global et_natural_alignment_64
2665
2666     if [info exists et_natural_alignment_64_saved] {
2667         verbose "check_effective_target_natural_alignment_64: using cached result" 2
2668     } else {
2669         set et_natural_alignment_64_saved 0
2670         if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2671              || [istarget spu-*-*] } {
2672             set et_natural_alignment_64_saved 1
2673         }
2674     }
2675     verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2676     return $et_natural_alignment_64_saved
2677 }
2678
2679 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2680 #
2681 # This won't change for different subtargets so cache the result.
2682
2683 proc check_effective_target_vector_alignment_reachable { } {
2684     global et_vector_alignment_reachable
2685
2686     if [info exists et_vector_alignment_reachable_saved] {
2687         verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2688     } else {
2689         if { [check_effective_target_vect_aligned_arrays]
2690              || [check_effective_target_natural_alignment_32] } {
2691             set et_vector_alignment_reachable_saved 1
2692         } else {
2693             set et_vector_alignment_reachable_saved 0
2694         }
2695     }
2696     verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2697     return $et_vector_alignment_reachable_saved
2698 }
2699
2700 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2701 #
2702 # This won't change for different subtargets so cache the result.
2703
2704 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2705     global et_vector_alignment_reachable_for_64bit
2706
2707     if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2708         verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2709     } else {
2710         if { [check_effective_target_vect_aligned_arrays] 
2711              || [check_effective_target_natural_alignment_64] } {
2712             set et_vector_alignment_reachable_for_64bit_saved 1
2713         } else {
2714             set et_vector_alignment_reachable_for_64bit_saved 0
2715         }
2716     }
2717     verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2718     return $et_vector_alignment_reachable_for_64bit_saved
2719 }
2720
2721 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2722
2723 proc check_effective_target_vect_condition { } {
2724     global et_vect_cond_saved
2725
2726     if [info exists et_vect_cond_saved] {
2727         verbose "check_effective_target_vect_cond: using cached result" 2
2728     } else {
2729         set et_vect_cond_saved 0
2730         if { [istarget powerpc*-*-*]
2731              || [istarget ia64-*-*]
2732              || [istarget i?86-*-*]
2733              || [istarget spu-*-*]
2734              || [istarget x86_64-*-*] } {
2735            set et_vect_cond_saved 1
2736         }
2737     }
2738
2739     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2740     return $et_vect_cond_saved
2741 }
2742
2743 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2744
2745 proc check_effective_target_vect_char_mult { } {
2746     global et_vect_char_mult_saved
2747
2748     if [info exists et_vect_char_mult_saved] {
2749         verbose "check_effective_target_vect_char_mult: using cached result" 2
2750     } else {
2751         set et_vect_char_mult_saved 0
2752         if { [istarget ia64-*-*]
2753              || [istarget i?86-*-*]
2754              || [istarget x86_64-*-*] } {
2755            set et_vect_char_mult_saved 1
2756         }
2757     }
2758
2759     verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2760     return $et_vect_char_mult_saved
2761 }
2762
2763 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2764
2765 proc check_effective_target_vect_short_mult { } {
2766     global et_vect_short_mult_saved
2767
2768     if [info exists et_vect_short_mult_saved] {
2769         verbose "check_effective_target_vect_short_mult: using cached result" 2
2770     } else {
2771         set et_vect_short_mult_saved 0
2772         if { [istarget ia64-*-*]
2773              || [istarget spu-*-*]
2774              || [istarget i?86-*-*]
2775              || [istarget x86_64-*-*]
2776              || [istarget powerpc*-*-*]
2777              || [check_effective_target_arm32] } {
2778            set et_vect_short_mult_saved 1
2779         }
2780     }
2781
2782     verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2783     return $et_vect_short_mult_saved
2784 }
2785
2786 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2787
2788 proc check_effective_target_vect_int_mult { } {
2789     global et_vect_int_mult_saved
2790
2791     if [info exists et_vect_int_mult_saved] {
2792         verbose "check_effective_target_vect_int_mult: using cached result" 2
2793     } else {
2794         set et_vect_int_mult_saved 0
2795         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2796              || [istarget spu-*-*]
2797              || [istarget i?86-*-*]
2798              || [istarget x86_64-*-*]
2799              || [check_effective_target_arm32] } {
2800            set et_vect_int_mult_saved 1
2801         }
2802     }
2803
2804     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2805     return $et_vect_int_mult_saved
2806 }
2807
2808 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2809
2810 proc check_effective_target_vect_extract_even_odd { } {
2811     global et_vect_extract_even_odd_saved
2812     
2813     if [info exists et_vect_extract_even_odd_saved] {
2814         verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2815     } else {
2816         set et_vect_extract_even_odd_saved 0 
2817         if { [istarget powerpc*-*-*] 
2818              || [istarget i?86-*-*]
2819              || [istarget x86_64-*-*]
2820              || [istarget spu-*-*] } {
2821            set et_vect_extract_even_odd_saved 1
2822         }
2823     }
2824
2825     verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2826     return $et_vect_extract_even_odd_saved
2827 }
2828
2829 # Return 1 if the target supports vector even/odd elements extraction of
2830 # vectors with SImode elements or larger, 0 otherwise.
2831
2832 proc check_effective_target_vect_extract_even_odd_wide { } {
2833     global et_vect_extract_even_odd_wide_saved
2834     
2835     if [info exists et_vect_extract_even_odd_wide_saved] {
2836         verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2837     } else {
2838         set et_vect_extract_even_odd_wide_saved 0 
2839         if { [istarget powerpc*-*-*] 
2840              || [istarget i?86-*-*]
2841              || [istarget x86_64-*-*]
2842              || [istarget spu-*-*] } {
2843            set et_vect_extract_even_odd_wide_saved 1
2844         }
2845     }
2846
2847     verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2848     return $et_vect_extract_even_odd_wide_saved
2849 }
2850
2851 # Return 1 if the target supports vector interleaving, 0 otherwise.
2852
2853 proc check_effective_target_vect_interleave { } {
2854     global et_vect_interleave_saved
2855     
2856     if [info exists et_vect_interleave_saved] {
2857         verbose "check_effective_target_vect_interleave: using cached result" 2
2858     } else {
2859         set et_vect_interleave_saved 0
2860         if { [istarget powerpc*-*-*]
2861              || [istarget i?86-*-*]
2862              || [istarget x86_64-*-*]
2863              || [istarget spu-*-*] } {
2864            set et_vect_interleave_saved 1
2865         }
2866     }
2867
2868     verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2869     return $et_vect_interleave_saved
2870 }
2871
2872 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2873 proc check_effective_target_vect_strided { } {
2874     global et_vect_strided_saved
2875
2876     if [info exists et_vect_strided_saved] {
2877         verbose "check_effective_target_vect_strided: using cached result" 2
2878     } else {
2879         set et_vect_strided_saved 0
2880         if { [check_effective_target_vect_interleave]
2881              && [check_effective_target_vect_extract_even_odd] } {
2882            set et_vect_strided_saved 1
2883         }
2884     }
2885
2886     verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2887     return $et_vect_strided_saved
2888 }
2889
2890 # Return 1 if the target supports vector interleaving and extract even/odd
2891 # for wide element types, 0 otherwise.
2892 proc check_effective_target_vect_strided_wide { } {
2893     global et_vect_strided_wide_saved
2894
2895     if [info exists et_vect_strided_wide_saved] {
2896         verbose "check_effective_target_vect_strided_wide: using cached result" 2
2897     } else {
2898         set et_vect_strided_wide_saved 0
2899         if { [check_effective_target_vect_interleave]
2900              && [check_effective_target_vect_extract_even_odd_wide] } {
2901            set et_vect_strided_wide_saved 1
2902         }
2903     }
2904
2905     verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2906     return $et_vect_strided_wide_saved
2907 }
2908
2909 # Return 1 if the target supports section-anchors
2910
2911 proc check_effective_target_section_anchors { } {
2912     global et_section_anchors_saved
2913
2914     if [info exists et_section_anchors_saved] {
2915         verbose "check_effective_target_section_anchors: using cached result" 2
2916     } else {
2917         set et_section_anchors_saved 0
2918         if { [istarget powerpc*-*-*]
2919               || [istarget arm*-*-*] } {
2920            set et_section_anchors_saved 1
2921         }
2922     }
2923
2924     verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2925     return $et_section_anchors_saved
2926 }
2927
2928 # Return 1 if the target supports atomic operations on "int" and "long".
2929
2930 proc check_effective_target_sync_int_long { } {
2931     global et_sync_int_long_saved
2932
2933     if [info exists et_sync_int_long_saved] {
2934         verbose "check_effective_target_sync_int_long: using cached result" 2
2935     } else {
2936         set et_sync_int_long_saved 0
2937 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2938 # load-reserved/store-conditional instructions.
2939         if { [istarget ia64-*-*]
2940              || [istarget i?86-*-*]
2941              || [istarget x86_64-*-*]
2942              || [istarget alpha*-*-*] 
2943              || [istarget bfin*-*linux*]
2944              || [istarget s390*-*-*] 
2945              || [istarget powerpc*-*-*]
2946              || [istarget sparc64-*-*]
2947              || [istarget sparcv9-*-*]
2948              || [istarget mips*-*-*] } {
2949            set et_sync_int_long_saved 1
2950         }
2951     }
2952
2953     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2954     return $et_sync_int_long_saved
2955 }
2956
2957 # Return 1 if the target supports atomic operations on "char" and "short".
2958
2959 proc check_effective_target_sync_char_short { } {
2960     global et_sync_char_short_saved
2961
2962     if [info exists et_sync_char_short_saved] {
2963         verbose "check_effective_target_sync_char_short: using cached result" 2
2964     } else {
2965         set et_sync_char_short_saved 0
2966 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2967 # load-reserved/store-conditional instructions.
2968         if { [istarget ia64-*-*]
2969              || [istarget i?86-*-*]
2970              || [istarget x86_64-*-*]
2971              || [istarget alpha*-*-*] 
2972              || [istarget s390*-*-*] 
2973              || [istarget powerpc*-*-*]
2974              || [istarget sparc64-*-*]
2975              || [istarget sparcv9-*-*]
2976              || [istarget mips*-*-*] } {
2977            set et_sync_char_short_saved 1
2978         }
2979     }
2980
2981     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2982     return $et_sync_char_short_saved
2983 }
2984
2985 # Return 1 if the target uses a ColdFire FPU.
2986
2987 proc check_effective_target_coldfire_fpu { } {
2988     return [check_no_compiler_messages coldfire_fpu assembly {
2989         #ifndef __mcffpu__
2990         #error FOO
2991         #endif
2992     }]
2993 }
2994
2995 # Return true if this is a uClibc target.
2996
2997 proc check_effective_target_uclibc {} {
2998     return [check_no_compiler_messages uclibc object {
2999         #include <features.h>
3000         #if !defined (__UCLIBC__)
3001         #error FOO
3002         #endif
3003     }]
3004 }
3005
3006 # Return true if this is a uclibc target and if the uclibc feature
3007 # described by __$feature__ is not present.
3008
3009 proc check_missing_uclibc_feature {feature} {
3010     return [check_no_compiler_messages $feature object "
3011         #include <features.h>
3012         #if !defined (__UCLIBC) || defined (__${feature}__)
3013         #error FOO
3014         #endif
3015     "]
3016 }
3017
3018 # Return true if this is a Newlib target.
3019
3020 proc check_effective_target_newlib {} {
3021     return [check_no_compiler_messages newlib object {
3022         #include <newlib.h>
3023     }]
3024 }
3025
3026 # Return 1 if
3027 #   (a) an error of a few ULP is expected in string to floating-point
3028 #       conversion functions; and
3029 #   (b) overflow is not always detected correctly by those functions.
3030
3031 proc check_effective_target_lax_strtofp {} {
3032     # By default, assume that all uClibc targets suffer from this.
3033     return [check_effective_target_uclibc]
3034 }
3035
3036 # Return 1 if this is a target for which wcsftime is a dummy
3037 # function that always returns 0.
3038
3039 proc check_effective_target_dummy_wcsftime {} {
3040     # By default, assume that all uClibc targets suffer from this.
3041     return [check_effective_target_uclibc]
3042 }
3043
3044 # Return 1 if constructors with initialization priority arguments are
3045 # supposed on this target.
3046
3047 proc check_effective_target_init_priority {} {
3048     return [check_no_compiler_messages init_priority assembly "
3049         void f() __attribute__((constructor (1000)));
3050         void f() \{\}
3051     "]
3052 }
3053
3054 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3055 # This can be used with any check_* proc that takes no argument and
3056 # returns only 1 or 0.  It could be used with check_* procs that take
3057 # arguments with keywords that pass particular arguments.
3058
3059 proc is-effective-target { arg } {
3060     set selected 0
3061     if { [info procs check_effective_target_${arg}] != [list] } {
3062         set selected [check_effective_target_${arg}]
3063     } else {
3064         switch $arg {
3065           "vmx_hw"         { set selected [check_vmx_hw_available] }
3066           "vsx_hw"         { set selected [check_vsx_hw_available] }
3067           "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
3068           "named_sections" { set selected [check_named_sections_available] }
3069           "gc_sections"    { set selected [check_gc_sections_available] }
3070           "cxa_atexit"     { set selected [check_cxa_atexit_available] }
3071           default          { error "unknown effective target keyword `$arg'" }
3072         }
3073     }
3074     verbose "is-effective-target: $arg $selected" 2
3075     return $selected
3076 }
3077
3078 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3079
3080 proc is-effective-target-keyword { arg } {
3081     if { [info procs check_effective_target_${arg}] != [list] } {
3082         return 1
3083     } else {
3084         # These have different names for their check_* procs.
3085         switch $arg {
3086           "vmx_hw"         { return 1 }
3087           "vsx_hw"         { return 1 }
3088           "ppc_recip_hw"   { return 1 }
3089           "named_sections" { return 1 }
3090           "gc_sections"    { return 1 }
3091           "cxa_atexit"     { return 1 }
3092           default          { return 0 }
3093         }
3094     }
3095 }
3096
3097 # Return 1 if target default to short enums
3098
3099 proc check_effective_target_short_enums { } {
3100     return [check_no_compiler_messages short_enums assembly {
3101         enum foo { bar };
3102         int s[sizeof (enum foo) == 1 ? 1 : -1];
3103     }]
3104 }
3105
3106 # Return 1 if target supports merging string constants at link time.
3107
3108 proc check_effective_target_string_merging { } {
3109     return [check_no_messages_and_pattern string_merging \
3110                 "rodata\\.str" assembly {
3111                     const char *var = "String";
3112                 } {-O2}]
3113 }
3114
3115 # Return 1 if target has the basic signed and unsigned types in
3116 # <stdint.h>, 0 otherwise.  This will be obsolete when GCC ensures a
3117 # working <stdint.h> for all targets.
3118
3119 proc check_effective_target_stdint_types { } {
3120     return [check_no_compiler_messages stdint_types assembly {
3121         #include <stdint.h>
3122         int8_t a; int16_t b; int32_t c; int64_t d;
3123         uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3124     }]
3125 }
3126
3127 # Return 1 if target has the basic signed and unsigned types in
3128 # <inttypes.h>, 0 otherwise.  This is for tests that GCC's notions of
3129 # these types agree with those in the header, as some systems have
3130 # only <inttypes.h>.
3131
3132 proc check_effective_target_inttypes_types { } {
3133     return [check_no_compiler_messages inttypes_types assembly {
3134         #include <inttypes.h>
3135         int8_t a; int16_t b; int32_t c; int64_t d;
3136         uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3137     }]
3138 }
3139
3140 # Return 1 if programs are intended to be run on a simulator
3141 # (i.e. slowly) rather than hardware (i.e. fast).
3142
3143 proc check_effective_target_simulator { } {
3144
3145     # All "src/sim" simulators set this one.
3146     if [board_info target exists is_simulator] {
3147         return [board_info target is_simulator]
3148     }
3149
3150     # The "sid" simulators don't set that one, but at least they set
3151     # this one.
3152     if [board_info target exists slow_simulator] {
3153         return [board_info target slow_simulator]
3154     }
3155
3156     return 0
3157 }
3158
3159 # Return 1 if the target is a VxWorks kernel.
3160
3161 proc check_effective_target_vxworks_kernel { } {
3162     return [check_no_compiler_messages vxworks_kernel assembly {
3163         #if !defined __vxworks || defined __RTP__
3164         #error NO
3165         #endif
3166     }]
3167 }
3168
3169 # Return 1 if the target is a VxWorks RTP.
3170
3171 proc check_effective_target_vxworks_rtp { } {
3172     return [check_no_compiler_messages vxworks_rtp assembly {
3173         #if !defined __vxworks || !defined __RTP__
3174         #error NO
3175         #endif
3176     }]
3177 }
3178
3179 # Return 1 if the target is expected to provide wide character support.
3180
3181 proc check_effective_target_wchar { } {
3182     if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3183         return 0
3184     }
3185     return [check_no_compiler_messages wchar assembly {
3186         #include <wchar.h>
3187     }]
3188 }
3189
3190 # Return 1 if the target has <pthread.h>.
3191
3192 proc check_effective_target_pthread_h { } {
3193     return [check_no_compiler_messages pthread_h assembly {
3194         #include <pthread.h>
3195     }]
3196 }
3197
3198 # Return 1 if the target can truncate a file from a file-descriptor,
3199 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3200 # chsize.  We test for a trivially functional truncation; no stubs.
3201 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3202 # different function to be used.
3203
3204 proc check_effective_target_fd_truncate { } {
3205     set prog {
3206         #define _FILE_OFFSET_BITS 64
3207         #include <unistd.h>
3208         #include <stdio.h>
3209         #include <stdlib.h>
3210         int main ()
3211         {
3212           FILE *f = fopen ("tst.tmp", "wb");
3213           int fd;
3214           const char t[] = "test writing more than ten characters";
3215           char s[11];
3216           fd =  fileno (f);
3217           write (fd, t, sizeof (t) - 1);
3218           lseek (fd, 0, 0);
3219           if (ftruncate (fd, 10) != 0)
3220             exit (1);
3221           close (fd);
3222           f = fopen ("tst.tmp", "rb");
3223           if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3224             exit (1);
3225           exit (0);
3226         }
3227     }
3228
3229     if { [check_runtime ftruncate $prog] } {
3230       return 1;
3231     }
3232
3233     regsub "ftruncate" $prog "chsize" prog
3234     return [check_runtime chsize $prog]
3235 }
3236
3237 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3238
3239 proc add_options_for_c99_runtime { flags } {
3240     if { [istarget *-*-solaris2*] } {
3241         return "$flags -std=c99"
3242     }
3243     if { [istarget powerpc-*-darwin*] } {
3244         return "$flags -mmacosx-version-min=10.3"
3245     }
3246     return $flags
3247 }
3248
3249 # Add to FLAGS all the target-specific flags needed to enable
3250 # full IEEE compliance mode.
3251
3252 proc add_options_for_ieee { flags } {
3253     if { [istarget "alpha*-*-*"]
3254          || [istarget "sh*-*-*"] } {
3255        return "$flags -mieee"
3256     }
3257     return $flags
3258 }
3259
3260 # Add to FLAGS the flags needed to enable functions to bind locally
3261 # when using pic/PIC passes in the testsuite.
3262
3263 proc add_options_for_bind_pic_locally { flags } {
3264     if {[check_no_compiler_messages using_pic2 assembly {
3265         #if __PIC__ != 2
3266         #error FOO
3267         #endif
3268     }]} {
3269         return "$flags -fPIE"
3270     }
3271     if {[check_no_compiler_messages using_pic1 assembly {
3272         #if __PIC__ != 1
3273         #error FOO
3274         #endif
3275     }]} {
3276         return "$flags -fpie"
3277     }
3278
3279     return $flags
3280 }
3281
3282 # Return 1 if the target provides a full C99 runtime.
3283
3284 proc check_effective_target_c99_runtime { } {
3285     return [check_cached_effective_target c99_runtime {
3286         global srcdir
3287
3288         set file [open "$srcdir/gcc.dg/builtins-config.h"]
3289         set contents [read $file]
3290         close $file
3291         append contents {
3292             #ifndef HAVE_C99_RUNTIME
3293             #error FOO
3294             #endif
3295         }
3296         check_no_compiler_messages_nocache c99_runtime assembly \
3297             $contents [add_options_for_c99_runtime ""]
3298     }]
3299 }
3300
3301 # Return 1 if  target wchar_t is at least 4 bytes.
3302
3303 proc check_effective_target_4byte_wchar_t { } {
3304     return [check_no_compiler_messages 4byte_wchar_t object {
3305         int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3306     }]
3307 }
3308
3309 # Return 1 if the target supports automatic stack alignment.
3310
3311 proc check_effective_target_automatic_stack_alignment  { } {
3312     if { [istarget i?86*-*-*]
3313          || [istarget x86_64-*-*] } then {
3314         return 1
3315     } else {
3316         return 0
3317     }
3318 }
3319
3320 # Return 1 if avx instructions can be compiled.
3321
3322 proc check_effective_target_avx { } {
3323     return [check_no_compiler_messages avx object {
3324         void _mm256_zeroall (void)
3325         {
3326            __builtin_ia32_vzeroall ();
3327         }
3328     } "-O2 -mavx" ]
3329 }
3330
3331 # Return 1 if sse instructions can be compiled.
3332 proc check_effective_target_sse { } {
3333     return [check_no_compiler_messages sse object {
3334         int main ()
3335         {
3336             __builtin_ia32_stmxcsr ();
3337             return 0;
3338         }
3339     } "-O2 -msse" ]
3340 }
3341
3342 # Return 1 if sse2 instructions can be compiled.
3343 proc check_effective_target_sse2 { } {
3344     return [check_no_compiler_messages sse2 object {
3345         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3346         
3347         __m128i _mm_srli_si128 (__m128i __A, int __N)
3348         {
3349             return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3350         }
3351     } "-O2 -msse2" ]
3352 }
3353
3354 # Return 1 if F16C instructions can be compiled.
3355
3356 proc check_effective_target_f16c { } {
3357     return [check_no_compiler_messages f16c object {
3358         #include "immintrin.h"
3359         float
3360         foo (unsigned short val)
3361         {
3362           return _cvtsh_ss (val);
3363         }
3364     } "-O2 -mf16c" ]
3365 }
3366
3367 # Return 1 if C wchar_t type is compatible with char16_t.
3368
3369 proc check_effective_target_wchar_t_char16_t_compatible { } {
3370     return [check_no_compiler_messages wchar_t_char16_t object {
3371         __WCHAR_TYPE__ wc;
3372         __CHAR16_TYPE__ *p16 = &wc;
3373         char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3374     }]
3375 }
3376
3377 # Return 1 if C wchar_t type is compatible with char32_t.
3378
3379 proc check_effective_target_wchar_t_char32_t_compatible { } {
3380     return [check_no_compiler_messages wchar_t_char32_t object {
3381         __WCHAR_TYPE__ wc;
3382         __CHAR32_TYPE__ *p32 = &wc;
3383         char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3384     }]
3385 }
3386
3387 # Return 1 if pow10 function exists.
3388
3389 proc check_effective_target_pow10 { } {
3390     return [check_runtime pow10 {
3391         #include <math.h>
3392         int main () {
3393         double x;
3394         x = pow10 (1);
3395         return 0;
3396         }
3397     } "-lm" ]
3398 }
3399
3400 # Return 1 if current options generate DFP instructions, 0 otherwise.
3401
3402 proc check_effective_target_hard_dfp {} {
3403     return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3404         typedef float d64 __attribute__((mode(DD)));
3405         d64 x, y, z;
3406         void foo (void) { z = x + y; }
3407     }]
3408 }
3409
3410 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3411 # for strchr etc. functions.
3412
3413 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3414     return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3415         #include <string.h>
3416         #include <wchar.h>
3417         #if !defined(__cplusplus) \
3418             || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3419             || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3420         ISO C++ correct string.h and wchar.h protos not supported.
3421         #else
3422         int i;
3423         #endif
3424     }]
3425 }
3426
3427 # Return 1 if GNU as is used.
3428
3429 proc check_effective_target_gas { } {
3430     global use_gas_saved
3431     global tool
3432
3433     if {![info exists use_gas_saved]} {
3434         # Check if the as used by gcc is GNU as.
3435         set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3436         # Provide /dev/null as input, otherwise gas times out reading from
3437         # stdin.
3438         set status [remote_exec host "$gcc_as" "-v /dev/null"]
3439         set as_output [lindex $status 1]
3440         if { [ string first "GNU" $as_output ] >= 0 } {
3441             set use_gas_saved 1
3442         } else {
3443             set use_gas_saved 0
3444         }
3445     }
3446     return $use_gas_saved
3447 }
3448
3449 # Return 1 if the compiler has been configure with link-time optimization
3450 # (LTO) support.
3451
3452 proc check_effective_target_lto { } {
3453     global ENABLE_LTO
3454     return [info exists ENABLE_LTO]
3455 }
3456
3457 # Return 1 if the language for the compiler under test is C.
3458
3459 proc check_effective_target_c { } {
3460  global tool
3461     if [string match $tool "gcc"] {
3462    return 1
3463     }
3464  return 0
3465 }
3466
3467 # Return 1 if the language for the compiler under test is C++.
3468
3469 proc check_effective_target_c++ { } {
3470  global tool
3471     if [string match $tool "g++"] {
3472    return 1
3473     }
3474  return 0
3475 }