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