aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@codesourcery.com>2013-07-29 14:37:30 +0000
committerMaciej W. Rozycki <macro@gcc.gnu.org>2013-07-29 14:37:30 +0000
commitff3f395157c42a6d2c922de085f5a890834f975b (patch)
tree4b72a5f006ea9267e8c0e91ce37fdae020e14228
parent576e2f37400cecb0cdb4537c7777284b7878e7c0 (diff)
downloadgcc-ff3f395157c42a6d2c922de085f5a890834f975b.zip
gcc-ff3f395157c42a6d2c922de085f5a890834f975b.tar.gz
gcc-ff3f395157c42a6d2c922de085f5a890834f975b.tar.bz2
linux.h (GLIBC_DYNAMIC_LINKER): Handle `-mnan=2008'.
gcc/ * config/mips/linux.h (GLIBC_DYNAMIC_LINKER): Handle `-mnan=2008'. (UCLIBC_DYNAMIC_LINKER): New macro. * config/mips/linux64.h (GLIBC_DYNAMIC_LINKER32): Handle `-mnan=2008'. (GLIBC_DYNAMIC_LINKER64, GLIBC_DYNAMIC_LINKERN32): Likewise. (UCLIBC_DYNAMIC_LINKER32): Undefine macro first. Handle `-mnan=2008'. (UCLIBC_DYNAMIC_LINKER64): Redefine macro. (UCLIBC_DYNAMIC_LINKERN32): Likewise. * config/mips/mips-modes.def: Remove RESET_FLOAT_FORMAT calls for SF and DF modes. Use ieee_quad_format for TF mode. * config/mips/mips-opts.h (mips_ieee_754_setting): New enum. * config/mips/mips.c (mips_file_start): Output a `.nan' directive. (mips_option_override): Handle `-mnan=legacy'. * config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): Handle `-mabs=2008' and `-mnan=2008'. (OPTION_DEFAULT_SPECS): Add "nan" default. (ASM_SPEC): Handle `-mnan='. [!HAVE_AS_NAN] (HAVE_AS_NAN): New macro. * config/mips/mips.md (abs<mode>2): Handle `-mabs=2008', update comment accordingly. (neg<mode>2): Likewise. * config/mips/mips.opt (mabs, mnan): New options. * doc/install.texi (Configuration): Document `--with-nan=' option. * doc/invoke.texi (Option Summary): List MIPS `-mabs=' and `-mnan=' options. (MIPS Options): Document them. * config.gcc <mips*-*-*>: Handle `--with-nan='. * configure.ac <mips*-*-*>: Check for GAS `-mnan=2008' support. * configure: Regenerate. * config.in: Regenerate. gcc/testsuite/ * gcc.target/mips/fabs-2008.c: New test case. * gcc.target/mips/fabs-legacy.c: New test case. * gcc.target/mips/fabsf-2008.c: New test case. * gcc.target/mips/fabsf-legacy.c: New test case. * gcc.target/mips/fneg-2008.c: New test case. * gcc.target/mips/fneg-legacy.c: New test case. * gcc.target/mips/fneg-2008.c: New test case. * gcc.target/mips/fneg-legacy.c: New test case. * gcc.target/mips/nan-2008.c: New test case. * gcc.target/mips/nan-legacy.c: New test case. * gcc.target/mips/nanf-2008.c: New test case. * gcc.target/mips/nanf-legacy.c: New test case. * gcc.target/mips/nans-2008.c: New test case. * gcc.target/mips/nans-legacy.c: New test case. * gcc.target/mips/nansf-2008.c: New test case. * gcc.target/mips/nansf-legacy.c: New test case. * gcc.target/mips/mips.exp: Handle `-mabs=' and `-mnan='. From-SVN: r201313
-rw-r--r--gcc/ChangeLog34
-rw-r--r--gcc/config.gcc14
-rw-r--r--gcc/config.in6
-rw-r--r--gcc/config/mips/linux.h7
-rw-r--r--gcc/config/mips/linux64.h20
-rw-r--r--gcc/config/mips/mips-modes.def7
-rw-r--r--gcc/config/mips/mips-opts.h7
-rw-r--r--gcc/config/mips/mips.c14
-rw-r--r--gcc/config/mips/mips.h14
-rw-r--r--gcc/config/mips/mips.md18
-rw-r--r--gcc/config/mips/mips.opt18
-rwxr-xr-xgcc/configure35
-rw-r--r--gcc/configure.ac11
-rw-r--r--gcc/doc/install.texi18
-rw-r--r--gcc/doc/invoke.texi45
-rw-r--r--gcc/testsuite/ChangeLog20
-rw-r--r--gcc/testsuite/gcc.target/mips/fabs-2008.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fabs-legacy.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fabsf-2008.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fabsf-legacy.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fneg-2008.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fneg-legacy.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fnegf-2008.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/fnegf-legacy.c10
-rw-r--r--gcc/testsuite/gcc.target/mips/mips.exp18
-rw-r--r--gcc/testsuite/gcc.target/mips/nan-2008.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nan-legacy.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nanf-2008.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nanf-legacy.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nans-2008.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nans-legacy.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nansf-2008.c7
-rw-r--r--gcc/testsuite/gcc.target/mips/nansf-legacy.c7
33 files changed, 419 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e30f63b..4237a6d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,37 @@
+2013-07-29 Maciej W. Rozycki <macro@codesourcery.com>
+
+ * config/mips/linux.h (GLIBC_DYNAMIC_LINKER): Handle `-mnan=2008'.
+ (UCLIBC_DYNAMIC_LINKER): New macro.
+ * config/mips/linux64.h (GLIBC_DYNAMIC_LINKER32): Handle
+ `-mnan=2008'.
+ (GLIBC_DYNAMIC_LINKER64, GLIBC_DYNAMIC_LINKERN32): Likewise.
+ (UCLIBC_DYNAMIC_LINKER32): Undefine macro first. Handle
+ `-mnan=2008'.
+ (UCLIBC_DYNAMIC_LINKER64): Redefine macro.
+ (UCLIBC_DYNAMIC_LINKERN32): Likewise.
+ * config/mips/mips-modes.def: Remove RESET_FLOAT_FORMAT calls
+ for SF and DF modes. Use ieee_quad_format for TF mode.
+ * config/mips/mips-opts.h (mips_ieee_754_setting): New enum.
+ * config/mips/mips.c (mips_file_start): Output a `.nan' directive.
+ (mips_option_override): Handle `-mnan=legacy'.
+ * config/mips/mips.h (TARGET_CPU_CPP_BUILTINS): Handle
+ `-mabs=2008' and `-mnan=2008'.
+ (OPTION_DEFAULT_SPECS): Add "nan" default.
+ (ASM_SPEC): Handle `-mnan='.
+ [!HAVE_AS_NAN] (HAVE_AS_NAN): New macro.
+ * config/mips/mips.md (abs<mode>2): Handle `-mabs=2008', update
+ comment accordingly.
+ (neg<mode>2): Likewise.
+ * config/mips/mips.opt (mabs, mnan): New options.
+ * doc/install.texi (Configuration): Document `--with-nan=' option.
+ * doc/invoke.texi (Option Summary): List MIPS `-mabs=' and
+ `-mnan=' options.
+ (MIPS Options): Document them.
+ * config.gcc <mips*-*-*>: Handle `--with-nan='.
+ * configure.ac <mips*-*-*>: Check for GAS `-mnan=2008' support.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2013-07-29 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (float post-reload splitters): Do not check
diff --git a/gcc/config.gcc b/gcc/config.gcc
index e09ba64..e4c42ab 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3532,7 +3532,7 @@ case "${target}" in
;;
mips*-*-*)
- supported_defaults="abi arch arch_32 arch_64 float fpu tune tune_32 tune_64 divide llsc mips-plt synci"
+ supported_defaults="abi arch arch_32 arch_64 float fpu nan tune tune_32 tune_64 divide llsc mips-plt synci"
case ${with_float} in
"" | soft | hard)
@@ -3554,6 +3554,16 @@ case "${target}" in
;;
esac
+ case ${with_nan} in
+ "" | 2008 | legacy)
+ # OK
+ ;;
+ *)
+ echo "Unknown NaN encoding used in --with-nan=$with_nan" 1>&2
+ exit 1
+ ;;
+ esac
+
case ${with_abi} in
"" | 32 | o64 | n32 | 64 | eabi)
# OK
@@ -3913,7 +3923,7 @@ case ${target} in
esac
t=
-all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu divide llsc mips-plt synci tls"
+all_defaults="abi cpu cpu_32 cpu_64 arch arch_32 arch_64 tune tune_32 tune_64 schedule float mode fpu nan divide llsc mips-plt synci tls"
for option in $all_defaults
do
eval "val=\$with_"`echo $option | sed s/-/_/g`
diff --git a/gcc/config.in b/gcc/config.in
index 288c11f..25890e8 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -417,6 +417,12 @@
#endif
+/* Define if the assembler understands -mnan=. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_NAN
+#endif
+
+
/* Define if your assembler supports the -no-mul-bug-abort option. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION
diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
index 9b4c68d..6736295 100644
--- a/gcc/config/mips/linux.h
+++ b/gcc/config/mips/linux.h
@@ -17,4 +17,9 @@ 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/>. */
-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+#define GLIBC_DYNAMIC_LINKER \
+ "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
+
+#undef UCLIBC_DYNAMIC_LINKER
+#define UCLIBC_DYNAMIC_LINKER \
+ "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
diff --git a/gcc/config/mips/linux64.h b/gcc/config/mips/linux64.h
index dbba47a..421a53a 100644
--- a/gcc/config/mips/linux64.h
+++ b/gcc/config/mips/linux64.h
@@ -22,10 +22,22 @@ along with GCC; see the file COPYING3. If not see
#define GNU_USER_LINK_EMULATION64 "elf64%{EB:b}%{EL:l}tsmip"
#define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld.so.1"
-#define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
-#define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+#define GLIBC_DYNAMIC_LINKER32 \
+ "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
+#define GLIBC_DYNAMIC_LINKER64 \
+ "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
+#define GLIBC_DYNAMIC_LINKERN32 \
+ "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
+
+#undef UCLIBC_DYNAMIC_LINKER32
+#define UCLIBC_DYNAMIC_LINKER32 \
+ "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
+#undef UCLIBC_DYNAMIC_LINKER64
+#define UCLIBC_DYNAMIC_LINKER64 \
+ "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
+#define UCLIBC_DYNAMIC_LINKERN32 \
+ "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
+
#define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
#define GNU_USER_DYNAMIC_LINKERN32 \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
diff --git a/gcc/config/mips/mips-modes.def b/gcc/config/mips/mips-modes.def
index ecb7f18..383d2cb 100644
--- a/gcc/config/mips/mips-modes.def
+++ b/gcc/config/mips/mips-modes.def
@@ -17,12 +17,7 @@ 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/>. */
-/* MIPS has a quirky almost-IEEE format for all its
- floating point. */
-RESET_FLOAT_FORMAT (SF, mips_single_format);
-RESET_FLOAT_FORMAT (DF, mips_double_format);
-
-FLOAT_MODE (TF, 16, mips_quad_format);
+FLOAT_MODE (TF, 16, ieee_quad_format);
/* Vector modes. */
VECTOR_MODES (INT, 4); /* V4QI V2HI */
diff --git a/gcc/config/mips/mips-opts.h b/gcc/config/mips/mips-opts.h
index dbfcfad..56249d9 100644
--- a/gcc/config/mips/mips-opts.h
+++ b/gcc/config/mips/mips-opts.h
@@ -27,6 +27,13 @@ enum mips_code_readable_setting {
CODE_READABLE_YES
};
+/* Enumerates the setting of the -mabs and -mnan options. */
+enum mips_ieee_754_setting {
+ MIPS_IEEE_754_DEFAULT,
+ MIPS_IEEE_754_LEGACY,
+ MIPS_IEEE_754_2008
+};
+
/* Enumerates the setting of the -mr10k-cache-barrier option. */
enum mips_r10k_cache_barrier_setting {
R10K_CACHE_BARRIER_NONE,
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index a56757c..46e1d2d 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -8843,6 +8843,11 @@ mips_file_start (void)
fprintf (asm_out_file, "\t.section .gcc_compiled_long%d\n"
"\t.previous\n", TARGET_LONG64 ? 64 : 32);
+ /* Record the NaN encoding. */
+ if (HAVE_AS_NAN || mips_nan != MIPS_IEEE_754_DEFAULT)
+ fprintf (asm_out_file, "\t.nan\t%s\n",
+ mips_nan == MIPS_IEEE_754_2008 ? "2008" : "legacy");
+
#ifdef HAVE_AS_GNU_ATTRIBUTE
{
int attr;
@@ -16980,6 +16985,15 @@ mips_option_override (void)
}
}
+ /* Pre-IEEE 754-2008 MIPS hardware has a quirky almost-IEEE format
+ for all its floating point. */
+ if (mips_nan != MIPS_IEEE_754_2008)
+ {
+ REAL_MODE_FORMAT (SFmode) = &mips_single_format;
+ REAL_MODE_FORMAT (DFmode) = &mips_double_format;
+ REAL_MODE_FORMAT (TFmode) = &mips_quad_format;
+ }
+
/* Make sure that the user didn't turn off paired single support when
MIPS-3D support is requested. */
if (TARGET_MIPS3D
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 2dcccd4..af7eeee 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -507,6 +507,12 @@ struct mips_cpu_info {
if (TARGET_PAIRED_SINGLE_FLOAT) \
builtin_define ("__mips_paired_single_float"); \
\
+ if (mips_abs == MIPS_IEEE_754_2008) \
+ builtin_define ("__mips_abs2008"); \
+ \
+ if (mips_nan == MIPS_IEEE_754_2008) \
+ builtin_define ("__mips_nan2008"); \
+ \
if (TARGET_BIG_ENDIAN) \
{ \
builtin_define_std ("MIPSEB"); \
@@ -743,6 +749,7 @@ struct mips_cpu_info {
--with-abi is ignored if -mabi is specified.
--with-float is ignored if -mhard-float or -msoft-float are
specified.
+ --with-nan is ignored if -mnan is specified.
--with-divide is ignored if -mdivide-traps or -mdivide-breaks are
specified. */
#define OPTION_DEFAULT_SPECS \
@@ -755,6 +762,7 @@ struct mips_cpu_info {
{"abi", "%{!mabi=*:-mabi=%(VALUE)}" }, \
{"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }, \
{"fpu", "%{!msingle-float:%{!mdouble-float:-m%(VALUE)-float}}" }, \
+ {"nan", "%{!mnan=*:-mnan=%(VALUE)}" }, \
{"divide", "%{!mdivide-traps:%{!mdivide-breaks:-mdivide-%(VALUE)}}" }, \
{"llsc", "%{!mllsc:%{!mno-llsc:-m%(VALUE)}}" }, \
{"mips-plt", "%{!mplt:%{!mno-plt:-m%(VALUE)}}" }, \
@@ -1160,7 +1168,7 @@ struct mips_cpu_info {
%(subtarget_asm_debugging_spec) \
%{mabi=*} %{!mabi=*: %(asm_abi_default_spec)} \
%{mgp32} %{mgp64} %{march=*} %{mxgot:-xgot} \
-%{mfp32} %{mfp64} \
+%{mfp32} %{mfp64} %{mnan=*} \
%{mshared} %{mno-shared} \
%{msym32} %{mno-sym32} \
%{mtune=*} \
@@ -2897,6 +2905,10 @@ while (0)
#define HAVE_AS_TLS 0
#endif
+#ifndef HAVE_AS_NAN
+#define HAVE_AS_NAN 0
+#endif
+
#ifndef USED_FOR_TARGET
/* Information about ".set noFOO; ...; .set FOO" blocks. */
struct mips_asm_switch {
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index ca79a31..397c40a 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -2711,14 +2711,15 @@
;; Do not use the integer abs macro instruction, since that signals an
;; exception on -2147483648 (sigh).
-;; abs.fmt is an arithmetic instruction and treats all NaN inputs as
-;; invalid; it does not clear their sign bits. We therefore can't use
-;; abs.fmt if the signs of NaNs matter.
+;; The "legacy" (as opposed to "2008") form of ABS.fmt is an arithmetic
+;; instruction that treats all NaN inputs as invalid; it does not clear
+;; their sign bit. We therefore can't use that form if the signs of
+;; NaNs matter.
(define_insn "abs<mode>2"
[(set (match_operand:ANYF 0 "register_operand" "=f")
(abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
- "!HONOR_NANS (<MODE>mode)"
+ "mips_abs == MIPS_IEEE_754_2008 || !HONOR_NANS (<MODE>mode)"
"abs.<fmt>\t%0,%1"
[(set_attr "type" "fabs")
(set_attr "mode" "<UNITMODE>")])
@@ -2793,14 +2794,15 @@
[(set_attr "alu_type" "sub")
(set_attr "mode" "DI")])
-;; neg.fmt is an arithmetic instruction and treats all NaN inputs as
-;; invalid; it does not flip their sign bit. We therefore can't use
-;; neg.fmt if the signs of NaNs matter.
+;; The "legacy" (as opposed to "2008") form of NEG.fmt is an arithmetic
+;; instruction that treats all NaN inputs as invalid; it does not flip
+;; their sign bit. We therefore can't use that form if the signs of
+;; NaNs matter.
(define_insn "neg<mode>2"
[(set (match_operand:ANYF 0 "register_operand" "=f")
(neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))]
- "!HONOR_NANS (<MODE>mode)"
+ "mips_abs == MIPS_IEEE_754_2008 || !HONOR_NANS (<MODE>mode)"
"neg.<fmt>\t%0,%1"
[(set_attr "type" "fneg")
(set_attr "mode" "<UNITMODE>")])
diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt
index 08ab29b..0324041 100644
--- a/gcc/config/mips/mips.opt
+++ b/gcc/config/mips/mips.opt
@@ -205,6 +205,24 @@ mfused-madd
Target Report Mask(FUSED_MADD)
Generate floating-point multiply-add instructions
+mabs=
+Target RejectNegative Joined Enum(mips_ieee_754_value) Var(mips_abs) Init(MIPS_IEEE_754_DEFAULT)
+-mabs=MODE Select the IEEE 754 ABS/NEG instruction execution mode
+
+mnan=
+Target RejectNegative Joined Enum(mips_ieee_754_value) Var(mips_nan) Init(MIPS_IEEE_754_DEFAULT)
+-mnan=ENCODING Select the IEEE 754 NaN data encoding
+
+Enum
+Name(mips_ieee_754_value) Type(int)
+Known MIPS IEEE 754 settings (for use with the -mabs= and -mnan= options):
+
+EnumValue
+Enum(mips_ieee_754_value) String(2008) Value(MIPS_IEEE_754_2008)
+
+EnumValue
+Enum(mips_ieee_754_value) String(legacy) Value(MIPS_IEEE_754_LEGACY)
+
mgp32
Target Report RejectNegative InverseMask(64BIT)
Use 32-bit general registers
diff --git a/gcc/configure b/gcc/configure
index e36a608..0d6ddaa 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -26019,6 +26019,41 @@ $as_echo "$gcc_cv_ld_mips_personality_relaxation" >&6; }
$as_echo "#define HAVE_LD_PERSONALITY_RELAXATION 1" >>confdefs.h
fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mnan= support" >&5
+$as_echo_n "checking assembler for -mnan= support... " >&6; }
+if test "${gcc_cv_as_mips_nan+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_mips_nan=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mnan=2008 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_mips_nan=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mips_nan" >&5
+$as_echo "$gcc_cv_as_mips_nan" >&6; }
+if test $gcc_cv_as_mips_nan = yes; then
+
+$as_echo "#define HAVE_AS_NAN 1" >>confdefs.h
+
+fi
+ if test x$gcc_cv_as_mips_nan = xno \
+ && test x$with_nan != x; then
+ as_fn_error "Requesting --with-nan= requires assembler support for -mnan=" "$LINENO" 5
+ fi
;;
esac
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 9dfd389..b279373 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4168,6 +4168,17 @@ EOF
[Define if your linker can relax absolute .eh_frame personality
pointers into PC-relative form.])
fi
+
+ gcc_GAS_CHECK_FEATURE([-mnan= support],
+ gcc_cv_as_mips_nan,,
+ [-mnan=2008],,,
+ [AC_DEFINE(HAVE_AS_NAN, 1,
+ [Define if the assembler understands -mnan=.])])
+ if test x$gcc_cv_as_mips_nan = xno \
+ && test x$with_nan != x; then
+ AC_MSG_ERROR(
+ [Requesting --with-nan= requires assembler support for -mnan=])
+ fi
;;
esac
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index e05cbed..9e5ba5e 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1221,6 +1221,24 @@ ISA for floating-point arithmetics. You can select either @samp{sse} which
enables @option{-msse2} or @samp{avx} which enables @option{-mavx} by default.
This option is only supported on i386 and x86-64 targets.
+@item --with-nan=@var{encoding}
+On MIPS targets, set the default encoding convention to use for the
+special not-a-number (NaN) IEEE 754 floating-point data. The
+possibilities for @var{encoding} are:
+@table @code
+@item legacy
+Use the legacy encoding, as with the @option{-mnan=legacy} command-line
+option.
+@item 2008
+Use the 754-2008 encoding, as with the @option{-mnan=2008} command-line
+option.
+@end table
+To use this configuration option you must have an assembler version
+installed that supports the @option{-mnan=} command-line option too.
+In the absence of this configuration option the default convention is
+the legacy encoding, as when neither of the @option{-mnan=2008} and
+@option{-mnan=legacy} command-line options has been used.
+
@item --with-divide=@var{type}
Specify how the compiler should generate code for checking for
division by zero. This option is only supported on the MIPS target.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4457809..92cc250 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -750,7 +750,8 @@ Objective-C and Objective-C++ Dialects}.
-mabi=@var{abi} -mabicalls -mno-abicalls @gol
-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
-mgp32 -mgp64 -mfp32 -mfp64 -mhard-float -msoft-float @gol
--mno-float -msingle-float -mdouble-float @gol
+-mno-float -msingle-float -mdouble-float @gol
+-mabs=@var{mode} -mnan=@var{encoding} @gol
-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
-mmcu -mmno-mcu @gol
-meva -mno-eva @gol
@@ -16324,6 +16325,48 @@ operations.
Assume that the floating-point coprocessor supports double-precision
operations. This is the default.
+@item -mabs=2008
+@itemx -mabs=legacy
+@opindex mabs=2008
+@opindex mabs=legacy
+These options control the treatment of the special not-a-number (NaN)
+IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
+@code{neg.@i{fmt}} machine instructions.
+
+By default or when the @option{-mabs=legacy} is used the legacy
+treatment is selected. In this case these instructions are considered
+arithmetic and avoided where correct operation is required and the
+input operand might be a NaN. A longer sequence of instructions that
+manipulate the sign bit of floating-point datum manually is used
+instead unless the @option{-ffinite-math-only} option has also been
+specified.
+
+The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
+this case these instructions are considered non-arithmetic and therefore
+operating correctly in all cases, including in particular where the
+input operand is a NaN. These instructions are therefore always used
+for the respective operations.
+
+@item -mnan=2008
+@itemx -mnan=legacy
+@opindex mnan=2008
+@opindex mnan=legacy
+These options control the encoding of the special not-a-number (NaN)
+IEEE 754 floating-point data.
+
+The @option{-mnan=legacy} option selects the legacy encoding. In this
+case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
+significand field being 0, whereas signalling NaNs (sNaNs) are denoted
+by the first bit of their trailing significand field being 1.
+
+The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
+this case qNaNs are denoted by the first bit of their trailing
+significand field being 1, whereas sNaNs are denoted by the first bit of
+their trailing significand field being 0.
+
+The default is @option{-mnan=legacy} unless GCC has been configured with
+@option{--with-nan=2008}.
+
@item -mllsc
@itemx -mno-llsc
@opindex mllsc
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8082e4a..7c022b7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,23 @@
+2013-07-29 Maciej W. Rozycki <macro@codesourcery.com>
+
+ * gcc.target/mips/fabs-2008.c: New test case.
+ * gcc.target/mips/fabs-legacy.c: New test case.
+ * gcc.target/mips/fabsf-2008.c: New test case.
+ * gcc.target/mips/fabsf-legacy.c: New test case.
+ * gcc.target/mips/fneg-2008.c: New test case.
+ * gcc.target/mips/fneg-legacy.c: New test case.
+ * gcc.target/mips/fneg-2008.c: New test case.
+ * gcc.target/mips/fneg-legacy.c: New test case.
+ * gcc.target/mips/nan-2008.c: New test case.
+ * gcc.target/mips/nan-legacy.c: New test case.
+ * gcc.target/mips/nanf-2008.c: New test case.
+ * gcc.target/mips/nanf-legacy.c: New test case.
+ * gcc.target/mips/nans-2008.c: New test case.
+ * gcc.target/mips/nans-legacy.c: New test case.
+ * gcc.target/mips/nansf-2008.c: New test case.
+ * gcc.target/mips/nansf-legacy.c: New test case.
+ * gcc.target/mips/mips.exp: Handle `-mabs=' and `-mnan='.
+
2013-07-29 Alexander Ivchenko <alexander.ivchenko@intel.com>
Maxim Kuvyrkov <maxim@kugelworks.com>
diff --git a/gcc/testsuite/gcc.target/mips/fabs-2008.c b/gcc/testsuite/gcc.target/mips/fabs-2008.c
new file mode 100644
index 0000000..f48437d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabs-2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=2008" } */
+
+NOMIPS16 double
+fabs_2008 (double d)
+{
+ return __builtin_fabs (d);
+}
+
+/* { dg-final { scan-assembler "\tabs\.d\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fabs-legacy.c b/gcc/testsuite/gcc.target/mips/fabs-legacy.c
new file mode 100644
index 0000000..af86b85
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabs-legacy.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=legacy" } */
+
+NOMIPS16 double
+fabs_legacy (double d)
+{
+ return __builtin_fabs (d);
+}
+
+/* { dg-final { scan-assembler-not "\tabs\.d\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fabsf-2008.c b/gcc/testsuite/gcc.target/mips/fabsf-2008.c
new file mode 100644
index 0000000..229dae6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabsf-2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=2008" } */
+
+NOMIPS16 float
+fabsf_2008 (float f)
+{
+ return __builtin_fabsf (f);
+}
+
+/* { dg-final { scan-assembler "\tabs\.s\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fabsf-legacy.c b/gcc/testsuite/gcc.target/mips/fabsf-legacy.c
new file mode 100644
index 0000000..453a069
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fabsf-legacy.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=legacy" } */
+
+NOMIPS16 float
+fabsf_legacy (float f)
+{
+ return __builtin_fabsf (f);
+}
+
+/* { dg-final { scan-assembler-not "\tabs\.s\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fneg-2008.c b/gcc/testsuite/gcc.target/mips/fneg-2008.c
new file mode 100644
index 0000000..7d76f45
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fneg-2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=2008" } */
+
+NOMIPS16 double
+fneg_2008 (double d)
+{
+ return -d;
+}
+
+/* { dg-final { scan-assembler "\tneg\.d\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fneg-legacy.c b/gcc/testsuite/gcc.target/mips/fneg-legacy.c
new file mode 100644
index 0000000..cd1422d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fneg-legacy.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=legacy" } */
+
+NOMIPS16 double
+fneg_legacy (double d)
+{
+ return -d;
+}
+
+/* { dg-final { scan-assembler-not "\tneg\.d\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fnegf-2008.c b/gcc/testsuite/gcc.target/mips/fnegf-2008.c
new file mode 100644
index 0000000..72d8ef1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fnegf-2008.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=2008" } */
+
+NOMIPS16 float
+fnegf_2008 (float f)
+{
+ return -f;
+}
+
+/* { dg-final { scan-assembler "\tneg\.s\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/fnegf-legacy.c b/gcc/testsuite/gcc.target/mips/fnegf-legacy.c
new file mode 100644
index 0000000..946a6ef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/fnegf-legacy.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-mabs=legacy" } */
+
+NOMIPS16 float
+fnegf_legacy (float f)
+{
+ return -f;
+}
+
+/* { dg-final { scan-assembler-not "\tneg\.s\t" } } */
diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
index 54c97db..f648f07 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -276,8 +276,10 @@ foreach option {
# Add -mfoo= options to mips_option_groups.
foreach option {
+ abs
branch-cost
code-readable
+ nan
r10k-cache-barrier
tune
} {
@@ -705,6 +707,18 @@ proc mips-dg-init {} {
"-msoft-float",
#endif
+ #ifdef __mips_abs2008
+ "-mabs=2008",
+ #else
+ "-mabs=legacy",
+ #endif
+
+ #ifdef __mips_nan2008
+ "-mnan=2008",
+ #else
+ "-mnan=legacy",
+ #endif
+
#if __mips_fpr == 64
"-mfp64",
#else
@@ -826,6 +840,8 @@ proc mips-dg-finish {} {
# | |
# -mfp64 -mfp32
# | |
+# -mabs=2008/-mabs=legacy <no option>
+# | |
# -mhard-float -msoft-float
# | |
# -mno-sym32 -msym32
@@ -913,6 +929,8 @@ proc mips-dg-options { args } {
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 "-mabs=2008" "-mhard-float"
+ mips_option_dependency options "-mabs=legacy" "-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"
diff --git a/gcc/testsuite/gcc.target/mips/nan-2008.c b/gcc/testsuite/gcc.target/mips/nan-2008.c
new file mode 100644
index 0000000..b31299d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nan-2008.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008 -EB" } */
+
+double d = __builtin_nan ("");
+
+/* { dg-final { scan-assembler "\t\.nan\t2008\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2146959360\n\t.word\t0\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nan-legacy.c b/gcc/testsuite/gcc.target/mips/nan-legacy.c
new file mode 100644
index 0000000..8ae7166
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nan-legacy.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=legacy -EB" } */
+
+double d = __builtin_nan ("");
+
+/* { dg-final { scan-assembler "\t\.nan\tlegacy\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2146959359\n\t.word\t-1\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nanf-2008.c b/gcc/testsuite/gcc.target/mips/nanf-2008.c
new file mode 100644
index 0000000..6c5bd7b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nanf-2008.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008 -EB" } */
+
+float f = __builtin_nanf ("");
+
+/* { dg-final { scan-assembler "\t\.nan\t2008\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2143289344\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nanf-legacy.c b/gcc/testsuite/gcc.target/mips/nanf-legacy.c
new file mode 100644
index 0000000..b13d339
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nanf-legacy.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=legacy -EB" } */
+
+float f = __builtin_nanf ("");
+
+/* { dg-final { scan-assembler "\t\.nan\tlegacy\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2143289343\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nans-2008.c b/gcc/testsuite/gcc.target/mips/nans-2008.c
new file mode 100644
index 0000000..b75fc28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nans-2008.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008 -EB" } */
+
+double ds = __builtin_nans ("");
+
+/* { dg-final { scan-assembler "\t\.nan\t2008\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2146697216\n\t.word\t0\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nans-legacy.c b/gcc/testsuite/gcc.target/mips/nans-legacy.c
new file mode 100644
index 0000000..45fab68
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nans-legacy.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=legacy -EB" } */
+
+double ds = __builtin_nans ("");
+
+/* { dg-final { scan-assembler "\t\.nan\tlegacy\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2147483647\n\t.word\t-1\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nansf-2008.c b/gcc/testsuite/gcc.target/mips/nansf-2008.c
new file mode 100644
index 0000000..d6c86a8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nansf-2008.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=2008 -EB" } */
+
+float fs = __builtin_nansf ("");
+
+/* { dg-final { scan-assembler "\t\.nan\t2008\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2141192192\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/nansf-legacy.c b/gcc/testsuite/gcc.target/mips/nansf-legacy.c
new file mode 100644
index 0000000..27c480f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/nansf-legacy.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-mnan=legacy -EB" } */
+
+float fs = __builtin_nansf ("");
+
+/* { dg-final { scan-assembler "\t\.nan\tlegacy\n" } } */
+/* { dg-final { scan-assembler "\t\.word\t2147483647\n" } } */