summaryrefslogtreecommitdiff
path: root/fpu
AgeCommit message (Collapse)AuthorFilesLines
2013-06-10softfloat: Fix shift128Right for shift counts 64..127Peter Maydell1-1/+1
shift128Right would give the wrong result for a shift count between 64 and 127. This was never noticed because all of our uses of this function are guaranteed not to use shift counts in this range. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1370186269-24353-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-15fpu: Correct edgecase in float64_muladdPeter Maydell1-3/+9
In handling float64_muladd, if we end up doing a subtraction of the product and c, and the 128 bit result of this subtraction happens to have its most significant bit in bit 63, we weren't handling this correctly when attempting to normalize to put the most significant bit into bit 126. We would end up doing a right shift by a negative number (undefined behaviour in C) so at best we would return an incorrect result to the guest. MSB in bit 63 has to be handled as a special case separately from MSB in 0..62 and MSB in 63..126. (MSB in 127 is not possible.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2013-01-26softfloat: Handle float_muladd_negate_c when product is zeroRichard Sandiford1-2/+2
Honour float_muladd_negate_c in the case where the product is zero and c is nonzero. Previously we would fail to negate c. Seen in (and tested against) the gfortran testsuite on MIPS. Signed-off-by: Richard Sandiford <rdsandiford@googlemail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-05softfloat: Implement uint64_to_float128Richard Henderson1-0/+8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-05softfloat: Fix uint64_to_float64Richard Henderson1-3/+10
The interface to normalizeRoundAndPackFloat64 requires that the high bit be clear. Perform one shift-right-and-jam if needed. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-12-19fpu: move public header file to include/fpuPaolo Bonzini2-639/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-31softfloat: implement fused multiply-add NaN propagation for MIPSAurelien Jarno1-0/+27
Add a pickNaNMulAdd function for MIPS, implementing NaN propagation rules for MIPS fused multiply-add instructions. Cc: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2012-10-01fpu/softfloat.c: Return correctly signed values from uint64_to_float32Peter Maydell1-2/+2
The uint64_to_float32() conversion function was incorrectly always returning numbers with the sign bit set (ie negative numbers). Correct this so we return positive numbers instead. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2012-10-01fpu/softfloat.c: Remove pointless shift of always-zero valuePeter Maydell1-1/+1
In float16_to_float32, when returning an infinity, just pass zero as the mantissa argument to packFloat32(), rather than shifting a value which we know must be zero. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2012-09-22target-xtensa: specialize softfloat NaN rulesMax Filippov1-2/+3
NaN propagation rule: leftmost NaN in the expression gets propagated to the result. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-22softfloat: add NO_SIGNALING_NANSMax Filippov2-0/+72
Architectures that don't have signaling NaNs can define NO_SIGNALING_NANS, it will make float*_is_quiet_nan return 1 for any NaN and float*_is_signaling_nan always return 0. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-09-22softfloat: make float_muladd_negate_* flags independentMax Filippov1-1/+1
Flags passed into float{32,64}_muladd are treated as bits; assign independent bits to float_muladd_negate_* to allow precise control over what gets negated in float{32,64}_muladd. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-28softfloat: Replace int16 type with int_fast16_tAndreas Färber3-71/+68
Based on the following Coccinelle patch: @@ typedef int16, int_fast16_t; @@ -int16 +int_fast16_t Avoids a workaround for AIX. Add typedef for pre-10 Solaris. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: malc <av1474@comtv.ru> Cc: Ben Taylor <bentaylor.solx86@gmail.com> Tested-by: Bernhard Walle <bernhard@bwalle.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-28softfloat: Replace uint16 type with uint_fast16_tAndreas Färber2-7/+7
Based on the following Coccinelle patch: @@ typedef uint16, uint_fast16_t; @@ -uint16 +uint_fast16_t Fixes the build of the Cocoa frontend on Mac OS X and avoids a workaround for AIX. For pre-10 Solaris include osdep.h. Reported-by: Pavel Borzenkov <pavel.borzenkov@gmail.com> Reported-by: Rui Carmo <rui.carmo@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Juan Pineda <juan@logician.com> Cc: malc <av1474@comtv.ru> Cc: Ben Taylor <bentaylor.solx86@gmail.com> Tested-by: Bernhard Walle <bernhard@bwalle.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-28softfloat: Fix mixups of int and int16Andreas Färber1-2/+2
normalizeFloat{32,64}Subnormal() expect the exponent as int16, not int. This went unnoticed since int16 and uint16 were both typedef'ed to int. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Bernhard Walle <bernhard@bwalle.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-21softfloat: make USE_SOFTFLOAT_STRUCT_TYPES compileJuan Quintela1-2/+2
This change makes it compile and return the same value than the #undef one. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-07softfloat: roundAndPackInt{32, 64}: Don't assume int32 is 32 bitsPeter Maydell1-2/+2
Fix code in roundAndPackInt32 that assumed that int32 was only 32 bits, by simply using int32_t instead. Fix the parallel bug in roundAndPackInt64 as well, although that one is only theoretical since it's unlikely that int64 will ever be more than 64 bits. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-07softfloat: float*_to_int32_round_to_zero: don't assume int32 is 32 bitsPeter Maydell1-4/+4
Code in the float64_to_int32_round_to_zero() function was assuming that int32 would not be wider than 32 bits; this meant it might not correctly detect the overflow case. We take the simple approach of using int32_t. Also fix equivalent issues in the functions for other float sizes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-03-17softfloat: fix for C99Avi Kivity2-4/+6
C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax. Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Andreas Färber <afaerber@suse.de> Reported-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-10-19softfloat: Implement fused multiply-addPeter Maydell3-0/+619
Implement fused multiply-add as a softfloat primitive. This implements "a+b*c" as a single step without any intermediate rounding; it is specified in IEEE 754-2008 and implemented in a number of CPUs. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2011-10-01softfloat: Reinstate accidentally disabled target-specific NaN handlingPeter Maydell1-0/+5
Include config.h in softfloat.c, so that the target specific ifdefs in softfloat-specialize.h are evaluated correctly. This was accidentally broken in commit 789ec7ce2 when config-target.h was removed from softfloat.h, and means that most targets will have been returning the wrong results for calculations involving NaNs. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-03softfloat: Use uint32 consistentlyAndreas Färber2-12/+12
Prepares for uint32 replacement. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-09-03softfloat: Use uint16 consistentlyAndreas Färber2-6/+6
Prepares for uint16 replacement. Signed-off-by: Andreas Färber <andreas.faerber@web.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-07-29softfloat: change default nan definitions to variablesPaolo Bonzini2-51/+81
Most definitions in softfloat.h are really target-independent, but the file is not because it includes definitions of the default NaN values. Change those to variables to allow including softfloat.h from files that are not compiled per-target. By making them const, the compiler is allowed to optimize them into softfloat functions that use them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-06-03softfloat: add float*_is_zero_or_denormal()Aurelien Jarno1-0/+15
float*_is_zero_or_denormal() is available for float32, but not for float64, floatx80 and float128. Fix that. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-06-03softfloat: always enable floatx80 and float128 supportAurelien Jarno3-116/+0
Now that softfloat-native is gone, there is no real point on not always enabling floatx80 and float128 support. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-06-03softfloat-native: removeAurelien Jarno3-1085/+0
Remove softfloat-native support, all targets are now using softfloat instead. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-05-23softfloat: Add new flag for when denormal result is flushed to zeroPeter Maydell2-8/+36
Add a new float_flag_output_denormal which is set when the result of a floating point operation would be denormal but is flushed to zero because we are in flush_to_zero mode. This is necessary because some architectures signal this condition as an underflow and others signal it as an inexact result. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat-native: add float*_is_any_nan() functionsAurelien Jarno2-0/+29
Add float*_is_any_nan() functions to match the softfloat API. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat-native: fix float*_scalbn() functionsAurelien Jarno1-3/+3
float*_scalbn() should be able to take a status parameter. Fix that. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: fix float*_scalnb() corner casesAurelien Jarno1-5/+42
float*_scalnb() were not taking into account all cases. This patch fixes some corner cases: - NaN values in input were not properly propagated and the invalid flag not correctly raised. Use propagateFloat*NaN() for that. - NaN or infinite values in input of floatx80_scalnb() were not correctly detected due to a typo. - The sum of exponent and n could overflow, leading to strange results. Additionally having int16 defined to int make that happening for a very small range of values. Fix that by saturating n to the maximum exponent range, and using an explicit wider type if needed. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: add floatx80_compare*() functionsAurelien Jarno2-0/+48
Add floatx80_compare() and floatx80_compare_quiet() functions to match the softfloat-native ones. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat-native: add a few constant valuesAurelien Jarno1-0/+27
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: add pi constantsAurelien Jarno1-0/+3
Add a pi constant for float32, float64, floatx80. It will be used by target-i386 and later by the trigonometric functions. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: add floatx80 constantsAurelien Jarno1-0/+7
Add floatx80 constants similarly to float32 or float64. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: fix floatx80_is_infinity()Aurelien Jarno1-1/+1
With floatx80, the explicit bit is set for infinity. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-25softfloat: fix floatx80 handling of NaNAurelien Jarno1-7/+16
The floatx80 format uses an explicit bit that should be taken into account when converting to and from commonNaN format. When converting to commonNaN, the explicit bit should be removed if it is a 1, and a default NaN should be used if it is 0. When converting from commonNan, the explicit bit should be added. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: improve description of comparison functionsAurelien Jarno1-37/+48
Make clear for all comparison functions which ones trigger an exception for all NaNs, and which one only for sNaNs. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: move float*_eq and float*_eq_quietAurelien Jarno2-59/+58
I am not a big fan of code moving, but having the signaling version in the middle of quiet versions and vice versa doesn't make the code easy to read. This patch is a simple code move, basically swapping locations of float*_eq and float*_eq_quiet. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: rename float*_eq_signaling() into float*_eq()Aurelien Jarno3-11/+11
float*_eq_signaling functions have a different semantics than other comparison functions. Fix that by renaming float*_quiet_signaling() into float*_eq(). Note that it is purely mechanical, and the behaviour should be unchanged. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: rename float*_eq() into float*_eq_quiet()Aurelien Jarno3-11/+11
float*_eq functions have a different semantics than other comparison functions. Fix that by first renaming float*_quiet() into float*_eq_quiet(). Note that it is purely mechanical, and the behaviour should be unchanged. That said it clearly highlight problems due to this different semantics, they are fixed later in this patch series. Cc: Alexander Graf <agraf@suse.de> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat-native: add float*_unordered_quiet() functionsAurelien Jarno1-3/+12
Add float*_unordered_quiet() functions to march the softfloat versions. As FPU status is not tracked with softfloat-native, they don't differ from the signaling version. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: add float*_unordered_{,quiet}() functionsAurelien Jarno2-0/+175
Add float*_unordered() functions to softfloat, matching the softfloat-native ones. Also add float*_unordered_quiet() functions to match the others comparison functions. This allow target-i386/ops_sse.h to be compiled with softfloat. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-17softfloat: use GCC builtins to count the leading zerosAurelien Jarno1-2/+27
Softfloat has its own implementation to count the leading zeros. However a lot of architectures have either a dedicated instruction or an optimized to do that. When using GCC >= 3.4, this patch uses GCC builtins instead of the handcoded implementation. Note that I amware that QEMU_GNUC_PREREQ is defined in osdep.h and that clz32() and clz64() are defined in host-utils.h, but I think it is better to keep the softfloat implementation self contained. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-12softfloat: Add setter function for tininess detection modePeter Maydell1-0/+4
Add a setter function for the underflow tininess detection mode, in line with the similar functions for other parts of the float status structure. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-04-12unicore32: necessary modifications for other files to support unicore32Guan Xuetao2-6/+6
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-04-03softfloat: Add float*_min() and float*_max() functionsPeter Maydell2-0/+53
Add min and max operations to softfloat. This allows us to implement propagation of NaNs and handling of negative zero correctly (unlike the approach of having target helper routines return one of the operands based on the result of a comparison op). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-03-21softfloat: Drop [s]bits{8, 16, 32, 64} types in favor of [u]int{8, 16, 32, 64}_tAndreas Färber5-432/+417
They are defined with the same semantics as the POSIX types, so prefer those for consistency. Suggested by Peter Maydell. Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-03-21softfloat: Resolve type mismatches between declaration and implementationAndreas Färber1-34/+34
The original SoftFloat 2.0b library avoided the use of custom integer types in its public headers. This requires the definitions of int{8,16,32,64} to match the assumptions in the declarations. This breaks on BeOS R5 and Haiku/x86, where int32 is defined in {be,os}/support/SupportDefs.h in terms of a long rather than an int. Spotted by Michael Lotz. Since QEMU already breaks this distinction by defining those types just above, do use them for consistency and to allow #ifndef'ing them out as done for [u]int16 on AIX. Cc: Michael Lotz <mmlr@mlotz.ch> Cc: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>