summary refs log tree commit diff
path: root/soft-fp/soft-fp.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-10-09 14:59:23 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-10-09 14:59:23 +0000
commitff12c11f4515a9f83467471e8d4381eb3dbc06b5 (patch)
treedf4a57f11f0ee2f2fb1fd07c6538c66df6dd7fea /soft-fp/soft-fp.h
parentb6dcfe8c2408958be246dd61f1c5415ed7667a2a (diff)
downloadglibc-ff12c11f4515a9f83467471e8d4381eb3dbc06b5.tar.gz
glibc-ff12c11f4515a9f83467471e8d4381eb3dbc06b5.tar.xz
glibc-ff12c11f4515a9f83467471e8d4381eb3dbc06b5.zip
soft-fp: Support more precise "invalid" exceptions.
As previously discussed
<https://sourceware.org/ml/libc-alpha/2013-10/msg00345.html>, it would
be desirable to be able to use the same version of the soft-fp code in
the Linux kernel as well as in glibc and libgcc (instead of an old
version in the kernel that's missing ten years of bug fixes,
performance improvements and new features), and to that end it is
useful to add to glibc's copy features in the kernel's copy, even when
they are not directly useful in glibc.

To that end, this patch adds one of those features: support for more
precise "invalid" exceptions describing the particular kind of invalid
operation.  These are relevant for powerpc emulation, and are also as
described in IEEE 754-2008 as sub-exceptions.

The set of sub-exceptions here is the union of those supported on
powerpc and those from IEEE 754-2008 (the former adds a distinction
between 0/0 and Inf/Inf; the latter adds a distinction between Inf*0
from multiplication and the same from fma).  This includes
sub-exceptions for sqrt, conversions to integer and comparisons that
are not supported in the kernel; I see no obvious reason for these
being missing from the kernel support, given that they are supported
on powerpc so accurate powerpc emulation should generate them.

Tested for powerpc-nofpu that the disassembly of installed shared
libraries is unchanged by this patch.

	* soft-fp/soft-fp.h (FP_EX_INVALID_SNAN): New macro.
	(FP_EX_INVALID_IMZ): Likewise.
	(FP_EX_INVALID_IMZ_FMA): Likewise.
	(FP_EX_INVALID_ISI): Likewise.
	(FP_EX_INVALID_ZDZ): Likewise.
	(FP_EX_INVALID_IDI): Likewise.
	(FP_EX_INVALID_SQRT): Likewise.
	(FP_EX_INVALID_CVI): Likewise.
	(FP_EX_INVALID_VC): Likewise.
	* soft-fp/op-common.h (_FP_UNPACK_CANONICAL): Specify more precise
	"invalid" exceptions.
	(_FP_CHECK_SIGNAN_SEMIRAW): Likewise.
	(_FP_ADD_INTERNAL): Likewise.
	(_FP_MUL): Likewise.
	(_FP_FMA): Likewise.
	(_FP_DIV): Likewise.
	(_FP_CMP_CHECK_NAN): Likewise.
	(_FP_SQRT): Likewise.
	(_FP_TO_INT): Likewise.
	(FP_EXTEND): Likewise.
Diffstat (limited to 'soft-fp/soft-fp.h')
-rw-r--r--soft-fp/soft-fp.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h
index 3ac269ecf7..05fcca0aba 100644
--- a/soft-fp/soft-fp.h
+++ b/soft-fp/soft-fp.h
@@ -83,6 +83,44 @@
 # define FP_EX_DENORM		0
 #endif
 
+/* Sub-exceptions of "invalid".  */
+/* Signaling NaN operand.  */
+#ifndef FP_EX_INVALID_SNAN
+# define FP_EX_INVALID_SNAN	0
+#endif
+/* Inf * 0.  */
+#ifndef FP_EX_INVALID_IMZ
+# define FP_EX_INVALID_IMZ	0
+#endif
+/* fma (Inf, 0, c).  */
+#ifndef FP_EX_INVALID_IMZ_FMA
+# define FP_EX_INVALID_IMZ_FMA	0
+#endif
+/* Inf - Inf.  */
+#ifndef FP_EX_INVALID_ISI
+# define FP_EX_INVALID_ISI	0
+#endif
+/* 0 / 0.  */
+#ifndef FP_EX_INVALID_ZDZ
+# define FP_EX_INVALID_ZDZ	0
+#endif
+/* Inf / Inf.  */
+#ifndef FP_EX_INVALID_IDI
+# define FP_EX_INVALID_IDI	0
+#endif
+/* sqrt (negative).  */
+#ifndef FP_EX_INVALID_SQRT
+# define FP_EX_INVALID_SQRT	0
+#endif
+/* Invalid conversion to integer.  */
+#ifndef FP_EX_INVALID_CVI
+# define FP_EX_INVALID_CVI	0
+#endif
+/* Invalid comparison.  */
+#ifndef FP_EX_INVALID_VC
+# define FP_EX_INVALID_VC	0
+#endif
+
 /* _FP_STRUCT_LAYOUT may be defined as an attribute to determine the
    struct layout variant used for structures where bit-fields are used
    to access specific parts of binary floating-point numbers.  This is