From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: gdb-patches <gdb-patches@sourceware.org>
Subject: [RFA] Put SPE verification in macro.
Date: Wed, 30 Jan 2008 15:26:00 -0000 [thread overview]
Message-ID: <1201705759.11950.228.camel@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]
Hi,
This patch is a small cleanup which makes my revised version of the DFP
pseudo-registers patch more readable. I put the mantra used to check if
a given register number is an SPE pseudo-register in a macro and used it
whenever possible.
The only case the macro isnt't a direct replacement was this:
@@ -179,9 +184,7 @@ spe_register_p (struct gdbarch *gdbarch,
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Is it a reference to EV0 -- EV31, and do we have those? */
- if (tdep->ppc_ev0_regnum >= 0
- && tdep->ppc_ev31_regnum >= 0
- && tdep->ppc_ev0_regnum <= regno && regno <=
tdep->ppc_ev31_regnum)
+ if (IS_SPE_PSEUDOREG (tdep, regno))
return 1;
The above code checks if ppc_ev31_regnum is >= 0 and if regno <=
ppc_ev31_regnum. Since ppc_ev31_regnum is set in the same place and
condition that ppc_ev0_regnum is set, and that ppc_ev31_regnum's value
is ppc_ev0_regnum + 31, those checks are equivalent to the ones made by
the new macro.
GDB builds correctly with this patch. Unfortunately I don't have the
means to test it... Ok to commit?
--
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center
[-- Attachment #2: spe-macro-cleanup.diff --]
[-- Type: text/x-patch, Size: 3783 bytes --]
2008-01-30 Thiago Jung Bauermann <bauerman@br.ibm.com>
* rs6000-tdep.c (IS_SPE_PSEUDOREG): New macro.
(spe_register_p, rs6000_register_name, rs6000_pseudo_register_type,
rs6000_pseudo_register_reggroup_p, e500_move_ev_register,
e500_pseudo_register_read, e500_pseudo_register_write): Use
IS_SPE_PSEUDOREG macro.
diff -r efbf5d3c6cd9 -r acb978e1aa00 gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c Mon Jan 28 03:15:08 2008 -0800
+++ b/gdb/rs6000-tdep.c Tue Jan 29 02:01:12 2008 -0200
@@ -77,6 +77,11 @@
#include "features/rs6000/powerpc-860.c"
#include "features/rs6000/powerpc-e500.c"
#include "features/rs6000/rs6000.c"
+
+/* Determine if regnum is an SPE pseudo-register. */
+#define IS_SPE_PSEUDOREG(tdep, regnum) ((tdep)->ppc_ev0_regnum >= 0 \
+ && (regnum) >= (tdep)->ppc_ev0_regnum \
+ && (regnum) < (tdep)->ppc_ev0_regnum + 32)
/* The list of available "set powerpc ..." and "show powerpc ..."
commands. */
@@ -179,9 +184,7 @@ spe_register_p (struct gdbarch *gdbarch,
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Is it a reference to EV0 -- EV31, and do we have those? */
- if (tdep->ppc_ev0_regnum >= 0
- && tdep->ppc_ev31_regnum >= 0
- && tdep->ppc_ev0_regnum <= regno && regno <= tdep->ppc_ev31_regnum)
+ if (IS_SPE_PSEUDOREG (tdep, regno))
return 1;
/* Is it a reference to one of the raw upper GPR halves? */
@@ -2371,9 +2374,7 @@ rs6000_register_name (struct gdbarch *gd
return "";
/* Check if the SPE pseudo registers are available. */
- if (tdep->ppc_ev0_regnum >= 0
- && tdep->ppc_ev0_regnum <= regno
- && regno < tdep->ppc_ev0_regnum + ppc_num_gprs)
+ if (IS_SPE_PSEUDOREG (tdep, regno))
{
static const char *const spe_regnames[] = {
"ev0", "ev1", "ev2", "ev3", "ev4", "ev5", "ev6", "ev7",
@@ -2396,9 +2397,7 @@ rs6000_pseudo_register_type (struct gdba
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* These are the only pseudo-registers we support. */
- gdb_assert (tdep->ppc_ev0_regnum >= 0
- && regnum >= tdep->ppc_ev0_regnum
- && regnum < tdep->ppc_ev0_regnum + 32);
+ gdb_assert (IS_SPE_PSEUDOREG (tdep, regnum));
return rs6000_builtin_type_vec64 (gdbarch);
}
@@ -2411,9 +2410,7 @@ rs6000_pseudo_register_reggroup_p (struc
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* These are the only pseudo-registers we support. */
- gdb_assert (tdep->ppc_ev0_regnum >= 0
- && regnum >= tdep->ppc_ev0_regnum
- && regnum < tdep->ppc_ev0_regnum + 32);
+ gdb_assert (IS_SPE_PSEUDOREG (tdep, regnum));
if (group == all_reggroup || group == vector_reggroup)
return 1;
@@ -2499,8 +2496,7 @@ e500_move_ev_register (void (*move) (str
int reg_index;
gdb_byte *byte_buffer = buffer;
- gdb_assert (tdep->ppc_ev0_regnum <= ev_reg
- && ev_reg < tdep->ppc_ev0_regnum + ppc_num_gprs);
+ gdb_assert (IS_SPE_PSEUDOREG (tdep, ev_reg));
reg_index = ev_reg - tdep->ppc_ev0_regnum;
@@ -2525,8 +2521,7 @@ e500_pseudo_register_read (struct gdbarc
gdb_assert (regcache_arch == gdbarch);
- if (tdep->ppc_ev0_regnum <= reg_nr
- && reg_nr < tdep->ppc_ev0_regnum + ppc_num_gprs)
+ if (IS_SPE_PSEUDOREG (tdep, reg_nr))
e500_move_ev_register (regcache_raw_read, regcache, reg_nr, buffer);
else
internal_error (__FILE__, __LINE__,
@@ -2544,8 +2539,7 @@ e500_pseudo_register_write (struct gdbar
gdb_assert (regcache_arch == gdbarch);
- if (tdep->ppc_ev0_regnum <= reg_nr
- && reg_nr < tdep->ppc_ev0_regnum + ppc_num_gprs)
+ if (IS_SPE_PSEUDOREG (tdep, reg_nr))
e500_move_ev_register ((void (*) (struct regcache *, int, gdb_byte *))
regcache_raw_write,
regcache, reg_nr, (gdb_byte *) buffer);
next reply other threads:[~2008-01-30 15:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-30 15:26 Thiago Jung Bauermann [this message]
2008-01-30 18:21 ` Mark Kettenis
2008-01-30 18:38 ` Thiago Jung Bauermann
2008-01-30 19:06 ` Mark Kettenis
2008-01-30 19:24 ` Thiago Jung Bauermann
2008-01-31 14:55 ` Thiago Jung Bauermann
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=1201705759.11950.228.camel@localhost.localdomain \
--to=bauerman@br.ibm.com \
--cc=gdb-patches@sourceware.org \
/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