From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH v2 17/20] target-i386: fix logarithmic and trigonometric helpers wrt softfloat
Date: Wed, 20 Apr 2011 12:12:06 +0200 [thread overview]
Message-ID: <1303294329-22634-18-git-send-email-aurelien@aurel32.net> (raw)
In-Reply-To: <1303294329-22634-1-git-send-email-aurelien@aurel32.net>
Use the new CPU86_LDouble <-> double conversion functions to make logarithmic
and trigonometric helpers working with softfloat.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
target-i386/op_helper.c | 52 +++++++++++++++++++++++-----------------------
1 files changed, 26 insertions(+), 26 deletions(-)
v1 -> v2: use floatx_one instead of double_to_CPU86_LDouble(1.0)
diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index d9c8c1b..f18c573 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <math.h>
#include "exec.h"
#include "exec-all.h"
#include "host-utils.h"
@@ -3981,17 +3982,19 @@ void helper_fbst_ST0(target_ulong ptr)
void helper_f2xm1(void)
{
- ST0 = pow(2.0,ST0) - 1.0;
+ double val = CPU86_LDouble_to_double(ST0);
+ val = pow(2.0, val) - 1.0;
+ ST0 = double_to_CPU86_LDouble(val);
}
void helper_fyl2x(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if (fptemp>0.0){
- fptemp = log(fptemp)/log(2.0); /* log2(ST) */
- ST1 *= fptemp;
+ fptemp = log(fptemp)/log(2.0); /* log2(ST) */
+ fptemp *= CPU86_LDouble_to_double(ST1);
+ ST1 = double_to_CPU86_LDouble(fptemp);
fpop();
} else {
env->fpus &= (~0x4700);
@@ -4001,15 +4004,15 @@ void helper_fyl2x(void)
void helper_fptan(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
env->fpus |= 0x400;
} else {
- ST0 = tan(fptemp);
+ fptemp = tan(fptemp);
+ ST0 = double_to_CPU86_LDouble(fptemp);
fpush();
- ST0 = 1.0;
+ ST0 = floatx_one;
env->fpus &= (~0x400); /* C2 <-- 0 */
/* the above code is for |arg| < 2**52 only */
}
@@ -4017,11 +4020,11 @@ void helper_fptan(void)
void helper_fpatan(void)
{
- CPU86_LDouble fptemp, fpsrcop;
+ double fptemp, fpsrcop;
- fpsrcop = ST1;
- fptemp = ST0;
- ST1 = atan2(fpsrcop,fptemp);
+ fpsrcop = CPU86_LDouble_to_double(ST1);
+ fptemp = CPU86_LDouble_to_double(ST0);
+ ST1 = double_to_CPU86_LDouble(atan2(fpsrcop, fptemp));
fpop();
}
@@ -4159,12 +4162,12 @@ void helper_fprem(void)
void helper_fyl2xp1(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if ((fptemp+1.0)>0.0) {
fptemp = log(fptemp+1.0) / log(2.0); /* log2(ST+1.0) */
- ST1 *= fptemp;
+ fptemp *= CPU86_LDouble_to_double(ST1);
+ ST1 = double_to_CPU86_LDouble(fptemp);
fpop();
} else {
env->fpus &= (~0x4700);
@@ -4183,15 +4186,14 @@ void helper_fsqrt(void)
void helper_fsincos(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if ((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
env->fpus |= 0x400;
} else {
- ST0 = sin(fptemp);
+ ST0 = double_to_CPU86_LDouble(sin(fptemp));
fpush();
- ST0 = cos(fptemp);
+ ST0 = double_to_CPU86_LDouble(cos(fptemp));
env->fpus &= (~0x400); /* C2 <-- 0 */
/* the above code is for |arg| < 2**63 only */
}
@@ -4214,13 +4216,12 @@ void helper_fscale(void)
void helper_fsin(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if ((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
env->fpus |= 0x400;
} else {
- ST0 = sin(fptemp);
+ ST0 = double_to_CPU86_LDouble(sin(fptemp));
env->fpus &= (~0x400); /* C2 <-- 0 */
/* the above code is for |arg| < 2**53 only */
}
@@ -4228,13 +4229,12 @@ void helper_fsin(void)
void helper_fcos(void)
{
- CPU86_LDouble fptemp;
+ double fptemp = CPU86_LDouble_to_double(ST0);
- fptemp = ST0;
if((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
env->fpus |= 0x400;
} else {
- ST0 = cos(fptemp);
+ ST0 = double_to_CPU86_LDouble(cos(fptemp));
env->fpus &= (~0x400); /* C2 <-- 0 */
/* the above code is for |arg5 < 2**63 only */
}
--
1.7.2.3
next prev parent reply other threads:[~2011-04-20 10:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 10:11 [Qemu-devel] [PATCH v2 00/20] *** SUBJECT HERE *** Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 01/20] softfloat: fix floatx80 handling of NaN Aurelien Jarno
2011-04-20 10:35 ` Peter Maydell
2011-04-20 11:24 ` [Qemu-devel] [PATCH v3 " Aurelien Jarno
2011-04-20 11:28 ` Peter Maydell
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 02/20] softfloat: fix floatx80_is_infinity() Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 03/20] softfloat: add floatx80 constants Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 04/20] softfloat: add pi constants Aurelien Jarno
2011-04-20 10:40 ` Peter Maydell
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 05/20] softfloat-native: add a few constant values Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 06/20] softfloat: add floatx80_compare*() functions Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 07/20] softfloat: fix float*_scalnb() corner cases Aurelien Jarno
2011-04-20 10:40 ` Peter Maydell
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 08/20] softfloat-native: fix float*_scalbn() functions Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 09/20] softfloat-native: add float*_is_any_nan() functions Aurelien Jarno
2011-04-20 10:11 ` [Qemu-devel] [PATCH v2 10/20] target-i386: fix helper_fscale() wrt softfloat Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 11/20] target-i386: fix helper_fbld_ST0() " Aurelien Jarno
2011-04-20 10:41 ` Peter Maydell
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 12/20] target-i386: fix helper_fxtract() " Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 13/20] target-i386: fix helper_fdiv() " Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 14/20] target-i386: fix helper_fsqrt() " Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 15/20] target-i386: replace approx_rsqrt and approx_rcp by softfloat ops Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 16/20] target-i386: add CPU86_LDouble <-> double conversion functions Aurelien Jarno
2011-04-20 10:12 ` Aurelien Jarno [this message]
2011-04-20 10:41 ` [Qemu-devel] [PATCH v2 17/20] target-i386: fix logarithmic and trigonometric helpers wrt softfloat Peter Maydell
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 18/20] target-i386: fix helper_fprem() and helper_fprem1() " Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 19/20] target-i386: fix constants " Aurelien Jarno
2011-04-20 10:12 ` [Qemu-devel] [PATCH v2 20/20] target-i386: switch to softfloat Aurelien Jarno
2011-04-20 10:42 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303294329-22634-18-git-send-email-aurelien@aurel32.net \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).