[RFA] cleanup alpha convert_to_{raw,virtual}

Richard Henderson
2003-06-02T05:04:54Z

Ok?

r~

* alpha-tdep.c (alpha_register_convert_to_virtual): Tidy use of
deprecated interfaces; use ALPHA_REGISTER_SIZE instead of gdbarch
macros where appropriate.
(alpha_register_convert_to_raw): Similarly. Use unpack_long.
(alpha_convert_flt_dbl, alpha_convert_dbl_flt): New.

*** alpha-tdep.c.1 Sun Jun 1 21:40:43 2003
--- alpha-tdep.c Sun Jun 1 21:51:35 2003
*************** alpha_register_virtual_size (int regno)
*** 160,183 ****
registers is different. */

static void
alpha_register_convert_to_virtual (int regnum, struct type *valtype,
char *raw_buffer, char *virtual_buffer)
{
! if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
{
! memcpy (virtual_buffer, raw_buffer, REGISTER_VIRTUAL_SIZE (regnum));
return;
}

if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
! {
! double d = deprecated_extract_floating (raw_buffer, REGISTER_RAW_SIZE (regnum));
! deprecated_store_floating (virtual_buffer, TYPE_LENGTH (valtype), d);
! }
! else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
{
ULONGEST l;
! l = extract_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum));
l = ((l >> 32) & 0xc0000000) | ((l >> 29) & 0x3fffffff);
store_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype), l);
}
--- 160,196 ----
registers is different. */

static void
+ alpha_convert_flt_dbl (void *out, const void *in)
+ {
+ DOUBLEST d = extract_typed_floating (in, builtin_type_ieee_single_little);
+ store_typed_floating (out, builtin_type_ieee_double_little, d);
+ }
+
+ static void
+ alpha_convert_dbl_flt (void *out, const void *in)
+ {
+ DOUBLEST d = extract_typed_floating (in, builtin_type_ieee_double_little);
+ store_typed_floating (out, builtin_type_ieee_single_little, d);
+ }
+
+ static void
alpha_register_convert_to_virtual (int regnum, struct type *valtype,
char *raw_buffer, char *virtual_buffer)
{
! if (TYPE_LENGTH (valtype) >= ALPHA_REGISTER_SIZE)
{
! memcpy (virtual_buffer, raw_buffer, ALPHA_REGISTER_SIZE);
return;
}

+ /* Note that everything below is less than 8 bytes long. */
+
if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
! alpha_convert_dbl_flt (virtual_buffer, raw_buffer);
! else if (TYPE_CODE (valtype) == TYPE_CODE_INT)
{
ULONGEST l;
! l = extract_unsigned_integer (raw_buffer, ALPHA_REGISTER_SIZE);
l = ((l >> 32) & 0xc0000000) | ((l >> 29) & 0x3fffffff);
store_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype), l);
}
*************** static void
*** 189,214 ****
alpha_register_convert_to_raw (struct type *valtype, int regnum,
char *virtual_buffer, char *raw_buffer)
{
! if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum))
{
! memcpy (raw_buffer, virtual_buffer, REGISTER_RAW_SIZE (regnum));
return;
}

if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
{
! double d = deprecated_extract_floating (virtual_buffer, TYPE_LENGTH (valtype));
! deprecated_store_floating (raw_buffer, REGISTER_RAW_SIZE (regnum), d);
! }
! else if (TYPE_CODE (valtype) == TYPE_CODE_INT && TYPE_LENGTH (valtype) <= 4)
! {
! ULONGEST l;
! if (TYPE_UNSIGNED (valtype))
! l = extract_unsigned_integer (virtual_buffer, TYPE_LENGTH (valtype));
! else
! l = extract_signed_integer (virtual_buffer, TYPE_LENGTH (valtype));
l = ((l & 0xc0000000) << 32) | ((l & 0x3fffffff) << 29);
! store_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (regnum), l);
}
else
error ("Cannot store value in floating point register");
--- 202,222 ----
alpha_register_convert_to_raw (struct type *valtype, int regnum,
char *virtual_buffer, char *raw_buffer)
{
! if (TYPE_LENGTH (valtype) >= ALPHA_REGISTER_SIZE)
{
! memcpy (raw_buffer, virtual_buffer, ALPHA_REGISTER_SIZE);
return;
}

+ /* Note that everything below is less than 8 bytes long. */
+
if (TYPE_CODE (valtype) == TYPE_CODE_FLT)
+ alpha_convert_flt_dbl (raw_buffer, virtual_buffer);
+ else if (TYPE_CODE (valtype) == TYPE_CODE_INT)
{
! ULONGEST l = unpack_long (valtype, virtual_buffer);
l = ((l & 0xc0000000) << 32) | ((l & 0x3fffffff) << 29);
! store_unsigned_integer (raw_buffer, ALPHA_REGISTER_SIZE, l);
}
else
error ("Cannot store value in floating point register");