* i387-tdep.c: Remove excessive whitespace.
[deliverable/binutils-gdb.git] / gdb / i387-tdep.c
index 63943e7b2d76e1ef102aeb435567646220010d0d..0e60a13968b242396c81a885d8581ec7809f6ca8 100644 (file)
@@ -1,7 +1,7 @@
 /* Intel 387 floating point stuff.
 
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1998, 1999, 2000,
-   2001, 2002, 2003 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -340,7 +340,6 @@ i387_value_to_register (struct frame_info *frame, int regnum,
   put_frame_register (frame, regnum, to);
 }
 \f
-\f
 
 /* Handle FSAVE and FXSAVE formats.  */
 
@@ -378,15 +377,14 @@ static int fsave_offset[] =
   (fsave + fsave_offset[regnum - I387_ST0_REGNUM])
 \f
 
-/* Fill register REGNUM in GDB's register cache with the appropriate
-   value from *FSAVE.  This function masks off any of the reserved
-   bits in *FSAVE.  */
+/* Fill register REGNUM in REGCACHE with the appropriate value from
+   *FSAVE.  This function masks off any of the reserved bits in
+   *FSAVE.  */
 
 void
-i387_supply_fsave (const void *fsave, int regnum)
+i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
 {
-  struct regcache *regcache = current_regcache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
   const char *regs = fsave;
   int i;
 
@@ -425,14 +423,13 @@ i387_supply_fsave (const void *fsave, int regnum)
 }
 
 /* Fill register REGNUM (if it is a floating-point register) in *FSAVE
-   with the value in GDB's register cache.  If REGNUM is -1, do this
-   for all registers.  This function doesn't touch any of the reserved
-   bits in *FSAVE.  */
+   with the value from REGCACHE.  If REGNUM is -1, do this for all
+   registers.  This function doesn't touch any of the reserved bits in
+   *FSAVE.  */
 
 void
-i387_fill_fsave (void *fsave, int regnum)
+i387_collect_fsave (const struct regcache *regcache, int regnum, void *fsave)
 {
-  struct regcache *regcache = current_regcache;
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   char *regs = fsave;
   int i;
@@ -469,6 +466,17 @@ i387_fill_fsave (void *fsave, int regnum)
       }
 #undef I387_ST0_REGNUM
 }
+
+/* Fill register REGNUM (if it is a floating-point register) in *FSAVE
+   with the value in GDB's register cache.  If REGNUM is -1, do this
+   for all registers.  This function doesn't touch any of the reserved
+   bits in *FSAVE.  */
+
+void
+i387_fill_fsave (void *fsave, int regnum)
+{
+  i387_collect_fsave (current_regcache, regnum, fsave);
+}
 \f
 
 /* At fxsave_offset[REGNUM] you'll find the offset to the location in
@@ -524,15 +532,14 @@ static int fxsave_offset[] =
 static int i387_tag (const unsigned char *raw);
 \f
 
-/* Fill register REGNUM in GDB's register cache with the appropriate
+/* Fill register REGNUM in REGCACHE with the appropriate
    floating-point or SSE register value from *FXSAVE.  This function
    masks off any of the reserved bits in *FXSAVE.  */
 
 void
-i387_supply_fxsave (const void *fxsave, int regnum)
+i387_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave)
 {
-  struct regcache *regcache = current_regcache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
   const char *regs = fxsave;
   int i;
 
@@ -615,14 +622,13 @@ i387_supply_fxsave (const void *fxsave, int regnum)
 }
 
 /* Fill register REGNUM (if it is a floating-point or SSE register) in
-   *FXSAVE with the value in GDB's register cache.  If REGNUM is -1, do
-   this for all registers.  This function doesn't touch any of the
-   reserved bits in *FXSAVE.  */
+   *FXSAVE with the value from REGCACHE.  If REGNUM is -1, do this for
+   all registers.  This function doesn't touch any of the reserved
+   bits in *FXSAVE.  */
 
 void
-i387_fill_fxsave (void *fxsave, int regnum)
+i387_collect_fxsave (const struct regcache *regcache, int regnum, void *fxsave)
 {
-  struct regcache *regcache = current_regcache;
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   char *regs = fxsave;
   int i;
@@ -688,6 +694,17 @@ i387_fill_fxsave (void *fxsave, int regnum)
 #undef I387_NUM_XMM_REGS
 }
 
+/* Fill register REGNUM (if it is a floating-point or SSE register) in
+   *FXSAVE with the value in GDB's register cache.  If REGNUM is -1, do
+   this for all registers.  This function doesn't touch any of the
+   reserved bits in *FXSAVE.  */
+
+void
+i387_fill_fxsave (void *fxsave, int regnum)
+{
+  i387_collect_fxsave (current_regcache, regnum, fxsave);
+}
+
 /* Recreate the FTW (tag word) valid bits from the 80-bit FP data in
    *RAW.  */
 
@@ -736,3 +753,31 @@ i387_tag (const unsigned char *raw)
        }
     }
 }
+
+/* Prepare the FPU stack in REGCACHE for a function return.  */
+
+void
+i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  ULONGEST fstat;
+
+  /* Define I387_ST0_REGNUM such that we use the proper
+     definitions for the architecture.  */
+#define I387_ST0_REGNUM tdep->st0_regnum
+
+  /* Set the top of the floating-point register stack to 7.  The
+     actual value doesn't really matter, but 7 is what a normal
+     function return would end up with if the program started out with
+     a freshly initialized FPU.  */
+  regcache_raw_read_unsigned (regcache, I387_FSTAT_REGNUM, &fstat);
+  fstat |= (7 << 11);
+  regcache_raw_write_unsigned (regcache, I387_FSTAT_REGNUM, fstat);
+
+  /* Mark %st(1) through %st(7) as empty.  Since we set the top of the
+     floating-point register stack to 7, the appropriate value for the
+     tag word is 0x3fff.  */
+  regcache_raw_write_unsigned (regcache, I387_FTAG_REGNUM, 0x3fff);
+
+#undef I387_ST0_REGNUM
+}
This page took 0.025826 seconds and 4 git commands to generate.