Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Omair Javaid <omair.javaid@linaro.org>
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 11:32:00 -0000	[thread overview]
Message-ID: <87lhs4f5ng.fsf@br87z6lw.de.ibm.com> (raw)
In-Reply-To: <CANW4E-0cEaQ=DLN5SVjWtCiHCK5iDDqUFnEgKbACig+pe4pW_A@mail.gmail.com>	(Omair Javaid's message of "Mon, 7 Jul 2014 14:32:21 +0500")

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?


  reply	other threads:[~2014-07-08 11:32 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 05/13] ALPHA Linux: Fill 'collect_regset' in regset structures 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 10/13] SCORE: " Andreas Arnez
2014-07-15 10:01   ` Ulrich Weigand
2014-07-15 12:25     ` 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 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 [this message]
2014-07-08 19:09       ` Omair Javaid
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 07/13] HPPA " Andreas Arnez
2014-06-25 16:49 ` [PATCH v2 09/13] NIOS2 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 06/13] FRV Linux: Fill 'collect_regset' in " 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 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 12/13] M68K Linux: Define regset structures Andreas Arnez
2014-07-15 12:13   ` Ulrich Weigand
2014-07-16 18:01     ` 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=87lhs4f5ng.fsf@br87z6lw.de.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=kettenis@gnu.org \
    --cc=omair.javaid@linaro.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