# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
|
# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
|
|
|
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with GCC; see the file COPYING3. If not see
|
# along with GCC; see the file COPYING3. If not see
|
# .
|
# .
|
|
|
# GCC testsuite that uses the `dg.exp' driver.
|
# GCC testsuite that uses the `dg.exp' driver.
|
|
|
# Exit immediately if this isn't a MIPS target.
|
# Exit immediately if this isn't a MIPS target.
|
if ![istarget mips*-*-*] {
|
if ![istarget mips*-*-*] {
|
return
|
return
|
}
|
}
|
|
|
# Load support procs.
|
# Load support procs.
|
load_lib gcc-dg.exp
|
load_lib gcc-dg.exp
|
|
|
# Find out which target is selected by the default compiler flags.
|
# Find out which target is selected by the default compiler flags.
|
# Also remember which aspects of the target are forced on the command
|
# Also remember which aspects of the target are forced on the command
|
# line (as opposed to being overridable defaults).
|
# line (as opposed to being overridable defaults).
|
#
|
#
|
# $mips_isa: the ISA level specified by __mips
|
# $mips_isa: the ISA level specified by __mips
|
# $mips_arch: the architecture specified by _MIPS_ARCH
|
# $mips_arch: the architecture specified by _MIPS_ARCH
|
# $mips_mips16: true if MIPS16 mode is selected
|
# $mips_mips16: true if MIPS16 mode is selected
|
# $mips_mips64: true if 64-bit output is selected
|
# $mips_mips64: true if 64-bit output is selected
|
# $mips_float: "hard" or "soft"
|
# $mips_float: "hard" or "soft"
|
#
|
#
|
# $mips_forced_isa: true if the command line uses -march=* or -mips*
|
# $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_abi: true if the command line uses -mabi=* or -mgp*
|
# $mips_forced_float: true if the command line uses -mhard/soft-float
|
# $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_le true if the command line uses -EL or -mel
|
proc setup_mips_tests {} {
|
proc setup_mips_tests {} {
|
global mips_isa
|
global mips_isa
|
global mips_arch
|
global mips_arch
|
global mips_mips16
|
global mips_mips16
|
global mips_mips64
|
global mips_mips64
|
global mips_float
|
global mips_float
|
|
|
global mips_forced_isa
|
global mips_forced_isa
|
global mips_forced_abi
|
global mips_forced_abi
|
global mips_forced_float
|
global mips_forced_float
|
global mips_forced_le
|
global mips_forced_le
|
|
|
global compiler_flags
|
global compiler_flags
|
global tool
|
global tool
|
|
|
set src dummy[pid].c
|
set src dummy[pid].c
|
set f [open $src "w"]
|
set f [open $src "w"]
|
puts $f {
|
puts $f {
|
int isa = __mips;
|
int isa = __mips;
|
const char *arch = _MIPS_ARCH;
|
const char *arch = _MIPS_ARCH;
|
#ifdef __mips16
|
#ifdef __mips16
|
int mips16 = 1;
|
int mips16 = 1;
|
#endif
|
#endif
|
#ifdef __mips64
|
#ifdef __mips64
|
int mips64 = 1;
|
int mips64 = 1;
|
#endif
|
#endif
|
#ifdef __mips_hard_float
|
#ifdef __mips_hard_float
|
const char *float = "hard";
|
const char *float = "hard";
|
#else
|
#else
|
const char *float = "soft";
|
const char *float = "soft";
|
#endif
|
#endif
|
}
|
}
|
close $f
|
close $f
|
set output [${tool}_target_compile $src "" preprocess ""]
|
set output [${tool}_target_compile $src "" preprocess ""]
|
file delete $src
|
file delete $src
|
|
|
regexp {isa = ([^;]*)} $output dummy mips_isa
|
regexp {isa = ([^;]*)} $output dummy mips_isa
|
regexp {arch = "([^"]*)} $output dummy mips_arch
|
regexp {arch = "([^"]*)} $output dummy mips_arch
|
set mips_mips16 [regexp {mips16 = 1} $output]
|
set mips_mips16 [regexp {mips16 = 1} $output]
|
set mips_mips64 [regexp {mips64 = 1} $output]
|
set mips_mips64 [regexp {mips64 = 1} $output]
|
regexp {float = "([^"]*)} $output dummy mips_float
|
regexp {float = "([^"]*)} $output dummy mips_float
|
|
|
set mips_forced_isa [regexp -- {(-mips|-march)} $compiler_flags]
|
set mips_forced_isa [regexp -- {(-mips|-march)} $compiler_flags]
|
set mips_forced_abi [regexp -- {(-mgp|-mabi)} $compiler_flags]
|
set mips_forced_abi [regexp -- {(-mgp|-mabi)} $compiler_flags]
|
set mips_forced_float [regexp -- {-m(hard|soft)-float} $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_le [regexp -- {-(EL|mel)[[:>:]]} $compiler_flags]
|
}
|
}
|
|
|
# Return true if command-line option FLAG forces 32-bit code.
|
# Return true if command-line option FLAG forces 32-bit code.
|
proc is_gp32_flag {flag} {
|
proc is_gp32_flag {flag} {
|
switch -glob -- $flag {
|
switch -glob -- $flag {
|
-march=mips32* -
|
-march=mips32* -
|
-mgp32 { return 1 }
|
-mgp32 { return 1 }
|
default { return 0 }
|
default { return 0 }
|
}
|
}
|
}
|
}
|
|
|
# Like dg-options, but treats certain MIPS-specific options specially:
|
# Like dg-options, but treats certain MIPS-specific options specially:
|
#
|
#
|
# -mgp32
|
# -mgp32
|
# -march=mips32*
|
# -march=mips32*
|
# Force 32-bit code. Skip the test if the multilib flags force
|
# Force 32-bit code. Skip the test if the multilib flags force
|
# a 64-bit ABI.
|
# a 64-bit ABI.
|
#
|
#
|
# -mgp64
|
# -mgp64
|
# Force 64-bit code. Also force a 64-bit target architecture
|
# 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
|
# 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.
|
# flags force a 32-bit ABI or a 32-bit architecture.
|
#
|
#
|
# -mno-mips16
|
# -mno-mips16
|
# Skip the test for MIPS16 targets.
|
# Skip the test for MIPS16 targets.
|
#
|
#
|
# -march=*
|
# -march=*
|
# -mips*
|
# -mips*
|
# Select the target architecture. Skip the test for MIPS16 targets
|
# Select the target architecture. Skip the test for MIPS16 targets
|
# or if the multilib flags force a different architecture.
|
# or if the multilib flags force a different architecture.
|
#
|
#
|
# -msoft-float
|
# -msoft-float
|
# -mhard-float
|
# -mhard-float
|
# Select the given floating-point mode. Skip the test if the
|
# Select the given floating-point mode. Skip the test if the
|
# multilib flags force a different selection.
|
# multilib flags force a different selection.
|
#
|
#
|
# -EB
|
# -EB
|
# Select big-endian code. Skip the test if the multilib flags
|
# Select big-endian code. Skip the test if the multilib flags
|
# force a little-endian target.
|
# force a little-endian target.
|
proc dg-mips-options {args} {
|
proc dg-mips-options {args} {
|
upvar dg-extra-tool-flags extra_tool_flags
|
upvar dg-extra-tool-flags extra_tool_flags
|
upvar dg-do-what do_what
|
upvar dg-do-what do_what
|
|
|
global mips_isa
|
global mips_isa
|
global mips_arch
|
global mips_arch
|
global mips_mips16
|
global mips_mips16
|
global mips_mips64
|
global mips_mips64
|
global mips_float
|
global mips_float
|
|
|
global mips_forced_isa
|
global mips_forced_isa
|
global mips_forced_abi
|
global mips_forced_abi
|
global mips_forced_float
|
global mips_forced_float
|
global mips_forced_le
|
global mips_forced_le
|
|
|
set flags [lindex $args 1]
|
set flags [lindex $args 1]
|
set matches 1
|
set matches 1
|
|
|
# First handle the -mgp* options. Add an architecture option if necessary.
|
# First handle the -mgp* options. Add an architecture option if necessary.
|
foreach flag $flags {
|
foreach flag $flags {
|
if {[is_gp32_flag $flag] && $mips_mips64} {
|
if {[is_gp32_flag $flag] && $mips_mips64} {
|
if {$mips_forced_abi} {
|
if {$mips_forced_abi} {
|
set matches 0
|
set matches 0
|
} else {
|
} else {
|
append flags " -mabi=32"
|
append flags " -mabi=32"
|
}
|
}
|
} elseif {$flag == "-mgp64" && !$mips_mips64} {
|
} elseif {$flag == "-mgp64" && !$mips_mips64} {
|
if {$mips_forced_abi} {
|
if {$mips_forced_abi} {
|
set matches 0
|
set matches 0
|
} else {
|
} else {
|
append flags " -mabi=o64"
|
append flags " -mabi=o64"
|
if {[lsearch -regexp $flags {^(-mips|-march)}] < 0} {
|
if {[lsearch -regexp $flags {^(-mips|-march)}] < 0} {
|
append flags " -mips3"
|
append flags " -mips3"
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
# Handle the other options.
|
# Handle the other options.
|
foreach flag $flags {
|
foreach flag $flags {
|
if {$flag == "-mno-mips16"} {
|
if {$flag == "-mno-mips16"} {
|
if {$mips_mips16} {
|
if {$mips_mips16} {
|
set matches 0
|
set matches 0
|
}
|
}
|
} elseif {[regexp -- {^-march=(.*)} $flag dummy arch]} {
|
} elseif {[regexp -- {^-march=(.*)} $flag dummy arch]} {
|
if {$mips_mips16 || ($arch != $mips_arch && $mips_forced_isa)} {
|
if {$mips_mips16 || ($arch != $mips_arch && $mips_forced_isa)} {
|
set matches 0
|
set matches 0
|
}
|
}
|
} elseif {[regexp -- {^-mips(.*)} $flag dummy isa] && $isa != 16} {
|
} elseif {[regexp -- {^-mips(.*)} $flag dummy isa] && $isa != 16} {
|
if {$mips_mips16 || ($isa != $mips_isa && $mips_forced_isa)} {
|
if {$mips_mips16 || ($isa != $mips_isa && $mips_forced_isa)} {
|
set matches 0
|
set matches 0
|
}
|
}
|
} elseif {[regexp -- {^-m(hard|soft)-float} $flag dummy float]} {
|
} elseif {[regexp -- {^-m(hard|soft)-float} $flag dummy float]} {
|
if {$mips_float != $float && $mips_forced_float} {
|
if {$mips_float != $float && $mips_forced_float} {
|
set matches 0
|
set matches 0
|
}
|
}
|
} elseif {[regexp -- {^-(EB|meb)$} $flag]} {
|
} elseif {[regexp -- {^-(EB|meb)$} $flag]} {
|
if {$mips_forced_le} {
|
if {$mips_forced_le} {
|
set matches 0
|
set matches 0
|
}
|
}
|
}
|
}
|
}
|
}
|
if {$matches} {
|
if {$matches} {
|
set extra_tool_flags $flags
|
set extra_tool_flags $flags
|
} else {
|
} else {
|
set do_what [list [lindex $do_what 0] "N" "P"]
|
set do_what [list [lindex $do_what 0] "N" "P"]
|
}
|
}
|
}
|
}
|
|
|
setup_mips_tests
|
setup_mips_tests
|
|
|
dg-init
|
dg-init
|
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" ""
|
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" ""
|
dg-finish
|
dg-finish
|
|
|