]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/lib/target-supports.exp
Support non-masked epilogue vectoriziation
[thirdparty/gcc.git] / gcc / testsuite / lib / target-supports.exp
1 # Copyright (C) 1999-2016 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile the code given by CONTENTS into an output file of
23 # type TYPE, where TYPE is as for target_compile. Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the name of the output file.
26 #
27 # BASENAME is a prefix to use for source and output files.
28 # If ARGS is not empty, its first element is a string that
29 # should be added to the command line.
30 #
31 # Assume by default that CONTENTS is C code.
32 # Otherwise, code should contain:
33 # "// C++" for c++,
34 # "! Fortran" for Fortran code,
35 # "/* ObjC", for ObjC
36 # "// ObjC++" for ObjC++
37 # and "// Go" for Go
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
43
44 # Save additional_sources to avoid compiling testsuite's sources
45 # against check_compile's source.
46 global additional_sources
47 if [info exists additional_sources] {
48 set tmp_additional_sources "$additional_sources"
49 set additional_sources ""
50 }
51
52 if { [llength $args] > 0 } {
53 set options [list "additional_flags=[lindex $args 0]"]
54 } else {
55 set options ""
56 }
57 switch -glob -- $contents {
58 "*! Fortran*" { set src ${basename}[pid].f90 }
59 "*// C++*" { set src ${basename}[pid].cc }
60 "*// ObjC++*" { set src ${basename}[pid].mm }
61 "*/* ObjC*" { set src ${basename}[pid].m }
62 "*// Go*" { set src ${basename}[pid].go }
63 default {
64 switch -- $tool {
65 "objc" { set src ${basename}[pid].m }
66 "obj-c++" { set src ${basename}[pid].mm }
67 default { set src ${basename}[pid].c }
68 }
69 }
70 }
71
72 set compile_type $type
73 switch -glob $type {
74 assembly { set output ${basename}[pid].s }
75 object { set output ${basename}[pid].o }
76 executable { set output ${basename}[pid].exe }
77 "rtl-*" {
78 set output ${basename}[pid].s
79 lappend options "additional_flags=-fdump-$type"
80 set compile_type assembly
81 }
82 }
83 set f [open $src "w"]
84 puts $f $contents
85 close $f
86 set lines [${tool}_target_compile $src $output $compile_type "$options"]
87 file delete $src
88
89 set scan_output $output
90 # Don't try folding this into the switch above; calling "glob" before the
91 # file is created won't work.
92 if [regexp "rtl-(.*)" $type dummy rtl_type] {
93 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
94 file delete $output
95 }
96
97 # Restore additional_sources.
98 if [info exists additional_sources] {
99 set additional_sources "$tmp_additional_sources"
100 }
101
102 return [list $lines $scan_output]
103 }
104
105 proc current_target_name { } {
106 global target_info
107 if [info exists target_info(target,name)] {
108 set answer $target_info(target,name)
109 } else {
110 set answer ""
111 }
112 return $answer
113 }
114
115 # Implement an effective-target check for property PROP by invoking
116 # the Tcl command ARGS and seeing if it returns true.
117
118 proc check_cached_effective_target { prop args } {
119 global et_cache
120 global et_prop_list
121
122 set target [current_target_name]
123 if {![info exists et_cache($prop,target)]
124 || $et_cache($prop,target) != $target} {
125 verbose "check_cached_effective_target $prop: checking $target" 2
126 set et_cache($prop,target) $target
127 set et_cache($prop,value) [uplevel eval $args]
128 if {![info exists et_prop_list]
129 || [lsearch $et_prop_list $prop] < 0} {
130 lappend et_prop_list $prop
131 }
132 verbose "check_cached_effective_target cached list is now: $et_prop_list" 2
133 }
134 set value $et_cache($prop,value)
135 verbose "check_cached_effective_target $prop: returning $value for $target" 2
136 return $value
137 }
138
139 # Clear effective-target cache. This is useful after testing
140 # effective-target features and overriding TEST_ALWAYS_FLAGS and/or
141 # ALWAYS_CXXFLAGS.
142 # If one changes ALWAYS_CXXFLAGS or TEST_ALWAYS_FLAGS then they should
143 # do a clear_effective_target_cache at the end as the target cache can
144 # make decisions based upon the flags, and those decisions need to be
145 # redone when the flags change. An example of this is the
146 # asan_init/asan_finish pair.
147
148 proc clear_effective_target_cache { } {
149 global et_cache
150 global et_prop_list
151
152 if {[info exists et_prop_list]} {
153 verbose "clear_effective_target_cache: $et_prop_list" 2
154 foreach prop $et_prop_list {
155 unset et_cache($prop,value)
156 unset et_cache($prop,target)
157 }
158 unset et_prop_list
159 }
160 }
161
162 # Like check_compile, but delete the output file and return true if the
163 # compiler printed no messages.
164 proc check_no_compiler_messages_nocache {args} {
165 set result [eval check_compile $args]
166 set lines [lindex $result 0]
167 set output [lindex $result 1]
168 remote_file build delete $output
169 return [string match "" $lines]
170 }
171
172 # Like check_no_compiler_messages_nocache, but cache the result.
173 # PROP is the property we're checking, and doubles as a prefix for
174 # temporary filenames.
175 proc check_no_compiler_messages {prop args} {
176 return [check_cached_effective_target $prop {
177 eval [list check_no_compiler_messages_nocache $prop] $args
178 }]
179 }
180
181 # Like check_compile, but return true if the compiler printed no
182 # messages and if the contents of the output file satisfy PATTERN.
183 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
184 # don't match regular expression REGEXP, otherwise they satisfy it
185 # if they do match regular expression PATTERN. (PATTERN can start
186 # with something like "[!]" if the regular expression needs to match
187 # "!" as the first character.)
188 #
189 # Delete the output file before returning. The other arguments are
190 # as for check_compile.
191 proc check_no_messages_and_pattern_nocache {basename pattern args} {
192 global tool
193
194 set result [eval [list check_compile $basename] $args]
195 set lines [lindex $result 0]
196 set output [lindex $result 1]
197
198 set ok 0
199 if { [string match "" $lines] } {
200 set chan [open "$output"]
201 set invert [regexp {^!(.*)} $pattern dummy pattern]
202 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
203 close $chan
204 }
205
206 remote_file build delete $output
207 return $ok
208 }
209
210 # Like check_no_messages_and_pattern_nocache, but cache the result.
211 # PROP is the property we're checking, and doubles as a prefix for
212 # temporary filenames.
213 proc check_no_messages_and_pattern {prop pattern args} {
214 return [check_cached_effective_target $prop {
215 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
216 }]
217 }
218
219 # Try to compile and run an executable from code CONTENTS. Return true
220 # if the compiler reports no messages and if execution "passes" in the
221 # usual DejaGNU sense. The arguments are as for check_compile, with
222 # TYPE implicitly being "executable".
223 proc check_runtime_nocache {basename contents args} {
224 global tool
225
226 set result [eval [list check_compile $basename executable $contents] $args]
227 set lines [lindex $result 0]
228 set output [lindex $result 1]
229
230 set ok 0
231 if { [string match "" $lines] } {
232 # No error messages, everything is OK.
233 set result [remote_load target "./$output" "" ""]
234 set status [lindex $result 0]
235 verbose "check_runtime_nocache $basename: status is <$status>" 2
236 if { $status == "pass" } {
237 set ok 1
238 }
239 }
240 remote_file build delete $output
241 return $ok
242 }
243
244 # Like check_runtime_nocache, but cache the result. PROP is the
245 # property we're checking, and doubles as a prefix for temporary
246 # filenames.
247 proc check_runtime {prop args} {
248 global tool
249
250 return [check_cached_effective_target $prop {
251 eval [list check_runtime_nocache $prop] $args
252 }]
253 }
254
255 ###############################
256 # proc check_weak_available { }
257 ###############################
258
259 # weak symbols are only supported in some configs/object formats
260 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
261
262 proc check_weak_available { } {
263 global target_cpu
264
265 # All mips targets should support it
266
267 if { [ string first "mips" $target_cpu ] >= 0 } {
268 return 1
269 }
270
271 # All AIX targets should support it
272
273 if { [istarget *-*-aix*] } {
274 return 1
275 }
276
277 # All solaris2 targets should support it
278
279 if { [istarget *-*-solaris2*] } {
280 return 1
281 }
282
283 # Windows targets Cygwin and MingW32 support it
284
285 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
286 return 1
287 }
288
289 # HP-UX 10.X doesn't support it
290
291 if { [istarget hppa*-*-hpux10*] } {
292 return 0
293 }
294
295 # nvptx (nearly) supports it
296
297 if { [istarget nvptx-*-*] } {
298 return 1
299 }
300
301 # ELF and ECOFF support it. a.out does with gas/gld but may also with
302 # other linkers, so we should try it
303
304 set objformat [gcc_target_object_format]
305
306 switch $objformat {
307 elf { return 1 }
308 ecoff { return 1 }
309 a.out { return 1 }
310 mach-o { return 1 }
311 som { return 1 }
312 unknown { return -1 }
313 default { return 0 }
314 }
315 }
316
317 ###############################
318 # proc check_weak_override_available { }
319 ###############################
320
321 # Like check_weak_available, but return 0 if weak symbol definitions
322 # cannot be overridden.
323
324 proc check_weak_override_available { } {
325 if { [istarget *-*-mingw*] } {
326 return 0
327 }
328 return [check_weak_available]
329 }
330
331 ###############################
332 # proc check_visibility_available { what_kind }
333 ###############################
334
335 # The visibility attribute is only support in some object formats
336 # This proc returns 1 if it is supported, 0 if not.
337 # The argument is the kind of visibility, default/protected/hidden/internal.
338
339 proc check_visibility_available { what_kind } {
340 if [string match "" $what_kind] { set what_kind "hidden" }
341
342 return [check_no_compiler_messages visibility_available_$what_kind object "
343 void f() __attribute__((visibility(\"$what_kind\")));
344 void f() {}
345 "]
346 }
347
348 ###############################
349 # proc check_alias_available { }
350 ###############################
351
352 # Determine if the target toolchain supports the alias attribute.
353
354 # Returns 2 if the target supports aliases. Returns 1 if the target
355 # only supports weak aliased. Returns 0 if the target does not
356 # support aliases at all. Returns -1 if support for aliases could not
357 # be determined.
358
359 proc check_alias_available { } {
360 global alias_available_saved
361 global tool
362
363 if [info exists alias_available_saved] {
364 verbose "check_alias_available returning saved $alias_available_saved" 2
365 } else {
366 set src alias[pid].c
367 set obj alias[pid].o
368 verbose "check_alias_available compiling testfile $src" 2
369 set f [open $src "w"]
370 # Compile a small test program. The definition of "g" is
371 # necessary to keep the Solaris assembler from complaining
372 # about the program.
373 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
374 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
375 close $f
376 set lines [${tool}_target_compile $src $obj object ""]
377 file delete $src
378 remote_file build delete $obj
379
380 if [string match "" $lines] then {
381 # No error messages, everything is OK.
382 set alias_available_saved 2
383 } else {
384 if [regexp "alias definitions not supported" $lines] {
385 verbose "check_alias_available target does not support aliases" 2
386
387 set objformat [gcc_target_object_format]
388
389 if { $objformat == "elf" } {
390 verbose "check_alias_available but target uses ELF format, so it ought to" 2
391 set alias_available_saved -1
392 } else {
393 set alias_available_saved 0
394 }
395 } else {
396 if [regexp "only weak aliases are supported" $lines] {
397 verbose "check_alias_available target supports only weak aliases" 2
398 set alias_available_saved 1
399 } else {
400 set alias_available_saved -1
401 }
402 }
403 }
404
405 verbose "check_alias_available returning $alias_available_saved" 2
406 }
407
408 return $alias_available_saved
409 }
410
411 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
412
413 proc check_effective_target_alias { } {
414 if { [check_alias_available] < 2 } {
415 return 0
416 } else {
417 return 1
418 }
419 }
420
421 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
422
423 proc check_ifunc_available { } {
424 return [check_no_compiler_messages ifunc_available object {
425 #ifdef __cplusplus
426 extern "C"
427 #endif
428 void g() {}
429 void f() __attribute__((ifunc("g")));
430 }]
431 }
432
433 # Returns true if --gc-sections is supported on the target.
434
435 proc check_gc_sections_available { } {
436 global gc_sections_available_saved
437 global tool
438
439 if {![info exists gc_sections_available_saved]} {
440 # Some targets don't support gc-sections despite whatever's
441 # advertised by ld's options.
442 if { [istarget alpha*-*-*]
443 || [istarget ia64-*-*] } {
444 set gc_sections_available_saved 0
445 return 0
446 }
447
448 # elf2flt uses -q (--emit-relocs), which is incompatible with
449 # --gc-sections.
450 if { [board_info target exists ldflags]
451 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
452 set gc_sections_available_saved 0
453 return 0
454 }
455
456 # VxWorks kernel modules are relocatable objects linked with -r,
457 # while RTP executables are linked with -q (--emit-relocs).
458 # Both of these options are incompatible with --gc-sections.
459 if { [istarget *-*-vxworks*] } {
460 set gc_sections_available_saved 0
461 return 0
462 }
463
464 # Check if the ld used by gcc supports --gc-sections.
465 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
466 set ld_output [remote_exec host "$gcc_ld" "--help"]
467 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
468 set gc_sections_available_saved 1
469 } else {
470 set gc_sections_available_saved 0
471 }
472 }
473 return $gc_sections_available_saved
474 }
475
476 # Return 1 if according to target_info struct and explicit target list
477 # target is supposed to support trampolines.
478
479 proc check_effective_target_trampolines { } {
480 if [target_info exists no_trampolines] {
481 return 0
482 }
483 if { [istarget avr-*-*]
484 || [istarget msp430-*-*]
485 || [istarget nvptx-*-*]
486 || [istarget hppa2.0w-hp-hpux11.23]
487 || [istarget hppa64-hp-hpux11.23] } {
488 return 0;
489 }
490 return 1
491 }
492
493 # Return 1 if according to target_info struct and explicit target list
494 # target disables -fdelete-null-pointer-checks. Targets should return 0
495 # if they simply default to -fno-delete-null-pointer-checks but obey
496 # -fdelete-null-pointer-checks when passed explicitly (and tests that
497 # depend on this option should do that).
498
499 proc check_effective_target_keeps_null_pointer_checks { } {
500 if [target_info exists keeps_null_pointer_checks] {
501 return 1
502 }
503 if { [istarget avr-*-*] } {
504 return 1;
505 }
506 return 0
507 }
508
509 # Return the autofdo profile wrapper
510
511 proc profopt-perf-wrapper { } {
512 global srcdir
513 return "$srcdir/../config/i386/gcc-auto-profile -o perf.data "
514 }
515
516 # Return true if profiling is supported on the target.
517
518 proc check_profiling_available { test_what } {
519 global profiling_available_saved
520
521 verbose "Profiling argument is <$test_what>" 1
522
523 # These conditions depend on the argument so examine them before
524 # looking at the cache variable.
525
526 # Tree profiling requires TLS runtime support.
527 if { $test_what == "-fprofile-generate" } {
528 if { ![check_effective_target_tls_runtime] } {
529 return 0
530 }
531 }
532
533 if { $test_what == "-fauto-profile" } {
534 if { !([istarget i?86-*-linux*] || [istarget x86_64-*-linux*]) } {
535 verbose "autofdo only supported on linux"
536 return 0
537 }
538 # not cross compiling?
539 if { ![isnative] } {
540 verbose "autofdo not supported for non native builds"
541 return 0
542 }
543 set event [profopt-perf-wrapper]
544 if {$event == "" } {
545 verbose "autofdo not supported"
546 return 0
547 }
548 global srcdir
549 set status [remote_exec host "$srcdir/../config/i386/gcc-auto-profile" "true -v >/dev/null"]
550 if { [lindex $status 0] != 0 } {
551 verbose "autofdo not supported because perf does not work"
552 return 0
553 }
554
555 # no good way to check this in advance -- check later instead.
556 #set status [remote_exec host "create_gcov" "2>/dev/null"]
557 #if { [lindex $status 0] != 255 } {
558 # verbose "autofdo not supported due to missing create_gcov"
559 # return 0
560 #}
561 }
562
563 # Support for -p on solaris2 relies on mcrt1.o which comes with the
564 # vendor compiler. We cannot reliably predict the directory where the
565 # vendor compiler (and thus mcrt1.o) is installed so we can't
566 # necessarily find mcrt1.o even if we have it.
567 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
568 return 0
569 }
570
571 # We don't yet support profiling for MIPS16.
572 if { [istarget mips*-*-*]
573 && ![check_effective_target_nomips16]
574 && ($test_what == "-p" || $test_what == "-pg") } {
575 return 0
576 }
577
578 # MinGW does not support -p.
579 if { [istarget *-*-mingw*] && $test_what == "-p" } {
580 return 0
581 }
582
583 # cygwin does not support -p.
584 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
585 return 0
586 }
587
588 # uClibc does not have gcrt1.o.
589 if { [check_effective_target_uclibc]
590 && ($test_what == "-p" || $test_what == "-pg") } {
591 return 0
592 }
593
594 # Now examine the cache variable.
595 if {![info exists profiling_available_saved]} {
596 # Some targets don't have any implementation of __bb_init_func or are
597 # missing other needed machinery.
598 if {[istarget aarch64*-*-elf]
599 || [istarget am3*-*-linux*]
600 || [istarget arm*-*-eabi*]
601 || [istarget arm*-*-elf]
602 || [istarget arm*-*-symbianelf*]
603 || [istarget avr-*-*]
604 || [istarget bfin-*-*]
605 || [istarget cris-*-*]
606 || [istarget crisv32-*-*]
607 || [istarget fido-*-elf]
608 || [istarget h8300-*-*]
609 || [istarget lm32-*-*]
610 || [istarget m32c-*-elf]
611 || [istarget m68k-*-elf]
612 || [istarget m68k-*-uclinux*]
613 || [istarget mips*-*-elf*]
614 || [istarget mmix-*-*]
615 || [istarget mn10300-*-elf*]
616 || [istarget moxie-*-elf*]
617 || [istarget msp430-*-*]
618 || [istarget nds32*-*-elf]
619 || [istarget nios2-*-elf]
620 || [istarget nvptx-*-*]
621 || [istarget powerpc-*-eabi*]
622 || [istarget powerpc-*-elf]
623 || [istarget rx-*-*]
624 || [istarget tic6x-*-elf]
625 || [istarget visium-*-*]
626 || [istarget xstormy16-*]
627 || [istarget xtensa*-*-elf]
628 || [istarget *-*-rtems*]
629 || [istarget *-*-vxworks*] } {
630 set profiling_available_saved 0
631 } else {
632 set profiling_available_saved 1
633 }
634 }
635
636 # -pg link test result can't be cached since it may change between
637 # runs.
638 set profiling_working $profiling_available_saved
639 if { $profiling_available_saved == 1
640 && ![check_no_compiler_messages_nocache profiling executable {
641 int main() { return 0; } } "-pg"] } {
642 set profiling_working 0
643 }
644
645 return $profiling_working
646 }
647
648 # Check to see if a target is "freestanding". This is as per the definition
649 # in Section 4 of C99 standard. Effectively, it is a target which supports no
650 # extra headers or libraries other than what is considered essential.
651 proc check_effective_target_freestanding { } {
652 if { [istarget nvptx-*-*] } {
653 return 1
654 }
655 return 0
656 }
657
658 # Return 1 if target has packed layout of structure members by
659 # default, 0 otherwise. Note that this is slightly different than
660 # whether the target has "natural alignment": both attributes may be
661 # false.
662
663 proc check_effective_target_default_packed { } {
664 return [check_no_compiler_messages default_packed assembly {
665 struct x { char a; long b; } c;
666 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
667 }]
668 }
669
670 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
671 # documentation, where the test also comes from.
672
673 proc check_effective_target_pcc_bitfield_type_matters { } {
674 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
675 # bitfields, but let's stick to the example code from the docs.
676 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
677 struct foo1 { char x; char :0; char y; };
678 struct foo2 { char x; int :0; char y; };
679 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
680 }]
681 }
682
683 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
684
685 proc add_options_for_tls { flags } {
686 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
687 # libthread, so always pass -pthread for native TLS. Same for AIX.
688 # Need to duplicate native TLS check from
689 # check_effective_target_tls_native to avoid recursion.
690 if { ([istarget powerpc-ibm-aix*]) &&
691 [check_no_messages_and_pattern tls_native "!emutls" assembly {
692 __thread int i;
693 int f (void) { return i; }
694 void g (int j) { i = j; }
695 }] } {
696 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
697 }
698 return $flags
699 }
700
701 # Return 1 if indirect jumps are supported, 0 otherwise.
702
703 proc check_effective_target_indirect_jumps {} {
704 if { [istarget nvptx-*-*] } {
705 return 0
706 }
707 return 1
708 }
709
710 # Return 1 if nonlocal goto is supported, 0 otherwise.
711
712 proc check_effective_target_nonlocal_goto {} {
713 if { [istarget nvptx-*-*] } {
714 return 0
715 }
716 return 1
717 }
718
719 # Return 1 if global constructors are supported, 0 otherwise.
720
721 proc check_effective_target_global_constructor {} {
722 if { [istarget nvptx-*-*] } {
723 return 0
724 }
725 return 1
726 }
727
728 # Return 1 if taking label values is supported, 0 otherwise.
729
730 proc check_effective_target_label_values {} {
731 if { [istarget nvptx-*-*] } {
732 return 0
733 }
734 return [check_no_compiler_messages label_values assembly {
735 #ifdef NO_LABEL_VALUES
736 #error NO
737 #endif
738 }]
739 }
740
741 # Return 1 if builtin_return_address and builtin_frame_address are
742 # supported, 0 otherwise.
743
744 proc check_effective_target_return_address {} {
745 if { [istarget nvptx-*-*] } {
746 return 0
747 }
748 return 1
749 }
750
751 # Return 1 if the assembler does not verify function types against
752 # calls, 0 otherwise. Such verification will typically show up problems
753 # with K&R C function declarations.
754
755 proc check_effective_target_untyped_assembly {} {
756 if { [istarget nvptx-*-*] } {
757 return 0
758 }
759 return 1
760 }
761
762 # Return 1 if alloca is supported, 0 otherwise.
763
764 proc check_effective_target_alloca {} {
765 if { [istarget nvptx-*-*] } {
766 return 0
767 }
768 return 1
769 }
770
771 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
772
773 proc check_effective_target_tls {} {
774 return [check_no_compiler_messages tls assembly {
775 __thread int i;
776 int f (void) { return i; }
777 void g (int j) { i = j; }
778 }]
779 }
780
781 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
782
783 proc check_effective_target_tls_native {} {
784 # VxWorks uses emulated TLS machinery, but with non-standard helper
785 # functions, so we fail to automatically detect it.
786 if { [istarget *-*-vxworks*] } {
787 return 0
788 }
789
790 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
791 __thread int i;
792 int f (void) { return i; }
793 void g (int j) { i = j; }
794 }]
795 }
796
797 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
798
799 proc check_effective_target_tls_emulated {} {
800 # VxWorks uses emulated TLS machinery, but with non-standard helper
801 # functions, so we fail to automatically detect it.
802 if { [istarget *-*-vxworks*] } {
803 return 1
804 }
805
806 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
807 __thread int i;
808 int f (void) { return i; }
809 void g (int j) { i = j; }
810 }]
811 }
812
813 # Return 1 if TLS executables can run correctly, 0 otherwise.
814
815 proc check_effective_target_tls_runtime {} {
816 # The runtime does not have TLS support, but just
817 # running the test below is insufficient to show this.
818 if { [istarget msp430-*-*] || [istarget visium-*-*] } {
819 return 0
820 }
821 return [check_runtime tls_runtime {
822 __thread int thr = 0;
823 int main (void) { return thr; }
824 } [add_options_for_tls ""]]
825 }
826
827 # Return 1 if atomic compare-and-swap is supported on 'int'
828
829 proc check_effective_target_cas_char {} {
830 return [check_no_compiler_messages cas_char assembly {
831 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
832 #error unsupported
833 #endif
834 } ""]
835 }
836
837 proc check_effective_target_cas_int {} {
838 return [check_no_compiler_messages cas_int assembly {
839 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
840 /* ok */
841 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
842 /* ok */
843 #else
844 #error unsupported
845 #endif
846 } ""]
847 }
848
849 # Return 1 if -ffunction-sections is supported, 0 otherwise.
850
851 proc check_effective_target_function_sections {} {
852 # Darwin has its own scheme and silently accepts -ffunction-sections.
853 if { [istarget *-*-darwin*] } {
854 return 0
855 }
856
857 return [check_no_compiler_messages functionsections assembly {
858 void foo (void) { }
859 } "-ffunction-sections"]
860 }
861
862 # Return 1 if instruction scheduling is available, 0 otherwise.
863
864 proc check_effective_target_scheduling {} {
865 return [check_no_compiler_messages scheduling object {
866 void foo (void) { }
867 } "-fschedule-insns"]
868 }
869
870 # Return 1 if trapping arithmetic is available, 0 otherwise.
871
872 proc check_effective_target_trapping {} {
873 return [check_no_compiler_messages trapping object {
874 int add (int a, int b) { return a + b; }
875 } "-ftrapv"]
876 }
877
878 # Return 1 if compilation with -fgraphite is error-free for trivial
879 # code, 0 otherwise.
880
881 proc check_effective_target_fgraphite {} {
882 return [check_no_compiler_messages fgraphite object {
883 void foo (void) { }
884 } "-O1 -fgraphite"]
885 }
886
887 # Return 1 if compilation with -fopenacc is error-free for trivial
888 # code, 0 otherwise.
889
890 proc check_effective_target_fopenacc {} {
891 # nvptx can be built with the device-side bits of openacc, but it
892 # does not make sense to test it as an openacc host.
893 if [istarget nvptx-*-*] { return 0 }
894
895 return [check_no_compiler_messages fopenacc object {
896 void foo (void) { }
897 } "-fopenacc"]
898 }
899
900 # Return 1 if compilation with -fopenmp is error-free for trivial
901 # code, 0 otherwise.
902
903 proc check_effective_target_fopenmp {} {
904 # nvptx can be built with the device-side bits of libgomp, but it
905 # does not make sense to test it as an openmp host.
906 if [istarget nvptx-*-*] { return 0 }
907
908 return [check_no_compiler_messages fopenmp object {
909 void foo (void) { }
910 } "-fopenmp"]
911 }
912
913 # Return 1 if compilation with -fgnu-tm is error-free for trivial
914 # code, 0 otherwise.
915
916 proc check_effective_target_fgnu_tm {} {
917 return [check_no_compiler_messages fgnu_tm object {
918 void foo (void) { }
919 } "-fgnu-tm"]
920 }
921
922 # Return 1 if the target supports mmap, 0 otherwise.
923
924 proc check_effective_target_mmap {} {
925 return [check_function_available "mmap"]
926 }
927
928 # Return 1 if the target supports dlopen, 0 otherwise.
929 proc check_effective_target_dlopen {} {
930 return [check_no_compiler_messages dlopen executable {
931 #include <dlfcn.h>
932 int main(void) { dlopen ("dummy.so", RTLD_NOW); }
933 } [add_options_for_dlopen ""]]
934 }
935
936 proc add_options_for_dlopen { flags } {
937 return "$flags -ldl"
938 }
939
940 # Return 1 if the target supports clone, 0 otherwise.
941 proc check_effective_target_clone {} {
942 return [check_function_available "clone"]
943 }
944
945 # Return 1 if the target supports setrlimit, 0 otherwise.
946 proc check_effective_target_setrlimit {} {
947 # Darwin has non-posix compliant RLIMIT_AS
948 if { [istarget *-*-darwin*] } {
949 return 0
950 }
951 return [check_function_available "setrlimit"]
952 }
953
954 # Return 1 if the target supports swapcontext, 0 otherwise.
955 proc check_effective_target_swapcontext {} {
956 return [check_no_compiler_messages swapcontext executable {
957 #include <ucontext.h>
958 int main (void)
959 {
960 ucontext_t orig_context,child_context;
961 if (swapcontext(&child_context, &orig_context) < 0) { }
962 }
963 }]
964 }
965
966 # Return 1 if compilation with -pthread is error-free for trivial
967 # code, 0 otherwise.
968
969 proc check_effective_target_pthread {} {
970 return [check_no_compiler_messages pthread object {
971 void foo (void) { }
972 } "-pthread"]
973 }
974
975 # Return 1 if compilation with -gstabs is error-free for trivial
976 # code, 0 otherwise.
977
978 proc check_effective_target_stabs {} {
979 return [check_no_compiler_messages stabs object {
980 void foo (void) { }
981 } "-gstabs"]
982 }
983
984 # Return 1 if compilation with -mpe-aligned-commons is error-free
985 # for trivial code, 0 otherwise.
986
987 proc check_effective_target_pe_aligned_commons {} {
988 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
989 return [check_no_compiler_messages pe_aligned_commons object {
990 int foo;
991 } "-mpe-aligned-commons"]
992 }
993 return 0
994 }
995
996 # Return 1 if the target supports -static
997 proc check_effective_target_static {} {
998 return [check_no_compiler_messages static executable {
999 int main (void) { return 0; }
1000 } "-static"]
1001 }
1002
1003 # Return 1 if the target supports -fstack-protector
1004 proc check_effective_target_fstack_protector {} {
1005 return [check_runtime fstack_protector {
1006 int main (void) { return 0; }
1007 } "-fstack-protector"]
1008 }
1009
1010 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
1011 # for trivial code, 0 otherwise.
1012
1013 proc check_effective_target_freorder {} {
1014 return [check_no_compiler_messages freorder object {
1015 void foo (void) { }
1016 } "-freorder-blocks-and-partition"]
1017 }
1018
1019 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
1020 # emitted, 0 otherwise. Whether a shared library can actually be built is
1021 # out of scope for this test.
1022
1023 proc check_effective_target_fpic { } {
1024 # Note that M68K has a multilib that supports -fpic but not
1025 # -fPIC, so we need to check both. We test with a program that
1026 # requires GOT references.
1027 foreach arg {fpic fPIC} {
1028 if [check_no_compiler_messages $arg object {
1029 extern int foo (void); extern int bar;
1030 int baz (void) { return foo () + bar; }
1031 } "-$arg"] {
1032 return 1
1033 }
1034 }
1035 return 0
1036 }
1037
1038 # On AArch64, if -fpic is not supported, then we will fall back to -fPIC
1039 # silently. So, we can't rely on above "check_effective_target_fpic" as it
1040 # assumes compiler will give warning if -fpic not supported. Here we check
1041 # whether binutils supports those new -fpic relocation modifiers, and assume
1042 # -fpic is supported if there is binutils support. GCC configuration will
1043 # enable -fpic for AArch64 in this case.
1044 #
1045 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
1046 # memory model -fpic relocation types.
1047
1048 proc check_effective_target_aarch64_small_fpic { } {
1049 if { [istarget aarch64*-*-*] } {
1050 return [check_no_compiler_messages aarch64_small_fpic object {
1051 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
1052 }]
1053 } else {
1054 return 0
1055 }
1056 }
1057
1058 # On AArch64, instruction sequence for TLS LE under -mtls-size=32 will utilize
1059 # the relocation modifier "tprel_g0_nc" together with MOVK, it's only supported
1060 # in binutils since 2015-03-04 as PR gas/17843.
1061 #
1062 # This test directive make sure binutils support all features needed by TLS LE
1063 # under -mtls-size=32 on AArch64.
1064
1065 proc check_effective_target_aarch64_tlsle32 { } {
1066 if { [istarget aarch64*-*-*] } {
1067 return [check_no_compiler_messages aarch64_tlsle32 object {
1068 void foo (void) { asm ("movk x1,#:tprel_g0_nc:t1"); }
1069 }]
1070 } else {
1071 return 0
1072 }
1073 }
1074
1075 # Return 1 if -shared is supported, as in no warnings or errors
1076 # emitted, 0 otherwise.
1077
1078 proc check_effective_target_shared { } {
1079 # Note that M68K has a multilib that supports -fpic but not
1080 # -fPIC, so we need to check both. We test with a program that
1081 # requires GOT references.
1082 return [check_no_compiler_messages shared executable {
1083 extern int foo (void); extern int bar;
1084 int baz (void) { return foo () + bar; }
1085 } "-shared -fpic"]
1086 }
1087
1088 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
1089
1090 proc check_effective_target_pie { } {
1091 if { [istarget *-*-darwin\[912\]*]
1092 || [istarget *-*-dragonfly*]
1093 || [istarget *-*-freebsd*]
1094 || [istarget *-*-linux*]
1095 || [istarget *-*-gnu*] } {
1096 return 1;
1097 }
1098 if { [istarget *-*-solaris2.1\[1-9\]*] } {
1099 # Full PIE support was added in Solaris 11.x and Solaris 12, but gcc
1100 # errors out if missing, so check for that.
1101 return [check_no_compiler_messages pie executable {
1102 int main (void) { return 0; }
1103 } "-pie -fpie"]
1104 }
1105 return 0
1106 }
1107
1108 # Return true if the target supports -mpaired-single (as used on MIPS).
1109
1110 proc check_effective_target_mpaired_single { } {
1111 return [check_no_compiler_messages mpaired_single object {
1112 void foo (void) { }
1113 } "-mpaired-single"]
1114 }
1115
1116 # Return true if the target has access to FPU instructions.
1117
1118 proc check_effective_target_hard_float { } {
1119 if { [istarget mips*-*-*] } {
1120 return [check_no_compiler_messages hard_float assembly {
1121 #if (defined __mips_soft_float || defined __mips16)
1122 #error __mips_soft_float || __mips16
1123 #endif
1124 }]
1125 }
1126
1127 # This proc is actually checking the availabilty of FPU
1128 # support for doubles, so on the RX we must fail if the
1129 # 64-bit double multilib has been selected.
1130 if { [istarget rx-*-*] } {
1131 return 0
1132 # return [check_no_compiler_messages hard_float assembly {
1133 #if defined __RX_64_BIT_DOUBLES__
1134 #error __RX_64_BIT_DOUBLES__
1135 #endif
1136 # }]
1137 }
1138
1139 # The generic test equates hard_float with "no call for adding doubles".
1140 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1141 double a (double b, double c) { return b + c; }
1142 }]
1143 }
1144
1145 # Return true if the target is a 64-bit MIPS target.
1146
1147 proc check_effective_target_mips64 { } {
1148 return [check_no_compiler_messages mips64 assembly {
1149 #ifndef __mips64
1150 #error !__mips64
1151 #endif
1152 }]
1153 }
1154
1155 # Return true if the target is a MIPS target that does not produce
1156 # MIPS16 code.
1157
1158 proc check_effective_target_nomips16 { } {
1159 return [check_no_compiler_messages nomips16 object {
1160 #ifndef __mips
1161 #error !__mips
1162 #else
1163 /* A cheap way of testing for -mflip-mips16. */
1164 void foo (void) { asm ("addiu $20,$20,1"); }
1165 void bar (void) { asm ("addiu $20,$20,1"); }
1166 #endif
1167 }]
1168 }
1169
1170 # Add the options needed for MIPS16 function attributes. At the moment,
1171 # we don't support MIPS16 PIC.
1172
1173 proc add_options_for_mips16_attribute { flags } {
1174 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1175 }
1176
1177 # Return true if we can force a mode that allows MIPS16 code generation.
1178 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
1179 # for o32 and o64.
1180
1181 proc check_effective_target_mips16_attribute { } {
1182 return [check_no_compiler_messages mips16_attribute assembly {
1183 #ifdef PIC
1184 #error PIC
1185 #endif
1186 #if defined __mips_hard_float \
1187 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1188 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1189 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1190 #endif
1191 } [add_options_for_mips16_attribute ""]]
1192 }
1193
1194 # Return 1 if the target supports long double larger than double when
1195 # using the new ABI, 0 otherwise.
1196
1197 proc check_effective_target_mips_newabi_large_long_double { } {
1198 return [check_no_compiler_messages mips_newabi_large_long_double object {
1199 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1200 } "-mabi=64"]
1201 }
1202
1203 # Return true if the target is a MIPS target that has access
1204 # to the LL and SC instructions.
1205
1206 proc check_effective_target_mips_llsc { } {
1207 if { ![istarget mips*-*-*] } {
1208 return 0
1209 }
1210 # Assume that these instructions are always implemented for
1211 # non-elf* targets, via emulation if necessary.
1212 if { ![istarget *-*-elf*] } {
1213 return 1
1214 }
1215 # Otherwise assume LL/SC support for everything but MIPS I.
1216 return [check_no_compiler_messages mips_llsc assembly {
1217 #if __mips == 1
1218 #error __mips == 1
1219 #endif
1220 }]
1221 }
1222
1223 # Return true if the target is a MIPS target that uses in-place relocations.
1224
1225 proc check_effective_target_mips_rel { } {
1226 if { ![istarget mips*-*-*] } {
1227 return 0
1228 }
1229 return [check_no_compiler_messages mips_rel object {
1230 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1231 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1232 #error _ABIN32 && (_ABIN32 || _ABI64)
1233 #endif
1234 }]
1235 }
1236
1237 # Return true if the target is a MIPS target that uses the EABI.
1238
1239 proc check_effective_target_mips_eabi { } {
1240 if { ![istarget mips*-*-*] } {
1241 return 0
1242 }
1243 return [check_no_compiler_messages mips_eabi object {
1244 #ifndef __mips_eabi
1245 #error !__mips_eabi
1246 #endif
1247 }]
1248 }
1249
1250 # Return 1 if the current multilib does not generate PIC by default.
1251
1252 proc check_effective_target_nonpic { } {
1253 return [check_no_compiler_messages nonpic assembly {
1254 #if __PIC__
1255 #error __PIC__
1256 #endif
1257 }]
1258 }
1259
1260 # Return 1 if the current multilib generates PIE by default.
1261
1262 proc check_effective_target_pie_enabled { } {
1263 return [check_no_compiler_messages pie_enabled assembly {
1264 #ifndef __PIE__
1265 #error unsupported
1266 #endif
1267 }]
1268 }
1269
1270 # Return 1 if the target generates -fstack-protector by default.
1271
1272 proc check_effective_target_fstack_protector_enabled {} {
1273 return [ check_no_compiler_messages fstack_protector_enabled assembly {
1274 #if !defined(__SSP__) && !defined(__SSP_ALL__) && \
1275 !defined(__SSP_STRONG__) && !defined(__SSP_EXPICIT__)
1276 #error unsupported
1277 #endif
1278 }]
1279 }
1280
1281 # Return 1 if the target does not use a status wrapper.
1282
1283 proc check_effective_target_unwrapped { } {
1284 if { [target_info needs_status_wrapper] != "" \
1285 && [target_info needs_status_wrapper] != "0" } {
1286 return 0
1287 }
1288 return 1
1289 }
1290
1291 # Return true if iconv is supported on the target. In particular IBM1047.
1292
1293 proc check_iconv_available { test_what } {
1294 global libiconv
1295
1296 # If the tool configuration file has not set libiconv, try "-liconv"
1297 if { ![info exists libiconv] } {
1298 set libiconv "-liconv"
1299 }
1300 set test_what [lindex $test_what 1]
1301 return [check_runtime_nocache $test_what [subst {
1302 #include <iconv.h>
1303 int main (void)
1304 {
1305 iconv_t cd;
1306
1307 cd = iconv_open ("$test_what", "UTF-8");
1308 if (cd == (iconv_t) -1)
1309 return 1;
1310 return 0;
1311 }
1312 }] $libiconv]
1313 }
1314
1315 # Return true if Cilk Library is supported on the target.
1316 proc check_effective_target_cilkplus_runtime { } {
1317 return [ check_no_compiler_messages_nocache cilkplus_runtime executable {
1318 #ifdef __cplusplus
1319 extern "C"
1320 #endif
1321 int __cilkrts_set_param (const char *, const char *);
1322 int main (void) {
1323 int x = __cilkrts_set_param ("nworkers", "0");
1324 return x;
1325 }
1326 } "-fcilkplus -lcilkrts" ]
1327 }
1328
1329 # Return true if the atomic library is supported on the target.
1330 proc check_effective_target_libatomic_available { } {
1331 return [check_no_compiler_messages libatomic_available executable {
1332 int main (void) { return 0; }
1333 } "-latomic"]
1334 }
1335
1336 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1337
1338 proc check_ascii_locale_available { } {
1339 return 1
1340 }
1341
1342 # Return true if named sections are supported on this target.
1343
1344 proc check_named_sections_available { } {
1345 return [check_no_compiler_messages named_sections assembly {
1346 int __attribute__ ((section("whatever"))) foo;
1347 }]
1348 }
1349
1350 # Return true if the "naked" function attribute is supported on this target.
1351
1352 proc check_effective_target_naked_functions { } {
1353 return [check_no_compiler_messages naked_functions assembly {
1354 void f() __attribute__((naked));
1355 }]
1356 }
1357
1358 # Return 1 if the target supports Fortran real kinds larger than real(8),
1359 # 0 otherwise.
1360 #
1361 # When the target name changes, replace the cached result.
1362
1363 proc check_effective_target_fortran_large_real { } {
1364 return [check_no_compiler_messages fortran_large_real executable {
1365 ! Fortran
1366 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1367 real(kind=k) :: x
1368 x = cos (x)
1369 end
1370 }]
1371 }
1372
1373 # Return 1 if the target supports Fortran real kind real(16),
1374 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1375 # this checks for Real(16) only; the other returned real(10) if
1376 # both real(10) and real(16) are available.
1377 #
1378 # When the target name changes, replace the cached result.
1379
1380 proc check_effective_target_fortran_real_16 { } {
1381 return [check_no_compiler_messages fortran_real_16 executable {
1382 ! Fortran
1383 real(kind=16) :: x
1384 x = cos (x)
1385 end
1386 }]
1387 }
1388
1389
1390 # Return 1 if the target supports Fortran's IEEE modules,
1391 # 0 otherwise.
1392 #
1393 # When the target name changes, replace the cached result.
1394
1395 proc check_effective_target_fortran_ieee { flags } {
1396 return [check_no_compiler_messages fortran_ieee executable {
1397 ! Fortran
1398 use, intrinsic :: ieee_features
1399 end
1400 } $flags ]
1401 }
1402
1403
1404 # Return 1 if the target supports SQRT for the largest floating-point
1405 # type. (Some targets lack the libm support for this FP type.)
1406 # On most targets, this check effectively checks either whether sqrtl is
1407 # available or on __float128 systems whether libquadmath is installed,
1408 # which provides sqrtq.
1409 #
1410 # When the target name changes, replace the cached result.
1411
1412 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1413 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1414 ! Fortran
1415 use iso_fortran_env, only: real_kinds
1416 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1417 real(kind=maxFP), volatile :: x
1418 x = 2.0_maxFP
1419 x = sqrt (x)
1420 end
1421 }]
1422 }
1423
1424
1425 # Return 1 if the target supports Fortran integer kinds larger than
1426 # integer(8), 0 otherwise.
1427 #
1428 # When the target name changes, replace the cached result.
1429
1430 proc check_effective_target_fortran_large_int { } {
1431 return [check_no_compiler_messages fortran_large_int executable {
1432 ! Fortran
1433 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1434 integer(kind=k) :: i
1435 end
1436 }]
1437 }
1438
1439 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1440 #
1441 # When the target name changes, replace the cached result.
1442
1443 proc check_effective_target_fortran_integer_16 { } {
1444 return [check_no_compiler_messages fortran_integer_16 executable {
1445 ! Fortran
1446 integer(16) :: i
1447 end
1448 }]
1449 }
1450
1451 # Return 1 if we can statically link libgfortran, 0 otherwise.
1452 #
1453 # When the target name changes, replace the cached result.
1454
1455 proc check_effective_target_static_libgfortran { } {
1456 return [check_no_compiler_messages static_libgfortran executable {
1457 ! Fortran
1458 print *, 'test'
1459 end
1460 } "-static"]
1461 }
1462
1463 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1464
1465 proc check_effective_target_cilkplus { } {
1466 # Skip cilk-plus tests on int16 and size16 targets for now.
1467 # The cilk-plus tests are not generic enough to cover these
1468 # cases and would throw hundreds of FAILs.
1469 if { [check_effective_target_int16]
1470 || ![check_effective_target_size32plus] } {
1471 return 0;
1472 }
1473
1474 # Skip AVR, its RAM is too small and too many tests would fail.
1475 if { [istarget avr-*-*] } {
1476 return 0;
1477 }
1478
1479 if { ! [check_effective_target_pthread] } {
1480 return 0;
1481 }
1482
1483 return 1
1484 }
1485
1486 proc check_linker_plugin_available { } {
1487 return [check_no_compiler_messages_nocache linker_plugin executable {
1488 int main() { return 0; }
1489 } "-flto -fuse-linker-plugin"]
1490 }
1491
1492 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1493 # otherwise. Cache the result.
1494
1495 proc check_750cl_hw_available { } {
1496 return [check_cached_effective_target 750cl_hw_available {
1497 # If this is not the right target then we can skip the test.
1498 if { ![istarget powerpc-*paired*] } {
1499 expr 0
1500 } else {
1501 check_runtime_nocache 750cl_hw_available {
1502 int main()
1503 {
1504 #ifdef __MACH__
1505 asm volatile ("ps_mul v0,v0,v0");
1506 #else
1507 asm volatile ("ps_mul 0,0,0");
1508 #endif
1509 return 0;
1510 }
1511 } "-mpaired"
1512 }
1513 }]
1514 }
1515
1516 # Return 1 if the target OS supports running SSE executables, 0
1517 # otherwise. Cache the result.
1518
1519 proc check_sse_os_support_available { } {
1520 return [check_cached_effective_target sse_os_support_available {
1521 # If this is not the right target then we can skip the test.
1522 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1523 expr 0
1524 } elseif { [istarget i?86-*-solaris2*] } {
1525 # The Solaris 2 kernel doesn't save and restore SSE registers
1526 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1527 check_runtime_nocache sse_os_support_available {
1528 int main ()
1529 {
1530 asm volatile ("movaps %xmm0,%xmm0");
1531 return 0;
1532 }
1533 } "-msse"
1534 } else {
1535 expr 1
1536 }
1537 }]
1538 }
1539
1540 # Return 1 if the target OS supports running AVX executables, 0
1541 # otherwise. Cache the result.
1542
1543 proc check_avx_os_support_available { } {
1544 return [check_cached_effective_target avx_os_support_available {
1545 # If this is not the right target then we can skip the test.
1546 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1547 expr 0
1548 } else {
1549 # Check that OS has AVX and SSE saving enabled.
1550 check_runtime_nocache avx_os_support_available {
1551 int main ()
1552 {
1553 unsigned int eax, edx;
1554
1555 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1556 return (eax & 6) != 6;
1557 }
1558 } ""
1559 }
1560 }]
1561 }
1562
1563 # Return 1 if the target supports executing SSE instructions, 0
1564 # otherwise. Cache the result.
1565
1566 proc check_sse_hw_available { } {
1567 return [check_cached_effective_target sse_hw_available {
1568 # If this is not the right target then we can skip the test.
1569 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1570 expr 0
1571 } else {
1572 check_runtime_nocache sse_hw_available {
1573 #include "cpuid.h"
1574 int main ()
1575 {
1576 unsigned int eax, ebx, ecx, edx;
1577 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1578 return !(edx & bit_SSE);
1579 return 1;
1580 }
1581 } ""
1582 }
1583 }]
1584 }
1585
1586 # Return 1 if the target supports executing MIPS Paired-Single instructions,
1587 # 0 otherwise. Cache the result.
1588
1589 proc check_mpaired_single_hw_available { } {
1590 return [check_cached_effective_target mpaired_single_hw_available {
1591 # If this is not the right target then we can skip the test.
1592 if { !([istarget mips*-*-*]) } {
1593 expr 0
1594 } else {
1595 check_runtime_nocache mpaired_single_hw_available {
1596 int main()
1597 {
1598 asm volatile ("pll.ps $f2,$f4,$f6");
1599 return 0;
1600 }
1601 } ""
1602 }
1603 }]
1604 }
1605
1606 # Return 1 if the target supports executing Loongson vector instructions,
1607 # 0 otherwise. Cache the result.
1608
1609 proc check_mips_loongson_hw_available { } {
1610 return [check_cached_effective_target mips_loongson_hw_available {
1611 # If this is not the right target then we can skip the test.
1612 if { !([istarget mips*-*-*]) } {
1613 expr 0
1614 } else {
1615 check_runtime_nocache mips_loongson_hw_available {
1616 #include <loongson.h>
1617 int main()
1618 {
1619 asm volatile ("paddw $f2,$f4,$f6");
1620 return 0;
1621 }
1622 } ""
1623 }
1624 }]
1625 }
1626
1627 # Return 1 if the target supports executing MIPS MSA instructions, 0
1628 # otherwise. Cache the result.
1629
1630 proc check_mips_msa_hw_available { } {
1631 return [check_cached_effective_target mips_msa_hw_available {
1632 # If this is not the right target then we can skip the test.
1633 if { !([istarget mips*-*-*]) } {
1634 expr 0
1635 } else {
1636 check_runtime_nocache mips_msa_hw_available {
1637 #if !defined(__mips_msa)
1638 #error "MSA NOT AVAIL"
1639 #else
1640 #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
1641 #error "MSA NOT AVAIL FOR ISA REV < 2"
1642 #endif
1643 #if !defined(__mips_hard_float)
1644 #error "MSA HARD_FLOAT REQUIRED"
1645 #endif
1646 #if __mips_fpr != 64
1647 #error "MSA 64-bit FPR REQUIRED"
1648 #endif
1649 #include <msa.h>
1650
1651 int main()
1652 {
1653 v8i16 v = __builtin_msa_ldi_h (0);
1654 v[0] = 0;
1655 return v[0];
1656 }
1657 #endif
1658 } "-mmsa"
1659 }
1660 }]
1661 }
1662
1663 # Return 1 if the target supports executing SSE2 instructions, 0
1664 # otherwise. Cache the result.
1665
1666 proc check_sse2_hw_available { } {
1667 return [check_cached_effective_target sse2_hw_available {
1668 # If this is not the right target then we can skip the test.
1669 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1670 expr 0
1671 } else {
1672 check_runtime_nocache sse2_hw_available {
1673 #include "cpuid.h"
1674 int main ()
1675 {
1676 unsigned int eax, ebx, ecx, edx;
1677 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1678 return !(edx & bit_SSE2);
1679 return 1;
1680 }
1681 } ""
1682 }
1683 }]
1684 }
1685
1686 # Return 1 if the target supports executing SSE4 instructions, 0
1687 # otherwise. Cache the result.
1688
1689 proc check_sse4_hw_available { } {
1690 return [check_cached_effective_target sse4_hw_available {
1691 # If this is not the right target then we can skip the test.
1692 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1693 expr 0
1694 } else {
1695 check_runtime_nocache sse4_hw_available {
1696 #include "cpuid.h"
1697 int main ()
1698 {
1699 unsigned int eax, ebx, ecx, edx;
1700 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1701 return !(ecx & bit_SSE4_2);
1702 return 1;
1703 }
1704 } ""
1705 }
1706 }]
1707 }
1708
1709 # Return 1 if the target supports executing AVX instructions, 0
1710 # otherwise. Cache the result.
1711
1712 proc check_avx_hw_available { } {
1713 return [check_cached_effective_target avx_hw_available {
1714 # If this is not the right target then we can skip the test.
1715 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
1716 expr 0
1717 } else {
1718 check_runtime_nocache avx_hw_available {
1719 #include "cpuid.h"
1720 int main ()
1721 {
1722 unsigned int eax, ebx, ecx, edx;
1723 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1724 return ((ecx & (bit_AVX | bit_OSXSAVE))
1725 != (bit_AVX | bit_OSXSAVE));
1726 return 1;
1727 }
1728 } ""
1729 }
1730 }]
1731 }
1732
1733 # Return 1 if the target supports executing AVX2 instructions, 0
1734 # otherwise. Cache the result.
1735
1736 proc check_avx2_hw_available { } {
1737 return [check_cached_effective_target avx2_hw_available {
1738 # If this is not the right target then we can skip the test.
1739 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1740 expr 0
1741 } else {
1742 check_runtime_nocache avx2_hw_available {
1743 #include "cpuid.h"
1744 int main ()
1745 {
1746 unsigned int eax, ebx, ecx, edx;
1747 if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)
1748 || ((ecx & bit_OSXSAVE) != bit_OSXSAVE))
1749 return 1;
1750
1751 if (__get_cpuid_max (0, NULL) < 7)
1752 return 1;
1753
1754 __cpuid_count (7, 0, eax, ebx, ecx, edx);
1755
1756 return (ebx & bit_AVX2) != bit_AVX2;
1757 }
1758 } ""
1759 }
1760 }]
1761 }
1762
1763 # Return 1 if the target supports running SSE executables, 0 otherwise.
1764
1765 proc check_effective_target_sse_runtime { } {
1766 if { [check_effective_target_sse]
1767 && [check_sse_hw_available]
1768 && [check_sse_os_support_available] } {
1769 return 1
1770 }
1771 return 0
1772 }
1773
1774 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1775
1776 proc check_effective_target_sse2_runtime { } {
1777 if { [check_effective_target_sse2]
1778 && [check_sse2_hw_available]
1779 && [check_sse_os_support_available] } {
1780 return 1
1781 }
1782 return 0
1783 }
1784
1785 # Return 1 if the target supports running SSE4 executables, 0 otherwise.
1786
1787 proc check_effective_target_sse4_runtime { } {
1788 if { [check_effective_target_sse4]
1789 && [check_sse4_hw_available]
1790 && [check_sse_os_support_available] } {
1791 return 1
1792 }
1793 return 0
1794 }
1795
1796 # Return 1 if the target supports running MIPS Paired-Single
1797 # executables, 0 otherwise.
1798
1799 proc check_effective_target_mpaired_single_runtime { } {
1800 if { [check_effective_target_mpaired_single]
1801 && [check_mpaired_single_hw_available] } {
1802 return 1
1803 }
1804 return 0
1805 }
1806
1807 # Return 1 if the target supports running Loongson executables, 0 otherwise.
1808
1809 proc check_effective_target_mips_loongson_runtime { } {
1810 if { [check_effective_target_mips_loongson]
1811 && [check_mips_loongson_hw_available] } {
1812 return 1
1813 }
1814 return 0
1815 }
1816
1817 # Return 1 if the target supports running MIPS MSA executables, 0 otherwise.
1818
1819 proc check_effective_target_mips_msa_runtime { } {
1820 if { [check_effective_target_mips_msa]
1821 && [check_mips_msa_hw_available] } {
1822 return 1
1823 }
1824 return 0
1825 }
1826
1827 # Return 1 if the target supports running AVX executables, 0 otherwise.
1828
1829 proc check_effective_target_avx_runtime { } {
1830 if { [check_effective_target_avx]
1831 && [check_avx_hw_available]
1832 && [check_avx_os_support_available] } {
1833 return 1
1834 }
1835 return 0
1836 }
1837
1838 # Return 1 if the target supports running AVX2 executables, 0 otherwise.
1839
1840 proc check_effective_target_avx2_runtime { } {
1841 if { [check_effective_target_avx2]
1842 && [check_avx2_hw_available]
1843 && [check_avx_os_support_available] } {
1844 return 1
1845 }
1846 return 0
1847 }
1848
1849 # Return 1 if we are compiling for 64-bit PowerPC but we do not use direct
1850 # move instructions for moves from GPR to FPR.
1851
1852 proc check_effective_target_powerpc64_no_dm { } {
1853 # The "mulld" checks if we are generating PowerPC64 code. The "lfd"
1854 # checks if we do not use direct moves, but use the old-fashioned
1855 # slower move-via-the-stack.
1856 return [check_no_messages_and_pattern powerpc64_no_dm \
1857 {\mmulld\M.*\mlfd} assembly {
1858 double f(long long x) { return x*x; }
1859 } {-O2}]
1860 }
1861
1862 # Return 1 if the target supports executing power8 vector instructions, 0
1863 # otherwise. Cache the result.
1864
1865 proc check_p8vector_hw_available { } {
1866 return [check_cached_effective_target p8vector_hw_available {
1867 # Some simulators are known to not support VSX/power8 instructions.
1868 # For now, disable on Darwin
1869 if { [istarget powerpc-*-eabi]
1870 || [istarget powerpc*-*-eabispe]
1871 || [istarget *-*-darwin*]} {
1872 expr 0
1873 } else {
1874 set options "-mpower8-vector"
1875 check_runtime_nocache p8vector_hw_available {
1876 int main()
1877 {
1878 #ifdef __MACH__
1879 asm volatile ("xxlorc vs0,vs0,vs0");
1880 #else
1881 asm volatile ("xxlorc 0,0,0");
1882 #endif
1883 return 0;
1884 }
1885 } $options
1886 }
1887 }]
1888 }
1889
1890 # Return 1 if the target supports executing power9 vector instructions, 0
1891 # otherwise. Cache the result.
1892
1893 proc check_p9vector_hw_available { } {
1894 return [check_cached_effective_target p9vector_hw_available {
1895 # Some simulators are known to not support VSX/power8/power9
1896 # instructions. For now, disable on Darwin.
1897 if { [istarget powerpc-*-eabi]
1898 || [istarget powerpc*-*-eabispe]
1899 || [istarget *-*-darwin*]} {
1900 expr 0
1901 } else {
1902 set options "-mpower9-vector"
1903 check_runtime_nocache p9vector_hw_available {
1904 int main()
1905 {
1906 long e = -1;
1907 vector double v = (vector double) { 0.0, 0.0 };
1908 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
1909 return e;
1910 }
1911 } $options
1912 }
1913 }]
1914 }
1915
1916 # Return 1 if the target supports executing power9 modulo instructions, 0
1917 # otherwise. Cache the result.
1918
1919 proc check_p9modulo_hw_available { } {
1920 return [check_cached_effective_target p9modulo_hw_available {
1921 # Some simulators are known to not support VSX/power8/power9
1922 # instructions. For now, disable on Darwin.
1923 if { [istarget powerpc-*-eabi]
1924 || [istarget powerpc*-*-eabispe]
1925 || [istarget *-*-darwin*]} {
1926 expr 0
1927 } else {
1928 set options "-mmodulo"
1929 check_runtime_nocache p9modulo_hw_available {
1930 int main()
1931 {
1932 int i = 5, j = 3, r = -1;
1933 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
1934 return (r == 2);
1935 }
1936 } $options
1937 }
1938 }]
1939 }
1940
1941 # Return 1 if the target supports executing __float128 on PowerPC via software
1942 # emulation, 0 otherwise. Cache the result.
1943
1944 proc check_ppc_float128_sw_available { } {
1945 return [check_cached_effective_target ppc_float128_sw_available {
1946 # Some simulators are known to not support VSX/power8/power9
1947 # instructions. For now, disable on Darwin.
1948 if { [istarget powerpc-*-eabi]
1949 || [istarget powerpc*-*-eabispe]
1950 || [istarget *-*-darwin*]} {
1951 expr 0
1952 } else {
1953 set options "-mfloat128 -mvsx"
1954 check_runtime_nocache ppc_float128_sw_available {
1955 volatile __float128 x = 1.0q;
1956 volatile __float128 y = 2.0q;
1957 int main()
1958 {
1959 __float128 z = x + y;
1960 return (z != 3.0q);
1961 }
1962 } $options
1963 }
1964 }]
1965 }
1966
1967 # Return 1 if the target supports executing __float128 on PowerPC via power9
1968 # hardware instructions, 0 otherwise. Cache the result.
1969
1970 proc check_ppc_float128_hw_available { } {
1971 return [check_cached_effective_target ppc_float128_hw_available {
1972 # Some simulators are known to not support VSX/power8/power9
1973 # instructions. For now, disable on Darwin.
1974 if { [istarget powerpc-*-eabi]
1975 || [istarget powerpc*-*-eabispe]
1976 || [istarget *-*-darwin*]} {
1977 expr 0
1978 } else {
1979 set options "-mfloat128 -mvsx -mfloat128-hardware -mpower9-vector"
1980 check_runtime_nocache ppc_float128_hw_available {
1981 volatile __float128 x = 1.0q;
1982 volatile __float128 y = 2.0q;
1983 int main()
1984 {
1985 __float128 z = x + y;
1986 __float128 w = -1.0q;
1987
1988 __asm__ ("xsaddqp %0,%1,%2" : "+v" (w) : "v" (x), "v" (y));
1989 return ((z != 3.0q) || (z != w);
1990 }
1991 } $options
1992 }
1993 }]
1994 }
1995
1996 # Return 1 if the target supports executing VSX instructions, 0
1997 # otherwise. Cache the result.
1998
1999 proc check_vsx_hw_available { } {
2000 return [check_cached_effective_target vsx_hw_available {
2001 # Some simulators are known to not support VSX instructions.
2002 # For now, disable on Darwin
2003 if { [istarget powerpc-*-eabi]
2004 || [istarget powerpc*-*-eabispe]
2005 || [istarget *-*-darwin*]} {
2006 expr 0
2007 } else {
2008 set options "-mvsx"
2009 check_runtime_nocache vsx_hw_available {
2010 int main()
2011 {
2012 #ifdef __MACH__
2013 asm volatile ("xxlor vs0,vs0,vs0");
2014 #else
2015 asm volatile ("xxlor 0,0,0");
2016 #endif
2017 return 0;
2018 }
2019 } $options
2020 }
2021 }]
2022 }
2023
2024 # Return 1 if the target supports executing AltiVec instructions, 0
2025 # otherwise. Cache the result.
2026
2027 proc check_vmx_hw_available { } {
2028 return [check_cached_effective_target vmx_hw_available {
2029 # Some simulators are known to not support VMX instructions.
2030 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
2031 expr 0
2032 } else {
2033 # Most targets don't require special flags for this test case, but
2034 # Darwin does. Just to be sure, make sure VSX is not enabled for
2035 # the altivec tests.
2036 if { [istarget *-*-darwin*]
2037 || [istarget *-*-aix*] } {
2038 set options "-maltivec -mno-vsx"
2039 } else {
2040 set options "-mno-vsx"
2041 }
2042 check_runtime_nocache vmx_hw_available {
2043 int main()
2044 {
2045 #ifdef __MACH__
2046 asm volatile ("vor v0,v0,v0");
2047 #else
2048 asm volatile ("vor 0,0,0");
2049 #endif
2050 return 0;
2051 }
2052 } $options
2053 }
2054 }]
2055 }
2056
2057 proc check_ppc_recip_hw_available { } {
2058 return [check_cached_effective_target ppc_recip_hw_available {
2059 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
2060 # For now, disable on Darwin
2061 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2062 expr 0
2063 } else {
2064 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
2065 check_runtime_nocache ppc_recip_hw_available {
2066 volatile double d_recip, d_rsqrt, d_four = 4.0;
2067 volatile float f_recip, f_rsqrt, f_four = 4.0f;
2068 int main()
2069 {
2070 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
2071 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
2072 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
2073 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
2074 return 0;
2075 }
2076 } $options
2077 }
2078 }]
2079 }
2080
2081 # Return 1 if the target supports executing AltiVec and Cell PPU
2082 # instructions, 0 otherwise. Cache the result.
2083
2084 proc check_effective_target_cell_hw { } {
2085 return [check_cached_effective_target cell_hw_available {
2086 # Some simulators are known to not support VMX and PPU instructions.
2087 if { [istarget powerpc-*-eabi*] } {
2088 expr 0
2089 } else {
2090 # Most targets don't require special flags for this test
2091 # case, but Darwin and AIX do.
2092 if { [istarget *-*-darwin*]
2093 || [istarget *-*-aix*] } {
2094 set options "-maltivec -mcpu=cell"
2095 } else {
2096 set options "-mcpu=cell"
2097 }
2098 check_runtime_nocache cell_hw_available {
2099 int main()
2100 {
2101 #ifdef __MACH__
2102 asm volatile ("vor v0,v0,v0");
2103 asm volatile ("lvlx v0,r0,r0");
2104 #else
2105 asm volatile ("vor 0,0,0");
2106 asm volatile ("lvlx 0,0,0");
2107 #endif
2108 return 0;
2109 }
2110 } $options
2111 }
2112 }]
2113 }
2114
2115 # Return 1 if the target supports executing 64-bit instructions, 0
2116 # otherwise. Cache the result.
2117
2118 proc check_effective_target_powerpc64 { } {
2119 global powerpc64_available_saved
2120 global tool
2121
2122 if [info exists powerpc64_available_saved] {
2123 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
2124 } else {
2125 set powerpc64_available_saved 0
2126
2127 # Some simulators are known to not support powerpc64 instructions.
2128 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
2129 verbose "check_effective_target_powerpc64 returning 0" 2
2130 return $powerpc64_available_saved
2131 }
2132
2133 # Set up, compile, and execute a test program containing a 64-bit
2134 # instruction. Include the current process ID in the file
2135 # names to prevent conflicts with invocations for multiple
2136 # testsuites.
2137 set src ppc[pid].c
2138 set exe ppc[pid].x
2139
2140 set f [open $src "w"]
2141 puts $f "int main() {"
2142 puts $f "#ifdef __MACH__"
2143 puts $f " asm volatile (\"extsw r0,r0\");"
2144 puts $f "#else"
2145 puts $f " asm volatile (\"extsw 0,0\");"
2146 puts $f "#endif"
2147 puts $f " return 0; }"
2148 close $f
2149
2150 set opts "additional_flags=-mcpu=G5"
2151
2152 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
2153 set lines [${tool}_target_compile $src $exe executable "$opts"]
2154 file delete $src
2155
2156 if [string match "" $lines] then {
2157 # No error message, compilation succeeded.
2158 set result [${tool}_load "./$exe" "" ""]
2159 set status [lindex $result 0]
2160 remote_file build delete $exe
2161 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
2162
2163 if { $status == "pass" } then {
2164 set powerpc64_available_saved 1
2165 }
2166 } else {
2167 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
2168 }
2169 }
2170
2171 return $powerpc64_available_saved
2172 }
2173
2174 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
2175 # complex float arguments. This affects gfortran tests that call cabsf
2176 # in libm built by an earlier compiler. Return 1 if libm uses the same
2177 # argument passing as the compiler under test, 0 otherwise.
2178 #
2179 # When the target name changes, replace the cached result.
2180
2181 proc check_effective_target_broken_cplxf_arg { } {
2182 return [check_cached_effective_target broken_cplxf_arg {
2183 # Skip the work for targets known not to be affected.
2184 if { ![istarget powerpc64-*-linux*] } {
2185 expr 0
2186 } elseif { ![is-effective-target lp64] } {
2187 expr 0
2188 } else {
2189 check_runtime_nocache broken_cplxf_arg {
2190 #include <complex.h>
2191 extern void abort (void);
2192 float fabsf (float);
2193 float cabsf (_Complex float);
2194 int main ()
2195 {
2196 _Complex float cf;
2197 float f;
2198 cf = 3 + 4.0fi;
2199 f = cabsf (cf);
2200 if (fabsf (f - 5.0) > 0.0001)
2201 abort ();
2202 return 0;
2203 }
2204 } "-lm"
2205 }
2206 }]
2207 }
2208
2209 # Return 1 is this is a TI C6X target supporting C67X instructions
2210 proc check_effective_target_ti_c67x { } {
2211 return [check_no_compiler_messages ti_c67x assembly {
2212 #if !defined(_TMS320C6700)
2213 #error !_TMS320C6700
2214 #endif
2215 }]
2216 }
2217
2218 # Return 1 is this is a TI C6X target supporting C64X+ instructions
2219 proc check_effective_target_ti_c64xp { } {
2220 return [check_no_compiler_messages ti_c64xp assembly {
2221 #if !defined(_TMS320C6400_PLUS)
2222 #error !_TMS320C6400_PLUS
2223 #endif
2224 }]
2225 }
2226
2227
2228 proc check_alpha_max_hw_available { } {
2229 return [check_runtime alpha_max_hw_available {
2230 int main() { return __builtin_alpha_amask(1<<8) != 0; }
2231 }]
2232 }
2233
2234 # Returns true iff the FUNCTION is available on the target system.
2235 # (This is essentially a Tcl implementation of Autoconf's
2236 # AC_CHECK_FUNC.)
2237
2238 proc check_function_available { function } {
2239 return [check_no_compiler_messages ${function}_available \
2240 executable [subst {
2241 #ifdef __cplusplus
2242 extern "C"
2243 #endif
2244 char $function ();
2245 int main () { $function (); }
2246 }] "-fno-builtin" ]
2247 }
2248
2249 # Returns true iff "fork" is available on the target system.
2250
2251 proc check_fork_available {} {
2252 return [check_function_available "fork"]
2253 }
2254
2255 # Returns true iff "mkfifo" is available on the target system.
2256
2257 proc check_mkfifo_available {} {
2258 if { [istarget *-*-cygwin*] } {
2259 # Cygwin has mkfifo, but support is incomplete.
2260 return 0
2261 }
2262
2263 return [check_function_available "mkfifo"]
2264 }
2265
2266 # Returns true iff "__cxa_atexit" is used on the target system.
2267
2268 proc check_cxa_atexit_available { } {
2269 return [check_cached_effective_target cxa_atexit_available {
2270 if { [istarget hppa*-*-hpux10*] } {
2271 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
2272 expr 0
2273 } elseif { [istarget *-*-vxworks] } {
2274 # vxworks doesn't have __cxa_atexit but subsequent test passes.
2275 expr 0
2276 } else {
2277 check_runtime_nocache cxa_atexit_available {
2278 // C++
2279 #include <stdlib.h>
2280 static unsigned int count;
2281 struct X
2282 {
2283 X() { count = 1; }
2284 ~X()
2285 {
2286 if (count != 3)
2287 exit(1);
2288 count = 4;
2289 }
2290 };
2291 void f()
2292 {
2293 static X x;
2294 }
2295 struct Y
2296 {
2297 Y() { f(); count = 2; }
2298 ~Y()
2299 {
2300 if (count != 2)
2301 exit(1);
2302 count = 3;
2303 }
2304 };
2305 Y y;
2306 int main() { return 0; }
2307 }
2308 }
2309 }]
2310 }
2311
2312 proc check_effective_target_objc2 { } {
2313 return [check_no_compiler_messages objc2 object {
2314 #ifdef __OBJC2__
2315 int dummy[1];
2316 #else
2317 #error !__OBJC2__
2318 #endif
2319 }]
2320 }
2321
2322 proc check_effective_target_next_runtime { } {
2323 return [check_no_compiler_messages objc2 object {
2324 #ifdef __NEXT_RUNTIME__
2325 int dummy[1];
2326 #else
2327 #error !__NEXT_RUNTIME__
2328 #endif
2329 }]
2330 }
2331
2332 # Return 1 if we're generating 32-bit code using default options, 0
2333 # otherwise.
2334
2335 proc check_effective_target_ilp32 { } {
2336 return [check_no_compiler_messages ilp32 object {
2337 int dummy[sizeof (int) == 4
2338 && sizeof (void *) == 4
2339 && sizeof (long) == 4 ? 1 : -1];
2340 }]
2341 }
2342
2343 # Return 1 if we're generating ia32 code using default options, 0
2344 # otherwise.
2345
2346 proc check_effective_target_ia32 { } {
2347 return [check_no_compiler_messages ia32 object {
2348 int dummy[sizeof (int) == 4
2349 && sizeof (void *) == 4
2350 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
2351 }]
2352 }
2353
2354 # Return 1 if we're generating x32 code using default options, 0
2355 # otherwise.
2356
2357 proc check_effective_target_x32 { } {
2358 return [check_no_compiler_messages x32 object {
2359 int dummy[sizeof (int) == 4
2360 && sizeof (void *) == 4
2361 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
2362 }]
2363 }
2364
2365 # Return 1 if we're generating 32-bit integers using default
2366 # options, 0 otherwise.
2367
2368 proc check_effective_target_int32 { } {
2369 return [check_no_compiler_messages int32 object {
2370 int dummy[sizeof (int) == 4 ? 1 : -1];
2371 }]
2372 }
2373
2374 # Return 1 if we're generating 32-bit or larger integers using default
2375 # options, 0 otherwise.
2376
2377 proc check_effective_target_int32plus { } {
2378 return [check_no_compiler_messages int32plus object {
2379 int dummy[sizeof (int) >= 4 ? 1 : -1];
2380 }]
2381 }
2382
2383 # Return 1 if we're generating 32-bit or larger pointers using default
2384 # options, 0 otherwise.
2385
2386 proc check_effective_target_ptr32plus { } {
2387 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
2388 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
2389 # cannot really hold a 32-bit address, so we always return false here.
2390 if { [istarget msp430-*-*] } {
2391 return 0
2392 }
2393
2394 return [check_no_compiler_messages ptr32plus object {
2395 int dummy[sizeof (void *) >= 4 ? 1 : -1];
2396 }]
2397 }
2398
2399 # Return 1 if we support 32-bit or larger array and structure sizes
2400 # using default options, 0 otherwise. Avoid false positive on
2401 # targets with 20 or 24 bit address spaces.
2402
2403 proc check_effective_target_size32plus { } {
2404 return [check_no_compiler_messages size32plus object {
2405 char dummy[16777217L];
2406 }]
2407 }
2408
2409 # Returns 1 if we're generating 16-bit or smaller integers with the
2410 # default options, 0 otherwise.
2411
2412 proc check_effective_target_int16 { } {
2413 return [check_no_compiler_messages int16 object {
2414 int dummy[sizeof (int) < 4 ? 1 : -1];
2415 }]
2416 }
2417
2418 # Return 1 if we're generating 64-bit code using default options, 0
2419 # otherwise.
2420
2421 proc check_effective_target_lp64 { } {
2422 return [check_no_compiler_messages lp64 object {
2423 int dummy[sizeof (int) == 4
2424 && sizeof (void *) == 8
2425 && sizeof (long) == 8 ? 1 : -1];
2426 }]
2427 }
2428
2429 # Return 1 if we're generating 64-bit code using default llp64 options,
2430 # 0 otherwise.
2431
2432 proc check_effective_target_llp64 { } {
2433 return [check_no_compiler_messages llp64 object {
2434 int dummy[sizeof (int) == 4
2435 && sizeof (void *) == 8
2436 && sizeof (long long) == 8
2437 && sizeof (long) == 4 ? 1 : -1];
2438 }]
2439 }
2440
2441 # Return 1 if long and int have different sizes,
2442 # 0 otherwise.
2443
2444 proc check_effective_target_long_neq_int { } {
2445 return [check_no_compiler_messages long_ne_int object {
2446 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2447 }]
2448 }
2449
2450 # Return 1 if the target supports long double larger than double,
2451 # 0 otherwise.
2452
2453 proc check_effective_target_large_long_double { } {
2454 return [check_no_compiler_messages large_long_double object {
2455 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2456 }]
2457 }
2458
2459 # Return 1 if the target supports double larger than float,
2460 # 0 otherwise.
2461
2462 proc check_effective_target_large_double { } {
2463 return [check_no_compiler_messages large_double object {
2464 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2465 }]
2466 }
2467
2468 # Return 1 if the target supports long double of 128 bits,
2469 # 0 otherwise.
2470
2471 proc check_effective_target_longdouble128 { } {
2472 return [check_no_compiler_messages longdouble128 object {
2473 int dummy[sizeof(long double) == 16 ? 1 : -1];
2474 }]
2475 }
2476
2477 # Return 1 if the target supports double of 64 bits,
2478 # 0 otherwise.
2479
2480 proc check_effective_target_double64 { } {
2481 return [check_no_compiler_messages double64 object {
2482 int dummy[sizeof(double) == 8 ? 1 : -1];
2483 }]
2484 }
2485
2486 # Return 1 if the target supports double of at least 64 bits,
2487 # 0 otherwise.
2488
2489 proc check_effective_target_double64plus { } {
2490 return [check_no_compiler_messages double64plus object {
2491 int dummy[sizeof(double) >= 8 ? 1 : -1];
2492 }]
2493 }
2494
2495 # Return 1 if the target supports 'w' suffix on floating constant
2496 # 0 otherwise.
2497
2498 proc check_effective_target_has_w_floating_suffix { } {
2499 set opts ""
2500 if [check_effective_target_c++] {
2501 append opts "-std=gnu++03"
2502 }
2503 return [check_no_compiler_messages w_fp_suffix object {
2504 float dummy = 1.0w;
2505 } "$opts"]
2506 }
2507
2508 # Return 1 if the target supports 'q' suffix on floating constant
2509 # 0 otherwise.
2510
2511 proc check_effective_target_has_q_floating_suffix { } {
2512 set opts ""
2513 if [check_effective_target_c++] {
2514 append opts "-std=gnu++03"
2515 }
2516 return [check_no_compiler_messages q_fp_suffix object {
2517 float dummy = 1.0q;
2518 } "$opts"]
2519 }
2520
2521 # Return 1 if the target supports the _FloatN / _FloatNx type
2522 # indicated in the function name, 0 otherwise.
2523
2524 proc check_effective_target_float16 {} {
2525 return [check_no_compiler_messages_nocache float16 object {
2526 _Float16 x;
2527 }]
2528 }
2529
2530 proc check_effective_target_float32 {} {
2531 return [check_no_compiler_messages_nocache float32 object {
2532 _Float32 x;
2533 }]
2534 }
2535
2536 proc check_effective_target_float64 {} {
2537 return [check_no_compiler_messages_nocache float64 object {
2538 _Float64 x;
2539 }]
2540 }
2541
2542 proc check_effective_target_float128 {} {
2543 return [check_no_compiler_messages_nocache float128 object {
2544 _Float128 x;
2545 }]
2546 }
2547
2548 proc check_effective_target_float32x {} {
2549 return [check_no_compiler_messages_nocache float32x object {
2550 _Float32x x;
2551 }]
2552 }
2553
2554 proc check_effective_target_float64x {} {
2555 return [check_no_compiler_messages_nocache float64x object {
2556 _Float64x x;
2557 }]
2558 }
2559
2560 proc check_effective_target_float128x {} {
2561 return [check_no_compiler_messages_nocache float128x object {
2562 _Float128x x;
2563 }]
2564 }
2565
2566 # Likewise, but runtime support for any special options used as well
2567 # as compile-time support is required.
2568
2569 proc check_effective_target_float16_runtime {} {
2570 return [check_effective_target_float16]
2571 }
2572
2573 proc check_effective_target_float32_runtime {} {
2574 return [check_effective_target_float32]
2575 }
2576
2577 proc check_effective_target_float64_runtime {} {
2578 return [check_effective_target_float64]
2579 }
2580
2581 proc check_effective_target_float128_runtime {} {
2582 if { ![check_effective_target_float128] } {
2583 return 0
2584 }
2585 if { [istarget powerpc*-*-*] } {
2586 return [check_effective_target_base_quadfloat_support]
2587 }
2588 return 1
2589 }
2590
2591 proc check_effective_target_float32x_runtime {} {
2592 return [check_effective_target_float32x]
2593 }
2594
2595 proc check_effective_target_float64x_runtime {} {
2596 if { ![check_effective_target_float64x] } {
2597 return 0
2598 }
2599 if { [istarget powerpc*-*-*] } {
2600 return [check_effective_target_base_quadfloat_support]
2601 }
2602 return 1
2603 }
2604
2605 proc check_effective_target_float128x_runtime {} {
2606 return [check_effective_target_float128x]
2607 }
2608
2609 # Return 1 if the target hardware supports any options added for
2610 # _FloatN and _FloatNx types, 0 otherwise.
2611
2612 proc check_effective_target_floatn_nx_runtime {} {
2613 if { [istarget powerpc*-*-aix*] } {
2614 return 0
2615 }
2616 if { [istarget powerpc*-*-*] } {
2617 return [check_effective_target_base_quadfloat_support]
2618 }
2619 return 1
2620 }
2621
2622 # Add options needed to use the _FloatN / _FloatNx type indicated in
2623 # the function name.
2624
2625 proc add_options_for_float16 { flags } {
2626 return "$flags"
2627 }
2628
2629 proc add_options_for_float32 { flags } {
2630 return "$flags"
2631 }
2632
2633 proc add_options_for_float64 { flags } {
2634 return "$flags"
2635 }
2636
2637 proc add_options_for_float128 { flags } {
2638 return [add_options_for___float128 "$flags"]
2639 }
2640
2641 proc add_options_for_float32x { flags } {
2642 return "$flags"
2643 }
2644
2645 proc add_options_for_float64x { flags } {
2646 return [add_options_for___float128 "$flags"]
2647 }
2648
2649 proc add_options_for_float128x { flags } {
2650 return "$flags"
2651 }
2652
2653 # Return 1 if the target supports __float128,
2654 # 0 otherwise.
2655
2656 proc check_effective_target___float128 { } {
2657 if { [istarget powerpc*-*-*] } {
2658 return [check_ppc_float128_sw_available]
2659 }
2660 if { [istarget ia64-*-*]
2661 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2662 return 1
2663 }
2664 return 0
2665 }
2666
2667 proc add_options_for___float128 { flags } {
2668 if { [istarget powerpc*-*-*] } {
2669 return "$flags -mfloat128 -mvsx"
2670 }
2671 return "$flags"
2672 }
2673
2674 # Return 1 if the target supports any special run-time requirements
2675 # for __float128 or _Float128,
2676 # 0 otherwise.
2677
2678 proc check_effective_target_base_quadfloat_support { } {
2679 if { [istarget powerpc*-*-*] } {
2680 return [check_vsx_hw_available]
2681 }
2682 return 1
2683 }
2684
2685 # Return 1 if the target supports compiling fixed-point,
2686 # 0 otherwise.
2687
2688 proc check_effective_target_fixed_point { } {
2689 return [check_no_compiler_messages fixed_point object {
2690 _Sat _Fract x; _Sat _Accum y;
2691 }]
2692 }
2693
2694 # Return 1 if the target supports compiling decimal floating point,
2695 # 0 otherwise.
2696
2697 proc check_effective_target_dfp_nocache { } {
2698 verbose "check_effective_target_dfp_nocache: compiling source" 2
2699 set ret [check_no_compiler_messages_nocache dfp object {
2700 float x __attribute__((mode(DD)));
2701 }]
2702 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2703 return $ret
2704 }
2705
2706 proc check_effective_target_dfprt_nocache { } {
2707 return [check_runtime_nocache dfprt {
2708 typedef float d64 __attribute__((mode(DD)));
2709 d64 x = 1.2df, y = 2.3dd, z;
2710 int main () { z = x + y; return 0; }
2711 }]
2712 }
2713
2714 # Return 1 if the target supports compiling Decimal Floating Point,
2715 # 0 otherwise.
2716 #
2717 # This won't change for different subtargets so cache the result.
2718
2719 proc check_effective_target_dfp { } {
2720 return [check_cached_effective_target dfp {
2721 check_effective_target_dfp_nocache
2722 }]
2723 }
2724
2725 # Return 1 if the target supports linking and executing Decimal Floating
2726 # Point, 0 otherwise.
2727 #
2728 # This won't change for different subtargets so cache the result.
2729
2730 proc check_effective_target_dfprt { } {
2731 return [check_cached_effective_target dfprt {
2732 check_effective_target_dfprt_nocache
2733 }]
2734 }
2735
2736 # Return 1 if the target supports executing DFP hardware instructions,
2737 # 0 otherwise. Cache the result.
2738
2739 proc check_dfp_hw_available { } {
2740 return [check_cached_effective_target dfp_hw_available {
2741 # For now, disable on Darwin
2742 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2743 expr 0
2744 } else {
2745 check_runtime_nocache dfp_hw_available {
2746 volatile _Decimal64 r;
2747 volatile _Decimal64 a = 4.0DD;
2748 volatile _Decimal64 b = 2.0DD;
2749 int main()
2750 {
2751 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2752 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2753 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2754 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2755 return 0;
2756 }
2757 } "-mcpu=power6 -mhard-float"
2758 }
2759 }]
2760 }
2761
2762 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2763
2764 proc check_effective_target_ucn_nocache { } {
2765 # -std=c99 is only valid for C
2766 if [check_effective_target_c] {
2767 set ucnopts "-std=c99"
2768 } else {
2769 set ucnopts ""
2770 }
2771 verbose "check_effective_target_ucn_nocache: compiling source" 2
2772 set ret [check_no_compiler_messages_nocache ucn object {
2773 int \u00C0;
2774 } $ucnopts]
2775 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2776 return $ret
2777 }
2778
2779 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2780 #
2781 # This won't change for different subtargets, so cache the result.
2782
2783 proc check_effective_target_ucn { } {
2784 return [check_cached_effective_target ucn {
2785 check_effective_target_ucn_nocache
2786 }]
2787 }
2788
2789 # Return 1 if the target needs a command line argument to enable a SIMD
2790 # instruction set.
2791
2792 proc check_effective_target_vect_cmdline_needed { } {
2793 global et_vect_cmdline_needed_saved
2794 global et_vect_cmdline_needed_target_name
2795
2796 if { ![info exists et_vect_cmdline_needed_target_name] } {
2797 set et_vect_cmdline_needed_target_name ""
2798 }
2799
2800 # If the target has changed since we set the cached value, clear it.
2801 set current_target [current_target_name]
2802 if { $current_target != $et_vect_cmdline_needed_target_name } {
2803 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2804 set et_vect_cmdline_needed_target_name $current_target
2805 if { [info exists et_vect_cmdline_needed_saved] } {
2806 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
2807 unset et_vect_cmdline_needed_saved
2808 }
2809 }
2810
2811 if [info exists et_vect_cmdline_needed_saved] {
2812 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2813 } else {
2814 set et_vect_cmdline_needed_saved 1
2815 if { [istarget alpha*-*-*]
2816 || [istarget ia64-*-*]
2817 || (([istarget i?86-*-*] || [istarget x86_64-*-*])
2818 && ![is-effective-target ia32])
2819 || ([istarget powerpc*-*-*]
2820 && ([check_effective_target_powerpc_spe]
2821 || [check_effective_target_powerpc_altivec]))
2822 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2823 || [istarget spu-*-*]
2824 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2825 || [istarget aarch64*-*-*] } {
2826 set et_vect_cmdline_needed_saved 0
2827 }
2828 }
2829
2830 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2831 return $et_vect_cmdline_needed_saved
2832 }
2833
2834 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2835 #
2836 # This won't change for different subtargets so cache the result.
2837
2838 proc check_effective_target_vect_int { } {
2839 global et_vect_int_saved
2840 global et_index
2841
2842 if [info exists et_vect_int_saved($et_index)] {
2843 verbose "check_effective_target_vect_int: using cached result" 2
2844 } else {
2845 set et_vect_int_saved($et_index) 0
2846 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2847 || ([istarget powerpc*-*-*]
2848 && ![istarget powerpc-*-linux*paired*])
2849 || [istarget spu-*-*]
2850 || [istarget sparc*-*-*]
2851 || [istarget alpha*-*-*]
2852 || [istarget ia64-*-*]
2853 || [istarget aarch64*-*-*]
2854 || [check_effective_target_arm32]
2855 || ([istarget mips*-*-*]
2856 && ([et-is-effective-target mips_loongson]
2857 || [et-is-effective-target mips_msa])) } {
2858 set et_vect_int_saved($et_index) 1
2859 }
2860 }
2861
2862 verbose "check_effective_target_vect_int:\
2863 returning $et_vect_int_saved($et_index)" 2
2864 return $et_vect_int_saved($et_index)
2865 }
2866
2867 # Return 1 if the target supports signed int->float conversion
2868 #
2869
2870 proc check_effective_target_vect_intfloat_cvt { } {
2871 global et_vect_intfloat_cvt_saved
2872 global et_index
2873
2874 if [info exists et_vect_intfloat_cvt_saved($et_index)] {
2875 verbose "check_effective_target_vect_intfloat_cvt:\
2876 using cached result" 2
2877 } else {
2878 set et_vect_intfloat_cvt_saved($et_index) 0
2879 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2880 || ([istarget powerpc*-*-*]
2881 && ![istarget powerpc-*-linux*paired*])
2882 || ([istarget arm*-*-*]
2883 && [check_effective_target_arm_neon_ok])
2884 || ([istarget mips*-*-*]
2885 && [et-is-effective-target mips_msa]) } {
2886 set et_vect_intfloat_cvt_saved($et_index) 1
2887 }
2888 }
2889
2890 verbose "check_effective_target_vect_intfloat_cvt:\
2891 returning $et_vect_intfloat_cvt_saved($et_index)" 2
2892 return $et_vect_intfloat_cvt_saved($et_index)
2893 }
2894
2895 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2896
2897 proc check_effective_target_int128 { } {
2898 return [check_no_compiler_messages int128 object {
2899 int dummy[
2900 #ifndef __SIZEOF_INT128__
2901 -1
2902 #else
2903 1
2904 #endif
2905 ];
2906 }]
2907 }
2908
2909 # Return 1 if the target supports unsigned int->float conversion
2910 #
2911
2912 proc check_effective_target_vect_uintfloat_cvt { } {
2913 global et_vect_uintfloat_cvt_saved
2914 global et_index
2915
2916 if [info exists et_vect_uintfloat_cvt_saved($et_index)] {
2917 verbose "check_effective_target_vect_uintfloat_cvt:\
2918 using cached result" 2
2919 } else {
2920 set et_vect_uintfloat_cvt_saved($et_index) 0
2921 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2922 || ([istarget powerpc*-*-*]
2923 && ![istarget powerpc-*-linux*paired*])
2924 || [istarget aarch64*-*-*]
2925 || ([istarget arm*-*-*]
2926 && [check_effective_target_arm_neon_ok])
2927 || ([istarget mips*-*-*]
2928 && [et-is-effective-target mips_msa]) } {
2929 set et_vect_uintfloat_cvt_saved($et_index) 1
2930 }
2931 }
2932
2933 verbose "check_effective_target_vect_uintfloat_cvt:\
2934 returning $et_vect_uintfloat_cvt_saved($et_index)" 2
2935 return $et_vect_uintfloat_cvt_saved($et_index)
2936 }
2937
2938
2939 # Return 1 if the target supports signed float->int conversion
2940 #
2941
2942 proc check_effective_target_vect_floatint_cvt { } {
2943 global et_vect_floatint_cvt_saved
2944 global et_index
2945
2946 if [info exists et_vect_floatint_cvt_saved($et_index)] {
2947 verbose "check_effective_target_vect_floatint_cvt:\
2948 using cached result" 2
2949 } else {
2950 set et_vect_floatint_cvt_saved($et_index) 0
2951 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2952 || ([istarget powerpc*-*-*]
2953 && ![istarget powerpc-*-linux*paired*])
2954 || ([istarget arm*-*-*]
2955 && [check_effective_target_arm_neon_ok])
2956 || ([istarget mips*-*-*]
2957 && [et-is-effective-target mips_msa]) } {
2958 set et_vect_floatint_cvt_saved($et_index) 1
2959 }
2960 }
2961
2962 verbose "check_effective_target_vect_floatint_cvt:\
2963 returning $et_vect_floatint_cvt_saved($et_index)" 2
2964 return $et_vect_floatint_cvt_saved($et_index)
2965 }
2966
2967 # Return 1 if the target supports unsigned float->int conversion
2968 #
2969
2970 proc check_effective_target_vect_floatuint_cvt { } {
2971 global et_vect_floatuint_cvt_saved
2972 global et_index
2973
2974 if [info exists et_vect_floatuint_cvt_saved($et_index)] {
2975 verbose "check_effective_target_vect_floatuint_cvt:\
2976 using cached result" 2
2977 } else {
2978 set et_vect_floatuint_cvt_saved($et_index) 0
2979 if { ([istarget powerpc*-*-*]
2980 && ![istarget powerpc-*-linux*paired*])
2981 || ([istarget arm*-*-*]
2982 && [check_effective_target_arm_neon_ok])
2983 || ([istarget mips*-*-*]
2984 && [et-is-effective-target mips_msa]) } {
2985 set et_vect_floatuint_cvt_saved($et_index) 1
2986 }
2987 }
2988
2989 verbose "check_effective_target_vect_floatuint_cvt:\
2990 returning $et_vect_floatuint_cvt_saved($et_index)" 2
2991 return $et_vect_floatuint_cvt_saved($et_index)
2992 }
2993
2994 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2995 #
2996 # This won't change for different subtargets so cache the result.
2997
2998 proc check_effective_target_vect_simd_clones { } {
2999 global et_vect_simd_clones_saved
3000 global et_index
3001
3002 if [info exists et_vect_simd_clones_saved($et_index)] {
3003 verbose "check_effective_target_vect_simd_clones: using cached result" 2
3004 } else {
3005 set et_vect_simd_clones_saved($et_index) 0
3006 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx,
3007 # avx2 and avx512f clone. Only the right clone for the
3008 # specified arch will be chosen, but still we need to at least
3009 # be able to assemble avx512f.
3010 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
3011 && [check_effective_target_avx512f]) } {
3012 set et_vect_simd_clones_saved($et_index) 1
3013 }
3014 }
3015
3016 verbose "check_effective_target_vect_simd_clones:\
3017 returning $et_vect_simd_clones_saved($et_index)" 2
3018 return $et_vect_simd_clones_saved($et_index)
3019 }
3020
3021 # Return 1 if this is a AArch64 target supporting big endian
3022 proc check_effective_target_aarch64_big_endian { } {
3023 return [check_no_compiler_messages aarch64_big_endian assembly {
3024 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
3025 #error !__aarch64__ || !__AARCH64EB__
3026 #endif
3027 }]
3028 }
3029
3030 # Return 1 if this is a AArch64 target supporting little endian
3031 proc check_effective_target_aarch64_little_endian { } {
3032 if { ![istarget aarch64*-*-*] } {
3033 return 0
3034 }
3035
3036 return [check_no_compiler_messages aarch64_little_endian assembly {
3037 #if !defined(__aarch64__) || defined(__AARCH64EB__)
3038 #error FOO
3039 #endif
3040 }]
3041 }
3042
3043 # Return 1 if this is a compiler supporting ARC atomic operations
3044 proc check_effective_target_arc_atomic { } {
3045 return [check_no_compiler_messages arc_atomic assembly {
3046 #if !defined(__ARC_ATOMIC__)
3047 #error FOO
3048 #endif
3049 }]
3050 }
3051
3052 # Return 1 if this is an arm target using 32-bit instructions
3053 proc check_effective_target_arm32 { } {
3054 if { ![istarget arm*-*-*] } {
3055 return 0
3056 }
3057
3058 return [check_no_compiler_messages arm32 assembly {
3059 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
3060 #error !__arm || __thumb__ && !__thumb2__
3061 #endif
3062 }]
3063 }
3064
3065 # Return 1 if this is an arm target not using Thumb
3066 proc check_effective_target_arm_nothumb { } {
3067 if { ![istarget arm*-*-*] } {
3068 return 0
3069 }
3070
3071 return [check_no_compiler_messages arm_nothumb assembly {
3072 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
3073 #error !__arm__ || __thumb || __thumb2__
3074 #endif
3075 }]
3076 }
3077
3078 # Return 1 if this is a little-endian ARM target
3079 proc check_effective_target_arm_little_endian { } {
3080 if { ![istarget arm*-*-*] } {
3081 return 0
3082 }
3083
3084 return [check_no_compiler_messages arm_little_endian assembly {
3085 #if !defined(__arm__) || !defined(__ARMEL__)
3086 #error !__arm__ || !__ARMEL__
3087 #endif
3088 }]
3089 }
3090
3091 # Return 1 if this is an ARM target that only supports aligned vector accesses
3092 proc check_effective_target_arm_vect_no_misalign { } {
3093 if { ![istarget arm*-*-*] } {
3094 return 0
3095 }
3096
3097 return [check_no_compiler_messages arm_vect_no_misalign assembly {
3098 #if !defined(__arm__) \
3099 || (defined(__ARM_FEATURE_UNALIGNED) \
3100 && defined(__ARMEL__))
3101 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
3102 #endif
3103 }]
3104 }
3105
3106
3107 # Return 1 if this is an ARM target supporting -mfpu=vfp
3108 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
3109 # options.
3110
3111 proc check_effective_target_arm_vfp_ok { } {
3112 if { [check_effective_target_arm32] } {
3113 return [check_no_compiler_messages arm_vfp_ok object {
3114 int dummy;
3115 } "-mfpu=vfp -mfloat-abi=softfp"]
3116 } else {
3117 return 0
3118 }
3119 }
3120
3121 # Return 1 if this is an ARM target supporting -mfpu=vfp3
3122 # -mfloat-abi=softfp.
3123
3124 proc check_effective_target_arm_vfp3_ok { } {
3125 if { [check_effective_target_arm32] } {
3126 return [check_no_compiler_messages arm_vfp3_ok object {
3127 int dummy;
3128 } "-mfpu=vfp3 -mfloat-abi=softfp"]
3129 } else {
3130 return 0
3131 }
3132 }
3133
3134 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
3135 # -mfloat-abi=softfp.
3136 proc check_effective_target_arm_v8_vfp_ok {} {
3137 if { [check_effective_target_arm32] } {
3138 return [check_no_compiler_messages arm_v8_vfp_ok object {
3139 int foo (void)
3140 {
3141 __asm__ volatile ("vrinta.f32.f32 s0, s0");
3142 return 0;
3143 }
3144 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
3145 } else {
3146 return 0
3147 }
3148 }
3149
3150 # Return 1 if this is an ARM target supporting -mfpu=vfp
3151 # -mfloat-abi=hard. Some multilibs may be incompatible with these
3152 # options.
3153
3154 proc check_effective_target_arm_hard_vfp_ok { } {
3155 if { [check_effective_target_arm32]
3156 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
3157 return [check_no_compiler_messages arm_hard_vfp_ok executable {
3158 int main() { return 0;}
3159 } "-mfpu=vfp -mfloat-abi=hard"]
3160 } else {
3161 return 0
3162 }
3163 }
3164
3165 # Return 1 if this is an ARM target defining __ARM_FP. We may need
3166 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3167 # incompatible with these options. Also set et_arm_fp_flags to the
3168 # best options to add.
3169
3170 proc check_effective_target_arm_fp_ok_nocache { } {
3171 global et_arm_fp_flags
3172 set et_arm_fp_flags ""
3173 if { [check_effective_target_arm32] } {
3174 foreach flags {"" "-mfloat-abi=softfp" "-mfloat-abi=hard"} {
3175 if { [check_no_compiler_messages_nocache arm_fp_ok object {
3176 #ifndef __ARM_FP
3177 #error __ARM_FP not defined
3178 #endif
3179 } "$flags"] } {
3180 set et_arm_fp_flags $flags
3181 return 1
3182 }
3183 }
3184 }
3185
3186 return 0
3187 }
3188
3189 proc check_effective_target_arm_fp_ok { } {
3190 return [check_cached_effective_target arm_fp_ok \
3191 check_effective_target_arm_fp_ok_nocache]
3192 }
3193
3194 # Add the options needed to define __ARM_FP. We need either
3195 # -mfloat-abi=softfp or -mfloat-abi=hard, but if one is already
3196 # specified by the multilib, use it.
3197
3198 proc add_options_for_arm_fp { flags } {
3199 if { ! [check_effective_target_arm_fp_ok] } {
3200 return "$flags"
3201 }
3202 global et_arm_fp_flags
3203 return "$flags $et_arm_fp_flags"
3204 }
3205
3206 # Return 1 if this is an ARM target that supports DSP multiply with
3207 # current multilib flags.
3208
3209 proc check_effective_target_arm_dsp { } {
3210 return [check_no_compiler_messages arm_dsp assembly {
3211 #ifndef __ARM_FEATURE_DSP
3212 #error not DSP
3213 #endif
3214 int i;
3215 }]
3216 }
3217
3218 # Return 1 if this is an ARM target that supports unaligned word/halfword
3219 # load/store instructions.
3220
3221 proc check_effective_target_arm_unaligned { } {
3222 return [check_no_compiler_messages arm_unaligned assembly {
3223 #ifndef __ARM_FEATURE_UNALIGNED
3224 #error no unaligned support
3225 #endif
3226 int i;
3227 }]
3228 }
3229
3230 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
3231 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3232 # incompatible with these options. Also set et_arm_crypto_flags to the
3233 # best options to add.
3234
3235 proc check_effective_target_arm_crypto_ok_nocache { } {
3236 global et_arm_crypto_flags
3237 set et_arm_crypto_flags ""
3238 if { [check_effective_target_arm_v8_neon_ok] } {
3239 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
3240 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
3241 #include "arm_neon.h"
3242 uint8x16_t
3243 foo (uint8x16_t a, uint8x16_t b)
3244 {
3245 return vaeseq_u8 (a, b);
3246 }
3247 } "$flags"] } {
3248 set et_arm_crypto_flags $flags
3249 return 1
3250 }
3251 }
3252 }
3253
3254 return 0
3255 }
3256
3257 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
3258
3259 proc check_effective_target_arm_crypto_ok { } {
3260 return [check_cached_effective_target arm_crypto_ok \
3261 check_effective_target_arm_crypto_ok_nocache]
3262 }
3263
3264 # Add options for crypto extensions.
3265 proc add_options_for_arm_crypto { flags } {
3266 if { ! [check_effective_target_arm_crypto_ok] } {
3267 return "$flags"
3268 }
3269 global et_arm_crypto_flags
3270 return "$flags $et_arm_crypto_flags"
3271 }
3272
3273 # Add the options needed for NEON. We need either -mfloat-abi=softfp
3274 # or -mfloat-abi=hard, but if one is already specified by the
3275 # multilib, use it. Similarly, if a -mfpu option already enables
3276 # NEON, do not add -mfpu=neon.
3277
3278 proc add_options_for_arm_neon { flags } {
3279 if { ! [check_effective_target_arm_neon_ok] } {
3280 return "$flags"
3281 }
3282 global et_arm_neon_flags
3283 return "$flags $et_arm_neon_flags"
3284 }
3285
3286 proc add_options_for_arm_v8_vfp { flags } {
3287 if { ! [check_effective_target_arm_v8_vfp_ok] } {
3288 return "$flags"
3289 }
3290 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
3291 }
3292
3293 proc add_options_for_arm_v8_neon { flags } {
3294 if { ! [check_effective_target_arm_v8_neon_ok] } {
3295 return "$flags"
3296 }
3297 global et_arm_v8_neon_flags
3298 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
3299 }
3300
3301 # Add the options needed for ARMv8.1 Adv.SIMD. Also adds the ARMv8 NEON
3302 # options for AArch64 and for ARM.
3303
3304 proc add_options_for_arm_v8_1a_neon { flags } {
3305 if { ! [check_effective_target_arm_v8_1a_neon_ok] } {
3306 return "$flags"
3307 }
3308 global et_arm_v8_1a_neon_flags
3309 return "$flags $et_arm_v8_1a_neon_flags -march=armv8.1-a"
3310 }
3311
3312 # Add the options needed for ARMv8.2 with the scalar FP16 extension.
3313 # Also adds the ARMv8 FP options for ARM and for AArch64.
3314
3315 proc add_options_for_arm_v8_2a_fp16_scalar { flags } {
3316 if { ! [check_effective_target_arm_v8_2a_fp16_scalar_ok] } {
3317 return "$flags"
3318 }
3319 global et_arm_v8_2a_fp16_scalar_flags
3320 return "$flags $et_arm_v8_2a_fp16_scalar_flags"
3321 }
3322
3323 # Add the options needed for ARMv8.2 with the FP16 extension. Also adds
3324 # the ARMv8 NEON options for ARM and for AArch64.
3325
3326 proc add_options_for_arm_v8_2a_fp16_neon { flags } {
3327 if { ! [check_effective_target_arm_v8_2a_fp16_neon_ok] } {
3328 return "$flags"
3329 }
3330 global et_arm_v8_2a_fp16_neon_flags
3331 return "$flags $et_arm_v8_2a_fp16_neon_flags"
3332 }
3333
3334 proc add_options_for_arm_crc { flags } {
3335 if { ! [check_effective_target_arm_crc_ok] } {
3336 return "$flags"
3337 }
3338 global et_arm_crc_flags
3339 return "$flags $et_arm_crc_flags"
3340 }
3341
3342 # Add the options needed for NEON. We need either -mfloat-abi=softfp
3343 # or -mfloat-abi=hard, but if one is already specified by the
3344 # multilib, use it. Similarly, if a -mfpu option already enables
3345 # NEON, do not add -mfpu=neon.
3346
3347 proc add_options_for_arm_neonv2 { flags } {
3348 if { ! [check_effective_target_arm_neonv2_ok] } {
3349 return "$flags"
3350 }
3351 global et_arm_neonv2_flags
3352 return "$flags $et_arm_neonv2_flags"
3353 }
3354
3355 # Add the options needed for vfp3.
3356 proc add_options_for_arm_vfp3 { flags } {
3357 if { ! [check_effective_target_arm_vfp3_ok] } {
3358 return "$flags"
3359 }
3360 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
3361 }
3362
3363 # Return 1 if this is an ARM target supporting -mfpu=neon
3364 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3365 # incompatible with these options. Also set et_arm_neon_flags to the
3366 # best options to add.
3367
3368 proc check_effective_target_arm_neon_ok_nocache { } {
3369 global et_arm_neon_flags
3370 set et_arm_neon_flags ""
3371 if { [check_effective_target_arm32] } {
3372 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp" "-mfpu=neon -mfloat-abi=softfp -march=armv7-a"} {
3373 if { [check_no_compiler_messages_nocache arm_neon_ok object {
3374 int dummy;
3375 #ifndef __ARM_NEON__
3376 #error not NEON
3377 #endif
3378 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
3379 configured for -mcpu=arm926ej-s, for example. */
3380 #if __ARM_ARCH < 7 || __ARM_ARCH_PROFILE == 'M'
3381 #error Architecture does not support NEON.
3382 #endif
3383 } "$flags"] } {
3384 set et_arm_neon_flags $flags
3385 return 1
3386 }
3387 }
3388 }
3389
3390 return 0
3391 }
3392
3393 proc check_effective_target_arm_neon_ok { } {
3394 return [check_cached_effective_target arm_neon_ok \
3395 check_effective_target_arm_neon_ok_nocache]
3396 }
3397
3398 proc check_effective_target_arm_crc_ok_nocache { } {
3399 global et_arm_crc_flags
3400 set et_arm_crc_flags "-march=armv8-a+crc"
3401 return [check_no_compiler_messages_nocache arm_crc_ok object {
3402 #if !defined (__ARM_FEATURE_CRC32)
3403 #error FOO
3404 #endif
3405 } "$et_arm_crc_flags"]
3406 }
3407
3408 proc check_effective_target_arm_crc_ok { } {
3409 return [check_cached_effective_target arm_crc_ok \
3410 check_effective_target_arm_crc_ok_nocache]
3411 }
3412
3413 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
3414 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3415 # incompatible with these options. Also set et_arm_neon_fp16_flags to
3416 # the best options to add.
3417
3418 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
3419 global et_arm_neon_fp16_flags
3420 global et_arm_neon_flags
3421 set et_arm_neon_fp16_flags ""
3422 if { [check_effective_target_arm32]
3423 && [check_effective_target_arm_neon_ok] } {
3424 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3425 "-mfpu=neon-fp16 -mfloat-abi=softfp"
3426 "-mfp16-format=ieee"
3427 "-mfloat-abi=softfp -mfp16-format=ieee"
3428 "-mfpu=neon-fp16 -mfp16-format=ieee"
3429 "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
3430 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
3431 #include "arm_neon.h"
3432 float16x4_t
3433 foo (float32x4_t arg)
3434 {
3435 return vcvt_f16_f32 (arg);
3436 }
3437 } "$et_arm_neon_flags $flags"] } {
3438 set et_arm_neon_fp16_flags [concat $et_arm_neon_flags $flags]
3439 return 1
3440 }
3441 }
3442 }
3443
3444 return 0
3445 }
3446
3447 proc check_effective_target_arm_neon_fp16_ok { } {
3448 return [check_cached_effective_target arm_neon_fp16_ok \
3449 check_effective_target_arm_neon_fp16_ok_nocache]
3450 }
3451
3452 proc check_effective_target_arm_neon_fp16_hw { } {
3453 if {! [check_effective_target_arm_neon_fp16_ok] } {
3454 return 0
3455 }
3456 global et_arm_neon_fp16_flags
3457 check_runtime_nocache arm_neon_fp16_hw {
3458 int
3459 main (int argc, char **argv)
3460 {
3461 asm ("vcvt.f32.f16 q1, d0");
3462 return 0;
3463 }
3464 } $et_arm_neon_fp16_flags
3465 }
3466
3467 proc add_options_for_arm_neon_fp16 { flags } {
3468 if { ! [check_effective_target_arm_neon_fp16_ok] } {
3469 return "$flags"
3470 }
3471 global et_arm_neon_fp16_flags
3472 return "$flags $et_arm_neon_fp16_flags"
3473 }
3474
3475 # Return 1 if this is an ARM target supporting the FP16 alternative
3476 # format. Some multilibs may be incompatible with the options needed. Also
3477 # set et_arm_neon_fp16_flags to the best options to add.
3478
3479 proc check_effective_target_arm_fp16_alternative_ok_nocache { } {
3480 global et_arm_neon_fp16_flags
3481 set et_arm_neon_fp16_flags ""
3482 if { [check_effective_target_arm32] } {
3483 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3484 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
3485 if { [check_no_compiler_messages_nocache \
3486 arm_fp16_alternative_ok object {
3487 #if !defined (__ARM_FP16_FORMAT_ALTERNATIVE)
3488 #error __ARM_FP16_FORMAT_ALTERNATIVE not defined
3489 #endif
3490 } "$flags -mfp16-format=alternative"] } {
3491 set et_arm_neon_fp16_flags "$flags -mfp16-format=alternative"
3492 return 1
3493 }
3494 }
3495 }
3496
3497 return 0
3498 }
3499
3500 proc check_effective_target_arm_fp16_alternative_ok { } {
3501 return [check_cached_effective_target arm_fp16_alternative_ok \
3502 check_effective_target_arm_fp16_alternative_ok_nocache]
3503 }
3504
3505 # Return 1 if this is an ARM target supports specifying the FP16 none
3506 # format. Some multilibs may be incompatible with the options needed.
3507
3508 proc check_effective_target_arm_fp16_none_ok_nocache { } {
3509 if { [check_effective_target_arm32] } {
3510 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
3511 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
3512 if { [check_no_compiler_messages_nocache \
3513 arm_fp16_none_ok object {
3514 #if defined (__ARM_FP16_FORMAT_ALTERNATIVE)
3515 #error __ARM_FP16_FORMAT_ALTERNATIVE defined
3516 #endif
3517 #if defined (__ARM_FP16_FORMAT_IEEE)
3518 #error __ARM_FP16_FORMAT_IEEE defined
3519 #endif
3520 } "$flags -mfp16-format=none"] } {
3521 return 1
3522 }
3523 }
3524 }
3525
3526 return 0
3527 }
3528
3529 proc check_effective_target_arm_fp16_none_ok { } {
3530 return [check_cached_effective_target arm_fp16_none_ok \
3531 check_effective_target_arm_fp16_none_ok_nocache]
3532 }
3533
3534 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
3535 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3536 # incompatible with these options. Also set et_arm_v8_neon_flags to the
3537 # best options to add.
3538
3539 proc check_effective_target_arm_v8_neon_ok_nocache { } {
3540 global et_arm_v8_neon_flags
3541 set et_arm_v8_neon_flags ""
3542 if { [check_effective_target_arm32] } {
3543 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3544 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
3545 #if __ARM_ARCH < 8
3546 #error not armv8 or later
3547 #endif
3548 #include "arm_neon.h"
3549 void
3550 foo ()
3551 {
3552 __asm__ volatile ("vrintn.f32 q0, q0");
3553 }
3554 } "$flags -march=armv8-a"] } {
3555 set et_arm_v8_neon_flags $flags
3556 return 1
3557 }
3558 }
3559 }
3560
3561 return 0
3562 }
3563
3564 proc check_effective_target_arm_v8_neon_ok { } {
3565 return [check_cached_effective_target arm_v8_neon_ok \
3566 check_effective_target_arm_v8_neon_ok_nocache]
3567 }
3568
3569 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
3570 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3571 # incompatible with these options. Also set et_arm_neonv2_flags to the
3572 # best options to add.
3573
3574 proc check_effective_target_arm_neonv2_ok_nocache { } {
3575 global et_arm_neonv2_flags
3576 global et_arm_neon_flags
3577 set et_arm_neonv2_flags ""
3578 if { [check_effective_target_arm32]
3579 && [check_effective_target_arm_neon_ok] } {
3580 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
3581 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
3582 #include "arm_neon.h"
3583 float32x2_t
3584 foo (float32x2_t a, float32x2_t b, float32x2_t c)
3585 {
3586 return vfma_f32 (a, b, c);
3587 }
3588 } "$et_arm_neon_flags $flags"] } {
3589 set et_arm_neonv2_flags [concat $et_arm_neon_flags $flags]
3590 return 1
3591 }
3592 }
3593 }
3594
3595 return 0
3596 }
3597
3598 proc check_effective_target_arm_neonv2_ok { } {
3599 return [check_cached_effective_target arm_neonv2_ok \
3600 check_effective_target_arm_neonv2_ok_nocache]
3601 }
3602
3603 # Add the options needed for VFP FP16 support. We need either
3604 # -mfloat-abi=softfp or -mfloat-abi=hard. If one is already specified by
3605 # the multilib, use it.
3606
3607 proc add_options_for_arm_fp16 { flags } {
3608 if { ! [check_effective_target_arm_fp16_ok] } {
3609 return "$flags"
3610 }
3611 global et_arm_fp16_flags
3612 return "$flags $et_arm_fp16_flags"
3613 }
3614
3615 # Add the options needed to enable support for IEEE format
3616 # half-precision support. This is valid for ARM targets.
3617
3618 proc add_options_for_arm_fp16_ieee { flags } {
3619 if { ! [check_effective_target_arm_fp16_ok] } {
3620 return "$flags"
3621 }
3622 global et_arm_fp16_flags
3623 return "$flags $et_arm_fp16_flags -mfp16-format=ieee"
3624 }
3625
3626 # Add the options needed to enable support for ARM Alternative format
3627 # half-precision support. This is valid for ARM targets.
3628
3629 proc add_options_for_arm_fp16_alternative { flags } {
3630 if { ! [check_effective_target_arm_fp16_ok] } {
3631 return "$flags"
3632 }
3633 global et_arm_fp16_flags
3634 return "$flags $et_arm_fp16_flags -mfp16-format=alternative"
3635 }
3636
3637 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
3638 # Skip multilibs that are incompatible with these options and set
3639 # et_arm_fp16_flags to the best options to add. This test is valid for
3640 # ARM only.
3641
3642 proc check_effective_target_arm_fp16_ok_nocache { } {
3643 global et_arm_fp16_flags
3644 set et_arm_fp16_flags ""
3645 if { ! [check_effective_target_arm32] } {
3646 return 0;
3647 }
3648 if [check-flags \
3649 [list "" { *-*-* } { "-mfpu=*" } \
3650 { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" \
3651 "-mfpu=*fpv[1-9][0-9]*" "-mfpu=*fp-armv8*" } ]] {
3652 # Multilib flags would override -mfpu.
3653 return 0
3654 }
3655 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
3656 # Must generate floating-point instructions.
3657 return 0
3658 }
3659 if [check_effective_target_arm_hf_eabi] {
3660 # Use existing float-abi and force an fpu which supports fp16
3661 set et_arm_fp16_flags "-mfpu=vfpv4"
3662 return 1;
3663 }
3664 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
3665 # The existing -mfpu value is OK; use it, but add softfp.
3666 set et_arm_fp16_flags "-mfloat-abi=softfp"
3667 return 1;
3668 }
3669 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
3670 # macro to check for this support.
3671 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
3672 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
3673 int dummy;
3674 } "$flags"] } {
3675 set et_arm_fp16_flags "$flags"
3676 return 1
3677 }
3678
3679 return 0
3680 }
3681
3682 proc check_effective_target_arm_fp16_ok { } {
3683 return [check_cached_effective_target arm_fp16_ok \
3684 check_effective_target_arm_fp16_ok_nocache]
3685 }
3686
3687 # Return 1 if the target supports executing VFP FP16 instructions, 0
3688 # otherwise. This test is valid for ARM only.
3689
3690 proc check_effective_target_arm_fp16_hw { } {
3691 if {! [check_effective_target_arm_fp16_ok] } {
3692 return 0
3693 }
3694 global et_arm_fp16_flags
3695 check_runtime_nocache arm_fp16_hw {
3696 int
3697 main (int argc, char **argv)
3698 {
3699 __fp16 a = 1.0;
3700 float r;
3701 asm ("vcvtb.f32.f16 %0, %1"
3702 : "=w" (r) : "w" (a)
3703 : /* No clobbers. */);
3704 return (r == 1.0) ? 0 : 1;
3705 }
3706 } "$et_arm_fp16_flags -mfp16-format=ieee"
3707 }
3708
3709 # Creates a series of routines that return 1 if the given architecture
3710 # can be selected and a routine to give the flags to select that architecture
3711 # Note: Extra flags may be added to disable options from newer compilers
3712 # (Thumb in particular - but others may be added in the future).
3713 # -march=armv7ve is special and is handled explicitly after this loop because
3714 # it needs more than one predefine check to identify.
3715 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
3716 # /* { dg-add-options arm_arch_v5 } */
3717 # /* { dg-require-effective-target arm_arch_v5_multilib } */
3718 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
3719 v4t "-march=armv4t" __ARM_ARCH_4T__
3720 v5 "-march=armv5 -marm" __ARM_ARCH_5__
3721 v5t "-march=armv5t" __ARM_ARCH_5T__
3722 v5te "-march=armv5te" __ARM_ARCH_5TE__
3723 v6 "-march=armv6" __ARM_ARCH_6__
3724 v6k "-march=armv6k" __ARM_ARCH_6K__
3725 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
3726 v6z "-march=armv6z" __ARM_ARCH_6Z__
3727 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
3728 v7a "-march=armv7-a" __ARM_ARCH_7A__
3729 v7r "-march=armv7-r" __ARM_ARCH_7R__
3730 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
3731 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
3732 v8a "-march=armv8-a" __ARM_ARCH_8A__
3733 v8_1a "-march=armv8.1a" __ARM_ARCH_8A__
3734 v8_2a "-march=armv8.2a" __ARM_ARCH_8A__
3735 v8m_base "-march=armv8-m.base -mthumb" __ARM_ARCH_8M_BASE__
3736 v8m_main "-march=armv8-m.main -mthumb" __ARM_ARCH_8M_MAIN__ } {
3737 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
3738 proc check_effective_target_arm_arch_FUNC_ok { } {
3739 if { [ string match "*-marm*" "FLAG" ] &&
3740 ![check_effective_target_arm_arm_ok] } {
3741 return 0
3742 }
3743 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
3744 #if !defined (DEF)
3745 #error !DEF
3746 #endif
3747 } "FLAG" ]
3748 }
3749
3750 proc add_options_for_arm_arch_FUNC { flags } {
3751 return "$flags FLAG"
3752 }
3753
3754 proc check_effective_target_arm_arch_FUNC_multilib { } {
3755 return [check_runtime arm_arch_FUNC_multilib {
3756 int
3757 main (void)
3758 {
3759 return 0;
3760 }
3761 } [add_options_for_arm_arch_FUNC ""]]
3762 }
3763 }]
3764 }
3765
3766 # Same functions as above but for -march=armv7ve. To uniquely identify
3767 # -march=armv7ve we need to check for __ARM_ARCH_7A__ as well as
3768 # __ARM_FEATURE_IDIV otherwise it aliases with armv7-a.
3769
3770 proc check_effective_target_arm_arch_v7ve_ok { } {
3771 if { [ string match "*-marm*" "-march=armv7ve" ] &&
3772 ![check_effective_target_arm_arm_ok] } {
3773 return 0
3774 }
3775 return [check_no_compiler_messages arm_arch_v7ve_ok assembly {
3776 #if !defined (__ARM_ARCH_7A__) || !defined (__ARM_FEATURE_IDIV)
3777 #error !armv7ve
3778 #endif
3779 } "-march=armv7ve" ]
3780 }
3781
3782 proc add_options_for_arm_arch_v7ve { flags } {
3783 return "$flags -march=armv7ve"
3784 }
3785
3786 # Return 1 if this is an ARM target where -marm causes ARM to be
3787 # used (not Thumb)
3788
3789 proc check_effective_target_arm_arm_ok { } {
3790 return [check_no_compiler_messages arm_arm_ok assembly {
3791 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
3792 #error !__arm__ || __thumb__ || __thumb2__
3793 #endif
3794 } "-marm"]
3795 }
3796
3797
3798 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
3799 # used.
3800
3801 proc check_effective_target_arm_thumb1_ok { } {
3802 return [check_no_compiler_messages arm_thumb1_ok assembly {
3803 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3804 #error !__arm__ || !__thumb__ || __thumb2__
3805 #endif
3806 int foo (int i) { return i; }
3807 } "-mthumb"]
3808 }
3809
3810 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
3811 # used.
3812
3813 proc check_effective_target_arm_thumb2_ok { } {
3814 return [check_no_compiler_messages arm_thumb2_ok assembly {
3815 #if !defined(__thumb2__)
3816 #error !__thumb2__
3817 #endif
3818 int foo (int i) { return i; }
3819 } "-mthumb"]
3820 }
3821
3822 # Return 1 if this is an ARM target where Thumb-1 is used without options
3823 # added by the test.
3824
3825 proc check_effective_target_arm_thumb1 { } {
3826 return [check_no_compiler_messages arm_thumb1 assembly {
3827 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3828 #error !__arm__ || !__thumb__ || __thumb2__
3829 #endif
3830 int i;
3831 } ""]
3832 }
3833
3834 # Return 1 if this is an ARM target where Thumb-2 is used without options
3835 # added by the test.
3836
3837 proc check_effective_target_arm_thumb2 { } {
3838 return [check_no_compiler_messages arm_thumb2 assembly {
3839 #if !defined(__thumb2__)
3840 #error !__thumb2__
3841 #endif
3842 int i;
3843 } ""]
3844 }
3845
3846 # Return 1 if this is an ARM target where conditional execution is available.
3847
3848 proc check_effective_target_arm_cond_exec { } {
3849 return [check_no_compiler_messages arm_cond_exec assembly {
3850 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
3851 #error FOO
3852 #endif
3853 int i;
3854 } ""]
3855 }
3856
3857 # Return 1 if this is an ARM cortex-M profile cpu
3858
3859 proc check_effective_target_arm_cortex_m { } {
3860 if { ![istarget arm*-*-*] } {
3861 return 0
3862 }
3863 return [check_no_compiler_messages arm_cortex_m assembly {
3864 #if defined(__ARM_ARCH_ISA_ARM)
3865 #error __ARM_ARCH_ISA_ARM is defined
3866 #endif
3867 int i;
3868 } "-mthumb"]
3869 }
3870
3871 # Return 1 if this is an ARM target where -mthumb causes Thumb-1 to be
3872 # used and MOVT/MOVW instructions to be available.
3873
3874 proc check_effective_target_arm_thumb1_movt_ok {} {
3875 if [check_effective_target_arm_thumb1_ok] {
3876 return [check_no_compiler_messages arm_movt object {
3877 int
3878 foo (void)
3879 {
3880 asm ("movt r0, #42");
3881 }
3882 } "-mthumb"]
3883 } else {
3884 return 0
3885 }
3886 }
3887
3888 # Return 1 if this is an ARM target where -mthumb causes Thumb-1 to be
3889 # used and CBZ and CBNZ instructions are available.
3890
3891 proc check_effective_target_arm_thumb1_cbz_ok {} {
3892 if [check_effective_target_arm_thumb1_ok] {
3893 return [check_no_compiler_messages arm_movt object {
3894 int
3895 foo (void)
3896 {
3897 asm ("cbz r0, 2f\n2:");
3898 }
3899 } "-mthumb"]
3900 } else {
3901 return 0
3902 }
3903 }
3904
3905 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3906
3907 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3908 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3909 int foo (void) { return 0; }
3910 } "-O2 -mprint-tune-info" ]
3911 }
3912
3913 # Return 1 if the target supports executing NEON instructions, 0
3914 # otherwise. Cache the result.
3915
3916 proc check_effective_target_arm_neon_hw { } {
3917 return [check_runtime arm_neon_hw_available {
3918 int
3919 main (void)
3920 {
3921 long long a = 0, b = 1;
3922 asm ("vorr %P0, %P1, %P2"
3923 : "=w" (a)
3924 : "0" (a), "w" (b));
3925 return (a != 1);
3926 }
3927 } [add_options_for_arm_neon ""]]
3928 }
3929
3930 proc check_effective_target_arm_neonv2_hw { } {
3931 return [check_runtime arm_neon_hwv2_available {
3932 #include "arm_neon.h"
3933 int
3934 main (void)
3935 {
3936 float32x2_t a, b, c;
3937 asm ("vfma.f32 %P0, %P1, %P2"
3938 : "=w" (a)
3939 : "w" (b), "w" (c));
3940 return 0;
3941 }
3942 } [add_options_for_arm_neonv2 ""]]
3943 }
3944
3945 # Return 1 if the target supports the ARMv8.1 Adv.SIMD extension, 0
3946 # otherwise. The test is valid for AArch64 and ARM. Record the command
3947 # line options needed.
3948
3949 proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
3950 global et_arm_v8_1a_neon_flags
3951 set et_arm_v8_1a_neon_flags ""
3952
3953 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3954 return 0;
3955 }
3956
3957 # Iterate through sets of options to find the compiler flags that
3958 # need to be added to the -march option. Start with the empty set
3959 # since AArch64 only needs the -march setting.
3960 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
3961 "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3962 if { [check_no_compiler_messages_nocache arm_v8_1a_neon_ok object {
3963 #if !defined (__ARM_FEATURE_QRDMX)
3964 #error "__ARM_FEATURE_QRDMX not defined"
3965 #endif
3966 } "$flags -march=armv8.1-a"] } {
3967 set et_arm_v8_1a_neon_flags "$flags -march=armv8.1-a"
3968 return 1
3969 }
3970 }
3971
3972 return 0;
3973 }
3974
3975 proc check_effective_target_arm_v8_1a_neon_ok { } {
3976 return [check_cached_effective_target arm_v8_1a_neon_ok \
3977 check_effective_target_arm_v8_1a_neon_ok_nocache]
3978 }
3979
3980 # Return 1 if the target supports ARMv8.2 scalar FP16 arithmetic
3981 # instructions, 0 otherwise. The test is valid for ARM and for AArch64.
3982 # Record the command line options needed.
3983
3984 proc check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
3985 global et_arm_v8_2a_fp16_scalar_flags
3986 set et_arm_v8_2a_fp16_scalar_flags ""
3987
3988 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3989 return 0;
3990 }
3991
3992 # Iterate through sets of options to find the compiler flags that
3993 # need to be added to the -march option.
3994 foreach flags {"" "-mfpu=fp-armv8" "-mfloat-abi=softfp" \
3995 "-mfpu=fp-armv8 -mfloat-abi=softfp"} {
3996 if { [check_no_compiler_messages_nocache \
3997 arm_v8_2a_fp16_scalar_ok object {
3998 #if !defined (__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
3999 #error "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined"
4000 #endif
4001 } "$flags -march=armv8.2-a+fp16"] } {
4002 set et_arm_v8_2a_fp16_scalar_flags "$flags -march=armv8.2-a+fp16"
4003 return 1
4004 }
4005 }
4006
4007 return 0;
4008 }
4009
4010 proc check_effective_target_arm_v8_2a_fp16_scalar_ok { } {
4011 return [check_cached_effective_target arm_v8_2a_fp16_scalar_ok \
4012 check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache]
4013 }
4014
4015 # Return 1 if the target supports ARMv8.2 Adv.SIMD FP16 arithmetic
4016 # instructions, 0 otherwise. The test is valid for ARM and for AArch64.
4017 # Record the command line options needed.
4018
4019 proc check_effective_target_arm_v8_2a_fp16_neon_ok_nocache { } {
4020 global et_arm_v8_2a_fp16_neon_flags
4021 set et_arm_v8_2a_fp16_neon_flags ""
4022
4023 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
4024 return 0;
4025 }
4026
4027 # Iterate through sets of options to find the compiler flags that
4028 # need to be added to the -march option.
4029 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
4030 "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
4031 if { [check_no_compiler_messages_nocache \
4032 arm_v8_2a_fp16_neon_ok object {
4033 #if !defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
4034 #error "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined"
4035 #endif
4036 } "$flags -march=armv8.2-a+fp16"] } {
4037 set et_arm_v8_2a_fp16_neon_flags "$flags -march=armv8.2-a+fp16"
4038 return 1
4039 }
4040 }
4041
4042 return 0;
4043 }
4044
4045 proc check_effective_target_arm_v8_2a_fp16_neon_ok { } {
4046 return [check_cached_effective_target arm_v8_2a_fp16_neon_ok \
4047 check_effective_target_arm_v8_2a_fp16_neon_ok_nocache]
4048 }
4049
4050 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
4051 # otherwise.
4052
4053 proc check_effective_target_arm_v8_neon_hw { } {
4054 return [check_runtime arm_v8_neon_hw_available {
4055 #include "arm_neon.h"
4056 int
4057 main (void)
4058 {
4059 float32x2_t a = { 1.0f, 2.0f };
4060 #ifdef __ARM_ARCH_ISA_A64
4061 asm ("frinta %0.2s, %1.2s"
4062 : "=w" (a)
4063 : "w" (a));
4064 #else
4065 asm ("vrinta.f32 %P0, %P1"
4066 : "=w" (a)
4067 : "0" (a));
4068 #endif
4069 return a[0] == 2.0f;
4070 }
4071 } [add_options_for_arm_v8_neon ""]]
4072 }
4073
4074 # Return 1 if the target supports executing the ARMv8.1 Adv.SIMD extension, 0
4075 # otherwise. The test is valid for AArch64 and ARM.
4076
4077 proc check_effective_target_arm_v8_1a_neon_hw { } {
4078 if { ![check_effective_target_arm_v8_1a_neon_ok] } {
4079 return 0;
4080 }
4081 return [check_runtime arm_v8_1a_neon_hw_available {
4082 int
4083 main (void)
4084 {
4085 #ifdef __ARM_ARCH_ISA_A64
4086 __Int32x2_t a = {0, 1};
4087 __Int32x2_t b = {0, 2};
4088 __Int32x2_t result;
4089
4090 asm ("sqrdmlah %0.2s, %1.2s, %2.2s"
4091 : "=w"(result)
4092 : "w"(a), "w"(b)
4093 : /* No clobbers. */);
4094
4095 #else
4096
4097 __simd64_int32_t a = {0, 1};
4098 __simd64_int32_t b = {0, 2};
4099 __simd64_int32_t result;
4100
4101 asm ("vqrdmlah.s32 %P0, %P1, %P2"
4102 : "=w"(result)
4103 : "w"(a), "w"(b)
4104 : /* No clobbers. */);
4105 #endif
4106
4107 return result[0];
4108 }
4109 } [add_options_for_arm_v8_1a_neon ""]]
4110 }
4111
4112 # Return 1 if the target supports executing floating point instructions from
4113 # ARMv8.2 with the FP16 extension, 0 otherwise. The test is valid for ARM and
4114 # for AArch64.
4115
4116 proc check_effective_target_arm_v8_2a_fp16_scalar_hw { } {
4117 if { ![check_effective_target_arm_v8_2a_fp16_scalar_ok] } {
4118 return 0;
4119 }
4120 return [check_runtime arm_v8_2a_fp16_scalar_hw_available {
4121 int
4122 main (void)
4123 {
4124 __fp16 a = 1.0;
4125 __fp16 result;
4126
4127 #ifdef __ARM_ARCH_ISA_A64
4128
4129 asm ("fabs %h0, %h1"
4130 : "=w"(result)
4131 : "w"(a)
4132 : /* No clobbers. */);
4133
4134 #else
4135
4136 asm ("vabs.f16 %0, %1"
4137 : "=w"(result)
4138 : "w"(a)
4139 : /* No clobbers. */);
4140
4141 #endif
4142
4143 return (result == 1.0) ? 0 : 1;
4144 }
4145 } [add_options_for_arm_v8_2a_fp16_scalar ""]]
4146 }
4147
4148 # Return 1 if the target supports executing Adv.SIMD instructions from ARMv8.2
4149 # with the FP16 extension, 0 otherwise. The test is valid for ARM and for
4150 # AArch64.
4151
4152 proc check_effective_target_arm_v8_2a_fp16_neon_hw { } {
4153 if { ![check_effective_target_arm_v8_2a_fp16_neon_ok] } {
4154 return 0;
4155 }
4156 return [check_runtime arm_v8_2a_fp16_neon_hw_available {
4157 int
4158 main (void)
4159 {
4160 #ifdef __ARM_ARCH_ISA_A64
4161
4162 __Float16x4_t a = {1.0, -1.0, 1.0, -1.0};
4163 __Float16x4_t result;
4164
4165 asm ("fabs %0.4h, %1.4h"
4166 : "=w"(result)
4167 : "w"(a)
4168 : /* No clobbers. */);
4169
4170 #else
4171
4172 __simd64_float16_t a = {1.0, -1.0, 1.0, -1.0};
4173 __simd64_float16_t result;
4174
4175 asm ("vabs.f16 %P0, %P1"
4176 : "=w"(result)
4177 : "w"(a)
4178 : /* No clobbers. */);
4179
4180 #endif
4181
4182 return (result[0] == 1.0) ? 0 : 1;
4183 }
4184 } [add_options_for_arm_v8_2a_fp16_neon ""]]
4185 }
4186
4187 # Return 1 if this is a ARM target with NEON enabled.
4188
4189 proc check_effective_target_arm_neon { } {
4190 if { [check_effective_target_arm32] } {
4191 return [check_no_compiler_messages arm_neon object {
4192 #ifndef __ARM_NEON__
4193 #error not NEON
4194 #else
4195 int dummy;
4196 #endif
4197 }]
4198 } else {
4199 return 0
4200 }
4201 }
4202
4203 proc check_effective_target_arm_neonv2 { } {
4204 if { [check_effective_target_arm32] } {
4205 return [check_no_compiler_messages arm_neon object {
4206 #ifndef __ARM_NEON__
4207 #error not NEON
4208 #else
4209 #ifndef __ARM_FEATURE_FMA
4210 #error not NEONv2
4211 #else
4212 int dummy;
4213 #endif
4214 #endif
4215 }]
4216 } else {
4217 return 0
4218 }
4219 }
4220
4221 # Return 1 if this is an ARM target with load acquire and store release
4222 # instructions for 8-, 16- and 32-bit types.
4223
4224 proc check_effective_target_arm_acq_rel { } {
4225 return [check_no_compiler_messages arm_acq_rel object {
4226 void
4227 load_acquire_store_release (void)
4228 {
4229 asm ("lda r0, [r1]\n\t"
4230 "stl r0, [r1]\n\t"
4231 "ldah r0, [r1]\n\t"
4232 "stlh r0, [r1]\n\t"
4233 "ldab r0, [r1]\n\t"
4234 "stlb r0, [r1]"
4235 : : : "r0", "memory");
4236 }
4237 }]
4238 }
4239
4240 # Add the options needed for MIPS Paired-Single.
4241
4242 proc add_options_for_mpaired_single { flags } {
4243 if { ! [check_effective_target_mpaired_single] } {
4244 return "$flags"
4245 }
4246 return "$flags -mpaired-single"
4247 }
4248
4249 # Add the options needed for MIPS SIMD Architecture.
4250
4251 proc add_options_for_mips_msa { flags } {
4252 if { ! [check_effective_target_mips_msa] } {
4253 return "$flags"
4254 }
4255 return "$flags -mmsa"
4256 }
4257
4258 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
4259 # the Loongson vector modes.
4260
4261 proc check_effective_target_mips_loongson { } {
4262 return [check_no_compiler_messages loongson assembly {
4263 #if !defined(__mips_loongson_vector_rev)
4264 #error !__mips_loongson_vector_rev
4265 #endif
4266 }]
4267 }
4268
4269 # Return 1 if this is a MIPS target that supports the legacy NAN.
4270
4271 proc check_effective_target_mips_nanlegacy { } {
4272 return [check_no_compiler_messages nanlegacy assembly {
4273 #include <stdlib.h>
4274 int main () { return 0; }
4275 } "-mnan=legacy"]
4276 }
4277
4278 # Return 1 if an MSA program can be compiled to object
4279
4280 proc check_effective_target_mips_msa { } {
4281 if ![check_effective_target_nomips16] {
4282 return 0
4283 }
4284 return [check_no_compiler_messages msa object {
4285 #if !defined(__mips_msa)
4286 #error "MSA NOT AVAIL"
4287 #else
4288 #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
4289 #error "MSA NOT AVAIL FOR ISA REV < 2"
4290 #endif
4291 #if !defined(__mips_hard_float)
4292 #error "MSA HARD_FLOAT REQUIRED"
4293 #endif
4294 #if __mips_fpr != 64
4295 #error "MSA 64-bit FPR REQUIRED"
4296 #endif
4297 #include <msa.h>
4298
4299 int main()
4300 {
4301 v8i16 v = __builtin_msa_ldi_h (1);
4302
4303 return v[0];
4304 }
4305 #endif
4306 } "-mmsa" ]
4307 }
4308
4309 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
4310 # Architecture.
4311
4312 proc check_effective_target_arm_eabi { } {
4313 return [check_no_compiler_messages arm_eabi object {
4314 #ifndef __ARM_EABI__
4315 #error not EABI
4316 #else
4317 int dummy;
4318 #endif
4319 }]
4320 }
4321
4322 # Return 1 if this is an ARM target that adheres to the hard-float variant of
4323 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
4324
4325 proc check_effective_target_arm_hf_eabi { } {
4326 return [check_no_compiler_messages arm_hf_eabi object {
4327 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
4328 #error not hard-float EABI
4329 #else
4330 int dummy;
4331 #endif
4332 }]
4333 }
4334
4335 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
4336 # Some multilibs may be incompatible with this option.
4337
4338 proc check_effective_target_arm_iwmmxt_ok { } {
4339 if { [check_effective_target_arm32] } {
4340 return [check_no_compiler_messages arm_iwmmxt_ok object {
4341 int dummy;
4342 } "-mcpu=iwmmxt"]
4343 } else {
4344 return 0
4345 }
4346 }
4347
4348 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
4349 # for an ARM target.
4350 proc check_effective_target_arm_prefer_ldrd_strd { } {
4351 if { ![check_effective_target_arm32] } {
4352 return 0;
4353 }
4354
4355 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
4356 void foo (int *p) { p[0] = 1; p[1] = 0;}
4357 } "-O2 -mthumb" ]
4358 }
4359
4360 # Return 1 if this is a PowerPC target supporting -meabi.
4361
4362 proc check_effective_target_powerpc_eabi_ok { } {
4363 if { [istarget powerpc*-*-*] } {
4364 return [check_no_compiler_messages powerpc_eabi_ok object {
4365 int dummy;
4366 } "-meabi"]
4367 } else {
4368 return 0
4369 }
4370 }
4371
4372 # Return 1 if this is a PowerPC target with floating-point registers.
4373
4374 proc check_effective_target_powerpc_fprs { } {
4375 if { [istarget powerpc*-*-*]
4376 || [istarget rs6000-*-*] } {
4377 return [check_no_compiler_messages powerpc_fprs object {
4378 #ifdef __NO_FPRS__
4379 #error no FPRs
4380 #else
4381 int dummy;
4382 #endif
4383 }]
4384 } else {
4385 return 0
4386 }
4387 }
4388
4389 # Return 1 if this is a PowerPC target with hardware double-precision
4390 # floating point.
4391
4392 proc check_effective_target_powerpc_hard_double { } {
4393 if { [istarget powerpc*-*-*]
4394 || [istarget rs6000-*-*] } {
4395 return [check_no_compiler_messages powerpc_hard_double object {
4396 #ifdef _SOFT_DOUBLE
4397 #error soft double
4398 #else
4399 int dummy;
4400 #endif
4401 }]
4402 } else {
4403 return 0
4404 }
4405 }
4406
4407 # Return 1 if this is a PowerPC target supporting -maltivec.
4408
4409 proc check_effective_target_powerpc_altivec_ok { } {
4410 if { ([istarget powerpc*-*-*]
4411 && ![istarget powerpc-*-linux*paired*])
4412 || [istarget rs6000-*-*] } {
4413 # AltiVec is not supported on AIX before 5.3.
4414 if { [istarget powerpc*-*-aix4*]
4415 || [istarget powerpc*-*-aix5.1*]
4416 || [istarget powerpc*-*-aix5.2*] } {
4417 return 0
4418 }
4419 return [check_no_compiler_messages powerpc_altivec_ok object {
4420 int dummy;
4421 } "-maltivec"]
4422 } else {
4423 return 0
4424 }
4425 }
4426
4427 # Return 1 if this is a PowerPC target supporting -mpower8-vector
4428
4429 proc check_effective_target_powerpc_p8vector_ok { } {
4430 if { ([istarget powerpc*-*-*]
4431 && ![istarget powerpc-*-linux*paired*])
4432 || [istarget rs6000-*-*] } {
4433 # AltiVec is not supported on AIX before 5.3.
4434 if { [istarget powerpc*-*-aix4*]
4435 || [istarget powerpc*-*-aix5.1*]
4436 || [istarget powerpc*-*-aix5.2*] } {
4437 return 0
4438 }
4439 return [check_no_compiler_messages powerpc_p8vector_ok object {
4440 int main (void) {
4441 #ifdef __MACH__
4442 asm volatile ("xxlorc vs0,vs0,vs0");
4443 #else
4444 asm volatile ("xxlorc 0,0,0");
4445 #endif
4446 return 0;
4447 }
4448 } "-mpower8-vector"]
4449 } else {
4450 return 0
4451 }
4452 }
4453
4454 # Return 1 if this is a PowerPC target supporting -mpower9-vector
4455
4456 proc check_effective_target_powerpc_p9vector_ok { } {
4457 if { ([istarget powerpc*-*-*]
4458 && ![istarget powerpc-*-linux*paired*])
4459 || [istarget rs6000-*-*] } {
4460 # AltiVec is not supported on AIX before 5.3.
4461 if { [istarget powerpc*-*-aix4*]
4462 || [istarget powerpc*-*-aix5.1*]
4463 || [istarget powerpc*-*-aix5.2*] } {
4464 return 0
4465 }
4466 return [check_no_compiler_messages powerpc_p9vector_ok object {
4467 int main (void) {
4468 long e = -1;
4469 vector double v = (vector double) { 0.0, 0.0 };
4470 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
4471 return e;
4472 }
4473 } "-mpower9-vector"]
4474 } else {
4475 return 0
4476 }
4477 }
4478
4479 # Return 1 if this is a PowerPC target supporting -mmodulo
4480
4481 proc check_effective_target_powerpc_p9modulo_ok { } {
4482 if { ([istarget powerpc*-*-*]
4483 && ![istarget powerpc-*-linux*paired*])
4484 || [istarget rs6000-*-*] } {
4485 # AltiVec is not supported on AIX before 5.3.
4486 if { [istarget powerpc*-*-aix4*]
4487 || [istarget powerpc*-*-aix5.1*]
4488 || [istarget powerpc*-*-aix5.2*] } {
4489 return 0
4490 }
4491 return [check_no_compiler_messages powerpc_p9modulo_ok object {
4492 int main (void) {
4493 int i = 5, j = 3, r = -1;
4494 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
4495 return (r == 2);
4496 }
4497 } "-mmodulo"]
4498 } else {
4499 return 0
4500 }
4501 }
4502
4503 # Return 1 if this is a PowerPC target supporting -mfloat128 via either
4504 # software emulation on power7/power8 systems or hardware support on power9.
4505
4506 proc check_effective_target_powerpc_float128_sw_ok { } {
4507 if { ([istarget powerpc*-*-*]
4508 && ![istarget powerpc-*-linux*paired*])
4509 || [istarget rs6000-*-*] } {
4510 # AltiVec is not supported on AIX before 5.3.
4511 if { [istarget powerpc*-*-aix4*]
4512 || [istarget powerpc*-*-aix5.1*]
4513 || [istarget powerpc*-*-aix5.2*] } {
4514 return 0
4515 }
4516 return [check_no_compiler_messages powerpc_float128_sw_ok object {
4517 volatile __float128 x = 1.0q;
4518 volatile __float128 y = 2.0q;
4519 int main() {
4520 __float128 z = x + y;
4521 return (z == 3.0q);
4522 }
4523 } "-mfloat128 -mvsx"]
4524 } else {
4525 return 0
4526 }
4527 }
4528
4529 # Return 1 if this is a PowerPC target supporting -mfloat128 via hardware
4530 # support on power9.
4531
4532 proc check_effective_target_powerpc_float128_hw_ok { } {
4533 if { ([istarget powerpc*-*-*]
4534 && ![istarget powerpc-*-linux*paired*])
4535 || [istarget rs6000-*-*] } {
4536 # AltiVec is not supported on AIX before 5.3.
4537 if { [istarget powerpc*-*-aix4*]
4538 || [istarget powerpc*-*-aix5.1*]
4539 || [istarget powerpc*-*-aix5.2*] } {
4540 return 0
4541 }
4542 return [check_no_compiler_messages powerpc_float128_hw_ok object {
4543 volatile __float128 x = 1.0q;
4544 volatile __float128 y = 2.0q;
4545 int main() {
4546 __float128 z;
4547 __asm__ ("xsaddqp %0,%1,%2" : "=v" (z) : "v" (x), "v" (y));
4548 return (z == 3.0q);
4549 }
4550 } "-mfloat128-hardware"]
4551 } else {
4552 return 0
4553 }
4554 }
4555
4556 # Return 1 if this is a PowerPC target supporting -mvsx
4557
4558 proc check_effective_target_powerpc_vsx_ok { } {
4559 if { ([istarget powerpc*-*-*]
4560 && ![istarget powerpc-*-linux*paired*])
4561 || [istarget rs6000-*-*] } {
4562 # VSX is not supported on AIX before 7.1.
4563 if { [istarget powerpc*-*-aix4*]
4564 || [istarget powerpc*-*-aix5*]
4565 || [istarget powerpc*-*-aix6*] } {
4566 return 0
4567 }
4568 return [check_no_compiler_messages powerpc_vsx_ok object {
4569 int main (void) {
4570 #ifdef __MACH__
4571 asm volatile ("xxlor vs0,vs0,vs0");
4572 #else
4573 asm volatile ("xxlor 0,0,0");
4574 #endif
4575 return 0;
4576 }
4577 } "-mvsx"]
4578 } else {
4579 return 0
4580 }
4581 }
4582
4583 # Return 1 if this is a PowerPC target supporting -mhtm
4584
4585 proc check_effective_target_powerpc_htm_ok { } {
4586 if { ([istarget powerpc*-*-*]
4587 && ![istarget powerpc-*-linux*paired*])
4588 || [istarget rs6000-*-*] } {
4589 # HTM is not supported on AIX yet.
4590 if { [istarget powerpc*-*-aix*] } {
4591 return 0
4592 }
4593 return [check_no_compiler_messages powerpc_htm_ok object {
4594 int main (void) {
4595 asm volatile ("tbegin. 0");
4596 return 0;
4597 }
4598 } "-mhtm"]
4599 } else {
4600 return 0
4601 }
4602 }
4603
4604 # Return 1 if the target supports executing HTM hardware instructions,
4605 # 0 otherwise. Cache the result.
4606
4607 proc check_htm_hw_available { } {
4608 return [check_cached_effective_target htm_hw_available {
4609 # For now, disable on Darwin
4610 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
4611 expr 0
4612 } else {
4613 check_runtime_nocache htm_hw_available {
4614 int main()
4615 {
4616 __builtin_ttest ();
4617 return 0;
4618 }
4619 } "-mhtm"
4620 }
4621 }]
4622 }
4623 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
4624
4625 proc check_effective_target_powerpc_ppu_ok { } {
4626 if [check_effective_target_powerpc_altivec_ok] {
4627 return [check_no_compiler_messages cell_asm_available object {
4628 int main (void) {
4629 #ifdef __MACH__
4630 asm volatile ("lvlx v0,v0,v0");
4631 #else
4632 asm volatile ("lvlx 0,0,0");
4633 #endif
4634 return 0;
4635 }
4636 }]
4637 } else {
4638 return 0
4639 }
4640 }
4641
4642 # Return 1 if this is a PowerPC target that supports SPU.
4643
4644 proc check_effective_target_powerpc_spu { } {
4645 if { [istarget powerpc*-*-linux*] } {
4646 return [check_effective_target_powerpc_altivec_ok]
4647 } else {
4648 return 0
4649 }
4650 }
4651
4652 # Return 1 if this is a PowerPC SPE target. The check includes options
4653 # specified by dg-options for this test, so don't cache the result.
4654
4655 proc check_effective_target_powerpc_spe_nocache { } {
4656 if { [istarget powerpc*-*-*] } {
4657 return [check_no_compiler_messages_nocache powerpc_spe object {
4658 #ifndef __SPE__
4659 #error not SPE
4660 #else
4661 int dummy;
4662 #endif
4663 } [current_compiler_flags]]
4664 } else {
4665 return 0
4666 }
4667 }
4668
4669 # Return 1 if this is a PowerPC target with SPE enabled.
4670
4671 proc check_effective_target_powerpc_spe { } {
4672 if { [istarget powerpc*-*-*] } {
4673 return [check_no_compiler_messages powerpc_spe object {
4674 #ifndef __SPE__
4675 #error not SPE
4676 #else
4677 int dummy;
4678 #endif
4679 }]
4680 } else {
4681 return 0
4682 }
4683 }
4684
4685 # Return 1 if this is a PowerPC target with Altivec enabled.
4686
4687 proc check_effective_target_powerpc_altivec { } {
4688 if { [istarget powerpc*-*-*] } {
4689 return [check_no_compiler_messages powerpc_altivec object {
4690 #ifndef __ALTIVEC__
4691 #error not Altivec
4692 #else
4693 int dummy;
4694 #endif
4695 }]
4696 } else {
4697 return 0
4698 }
4699 }
4700
4701 # Return 1 if this is a PowerPC 405 target. The check includes options
4702 # specified by dg-options for this test, so don't cache the result.
4703
4704 proc check_effective_target_powerpc_405_nocache { } {
4705 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
4706 return [check_no_compiler_messages_nocache powerpc_405 object {
4707 #ifdef __PPC405__
4708 int dummy;
4709 #else
4710 #error not a PPC405
4711 #endif
4712 } [current_compiler_flags]]
4713 } else {
4714 return 0
4715 }
4716 }
4717
4718 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
4719
4720 proc check_effective_target_powerpc_elfv2 { } {
4721 if { [istarget powerpc*-*-*] } {
4722 return [check_no_compiler_messages powerpc_elfv2 object {
4723 #if _CALL_ELF != 2
4724 #error not ELF v2 ABI
4725 #else
4726 int dummy;
4727 #endif
4728 }]
4729 } else {
4730 return 0
4731 }
4732 }
4733
4734 # Return 1 if this is a SPU target with a toolchain that
4735 # supports automatic overlay generation.
4736
4737 proc check_effective_target_spu_auto_overlay { } {
4738 if { [istarget spu*-*-elf*] } {
4739 return [check_no_compiler_messages spu_auto_overlay executable {
4740 int main (void) { }
4741 } "-Wl,--auto-overlay" ]
4742 } else {
4743 return 0
4744 }
4745 }
4746
4747 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
4748 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
4749 # test environment appears to run executables on such a simulator.
4750
4751 proc check_effective_target_ultrasparc_hw { } {
4752 return [check_runtime ultrasparc_hw {
4753 int main() { return 0; }
4754 } "-mcpu=ultrasparc"]
4755 }
4756
4757 # Return 1 if the test environment supports executing UltraSPARC VIS2
4758 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
4759
4760 proc check_effective_target_ultrasparc_vis2_hw { } {
4761 return [check_runtime ultrasparc_vis2_hw {
4762 int main() { __asm__(".word 0x81b00320"); return 0; }
4763 } "-mcpu=ultrasparc3"]
4764 }
4765
4766 # Return 1 if the test environment supports executing UltraSPARC VIS3
4767 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
4768
4769 proc check_effective_target_ultrasparc_vis3_hw { } {
4770 return [check_runtime ultrasparc_vis3_hw {
4771 int main() { __asm__(".word 0x81b00220"); return 0; }
4772 } "-mcpu=niagara3"]
4773 }
4774
4775 # Return 1 if this is a SPARC-V9 target.
4776
4777 proc check_effective_target_sparc_v9 { } {
4778 if { [istarget sparc*-*-*] } {
4779 return [check_no_compiler_messages sparc_v9 object {
4780 int main (void) {
4781 asm volatile ("return %i7+8");
4782 return 0;
4783 }
4784 }]
4785 } else {
4786 return 0
4787 }
4788 }
4789
4790 # Return 1 if this is a SPARC target with VIS enabled.
4791
4792 proc check_effective_target_sparc_vis { } {
4793 if { [istarget sparc*-*-*] } {
4794 return [check_no_compiler_messages sparc_vis object {
4795 #ifndef __VIS__
4796 #error not VIS
4797 #else
4798 int dummy;
4799 #endif
4800 }]
4801 } else {
4802 return 0
4803 }
4804 }
4805
4806 # Return 1 if the target supports hardware vector shift operation.
4807
4808 proc check_effective_target_vect_shift { } {
4809 global et_vect_shift_saved
4810 global et_index
4811
4812 if [info exists et_vect_shift_saved($et_index)] {
4813 verbose "check_effective_target_vect_shift: using cached result" 2
4814 } else {
4815 set et_vect_shift_saved($et_index) 0
4816 if { ([istarget powerpc*-*-*]
4817 && ![istarget powerpc-*-linux*paired*])
4818 || [istarget ia64-*-*]
4819 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4820 || [istarget aarch64*-*-*]
4821 || [check_effective_target_arm32]
4822 || ([istarget mips*-*-*]
4823 && ([et-is-effective-target mips_msa]
4824 || [et-is-effective-target mips_loongson])) } {
4825 set et_vect_shift_saved($et_index) 1
4826 }
4827 }
4828
4829 verbose "check_effective_target_vect_shift:\
4830 returning $et_vect_shift_saved($et_index)" 2
4831 return $et_vect_shift_saved($et_index)
4832 }
4833
4834 proc check_effective_target_whole_vector_shift { } {
4835 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4836 || [istarget ia64-*-*]
4837 || [istarget aarch64*-*-*]
4838 || [istarget powerpc64*-*-*]
4839 || ([check_effective_target_arm32]
4840 && [check_effective_target_arm_little_endian])
4841 || ([istarget mips*-*-*]
4842 && [et-is-effective-target mips_loongson]) } {
4843 set answer 1
4844 } else {
4845 set answer 0
4846 }
4847
4848 verbose "check_effective_target_vect_long: returning $answer" 2
4849 return $answer
4850 }
4851
4852 # Return 1 if the target supports vector bswap operations.
4853
4854 proc check_effective_target_vect_bswap { } {
4855 global et_vect_bswap_saved
4856 global et_index
4857
4858 if [info exists et_vect_bswap_saved($et_index)] {
4859 verbose "check_effective_target_vect_bswap: using cached result" 2
4860 } else {
4861 set et_vect_bswap_saved($et_index) 0
4862 if { [istarget aarch64*-*-*]
4863 || ([istarget arm*-*-*]
4864 && [check_effective_target_arm_neon])
4865 } {
4866 set et_vect_bswap_saved($et_index) 1
4867 }
4868 }
4869
4870 verbose "check_effective_target_vect_bswap:\
4871 returning $et_vect_bswap_saved($et_index)" 2
4872 return $et_vect_bswap_saved($et_index)
4873 }
4874
4875 # Return 1 if the target supports hardware vector shift operation for char.
4876
4877 proc check_effective_target_vect_shift_char { } {
4878 global et_vect_shift_char_saved
4879 global et_index
4880
4881 if [info exists et_vect_shift_char_saved($et_index)] {
4882 verbose "check_effective_target_vect_shift_char: using cached result" 2
4883 } else {
4884 set et_vect_shift_char_saved($et_index) 0
4885 if { ([istarget powerpc*-*-*]
4886 && ![istarget powerpc-*-linux*paired*])
4887 || [check_effective_target_arm32]
4888 || ([istarget mips*-*-*]
4889 && [et-is-effective-target mips_msa]) } {
4890 set et_vect_shift_char_saved($et_index) 1
4891 }
4892 }
4893
4894 verbose "check_effective_target_vect_shift_char:\
4895 returning $et_vect_shift_char_saved($et_index)" 2
4896 return $et_vect_shift_char_saved($et_index)
4897 }
4898
4899 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
4900 #
4901 # This can change for different subtargets so do not cache the result.
4902
4903 proc check_effective_target_vect_long { } {
4904 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4905 || (([istarget powerpc*-*-*]
4906 && ![istarget powerpc-*-linux*paired*])
4907 && [check_effective_target_ilp32])
4908 || [check_effective_target_arm32]
4909 || ([istarget sparc*-*-*] && [check_effective_target_ilp32])
4910 || [istarget aarch64*-*-*]
4911 || ([istarget mips*-*-*]
4912 && [et-is-effective-target mips_msa]) } {
4913 set answer 1
4914 } else {
4915 set answer 0
4916 }
4917
4918 verbose "check_effective_target_vect_long: returning $answer" 2
4919 return $answer
4920 }
4921
4922 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
4923 #
4924 # This won't change for different subtargets so cache the result.
4925
4926 proc check_effective_target_vect_float { } {
4927 global et_vect_float_saved
4928 global et_index
4929
4930 if [info exists et_vect_float_saved($et_index)] {
4931 verbose "check_effective_target_vect_float: using cached result" 2
4932 } else {
4933 set et_vect_float_saved($et_index) 0
4934 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4935 || [istarget powerpc*-*-*]
4936 || [istarget spu-*-*]
4937 || [istarget mips-sde-elf]
4938 || [istarget mipsisa64*-*-*]
4939 || [istarget ia64-*-*]
4940 || [istarget aarch64*-*-*]
4941 || ([istarget mips*-*-*]
4942 && [et-is-effective-target mips_msa])
4943 || [check_effective_target_arm32] } {
4944 set et_vect_float_saved($et_index) 1
4945 }
4946 }
4947
4948 verbose "check_effective_target_vect_float:\
4949 returning $et_vect_float_saved($et_index)" 2
4950 return $et_vect_float_saved($et_index)
4951 }
4952
4953 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
4954 #
4955 # This won't change for different subtargets so cache the result.
4956
4957 proc check_effective_target_vect_double { } {
4958 global et_vect_double_saved
4959 global et_index
4960
4961 if [info exists et_vect_double_saved($et_index)] {
4962 verbose "check_effective_target_vect_double: using cached result" 2
4963 } else {
4964 set et_vect_double_saved($et_index) 0
4965 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
4966 && [check_no_compiler_messages vect_double assembly {
4967 #ifdef __tune_atom__
4968 # error No double vectorizer support.
4969 #endif
4970 }])
4971 || [istarget aarch64*-*-*]
4972 || [istarget spu-*-*]
4973 || ([istarget powerpc*-*-*] && [check_vsx_hw_available])
4974 || ([istarget mips*-*-*]
4975 && [et-is-effective-target mips_msa]) } {
4976 set et_vect_double_saved($et_index) 1
4977 }
4978 }
4979
4980 verbose "check_effective_target_vect_double:\
4981 returning $et_vect_double_saved($et_index)" 2
4982 return $et_vect_double_saved($et_index)
4983 }
4984
4985 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
4986 #
4987 # This won't change for different subtargets so cache the result.
4988
4989 proc check_effective_target_vect_long_long { } {
4990 global et_vect_long_long_saved
4991 global et_index
4992
4993 if [info exists et_vect_long_long_saved($et_index)] {
4994 verbose "check_effective_target_vect_long_long: using cached result" 2
4995 } else {
4996 set et_vect_long_long_saved($et_index) 0
4997 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4998 || ([istarget mips*-*-*]
4999 && [et-is-effective-target mips_msa]) } {
5000 set et_vect_long_long_saved($et_index) 1
5001 }
5002 }
5003
5004 verbose "check_effective_target_vect_long_long:\
5005 returning $et_vect_long_long_saved($et_index)" 2
5006 return $et_vect_long_long_saved($et_index)
5007 }
5008
5009
5010 # Return 1 if the target plus current options does not support a vector
5011 # max instruction on "int", 0 otherwise.
5012 #
5013 # This won't change for different subtargets so cache the result.
5014
5015 proc check_effective_target_vect_no_int_min_max { } {
5016 global et_vect_no_int_min_max_saved
5017 global et_index
5018
5019 if [info exists et_vect_no_int_min_max_saved($et_index)] {
5020 verbose "check_effective_target_vect_no_int_min_max:\
5021 using cached result" 2
5022 } else {
5023 set et_vect_no_int_min_max_saved($et_index) 0
5024 if { [istarget sparc*-*-*]
5025 || [istarget spu-*-*]
5026 || [istarget alpha*-*-*]
5027 || ([istarget mips*-*-*]
5028 && [et-is-effective-target mips_loongson]) } {
5029 set et_vect_no_int_min_max_saved($et_index) 1
5030 }
5031 }
5032 verbose "check_effective_target_vect_no_int_min_max:\
5033 returning $et_vect_no_int_min_max_saved($et_index)" 2
5034 return $et_vect_no_int_min_max_saved($et_index)
5035 }
5036
5037 # Return 1 if the target plus current options does not support a vector
5038 # add instruction on "int", 0 otherwise.
5039 #
5040 # This won't change for different subtargets so cache the result.
5041
5042 proc check_effective_target_vect_no_int_add { } {
5043 global et_vect_no_int_add_saved
5044 global et_index
5045
5046 if [info exists et_vect_no_int_add_saved($et_index)] {
5047 verbose "check_effective_target_vect_no_int_add: using cached result" 2
5048 } else {
5049 set et_vect_no_int_add_saved($et_index) 0
5050 # Alpha only supports vector add on V8QI and V4HI.
5051 if { [istarget alpha*-*-*] } {
5052 set et_vect_no_int_add_saved($et_index) 1
5053 }
5054 }
5055 verbose "check_effective_target_vect_no_int_add:\
5056 returning $et_vect_no_int_add_saved($et_index)" 2
5057 return $et_vect_no_int_add_saved($et_index)
5058 }
5059
5060 # Return 1 if the target plus current options does not support vector
5061 # bitwise instructions, 0 otherwise.
5062 #
5063 # This won't change for different subtargets so cache the result.
5064
5065 proc check_effective_target_vect_no_bitwise { } {
5066 global et_vect_no_bitwise_saved
5067 global et_index
5068
5069 if [info exists et_vect_no_bitwise_saved($et_index)] {
5070 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
5071 } else {
5072 set et_vect_no_bitwise_saved($et_index) 0
5073 }
5074 verbose "check_effective_target_vect_no_bitwise:\
5075 returning $et_vect_no_bitwise_saved($et_index)" 2
5076 return $et_vect_no_bitwise_saved($et_index)
5077 }
5078
5079 # Return 1 if the target plus current options supports vector permutation,
5080 # 0 otherwise.
5081 #
5082 # This won't change for different subtargets so cache the result.
5083
5084 proc check_effective_target_vect_perm { } {
5085 global et_vect_perm_saved
5086 global et_index
5087
5088 if [info exists et_vect_perm_saved($et_index)] {
5089 verbose "check_effective_target_vect_perm: using cached result" 2
5090 } else {
5091 set et_vect_perm_saved($et_index) 0
5092 if { [is-effective-target arm_neon_ok]
5093 || [istarget aarch64*-*-*]
5094 || [istarget powerpc*-*-*]
5095 || [istarget spu-*-*]
5096 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5097 || ([istarget mips*-*-*]
5098 && ([et-is-effective-target mpaired_single]
5099 || [et-is-effective-target mips_msa])) } {
5100 set et_vect_perm_saved($et_index) 1
5101 }
5102 }
5103 verbose "check_effective_target_vect_perm:\
5104 returning $et_vect_perm_saved($et_index)" 2
5105 return $et_vect_perm_saved($et_index)
5106 }
5107
5108 # Return 1 if the target plus current options supports vector permutation
5109 # on byte-sized elements, 0 otherwise.
5110 #
5111 # This won't change for different subtargets so cache the result.
5112
5113 proc check_effective_target_vect_perm_byte { } {
5114 global et_vect_perm_byte_saved
5115 global et_index
5116
5117 if [info exists et_vect_perm_byte_saved($et_index)] {
5118 verbose "check_effective_target_vect_perm_byte: using cached result" 2
5119 } else {
5120 set et_vect_perm_byte_saved($et_index) 0
5121 if { ([is-effective-target arm_neon_ok]
5122 && [is-effective-target arm_little_endian])
5123 || ([istarget aarch64*-*-*]
5124 && [is-effective-target aarch64_little_endian])
5125 || [istarget powerpc*-*-*]
5126 || [istarget spu-*-*]
5127 || ([istarget mips-*.*]
5128 && [et-is-effective-target mips_msa]) } {
5129 set et_vect_perm_byte_saved($et_index) 1
5130 }
5131 }
5132 verbose "check_effective_target_vect_perm_byte:\
5133 returning $et_vect_perm_byte_saved($et_index)" 2
5134 return $et_vect_perm_byte_saved($et_index)
5135 }
5136
5137 # Return 1 if the target plus current options supports vector permutation
5138 # on short-sized elements, 0 otherwise.
5139 #
5140 # This won't change for different subtargets so cache the result.
5141
5142 proc check_effective_target_vect_perm_short { } {
5143 global et_vect_perm_short_saved
5144 global et_index
5145
5146 if [info exists et_vect_perm_short_saved($et_index)] {
5147 verbose "check_effective_target_vect_perm_short: using cached result" 2
5148 } else {
5149 set et_vect_perm_short_saved($et_index) 0
5150 if { ([is-effective-target arm_neon_ok]
5151 && [is-effective-target arm_little_endian])
5152 || ([istarget aarch64*-*-*]
5153 && [is-effective-target aarch64_little_endian])
5154 || [istarget powerpc*-*-*]
5155 || [istarget spu-*-*]
5156 || ([istarget mips*-*-*]
5157 && [et-is-effective-target mips_msa]) } {
5158 set et_vect_perm_short_saved($et_index) 1
5159 }
5160 }
5161 verbose "check_effective_target_vect_perm_short:\
5162 returning $et_vect_perm_short_saved($et_index)" 2
5163 return $et_vect_perm_short_saved($et_index)
5164 }
5165
5166 # Return 1 if the target plus current options supports a vector
5167 # widening summation of *short* args into *int* result, 0 otherwise.
5168 #
5169 # This won't change for different subtargets so cache the result.
5170
5171 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
5172 global et_vect_widen_sum_hi_to_si_pattern_saved
5173 global et_index
5174
5175 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved($et_index)] {
5176 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern:\
5177 using cached result" 2
5178 } else {
5179 set et_vect_widen_sum_hi_to_si_pattern_saved($et_index) 0
5180 if { [istarget powerpc*-*-*]
5181 || [istarget aarch64*-*-*]
5182 || ([istarget arm*-*-*] &&
5183 [check_effective_target_arm_neon_ok])
5184 || [istarget ia64-*-*] } {
5185 set et_vect_widen_sum_hi_to_si_pattern_saved($et_index) 1
5186 }
5187 }
5188 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern:\
5189 returning $et_vect_widen_sum_hi_to_si_pattern_saved($et_index)" 2
5190 return $et_vect_widen_sum_hi_to_si_pattern_saved($et_index)
5191 }
5192
5193 # Return 1 if the target plus current options supports a vector
5194 # widening summation of *short* args into *int* result, 0 otherwise.
5195 # A target can also support this widening summation if it can support
5196 # promotion (unpacking) from shorts to ints.
5197 #
5198 # This won't change for different subtargets so cache the result.
5199
5200 proc check_effective_target_vect_widen_sum_hi_to_si { } {
5201 global et_vect_widen_sum_hi_to_si_saved
5202 global et_index
5203
5204 if [info exists et_vect_widen_sum_hi_to_si_saved($et_index)] {
5205 verbose "check_effective_target_vect_widen_sum_hi_to_si:\
5206 using cached result" 2
5207 } else {
5208 set et_vect_widen_sum_hi_to_si_saved($et_index) \
5209 [check_effective_target_vect_unpack]
5210 if { [istarget powerpc*-*-*]
5211 || [istarget ia64-*-*] } {
5212 set et_vect_widen_sum_hi_to_si_saved($et_index) 1
5213 }
5214 }
5215 verbose "check_effective_target_vect_widen_sum_hi_to_si:\
5216 returning $et_vect_widen_sum_hi_to_si_saved($et_index)" 2
5217 return $et_vect_widen_sum_hi_to_si_saved($et_index)
5218 }
5219
5220 # Return 1 if the target plus current options supports a vector
5221 # widening summation of *char* args into *short* result, 0 otherwise.
5222 # A target can also support this widening summation if it can support
5223 # promotion (unpacking) from chars to shorts.
5224 #
5225 # This won't change for different subtargets so cache the result.
5226
5227 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
5228 global et_vect_widen_sum_qi_to_hi_saved
5229 global et_index
5230
5231 if [info exists et_vect_widen_sum_qi_to_hi_saved($et_index)] {
5232 verbose "check_effective_target_vect_widen_sum_qi_to_hi:\
5233 using cached result" 2
5234 } else {
5235 set et_vect_widen_sum_qi_to_hi_saved($et_index) 0
5236 if { [check_effective_target_vect_unpack]
5237 || [check_effective_target_arm_neon_ok]
5238 || [istarget ia64-*-*] } {
5239 set et_vect_widen_sum_qi_to_hi_saved($et_index) 1
5240 }
5241 }
5242 verbose "check_effective_target_vect_widen_sum_qi_to_hi:\
5243 returning $et_vect_widen_sum_qi_to_hi_saved($et_index)" 2
5244 return $et_vect_widen_sum_qi_to_hi_saved($et_index)
5245 }
5246
5247 # Return 1 if the target plus current options supports a vector
5248 # widening summation of *char* args into *int* result, 0 otherwise.
5249 #
5250 # This won't change for different subtargets so cache the result.
5251
5252 proc check_effective_target_vect_widen_sum_qi_to_si { } {
5253 global et_vect_widen_sum_qi_to_si_saved
5254 global et_index
5255
5256 if [info exists et_vect_widen_sum_qi_to_si_saved($et_index)] {
5257 verbose "check_effective_target_vect_widen_sum_qi_to_si:\
5258 using cached result" 2
5259 } else {
5260 set et_vect_widen_sum_qi_to_si_saved($et_index) 0
5261 if { [istarget powerpc*-*-*] } {
5262 set et_vect_widen_sum_qi_to_si_saved($et_index) 1
5263 }
5264 }
5265 verbose "check_effective_target_vect_widen_sum_qi_to_si:\
5266 returning $et_vect_widen_sum_qi_to_si_saved($et_index)" 2
5267 return $et_vect_widen_sum_qi_to_si_saved($et_index)
5268 }
5269
5270 # Return 1 if the target plus current options supports a vector
5271 # widening multiplication of *char* args into *short* result, 0 otherwise.
5272 # A target can also support this widening multplication if it can support
5273 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
5274 # multiplication of shorts).
5275 #
5276 # This won't change for different subtargets so cache the result.
5277
5278
5279 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
5280 global et_vect_widen_mult_qi_to_hi_saved
5281 global et_index
5282
5283 if [info exists et_vect_widen_mult_qi_to_hi_saved($et_index)] {
5284 verbose "check_effective_target_vect_widen_mult_qi_to_hi:\
5285 using cached result" 2
5286 } else {
5287 if { [check_effective_target_vect_unpack]
5288 && [check_effective_target_vect_short_mult] } {
5289 set et_vect_widen_mult_qi_to_hi_saved($et_index) 1
5290 } else {
5291 set et_vect_widen_mult_qi_to_hi_saved($et_index) 0
5292 }
5293 if { [istarget powerpc*-*-*]
5294 || [istarget aarch64*-*-*]
5295 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
5296 set et_vect_widen_mult_qi_to_hi_saved($et_index) 1
5297 }
5298 }
5299 verbose "check_effective_target_vect_widen_mult_qi_to_hi:\
5300 returning $et_vect_widen_mult_qi_to_hi_saved($et_index)" 2
5301 return $et_vect_widen_mult_qi_to_hi_saved($et_index)
5302 }
5303
5304 # Return 1 if the target plus current options supports a vector
5305 # widening multiplication of *short* args into *int* result, 0 otherwise.
5306 # A target can also support this widening multplication if it can support
5307 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
5308 # multiplication of ints).
5309 #
5310 # This won't change for different subtargets so cache the result.
5311
5312
5313 proc check_effective_target_vect_widen_mult_hi_to_si { } {
5314 global et_vect_widen_mult_hi_to_si_saved
5315 global et_index
5316
5317 if [info exists et_vect_widen_mult_hi_to_si_saved($et_index)] {
5318 verbose "check_effective_target_vect_widen_mult_hi_to_si:\
5319 using cached result" 2
5320 } else {
5321 if { [check_effective_target_vect_unpack]
5322 && [check_effective_target_vect_int_mult] } {
5323 set et_vect_widen_mult_hi_to_si_saved($et_index) 1
5324 } else {
5325 set et_vect_widen_mult_hi_to_si_saved($et_index) 0
5326 }
5327 if { [istarget powerpc*-*-*]
5328 || [istarget spu-*-*]
5329 || [istarget ia64-*-*]
5330 || [istarget aarch64*-*-*]
5331 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5332 || ([istarget arm*-*-*]
5333 && [check_effective_target_arm_neon_ok]) } {
5334 set et_vect_widen_mult_hi_to_si_saved($et_index) 1
5335 }
5336 }
5337 verbose "check_effective_target_vect_widen_mult_hi_to_si:\
5338 returning $et_vect_widen_mult_hi_to_si_saved($et_index)" 2
5339 return $et_vect_widen_mult_hi_to_si_saved($et_index)
5340 }
5341
5342 # Return 1 if the target plus current options supports a vector
5343 # widening multiplication of *char* args into *short* result, 0 otherwise.
5344 #
5345 # This won't change for different subtargets so cache the result.
5346
5347 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
5348 global et_vect_widen_mult_qi_to_hi_pattern_saved
5349 global et_index
5350
5351 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)] {
5352 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern:\
5353 using cached result" 2
5354 } else {
5355 set et_vect_widen_mult_qi_to_hi_pattern_saved($et_index) 0
5356 if { [istarget powerpc*-*-*]
5357 || ([istarget arm*-*-*]
5358 && [check_effective_target_arm_neon_ok]
5359 && [check_effective_target_arm_little_endian]) } {
5360 set et_vect_widen_mult_qi_to_hi_pattern_saved($et_index) 1
5361 }
5362 }
5363 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern:\
5364 returning $et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)" 2
5365 return $et_vect_widen_mult_qi_to_hi_pattern_saved($et_index)
5366 }
5367
5368 # Return 1 if the target plus current options supports a vector
5369 # widening multiplication of *short* args into *int* result, 0 otherwise.
5370 #
5371 # This won't change for different subtargets so cache the result.
5372
5373 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
5374 global et_vect_widen_mult_hi_to_si_pattern_saved
5375 global et_index
5376
5377 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved($et_index)] {
5378 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern:\
5379 using cached result" 2
5380 } else {
5381 set et_vect_widen_mult_hi_to_si_pattern_saved($et_index) 0
5382 if { [istarget powerpc*-*-*]
5383 || [istarget spu-*-*]
5384 || [istarget ia64-*-*]
5385 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5386 || ([istarget arm*-*-*]
5387 && [check_effective_target_arm_neon_ok]
5388 && [check_effective_target_arm_little_endian]) } {
5389 set et_vect_widen_mult_hi_to_si_pattern_saved($et_index) 1
5390 }
5391 }
5392 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern:\
5393 returning $et_vect_widen_mult_hi_to_si_pattern_saved($et_index)" 2
5394 return $et_vect_widen_mult_hi_to_si_pattern_saved($et_index)
5395 }
5396
5397 # Return 1 if the target plus current options supports a vector
5398 # widening multiplication of *int* args into *long* result, 0 otherwise.
5399 #
5400 # This won't change for different subtargets so cache the result.
5401
5402 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
5403 global et_vect_widen_mult_si_to_di_pattern_saved
5404 global et_index
5405
5406 if [info exists et_vect_widen_mult_si_to_di_pattern_saved($et_index)] {
5407 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern:\
5408 using cached result" 2
5409 } else {
5410 set et_vect_widen_mult_si_to_di_pattern_saved($et_index) 0
5411 if {[istarget ia64-*-*]
5412 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5413 set et_vect_widen_mult_si_to_di_pattern_saved($et_index) 1
5414 }
5415 }
5416 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern:\
5417 returning $et_vect_widen_mult_si_to_di_pattern_saved($et_index)" 2
5418 return $et_vect_widen_mult_si_to_di_pattern_saved($et_index)
5419 }
5420
5421 # Return 1 if the target plus current options supports a vector
5422 # widening shift, 0 otherwise.
5423 #
5424 # This won't change for different subtargets so cache the result.
5425
5426 proc check_effective_target_vect_widen_shift { } {
5427 global et_vect_widen_shift_saved
5428 global et_index
5429
5430 if [info exists et_vect_shift_saved($et_index)] {
5431 verbose "check_effective_target_vect_widen_shift: using cached result" 2
5432 } else {
5433 set et_vect_widen_shift_saved($et_index) 0
5434 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
5435 set et_vect_widen_shift_saved($et_index) 1
5436 }
5437 }
5438 verbose "check_effective_target_vect_widen_shift:\
5439 returning $et_vect_widen_shift_saved($et_index)" 2
5440 return $et_vect_widen_shift_saved($et_index)
5441 }
5442
5443 # Return 1 if the target plus current options supports a vector
5444 # dot-product of signed chars, 0 otherwise.
5445 #
5446 # This won't change for different subtargets so cache the result.
5447
5448 proc check_effective_target_vect_sdot_qi { } {
5449 global et_vect_sdot_qi_saved
5450 global et_index
5451
5452 if [info exists et_vect_sdot_qi_saved($et_index)] {
5453 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
5454 } else {
5455 set et_vect_sdot_qi_saved($et_index) 0
5456 if { [istarget ia64-*-*]
5457 || ([istarget mips*-*-*]
5458 && [et-is-effective-target mips_msa]) } {
5459 set et_vect_udot_qi_saved 1
5460 }
5461 }
5462 verbose "check_effective_target_vect_sdot_qi:\
5463 returning $et_vect_sdot_qi_saved($et_index)" 2
5464 return $et_vect_sdot_qi_saved($et_index)
5465 }
5466
5467 # Return 1 if the target plus current options supports a vector
5468 # dot-product of unsigned chars, 0 otherwise.
5469 #
5470 # This won't change for different subtargets so cache the result.
5471
5472 proc check_effective_target_vect_udot_qi { } {
5473 global et_vect_udot_qi_saved
5474 global et_index
5475
5476 if [info exists et_vect_udot_qi_saved($et_index)] {
5477 verbose "check_effective_target_vect_udot_qi: using cached result" 2
5478 } else {
5479 set et_vect_udot_qi_saved($et_index) 0
5480 if { [istarget powerpc*-*-*]
5481 || [istarget ia64-*-*]
5482 || ([istarget mips*-*-*]
5483 && [et-is-effective-target mips_msa]) } {
5484 set et_vect_udot_qi_saved($et_index) 1
5485 }
5486 }
5487 verbose "check_effective_target_vect_udot_qi:\
5488 returning $et_vect_udot_qi_saved($et_index)" 2
5489 return $et_vect_udot_qi_saved($et_index)
5490 }
5491
5492 # Return 1 if the target plus current options supports a vector
5493 # dot-product of signed shorts, 0 otherwise.
5494 #
5495 # This won't change for different subtargets so cache the result.
5496
5497 proc check_effective_target_vect_sdot_hi { } {
5498 global et_vect_sdot_hi_saved
5499 global et_index
5500
5501 if [info exists et_vect_sdot_hi_saved($et_index)] {
5502 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
5503 } else {
5504 set et_vect_sdot_hi_saved($et_index) 0
5505 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5506 || [istarget ia64-*-*]
5507 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5508 || ([istarget mips*-*-*]
5509 && [et-is-effective-target mips_msa]) } {
5510 set et_vect_sdot_hi_saved($et_index) 1
5511 }
5512 }
5513 verbose "check_effective_target_vect_sdot_hi:\
5514 returning $et_vect_sdot_hi_saved($et_index)" 2
5515 return $et_vect_sdot_hi_saved($et_index)
5516 }
5517
5518 # Return 1 if the target plus current options supports a vector
5519 # dot-product of unsigned shorts, 0 otherwise.
5520 #
5521 # This won't change for different subtargets so cache the result.
5522
5523 proc check_effective_target_vect_udot_hi { } {
5524 global et_vect_udot_hi_saved
5525 global et_index
5526
5527 if [info exists et_vect_udot_hi_saved($et_index)] {
5528 verbose "check_effective_target_vect_udot_hi: using cached result" 2
5529 } else {
5530 set et_vect_udot_hi_saved($et_index) 0
5531 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5532 || ([istarget mips*-*-*]
5533 && [et-is-effective-target mips_msa]) } {
5534 set et_vect_udot_hi_saved($et_index) 1
5535 }
5536 }
5537 verbose "check_effective_target_vect_udot_hi:\
5538 returning $et_vect_udot_hi_saved($et_index)" 2
5539 return $et_vect_udot_hi_saved($et_index)
5540 }
5541
5542 # Return 1 if the target plus current options supports a vector
5543 # sad operation of unsigned chars, 0 otherwise.
5544 #
5545 # This won't change for different subtargets so cache the result.
5546
5547 proc check_effective_target_vect_usad_char { } {
5548 global et_vect_usad_char_saved
5549 global et_index
5550
5551 if [info exists et_vect_usad_char_saved($et_index)] {
5552 verbose "check_effective_target_vect_usad_char: using cached result" 2
5553 } else {
5554 set et_vect_usad_char_saved($et_index) 0
5555 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5556 set et_vect_usad_char_saved($et_index) 1
5557 }
5558 }
5559 verbose "check_effective_target_vect_usad_char:\
5560 returning $et_vect_usad_char_saved($et_index)" 2
5561 return $et_vect_usad_char_saved($et_index)
5562 }
5563
5564 # Return 1 if the target plus current options supports a vector
5565 # demotion (packing) of shorts (to chars) and ints (to shorts)
5566 # using modulo arithmetic, 0 otherwise.
5567 #
5568 # This won't change for different subtargets so cache the result.
5569
5570 proc check_effective_target_vect_pack_trunc { } {
5571 global et_vect_pack_trunc_saved
5572 global et_index
5573
5574 if [info exists et_vect_pack_trunc_saved($et_index)] {
5575 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
5576 } else {
5577 set et_vect_pack_trunc_saved($et_index) 0
5578 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5579 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5580 || [istarget aarch64*-*-*]
5581 || [istarget spu-*-*]
5582 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
5583 && [check_effective_target_arm_little_endian])
5584 || ([istarget mips*-*-*]
5585 && [et-is-effective-target mips_msa]) } {
5586 set et_vect_pack_trunc_saved($et_index) 1
5587 }
5588 }
5589 verbose "check_effective_target_vect_pack_trunc:\
5590 returning $et_vect_pack_trunc_saved($et_index)" 2
5591 return $et_vect_pack_trunc_saved($et_index)
5592 }
5593
5594 # Return 1 if the target plus current options supports a vector
5595 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
5596 #
5597 # This won't change for different subtargets so cache the result.
5598
5599 proc check_effective_target_vect_unpack { } {
5600 global et_vect_unpack_saved
5601 global et_index
5602
5603 if [info exists et_vect_unpack_saved($et_index)] {
5604 verbose "check_effective_target_vect_unpack: using cached result" 2
5605 } else {
5606 set et_vect_unpack_saved($et_index) 0
5607 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
5608 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5609 || [istarget spu-*-*]
5610 || [istarget ia64-*-*]
5611 || [istarget aarch64*-*-*]
5612 || ([istarget mips*-*-*]
5613 && [et-is-effective-target mips_msa])
5614 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
5615 && [check_effective_target_arm_little_endian]) } {
5616 set et_vect_unpack_saved($et_index) 1
5617 }
5618 }
5619 verbose "check_effective_target_vect_unpack:\
5620 returning $et_vect_unpack_saved($et_index)" 2
5621 return $et_vect_unpack_saved($et_index)
5622 }
5623
5624 # Return 1 if the target plus current options does not guarantee
5625 # that its STACK_BOUNDARY is >= the reguired vector alignment.
5626 #
5627 # This won't change for different subtargets so cache the result.
5628
5629 proc check_effective_target_unaligned_stack { } {
5630 global et_unaligned_stack_saved
5631
5632 if [info exists et_unaligned_stack_saved] {
5633 verbose "check_effective_target_unaligned_stack: using cached result" 2
5634 } else {
5635 set et_unaligned_stack_saved 0
5636 }
5637 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
5638 return $et_unaligned_stack_saved
5639 }
5640
5641 # Return 1 if the target plus current options does not support a vector
5642 # alignment mechanism, 0 otherwise.
5643 #
5644 # This won't change for different subtargets so cache the result.
5645
5646 proc check_effective_target_vect_no_align { } {
5647 global et_vect_no_align_saved
5648 global et_index
5649
5650 if [info exists et_vect_no_align_saved($et_index)] {
5651 verbose "check_effective_target_vect_no_align: using cached result" 2
5652 } else {
5653 set et_vect_no_align_saved($et_index) 0
5654 if { [istarget mipsisa64*-*-*]
5655 || [istarget mips-sde-elf]
5656 || [istarget sparc*-*-*]
5657 || [istarget ia64-*-*]
5658 || [check_effective_target_arm_vect_no_misalign]
5659 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
5660 || ([istarget mips*-*-*]
5661 && [et-is-effective-target mips_loongson]) } {
5662 set et_vect_no_align_saved($et_index) 1
5663 }
5664 }
5665 verbose "check_effective_target_vect_no_align:\
5666 returning $et_vect_no_align_saved($et_index)" 2
5667 return $et_vect_no_align_saved($et_index)
5668 }
5669
5670 # Return 1 if the target supports a vector misalign access, 0 otherwise.
5671 #
5672 # This won't change for different subtargets so cache the result.
5673
5674 proc check_effective_target_vect_hw_misalign { } {
5675 global et_vect_hw_misalign_saved
5676 global et_index
5677
5678 if [info exists et_vect_hw_misalign_saved($et_index)] {
5679 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
5680 } else {
5681 set et_vect_hw_misalign_saved($et_index) 0
5682 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5683 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
5684 || [istarget aarch64*-*-*]
5685 || ([istarget mips*-*-*] && [et-is-effective-target mips_msa]) } {
5686 set et_vect_hw_misalign_saved($et_index) 1
5687 }
5688 }
5689 verbose "check_effective_target_vect_hw_misalign:\
5690 returning $et_vect_hw_misalign_saved($et_index)" 2
5691 return $et_vect_hw_misalign_saved($et_index)
5692 }
5693
5694
5695 # Return 1 if arrays are aligned to the vector alignment
5696 # boundary, 0 otherwise.
5697
5698 proc check_effective_target_vect_aligned_arrays { } {
5699 set et_vect_aligned_arrays 0
5700 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
5701 && !([is-effective-target ia32]
5702 || ([check_avx_available] && ![check_prefer_avx128])))
5703 || [istarget spu-*-*] } {
5704 set et_vect_aligned_arrays 1
5705 }
5706
5707 verbose "check_effective_target_vect_aligned_arrays:\
5708 returning $et_vect_aligned_arrays" 2
5709 return $et_vect_aligned_arrays
5710 }
5711
5712 # Return 1 if types of size 32 bit or less are naturally aligned
5713 # (aligned to their type-size), 0 otherwise.
5714 #
5715 # This won't change for different subtargets so cache the result.
5716
5717 proc check_effective_target_natural_alignment_32 { } {
5718 global et_natural_alignment_32
5719
5720 if [info exists et_natural_alignment_32_saved] {
5721 verbose "check_effective_target_natural_alignment_32: using cached result" 2
5722 } else {
5723 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
5724 set et_natural_alignment_32_saved 1
5725 if { ([istarget *-*-darwin*] && [is-effective-target lp64])
5726 || [istarget avr-*-*] } {
5727 set et_natural_alignment_32_saved 0
5728 }
5729 }
5730 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
5731 return $et_natural_alignment_32_saved
5732 }
5733
5734 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
5735 # type-size), 0 otherwise.
5736 #
5737 # This won't change for different subtargets so cache the result.
5738
5739 proc check_effective_target_natural_alignment_64 { } {
5740 global et_natural_alignment_64
5741
5742 if [info exists et_natural_alignment_64_saved] {
5743 verbose "check_effective_target_natural_alignment_64: using cached result" 2
5744 } else {
5745 set et_natural_alignment_64_saved 0
5746 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
5747 || [istarget spu-*-*] } {
5748 set et_natural_alignment_64_saved 1
5749 }
5750 }
5751 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
5752 return $et_natural_alignment_64_saved
5753 }
5754
5755 # Return 1 if all vector types are naturally aligned (aligned to their
5756 # type-size), 0 otherwise.
5757
5758 proc check_effective_target_vect_natural_alignment { } {
5759 set et_vect_natural_alignment 1
5760 if { [check_effective_target_arm_eabi]
5761 || [istarget nvptx-*-*]
5762 || [istarget s390*-*-*] } {
5763 set et_vect_natural_alignment 0
5764 }
5765 verbose "check_effective_target_vect_natural_alignment:\
5766 returning $et_vect_natural_alignment" 2
5767 return $et_vect_natural_alignment
5768 }
5769
5770 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
5771
5772 proc check_effective_target_vector_alignment_reachable { } {
5773 set et_vector_alignment_reachable 0
5774 if { [check_effective_target_vect_aligned_arrays]
5775 || [check_effective_target_natural_alignment_32] } {
5776 set et_vector_alignment_reachable 1
5777 }
5778 verbose "check_effective_target_vector_alignment_reachable:\
5779 returning $et_vector_alignment_reachable" 2
5780 return $et_vector_alignment_reachable
5781 }
5782
5783 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
5784
5785 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
5786 set et_vector_alignment_reachable_for_64bit 0
5787 if { [check_effective_target_vect_aligned_arrays]
5788 || [check_effective_target_natural_alignment_64] } {
5789 set et_vector_alignment_reachable_for_64bit 1
5790 }
5791 verbose "check_effective_target_vector_alignment_reachable_for_64bit:\
5792 returning $et_vector_alignment_reachable_for_64bit" 2
5793 return $et_vector_alignment_reachable_for_64bit
5794 }
5795
5796 # Return 1 if the target only requires element alignment for vector accesses
5797
5798 proc check_effective_target_vect_element_align { } {
5799 global et_vect_element_align
5800 global et_index
5801
5802 if [info exists et_vect_element_align($et_index)] {
5803 verbose "check_effective_target_vect_element_align:\
5804 using cached result" 2
5805 } else {
5806 set et_vect_element_align($et_index) 0
5807 if { ([istarget arm*-*-*]
5808 && ![check_effective_target_arm_vect_no_misalign])
5809 || [check_effective_target_vect_hw_misalign] } {
5810 set et_vect_element_align($et_index) 1
5811 }
5812 }
5813
5814 verbose "check_effective_target_vect_element_align:\
5815 returning $et_vect_element_align($et_index)" 2
5816 return $et_vect_element_align($et_index)
5817 }
5818
5819 # Return 1 if the target supports vector LOAD_LANES operations, 0 otherwise.
5820
5821 proc check_effective_target_vect_load_lanes { } {
5822 global et_vect_load_lanes
5823
5824 if [info exists et_vect_load_lanes] {
5825 verbose "check_effective_target_vect_load_lanes: using cached result" 2
5826 } else {
5827 set et_vect_load_lanes 0
5828 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])
5829 || [istarget aarch64*-*-*] } {
5830 set et_vect_load_lanes 1
5831 }
5832 }
5833
5834 verbose "check_effective_target_vect_load_lanes: returning $et_vect_load_lanes" 2
5835 return $et_vect_load_lanes
5836 }
5837
5838 # Return 1 if the target supports vector conditional operations, 0 otherwise.
5839
5840 proc check_effective_target_vect_condition { } {
5841 global et_vect_cond_saved
5842 global et_index
5843
5844 if [info exists et_vect_cond_saved($et_index)] {
5845 verbose "check_effective_target_vect_cond: using cached result" 2
5846 } else {
5847 set et_vect_cond_saved($et_index) 0
5848 if { [istarget aarch64*-*-*]
5849 || [istarget powerpc*-*-*]
5850 || [istarget ia64-*-*]
5851 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5852 || [istarget spu-*-*]
5853 || ([istarget mips*-*-*]
5854 && [et-is-effective-target mips_msa])
5855 || ([istarget arm*-*-*]
5856 && [check_effective_target_arm_neon_ok]) } {
5857 set et_vect_cond_saved($et_index) 1
5858 }
5859 }
5860
5861 verbose "check_effective_target_vect_cond:\
5862 returning $et_vect_cond_saved($et_index)" 2
5863 return $et_vect_cond_saved($et_index)
5864 }
5865
5866 # Return 1 if the target supports vector conditional operations where
5867 # the comparison has different type from the lhs, 0 otherwise.
5868
5869 proc check_effective_target_vect_cond_mixed { } {
5870 global et_vect_cond_mixed_saved
5871 global et_index
5872
5873 if [info exists et_vect_cond_mixed_saved($et_index)] {
5874 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
5875 } else {
5876 set et_vect_cond_mixed_saved($et_index) 0
5877 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5878 || [istarget aarch64*-*-*]
5879 || [istarget powerpc*-*-*]
5880 || ([istarget mips*-*-*]
5881 && [et-is-effective-target mips_msa]) } {
5882 set et_vect_cond_mixed_saved($et_index) 1
5883 }
5884 }
5885
5886 verbose "check_effective_target_vect_cond_mixed:\
5887 returning $et_vect_cond_mixed_saved($et_index)" 2
5888 return $et_vect_cond_mixed_saved($et_index)
5889 }
5890
5891 # Return 1 if the target supports vector char multiplication, 0 otherwise.
5892
5893 proc check_effective_target_vect_char_mult { } {
5894 global et_vect_char_mult_saved
5895 global et_index
5896
5897 if [info exists et_vect_char_mult_saved($et_index)] {
5898 verbose "check_effective_target_vect_char_mult: using cached result" 2
5899 } else {
5900 set et_vect_char_mult_saved($et_index) 0
5901 if { [istarget aarch64*-*-*]
5902 || [istarget ia64-*-*]
5903 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5904 || [check_effective_target_arm32]
5905 || [check_effective_target_powerpc_altivec]
5906 || ([istarget mips*-*-*]
5907 && [et-is-effective-target mips_msa]) } {
5908 set et_vect_char_mult_saved($et_index) 1
5909 }
5910 }
5911
5912 verbose "check_effective_target_vect_char_mult:\
5913 returning $et_vect_char_mult_saved($et_index)" 2
5914 return $et_vect_char_mult_saved($et_index)
5915 }
5916
5917 # Return 1 if the target supports vector short multiplication, 0 otherwise.
5918
5919 proc check_effective_target_vect_short_mult { } {
5920 global et_vect_short_mult_saved
5921 global et_index
5922
5923 if [info exists et_vect_short_mult_saved($et_index)] {
5924 verbose "check_effective_target_vect_short_mult: using cached result" 2
5925 } else {
5926 set et_vect_short_mult_saved($et_index) 0
5927 if { [istarget ia64-*-*]
5928 || [istarget spu-*-*]
5929 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5930 || [istarget powerpc*-*-*]
5931 || [istarget aarch64*-*-*]
5932 || [check_effective_target_arm32]
5933 || ([istarget mips*-*-*]
5934 && ([et-is-effective-target mips_msa]
5935 || [et-is-effective-target mips_loongson])) } {
5936 set et_vect_short_mult_saved($et_index) 1
5937 }
5938 }
5939
5940 verbose "check_effective_target_vect_short_mult:\
5941 returning $et_vect_short_mult_saved($et_index)" 2
5942 return $et_vect_short_mult_saved($et_index)
5943 }
5944
5945 # Return 1 if the target supports vector int multiplication, 0 otherwise.
5946
5947 proc check_effective_target_vect_int_mult { } {
5948 global et_vect_int_mult_saved
5949 global et_index
5950
5951 if [info exists et_vect_int_mult_saved($et_index)] {
5952 verbose "check_effective_target_vect_int_mult: using cached result" 2
5953 } else {
5954 set et_vect_int_mult_saved($et_index) 0
5955 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5956 || [istarget spu-*-*]
5957 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5958 || [istarget ia64-*-*]
5959 || [istarget aarch64*-*-*]
5960 || ([istarget mips*-*-*]
5961 && [et-is-effective-target mips_msa])
5962 || [check_effective_target_arm32] } {
5963 set et_vect_int_mult_saved($et_index) 1
5964 }
5965 }
5966
5967 verbose "check_effective_target_vect_int_mult:\
5968 returning $et_vect_int_mult_saved($et_index)" 2
5969 return $et_vect_int_mult_saved($et_index)
5970 }
5971
5972 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
5973
5974 proc check_effective_target_vect_extract_even_odd { } {
5975 global et_vect_extract_even_odd_saved
5976 global et_index
5977
5978 if [info exists et_vect_extract_even_odd_saved($et_index)] {
5979 verbose "check_effective_target_vect_extract_even_odd:\
5980 using cached result" 2
5981 } else {
5982 set et_vect_extract_even_odd_saved($et_index) 0
5983 if { [istarget aarch64*-*-*]
5984 || [istarget powerpc*-*-*]
5985 || [is-effective-target arm_neon_ok]
5986 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5987 || [istarget ia64-*-*]
5988 || [istarget spu-*-*]
5989 || ([istarget mips*-*-*]
5990 && ([et-is-effective-target mips_msa]
5991 || [et-is-effective-target mpaired_single])) } {
5992 set et_vect_extract_even_odd_saved($et_index) 1
5993 }
5994 }
5995
5996 verbose "check_effective_target_vect_extract_even_odd:\
5997 returning $et_vect_extract_even_odd_saved($et_index)" 2
5998 return $et_vect_extract_even_odd_saved($et_index)
5999 }
6000
6001 # Return 1 if the target supports vector interleaving, 0 otherwise.
6002
6003 proc check_effective_target_vect_interleave { } {
6004 global et_vect_interleave_saved
6005 global et_index
6006
6007 if [info exists et_vect_interleave_saved($et_index)] {
6008 verbose "check_effective_target_vect_interleave: using cached result" 2
6009 } else {
6010 set et_vect_interleave_saved($et_index) 0
6011 if { [istarget aarch64*-*-*]
6012 || [istarget powerpc*-*-*]
6013 || [is-effective-target arm_neon_ok]
6014 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6015 || [istarget ia64-*-*]
6016 || [istarget spu-*-*]
6017 || ([istarget mips*-*-*]
6018 && ([et-is-effective-target mpaired_single]
6019 || [et-is-effective-target mips_msa])) } {
6020 set et_vect_interleave_saved($et_index) 1
6021 }
6022 }
6023
6024 verbose "check_effective_target_vect_interleave:\
6025 returning $et_vect_interleave_saved($et_index)" 2
6026 return $et_vect_interleave_saved($et_index)
6027 }
6028
6029 foreach N {2 3 4 8} {
6030 eval [string map [list N $N] {
6031 # Return 1 if the target supports 2-vector interleaving
6032 proc check_effective_target_vect_stridedN { } {
6033 global et_vect_stridedN_saved
6034 global et_index
6035
6036 if [info exists et_vect_stridedN_saved($et_index)] {
6037 verbose "check_effective_target_vect_stridedN:\
6038 using cached result" 2
6039 } else {
6040 set et_vect_stridedN_saved($et_index) 0
6041 if { (N & -N) == N
6042 && [check_effective_target_vect_interleave]
6043 && [check_effective_target_vect_extract_even_odd] } {
6044 set et_vect_stridedN_saved($et_index) 1
6045 }
6046 if { ([istarget arm*-*-*]
6047 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
6048 set et_vect_stridedN_saved($et_index) 1
6049 }
6050 }
6051
6052 verbose "check_effective_target_vect_stridedN:\
6053 returning $et_vect_stridedN_saved($et_index)" 2
6054 return $et_vect_stridedN_saved($et_index)
6055 }
6056 }]
6057 }
6058
6059 # Return 1 if the target supports multiple vector sizes
6060
6061 proc check_effective_target_vect_multiple_sizes { } {
6062 global et_vect_multiple_sizes_saved
6063 global et_index
6064
6065 set et_vect_multiple_sizes_saved($et_index) 0
6066 if { [istarget aarch64*-*-*]
6067 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])
6068 || (([istarget i?86-*-*] || [istarget x86_64-*-*])
6069 && ([check_avx_available] && ![check_prefer_avx128])) } {
6070 set et_vect_multiple_sizes_saved($et_index) 1
6071 }
6072
6073 verbose "check_effective_target_vect_multiple_sizes:\
6074 returning $et_vect_multiple_sizes_saved($et_index)" 2
6075 return $et_vect_multiple_sizes_saved($et_index)
6076 }
6077
6078 # Return 1 if the target supports vectors of 64 bits.
6079
6080 proc check_effective_target_vect64 { } {
6081 global et_vect64_saved
6082 global et_index
6083
6084 if [info exists et_vect64_saved($et_index)] {
6085 verbose "check_effective_target_vect64: using cached result" 2
6086 } else {
6087 set et_vect64_saved($et_index) 0
6088 if { ([istarget arm*-*-*]
6089 && [check_effective_target_arm_neon_ok]
6090 && [check_effective_target_arm_little_endian])
6091 || [istarget aarch64*-*-*]
6092 || [istarget sparc*-*-*] } {
6093 set et_vect64_saved($et_index) 1
6094 }
6095 }
6096
6097 verbose "check_effective_target_vect64:\
6098 returning $et_vect64_saved($et_index)" 2
6099 return $et_vect64_saved($et_index)
6100 }
6101
6102 # Return 1 if the target supports vector copysignf calls.
6103
6104 proc check_effective_target_vect_call_copysignf { } {
6105 global et_vect_call_copysignf_saved
6106 global et_index
6107
6108 if [info exists et_vect_call_copysignf_saved($et_index)] {
6109 verbose "check_effective_target_vect_call_copysignf:\
6110 using cached result" 2
6111 } else {
6112 set et_vect_call_copysignf_saved($et_index) 0
6113 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
6114 || [istarget powerpc*-*-*] } {
6115 set et_vect_call_copysignf_saved($et_index) 1
6116 }
6117 }
6118
6119 verbose "check_effective_target_vect_call_copysignf:\
6120 returning $et_vect_call_copysignf_saved($et_index)" 2
6121 return $et_vect_call_copysignf_saved($et_index)
6122 }
6123
6124 # Return 1 if the target supports hardware square root instructions.
6125
6126 proc check_effective_target_sqrt_insn { } {
6127 global et_sqrt_insn_saved
6128
6129 if [info exists et_sqrt_insn_saved] {
6130 verbose "check_effective_target_hw_sqrt: using cached result" 2
6131 } else {
6132 set et_sqrt_insn_saved 0
6133 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
6134 || [istarget powerpc*-*-*]
6135 || [istarget aarch64*-*-*]
6136 || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok]) } {
6137 set et_sqrt_insn_saved 1
6138 }
6139 }
6140
6141 verbose "check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
6142 return $et_sqrt_insn_saved
6143 }
6144
6145 # Return 1 if the target supports vector sqrtf calls.
6146
6147 proc check_effective_target_vect_call_sqrtf { } {
6148 global et_vect_call_sqrtf_saved
6149 global et_index
6150
6151 if [info exists et_vect_call_sqrtf_saved($et_index)] {
6152 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
6153 } else {
6154 set et_vect_call_sqrtf_saved($et_index) 0
6155 if { [istarget aarch64*-*-*]
6156 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6157 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
6158 set et_vect_call_sqrtf_saved($et_index) 1
6159 }
6160 }
6161
6162 verbose "check_effective_target_vect_call_sqrtf:\
6163 returning $et_vect_call_sqrtf_saved($et_index)" 2
6164 return $et_vect_call_sqrtf_saved($et_index)
6165 }
6166
6167 # Return 1 if the target supports vector lrint calls.
6168
6169 proc check_effective_target_vect_call_lrint { } {
6170 set et_vect_call_lrint 0
6171 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
6172 && [check_effective_target_ilp32]) } {
6173 set et_vect_call_lrint 1
6174 }
6175
6176 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
6177 return $et_vect_call_lrint
6178 }
6179
6180 # Return 1 if the target supports vector btrunc calls.
6181
6182 proc check_effective_target_vect_call_btrunc { } {
6183 global et_vect_call_btrunc_saved
6184 global et_index
6185
6186 if [info exists et_vect_call_btrunc_saved($et_index)] {
6187 verbose "check_effective_target_vect_call_btrunc:\
6188 using cached result" 2
6189 } else {
6190 set et_vect_call_btrunc_saved($et_index) 0
6191 if { [istarget aarch64*-*-*] } {
6192 set et_vect_call_btrunc_saved($et_index) 1
6193 }
6194 }
6195
6196 verbose "check_effective_target_vect_call_btrunc:\
6197 returning $et_vect_call_btrunc_saved($et_index)" 2
6198 return $et_vect_call_btrunc_saved($et_index)
6199 }
6200
6201 # Return 1 if the target supports vector btruncf calls.
6202
6203 proc check_effective_target_vect_call_btruncf { } {
6204 global et_vect_call_btruncf_saved
6205 global et_index
6206
6207 if [info exists et_vect_call_btruncf_saved($et_index)] {
6208 verbose "check_effective_target_vect_call_btruncf:\
6209 using cached result" 2
6210 } else {
6211 set et_vect_call_btruncf_saved($et_index) 0
6212 if { [istarget aarch64*-*-*] } {
6213 set et_vect_call_btruncf_saved($et_index) 1
6214 }
6215 }
6216
6217 verbose "check_effective_target_vect_call_btruncf:\
6218 returning $et_vect_call_btruncf_saved($et_index)" 2
6219 return $et_vect_call_btruncf_saved($et_index)
6220 }
6221
6222 # Return 1 if the target supports vector ceil calls.
6223
6224 proc check_effective_target_vect_call_ceil { } {
6225 global et_vect_call_ceil_saved
6226 global et_index
6227
6228 if [info exists et_vect_call_ceil_saved($et_index)] {
6229 verbose "check_effective_target_vect_call_ceil: using cached result" 2
6230 } else {
6231 set et_vect_call_ceil_saved($et_index) 0
6232 if { [istarget aarch64*-*-*] } {
6233 set et_vect_call_ceil_saved($et_index) 1
6234 }
6235 }
6236
6237 verbose "check_effective_target_vect_call_ceil:\
6238 returning $et_vect_call_ceil_saved($et_index)" 2
6239 return $et_vect_call_ceil_saved($et_index)
6240 }
6241
6242 # Return 1 if the target supports vector ceilf calls.
6243
6244 proc check_effective_target_vect_call_ceilf { } {
6245 global et_vect_call_ceilf_saved
6246 global et_index
6247
6248 if [info exists et_vect_call_ceilf_saved($et_index)] {
6249 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
6250 } else {
6251 set et_vect_call_ceilf_saved($et_index) 0
6252 if { [istarget aarch64*-*-*] } {
6253 set et_vect_call_ceilf_saved($et_index) 1
6254 }
6255 }
6256
6257 verbose "check_effective_target_vect_call_ceilf:\
6258 returning $et_vect_call_ceilf_saved($et_index)" 2
6259 return $et_vect_call_ceilf_saved($et_index)
6260 }
6261
6262 # Return 1 if the target supports vector floor calls.
6263
6264 proc check_effective_target_vect_call_floor { } {
6265 global et_vect_call_floor_saved
6266 global et_index
6267
6268 if [info exists et_vect_call_floor_saved($et_index)] {
6269 verbose "check_effective_target_vect_call_floor: using cached result" 2
6270 } else {
6271 set et_vect_call_floor_saved($et_index) 0
6272 if { [istarget aarch64*-*-*] } {
6273 set et_vect_call_floor_saved($et_index) 1
6274 }
6275 }
6276
6277 verbose "check_effective_target_vect_call_floor:\
6278 returning $et_vect_call_floor_saved($et_index)" 2
6279 return $et_vect_call_floor_saved($et_index)
6280 }
6281
6282 # Return 1 if the target supports vector floorf calls.
6283
6284 proc check_effective_target_vect_call_floorf { } {
6285 global et_vect_call_floorf_saved
6286 global et_index
6287
6288 if [info exists et_vect_call_floorf_saved($et_index)] {
6289 verbose "check_effective_target_vect_call_floorf: using cached result" 2
6290 } else {
6291 set et_vect_call_floorf_saved($et_index) 0
6292 if { [istarget aarch64*-*-*] } {
6293 set et_vect_call_floorf_saved($et_index) 1
6294 }
6295 }
6296
6297 verbose "check_effective_target_vect_call_floorf:\
6298 returning $et_vect_call_floorf_saved($et_index)" 2
6299 return $et_vect_call_floorf_saved($et_index)
6300 }
6301
6302 # Return 1 if the target supports vector lceil calls.
6303
6304 proc check_effective_target_vect_call_lceil { } {
6305 global et_vect_call_lceil_saved
6306 global et_index
6307
6308 if [info exists et_vect_call_lceil_saved($et_index)] {
6309 verbose "check_effective_target_vect_call_lceil: using cached result" 2
6310 } else {
6311 set et_vect_call_lceil_saved($et_index) 0
6312 if { [istarget aarch64*-*-*] } {
6313 set et_vect_call_lceil_saved($et_index) 1
6314 }
6315 }
6316
6317 verbose "check_effective_target_vect_call_lceil:\
6318 returning $et_vect_call_lceil_saved($et_index)" 2
6319 return $et_vect_call_lceil_saved($et_index)
6320 }
6321
6322 # Return 1 if the target supports vector lfloor calls.
6323
6324 proc check_effective_target_vect_call_lfloor { } {
6325 global et_vect_call_lfloor_saved
6326 global et_index
6327
6328 if [info exists et_vect_call_lfloor_saved($et_index)] {
6329 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
6330 } else {
6331 set et_vect_call_lfloor_saved($et_index) 0
6332 if { [istarget aarch64*-*-*] } {
6333 set et_vect_call_lfloor_saved($et_index) 1
6334 }
6335 }
6336
6337 verbose "check_effective_target_vect_call_lfloor:\
6338 returning $et_vect_call_lfloor_saved($et_index)" 2
6339 return $et_vect_call_lfloor_saved($et_index)
6340 }
6341
6342 # Return 1 if the target supports vector nearbyint calls.
6343
6344 proc check_effective_target_vect_call_nearbyint { } {
6345 global et_vect_call_nearbyint_saved
6346 global et_index
6347
6348 if [info exists et_vect_call_nearbyint_saved($et_index)] {
6349 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
6350 } else {
6351 set et_vect_call_nearbyint_saved($et_index) 0
6352 if { [istarget aarch64*-*-*] } {
6353 set et_vect_call_nearbyint_saved($et_index) 1
6354 }
6355 }
6356
6357 verbose "check_effective_target_vect_call_nearbyint:\
6358 returning $et_vect_call_nearbyint_saved($et_index)" 2
6359 return $et_vect_call_nearbyint_saved($et_index)
6360 }
6361
6362 # Return 1 if the target supports vector nearbyintf calls.
6363
6364 proc check_effective_target_vect_call_nearbyintf { } {
6365 global et_vect_call_nearbyintf_saved
6366 global et_index
6367
6368 if [info exists et_vect_call_nearbyintf_saved($et_index)] {
6369 verbose "check_effective_target_vect_call_nearbyintf:\
6370 using cached result" 2
6371 } else {
6372 set et_vect_call_nearbyintf_saved($et_index) 0
6373 if { [istarget aarch64*-*-*] } {
6374 set et_vect_call_nearbyintf_saved($et_index) 1
6375 }
6376 }
6377
6378 verbose "check_effective_target_vect_call_nearbyintf:\
6379 returning $et_vect_call_nearbyintf_saved($et_index)" 2
6380 return $et_vect_call_nearbyintf_saved($et_index)
6381 }
6382
6383 # Return 1 if the target supports vector round calls.
6384
6385 proc check_effective_target_vect_call_round { } {
6386 global et_vect_call_round_saved
6387 global et_index
6388
6389 if [info exists et_vect_call_round_saved($et_index)] {
6390 verbose "check_effective_target_vect_call_round: using cached result" 2
6391 } else {
6392 set et_vect_call_round_saved($et_index) 0
6393 if { [istarget aarch64*-*-*] } {
6394 set et_vect_call_round_saved($et_index) 1
6395 }
6396 }
6397
6398 verbose "check_effective_target_vect_call_round:\
6399 returning $et_vect_call_round_saved($et_index)" 2
6400 return $et_vect_call_round_saved($et_index)
6401 }
6402
6403 # Return 1 if the target supports vector roundf calls.
6404
6405 proc check_effective_target_vect_call_roundf { } {
6406 global et_vect_call_roundf_saved
6407 global et_index
6408
6409 if [info exists et_vect_call_roundf_saved($et_index)] {
6410 verbose "check_effective_target_vect_call_roundf: using cached result" 2
6411 } else {
6412 set et_vect_call_roundf_saved($et_index) 0
6413 if { [istarget aarch64*-*-*] } {
6414 set et_vect_call_roundf_saved($et_index) 1
6415 }
6416 }
6417
6418 verbose "check_effective_target_vect_call_roundf:\
6419 returning $et_vect_call_roundf_saved($et_index)" 2
6420 return $et_vect_call_roundf_saved($et_index)
6421 }
6422
6423 # Return 1 if the target supports section-anchors
6424
6425 proc check_effective_target_section_anchors { } {
6426 global et_section_anchors_saved
6427
6428 if [info exists et_section_anchors_saved] {
6429 verbose "check_effective_target_section_anchors: using cached result" 2
6430 } else {
6431 set et_section_anchors_saved 0
6432 if { [istarget powerpc*-*-*]
6433 || [istarget arm*-*-*]
6434 || [istarget aarch64*-*-*] } {
6435 set et_section_anchors_saved 1
6436 }
6437 }
6438
6439 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
6440 return $et_section_anchors_saved
6441 }
6442
6443 # Return 1 if the target supports atomic operations on "int_128" values.
6444
6445 proc check_effective_target_sync_int_128 { } {
6446 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
6447 && ![is-effective-target ia32])
6448 || [istarget spu-*-*] } {
6449 return 1
6450 } else {
6451 return 0
6452 }
6453 }
6454
6455 # Return 1 if the target supports atomic operations on "int_128" values
6456 # and can execute them.
6457
6458 proc check_effective_target_sync_int_128_runtime { } {
6459 if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
6460 && ![is-effective-target ia32]
6461 && [check_cached_effective_target sync_int_128_available {
6462 check_runtime_nocache sync_int_128_available {
6463 #include "cpuid.h"
6464 int main ()
6465 {
6466 unsigned int eax, ebx, ecx, edx;
6467 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
6468 return !(ecx & bit_CMPXCHG16B);
6469 return 1;
6470 }
6471 } ""
6472 }])
6473 || [istarget spu-*-*] } {
6474 return 1
6475 } else {
6476 return 0
6477 }
6478 }
6479
6480 # Return 1 if the target supports atomic operations on "long long".
6481 #
6482 # Note: 32bit x86 targets require -march=pentium in dg-options.
6483 # Note: 32bit s390 targets require -mzarch in dg-options.
6484
6485 proc check_effective_target_sync_long_long { } {
6486 if { [istarget i?86-*-*] || [istarget x86_64-*-*])
6487 || [istarget aarch64*-*-*]
6488 || [istarget arm*-*-*]
6489 || [istarget alpha*-*-*]
6490 || ([istarget sparc*-*-*] && [check_effective_target_lp64])
6491 || [istarget s390*-*-*]
6492 || [istarget spu-*-*] } {
6493 return 1
6494 } else {
6495 return 0
6496 }
6497 }
6498
6499 # Return 1 if the target supports atomic operations on "long long"
6500 # and can execute them.
6501 #
6502 # Note: 32bit x86 targets require -march=pentium in dg-options.
6503
6504 proc check_effective_target_sync_long_long_runtime { } {
6505 if { (([istarget x86_64-*-*] || [istarget i?86-*-*])
6506 && [check_cached_effective_target sync_long_long_available {
6507 check_runtime_nocache sync_long_long_available {
6508 #include "cpuid.h"
6509 int main ()
6510 {
6511 unsigned int eax, ebx, ecx, edx;
6512 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
6513 return !(edx & bit_CMPXCHG8B);
6514 return 1;
6515 }
6516 } ""
6517 }])
6518 || [istarget aarch64*-*-*]
6519 || ([istarget arm*-*-linux-*]
6520 && [check_runtime sync_longlong_runtime {
6521 #include <stdlib.h>
6522 int main ()
6523 {
6524 long long l1;
6525
6526 if (sizeof (long long) != 8)
6527 exit (1);
6528
6529 /* Just check for native;
6530 checking for kernel fallback is tricky. */
6531 asm volatile ("ldrexd r0,r1, [%0]"
6532 : : "r" (&l1) : "r0", "r1");
6533 exit (0);
6534 }
6535 } "" ])
6536 || [istarget alpha*-*-*]
6537 || ([istarget sparc*-*-*]
6538 && [check_effective_target_lp64]
6539 && [check_effective_target_ultrasparc_hw])
6540 || [istarget spu-*-*]
6541 || ([istarget powerpc*-*-*] && [check_effective_target_lp64]) } {
6542 return 1
6543 } else {
6544 return 0
6545 }
6546 }
6547
6548 # Return 1 if the target supports byte swap instructions.
6549
6550 proc check_effective_target_bswap { } {
6551 global et_bswap_saved
6552
6553 if [info exists et_bswap_saved] {
6554 verbose "check_effective_target_bswap: using cached result" 2
6555 } else {
6556 set et_bswap_saved 0
6557 if { [istarget aarch64*-*-*]
6558 || [istarget alpha*-*-*]
6559 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6560 || [istarget m68k-*-*]
6561 || [istarget powerpc*-*-*]
6562 || [istarget rs6000-*-*]
6563 || [istarget s390*-*-*]
6564 || ([istarget arm*-*-*]
6565 && [check_no_compiler_messages_nocache arm_v6_or_later object {
6566 #if __ARM_ARCH < 6
6567 #error not armv6 or later
6568 #endif
6569 int i;
6570 } ""]) } {
6571 set et_bswap_saved 1
6572 }
6573 }
6574
6575 verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
6576 return $et_bswap_saved
6577 }
6578
6579 # Return 1 if the target supports 16-bit byte swap instructions.
6580
6581 proc check_effective_target_bswap16 { } {
6582 global et_bswap16_saved
6583
6584 if [info exists et_bswap16_saved] {
6585 verbose "check_effective_target_bswap16: using cached result" 2
6586 } else {
6587 set et_bswap16_saved 0
6588 if { [is-effective-target bswap]
6589 && ![istarget alpha*-*-*]
6590 && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
6591 set et_bswap16_saved 1
6592 }
6593 }
6594
6595 verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
6596 return $et_bswap16_saved
6597 }
6598
6599 # Return 1 if the target supports 32-bit byte swap instructions.
6600
6601 proc check_effective_target_bswap32 { } {
6602 global et_bswap32_saved
6603
6604 if [info exists et_bswap32_saved] {
6605 verbose "check_effective_target_bswap32: using cached result" 2
6606 } else {
6607 set et_bswap32_saved 0
6608 if { [is-effective-target bswap] } {
6609 set et_bswap32_saved 1
6610 }
6611 }
6612
6613 verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
6614 return $et_bswap32_saved
6615 }
6616
6617 # Return 1 if the target supports 64-bit byte swap instructions.
6618 #
6619 # Note: 32bit s390 targets require -mzarch in dg-options.
6620
6621 proc check_effective_target_bswap64 { } {
6622 global et_bswap64_saved
6623
6624 # expand_unop can expand 64-bit byte swap on 32-bit targets
6625 if { [is-effective-target bswap] && [is-effective-target int32plus] } {
6626 return 1
6627 }
6628 return 0
6629 }
6630
6631 # Return 1 if the target supports atomic operations on "int" and "long".
6632
6633 proc check_effective_target_sync_int_long { } {
6634 global et_sync_int_long_saved
6635
6636 if [info exists et_sync_int_long_saved] {
6637 verbose "check_effective_target_sync_int_long: using cached result" 2
6638 } else {
6639 set et_sync_int_long_saved 0
6640 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
6641 # load-reserved/store-conditional instructions.
6642 if { [istarget ia64-*-*]
6643 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6644 || [istarget aarch64*-*-*]
6645 || [istarget alpha*-*-*]
6646 || [istarget arm*-*-linux-*]
6647 || ([istarget arm*-*-*]
6648 && [check_effective_target_arm_acq_rel])
6649 || [istarget bfin*-*linux*]
6650 || [istarget hppa*-*linux*]
6651 || [istarget s390*-*-*]
6652 || [istarget powerpc*-*-*]
6653 || [istarget crisv32-*-*] || [istarget cris-*-*]
6654 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
6655 || [istarget spu-*-*]
6656 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
6657 || [check_effective_target_mips_llsc] } {
6658 set et_sync_int_long_saved 1
6659 }
6660 }
6661
6662 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
6663 return $et_sync_int_long_saved
6664 }
6665
6666 # Return 1 if the target supports atomic operations on "char" and "short".
6667
6668 proc check_effective_target_sync_char_short { } {
6669 global et_sync_char_short_saved
6670
6671 if [info exists et_sync_char_short_saved] {
6672 verbose "check_effective_target_sync_char_short: using cached result" 2
6673 } else {
6674 set et_sync_char_short_saved 0
6675 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
6676 # load-reserved/store-conditional instructions.
6677 if { [istarget aarch64*-*-*]
6678 || [istarget ia64-*-*]
6679 || [istarget i?86-*-*] || [istarget x86_64-*-*]
6680 || [istarget alpha*-*-*]
6681 || [istarget arm*-*-linux-*]
6682 || ([istarget arm*-*-*]
6683 && [check_effective_target_arm_acq_rel])
6684 || [istarget hppa*-*linux*]
6685 || [istarget s390*-*-*]
6686 || [istarget powerpc*-*-*]
6687 || [istarget crisv32-*-*] || [istarget cris-*-*]
6688 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
6689 || [istarget spu-*-*]
6690 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
6691 || [check_effective_target_mips_llsc] } {
6692 set et_sync_char_short_saved 1
6693 }
6694 }
6695
6696 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
6697 return $et_sync_char_short_saved
6698 }
6699
6700 # Return 1 if the target uses a ColdFire FPU.
6701
6702 proc check_effective_target_coldfire_fpu { } {
6703 return [check_no_compiler_messages coldfire_fpu assembly {
6704 #ifndef __mcffpu__
6705 #error !__mcffpu__
6706 #endif
6707 }]
6708 }
6709
6710 # Return true if this is a uClibc target.
6711
6712 proc check_effective_target_uclibc {} {
6713 return [check_no_compiler_messages uclibc object {
6714 #include <features.h>
6715 #if !defined (__UCLIBC__)
6716 #error !__UCLIBC__
6717 #endif
6718 }]
6719 }
6720
6721 # Return true if this is a uclibc target and if the uclibc feature
6722 # described by __$feature__ is not present.
6723
6724 proc check_missing_uclibc_feature {feature} {
6725 return [check_no_compiler_messages $feature object "
6726 #include <features.h>
6727 #if !defined (__UCLIBC) || defined (__${feature}__)
6728 #error FOO
6729 #endif
6730 "]
6731 }
6732
6733 # Return true if this is a Newlib target.
6734
6735 proc check_effective_target_newlib {} {
6736 return [check_no_compiler_messages newlib object {
6737 #include <newlib.h>
6738 }]
6739 }
6740
6741 # Return true if this is NOT a Bionic target.
6742
6743 proc check_effective_target_non_bionic {} {
6744 return [check_no_compiler_messages non_bionic object {
6745 #include <ctype.h>
6746 #if defined (__BIONIC__)
6747 #error FOO
6748 #endif
6749 }]
6750 }
6751
6752 # Return true if this target has error.h header.
6753
6754 proc check_effective_target_error_h {} {
6755 return [check_no_compiler_messages error_h object {
6756 #include <error.h>
6757 }]
6758 }
6759
6760 # Return true if this target has tgmath.h header.
6761
6762 proc check_effective_target_tgmath_h {} {
6763 return [check_no_compiler_messages tgmath_h object {
6764 #include <tgmath.h>
6765 }]
6766 }
6767
6768 # Return true if target's libc supports complex functions.
6769
6770 proc check_effective_target_libc_has_complex_functions {} {
6771 return [check_no_compiler_messages libc_has_complex_functions object {
6772 #include <complex.h>
6773 }]
6774 }
6775
6776 # Return 1 if
6777 # (a) an error of a few ULP is expected in string to floating-point
6778 # conversion functions; and
6779 # (b) overflow is not always detected correctly by those functions.
6780
6781 proc check_effective_target_lax_strtofp {} {
6782 # By default, assume that all uClibc targets suffer from this.
6783 return [check_effective_target_uclibc]
6784 }
6785
6786 # Return 1 if this is a target for which wcsftime is a dummy
6787 # function that always returns 0.
6788
6789 proc check_effective_target_dummy_wcsftime {} {
6790 # By default, assume that all uClibc targets suffer from this.
6791 return [check_effective_target_uclibc]
6792 }
6793
6794 # Return 1 if constructors with initialization priority arguments are
6795 # supposed on this target.
6796
6797 proc check_effective_target_init_priority {} {
6798 return [check_no_compiler_messages init_priority assembly "
6799 void f() __attribute__((constructor (1000)));
6800 void f() \{\}
6801 "]
6802 }
6803
6804 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
6805 # This can be used with any check_* proc that takes no argument and
6806 # returns only 1 or 0. It could be used with check_* procs that take
6807 # arguments with keywords that pass particular arguments.
6808
6809 proc is-effective-target { arg } {
6810 global et_index
6811 set selected 0
6812 if { ![info exists et_index] } {
6813 # Initialize the effective target index that is used in some
6814 # check_effective_target_* procs.
6815 set et_index 0
6816 }
6817 if { [info procs check_effective_target_${arg}] != [list] } {
6818 set selected [check_effective_target_${arg}]
6819 } else {
6820 switch $arg {
6821 "vmx_hw" { set selected [check_vmx_hw_available] }
6822 "vsx_hw" { set selected [check_vsx_hw_available] }
6823 "p8vector_hw" { set selected [check_p8vector_hw_available] }
6824 "p9vector_hw" { set selected [check_p9vector_hw_available] }
6825 "p9modulo_hw" { set selected [check_p9modulo_hw_available] }
6826 "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
6827 "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
6828 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
6829 "dfp_hw" { set selected [check_dfp_hw_available] }
6830 "htm_hw" { set selected [check_htm_hw_available] }
6831 "named_sections" { set selected [check_named_sections_available] }
6832 "gc_sections" { set selected [check_gc_sections_available] }
6833 "cxa_atexit" { set selected [check_cxa_atexit_available] }
6834 default { error "unknown effective target keyword `$arg'" }
6835 }
6836 }
6837 verbose "is-effective-target: $arg $selected" 2
6838 return $selected
6839 }
6840
6841 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
6842
6843 proc is-effective-target-keyword { arg } {
6844 if { [info procs check_effective_target_${arg}] != [list] } {
6845 return 1
6846 } else {
6847 # These have different names for their check_* procs.
6848 switch $arg {
6849 "vmx_hw" { return 1 }
6850 "vsx_hw" { return 1 }
6851 "p8vector_hw" { return 1 }
6852 "p9vector_hw" { return 1 }
6853 "p9modulo_hw" { return 1 }
6854 "ppc_float128_sw" { return 1 }
6855 "ppc_float128_hw" { return 1 }
6856 "ppc_recip_hw" { return 1 }
6857 "dfp_hw" { return 1 }
6858 "htm_hw" { return 1 }
6859 "named_sections" { return 1 }
6860 "gc_sections" { return 1 }
6861 "cxa_atexit" { return 1 }
6862 default { return 0 }
6863 }
6864 }
6865 }
6866
6867 # Execute tests for all targets in EFFECTIVE_TARGETS list. Set et_index to
6868 # indicate what target is currently being processed. This is for
6869 # the vectorizer tests, e.g. vect_int, to keep track what target supports
6870 # a given feature.
6871
6872 proc et-dg-runtest { runtest testcases flags default-extra-flags } {
6873 global dg-do-what-default
6874 global EFFECTIVE_TARGETS
6875 global et_index
6876
6877 if { [llength $EFFECTIVE_TARGETS] > 0 } {
6878 foreach target $EFFECTIVE_TARGETS {
6879 set target_flags $flags
6880 set dg-do-what-default compile
6881 set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
6882 if { [info procs add_options_for_${target}] != [list] } {
6883 set target_flags [add_options_for_${target} "$flags"]
6884 }
6885 if { [info procs check_effective_target_${target}_runtime]
6886 != [list] && [check_effective_target_${target}_runtime] } {
6887 set dg-do-what-default run
6888 }
6889 $runtest $testcases $target_flags ${default-extra-flags}
6890 }
6891 } else {
6892 set et_index 0
6893 $runtest $testcases $flags ${default-extra-flags}
6894 }
6895 }
6896
6897 # Return 1 if a target matches the target in EFFECTIVE_TARGETS at index
6898 # et_index, 0 otherwise.
6899
6900 proc et-is-effective-target { target } {
6901 global EFFECTIVE_TARGETS
6902 global et_index
6903
6904 if { [llength $EFFECTIVE_TARGETS] > $et_index
6905 && [lindex $EFFECTIVE_TARGETS $et_index] == $target } {
6906 return 1
6907 }
6908 return 0
6909 }
6910
6911 # Return 1 if target default to short enums
6912
6913 proc check_effective_target_short_enums { } {
6914 return [check_no_compiler_messages short_enums assembly {
6915 enum foo { bar };
6916 int s[sizeof (enum foo) == 1 ? 1 : -1];
6917 }]
6918 }
6919
6920 # Return 1 if target supports merging string constants at link time.
6921
6922 proc check_effective_target_string_merging { } {
6923 return [check_no_messages_and_pattern string_merging \
6924 "rodata\\.str" assembly {
6925 const char *var = "String";
6926 } {-O2}]
6927 }
6928
6929 # Return 1 if target has the basic signed and unsigned types in
6930 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
6931 # working <stdint.h> for all targets.
6932
6933 proc check_effective_target_stdint_types { } {
6934 return [check_no_compiler_messages stdint_types assembly {
6935 #include <stdint.h>
6936 int8_t a; int16_t b; int32_t c; int64_t d;
6937 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
6938 }]
6939 }
6940
6941 # Return 1 if target has the basic signed and unsigned types in
6942 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
6943 # these types agree with those in the header, as some systems have
6944 # only <inttypes.h>.
6945
6946 proc check_effective_target_inttypes_types { } {
6947 return [check_no_compiler_messages inttypes_types assembly {
6948 #include <inttypes.h>
6949 int8_t a; int16_t b; int32_t c; int64_t d;
6950 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
6951 }]
6952 }
6953
6954 # Return 1 if programs are intended to be run on a simulator
6955 # (i.e. slowly) rather than hardware (i.e. fast).
6956
6957 proc check_effective_target_simulator { } {
6958
6959 # All "src/sim" simulators set this one.
6960 if [board_info target exists is_simulator] {
6961 return [board_info target is_simulator]
6962 }
6963
6964 # The "sid" simulators don't set that one, but at least they set
6965 # this one.
6966 if [board_info target exists slow_simulator] {
6967 return [board_info target slow_simulator]
6968 }
6969
6970 return 0
6971 }
6972
6973 # Return 1 if programs are intended to be run on hardware rather than
6974 # on a simulator
6975
6976 proc check_effective_target_hw { } {
6977
6978 # All "src/sim" simulators set this one.
6979 if [board_info target exists is_simulator] {
6980 if [board_info target is_simulator] {
6981 return 0
6982 } else {
6983 return 1
6984 }
6985 }
6986
6987 # The "sid" simulators don't set that one, but at least they set
6988 # this one.
6989 if [board_info target exists slow_simulator] {
6990 if [board_info target slow_simulator] {
6991 return 0
6992 } else {
6993 return 1
6994 }
6995 }
6996
6997 return 1
6998 }
6999
7000 # Return 1 if the target is a VxWorks kernel.
7001
7002 proc check_effective_target_vxworks_kernel { } {
7003 return [check_no_compiler_messages vxworks_kernel assembly {
7004 #if !defined __vxworks || defined __RTP__
7005 #error NO
7006 #endif
7007 }]
7008 }
7009
7010 # Return 1 if the target is a VxWorks RTP.
7011
7012 proc check_effective_target_vxworks_rtp { } {
7013 return [check_no_compiler_messages vxworks_rtp assembly {
7014 #if !defined __vxworks || !defined __RTP__
7015 #error NO
7016 #endif
7017 }]
7018 }
7019
7020 # Return 1 if the target is expected to provide wide character support.
7021
7022 proc check_effective_target_wchar { } {
7023 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
7024 return 0
7025 }
7026 return [check_no_compiler_messages wchar assembly {
7027 #include <wchar.h>
7028 }]
7029 }
7030
7031 # Return 1 if the target has <pthread.h>.
7032
7033 proc check_effective_target_pthread_h { } {
7034 return [check_no_compiler_messages pthread_h assembly {
7035 #include <pthread.h>
7036 }]
7037 }
7038
7039 # Return 1 if the target can truncate a file from a file-descriptor,
7040 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
7041 # chsize. We test for a trivially functional truncation; no stubs.
7042 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
7043 # different function to be used.
7044
7045 proc check_effective_target_fd_truncate { } {
7046 set prog {
7047 #define _FILE_OFFSET_BITS 64
7048 #include <unistd.h>
7049 #include <stdio.h>
7050 #include <stdlib.h>
7051 #include <string.h>
7052 int main ()
7053 {
7054 FILE *f = fopen ("tst.tmp", "wb");
7055 int fd;
7056 const char t[] = "test writing more than ten characters";
7057 char s[11];
7058 int status = 0;
7059 fd = fileno (f);
7060 write (fd, t, sizeof (t) - 1);
7061 lseek (fd, 0, 0);
7062 if (ftruncate (fd, 10) != 0)
7063 status = 1;
7064 close (fd);
7065 fclose (f);
7066 if (status)
7067 {
7068 unlink ("tst.tmp");
7069 exit (status);
7070 }
7071 f = fopen ("tst.tmp", "rb");
7072 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
7073 status = 1;
7074 fclose (f);
7075 unlink ("tst.tmp");
7076 exit (status);
7077 }
7078 }
7079
7080 if { [check_runtime ftruncate $prog] } {
7081 return 1;
7082 }
7083
7084 regsub "ftruncate" $prog "chsize" prog
7085 return [check_runtime chsize $prog]
7086 }
7087
7088 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
7089
7090 proc add_options_for_c99_runtime { flags } {
7091 if { [istarget *-*-solaris2*] } {
7092 return "$flags -std=c99"
7093 }
7094 if { [istarget powerpc-*-darwin*] } {
7095 return "$flags -mmacosx-version-min=10.3"
7096 }
7097 return $flags
7098 }
7099
7100 # Add to FLAGS all the target-specific flags needed to enable
7101 # full IEEE compliance mode.
7102
7103 proc add_options_for_ieee { flags } {
7104 if { [istarget alpha*-*-*]
7105 || [istarget sh*-*-*] } {
7106 return "$flags -mieee"
7107 }
7108 if { [istarget rx-*-*] } {
7109 return "$flags -mnofpu"
7110 }
7111 return $flags
7112 }
7113
7114 if {![info exists flags_to_postpone]} {
7115 set flags_to_postpone ""
7116 }
7117
7118 # Add to FLAGS the flags needed to enable functions to bind locally
7119 # when using pic/PIC passes in the testsuite.
7120 proc add_options_for_bind_pic_locally { flags } {
7121 global flags_to_postpone
7122
7123 # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
7124 # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
7125 # order to make sure that the multilib_flags doesn't override this.
7126
7127 if {[check_no_compiler_messages using_pic2 assembly {
7128 #if __PIC__ != 2
7129 #error __PIC__ != 2
7130 #endif
7131 }]} {
7132 set flags_to_postpone "-fPIE"
7133 return $flags
7134 }
7135 if {[check_no_compiler_messages using_pic1 assembly {
7136 #if __PIC__ != 1
7137 #error __PIC__ != 1
7138 #endif
7139 }]} {
7140 set flags_to_postpone "-fpie"
7141 return $flags
7142 }
7143 return $flags
7144 }
7145
7146 # Add to FLAGS the flags needed to enable 64-bit vectors.
7147
7148 proc add_options_for_double_vectors { flags } {
7149 if [is-effective-target arm_neon_ok] {
7150 return "$flags -mvectorize-with-neon-double"
7151 }
7152
7153 return $flags
7154 }
7155
7156 # Return 1 if the target provides a full C99 runtime.
7157
7158 proc check_effective_target_c99_runtime { } {
7159 return [check_cached_effective_target c99_runtime {
7160 global srcdir
7161
7162 set file [open "$srcdir/gcc.dg/builtins-config.h"]
7163 set contents [read $file]
7164 close $file
7165 append contents {
7166 #ifndef HAVE_C99_RUNTIME
7167 #error !HAVE_C99_RUNTIME
7168 #endif
7169 }
7170 check_no_compiler_messages_nocache c99_runtime assembly \
7171 $contents [add_options_for_c99_runtime ""]
7172 }]
7173 }
7174
7175 # Return 1 if target wchar_t is at least 4 bytes.
7176
7177 proc check_effective_target_4byte_wchar_t { } {
7178 return [check_no_compiler_messages 4byte_wchar_t object {
7179 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
7180 }]
7181 }
7182
7183 # Return 1 if the target supports automatic stack alignment.
7184
7185 proc check_effective_target_automatic_stack_alignment { } {
7186 # Ordinarily x86 supports automatic stack alignment ...
7187 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
7188 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
7189 # ... except Win64 SEH doesn't. Succeed for Win32 though.
7190 return [check_effective_target_ilp32];
7191 }
7192 return 1;
7193 }
7194 return 0;
7195 }
7196
7197 # Return true if we are compiling for AVX target.
7198
7199 proc check_avx_available { } {
7200 if { [check_no_compiler_messages avx_available assembly {
7201 #ifndef __AVX__
7202 #error unsupported
7203 #endif
7204 } ""] } {
7205 return 1;
7206 }
7207 return 0;
7208 }
7209
7210 # Return true if 32- and 16-bytes vectors are available.
7211
7212 proc check_effective_target_vect_sizes_32B_16B { } {
7213 if { [check_avx_available] && ![check_prefer_avx128] } {
7214 return 1;
7215 } else {
7216 return 0;
7217 }
7218 }
7219
7220 # Return true if 128-bits vectors are preferred even if 256-bits vectors
7221 # are available.
7222
7223 proc check_prefer_avx128 { } {
7224 if ![check_avx_available] {
7225 return 0;
7226 }
7227 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
7228 float a[1024],b[1024],c[1024];
7229 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
7230 } "-O2 -ftree-vectorize"]
7231 }
7232
7233
7234 # Return 1 if avx512f instructions can be compiled.
7235
7236 proc check_effective_target_avx512f { } {
7237 return [check_no_compiler_messages avx512f object {
7238 typedef double __m512d __attribute__ ((__vector_size__ (64)));
7239
7240 __m512d _mm512_add (__m512d a)
7241 {
7242 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
7243 }
7244 } "-O2 -mavx512f" ]
7245 }
7246
7247 # Return 1 if avx instructions can be compiled.
7248
7249 proc check_effective_target_avx { } {
7250 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
7251 return 0
7252 }
7253 return [check_no_compiler_messages avx object {
7254 void _mm256_zeroall (void)
7255 {
7256 __builtin_ia32_vzeroall ();
7257 }
7258 } "-O2 -mavx" ]
7259 }
7260
7261 # Return 1 if avx2 instructions can be compiled.
7262 proc check_effective_target_avx2 { } {
7263 return [check_no_compiler_messages avx2 object {
7264 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
7265 __v4di
7266 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
7267 {
7268 return __builtin_ia32_andnotsi256 (__X, __Y);
7269 }
7270 } "-O0 -mavx2" ]
7271 }
7272
7273 # Return 1 if sse instructions can be compiled.
7274 proc check_effective_target_sse { } {
7275 return [check_no_compiler_messages sse object {
7276 int main ()
7277 {
7278 __builtin_ia32_stmxcsr ();
7279 return 0;
7280 }
7281 } "-O2 -msse" ]
7282 }
7283
7284 # Return 1 if sse2 instructions can be compiled.
7285 proc check_effective_target_sse2 { } {
7286 return [check_no_compiler_messages sse2 object {
7287 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
7288
7289 __m128i _mm_srli_si128 (__m128i __A, int __N)
7290 {
7291 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
7292 }
7293 } "-O2 -msse2" ]
7294 }
7295
7296 # Return 1 if sse4.1 instructions can be compiled.
7297 proc check_effective_target_sse4 { } {
7298 return [check_no_compiler_messages sse4.1 object {
7299 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
7300 typedef int __v4si __attribute__ ((__vector_size__ (16)));
7301
7302 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
7303 {
7304 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
7305 (__v4si)__Y);
7306 }
7307 } "-O2 -msse4.1" ]
7308 }
7309
7310 # Return 1 if F16C instructions can be compiled.
7311
7312 proc check_effective_target_f16c { } {
7313 return [check_no_compiler_messages f16c object {
7314 #include "immintrin.h"
7315 float
7316 foo (unsigned short val)
7317 {
7318 return _cvtsh_ss (val);
7319 }
7320 } "-O2 -mf16c" ]
7321 }
7322
7323 # Return 1 if C wchar_t type is compatible with char16_t.
7324
7325 proc check_effective_target_wchar_t_char16_t_compatible { } {
7326 return [check_no_compiler_messages wchar_t_char16_t object {
7327 __WCHAR_TYPE__ wc;
7328 __CHAR16_TYPE__ *p16 = &wc;
7329 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
7330 }]
7331 }
7332
7333 # Return 1 if C wchar_t type is compatible with char32_t.
7334
7335 proc check_effective_target_wchar_t_char32_t_compatible { } {
7336 return [check_no_compiler_messages wchar_t_char32_t object {
7337 __WCHAR_TYPE__ wc;
7338 __CHAR32_TYPE__ *p32 = &wc;
7339 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
7340 }]
7341 }
7342
7343 # Return 1 if pow10 function exists.
7344
7345 proc check_effective_target_pow10 { } {
7346 return [check_runtime pow10 {
7347 #include <math.h>
7348 int main () {
7349 double x;
7350 x = pow10 (1);
7351 return 0;
7352 }
7353 } "-lm" ]
7354 }
7355
7356 # Return 1 if issignaling function exists.
7357 proc check_effective_target_issignaling {} {
7358 return [check_runtime issignaling {
7359 #define _GNU_SOURCE
7360 #include <math.h>
7361 int main ()
7362 {
7363 return issignaling (0.0);
7364 }
7365 } "-lm" ]
7366 }
7367
7368 # Return 1 if current options generate DFP instructions, 0 otherwise.
7369 proc check_effective_target_hard_dfp {} {
7370 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
7371 typedef float d64 __attribute__((mode(DD)));
7372 d64 x, y, z;
7373 void foo (void) { z = x + y; }
7374 }]
7375 }
7376
7377 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
7378 # for strchr etc. functions.
7379
7380 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
7381 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
7382 #include <string.h>
7383 #include <wchar.h>
7384 #if !defined(__cplusplus) \
7385 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
7386 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
7387 ISO C++ correct string.h and wchar.h protos not supported.
7388 #else
7389 int i;
7390 #endif
7391 }]
7392 }
7393
7394 # Return 1 if GNU as is used.
7395
7396 proc check_effective_target_gas { } {
7397 global use_gas_saved
7398 global tool
7399
7400 if {![info exists use_gas_saved]} {
7401 # Check if the as used by gcc is GNU as.
7402 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
7403 # Provide /dev/null as input, otherwise gas times out reading from
7404 # stdin.
7405 set status [remote_exec host "$gcc_as" "-v /dev/null"]
7406 set as_output [lindex $status 1]
7407 if { [ string first "GNU" $as_output ] >= 0 } {
7408 set use_gas_saved 1
7409 } else {
7410 set use_gas_saved 0
7411 }
7412 }
7413 return $use_gas_saved
7414 }
7415
7416 # Return 1 if GNU ld is used.
7417
7418 proc check_effective_target_gld { } {
7419 global use_gld_saved
7420 global tool
7421
7422 if {![info exists use_gld_saved]} {
7423 # Check if the ld used by gcc is GNU ld.
7424 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
7425 set status [remote_exec host "$gcc_ld" "--version"]
7426 set ld_output [lindex $status 1]
7427 if { [ string first "GNU" $ld_output ] >= 0 } {
7428 set use_gld_saved 1
7429 } else {
7430 set use_gld_saved 0
7431 }
7432 }
7433 return $use_gld_saved
7434 }
7435
7436 # Return 1 if the compiler has been configure with link-time optimization
7437 # (LTO) support.
7438
7439 proc check_effective_target_lto { } {
7440 if { [istarget nvptx-*-*] } {
7441 return 0;
7442 }
7443 return [check_no_compiler_messages lto object {
7444 void foo (void) { }
7445 } "-flto"]
7446 }
7447
7448 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
7449
7450 proc check_effective_target_maybe_x32 { } {
7451 return [check_no_compiler_messages maybe_x32 object {
7452 void foo (void) {}
7453 } "-mx32 -maddress-mode=short"]
7454 }
7455
7456 # Return 1 if this target supports the -fsplit-stack option, 0
7457 # otherwise.
7458
7459 proc check_effective_target_split_stack {} {
7460 return [check_no_compiler_messages split_stack object {
7461 void foo (void) { }
7462 } "-fsplit-stack"]
7463 }
7464
7465 # Return 1 if this target supports the -masm=intel option, 0
7466 # otherwise
7467
7468 proc check_effective_target_masm_intel {} {
7469 return [check_no_compiler_messages masm_intel object {
7470 extern void abort (void);
7471 } "-masm=intel"]
7472 }
7473
7474 # Return 1 if the language for the compiler under test is C.
7475
7476 proc check_effective_target_c { } {
7477 global tool
7478 if [string match $tool "gcc"] {
7479 return 1
7480 }
7481 return 0
7482 }
7483
7484 # Return 1 if the language for the compiler under test is C++.
7485
7486 proc check_effective_target_c++ { } {
7487 global tool
7488 if { [string match $tool "g++"] || [string match $tool "libstdc++"] } {
7489 return 1
7490 }
7491 return 0
7492 }
7493
7494 set cxx_default "c++14"
7495 # Check whether the current active language standard supports the features
7496 # of C++11/C++14 by checking for the presence of one of the -std flags.
7497 # This assumes that the default for the compiler is $cxx_default, and that
7498 # there will never be multiple -std= arguments on the command line.
7499 proc check_effective_target_c++11_only { } {
7500 global cxx_default
7501 if ![check_effective_target_c++] {
7502 return 0
7503 }
7504 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
7505 return 1
7506 }
7507 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
7508 return 1
7509 }
7510 return 0
7511 }
7512 proc check_effective_target_c++11 { } {
7513 if [check_effective_target_c++11_only] {
7514 return 1
7515 }
7516 return [check_effective_target_c++14]
7517 }
7518 proc check_effective_target_c++11_down { } {
7519 if ![check_effective_target_c++] {
7520 return 0
7521 }
7522 return [expr ![check_effective_target_c++14] ]
7523 }
7524
7525 proc check_effective_target_c++14_only { } {
7526 global cxx_default
7527 if ![check_effective_target_c++] {
7528 return 0
7529 }
7530 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
7531 return 1
7532 }
7533 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
7534 return 1
7535 }
7536 return 0
7537 }
7538
7539 proc check_effective_target_c++14 { } {
7540 if [check_effective_target_c++14_only] {
7541 return 1
7542 }
7543 return [check_effective_target_c++1z]
7544 }
7545 proc check_effective_target_c++14_down { } {
7546 if ![check_effective_target_c++] {
7547 return 0
7548 }
7549 return [expr ![check_effective_target_c++1z] ]
7550 }
7551
7552 proc check_effective_target_c++98_only { } {
7553 global cxx_default
7554 if ![check_effective_target_c++] {
7555 return 0
7556 }
7557 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
7558 return 1
7559 }
7560 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
7561 return 1
7562 }
7563 return 0
7564 }
7565
7566 proc check_effective_target_c++1z_only { } {
7567 global cxx_default
7568 if ![check_effective_target_c++] {
7569 return 0
7570 }
7571 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
7572 return 1
7573 }
7574 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
7575 return 1
7576 }
7577 return 0
7578 }
7579 proc check_effective_target_c++1z { } {
7580 return [check_effective_target_c++1z_only]
7581 }
7582
7583 # Check for C++ Concepts TS support, i.e. -fconcepts flag.
7584 proc check_effective_target_concepts { } {
7585 return [check-flags { "" { } { -fconcepts } }]
7586 }
7587
7588 # Return 1 if expensive testcases should be run.
7589
7590 proc check_effective_target_run_expensive_tests { } {
7591 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
7592 return 1
7593 }
7594 return 0
7595 }
7596
7597 # Returns 1 if "mempcpy" is available on the target system.
7598
7599 proc check_effective_target_mempcpy {} {
7600 return [check_function_available "mempcpy"]
7601 }
7602
7603 # Returns 1 if "stpcpy" is available on the target system.
7604
7605 proc check_effective_target_stpcpy {} {
7606 return [check_function_available "stpcpy"]
7607 }
7608
7609 # Check whether the vectorizer tests are supported by the target and
7610 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
7611 # If a port wants to execute the tests more than once it should append
7612 # the supported target to EFFECTIVE_TARGETS instead, and the compile flags
7613 # will be added by a call to add_options_for_<target>.
7614 # Set dg-do-what-default to either compile or run, depending on target
7615 # capabilities. Do not set this if the supported target is appended to
7616 # EFFECTIVE_TARGETS. Flags and this variable will be set by et-dg-runtest
7617 # automatically. Return the number of effective targets if vectorizer tests
7618 # are supported, 0 otherwise.
7619
7620 proc check_vect_support_and_set_flags { } {
7621 global DEFAULT_VECTCFLAGS
7622 global dg-do-what-default
7623 global EFFECTIVE_TARGETS
7624
7625 if [istarget powerpc-*paired*] {
7626 lappend DEFAULT_VECTCFLAGS "-mpaired"
7627 if [check_750cl_hw_available] {
7628 set dg-do-what-default run
7629 } else {
7630 set dg-do-what-default compile
7631 }
7632 } elseif [istarget powerpc*-*-*] {
7633 # Skip targets not supporting -maltivec.
7634 if ![is-effective-target powerpc_altivec_ok] {
7635 return 0
7636 }
7637
7638 lappend DEFAULT_VECTCFLAGS "-maltivec"
7639 if [check_p9vector_hw_available] {
7640 lappend DEFAULT_VECTCFLAGS "-mpower9-vector"
7641 } elseif [check_p8vector_hw_available] {
7642 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
7643 } elseif [check_vsx_hw_available] {
7644 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
7645 }
7646
7647 if [check_vmx_hw_available] {
7648 set dg-do-what-default run
7649 } else {
7650 if [is-effective-target ilp32] {
7651 # Specify a cpu that supports VMX for compile-only tests.
7652 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
7653 }
7654 set dg-do-what-default compile
7655 }
7656 } elseif { [istarget spu-*-*] } {
7657 set dg-do-what-default run
7658 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
7659 lappend DEFAULT_VECTCFLAGS "-msse2"
7660 if { [check_effective_target_sse2_runtime] } {
7661 set dg-do-what-default run
7662 } else {
7663 set dg-do-what-default compile
7664 }
7665 } elseif { [istarget mips*-*-*]
7666 && [check_effective_target_nomips16] } {
7667 if { [check_effective_target_mpaired_single] } {
7668 lappend EFFECTIVE_TARGETS mpaired_single
7669 }
7670 if { [check_effective_target_mips_loongson] } {
7671 lappend EFFECTIVE_TARGETS mips_loongson
7672 }
7673 if { [check_effective_target_mips_msa] } {
7674 lappend EFFECTIVE_TARGETS mips_msa
7675 }
7676 return [llength $EFFECTIVE_TARGETS]
7677 } elseif [istarget sparc*-*-*] {
7678 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
7679 if [check_effective_target_ultrasparc_hw] {
7680 set dg-do-what-default run
7681 } else {
7682 set dg-do-what-default compile
7683 }
7684 } elseif [istarget alpha*-*-*] {
7685 # Alpha's vectorization capabilities are extremely limited.
7686 # It's more effort than its worth disabling all of the tests
7687 # that it cannot pass. But if you actually want to see what
7688 # does work, command out the return.
7689 return 0
7690
7691 lappend DEFAULT_VECTCFLAGS "-mmax"
7692 if [check_alpha_max_hw_available] {
7693 set dg-do-what-default run
7694 } else {
7695 set dg-do-what-default compile
7696 }
7697 } elseif [istarget ia64-*-*] {
7698 set dg-do-what-default run
7699 } elseif [is-effective-target arm_neon_ok] {
7700 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
7701 # NEON does not support denormals, so is not used for vectorization by
7702 # default to avoid loss of precision. We must pass -ffast-math to test
7703 # vectorization of float operations.
7704 lappend DEFAULT_VECTCFLAGS "-ffast-math"
7705 if [is-effective-target arm_neon_hw] {
7706 set dg-do-what-default run
7707 } else {
7708 set dg-do-what-default compile
7709 }
7710 } elseif [istarget "aarch64*-*-*"] {
7711 set dg-do-what-default run
7712 } else {
7713 return 0
7714 }
7715
7716 return 1
7717 }
7718
7719 # Return 1 if the target does *not* require strict alignment.
7720
7721 proc check_effective_target_non_strict_align {} {
7722
7723 # On ARM, the default is to use STRICT_ALIGNMENT, but there
7724 # are interfaces defined for misaligned access and thus
7725 # depending on the architecture levels unaligned access is
7726 # available.
7727 if [istarget "arm*-*-*"] {
7728 return [check_effective_target_arm_unaligned]
7729 }
7730
7731 return [check_no_compiler_messages non_strict_align assembly {
7732 char *y;
7733 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
7734 c *z;
7735 void foo(void) { z = (c *) y; }
7736 } "-Wcast-align"]
7737 }
7738
7739 # Return 1 if the target has <ucontext.h>.
7740
7741 proc check_effective_target_ucontext_h { } {
7742 return [check_no_compiler_messages ucontext_h assembly {
7743 #include <ucontext.h>
7744 }]
7745 }
7746
7747 proc check_effective_target_aarch64_tiny { } {
7748 if { [istarget aarch64*-*-*] } {
7749 return [check_no_compiler_messages aarch64_tiny object {
7750 #ifdef __AARCH64_CMODEL_TINY__
7751 int dummy;
7752 #else
7753 #error target not AArch64 tiny code model
7754 #endif
7755 }]
7756 } else {
7757 return 0
7758 }
7759 }
7760
7761 # Create functions to check that the AArch64 assembler supports the
7762 # various architecture extensions via the .arch_extension pseudo-op.
7763
7764 foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse"} {
7765 eval [string map [list FUNC $aarch64_ext] {
7766 proc check_effective_target_aarch64_asm_FUNC_ok { } {
7767 if { [istarget aarch64*-*-*] } {
7768 return [check_no_compiler_messages aarch64_FUNC_assembler object {
7769 __asm__ (".arch_extension FUNC");
7770 } "-march=armv8-a+FUNC"]
7771 } else {
7772 return 0
7773 }
7774 }
7775 }]
7776 }
7777
7778 proc check_effective_target_aarch64_small { } {
7779 if { [istarget aarch64*-*-*] } {
7780 return [check_no_compiler_messages aarch64_small object {
7781 #ifdef __AARCH64_CMODEL_SMALL__
7782 int dummy;
7783 #else
7784 #error target not AArch64 small code model
7785 #endif
7786 }]
7787 } else {
7788 return 0
7789 }
7790 }
7791
7792 proc check_effective_target_aarch64_large { } {
7793 if { [istarget aarch64*-*-*] } {
7794 return [check_no_compiler_messages aarch64_large object {
7795 #ifdef __AARCH64_CMODEL_LARGE__
7796 int dummy;
7797 #else
7798 #error target not AArch64 large code model
7799 #endif
7800 }]
7801 } else {
7802 return 0
7803 }
7804 }
7805
7806
7807 # Return 1 if this is a reduced AVR Tiny core. Such cores have different
7808 # register set, instruction set, addressing capabilities and ABI.
7809
7810 proc check_effective_target_avr_tiny { } {
7811 if { [istarget avr*-*-*] } {
7812 return [check_no_compiler_messages avr_tiny object {
7813 #ifdef __AVR_TINY__
7814 int dummy;
7815 #else
7816 #error target not a reduced AVR Tiny core
7817 #endif
7818 }]
7819 } else {
7820 return 0
7821 }
7822 }
7823
7824 # Return 1 if <fenv.h> is available with all the standard IEEE
7825 # exceptions and floating-point exceptions are raised by arithmetic
7826 # operations. (If the target requires special options for "inexact"
7827 # exceptions, those need to be specified in the testcases.)
7828
7829 proc check_effective_target_fenv_exceptions {} {
7830 return [check_runtime fenv_exceptions {
7831 #include <fenv.h>
7832 #include <stdlib.h>
7833 #ifndef FE_DIVBYZERO
7834 # error Missing FE_DIVBYZERO
7835 #endif
7836 #ifndef FE_INEXACT
7837 # error Missing FE_INEXACT
7838 #endif
7839 #ifndef FE_INVALID
7840 # error Missing FE_INVALID
7841 #endif
7842 #ifndef FE_OVERFLOW
7843 # error Missing FE_OVERFLOW
7844 #endif
7845 #ifndef FE_UNDERFLOW
7846 # error Missing FE_UNDERFLOW
7847 #endif
7848 volatile float a = 0.0f, r;
7849 int
7850 main (void)
7851 {
7852 r = a / a;
7853 if (fetestexcept (FE_INVALID))
7854 exit (0);
7855 else
7856 abort ();
7857 }
7858 } [add_options_for_ieee "-std=gnu99"]]
7859 }
7860
7861 proc check_effective_target_tiny {} {
7862 global et_target_tiny_saved
7863
7864 if [info exists et_target_tine_saved] {
7865 verbose "check_effective_target_tiny: using cached result" 2
7866 } else {
7867 set et_target_tiny_saved 0
7868 if { [istarget aarch64*-*-*]
7869 && [check_effective_target_aarch64_tiny] } {
7870 set et_target_tiny_saved 1
7871 }
7872 }
7873
7874 return $et_target_tiny_saved
7875 }
7876
7877 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
7878
7879 proc check_effective_target_logical_op_short_circuit {} {
7880 if { [istarget mips*-*-*]
7881 || [istarget arc*-*-*]
7882 || [istarget avr*-*-*]
7883 || [istarget crisv32-*-*] || [istarget cris-*-*]
7884 || [istarget mmix-*-*]
7885 || [istarget s390*-*-*]
7886 || [istarget powerpc*-*-*]
7887 || [istarget nios2*-*-*]
7888 || [istarget visium-*-*]
7889 || [check_effective_target_arm_cortex_m] } {
7890 return 1
7891 }
7892 return 0
7893 }
7894
7895 # Record that dg-final test TEST requires convential compilation.
7896
7897 proc force_conventional_output_for { test } {
7898 if { [info proc $test] == "" } {
7899 perror "$test does not exist"
7900 exit 1
7901 }
7902 proc ${test}_required_options {} {
7903 global gcc_force_conventional_output
7904 return $gcc_force_conventional_output
7905 }
7906 }
7907
7908 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
7909 # otherwise. Cache the result.
7910
7911 proc check_effective_target_pie_copyreloc { } {
7912 global pie_copyreloc_available_saved
7913 global tool
7914 global GCC_UNDER_TEST
7915
7916 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
7917 return 0
7918 }
7919
7920 # Need auto-host.h to check linker support.
7921 if { ![file exists ../../auto-host.h ] } {
7922 return 0
7923 }
7924
7925 if [info exists pie_copyreloc_available_saved] {
7926 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
7927 } else {
7928 # Set up and compile to see if linker supports PIE with copy
7929 # reloc. Include the current process ID in the file names to
7930 # prevent conflicts with invocations for multiple testsuites.
7931
7932 set src pie[pid].c
7933 set obj pie[pid].o
7934
7935 set f [open $src "w"]
7936 puts $f "#include \"../../auto-host.h\""
7937 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
7938 puts $f "# error Linker does not support PIE with copy reloc."
7939 puts $f "#endif"
7940 close $f
7941
7942 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
7943 set lines [${tool}_target_compile $src $obj object ""]
7944
7945 file delete $src
7946 file delete $obj
7947
7948 if [string match "" $lines] then {
7949 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
7950 set pie_copyreloc_available_saved 1
7951 } else {
7952 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
7953 set pie_copyreloc_available_saved 0
7954 }
7955 }
7956
7957 return $pie_copyreloc_available_saved
7958 }
7959
7960 # Return 1 if the x86 target supports R_386_GOT32X relocation, 0
7961 # otherwise. Cache the result.
7962
7963 proc check_effective_target_got32x_reloc { } {
7964 global got32x_reloc_available_saved
7965 global tool
7966 global GCC_UNDER_TEST
7967
7968 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
7969 return 0
7970 }
7971
7972 # Need auto-host.h to check linker support.
7973 if { ![file exists ../../auto-host.h ] } {
7974 return 0
7975 }
7976
7977 if [info exists got32x_reloc_available_saved] {
7978 verbose "check_effective_target_got32x_reloc returning saved $got32x_reloc_available_saved" 2
7979 } else {
7980 # Include the current process ID in the file names to prevent
7981 # conflicts with invocations for multiple testsuites.
7982
7983 set src got32x[pid].c
7984 set obj got32x[pid].o
7985
7986 set f [open $src "w"]
7987 puts $f "#include \"../../auto-host.h\""
7988 puts $f "#if HAVE_AS_IX86_GOT32X == 0"
7989 puts $f "# error Assembler does not support R_386_GOT32X."
7990 puts $f "#endif"
7991 close $f
7992
7993 verbose "check_effective_target_got32x_reloc compiling testfile $src" 2
7994 set lines [${tool}_target_compile $src $obj object ""]
7995
7996 file delete $src
7997 file delete $obj
7998
7999 if [string match "" $lines] then {
8000 verbose "check_effective_target_got32x_reloc testfile compilation passed" 2
8001 set got32x_reloc_available_saved 1
8002 } else {
8003 verbose "check_effective_target_got32x_reloc testfile compilation failed" 2
8004 set got32x_reloc_available_saved 0
8005 }
8006 }
8007
8008 return $got32x_reloc_available_saved
8009 }
8010
8011 # Return 1 if the x86 target supports calling ___tls_get_addr via GOT,
8012 # 0 otherwise. Cache the result.
8013
8014 proc check_effective_target_tls_get_addr_via_got { } {
8015 global tls_get_addr_via_got_available_saved
8016 global tool
8017 global GCC_UNDER_TEST
8018
8019 if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
8020 return 0
8021 }
8022
8023 # Need auto-host.h to check linker support.
8024 if { ![file exists ../../auto-host.h ] } {
8025 return 0
8026 }
8027
8028 if [info exists tls_get_addr_via_got_available_saved] {
8029 verbose "check_effective_target_tls_get_addr_via_got returning saved $tls_get_addr_via_got_available_saved" 2
8030 } else {
8031 # Include the current process ID in the file names to prevent
8032 # conflicts with invocations for multiple testsuites.
8033
8034 set src tls_get_addr_via_got[pid].c
8035 set obj tls_get_addr_via_got[pid].o
8036
8037 set f [open $src "w"]
8038 puts $f "#include \"../../auto-host.h\""
8039 puts $f "#if HAVE_AS_IX86_TLS_GET_ADDR_GOT == 0"
8040 puts $f "# error Assembler/linker do not support calling ___tls_get_addr via GOT."
8041 puts $f "#endif"
8042 close $f
8043
8044 verbose "check_effective_target_tls_get_addr_via_got compiling testfile $src" 2
8045 set lines [${tool}_target_compile $src $obj object ""]
8046
8047 file delete $src
8048 file delete $obj
8049
8050 if [string match "" $lines] then {
8051 verbose "check_effective_target_tls_get_addr_via_got testfile compilation passed" 2
8052 set tls_get_addr_via_got_available_saved 1
8053 } else {
8054 verbose "check_effective_target_tls_get_addr_via_got testfile compilation failed" 2
8055 set tls_get_addr_via_got_available_saved 0
8056 }
8057 }
8058
8059 return $tls_get_addr_via_got_available_saved
8060 }
8061
8062 # Return 1 if the target uses comdat groups.
8063
8064 proc check_effective_target_comdat_group {} {
8065 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
8066 // C++
8067 inline int foo () { return 1; }
8068 int (*fn) () = foo;
8069 }]
8070 }
8071
8072 # Return 1 if target supports __builtin_eh_return
8073 proc check_effective_target_builtin_eh_return { } {
8074 return [check_no_compiler_messages builtin_eh_return object {
8075 void test (long l, void *p)
8076 {
8077 __builtin_eh_return (l, p);
8078 }
8079 } "" ]
8080 }
8081
8082 # Return 1 if the target supports max reduction for vectors.
8083
8084 proc check_effective_target_vect_max_reduc { } {
8085 if { [istarget aarch64*-*-*] || [istarget arm*-*-*] } {
8086 return 1
8087 }
8088 return 0
8089 }
8090
8091 # Return 1 if there is an nvptx offload compiler.
8092
8093 proc check_effective_target_offload_nvptx { } {
8094 return [check_no_compiler_messages offload_nvptx object {
8095 int main () {return 0;}
8096 } "-foffload=nvptx-none" ]
8097 }
8098
8099 # Return 1 if the compiler has been configured with hsa offloading.
8100
8101 proc check_effective_target_offload_hsa { } {
8102 return [check_no_compiler_messages offload_hsa assembly {
8103 int main () {return 0;}
8104 } "-foffload=hsa" ]
8105 }
8106
8107 # Return 1 if the target support -fprofile-update=atomic
8108 proc check_effective_target_profile_update_atomic {} {
8109 return [check_no_compiler_messages profile_update_atomic assembly {
8110 int main (void) { return 0; }
8111 } "-fprofile-update=atomic -fprofile-generate"]
8112 }
8113
8114 #For versions of ARM architectures that have hardware div insn,
8115 #disable the divmod transform
8116
8117 proc check_effective_target_arm_divmod_simode { } {
8118 return [check_no_compiler_messages arm_divmod assembly {
8119 #ifdef __ARM_ARCH_EXT_IDIV__
8120 #error has div insn
8121 #endif
8122 int i;
8123 }]
8124 }
8125
8126 # Return 1 if target supports divmod hardware insn or divmod libcall.
8127
8128 proc check_effective_target_divmod { } {
8129 #TODO: Add checks for all targets that have either hardware divmod insn
8130 # or define libfunc for divmod.
8131 if { [istarget arm*-*-*]
8132 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
8133 return 1
8134 }
8135 return 0
8136 }
8137
8138 # Return 1 if target supports divmod for SImode. The reason for
8139 # separating this from check_effective_target_divmod is that
8140 # some versions of ARM architecture define div instruction
8141 # only for simode, and for these archs, we do not want to enable
8142 # divmod transform for simode.
8143
8144 proc check_effective_target_divmod_simode { } {
8145 if { [istarget arm*-*-*] } {
8146 return [check_effective_target_arm_divmod_simode]
8147 }
8148
8149 return [check_effective_target_divmod]
8150 }
8151
8152 # Return 1 if store merging optimization is applicable for target.
8153 # Store merging is not profitable for targets like the avr which
8154 # can load/store only one byte at a time. Use int size as a proxy
8155 # for the number of bytes the target can write, and skip for targets
8156 # with a smallish (< 32) size.
8157
8158 proc check_effective_target_store_merge { } {
8159 if { [is-effective-target non_strict_align ] && [is-effective-target int32plus] } {
8160 return 1
8161 }
8162
8163 return 0
8164 }