public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: 李江帅 <jiangshuai_li@c-sky.com>
Cc: "Tom Tromey" <tom@tromey.com>,  gdb-patches <gdb-patches@sourceware.org>
Subject: Re: Re:[PATCH] gdb/csky complete csky_dwarf_reg_to_regnum
Date: Mon, 18 Jul 2022 10:16:11 -0600	[thread overview]
Message-ID: <87r12il7lg.fsf@tromey.com> (raw)
In-Reply-To: <772531f3-b91d-48e7-8ec4-3587600d97db.jiangshuai_li@c-sky.com> (" =?utf-8?B?5p2O5rGf5biFIidz?= message of "Mon, 18 Jul 2022 10:50:22 +0800")

>>> +  if (dw_reg >= CSKY_R0_REGNUM && dw_reg <= (CSKY_R0_REGNUM + 31))
>> 
>> This line and some others have too many parentheses.

> This line meens that "if (dw_reg >=0 && dw_reg <= 31)". As i does not define CSKY_R31_REGNUM,
> i wrote 31 as (CSKY_R0_REGNUM + 31).

Yeah, what I mean is that there doesn't seem to be a need for the parens
in the second comparison.  This sort of thing is more the gdb style:

  if (dw_reg >= CSKY_R0_REGNUM && dw_reg <= CSKY_R0_REGNUM + 31)

There are other cases like this:

>>> +  /* For Float and Vector pseudo registers.  */
>>> +  if ((dw_reg >= FV_PSEUDO_REGNO_FIRST)  && (dw_reg <= FV_PSEUDO_REGNO_LAST))

... where there are excessive parens.

>>> +      xsnprintf (name_buf, sizeof (name_buf), "s%d",
>>> +                 dw_reg - FV_PSEUDO_REGNO_FIRST);
>>> +      return user_reg_map_name_to_regnum (gdbarch, name_buf,
>>> +                                          strlen (name_buf));
>> 
>> This seems like a very roundabout approach.  Is there a reason it's done
>> this way?

> I am not sure what you mean, this code mean that:
> if (dw_reg >= 74 && dw_reg <= 201),  dw_reg will corresponds to a pseudo register
> added for float or vector registers.

> Similar code: arm-tdep.c: 4876

What I mean here is that this code looks up the register by name to get
its number.  But why is this extra step needed?  It's fine if it's
needed, but I'd like to understand why.

Tom

      reply	other threads:[~2022-07-18 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18  2:50 李江帅
2022-07-18 16:16 ` Tom Tromey [this message]

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=87r12il7lg.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jiangshuai_li@c-sky.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).