This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Put SPE verification in macro.
- From: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- To: gdb-patches <gdb-patches at sourceware dot org>
- Date: Wed, 30 Jan 2008 13:09:19 -0200
- Subject: [RFA] Put SPE verification in macro.
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
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);