glibc/soft-fp
Joseph Myers 2004e7fb76 soft-fp: Add _FP_TO_INT_ROUND.
Continuing the series of patches adding soft-fp features from the
kernel version of soft-fp to glibc so that glibc's version is able to
replace the old fork of soft-fp in the kernel, this patch adds the
last major such feature: _FP_TO_INT_ROUND, converting a floating-point
number to an integer with rounding according to the current rounding
direction (as opposed to truncating towards zero, which _FP_TO_INT
does).

The general structure of the implementation follows that of
_FP_TO_INT, but of course is more complicated.  As with glibc's
_FP_TO_INT it works with raw input (the kernel versions of these
macros predate the conversion of _FP_TO_INT and many other macros to
raw or semi-raw input).  I have not tried to work out what bugs there
might be in the kernel version that this might fix; it's a
from-scratch implementation based on _FP_TO_INT.

Tested for powerpc (soft-float) that there is no change to the
installed shared libraries; also tested with the libm tests with lrint
/ lrintf / llrint / llrintf made to use _FP_TO_INT_ROUND, to provide
some test of the functionality.  As we don't have benchmarks for those
functions, I haven't actually included the soft-fp versions of them,
although I expect them to be faster than the existing code (given that
the existing code involves adding and subtracting numbers such as
0x1p52 to achieve the desired rounding, which is not particularly
efficient when the underlying floating point is software floating
point).

2014-11-04  Joseph Myers  <joseph@codesourcery.com>

	* soft-fp/op-common.h (_FP_TO_INT_ROUND): New macro.
	* soft-fp/double.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_D): New
	macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_D): Likewise.
	* soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_E):
	New macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_E): Likewise.
	* soft-fp/quad.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_Q): New
	macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_Q): Likewise.
	* soft-fp/single.h (FP_TO_INT_ROUND_S): New macro.
2014-11-04 16:34:49 +00:00
..
adddf3.c
addsf3.c
addtf3.c
Banner
divdf3.c
divsf3.c
divtf3.c
double.h soft-fp: Add _FP_TO_INT_ROUND. 2014-11-04 16:34:49 +00:00
eqdf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
eqsf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
eqtf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
extenddftf2.c soft-fp: Make extensions of subnormals from XFmode to TFmode signal underflow if traps enabled. 2014-10-09 01:00:41 +00:00
extended.h soft-fp: Add _FP_TO_INT_ROUND. 2014-11-04 16:34:49 +00:00
extendsfdf2.c soft-fp: Make extensions of subnormals from XFmode to TFmode signal underflow if traps enabled. 2014-10-09 01:00:41 +00:00
extendsftf2.c soft-fp: Make extensions of subnormals from XFmode to TFmode signal underflow if traps enabled. 2014-10-09 01:00:41 +00:00
extendxftf2.c soft-fp: Make extensions of subnormals from XFmode to TFmode signal underflow if traps enabled. 2014-10-09 01:00:41 +00:00
fixdfdi.c
fixdfsi.c
fixdfti.c
fixsfdi.c
fixsfsi.c
fixsfti.c
fixtfdi.c
fixtfsi.c
fixtfti.c
fixunsdfdi.c
fixunsdfsi.c
fixunsdfti.c
fixunssfdi.c
fixunssfsi.c
fixunssfti.c
fixunstfdi.c
fixunstfsi.c
fixunstfti.c
floatdidf.c
floatdisf.c
floatditf.c
floatsidf.c
floatsisf.c
floatsitf.c
floattidf.c
floattisf.c
floattitf.c
floatundidf.c
floatundisf.c
floatunditf.c
floatunsidf.c
floatunsisf.c
floatunsitf.c
floatuntidf.c
floatuntisf.c
floatuntitf.c
fmadf4.c
fmasf4.c
fmatf4.c
gedf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
gesf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
getf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
ledf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
lesf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
letf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
Makefile Consistently include Makeconfig after defining subdir. 2014-02-26 23:12:03 +00:00
muldf3.c
mulsf3.c
multf3.c
negdf2.c
negsf2.c
negtf2.c
op-1.h soft-fp: Use parentheses around macro arguments. 2014-10-09 17:05:26 +00:00
op-2.h soft-fp: Use parentheses around macro arguments. 2014-10-09 17:05:26 +00:00
op-4.h soft-fp: Use parentheses around macro arguments. 2014-10-09 17:05:26 +00:00
op-8.h soft-fp: Fix comment formatting. 2014-09-17 22:20:45 +00:00
op-common.h soft-fp: Add _FP_TO_INT_ROUND. 2014-11-04 16:34:49 +00:00
quad.h soft-fp: Add _FP_TO_INT_ROUND. 2014-11-04 16:34:49 +00:00
single.h soft-fp: Add _FP_TO_INT_ROUND. 2014-11-04 16:34:49 +00:00
soft-fp.h soft-fp: Support more precise "invalid" exceptions. 2014-10-09 14:59:23 +00:00
sqrtdf2.c
sqrtsf2.c
sqrttf2.c
subdf3.c
subsf3.c
subtf3.c
testit.c
truncdfsf2.c
trunctfdf2.c
trunctfsf2.c
trunctfxf2.c
unorddf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
unordsf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00
unordtf2.c soft-fp: Refactor exception handling for comparisons. 2014-10-09 01:03:56 +00:00