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