From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13554 invoked by alias); 30 Jan 2008 19:01:14 -0000 Received: (qmail 13540 invoked by uid 22791); 30 Jan 2008 19:01:12 -0000 X-Spam-Check-By: sourceware.org Received: from igw1.br.ibm.com (HELO igw1.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 30 Jan 2008 19:00:47 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw1.br.ibm.com (Postfix) with ESMTP id 43BF832C0D1 for ; Wed, 30 Jan 2008 16:38:51 -0200 (BRDT) Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m0UJ0SRj2310338 for ; Wed, 30 Jan 2008 17:00:39 -0200 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m0UJ0Rvf022946 for ; Wed, 30 Jan 2008 17:00:27 -0200 Received: from [9.12.235.82] ([9.12.235.82]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m0UJ0PwG022820; Wed, 30 Jan 2008 17:00:26 -0200 Subject: Re: [RFA] Put SPE verification in macro. From: Thiago Jung Bauermann To: Mark Kettenis Cc: gdb-patches@sourceware.org In-Reply-To: <200801301853.m0UIr0Ii025415@brahms.sibelius.xs4all.nl> References: <1201705759.11950.228.camel@localhost.localdomain> <200801301814.m0UIE006010057@brahms.sibelius.xs4all.nl> <1201717972.11950.255.camel@localhost.localdomain> <200801301853.m0UIr0Ii025415@brahms.sibelius.xs4all.nl> Content-Type: multipart/mixed; boundary="=-V9Loft7+vAzAyS6XOAl/" Date: Wed, 30 Jan 2008 19:24:00 -0000 Message-Id: <1201719624.11950.256.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00821.txt.bz2 --=-V9Loft7+vAzAyS6XOAl/ Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1085 On Wed, 2008-01-30 at 19:53 +0100, Mark Kettenis wrote: > > From: Thiago Jung Bauermann > > Date: Wed, 30 Jan 2008 16:32:52 -0200 > > > > On Wed, 2008-01-30 at 19:14 +0100, Mark Kettenis wrote: > > > > From: Thiago Jung Bauermann > > > > Date: Wed, 30 Jan 2008 13:09:19 -0200 > > > > > > > > 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. > > > > > > This makes ppc_ev31_regnum completely redundant isn't it? Could you > > > remove it? > > > > Right. Yes, I can remove it. I also noticed that the num_sprs variable > > in rs6000_gdbarch_init is set to zero and used without any other > > assignment. I will remove that one as well... > > Sounds great! What about this? -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center --=-V9Loft7+vAzAyS6XOAl/ Content-Disposition: attachment; filename=spe-macro-cleanup-rev2.diff Content-Type: text/x-patch; name=spe-macro-cleanup-rev2.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 5888 2008-01-30 Thiago Jung Bauermann * ppc-tdep.h (struct gdbarch_tdep): Remove ppc_ev31_regnum member. * 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. (rs6000_frame_cache): Remove use of tdep->ppc_ev31_regnum. (rs6000_gdbarch_init): Remove unnecessary num_sprs local variable. Remove initialization of tdep->ppc_ev31_regnum. diff -r efbf5d3c6cd9 -r 168620c4b9da gdb/ppc-tdep.h --- a/gdb/ppc-tdep.h Mon Jan 28 03:15:08 2008 -0800 +++ b/gdb/ppc-tdep.h Wed Jan 30 16:49:16 2008 -0200 @@ -201,7 +201,6 @@ struct gdbarch_tdep /* SPE registers. */ int ppc_ev0_upper_regnum; /* First GPR upper half register */ int ppc_ev0_regnum; /* First ev register */ - int ppc_ev31_regnum; /* Last ev register */ int ppc_acc_regnum; /* SPE 'acc' register */ int ppc_spefscr_regnum; /* SPE 'spefscr' register */ diff -r efbf5d3c6cd9 -r 168620c4b9da gdb/rs6000-tdep.c --- a/gdb/rs6000-tdep.c Mon Jan 28 03:15:08 2008 -0800 +++ b/gdb/rs6000-tdep.c Wed Jan 30 16:49:16 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); @@ -2986,7 +2980,7 @@ rs6000_frame_cache (struct frame_info *n /* if != -1, fdata.saved_ev is the smallest number of saved_ev. All vr's from saved_ev to ev31 are saved. ????? */ - if (tdep->ppc_ev0_regnum != -1 && tdep->ppc_ev31_regnum != -1) + if (tdep->ppc_ev0_regnum != -1) { if (fdata.saved_ev >= 0) { @@ -3178,7 +3172,6 @@ rs6000_gdbarch_init (struct gdbarch_info int tdesc_wordsize = -1; const struct target_desc *tdesc = info.target_desc; struct tdesc_arch_data *tdesc_data = NULL; - int num_sprs = 0; from_xcoff_exec = info.abfd && info.abfd->format == bfd_object && bfd_get_flavour (info.abfd) == bfd_target_xcoff_flavour; @@ -3609,7 +3602,7 @@ rs6000_gdbarch_init (struct gdbarch_info else set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc); - set_gdbarch_num_regs (gdbarch, PPC_NUM_REGS + num_sprs); + set_gdbarch_num_regs (gdbarch, PPC_NUM_REGS); set_gdbarch_num_pseudo_regs (gdbarch, have_spe ? 32 : 0); set_gdbarch_ptr_bit (gdbarch, wordsize * TARGET_CHAR_BIT); @@ -3732,7 +3725,6 @@ rs6000_gdbarch_init (struct gdbarch_info /* Recording the numbering of pseudo registers. */ tdep->ppc_ev0_regnum = have_spe ? gdbarch_num_regs (gdbarch) : -1; - tdep->ppc_ev31_regnum = have_spe ? tdep->ppc_ev0_regnum + 31 : -1; return gdbarch; } --=-V9Loft7+vAzAyS6XOAl/--