1 |
306 |
jeremybenn |
# Copyright (C) 2003, 2006, 2007, 2008, 2010 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 |
|
|
# .
|
16 |
|
|
|
17 |
|
|
# Please email any bugs, comments, and/or additions to this file to
|
18 |
|
|
# the author.
|
19 |
|
|
|
20 |
|
|
# This file was written by Steven Bosscher (s.bosscher@student.tudelft.nl)
|
21 |
|
|
# based on f-torture.exp, which was written by Rob Savoye.
|
22 |
|
|
|
23 |
|
|
load_lib target-supports.exp
|
24 |
|
|
|
25 |
|
|
# Return the list of options to use for fortran torture tests.
|
26 |
|
|
# The default option list can be overridden by
|
27 |
|
|
# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
|
28 |
|
|
proc get-fortran-torture-options { } {
|
29 |
|
|
global TORTURE_OPTIONS
|
30 |
|
|
|
31 |
|
|
if [info exists TORTURE_OPTIONS] {
|
32 |
|
|
return $TORTURE_OPTIONS
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
# determine if host supports vectorization, and the necessary set
|
36 |
|
|
# of options, based on code from testsuite/vect/vect.exp
|
37 |
|
|
|
38 |
|
|
set vectorizer_options [list "-O2" "-ftree-vectorize"]
|
39 |
|
|
|
40 |
|
|
if { [istarget "powerpc*-*-*"]
|
41 |
|
|
&& [is-effective-target powerpc_altivec_ok]
|
42 |
|
|
&& [check_vmx_hw_available] } {
|
43 |
|
|
lappend vectorizer_options "-maltivec"
|
44 |
|
|
set test_tree_vectorize 1
|
45 |
|
|
} elseif { [istarget "spu-*-*"] } {
|
46 |
|
|
set test_tree_vectorize 1
|
47 |
|
|
} elseif { ( [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] )
|
48 |
|
|
&& [check_effective_target_sse2]
|
49 |
|
|
&& [check_sse2_hw_available]
|
50 |
|
|
&& [check_sse_os_support_available] } {
|
51 |
|
|
lappend vectorizer_options "-msse2"
|
52 |
|
|
set test_tree_vectorize 1
|
53 |
|
|
} elseif { [istarget "mips*-*-*"]
|
54 |
|
|
&& [check_effective_target_mpaired_single]
|
55 |
|
|
&& [check_effective_target_nomips16] } {
|
56 |
|
|
lappend vectorizer_options "-mpaired-single"
|
57 |
|
|
set test_tree_vectorize 1
|
58 |
|
|
} elseif { [istarget "sparc*-*-*"]
|
59 |
|
|
&& [check_effective_target_ultrasparc_hw] } {
|
60 |
|
|
lappend vectorizer_options "-mcpu=ultrasparc" "-mvis"
|
61 |
|
|
set test_tree_vectorize 1
|
62 |
|
|
} elseif { [istarget "alpha*-*-*"]
|
63 |
|
|
&& [check_alpha_max_hw_available] } {
|
64 |
|
|
lappend vectorizer_options "-mmax"
|
65 |
|
|
set test_tree_vectorize 1
|
66 |
|
|
} elseif [istarget "ia64-*-*"] {
|
67 |
|
|
set test_tree_vectorize 1
|
68 |
|
|
} else {
|
69 |
|
|
set test_tree_vectorize 0
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
set options {}
|
73 |
|
|
|
74 |
|
|
lappend options \
|
75 |
|
|
{ -O0 } \
|
76 |
|
|
{ -O1 } \
|
77 |
|
|
{ -O2 } \
|
78 |
|
|
{ -O2 -fomit-frame-pointer -finline-functions } \
|
79 |
|
|
{ -O2 -fomit-frame-pointer -finline-functions -funroll-loops } \
|
80 |
|
|
{ -O2 -fbounds-check } \
|
81 |
|
|
{ -O3 -g } \
|
82 |
|
|
{ -Os }
|
83 |
|
|
if { $test_tree_vectorize } {
|
84 |
|
|
lappend options $vectorizer_options
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
if [info exists ADDITIONAL_TORTURE_OPTIONS] {
|
88 |
|
|
set options [concat $options $ADDITIONAL_TORTURE_OPTIONS]
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
return $options
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
#
|
96 |
|
|
# fortran-torture-compile -- compile a gfortran.fortran-torture testcase.
|
97 |
|
|
#
|
98 |
|
|
# SRC is the full pathname of the testcase.
|
99 |
|
|
# OPTION is the specific compiler flag we're testing (eg: -O2).
|
100 |
|
|
#
|
101 |
|
|
proc fortran-torture-compile { src option } {
|
102 |
|
|
global output
|
103 |
|
|
global srcdir tmpdir
|
104 |
|
|
global host_triplet
|
105 |
|
|
|
106 |
|
|
set output "$tmpdir/[file tail [file rootname $src]].o"
|
107 |
|
|
|
108 |
|
|
regsub "(?q)$srcdir/" $src "" testcase
|
109 |
|
|
|
110 |
|
|
# If we couldn't rip $srcdir out of `src' then just do the best we can.
|
111 |
|
|
# The point is to reduce the unnecessary noise in the logs. Don't strip
|
112 |
|
|
# out too much because different testcases with the same name can confuse
|
113 |
|
|
# `test-tool'.
|
114 |
|
|
if [string match "/*" $testcase] {
|
115 |
|
|
set testcase "[file tail [file dirname $src]]/[file tail $src]"
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
verbose "Testing $testcase, $option" 1
|
119 |
|
|
|
120 |
|
|
# Run the compiler and get results in comp_output.
|
121 |
|
|
set options ""
|
122 |
|
|
lappend options "additional_flags=-w $option"
|
123 |
|
|
|
124 |
|
|
set comp_output [gfortran_target_compile "$src" "$output" object $options]
|
125 |
|
|
|
126 |
|
|
# See if we got something bad.
|
127 |
|
|
set fatal_signal "*95*: Internal compiler error: program*got fatal signal"
|
128 |
|
|
|
129 |
|
|
if [string match "$fatal_signal 6" $comp_output] then {
|
130 |
|
|
gfortran_fail $testcase "Got Signal 6, $option"
|
131 |
|
|
catch { remote_file build delete $output }
|
132 |
|
|
return
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
if [string match "$fatal_signal 11" $comp_output] then {
|
136 |
|
|
gfortran_fail $testcase "Got Signal 11, $option"
|
137 |
|
|
catch { remote_file build delete $output }
|
138 |
|
|
return
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
if [string match "*internal compiler error*" $comp_output] then {
|
142 |
|
|
gfortran_fail $testcase "$option (internal compiler error)"
|
143 |
|
|
catch { remote_file build delete $output }
|
144 |
|
|
return
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
# We shouldn't get these because of -w, but just in case.
|
148 |
|
|
if [string match "*95*:*warning:*" $comp_output] then {
|
149 |
|
|
warning "$testcase: (with warnings) $option"
|
150 |
|
|
send_log "$comp_output\n"
|
151 |
|
|
unresolved "$testcase, $option"
|
152 |
|
|
catch { remote_file build delete $output }
|
153 |
|
|
return
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
# Prune warnings we know are unwanted.
|
157 |
|
|
set comp_output [prune_warnings $comp_output]
|
158 |
|
|
|
159 |
|
|
# Report if the testcase is not supported.
|
160 |
|
|
set unsupported_message [gfortran_check_unsupported_p $comp_output]
|
161 |
|
|
if { $unsupported_message != "" } {
|
162 |
|
|
unsupported "$testcase: $unsupported_message"
|
163 |
|
|
catch { remote_file build delete $output }
|
164 |
|
|
return
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
# remove any leftover LF/CR to make sure any output is legit
|
168 |
|
|
regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
|
169 |
|
|
|
170 |
|
|
# If any message remains, we fail.
|
171 |
|
|
if ![string match "" $comp_output] then {
|
172 |
|
|
gfortran_fail $testcase $option
|
173 |
|
|
catch { remote_file build delete $output }
|
174 |
|
|
return
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
gfortran_pass $testcase $option
|
178 |
|
|
catch { remote_file build delete $output }
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
#
|
183 |
|
|
# fortran-torture-execute -- compile and execute a testcase.
|
184 |
|
|
#
|
185 |
|
|
# SRC is the full pathname of the testcase.
|
186 |
|
|
#
|
187 |
|
|
# If the testcase has an associated .x file, we source that to run the
|
188 |
|
|
# test instead. We use .x so that we don't lengthen the existing filename
|
189 |
|
|
# to more than 14 chars.
|
190 |
|
|
#
|
191 |
|
|
proc fortran-torture-execute { src } {
|
192 |
|
|
global output
|
193 |
|
|
global srcdir tmpdir
|
194 |
|
|
global tool
|
195 |
|
|
global compiler_conditional_xfail_data
|
196 |
|
|
global torture_with_loops
|
197 |
|
|
|
198 |
|
|
# Check for alternate driver.
|
199 |
|
|
set additional_flags ""
|
200 |
|
|
if [file exists [file rootname $src].x] {
|
201 |
|
|
verbose "Using alternate driver [file rootname [file tail $src]].x" 2
|
202 |
|
|
set done_p 0
|
203 |
|
|
catch "set done_p \[source [file rootname $src].x\]"
|
204 |
|
|
if { $done_p } {
|
205 |
|
|
return
|
206 |
|
|
}
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
# Setup the options for the testcase run.
|
210 |
|
|
set option_list $torture_with_loops
|
211 |
|
|
set executable $tmpdir/[file tail [file rootname $src].x]
|
212 |
|
|
regsub "(?q)$srcdir/" $src "" testcase
|
213 |
|
|
|
214 |
|
|
# If we couldn't rip $srcdir out of `src' then just do the best we can.
|
215 |
|
|
# The point is to reduce the unnecessary noise in the logs. Don't strip
|
216 |
|
|
# out too much because different testcases with the same name can confuse
|
217 |
|
|
# `test-tool'.
|
218 |
|
|
if [string match "/*" $testcase] {
|
219 |
|
|
set testcase "[file tail [file dirname $src]]/[file tail $src]"
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
# Walk the list of options and copmile and run the testcase for all
|
223 |
|
|
# options that are not explicitly disabled by the .x script (if present).
|
224 |
|
|
foreach option $option_list {
|
225 |
|
|
|
226 |
|
|
# Torture_{compile,execute}_xfail are set by the .x script.
|
227 |
|
|
if [info exists torture_compile_xfail] {
|
228 |
|
|
setup_xfail $torture_compile_xfail
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
# Torture_execute_before_{compile,execute} can be set by the .x script.
|
232 |
|
|
if [info exists torture_eval_before_compile] {
|
233 |
|
|
set ignore_me [eval $torture_eval_before_compile]
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
# FIXME: We should make sure that the modules required by this testcase
|
237 |
|
|
# exist. If not, the testcase should XFAIL.
|
238 |
|
|
|
239 |
|
|
# Compile the testcase.
|
240 |
|
|
catch { remote_file build delete $executable }
|
241 |
|
|
verbose "Testing $testcase, $option" 1
|
242 |
|
|
|
243 |
|
|
set options ""
|
244 |
|
|
lappend options "additional_flags=-w $option"
|
245 |
|
|
if { $additional_flags != "" } {
|
246 |
|
|
lappend options "additional_flags=$additional_flags"
|
247 |
|
|
}
|
248 |
|
|
set comp_output [gfortran_target_compile "$src" "$executable" executable $options]
|
249 |
|
|
|
250 |
|
|
# See if we got something bad.
|
251 |
|
|
set fatal_signal "*95*: Internal compiler error: program*got fatal signal"
|
252 |
|
|
|
253 |
|
|
if [string match "$fatal_signal 6" $comp_output] then {
|
254 |
|
|
gfortran_fail $testcase "Got Signal 6, $option"
|
255 |
|
|
catch { remote_file build delete $executable }
|
256 |
|
|
continue
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
if [string match "$fatal_signal 11" $comp_output] then {
|
260 |
|
|
gfortran_fail $testcase "Got Signal 11, $option"
|
261 |
|
|
catch { remote_file build delete $executable }
|
262 |
|
|
continue
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
if [string match "*internal compiler error*" $comp_output] then {
|
266 |
|
|
gfortran_fail $testcase "$option (internal compiler error)"
|
267 |
|
|
catch { remote_file build delete $executable }
|
268 |
|
|
continue
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
# We shouldn't get these because of -w, but just in case.
|
272 |
|
|
if [string match "*95*:*warning:*" $comp_output] then {
|
273 |
|
|
warning "$testcase: (with warnings) $option"
|
274 |
|
|
send_log "$comp_output\n"
|
275 |
|
|
unresolved "$testcase, $option"
|
276 |
|
|
catch { remote_file build delete $executable }
|
277 |
|
|
continue
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
# Prune warnings we know are unwanted.
|
281 |
|
|
set comp_output [prune_warnings $comp_output]
|
282 |
|
|
|
283 |
|
|
# Report if the testcase is not supported.
|
284 |
|
|
set unsupported_message [gfortran_check_unsupported_p $comp_output]
|
285 |
|
|
if { $unsupported_message != "" } {
|
286 |
|
|
unsupported "$testcase: $unsupported_message"
|
287 |
|
|
continue
|
288 |
|
|
} elseif ![file exists $executable] {
|
289 |
|
|
if ![is3way] {
|
290 |
|
|
fail "$testcase compilation, $option"
|
291 |
|
|
untested "$testcase execution, $option"
|
292 |
|
|
continue
|
293 |
|
|
} else {
|
294 |
|
|
# FIXME: since we can't test for the existence of a remote
|
295 |
|
|
# file without short of doing an remote file list, we assume
|
296 |
|
|
# that since we got no output, it must have compiled.
|
297 |
|
|
pass "$testcase compilation, $option"
|
298 |
|
|
}
|
299 |
|
|
} else {
|
300 |
|
|
pass "$testcase compilation, $option"
|
301 |
|
|
}
|
302 |
|
|
|
303 |
|
|
# See if this source file uses INTEGER(KIND=8) types, if it does, and
|
304 |
|
|
# no_long_long is set, skip execution of the test.
|
305 |
|
|
# FIXME: We should also look for F95 style "_8" or select_int_kind()
|
306 |
|
|
# integers, but that is obviously much harder than just regexping this.
|
307 |
|
|
# So maybe we should just avoid those in testcases.
|
308 |
|
|
if [target_info exists no_long_long] then {
|
309 |
|
|
if [expr [search_for_re $src "integer\*8"] \
|
310 |
|
|
+[search_for_re $src "integer *( *8 *)"] \
|
311 |
|
|
+[search_for_re $src "integer *( *kind *= *8 *)"]] \
|
312 |
|
|
then {
|
313 |
|
|
untested "$testcase execution, $option"
|
314 |
|
|
continue
|
315 |
|
|
}
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
if [info exists torture_execute_xfail] {
|
319 |
|
|
setup_xfail $torture_execute_xfail
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
if [info exists torture_eval_before_execute] {
|
323 |
|
|
set ignore_me [eval $torture_eval_before_execute]
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
# Run the testcase, and analyse the output.
|
327 |
|
|
set result [gfortran_load "$executable" "" ""]
|
328 |
|
|
set status [lindex $result 0]
|
329 |
|
|
set output [lindex $result 1]
|
330 |
|
|
if { $status == "pass" } {
|
331 |
|
|
catch { remote_file build delete $executable }
|
332 |
|
|
}
|
333 |
|
|
$status "$testcase execution, $option"
|
334 |
|
|
}
|
335 |
|
|
}
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
#
|
339 |
|
|
# search_for_re -- looks for a string match in a file
|
340 |
|
|
#
|
341 |
|
|
proc search_for_re { file pattern } {
|
342 |
|
|
set fd [open $file r]
|
343 |
|
|
while { [gets $fd cur_line]>=0 } {
|
344 |
|
|
set lower [string tolower $cur_line]
|
345 |
|
|
if [regexp "$pattern" $lower] then {
|
346 |
|
|
close $fd
|
347 |
|
|
return 1
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
close $fd
|
351 |
|
|
return 0
|
352 |
|
|
}
|
353 |
|
|
|
354 |
|
|
|
355 |
|
|
#
|
356 |
|
|
# fortran-torture -- the fortran-torture testcase source file processor
|
357 |
|
|
#
|
358 |
|
|
# This runs compilation only tests (no execute tests).
|
359 |
|
|
#
|
360 |
|
|
# SRC is the full pathname of the testcase, or just a file name in which
|
361 |
|
|
# case we prepend $srcdir/$subdir.
|
362 |
|
|
#
|
363 |
|
|
# If the testcase has an associated .x file, we source that to run the
|
364 |
|
|
# test instead. We use .x so that we don't lengthen the existing filename
|
365 |
|
|
# to more than 14 chars.
|
366 |
|
|
#
|
367 |
|
|
proc fortran-torture { args } {
|
368 |
|
|
global srcdir subdir
|
369 |
|
|
global compiler_conditional_xfail_data
|
370 |
|
|
global torture_with_loops
|
371 |
|
|
|
372 |
|
|
set src [lindex $args 0]
|
373 |
|
|
if { [llength $args] > 1 } {
|
374 |
|
|
set options [lindex $args 1]
|
375 |
|
|
} else {
|
376 |
|
|
set options ""
|
377 |
|
|
}
|
378 |
|
|
|
379 |
|
|
# Prepend $srdir/$subdir if missing.
|
380 |
|
|
if ![string match "*/*" $src] {
|
381 |
|
|
set src "$srcdir/$subdir/$src"
|
382 |
|
|
}
|
383 |
|
|
|
384 |
|
|
# Check for alternate driver.
|
385 |
|
|
if [file exists [file rootname $src].x] {
|
386 |
|
|
verbose "Using alternate driver [file rootname [file tail $src]].x" 2
|
387 |
|
|
set done_p 0
|
388 |
|
|
catch "set done_p \[source [file rootname $src].x\]"
|
389 |
|
|
if { $done_p } {
|
390 |
|
|
return
|
391 |
|
|
}
|
392 |
|
|
}
|
393 |
|
|
|
394 |
|
|
# loop through all the options
|
395 |
|
|
set option_list $torture_with_loops
|
396 |
|
|
foreach option $option_list {
|
397 |
|
|
|
398 |
|
|
# torture_compile_xfail is set by the .x script (if present)
|
399 |
|
|
if [info exists torture_compile_xfail] {
|
400 |
|
|
setup_xfail $torture_compile_xfail
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
# torture_execute_before_compile is set by the .x script (if present)
|
404 |
|
|
if [info exists torture_eval_before_compile] {
|
405 |
|
|
set ignore_me [eval $torture_eval_before_compile]
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
fortran-torture-compile $src "$option $options"
|
409 |
|
|
}
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
#
|
413 |
|
|
# add-ieee-options -- add options necessary for 100% ieee conformance.
|
414 |
|
|
#
|
415 |
|
|
proc add-ieee-options { } {
|
416 |
|
|
# Ensure that excess precision does not cause problems.
|
417 |
|
|
if { [istarget "i?86-*-*"]
|
418 |
|
|
|| [istarget "m68k-*-*"] } then {
|
419 |
|
|
uplevel 1 lappend additional_flags "-ffloat-store"
|
420 |
|
|
}
|
421 |
|
|
|
422 |
|
|
# Enable full IEEE compliance mode.
|
423 |
|
|
if { [istarget "alpha*-*-*"]
|
424 |
|
|
|| [istarget "sh*-*-*"] } then {
|
425 |
|
|
uplevel 1 lappend additional_flags "-mieee"
|
426 |
|
|
}
|
427 |
|
|
}
|