/* Intel 387 floating point stuff.
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GDB.
struct frame_info *frame, const char *args)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
- gdb_byte buf[4];
ULONGEST fctrl;
ULONGEST fstat;
ULONGEST ftag;
break;
}
- get_frame_register (frame, (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep),
+ get_frame_register (frame,
+ (fpreg + 8 - top) % 8 + I387_ST0_REGNUM (tdep),
raw);
fputs_filtered ("0x", file);
needs any special handling. */
int
-i387_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type)
+i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
+ struct type *type)
{
if (i386_fp_regnum_p (gdbarch, regnum))
{
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
return its contents in TO. */
-void
+int
i387_register_to_value (struct frame_info *frame, int regnum,
- struct type *type, gdb_byte *to)
+ struct type *type, gdb_byte *to,
+ int *optimizedp, int *unavailablep)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte from[I386_MAX_REGISTER_SIZE];
{
warning (_("Cannot convert floating-point register value "
"to non-floating-point type."));
- return;
+ *optimizedp = *unavailablep = 0;
+ return 0;
}
/* Convert to TYPE. */
- get_frame_register (frame, regnum, from);
+ if (!get_frame_register_bytes (frame, regnum, 0, TYPE_LENGTH (type),
+ from, optimizedp, unavailablep))
+ return 0;
+
convert_typed_floating (from, i387_ext_type (gdbarch), to, type);
+ *optimizedp = *unavailablep = 0;
+ return 1;
}
/* Write the contents FROM of a value of type TYPE into register
if (val[0] & (1 << fpreg))
{
- int regnum = (fpreg + 8 - top) % 8
- + I387_ST0_REGNUM (tdep);
- tag = i387_tag (FXSAVE_ADDR (tdep, regs, regnum));
+ int thisreg = (fpreg + 8 - top) % 8
+ + I387_ST0_REGNUM (tdep);
+ tag = i387_tag (FXSAVE_ADDR (tdep, regs, thisreg));
}
else
tag = 3; /* Empty */
return;
case all:
- /* Hanle the upper YMM registers. */
+ /* Handle the upper YMM registers. */
if ((tdep->xcr0 & I386_XSTATE_AVX))
{
if ((clear_bv & I386_XSTATE_AVX))
if (val[0] & (1 << fpreg))
{
- int regnum = (fpreg + 8 - top) % 8
+ int thisreg = (fpreg + 8 - top) % 8
+ I387_ST0_REGNUM (tdep);
- tag = i387_tag (FXSAVE_ADDR (tdep, regs, regnum));
+ tag = i387_tag (FXSAVE_ADDR (tdep, regs, thisreg));
}
else
tag = 3; /* Empty */
gdb_byte raw[I386_MAX_REGISTER_SIZE];
gdb_byte *xstate_bv_p = XSAVE_XSTATE_BV_ADDR (regs);
unsigned int xstate_bv = 0;
- /* The supported bits in `xstat_bv' are 1 byte. */
+ /* The supported bits in `xstat_bv' are 1 byte. */
unsigned int clear_bv = (~(*xstate_bv_p)) & tdep->xcr0;
gdb_byte *p;
switch (regclass)
{
default:
- abort ();
-
- case avxh:
- /* This is an upper YMM register. */
- p = XSAVE_AVXH_ADDR (tdep, regs, regnum);
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= I386_XSTATE_AVX;
- memcpy (p, raw, 16);
- }
- break;
-
- case sse:
- /* This is an SSE register. */
- p = FXSAVE_ADDR (tdep, regs, regnum);
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= I386_XSTATE_SSE;
- memcpy (p, raw, 16);
- }
- break;
-
- case x87:
- /* This is an x87 register. */
- p = FXSAVE_ADDR (tdep, regs, regnum);
- if (memcmp (raw, p, 10))
- {
- xstate_bv |= I386_XSTATE_X87;
- memcpy (p, raw, 10);
- }
- break;
- }
- }
+ internal_error (__FILE__, __LINE__,
+ _("invalid i387 regclass"));
- /* Update the corresponding bits in `xstate_bv' if any SSE/AVX
- registers are changed. */
- if (xstate_bv)
- {
- /* The supported bits in `xstat_bv' are 1 byte. */
- *xstate_bv_p |= (gdb_byte) xstate_bv;
-
- switch (regclass)
+ case avxh:
+ /* This is an upper YMM register. */
+ p = XSAVE_AVXH_ADDR (tdep, regs, regnum);
+ if (memcmp (raw, p, 16))
{
- default:
- abort ();
+ xstate_bv |= I386_XSTATE_AVX;
+ memcpy (p, raw, 16);
+ }
+ break;
- case all:
- break;
+ case sse:
+ /* This is an SSE register. */
+ p = FXSAVE_ADDR (tdep, regs, regnum);
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= I386_XSTATE_SSE;
+ memcpy (p, raw, 16);
+ }
+ break;
- case x87:
- case sse:
- case avxh:
- /* Register REGNUM has been updated. Return. */
- return;
+ case x87:
+ /* This is an x87 register. */
+ p = FXSAVE_ADDR (tdep, regs, regnum);
+ if (memcmp (raw, p, 10))
+ {
+ xstate_bv |= I386_XSTATE_X87;
+ memcpy (p, raw, 10);
}
+ break;
}
- else
+ }
+
+ /* Update the corresponding bits in `xstate_bv' if any SSE/AVX
+ registers are changed. */
+ if (xstate_bv)
+ {
+ /* The supported bits in `xstat_bv' are 1 byte. */
+ *xstate_bv_p |= (gdb_byte) xstate_bv;
+
+ switch (regclass)
{
- /* Return if REGNUM isn't changed. */
- if (regclass != all)
- return;
+ default:
+ internal_error (__FILE__, __LINE__,
+ _("invalid i387 regclass"));
+
+ case all:
+ break;
+
+ case x87:
+ case sse:
+ case avxh:
+ /* Register REGNUM has been updated. Return. */
+ return;
}
+ }
+ else
+ {
+ /* Return if REGNUM isn't changed. */
+ if (regclass != all)
+ return;
+ }
}
/* Only handle x87 control registers. */
if (i == I387_FOP_REGNUM (tdep))
{
/* The opcode occupies only 11 bits. Make sure we
- don't touch the other bits. */
+ don't touch the other bits. */
buf[1] &= ((1 << 3) - 1);
buf[1] |= ((FXSAVE_ADDR (tdep, regs, i))[1] & ~((1 << 3) - 1));
}