qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Antony T Curtis <antony.t.curtis@ntlworld.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Running QEMU on FreeBSD
Date: Mon, 31 May 2004 14:54:39 +0100	[thread overview]
Message-ID: <1086011679.347.75.camel@pcgem.rdg.cyberkinetica.com> (raw)
In-Reply-To: <40BA8D68.3070204@fabianowski.de>

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

On Mon, 2004-05-31 at 02:42, Bartosz Fabianowski wrote:
> This fixes the NaN, but reverts to what my hack did - weird rounding. 
> The total download size for some updates I selected is now reported as 
> 1.6000000000000003 (that's 14 zeros in between). Not quite sure what's 
> going wrong here...

Ok... I am curious if the following diff helps it (or makes it worse)
It is just a quick hack to use the native fpu instructions instead of
manual calculation...

-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-fpu.diff --]
[-- Type: text/x-patch, Size: 3205 bytes --]

--- /home/antony/cvs/qemu/target-i386/helper.c	Sat May 29 12:08:52 2004
+++ target-i386/helper.c	Mon May 31 15:40:13 2004
@@ -2105,7 +2105,12 @@
 
 void helper_f2xm1(void)
 {
+#ifdef USE_X86LDOUBLE
+    __asm __volatile__
+      ("f2xm1" : "=t" (ST0) : "0" (ST0));
+#else
     ST0 = pow(2.0,ST0) - 1.0;
+#endif
 }
 
 void helper_fyl2x(void)
@@ -2114,8 +2119,14 @@
     
     fptemp = ST0;
     if (fptemp>0.0){
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fyl2x"
+           : "=t" (ST1) : "0" (fptemp) , "u" (ST1));
+#else
         fptemp = log(fptemp)/log(2.0);	 /* log2(ST) */
         ST1 *= fptemp;
+#endif
         fpop();
     } else { 
         env->fpus &= (~0x4700);
@@ -2165,6 +2176,19 @@
 
 void helper_fprem1(void)
 {
+#ifdef USE_X86LDOUBLE
+    int flags;
+    __asm __volatile__
+      ("fprem1\n\t"
+       "fnstsw %%ax\n\t"
+       : "=t" (ST0), "=ax" (flags) : "0" (ST0) , "u" (ST1));
+    if (flags & 0x400) 
+        env->fpus |= 0x400;
+    else {
+        env->fpus &= (~0x4700);
+        env->fpus |= flags & 0x07;
+    }
+#else
     CPU86_LDouble dblq, fpsrcop, fptemp;
     CPU86_LDoubleU fpsrcop1, fptemp1;
     int expdif;
@@ -2194,10 +2218,24 @@
             floor(fpsrcop): ceil(fpsrcop);
         ST0 -= (ST1 * fpsrcop * fptemp);
     }
+#endif
 }
 
 void helper_fprem(void)
 {
+#ifdef USE_X86LDOUBLE
+    int flags;
+    __asm __volatile__
+      ("fprem\n\t"
+       "fnstsw %%ax\n\t"
+       : "=t" (ST0), "=ax" (flags) : "0" (ST0) , "u" (ST1));
+    if (flags & 0x400) 
+        env->fpus |= 0x400;
+    else {
+        env->fpus &= (~0x4700);
+        env->fpus |= flags & 0x07;
+    }
+#else
     CPU86_LDouble dblq, fpsrcop, fptemp;
     CPU86_LDoubleU fpsrcop1, fptemp1;
     int expdif;
@@ -2205,6 +2243,7 @@
     
     fpsrcop = ST0;
     fptemp = ST1;
+
     fpsrcop1.d = fpsrcop;
     fptemp1.d = fptemp;
     expdif = EXPD(fpsrcop1) - EXPD(fptemp1);
@@ -2227,6 +2266,7 @@
             -(floor(fabs(fpsrcop))): floor(fpsrcop);
         ST0 -= (ST1 * fpsrcop * fptemp);
     }
+#endif
 }
 
 void helper_fyl2xp1(void)
@@ -2235,8 +2275,13 @@
 
     fptemp = ST0;
     if ((fptemp+1.0)>0.0) {
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fyl2xp1" : "=t" (ST1) : "0" (fptemp) , "u" (ST1));
+#else
         fptemp = log(fptemp+1.0) / log(2.0); /* log2(ST+1.0) */
         ST1 *= fptemp;
+#endif
         fpop();
     } else { 
         env->fpus &= (~0x4700);
@@ -2264,11 +2309,17 @@
     if ((fptemp > MAXTAN)||(fptemp < -MAXTAN)) {
         env->fpus |= 0x400;
     } else {
+#ifdef USE_X86LDOUBLE
+        __asm __volatile__
+          ("fsincos" 
+           : "=t" (ST0) , "=u" (ST1) : "0" (ST0));
+#else
         ST0 = sin(fptemp);
         fpush();
         ST0 = cos(fptemp);
         env->fpus &= (~0x400);  /* C2 <-- 0 */
         /* the above code is for  |arg| < 2**63 only */
+#endif
     }
 }
 
@@ -2301,11 +2352,18 @@
 
 void helper_fscale(void)
 {
+#ifdef USE_X86LDOUBLE
+    __asm __volatile__
+      ("fscale" 
+       : "=t" (ST0) : "0" (ST0), "u" (ST1));
+#else
     CPU86_LDouble fpsrcop, fptemp;
 
     fpsrcop = 2.0;
     fptemp = pow(fpsrcop,ST1);
     ST0 *= fptemp;
+#endif
+
 }
 
 void helper_fsin(void)

  parent reply	other threads:[~2004-05-31 13:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-29 21:25 [Qemu-devel] Running QEMU on FreeBSD Antony T Curtis
2004-05-29 21:39 ` Bartosz Fabianowski
2004-05-29 21:50   ` Antony T Curtis
2004-05-29 21:58     ` Bartosz Fabianowski
2004-05-29 22:09       ` Antony T Curtis
2004-05-29 22:24         ` Bartosz Fabianowski
2004-05-29 23:09           ` Antony T Curtis
2004-05-30  3:53             ` Antony T Curtis
2004-05-30  7:25             ` Markus Niemistö
2004-05-30  9:50               ` Antony T Curtis
2004-05-30 14:41                 ` Bartosz Fabianowski
2004-05-30 17:27                   ` Antony T Curtis
2004-05-30 18:57                     ` Bartosz Fabianowski
2004-05-30 20:09                       ` Antony T Curtis
2004-05-31  0:36                         ` Bartosz Fabianowski
2004-05-31  1:24                           ` Antony T Curtis
2004-05-31  1:42                             ` Bartosz Fabianowski
2004-05-31  1:59                               ` Kyle Hayes
2004-05-31 12:15                                 ` Bartosz Fabianowski
2004-05-31 13:22                                   ` Antony T Curtis
2004-05-31  9:38                               ` Antony T Curtis
2004-05-31 20:36                                 ` Bartosz Fabianowski
2004-05-31 13:54                               ` Antony T Curtis [this message]
2004-05-31 20:31                                 ` Bartosz Fabianowski
2004-05-31 22:15                                   ` Antony T Curtis
2004-05-31 22:56                               ` Brion Vibber
2004-05-31 23:01                                 ` Bartosz Fabianowski
2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
2004-06-03 17:10                                 ` Gianni Tedesco
2004-06-04 18:44                                 ` Juergen Lock
2004-06-05 21:04                               ` [Qemu-devel] FreeSBIE timer (was: Re: qemu port) Juergen Lock

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=1086011679.347.75.camel@pcgem.rdg.cyberkinetica.com \
    --to=antony.t.curtis@ntlworld.com \
    --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).