summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/mips/mips.exp
blob: ee1c4f593bea901de54c88937227ef4c18998efb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#   Copyright (C) 1997 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  

# GCC testsuite that uses the `dg.exp' driver.

# Exit immediately if this isn't a MIPS target.
if ![istarget mips*-*-*] {
  return
}

# Load support procs.
load_lib gcc-dg.exp

# Find out which target is selected by the default compiler flags.
# Also remember which aspects of the target are forced on the command
# line (as opposed to being overridable defaults).
#
#    $mips_isa:		 the ISA level specified by __mips
#    $mips_arch:	 the architecture specified by _MIPS_ARCH
#    $mips_mips16:	 true if MIPS16 mode is selected
#    $mips_mips64:	 true if 64-bit output is selected
#    $mips_float:	 "hard" or "soft"
#
#    $mips_forced_isa:	 true if the command line uses -march=* or -mips*
#    $mips_forced_abi:	 true if the command line uses -mabi=* or -mgp*
#    $mips_forced_float: true if the command line uses -mhard/soft-float
proc setup_mips_tests {} {
    global mips_isa
    global mips_arch
    global mips_mips16
    global mips_mips64
    global mips_float

    global mips_forced_isa
    global mips_forced_abi
    global mips_forced_float

    global compiler_flags
    global tool

    set src dummy[pid].c
    set f [open $src "w"]
    puts $f {
	int isa = __mips;
	const char *arch = _MIPS_ARCH;
	#ifdef __mips16
	int mips16 = 1;
	#endif
	#ifdef __mips64
	int mips64 = 1;
	#endif
	#ifdef __mips_hard_float
	const char *float = "hard";
	#else
	const char *float = "soft";
	#endif
    }
    close $f
    set output [${tool}_target_compile $src "" preprocess ""]
    file delete $src

    regexp {isa = ([^;]*)} $output dummy mips_isa
    regexp {arch = "([^"]*)} $output dummy mips_arch
    set mips_mips16 [regexp {mips16 = 1} $output]
    set mips_mips64 [regexp {mips64 = 1} $output]
    regexp {float = "([^"]*)} $output dummy mips_float

    set mips_forced_isa [regexp -- {(-mips|-march)} $compiler_flags]
    set mips_forced_abi [regexp -- {(-mgp|-mabi)} $compiler_flags]
    set mips_forced_float [regexp -- {-m(hard|soft)-float} $compiler_flags]
}

# Like dg-options, but treats certain MIPS-specific options specially:
#
#    -mgp32
#	Force 32-bit code.  Skip the test if the multilib flags force
#	a 64-bit ABI.
#
#    -mgp64
#	Force 64-bit code.  Also force a 64-bit target architecture
#	if the other flags don't do so.  Skip the test if the multilib
#	flags force a 32-bit ABI or a 32-bit architecture.
#
#    -mno-mips16
#	Skip the test for MIPS16 targets.
#
#    -march=*
#    -mips*
#	Select the target architecture.  Skip the test for MIPS16 targets
#	or if the multilib flags force a different architecture.
#
#    -msoft-float
#    -mhard-float
#	Select the given floating-point mode.  Skip the test if the
#	multilib flags force a different selection.
proc dg-mips-options {args} {
    upvar dg-extra-tool-flags extra_tool_flags
    upvar dg-do-what do_what

    global mips_isa
    global mips_arch
    global mips_mips16
    global mips_mips64
    global mips_float

    global mips_forced_isa
    global mips_forced_abi
    global mips_forced_float

    set flags [lindex $args 1]
    set matches 1

    # First handle the -mgp* options.  Add an architecture option if necessary.
    foreach flag $flags {
	if {$flag == "-mgp32" && $mips_mips64} {
	    if {$mips_forced_abi} {
		set matches 0
	    } else {
		append flags " -mabi=32"
	    }
	} elseif {$flag == "-mgp64" && !$mips_mips64} {
	    if {$mips_forced_abi} {
		set matches 0
	    } else {
		append flags " -mabi=o64"
		if {[lsearch -regexp $flags {^(-mips|-march)}] < 0} {
		    append flags " -mips3"
		}
	    }
	}
    }
    # Handle the other options.
    foreach flag $flags {
	if {$flag == "-mno-mips16"} {
	    if {$mips_mips16} {
		set matches 0
	    }
	} elseif {[regexp -- {^-march=(.*)} $flag dummy arch]} {
	    if {$mips_mips16 || ($arch != $mips_arch && $mips_forced_isa)} {
		set matches 0
	    }
	} elseif {[regexp -- {^-mips(.*)} $flag dummy isa] && $isa != 16} {
	    if {$mips_mips16 || ($isa != $mips_isa && $mips_forced_isa)} {
		set matches 0
	    }
	} elseif {[regexp -- {^-m(hard|soft)-float} $flag dummy float]} {
	    if {$mips_float != $float && $mips_forced_float} {
		set matches 0
	    }
	}
    }
    if {$matches} {
	set extra_tool_flags $flags
    } else {
	set do_what [list [lindex $do_what 0] "N" "P"]
    }
}

setup_mips_tests

dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" ""
dg-finish