1# Copyright (C) 2012-2016 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17# Test for warnings when producing load hazards (instructions that
18# reference the target of load one stage further down the pipeline.
19# Written by Ben Elliston (bje@redhat.com)
20
21# Run GAS and check that it emits the desired warning for the test case.
22# Arguments:
23#   file -- name of the test case to assemble.
24#   testname -- a string describing the test.
25#   warnpattern -- a regular expression, suitable for use by the Tcl
26#     regexp command, to decide if the warning string was emitted by
27#     the assembler to stderr.
28
29proc iq2000_warning_test { file testname {warnpattern ""} } {
30    global comp_output
31
32    gas_run $file "" ">/dev/null"
33    verbose "output was $comp_output" 2
34
35    if {$warnpattern == ""} {
36	if {$comp_output == ""} { pass $testname } else { fail $testname }
37	return
38    }
39
40    if {[regexp "Warning: $warnpattern" $comp_output]} {
41	pass $testname
42    } else {
43	fail $testname
44    }
45}
46
47if [istarget iq2000*-*-*] {
48    foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/hazard*.s]] {
49	set file [file tail $file]
50	switch -- $file {
51	    "hazard0.s" {
52		set warnpattern "operand references R10 of previous load"
53	    }
54	    "hazard1.s" {
55		set warnpattern "operand references R1 of previous load"
56	    }
57	    "hazard2.s" {
58		set warnpattern "operand references R2 of previous load"
59	    }
60	    "hazard3.s" {
61		set warnpattern "instruction implicitly accesses R31 of previous load"
62	    }
63	    "hazard4.s" {
64		set warnpattern "operand references R10 of previous load"
65	    }
66	    "hazard5.s" {
67		set warnpattern "operand references R8 of previous load"
68	    }
69	    default {
70		error "no expected result specified for $file"
71		return
72	    }
73	}
74	iq2000_warning_test $file "assembler emits load hazard warning for $file" $warnpattern
75    }
76
77    set testname "assembler emits no warnings when there are no load hazards"
78    iq2000_warning_test nohazard.s $testname
79}
80