-# Copyright (C) 1997, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2007, 2008, 2009, 2010 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
# For example, "isa_rev>=1" selects a MIPS32 or MIPS64 processor,
# "isa=4" selects a MIPS IV processor, and so on.
#
-# If certain processor-specific extensions are not applicable to the
-# test you can list them as !CPU in the isa or isa_rev options. For
-# example, isa=64!octeon enforces MIPS64 while avoiding octeon. You
-# can also use ! without an ISA value. For example
-# isa=!octeon!loongson2e disables octeon and loongson2e if otherwise
-# you would compile for one of them.
-#
# There are also the following special pseudo-options:
#
# isa=loongson
# addressing=absolute
# force absolute addresses to be used
#
+# forbid_cpu=REGEXP
+# forbid processors that match the given regexp; choose a
+# generic ISA instead.
+#
#
# In summary:
#
# "-mips32r2" or "-mips64r2".
#
# (6) If you need to disable processor-specific extensions use
-# isa=!CPU instead of forcing a generic ISA.
+# forbid_cpu=REGEXP instead of forcing a generic ISA.
+#
+#
+# Terminology
+#
+# Option group or just group:
+# See comment before mips_option_groups.
+#
+# Test options:
+# The options specified in dg-options.
+#
+# Explicit options:
+# The options that were either passed to runtest as "multilib" options
+# (e.g. -mips4 in --target_board=mips-sim-idt/-mips4) or specified as
+# test options. Note that options in parenthesis (i.e. (-mips16)) are
+# not explicit and can be omitted depending on the base options.
+#
+# Base options:
+# Options that are on by default without being specified in dg-options,
+# e.g. -march=mips64r2 for mipsisa64r2-elf or because they've been
+# passed to runtest as "multilib" options.
+#
+# Option array:
+# Many functions in this file work with option arrays. These are
+# two-dimensional Tcl arrays where the first dimension can have three
+# values: option, explicit_p or test_option_p. The second dimension is
+# the name of the option group. "option" contains the name of the
+# option that is in effect from this group. If no option is active it
+# contains the empty string. The flags "explicit_p" and "test_option_p"
+# are set for explicit and test options.
# Exit immediately if this isn't a MIPS target.
if ![istarget mips*-*-*] {
load_lib gcc-dg.exp
# A list of GROUP REGEXP pairs. Each GROUP represents a logical group of
-# options from which only option should be chosen. REGEXP matches all the
-# options in that group; it is implicitly wrapped in "^(...)$".
+# options from which only one option should be chosen. REGEXP matches all
+# the options in that group; it is implicitly wrapped in "^(...)$".
set mips_option_groups {
abi "-mabi=.*"
addressing "addressing=.*"
arch "-mips([1-5]|32.*|64.*)|-march=.*|isa(|_rev)(=|<=|>=).*"
+ debug "-g*"
dump_pattern "-dp"
endianness "-E(L|B)|-me(l|b)"
float "-m(hard|soft)-float"
+ forbid_cpu "forbid_cpu=.*"
fp "-mfp(32|64)"
gp "-mgp(32|64)"
long "-mlong(32|64)"
- mips16 "-mips16|-mno-mips16"
+ mips16 "-mips16|-mno-mips16|-mflip-mips16"
mips3d "-mips3d|-mno-mips3d"
optimization "-O(|[0-3s])"
pic "-f(no-|)(pic|PIC)"
shared
smartmips
sym32
+ synci
+ relax-pic-calls
+ mcount-ra-address
} {
lappend mips_option_groups $option "-m(no-|)$option"
}
branch-cost
code-readable
r10k-cache-barrier
+ tune
} {
lappend mips_option_groups $option "-m$option=.*"
}
return $status(option,$group)
}
-# If the default options for this test run include an option in group GROUP,
+# If the base options for this test run include an option in group GROUP,
# return that option, otherwise return "".
proc mips_original_option { group } {
global mips_base_options
return [mips_option mips_base_options $group]
}
-# Return true if the test described up UPSTATUS requires a specific
-# option in group GROUP.
+# Return true if the test described by UPSTATUS requires a specific
+# option in group GROUP. UPSTATUS describes the option status.
proc mips_test_option_p { upstatus group } {
upvar $upstatus status
$option]
}
+# Return true if the options described by UPSTATUS require MIPS16 support.
+proc mips_using_mips16_p { upstatus } {
+ upvar $upstatus status
+
+ return [expr { [mips_have_option_p status "-mips16"]
+ || [mips_have_option_p status "-mflip-mips16"] }]
+}
+
# Return true if the test described by UPSTATUS requires option OPTION.
proc mips_have_test_option_p { upstatus option } {
upvar $upstatus status
return 0
}
+# Return true if the given abi-group option implicitly requires -mlong32.
+# o64 requires this for -mabicalls, but not otherwise; pick the conservative
+# case for simplicity.
+proc mips_long32_abi_p { option } {
+ switch -glob -- $option {
+ -mabi=o64 -
+ -mabi=n32 -
+ -mabi=32 {
+ return 1
+ }
+ }
+ return 0
+}
+
+# Return true if the given abi-group option implicitly requires -mlong64.
+proc mips_long64_abi_p { option } {
+ switch -glob -- $option {
+ -mabi=64 {
+ return 1
+ }
+ }
+ return 0
+}
+
# Check whether the current target supports all the options that the
# current test requires. Return "" if so, otherwise return one of
# the incompatible options. UPSTATUS describes the option status.
#
# START END
# | |
-# -mips16 -mno-mips16
+# -mips16/-mflip-mips16 -mno-mips16
# | |
# -mips3d -mno-mips3d
# | |
# | |
# -mno-sym32 -msym32
# | |
+# -mrelax-pic-calls -mno-relax-pic-calls
+# | |
# -fpic -fno-pic
# | |
# -mshared -mno-shared
# | |
# -mexplicit-relocs -mno-explicit-relocs
# | |
+# -mdspr2 -mno-dspr2
+# | |
+# -mdsp -mno-dsp
+# | |
# +-- gp, abi & arch ---------+
#
# For these purposes, the "gp", "abi" & "arch" option groups are treated
mips_option_dependency options "-mips3d" "-mpaired-single"
mips_option_dependency options "-mpaired-single" "-mfp64"
mips_option_dependency options "-mfp64" "-mhard-float"
+ mips_option_dependency options "-mrelax-pic-calls" "-mno-plt"
+ mips_option_dependency options "-mrelax-pic-calls" "-mabicalls"
+ mips_option_dependency options "-mrelax-pic-calls" "-mexplicit-relocs"
mips_option_dependency options "-fpic" "-mshared"
mips_option_dependency options "-mshared" "-mno-plt"
+ mips_option_dependency options "-mshared" "-mabicalls"
mips_option_dependency options "-mno-plt" "addressing=unknown"
mips_option_dependency options "-mabicalls" "-G0"
mips_option_dependency options "-mno-gpopt" "-mexplicit-relocs"
}
}
+ # See whether forbid_cpu forces us to choose a new architecture.
+ set arch [mips_option mips_base_options arch]
+ set force_generic_isa_p [expr {
+ [regexp "forbid_cpu=(.*)" [mips_option options forbid_cpu] dummy spec]
+ && [regexp -- "^-march=$spec\$" $arch]
+ }]
+
# Interpret the special "isa" and "isa_rev" options. If we have
# a choice of a 32-bit or a 64-bit architecture, prefer to keep
# the -mgp setting the same.
set spec [mips_option options arch]
if { [regexp {^[^-]} $spec] } {
- set arch [mips_option mips_base_options arch]
if { [string equal $spec "isa=loongson"] } {
if { ![regexp {^-march=loongson} $arch] } {
set arch "-march=loongson2f"
}
} else {
- # With ! and = the ISA value is optional.
- if { ![regexp {^(isa(?:|_rev))(=|<=|>=)([0-9]*)((?:![^!]+)*)$} \
- $spec dummy prop relation value nocpus]
- || ($value eq ""
- && ($relation ne "="
- || $nocpus eq ""))} {
+ if { ![regexp {^(isa(?:|_rev))(=|<=|>=)([0-9]*)$} \
+ $spec dummy prop relation value nocpus] } {
error "Unrecognized isa specification: $spec"
}
- if { $value ne "" } {
- set current [mips_arch_info $arch $prop]
- if { ($current < $value && ![string equal $relation "<="])
- || ($current > $value && ![string equal $relation ">="])
- || ([mips_have_test_option_p options "-mgp64"]
- && [mips_32bit_arch_p $arch]) } {
- # The current setting is out of range; it cannot
- # possibly be used. Find a replacement that can.
- if { [string equal $prop "isa"] } {
- set arch "-mips$value"
- } elseif { $value == 0 } {
- set arch "-mips4"
+ set current [mips_arch_info $arch $prop]
+ if { $force_generic_isa_p
+ || ($current < $value && ![string equal $relation "<="])
+ || ($current > $value && ![string equal $relation ">="])
+ || ([mips_have_test_option_p options "-mgp64"]
+ && [mips_32bit_arch_p $arch]) } {
+ # The current setting is out of range; it cannot
+ # possibly be used. Find a replacement that can.
+ if { [string equal $prop "isa"] } {
+ set arch "-mips$value"
+ } elseif { $value == 0 } {
+ set arch "-mips4"
+ } else {
+ if { [mips_have_option_p options "-mgp32"] } {
+ set arch "-mips32"
} else {
- if { [mips_have_option_p options "-mgp32"] } {
- set arch "-mips32"
- } else {
- set arch "-mips64"
- }
- if { $value > 1 } {
- append arch "r$value"
- }
+ set arch "-mips64"
}
- }
- }
- # If we haven't switched to a generic ISA based on the
- # isa* value, do it here if the processor-specific
- # extension is not allowed.
- if { $nocpus ne ""
- && $arch eq [mips_option mips_base_options arch] } {
- set cpu [regsub -- {-march=} $arch ""]
- if { [regexp "!$cpu!" "$nocpus!"] } {
- set isa_rev [mips_arch_info $arch isa_rev]
- set arch "-mips[mips_arch_info $arch isa]"
- if { $isa_rev > 1 } {
- append arch "r$isa_rev"
+ if { $value > 1 } {
+ append arch "r$value"
}
}
}
} else {
mips_make_test_option options "-mips64r$isa_rev"
}
+ # Otherwise, if the current choice of architecture is unacceptable,
+ # choose the equivalent generic architecture.
+ } elseif { $force_generic_isa_p } {
+ set arch "-mips[mips_arch_info $arch isa]"
+ if { $isa_rev > 1 } {
+ append arch "r$isa_rev"
+ }
+ mips_make_test_option options $arch
}
unset arch
unset isa
# EABI doesn't support -mabicalls.
# EABI doesn't support the combination -mgp32 -mfp64.
set force_abi 1
- } elseif { [mips_have_option_p options "-mips16"]
+ } elseif { [mips_using_mips16_p options]
&& ![mips_same_option_p $abi "-mabi=32"]
&& ![mips_same_option_p $abi "-mabi=o64"]
&& (![mips_have_option_p options "addressing=absolute"]
# -mips16 -mhard-float requires o32 or o64.
# -mips16 PIC requires o32 or o64.
set force_abi 1
+ } elseif { [mips_have_test_option_p options "-mlong32"]
+ && [mips_long64_abi_p $abi] } {
+ set force_abi 1
+ } elseif { [mips_have_test_option_p options "-mlong64"]
+ && [mips_long32_abi_p $abi] } {
+ set force_abi 1
} else {
set force_abi 0
}
if { $gp_size == 32 } {
if { $force_abi || [mips_64bit_abi_p $abi] } {
- mips_make_test_option options "-mabi=32"
+ if { [mips_have_test_option_p options "-mlong64"] } {
+ mips_make_test_option options "-mabi=eabi"
+ mips_make_test_option options "-mgp32"
+ } else {
+ mips_make_test_option options "-mabi=32"
+ }
}
} else {
if { $force_abi || [mips_32bit_abi_p $abi] } {
- # All configurations should have an assembler that
- # supports o64, since it requires the same BFD target
- # vector as o32. In contrast, many assembler
- # configurations do not have n32 or n64 support.
- mips_make_test_option options "-mabi=o64"
+ if { [mips_have_test_option_p options "-mlong64"] } {
+ mips_make_test_option options "-mabi=eabi"
+ mips_make_test_option options "-mgp64"
+ } else {
+ # All configurations should have an assembler that
+ # supports o64, since it requires the same BFD target
+ # vector as o32. In contrast, many assembler
+ # configurations do not have n32 or n64 support.
+ mips_make_test_option options "-mabi=o64"
+ }
}
}
- unset abi
- unset eabi_p
+ set abi_test_option_p [mips_test_option_p options abi]
+ set abi [mips_option options abi]
+ set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
}
# Handle dependencies between the abi options and the post-abi options.
mips_make_test_option options "-mfp32"
}
}
- if { [mips_have_option_p options "-mips16"]
+ if { [mips_using_mips16_p options]
&& ![mips_same_option_p $abi "-mabi=32"]
&& ![mips_same_option_p $abi "-mabi=o64"]
&& (![mips_have_option_p options "addressing=absolute"]
mips_make_test_option options "-mno-mips16"
}
}
- unset abi
- unset eabi_p
+ if { [mips_long32_abi_p $abi] } {
+ mips_make_test_option options "-mlong32"
+ } elseif { [mips_long64_abi_p $abi] } {
+ mips_make_test_option options "-mlong64"
+ }
}
# Handle dependencies between the arch option and the post-arch options.
mips_make_test_option options "-mfp32"
}
mips_make_test_option options "-mno-dsp"
- mips_make_test_option options "-mno-dspr2"
}
unset arch
unset isa
}
# Handle dependencies between options on the right of the diagram.
+ mips_option_dependency options "-mno-dsp" "-mno-dspr2"
mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
switch -- [mips_test_option options small-data] {
"" -
# Add all options to the dg variable.
set options(explicit_p,addressing) 0
+ set options(explicit_p,forbid_cpu) 0
foreach { group regexp } $mips_option_groups {
if { $options(explicit_p,$group) } {
append extra_tool_flags " " $options(option,$group)