Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: Elena Zannoni <ezannoni@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [RFA] rs6000-tdep.c: pseudoregs infrastructure
Date: Mon, 19 Aug 2002 11:06:00 -0000	[thread overview]
Message-ID: <1020819180645.ZM21013@localhost.localdomain> (raw)
In-Reply-To: Elena Zannoni <ezannoni@redhat.com> "[RFA] rs6000-tdep.c: pseudoregs infrastructure" (Aug 18,  1:40pm)

On Aug 18,  1:40pm, Elena Zannoni wrote:

> The only thing I am not sure is whether it wouldn't be better to add
> initialization values for the new fields added, instead of letting
> them deafult to 0. I think the code would be probably easier to
> maintain if I just added explicit zero's for those fields. yes? no?

Yes, I agree that maintenance will be easier if you add explicit
zeros to the non-pseudo-register initializer macros.

Now for some nits...

> @@ -2318,10 +2322,38 @@ struct variant
>      /* Table of register names; registers[R] is the name of the register
>         number R.  */
>      int nregs;
> +    int npregs;
> +    int num_tot_regs;
>      const struct reg *regs;
>    };

Could you add comments describing these new fields?  (I'd appreciate
it too if you'd add a comment for nregs and move the comment
immediately above the nregs declaration to the correct place.)

> +int
> +num_registers(const struct reg *reg_list, int num_tot_regs)
> +{
> +  int i;
> +  int nregs = num_tot_regs;
> +
> +  for (i = 0; i < num_tot_regs; i++)
> +    if (reg_list[i].pseudo == 1)
> +      nregs--;
> +       
> +  return nregs;
> +}

The ``pseudo'' field is intended to be a boolean, right?  If so,
I think it'd be less surprising to see:

       if (reg_list[i].pseudo)

instead of:

       if (reg_list[i].pseudo == 1)

When I see the ``== 1'', I'm left wondering what other values this
field might take on.

The other thing that I found surprising about the above is that
you're counting down instead of up.  We should get the same result
if we do the following instead, right? :

     int i;
     int nregs = 0;
    
     for (i = 0; i < num_tot_regs; i++)
       if (!reg_list[i].pseudo)
         nregs++;
          
     return nregs;

Structuring the code to count up instead of down will also cause it to
more closely resemble your definition of num_pseudo_registers().  In
fact, they'll be identical except for the ``reg_list[i].psuedo'' test.

....

The rest is okay.  Feel free to commit this patch after adding the 0's
to the struct reg initializer macros and adding comments to
``struct variant''.

If you agree with my comments regarding num_registers(), then consider
changing it as I suggested.  Otherwise, leave it alone.  (I didn't
find it *that* hard to understand, but I spent slightly longer looking
at it than I might have otherwise.)

Thanks,

Kevin


  reply	other threads:[~2002-08-19 18:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-18 10:42 Elena Zannoni
2002-08-19 11:06 ` Kevin Buettner [this message]
2002-08-19 16:22   ` Elena Zannoni

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=1020819180645.ZM21013@localhost.localdomain \
    --to=kevinb@redhat.com \
    --cc=ezannoni@redhat.com \
    --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