OSDN Git Service

2005-06-07 Adrian Straetling <straetling@de.ibm.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / target-supports.exp
1 #   Copyright (C) 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile some code and return the messages printed by the compiler.
23 #
24 # BASENAME is a basename to use for temporary files.
25 # TYPE is the type of compilation to perform (see target_compile).
26 # CONTENTS gives the contents of the input file.
27 # The rest is optional:
28 # OPTIONS: additional compiler options to use.
29 proc get_compiler_messages {basename type contents args} {
30     global tool
31
32     if { [llength $args] > 0 } {
33         set options "additional_flags=[lindex $args 0]"
34     } else {
35         set options ""
36     }
37
38     set src ${basename}[pid].c
39     switch $type {
40         assembly { set output ${basename}[pid].s }
41         object { set output ${basename}[pid].o }
42     }
43     set f [open $src "w"]
44     puts $f $contents
45     close $f
46     set lines [${tool}_target_compile $src $output $type "$options"]
47     file delete $src
48     remote_file build delete $output
49
50     return $lines
51 }
52
53 proc current_target_name { } {
54     global target_info
55     if [info exists target_info(target,name)] {
56         set answer $target_info(target,name)
57     } else {
58         set answer ""
59     }
60     return $answer
61 }
62
63 ###############################
64 # proc check_weak_available { }
65 ###############################
66
67 # weak symbols are only supported in some configs/object formats
68 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
69
70 proc check_weak_available { } {
71     global target_triplet
72     global target_cpu
73
74     # All mips targets should support it
75
76     if { [ string first "mips" $target_cpu ] >= 0 } {
77         return 1
78     }
79
80     # All solaris2 targets should support it
81
82     if { [regexp ".*-solaris2.*" $target_triplet] } {
83         return 1
84     }
85
86     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
87
88     if { [regexp "alpha.*osf.*" $target_triplet] } {
89         return 1
90     }
91
92     # Windows targets Cygwin and MingW32 support it
93
94     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
95         return 1
96     }
97
98     # HP-UX 10.X doesn't support it
99
100     if { [regexp "hppa.*hpux10" $target_triplet] } {
101         return 0
102     }
103
104     # ELF and ECOFF support it. a.out does with gas/gld but may also with
105     # other linkers, so we should try it
106
107     set objformat [gcc_target_object_format]
108
109     switch $objformat {
110         elf      { return 1 }
111         ecoff    { return 1 }
112         a.out    { return 1 }
113         mach-o   { return 1 }
114         som      { return 1 }
115         unknown  { return -1 }
116         default  { return 0 }
117     }
118 }
119
120 ###############################
121 # proc check_visibility_available { what_kind }
122 ###############################
123
124 # The visibility attribute is only support in some object formats
125 # This proc returns 1 if it is supported, 0 if not.
126 # The argument is the kind of visibility, default/protected/hidden/internal.
127
128 proc check_visibility_available { what_kind } {
129     global visibility_available_saved
130     global tool
131     global target_triplet
132
133     # On NetWare, support makes no sense.
134     if { [string match "*-*-netware*" $target_triplet] } {
135         return 0
136     }
137
138     if [string match "" $what_kind] { set what_kind "hidden" }
139
140     if { [info exists visibility_available_saved] } {
141         verbose "Saved result is <$visibility_available_saved>" 1
142         if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
143             return 1
144         } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
145             return 0
146         }
147     }
148
149     set lines [get_compiler_messages visibility object "
150         void f() __attribute__((visibility(\"$what_kind\")));
151         void f() {}
152     "]
153     if [string match "" $lines] then {
154         set answer 1
155         lappend visibility_available_saved $what_kind
156     } else {
157         set answer 0
158         lappend visibility_available_saved "!$what_kind"
159     }
160     return $answer
161 }
162
163 ###############################
164 # proc check_alias_available { }
165 ###############################
166
167 # Determine if the target toolchain supports the alias attribute.
168
169 # Returns 2 if the target supports aliases.  Returns 1 if the target
170 # only supports weak aliased.  Returns 0 if the target does not
171 # support aliases at all.  Returns -1 if support for aliases could not
172 # be determined.
173
174 proc check_alias_available { } {
175     global alias_available_saved
176     global tool
177
178     if [info exists alias_available_saved] {
179         verbose "check_alias_available  returning saved $alias_available_saved" 2
180     } else {
181         set src alias[pid].c
182         set obj alias[pid].o
183         verbose "check_alias_available  compiling testfile $src" 2
184         set f [open $src "w"]
185         # Compile a small test program.  The definition of "g" is
186         # necessary to keep the Solaris assembler from complaining
187         # about the program.
188         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
189         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
190         close $f
191         set lines [${tool}_target_compile $src $obj object ""]
192         file delete $src
193         remote_file build delete $obj
194
195         if [string match "" $lines] then {
196             # No error messages, everything is OK.
197             set alias_available_saved 2
198         } else {
199             if [regexp "alias definitions not supported" $lines] {
200                 verbose "check_alias_available  target does not support aliases" 2
201
202                 set objformat [gcc_target_object_format]
203
204                 if { $objformat == "elf" } {
205                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
206                     set alias_available_saved -1
207                 } else {
208                     set alias_available_saved 0
209                 }
210             } else {
211                 if [regexp "only weak aliases are supported" $lines] {
212                 verbose "check_alias_available  target supports only weak aliases" 2
213                 set alias_available_saved 1
214                 } else {
215                     set alias_available_saved -1
216                 }
217             }
218         }
219
220         verbose "check_alias_available  returning $alias_available_saved" 2
221     }
222
223     return $alias_available_saved
224 }
225
226 # Returns true if --gc-sections is supported on the target.
227
228 proc check_gc_sections_available { } {
229     global gc_sections_available_saved
230     global tool
231
232     if {![info exists gc_sections_available_saved]} {
233         # Some targets don't support gc-sections despite whatever's
234         # advertised by ld's options.
235         if { [istarget alpha*-*-*]
236              || [istarget ia64-*-*] } {
237             set gc_sections_available_saved 0
238             return 0
239         }
240
241         # Check if the ld used by gcc supports --gc-sections.
242         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
243         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
244         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
245         set ld_output [remote_exec host "$gcc_ld" "--help"]
246         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
247             set gc_sections_available_saved 1
248         } else {
249             set gc_sections_available_saved 0
250         }
251     }
252     return $gc_sections_available_saved
253 }
254
255 # Return true if profiling is supported on the target.
256
257 proc check_profiling_available { test_what } {
258     global profiling_available_saved
259
260     verbose "Profiling argument is <$test_what>" 1
261
262     # These conditions depend on the argument so examine them before
263     # looking at the cache variable.
264
265     # Support for -p on solaris2 relies on mcrt1.o which comes with the
266     # vendor compiler.  We cannot reliably predict the directory where the
267     # vendor compiler (and thus mcrt1.o) is installed so we can't
268     # necessarily find mcrt1.o even if we have it.
269     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
270         return 0
271     }
272
273     # Support for -p on irix relies on libprof1.a which doesn't appear to
274     # exist on any irix6 system currently posting testsuite results.
275     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
276     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
277     if { [istarget mips*-*-irix*]
278     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
279         return 0
280     }
281
282     # Now examine the cache variable.
283     if {![info exists profiling_available_saved]} {
284         # Some targets don't have any implementation of __bb_init_func or are
285         # missing other needed machinery.
286         if { [istarget mmix-*-*]
287              || [istarget arm*-*-eabi*]
288              || [istarget arm*-*-elf]
289              || [istarget arm*-*-symbianelf*]
290              || [istarget powerpc-*-eabi*]
291              || [istarget strongarm*-*-elf]
292              || [istarget xscale*-*-elf]
293              || [istarget cris-*-*]
294              || [istarget h8300-*-*]
295              || [istarget mips*-*-elf]
296              || [istarget xtensa-*-elf]
297              || [istarget *-*-windiss] } {
298             set profiling_available_saved 0
299         } else {
300             set profiling_available_saved 1
301         }
302     }
303
304     return $profiling_available_saved
305 }
306
307 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
308 # emitted, 0 otherwise.  Whether a shared library can actually be built is
309 # out of scope for this test.
310 #
311 # When the target name changes, replace the cached result.
312
313 proc check_effective_target_fpic { } {
314     global et_fpic_saved
315     global et_fpic_target_name
316
317     if { ![info exists et_fpic_target_name] } {
318         set et_fpic_target_name ""
319     }
320
321     # If the target has changed since we set the cached value, clear it.
322     set current_target [current_target_name]
323     if { $current_target != $et_fpic_target_name } {
324         verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
325         set et_fpic_target_name $current_target
326         if [info exists et_fpic_saved] {
327             verbose "check_effective_target_fpic: removing cached result" 2
328             unset et_fpic_saved
329         }
330     }
331
332     if [info exists et_fpic_saved] {
333         verbose "check_effective_target_fpic: using cached result" 2
334     } else {
335         verbose "check_effective_target_fpic: compiling source" 2
336
337         # Note that M68K has a multilib that supports -fpic but not
338         # -fPIC, so we need to check both.  We test with a program that
339         # requires GOT references.
340         set et_fpic_saved [string match "" [get_compiler_messages fpic object {
341             extern int foo (void); extern int bar;
342             int baz (void) { return foo () + bar; }
343         } "-fpic"]]
344
345         if { $et_fpic_saved != 0 } {
346             set et_fpic_saved [string match "" [get_compiler_messages fpic object {
347                 extern int foo (void); extern int bar;
348                 int baz (void) { return foo () + bar; }
349             } "-fPIC"]]
350         }
351     }
352     verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
353     return $et_fpic_saved
354 }
355
356 # Return true if iconv is supported on the target. In particular IBM1047.
357
358 proc check_iconv_available { test_what } {
359     global tool
360     global libiconv
361
362     set result ""
363
364     set src iconv[pid].c
365     set exe iconv[pid].x
366     verbose "check_iconv_available compiling testfile $src" 2
367     set f [open $src "w"]
368     # Compile a small test program.
369     puts $f "#include <iconv.h>\n"
370     puts $f "int main (void)\n {\n iconv_t cd; \n"
371     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
372     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
373     puts $f "return 0;\n}"
374     close $f
375
376     # If the tool configuration file has not set libiconv, try "-liconv"
377     if { ![info exists libiconv] } {
378         set libiconv "-liconv"
379     }
380     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
381     file delete $src
382
383     if [string match "" $lines] then {
384         # No error messages, everything is OK.
385
386         set result [${tool}_load "./$exe" "" ""]
387         set status [lindex $result 0]
388         remote_file build delete $exe
389
390         verbose "check_iconv_available status is <$status>" 2
391
392         if { $status == "pass" } then {
393             return 1
394         }
395     }
396
397     return 0
398 }
399
400 # Return true if named sections are supported on this target.
401 # This proc does not cache results, because the answer may vary
402 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
403 # the same test run.
404 proc check_named_sections_available { } {
405     verbose "check_named_sections_available: compiling source" 2
406     set answer [string match "" [get_compiler_messages named object {
407         int __attribute__ ((section("whatever"))) foo;
408     }]]
409     verbose "check_named_sections_available: returning $answer" 2
410     return $answer
411 }
412
413 # Return 1 if the target supports executing AltiVec instructions, 0
414 # otherwise.  Cache the result.
415
416 proc check_vmx_hw_available { } {
417     global vmx_hw_available_saved
418     global tool
419
420     if [info exists vmx_hw_available_saved] {
421         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
422     } else {
423         set vmx_hw_available_saved 0
424
425         # Some simulators are known to not support VMX instructions.
426         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
427             verbose "check_hw_available  returning 0" 2
428             return $vmx_hw_available_saved
429         }
430
431         # Set up, compile, and execute a test program containing VMX
432         # instructions.  Include the current process ID in the file
433         # names to prevent conflicts with invocations for multiple
434         # testsuites.
435         set src vmx[pid].c
436         set exe vmx[pid].x
437
438         set f [open $src "w"]
439         puts $f "int main() {"
440         puts $f "#ifdef __MACH__"
441         puts $f "  asm volatile (\"vor v0,v0,v0\");"
442         puts $f "#else"
443         puts $f "  asm volatile (\"vor 0,0,0\");"
444         puts $f "#endif"
445         puts $f "  return 0; }"
446         close $f
447
448         # Most targets don't require special flags for this test case, but
449         # Darwin does.
450         if [istarget *-*-darwin*] {
451           set opts "additional_flags=-maltivec"
452         } else {
453           set opts ""
454         }
455
456         verbose "check_vmx_hw_available  compiling testfile $src" 2
457         set lines [${tool}_target_compile $src $exe executable "$opts"]
458         file delete $src
459
460         if [string match "" $lines] then {
461             # No error message, compilation succeeded.
462             set result [${tool}_load "./$exe" "" ""]
463             set status [lindex $result 0]
464             remote_file build delete $exe
465             verbose "check_vmx_hw_available testfile status is <$status>" 2
466
467             if { $status == "pass" } then {
468                 set vmx_hw_available_saved 1
469             }
470         } else {
471             verbose "check_vmx_hw_availalble testfile compilation failed" 2
472         }
473     }
474
475     return $vmx_hw_available_saved
476 }
477
478 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
479 # complex float arguments.  This affects gfortran tests that call cabsf
480 # in libm built by an earlier compiler.  Return 1 if libm uses the same
481 # argument passing as the compiler under test, 0 otherwise.
482 #
483 # When the target name changes, replace the cached result.
484
485 proc check_effective_target_broken_cplxf_arg { } {
486     global et_broken_cplxf_arg_saved
487     global et_broken_cplxf_arg_target_name
488     global tool
489
490     # Skip the work for targets known not to be affected.
491     if { ![istarget powerpc64-*-linux*] } {
492         return 0
493     } elseif { [is-effective-target ilp32] } {
494         return 0
495     }
496
497     if { ![info exists et_broken_cplxf_arg_target_name] } {
498         set et_broken_cplxf_arg_target_name ""
499     }
500
501     # If the target has changed since we set the cached value, clear it.
502     set current_target [current_target_name]
503     if { $current_target != $et_broken_cplxf_arg_target_name } {
504         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
505         set et_broken_cplxf_arg_target_name $current_target
506         if [info exists et_broken_cplxf_arg_saved] {
507             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
508             unset et_broken_cplxf_arg_saved
509         }
510     }
511
512     if [info exists et_broken_cplxf_arg_saved] {
513         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
514     } else {
515         set et_broken_cplxf_arg_saved 0
516         # This is only known to affect one target.
517         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
518             set et_broken_cplxf_arg_saved 0
519             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
520             return $et_broken_cplxf_arg_saved
521         }
522
523         # Set up, compile, and execute a C test program that calls cabsf.
524         set src cabsf[pid].c
525         set exe cabsf[pid].x
526
527         set f [open $src "w"]
528         puts $f "#include <complex.h>"
529         puts $f "extern void abort (void);"
530         puts $f "float fabsf (float);"
531         puts $f "float cabsf (_Complex float);"
532         puts $f "int main ()"
533         puts $f "{"
534         puts $f "  _Complex float cf;"
535         puts $f "  float f;"
536         puts $f "  cf = 3 + 4.0fi;"
537         puts $f "  f = cabsf (cf);"
538         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
539         puts $f "  return 0;"
540         puts $f "}"
541         close $f
542
543         set lines [${tool}_target_compile $src $exe executable "-lm"]
544         file delete $src
545
546         if [string match "" $lines] {
547             # No error message, compilation succeeded.
548             set result [${tool}_load "./$exe" "" ""]
549             set status [lindex $result 0]
550             remote_file build delete $exe
551
552             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
553
554             if { $status != "pass" } {
555                 set et_broken_cplxf_arg_saved 1
556             }
557         } else {
558             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
559         }
560     }
561     return $et_broken_cplxf_arg_saved
562 }
563
564 proc check_alpha_max_hw_available { } {
565     global alpha_max_hw_available_saved
566     global tool
567
568     if [info exists alpha_max_hw_available_saved] {
569         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
570     } else {
571         set alpha_max_hw_available_saved 0
572
573         # Set up, compile, and execute a test program probing bit 8 of the
574         # architecture mask, which indicates presence of MAX instructions.
575         set src max[pid].c
576         set exe max[pid].x
577
578         set f [open $src "w"]
579         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
580         close $f
581
582         verbose "check_alpha_max_hw_available compiling testfile $src" 2
583         set lines [${tool}_target_compile $src $exe executable ""]
584         file delete $src
585
586         if [string match "" $lines] then {
587             # No error message, compilation succeeded.
588             set result [${tool}_load "./$exe" "" ""]
589             set status [lindex $result 0]
590             remote_file build delete $exe
591             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
592
593             if { $status == "pass" } then {
594                 set alpha_max_hw_available_saved 1
595             }
596         } else {
597             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
598         }
599     }
600
601     return $alpha_max_hw_available_saved
602 }
603
604 # Returns true iff the FUNCTION is available on the target system.
605 # (This is essentially a Tcl implementation of Autoconf's
606 # AC_CHECK_FUNC.)
607
608 proc check_function_available { function } {
609     set var "${function}_available_saved"
610     global $var
611     global tool
612
613     if {![info exists $var]} {
614         # Assume it exists.
615         set $var 1
616         # Check to make sure.
617         set src "function[pid].c"
618         set exe "function[pid].exe"
619
620         set f [open $src "w"]
621         puts $f "int main () { $function (); }"
622         close $f
623
624         set lines [${tool}_target_compile $src $exe executable ""]
625         file delete $src
626         file delete $exe
627
628         if {![string match "" $lines]} then {
629             set $var 0
630             verbose -log "$function is not available"
631         } else {
632             verbose -log "$function is available"
633         }
634     }
635
636     eval return \$$var
637 }
638
639 # Returns true iff "fork" is available on the target system.
640
641 proc check_fork_available {} {
642     return [check_function_available "fork"]
643 }
644
645 # Returns true iff "mkfifo" is available on the target system.
646
647 proc check_mkfifo_available {} {
648     if {[istarget *-*-cygwin*]} {
649        # Cygwin has mkfifo, but support is incomplete.
650        return 0
651      }
652
653     return [check_function_available "mkfifo"]
654 }
655
656 # Return 1 if we're generating 32-bit code using default options, 0
657 # otherwise.
658 #
659 # When the target name changes, replace the cached result.
660
661 proc check_effective_target_ilp32 { } {
662     global et_ilp32_saved
663     global et_ilp32_target_name
664
665     if { ![info exists et_ilp32_target_name] } {
666         set et_ilp32_target_name ""
667     }
668
669     # If the target has changed since we set the cached value, clear it.
670     set current_target [current_target_name]
671     if { $current_target != $et_ilp32_target_name } {
672         verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
673         set et_ilp32_target_name $current_target
674         if { [info exists et_ilp32_saved] } {
675             verbose "check_effective_target_ilp32: removing cached result" 2
676             unset et_ilp32_saved
677         }
678     }
679
680     if [info exists et_ilp32_saved] {
681         verbose "check-effective_target_ilp32: using cached result" 2
682     } else {
683         verbose "check_effective_target_ilp32: compiling source" 2
684         set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
685             int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
686         }]]
687     }
688     verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
689     return $et_ilp32_saved
690 }
691
692 # Return 1 if we're generating 64-bit code using default options, 0
693 # otherwise.
694 #
695 # When the target name changes, replace the cached result.
696
697 proc check_effective_target_lp64 { } {
698     global et_lp64_saved
699     global et_lp64_target_name
700
701     if { ![info exists et_lp64_target_name] } {
702         set et_lp64_target_name ""
703     }
704
705     # If the target has changed since we set the cached value, clear it.
706     set current_target [current_target_name]
707     if { $current_target != $et_lp64_target_name } {
708         verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
709         set et_lp64_target_name $current_target
710         if [info exists et_lp64_saved] {
711             verbose "check_effective_target_lp64: removing cached result" 2
712             unset et_lp64_saved
713         }
714     }
715
716     if [info exists et_lp64_saved] {
717         verbose "check_effective_target_lp64: using cached result" 2
718     } else {
719         verbose "check_effective_target_lp64: compiling source" 2
720         set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
721             int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
722         }]]
723     }
724     verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
725     return $et_lp64_saved
726 }
727
728 # Return 1 if the target needs a command line argument to enable a SIMD
729 # instruction set.
730 #
731 # This won't change for different subtargets so cache the result.
732
733 proc check_effective_target_vect_cmdline_needed { } {
734     global et_vect_cmdline_needed_saved
735
736     if [info exists et_vect_cmdline_needed_saved] {
737         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
738     } else {
739         set et_vect_cmdline_needed_saved 1
740         if { [istarget ia64-*-*]
741               || [istarget x86_64-*-*] } {
742            set et_vect_cmdline_needed_saved 0
743         }
744     }
745
746     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
747     return $et_vect_cmdline_needed_saved
748 }
749
750 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
751 #
752 # This won't change for different subtargets so cache the result.
753
754 proc check_effective_target_vect_int { } {
755     global et_vect_int_saved
756
757     if [info exists et_vect_int_saved] {
758         verbose "check_effective_target_vect_int: using cached result" 2
759     } else {
760         set et_vect_int_saved 0
761         if { [istarget i?86-*-*]
762               || [istarget powerpc*-*-*]
763               || [istarget x86_64-*-*]
764               || [istarget sparc*-*-*]
765               || [istarget alpha*-*-*]
766               || [istarget ia64-*-*] } {
767            set et_vect_int_saved 1
768         }
769     }
770
771     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
772     return $et_vect_int_saved
773 }
774
775 # Return 1 is this is an arm target using 32-bit instructions
776 proc check_effective_target_arm32 { } {
777     global et_arm32_saved
778     global et_arm32_target_name
779     global compiler_flags
780
781     if { ![info exists et_arm32_target_name] } {
782         set et_arm32_target_name ""
783     }
784
785     # If the target has changed since we set the cached value, clear it.
786     set current_target [current_target_name]
787     if { $current_target != $et_arm32_target_name } {
788         verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
789         set et_arm32_target_name $current_target
790         if { [info exists et_arm32_saved] } {
791             verbose "check_effective_target_arm32: removing cached result" 2
792             unset et_arm32_saved
793         }
794     }
795
796     if [info exists et_arm32_saved] {
797         verbose "check-effective_target_arm32: using cached result" 2
798     } else {
799         set et_arm32_saved 0
800         if { [istarget arm-*-*]
801               || [istarget strongarm*-*-*]
802               || [istarget xscale-*-*] } {
803             if ![string match "*-mthumb *" $compiler_flags] {
804                 set et_arm32_saved 1
805             }
806         }
807     }
808     verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
809     return $et_arm32_saved
810 }
811
812 # Return 1 if the target supports hardware vector shift operation.
813
814 proc check_effective_target_vect_shift { } {
815     if { [istarget powerpc*-*-*] } {
816         set answer 1
817     } else {
818         set answer 0
819     }
820
821     verbose "check_effective_target_vect_shift: returning $answer" 2
822     return $answer
823 }
824
825 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
826 #
827 # This can change for different subtargets so do not cache the result.
828
829 proc check_effective_target_vect_long { } {
830     if { [istarget i?86-*-*]
831          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
832          || [istarget x86_64-*-*]
833          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
834         set answer 1
835     } else {
836         set answer 0
837     }
838
839     verbose "check_effective_target_vect_long: returning $answer" 2
840     return $answer
841 }
842
843 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
844 #
845 # This won't change for different subtargets so cache the result.
846
847 proc check_effective_target_vect_float { } {
848     global et_vect_float_saved
849
850     if [info exists et_vect_float_saved] {
851         verbose "check_effective_target_vect_float: using cached result" 2
852     } else {
853         set et_vect_float_saved 0
854         if { [istarget i?86-*-*]
855               || [istarget powerpc*-*-*]
856               || [istarget mipsisa64*-*-*]
857               || [istarget x86_64-*-*]
858               || [istarget ia64-*-*] } {
859            set et_vect_float_saved 1
860         }
861     }
862
863     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
864     return $et_vect_float_saved
865 }
866
867 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
868 #
869 # This won't change for different subtargets so cache the result.
870
871 proc check_effective_target_vect_double { } {
872     global et_vect_double_saved
873
874     if [info exists et_vect_double_saved] {
875         verbose "check_effective_target_vect_double: using cached result" 2
876     } else {
877         set et_vect_double_saved 0
878         if { [istarget i?86-*-*]
879               || [istarget x86_64-*-*] } {
880            set et_vect_double_saved 1
881         }
882     }
883
884     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
885     return $et_vect_double_saved
886 }
887
888 # Return 1 if the target plus current options does not support a vector
889 # max instruction, 0 otherwise.
890 #
891 # This won't change for different subtargets so cache the result.
892
893 proc check_effective_target_vect_no_max { } {
894     global et_vect_no_max_saved
895
896     if [info exists et_vect_no_max_saved] {
897         verbose "check_effective_target_vect_no_max: using cached result" 2
898     } else {
899         set et_vect_no_max_saved 0
900         if { [istarget i?86-*-*]
901              || [istarget x86_64-*-*]
902              || [istarget sparc*-*-*]
903              || [istarget alpha*-*-*] } {
904             set et_vect_no_max_saved 1
905         }
906     }
907     verbose "check_effective_target_vect_no_max: returning $et_vect_no_max_saved" 2
908     return $et_vect_no_max_saved
909 }
910
911 # Return 1 if the target plus current options does not support vector
912 # bitwise instructions, 0 otherwise.
913 #
914 # This won't change for different subtargets so cache the result.
915
916 proc check_effective_target_vect_no_bitwise { } {
917     global et_vect_no_bitwise_saved
918
919     if [info exists et_vect_no_bitwise_saved] {
920         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
921     } else {
922         set et_vect_no_bitwise_saved 0
923     }
924     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
925     return $et_vect_no_bitwise_saved
926 }
927
928 # Return 1 if the target plus current options does not support a vector
929 # alignment mechanism, 0 otherwise.
930 #
931 # This won't change for different subtargets so cache the result.
932
933 proc check_effective_target_vect_no_align { } {
934     global et_vect_no_align_saved
935
936     if [info exists et_vect_no_align_saved] {
937         verbose "check_effective_target_vect_no_align: using cached result" 2
938     } else {
939         set et_vect_no_align_saved 0
940         if { [istarget mipsisa64*-*-*]
941              || [istarget sparc*-*-*]
942              || [istarget ia64-*-*] } {
943             set et_vect_no_align_saved 1
944         }
945     }
946     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
947     return $et_vect_no_align_saved
948 }
949
950 # Return 1 if the target supports vector conditional operations, 0 otherwise.
951
952 proc check_effective_target_vect_condition { } {
953     global et_vect_cond_saved
954
955     if [info exists et_vect_int_cond] {
956         verbose "check_effective_target_vect_cond: using cached result" 2
957     } else {
958         set et_vect_cond_saved 0
959         if { [istarget powerpc*-*-*]
960              || [istarget ia64-*-*]
961              || [istarget i?86-*-*]
962              || [istarget x86_64-*-*] } {
963            set et_vect_cond_saved 1
964         }
965     }
966
967     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
968     return $et_vect_cond_saved
969 }
970
971 # Return 1 if the target supports vector int multiplication, 0 otherwise.
972
973 proc check_effective_target_vect_int_mult { } {
974     global et_vect_int_mult_saved
975
976     if [info exists et_vect_int_mult_saved] {
977         verbose "check_effective_target_vect_int_mult: using cached result" 2
978     } else {
979         set et_vect_int_mult_saved 0
980         if { [istarget powerpc*-*-*]
981              || [istarget i?86-*-*]
982              || [istarget x86_64-*-*] } {
983            set et_vect_int_mult_saved 1
984         }
985     }
986
987     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
988     return $et_vect_int_mult_saved
989 }
990
991 # Return 1 if the target supports atomic operations on "int" and "long".
992
993 proc check_effective_target_sync_int_long { } {
994     global et_sync_int_long_saved
995
996     if [info exists et_sync_int_long_saved] {
997         verbose "check_effective_target_sync_int_long: using cached result" 2
998     } else {
999         set et_sync_int_long_saved 0
1000 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1001 # load-reserved/store-conditional instructions.
1002         if { [istarget ia64-*-*]
1003              || [istarget i?86-*-*]
1004              || [istarget x86_64-*-*]
1005              || [istarget alpha*-*-*] 
1006              || [istarget s390*-*-*] 
1007              || [istarget powerpc*-*-*] } {
1008            set et_sync_int_long_saved 1
1009         }
1010     }
1011
1012     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1013     return $et_sync_int_long_saved
1014 }
1015
1016 # Return 1 if the target supports atomic operations on "char" and "short".
1017
1018 proc check_effective_target_sync_char_short { } {
1019     global et_sync_char_short_saved
1020
1021     if [info exists et_sync_char_short_saved] {
1022         verbose "check_effective_target_sync_char_short: using cached result" 2
1023     } else {
1024         set et_sync_char_short_saved 0
1025 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1026 # load-reserved/store-conditional instructions.
1027         if { [istarget ia64-*-*]
1028              || [istarget i?86-*-*]
1029              || [istarget x86_64-*-*]
1030              || [istarget powerpc*-*-*] } {
1031            set et_sync_char_short_saved 1
1032         }
1033     }
1034
1035     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1036     return $et_sync_char_short_saved
1037 }
1038
1039 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1040 # This can be used with any check_* proc that takes no argument and
1041 # returns only 1 or 0.  It could be used with check_* procs that take
1042 # arguments with keywords that pass particular arguments.
1043
1044 proc is-effective-target { arg } {
1045     set selected 0
1046     if { [info procs check_effective_target_${arg}] != [list] } {
1047         set selected [check_effective_target_${arg}]
1048     } else {
1049         switch $arg {
1050           "vmx_hw"         { set selected [check_vmx_hw_available] }
1051           "named_sections" { set selected [check_named_sections_available] }
1052           "gc_sections"    { set selected [check_gc_sections_available] }
1053           default          { error "unknown effective target keyword `$arg'" }
1054         }
1055     }
1056     verbose "is-effective-target: $arg $selected" 2
1057     return $selected
1058 }
1059
1060 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1061
1062 proc is-effective-target-keyword { arg } {
1063     if { [info procs check_effective_target_${arg}] != [list] } {
1064         return 1
1065     } else {
1066         # These have different names for their check_* procs.
1067         switch $arg {
1068           "vmx_hw"         { return 1 }
1069           "named_sections" { return 1 }
1070           "gc_sections"    { return 1 }
1071           default          { return 0 }
1072         }
1073     }
1074 }