1# Copyright (C) 2007-2018 Free Software Foundation, Inc.
2#
3# This file is part of GCC.
4#
5# GCC is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# GCC is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GCC; see the file COPYING3.  If not see
17# <http://www.gnu.org/licenses/>.
18
19# Run compatibility tests in which the "alt" compiler tries to force
20# MIPS16 mode.
21
22# We can only guarantee MIPS16 runtime support for certain targets.
23if { ![istarget mipsisa*-*-elf*] && ![istarget mips64vr*-*-elf*] } {
24    return
25}
26
27load_lib gcc-dg.exp
28
29# Check whether the flags are compatible with MIPS16 code generation.
30if { ![check_effective_target_mips16_attribute] } {
31    return
32}
33
34# Save the old value of CFLAGS_FOR_TARGET, if any.
35global saved_CFLAGS_FOR_TARGET
36if { [info exists CFLAGS_FOR_TARGET] } {
37    set saved_CFLAGS_FOR_TARGET $CFLAGS_FOR_TARGET
38} else {
39    unset -nocomplain saved_CFLAGS_FOR_TARGET
40}
41
42# The "alt" compiler is the normal compiler with an extra "-mips16" argument.
43proc compat-use-alt-compiler { } {
44    global saved_CFLAGS_FOR_TARGET CFLAGS_FOR_TARGET
45
46    if { [info exists saved_CFLAGS_FOR_TARGET] } {
47	set CFLAGS_FOR_TARGET [concat $saved_CFLAGS_FOR_TARGET "-mips16"]
48    } else {
49	set CFLAGS_FOR_TARGET "-mips16"
50    }
51}
52
53# Make the compiler under test the default.
54proc compat-use-tst-compiler { } {
55    global saved_CFLAGS_FOR_TARGET CFLAGS_FOR_TARGET
56
57    if { [info exists saved_CFLAGS_FOR_TARGET] } {
58	set CFLAGS_FOR_TARGET $saved_CFLAGS_FOR_TARGET
59    } else {
60	unset -nocomplain CFLAGS_FOR_TARGET
61    }
62}
63
64load_lib compat.exp
65
66gcc_init
67foreach src [lsort [find $srcdir/$subdir mips16_*_main.c]] {
68    if { [runtest_file_p $runtests $src] } {
69	compat-execute $src "mips16_inter" 1
70    }
71}
72compat-use-tst-compiler
73