2003-04-13 Michael Snyder <msnyder@redhat.com>
[binutils-gdb.git] / gdb / i387-tdep.c
index e465690b823279a1cfd159da84777efc6eddd3ff..c6a2d5dac84961f246cae9123867c70b68c7a31d 100644 (file)
@@ -1,6 +1,7 @@
 /* Intel 387 floating point stuff.
+
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1998, 1999, 2000,
-   2001, 2002 Free Software Foundation, Inc.
+   2001, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 #include "i386-tdep.h"
 
-/* FIXME: Eliminate the next two functions when we have the time to
-   change all the callers.  */
-
-void i387_to_double (char *from, char *to);
-void double_to_i387 (char *from, char *to);
-
-void
-i387_to_double (char *from, char *to)
-{
-  floatformat_to_double (&floatformat_i387_ext, from, (double *) to);
-}
-
-void
-double_to_i387 (char *from, char *to)
-{
-  floatformat_from_double (&floatformat_i387_ext, (double *) from, to);
-}
-
 \f
 /* FIXME: The functions on this page are used by the old `info float'
    implementations that a few of the i386 targets provide.  These
@@ -388,7 +371,7 @@ i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
       fputs_filtered ("\n", file);
     }
 
-  puts_filtered ("\n");
+  fputs_filtered ("\n", file);
 
   print_i387_status_word (fstat, file);
   print_i387_control_word (fctrl, file);
@@ -444,6 +427,12 @@ static int fsave_offset[] =
 void
 i387_supply_register (int regnum, char *fsave)
 {
+  if (fsave == NULL)
+    {
+      supply_register (regnum, NULL);
+      return;
+    }
+
   /* Most of the FPU control registers occupy only 16 bits in
      the fsave area.  Give those a special treatment.  */
   if (regnum >= FPC_REGNUM
@@ -533,19 +522,34 @@ static int fxsave_offset[] =
   20,                          /* FOSEG_REGNUM (16 bits).  */
   16,                          /* FOOFF_REGNUM.  */
   6,                           /* FOP_REGNUM (bottom 11 bits).  */
-  160,                         /* XMM0_REGNUM through ...  */
-  176,
-  192,
-  208,
-  224,
-  240,
-  256,
-  272,                         /* ... XMM7_REGNUM (128 bits each).  */
-  24,                          /* MXCSR_REGNUM.  */
+  160 + 0 * 16,                        /* XMM0_REGNUM through ...  */
+  160 + 1 * 16,
+  160 + 2 * 16,
+  160 + 3 * 16,
+  160 + 4 * 16,
+  160 + 5 * 16,
+  160 + 6 * 16,
+  160 + 7 * 16,
+  160 + 8 * 16,
+  160 + 9 * 16,
+  160 + 10 * 16,
+  160 + 11 * 16,
+  160 + 12 * 16,
+  160 + 13 * 16,
+  160 + 14 * 16,
+  160 + 15 * 16,               /* ... XMM15_REGNUM (128 bits each).  */
+  24                           /* MXCSR_REGNUM.  */
 };
 
+/* FIXME: kettenis/20030430: We made an unfortunate choice in putting
+   %mxcsr after the SSE registers %xmm0-%xmm7 instead of before, since
+   it makes supporting the registers %xmm8-%xmm15 on x86-64 a bit
+   involved.  Hack around it by explicitly overriding the offset for
+   %mxcsr here.  */
+
 #define FXSAVE_ADDR(fxsave, regnum) \
-  (fxsave + fxsave_offset[regnum - FP0_REGNUM])
+  ((regnum == MXCSR_REGNUM) ? (fxsave + 24) : \
+   (fxsave + fxsave_offset[regnum - FP0_REGNUM]))
 
 static int i387_tag (unsigned char *raw);
 \f
@@ -564,6 +568,12 @@ i387_supply_fxsave (char *fxsave)
 
   for (i = FP0_REGNUM; i <= last_regnum; i++)
     {
+      if (fxsave == NULL)
+       {
+         supply_register (i, NULL);
+         continue;
+       }
+
       /* Most of the FPU control registers occupy only 16 bits in
         the fxsave area.  Give those a special treatment.  */
       if (i >= FPC_REGNUM && i < XMM0_REGNUM
@@ -630,7 +640,7 @@ i387_fill_fxsave (char *fxsave, int regnum)
        /* Most of the FPU control registers occupy only 16 bits in
            the fxsave area.  Give those a special treatment.  */
        if (i >= FPC_REGNUM && i < XMM0_REGNUM
-           && i != FIOFF_REGNUM && i != FDOFF_REGNUM)
+           && i != FIOFF_REGNUM && i != FOOFF_REGNUM)
          {
            unsigned char buf[4];