"Maciej W. Rozycki" <ma...@codesourcery.com> writes: > The run-time selection options are -mnan=2008 and -mnan=legacy for the > 2008 NaN and the legacy NaN mode respectively. The binary patterns of NaN > data produced by compiler builtins or otherwise is adjusted accordingly, > as is a `.nan' directive included now with the assembly source produced, > used by GAS to set the NAN2008 ELF file header flag appropriately. These > options are also passed down to GAS by the GCC driver so that user > assembly sources have the said NAN2008 flag set correctly in the absence > of a `.nan' directive. Finally the name of the dynamic linker is changed > accordingly if the driver is used to invoke the linker.
I was a bit surprised that a change to the NaN format requires a change to the dynamic linker, but I suppose that's the consequence of forcing every ELF object to fall on one side of the fence? I assume eventually there'll be an -mmac={legacy|2008} option too, although of course it's good that that's a separate patch. But then the question is: is there a plan for handling all 8 possible combinations of -mnan, -mabs and -mmac? How would the FCSR be set up? Even if we do plan to have all three be separately configurable, I imagine most people will want them all set the same way, so it would probably make sense to have something like -mfp-model={legacy|2008} for that case. And then my inclination would be to start with that option and only add the split-out versions if we have a specific (rather than theoretical) use case for them. The patch mostly looks good apart from that, but please use a single enum for the 2008/legacy thing, both in mips.h and mips.opt. > +;; On pre IEEE 754-2008 processors abs.fmt is an arithmetic instruction > +;; and treats all NaN inputs as invalid; it does not clear their sign bit. > +;; We therefore can't use abs.fmt unless in the IEEE 754-2008 mode or if > +;; the signs of NaNs matter. "don't matter". Or maybe to avoid the double negative: ;; The "legacy" (as opposed to "2008") form of ABS.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. > +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 I think it reads better without the "-2008" bit, since even the 1985 version suggested this behaviour in the appendix. > +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. Very minor, but I'd prefer this without the "trailing"s. > +These options are only supported on targets using the ELF binary format. Let's drop that bit. We don't support non-ELF on MIPS. > +/* { dg-do compile } */ > +/* { dg-options "-mhard-float -mabs=2008" } */ Please instead make "-mabs=" imply "-mhard-float" in mips.exp. (It is an "imply"; you can still test for -msoft-float -mabs=... if you want.) > +# Return 1 if this is a MIPS target supporting -mnan=. > +# Old versions of binutils may not support this option. > + > +proc check_effective_target_mips_nan { } { > + if { ![istarget mips*-*-*] } { > + return 0 > + } > + return [check_no_compiler_messages mips_nan object { > + int dummy; > + } "-mnan=2008"] > +} The tests you added are dg-do compile tests, which stop after assembly generation, so this guard shouldn't be needed. FWIW, if you did have dg-do assemble or dg-do run tests, the mips.exp approach would be to downgrade them to dg-do compile rather than skip them altogether. We can add that later if we need it though... Thanks, Richard