Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: gdb-patches@sources.redhat.com
Subject: [RFA] cleanup alpha convert_to_{raw,virtual}
Date: Mon, 02 Jun 2003 05:04:00 -0000	[thread overview]
Message-ID: <20030602050453.GA7460@twiddle.net> (raw)

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");


             reply	other threads:[~2003-06-02  5:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-02  5:04 Richard Henderson [this message]
2003-06-02 18:36 ` Andrew Cagney
     [not found] ` <863cisa1ps.fsf@elgar.kettenis.dyndns.org>
2003-06-02 22:36   ` Richard Henderson

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=20030602050453.GA7460@twiddle.net \
    --to=rth@twiddle.net \
    --cc=gdb-patches@sources.redhat.com \
    /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