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