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