blob: fef509749034b36c034298f7c56212ea278ea9ee (
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# Copyright (C) 1997, 2007 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 3 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 GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# 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
# $mips_forced_le true if the command line uses -EL or -mel
# $mips_forced_gp true if the command line forces a particular GP mode
# $mips_forced_no_er true if the command line contains -mno-explicit-relocs
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 mips_forced_le
global mips_forced_gp
global mips_forced_no_er
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|-mfp|-mabi)} $compiler_flags]
set mips_forced_float [regexp -- {-m(hard|soft)-float} $compiler_flags]
set mips_forced_le [regexp -- {-(EL|mel)[[:>:]]} $compiler_flags]
set mips_forced_gp [regexp -- {-(G|m(|no-)((extern|local)-sdata|gpopt)|mabicalls|mrtp)} $compiler_flags]
set mips_forced_no_er [regexp -- {-mno-explicit-relocs} $compiler_flags]
}
# Return true if command-line option FLAG forces 32-bit code.
proc is_gp32_flag {flag} {
switch -glob -- $flag {
-msmartmips -
-march=mips32* -
-mgp32 { return 1 }
default { return 0 }
}
}
# Like dg-options, but treats certain MIPS-specific options specially:
#
# -mgp32
# -march=mips32*
# 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.
#
# -EB
# Select big-endian code. Skip the test if the multilib flags
# force a little-endian target.
#
# -G*
# -m(no-)extern-sdata
# -m(no-)local-sdata
# -m(no-)gpopt
# Select the small-data mode, and -mno-abcialls. Skip the test if
# the multilib flags already contain such an option, or specify
# something that might be incompatible with them.
#
# -mexplicit-relocs
# Select explicit relocations. Skip the test if the multilib flags
# force -mno-explicit-relocs.
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
global mips_forced_le
global mips_forced_gp
global mips_forced_no_er
set flags [lindex $args 1]
set matches 1
# First handle the -mgp* options. Add an architecture option if necessary.
foreach flag $flags {
if {[is_gp32_flag $flag] && $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 {$flag == "-mfp64"} {
if {$mips_isa < 33 || $mips_float != "hard"} {
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
}
} elseif {[regexp -- {^-(EB|meb)$} $flag]} {
if {$mips_forced_le} {
set matches 0
}
} elseif {[regexp -- {^-(G|m(|no-)((extern|local)-sdata|gpopt))} $flag]} {
append flags " -mno-abicalls"
if {$mips_forced_gp} {
set matches 0
}
} elseif {[regexp -- {^-mexplicit-relocs$} $flag]} {
if {$mips_forced_no_er} {
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
|