From: Omair Javaid <omair.javaid@linaro.org>
To: Andreas Arnez <arnez@linux.vnet.ibm.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Yao Qi <yao@codesourcery.com>, Mark Kettenis <kettenis@gnu.org>
Subject: Re: [PATCH v2 02/13] regcache: Add functions suitable for regset_supply/collect.
Date: Tue, 08 Jul 2014 19:09:00 -0000 [thread overview]
Message-ID: <CANW4E-3S6+JApYt=uNiznJQOxDU=B54zXVyf0L0N2JuLpJKrMQ@mail.gmail.com> (raw)
In-Reply-To: <87lhs4f5ng.fsf@br87z6lw.de.ibm.com>
On 8 July 2014 16:31, Andreas Arnez <arnez@linux.vnet.ibm.com> wrote:
> On Mon, Jul 07 2014, Omair Javaid wrote:
>
>> Is there a way around avoiding the loop in supply/collect where regnum
>> != -1? It should be more efficient in cases where we are looking for a
>> register with regnum > 0.
>
> Good question. The most straightforward way would be a register map
> format where regnum is used as an index into an array of offsets, like
> this:
>
> int s390_regmap_gregset[S390_NUM_REGS] =
> {
> /* Program Status Word. */
> 0x00, 0x04,
> /* General Purpose Registers. */
> 0x08, 0x0c, 0x10, 0x14,
> 0x18, 0x1c, 0x20, 0x24,
> 0x28, 0x2c, 0x30, 0x34,
> 0x38, 0x3c, 0x40, 0x44,
> /* Access Registers. */
> 0x48, 0x4c, 0x50, 0x54,
> 0x58, 0x5c, 0x60, 0x64,
> 0x68, 0x6c, 0x70, 0x74,
> 0x78, 0x7c, 0x80, 0x84,
> /* Floating Point Control Word. */
> -1,
> /* Floating Point Registers. */
> -1, -1, -1, -1, -1, -1, -1, -1,
> -1, -1, -1, -1, -1, -1, -1, -1,
> /* GPR Uppper Halves. */
> -1, -1, -1, -1, -1, -1, -1, -1,
> -1, -1, -1, -1, -1, -1, -1, -1,
> /* GNU/Linux-specific optional "registers". */
> 0x88, -1, -1,
> };
>
> This is a real example. For the full example refer to:
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/s390-tdep.c;h=72d55450225e89da4394079efac1fa33b36cb68c;hb=d91fab15e7eb04f6c9b7fee5859d8815b7aa84ee#l412
>
> As you see, this is where the s390 implementation came from. Then I
> realized that regnum > 0 is a very rare case, and that the common case
> was suboptimal with this format, because the supply/collect functions
> had to iterate over *all* registers, not just those of a specific
> regset.
>
> Patch #3 in this series expresses the regmap from above like this:
>
> static const struct regcache_map_entry s390_gregmap[] =
> {
> { 1, S390_PSWM_REGNUM },
> { 1, S390_PSWA_REGNUM },
> { 16, S390_R0_REGNUM },
> { 16, S390_A0_REGNUM },
> { 1, S390_ORIG_R2_REGNUM },
> { 0 }
> };
>
> In addition to being more efficient in the common case, I also consider
> this version much easier to read and maintain.
>
> We could certainly spend more effort on supplying and collecting a
> single register more efficiently. For instance, we could offer
> additional routines for that special case, perhaps in conjunction with a
> preparation function that converts a regmap to an indexed-by-regnum
> array. However, I wouldn't focus on that too much before actually
> making use of it. Note that currently these functions are *always*
> called with regnum == -1.
>
> In fact, it may be more adequate to completely get rid of the parameter
> regnum in the regset supply/collect functions. Any reason why we
> shouldn't?
I think you are right its better off if we leave the single register
variants to target specific *-tdep where they can be retrieved using
regcache_raw_ supply/collect functions. All other options to get
around the loops wont be trivial.
next prev parent reply other threads:[~2014-07-08 19:09 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 16:49 [PATCH v2 00/13] Regset rework preparations part 2 Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 08/13] M32R Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 13/13] IA64 Linux: Define regset structures Andreas Arnez
2014-07-15 13:01 ` Ulrich Weigand
2014-07-18 9:06 ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 10/13] SCORE: Fill 'collect_regset' in regset structure Andreas Arnez
2014-07-15 10:01 ` Ulrich Weigand
2014-07-15 12:25 ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 09/13] NIOS2 Linux: " Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 06/13] FRV Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 03/13] S390: Migrate to regcache_supply/collect_regset Andreas Arnez
2014-07-15 9:27 ` Ulrich Weigand
2014-07-15 12:07 ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 11/13] TILEGX Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-07-15 10:12 ` Ulrich Weigand
2014-07-16 13:30 ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 07/13] HPPA Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 01/13] Rename 'descr' field in regset structure to 'regmap' Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 12/13] M68K Linux: Define regset structures Andreas Arnez
2014-07-15 12:13 ` Ulrich Weigand
2014-07-16 18:01 ` Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 02/13] regcache: Add functions suitable for regset_supply/collect Andreas Arnez
2014-07-07 9:32 ` Omair Javaid
2014-07-08 11:32 ` Andreas Arnez
2014-07-08 19:09 ` Omair Javaid [this message]
2014-07-10 7:54 ` Andreas Arnez
2014-07-19 13:10 ` Omair Javaid
2014-06-25 16:49 ` [PATCH v2 04/13] AARCH64 Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-07-07 9:57 ` Omair Javaid
2014-06-25 16:49 ` [PATCH v2 05/13] ALPHA " Andreas Arnez
2014-07-01 8:00 ` [ping][PATCH v2 00/13] Regset rework preparations part 2 Andreas Arnez
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='CANW4E-3S6+JApYt=uNiznJQOxDU=B54zXVyf0L0N2JuLpJKrMQ@mail.gmail.com' \
--to=omair.javaid@linaro.org \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=kettenis@gnu.org \
--cc=yao@codesourcery.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).