1 # Copyright
(C
) 2007-2017 Free Software Foundation
, Inc.
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.
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.
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
/>.
17 # GCC testsuite that uses the `dg.exp
' driver.
19 global torture_current_flags
20 set torture_current_flags ""
22 # Exit immediately if this isn't a s390 target.
23 if ![istarget s390
*-*-*] then {
30 #
Return 1 if the the assembler understands .machine and .machinemode. The
31 # target attribute needs that feature to work.
32 proc check_effective_target_target_attribute
{ } {
33 if { ![check_runtime s390_check_machine_machinemode
[subst
{
36 asm
(".machine push" : : );
37 asm
(".machine pop" : : );
38 asm
(".machinemode push" : : );
39 asm
(".machinemode pop" : : );
42 }] "" ] } { return 0 } else { return 1 }
45 #
Return 1 if htm
(etnd
- extract nesting depth
) instructions are
46 # understood by the assembler and can be executed.
47 proc check_effective_target_htm
{ } {
48 if { ![check_runtime s390_check_htm
[subst
{
52 asm
("etnd %0" : "=d" (nd));
55 }] "-march=zEC12 -mzarch" ] } { return 0 } else { return 1 }
58 #
Return 1 if vector
(va
- vector add
) instructions are understood by
59 # the assembler and can be executed. This also covers checking
for
60 # the VX kernel feature. A kernel without that feature does not
61 # enable the vector facility and the following check will die with a
63 proc check_effective_target_vector
{ } {
64 if { ![check_runtime s390_check_vector
[subst
{
67 asm
("va %%v24, %%v26, %%v28, 3" : : : "v24", "v26", "v28");
70 }] "-march=z13 -mzarch" ] } { return 0 } else { return 1 }
73 global s390_cached_flags
74 set s390_cached_flags
""
75 global s390_cached_value
76 set s390_cached_value
""
77 global s390_cached_value_noflags
78 set s390_cached_value_noflags
""
80 #
Return 1 if a
program using the full instruction
set allowed by
81 # the compiler option can be executed.
82 proc check_effective_target_s390_useable_hw
{ } {
83 global torture_current_flags
84 global s390_cached_flags
85 global s390_cached_value
86 global s390_cached_value_noflags
88 # Remove
-Ox options and whitespace.
89 set flags
[regsub
-all
{[-]O
[0-9s
]} "$torture_current_flags" ""]
90 set flags
[regsub
-all
{[ \\t
\\n
]+} "$flags" " "]
91 set flags
[regsub
-all
{(^
)|
( $
)} "$flags" ""]
92 if { "$s390_cached_flags" != "" && "$flags" == "$s390_cached_flags" } {
93 return $s390_cached_value
95 # Extra
cache for (frequent
) calls with empty torture_current_flags.
96 if { "$flags" == "" && $s390_cached_value_noflags != "" } {
97 return $s390_cached_value_noflags
99 if { ![check_runtime_nocache s390_check_useable_hw
[subst
{
102 asm
(".machinemode zarch" : : );
104 asm
("lcbb %%r2,0(%%r15),0" : : );
106 asm
("risbgn %%r2,%%r2,0,0,0" : : );
108 asm
("sgrk %%r2,%%r2,%%r2" : : );
110 asm
("rosbg %%r2,%%r2,0,0,0" : : );
112 asm
("nilf %%r2,0" : : );
114 asm
("lay %%r2,0(%%r15)" : : );
121 asm
("etnd %0" : "=d" (nd));
125 asm
("vzero %%v0" : : );
129 }] "$flags" ] } { set result 0 } else { set result 1 }
130 if { "$flags" == "" } {
131 set s390_cached_value_noflags
"$result"
133 set s390_cached_flags
"$flags"
134 set s390_cached_value
"$result"
139 #
Return 1 if -march
=... specific instructions are understood by
140 # the assembler and can be executed.
141 proc check_effective_target_s390_z900_hw
{ } {
142 if { ![check_runtime s390_check_s390_z900_hw
[subst
{
148 }] "-march=z900 -m64 -mzarch" ] } { return 0 } else { return 1 }
150 proc check_effective_target_s390_z990_hw
{ } {
151 if { ![check_runtime s390_check_s390_z990_hw
[subst
{
154 asm
("lay %%r2,0(%%r15)" : : );
157 }] "-march=z990 -m64 -mzarch" ] } { return 0 } else { return 1 }
159 proc check_effective_target_s390_z9_ec_hw
{ } {
160 if { ![check_runtime s390_check_s390_z9_ec_hw
[subst
{
163 asm
("nilf %%r2,0" : : );
166 }] "-march=z9-ec -m64 -mzarch" ] } { return 0 } else { return 1 }
168 proc check_effective_target_s390_z10_hw
{ } {
169 if { ![check_runtime s390_check_s390_z10_hw
[subst
{
172 asm
("rosbg %%r2,%%r2,0,0,0" : : );
175 }] "-march=z10 -m64 -mzarch" ] } { return 0 } else { return 1 }
177 proc check_effective_target_s390_z196_hw
{ } {
178 if { ![check_runtime s390_check_s390_z196_hw
[subst
{
181 asm
("sgrk %%r2,%%r2,%%r2" : : );
184 }] "-march=z196 -m64 -mzarch" ] } { return 0 } else { return 1 }
186 proc check_effective_target_s390_zEC12_hw
{ } {
187 if { ![check_runtime s390_check_s390_zEC12_hw
[subst
{
190 asm
("risbgn %%r2,%%r2,0,0,0" : : );
193 }] "-march=zEC12 -m64 -mzarch" ] } { return 0 } else { return 1 }
195 proc check_effective_target_s390_z13_hw
{ } {
196 if { ![check_runtime s390_check_s390_z13_hw
[subst
{
199 asm
("lcbb %%r2,0(%%r15),0" : : );
202 }] "-march=z13 -m64 -mzarch" ] } { return 0 } else { return 1 }
205 #
If a testcase doesn
't have special options, use these.
206 global DEFAULT_CFLAGS
207 if ![info exists DEFAULT_CFLAGS] then {
208 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
214 set md_tests $srcdir
/$subdir
/md
/*.c
217 dg
-runtest
[lsort
[prune
[glob
-nocomplain $srcdir
/$subdir
/*.
{c
,S
,C
}] \
218 $md_tests
]] "" $DEFAULT_CFLAGS
220 dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/*vector
*/*.
]] \
223 dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/target
-attribute
/*.
{c
,S
,C
}]] \
226 dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/md
/*.
{c
,S
,C
}]] \
229 # Additional hotpatch torture tests.
231 set-torture
-options
[list
-Os
-O0
-O1
-O2
-O3
]
232 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/hotpatch
-\
[0-9\
]*.c
]] \
236 # Additional md torture tests.
237 #
(Note
: Split into a separate torture test
for each
-march
= option to improve
240 set MD_TEST_OPTS
[list \
241 {-Os
} {-Os
-march
=z900
} \
242 {-O0
} {-O0
-march
=z900
} \
243 {-O1
} {-O1
-march
=z900
} \
244 {-O2
} {-O2
-march
=z900
} \
245 {-O3
} {-O3
-march
=z900
} ]
246 set-torture
-options $MD_TEST_OPTS
247 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $md_tests
]] "" "$DEFAULT_CFLAGS"
250 set MD_TEST_OPTS
[list \
256 set-torture
-options $MD_TEST_OPTS
257 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $md_tests
]] "" "$DEFAULT_CFLAGS"