* [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
@ 2004-02-10 16:14 Corinna Vinschen
2004-02-10 16:17 ` Corinna Vinschen
2004-02-16 15:29 ` Elena Zannoni
0 siblings, 2 replies; 6+ messages in thread
From: Corinna Vinschen @ 2004-02-10 16:14 UTC (permalink / raw)
To: gdb-patches
Hi,
the functions sh_sh4_register_convert_to_virtual and
sh_sh4_register_convert_to_raw are only called once each. In both
cases, the register numbers are already tested for the correct range,
before the function is actually called. Therefore it's possible to
optimize the register number tests away from both functions.
Also, I'd like to propose to rename both functions to get rid of the
"sh4" in the name. The functions are universal so I'd like to reuse
them for an upcoming SH variant with different virtual register numbering,
if that's ok.
Thanks in advance,
Corinna
ChangeLog:
* sh-tdep.c (sh_register_convert_to_virtual): Rename from
sh_sh4_register_convert_to_virtual. Remove register number test.
(sh_register_convert_to_raw): Rename from
sh_sh4_register_convert_to_raw. Remove register number test.
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.156
diff -u -p -r1.156 sh-tdep.c
--- sh-tdep.c 26 Jan 2004 20:52:12 -0000 1.156
+++ sh-tdep.c 10 Feb 2004 15:58:04 -0000
@@ -1541,33 +1541,22 @@ sh_default_register_type (struct gdbarch
because they are stored as 4 individual FP elements. */
static void
-sh_sh4_register_convert_to_virtual (int regnum, struct type *type,
+sh_register_convert_to_virtual (int regnum, struct type *type,
char *from, char *to)
{
- if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
- {
- DOUBLEST val;
- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
- from, &val);
- store_typed_floating (to, type, val);
- }
- else
- error
- ("sh_register_convert_to_virtual called with non DR register number");
+ DOUBLEST val;
+ floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
+ from, &val);
+ store_typed_floating (to, type, val);
}
static void
-sh_sh4_register_convert_to_raw (struct type *type, int regnum,
+sh_register_convert_to_raw (struct type *type, int regnum,
const void *from, void *to)
{
- if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
- {
- DOUBLEST val = extract_typed_floating (from, type);
- floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
- &val, to);
- }
- else
- error ("sh_register_convert_to_raw called with non DR register number");
+ DOUBLEST val = extract_typed_floating (from, type);
+ floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
+ &val, to);
}
/* For vectors of 4 floating point registers. */
@@ -1609,7 +1598,7 @@ sh_pseudo_register_read (struct gdbarch
+ register_size (gdbarch,
base_regnum) * portion));
/* We must pay attention to the endiannes. */
- sh_sh4_register_convert_to_virtual (reg_nr,
+ sh_register_convert_to_virtual (reg_nr,
gdbarch_register_type (gdbarch,
reg_nr),
temp_buffer, buffer);
@@ -1639,7 +1628,7 @@ sh_pseudo_register_write (struct gdbarch
base_regnum = dr_reg_base_num (reg_nr);
/* We must pay attention to the endiannes. */
- sh_sh4_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr),
+ sh_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr),
reg_nr, buffer, temp_buffer);
/* Write the real regs for which this one is an alias. */
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
2004-02-10 16:14 [RFA] sh-tdep.c: optimize and rename virtual register conversion functions Corinna Vinschen
@ 2004-02-10 16:17 ` Corinna Vinschen
2004-02-16 15:29 ` Elena Zannoni
1 sibling, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2004-02-10 16:17 UTC (permalink / raw)
To: gdb-patches
Uhm... sorry, the ChangeLog is missing two entries :-(
Here it's again in full length:
* sh-tdep.c (sh_register_convert_to_virtual): Rename from
sh_sh4_register_convert_to_virtual. Remove register number test.
(sh_register_convert_to_raw): Rename from
sh_sh4_register_convert_to_raw. Remove register number test.
(sh_pseudo_register_read): Accomodate above name change.
(sh_pseudo_register_write): Ditto.
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
2004-02-10 16:14 [RFA] sh-tdep.c: optimize and rename virtual register conversion functions Corinna Vinschen
2004-02-10 16:17 ` Corinna Vinschen
@ 2004-02-16 15:29 ` Elena Zannoni
2004-02-16 15:55 ` Corinna Vinschen
1 sibling, 1 reply; 6+ messages in thread
From: Elena Zannoni @ 2004-02-16 15:29 UTC (permalink / raw)
To: gdb-patches
Corinna Vinschen writes:
> Hi,
>
> the functions sh_sh4_register_convert_to_virtual and
> sh_sh4_register_convert_to_raw are only called once each. In both
> cases, the register numbers are already tested for the correct range,
> before the function is actually called. Therefore it's possible to
> optimize the register number tests away from both functions.
>
> Also, I'd like to propose to rename both functions to get rid of the
> "sh4" in the name. The functions are universal so I'd like to reuse
> them for an upcoming SH variant with different virtual register numbering,
> if that's ok.
Can you elaborate a bit about this new SH variant? Is the test in the
function conflicting with a different test for the new variant?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
2004-02-16 15:29 ` Elena Zannoni
@ 2004-02-16 15:55 ` Corinna Vinschen
2004-02-16 16:20 ` Elena Zannoni
0 siblings, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2004-02-16 15:55 UTC (permalink / raw)
To: gdb-patches
On Feb 16 10:25, Elena Zannoni wrote:
> Corinna Vinschen writes:
> > Hi,
> >
> > the functions sh_sh4_register_convert_to_virtual and
> > sh_sh4_register_convert_to_raw are only called once each. In both
> > cases, the register numbers are already tested for the correct range,
> > before the function is actually called. Therefore it's possible to
> > optimize the register number tests away from both functions.
> >
> > Also, I'd like to propose to rename both functions to get rid of the
> > "sh4" in the name. The functions are universal so I'd like to reuse
> > them for an upcoming SH variant with different virtual register numbering,
> > if that's ok.
>
>
> Can you elaborate a bit about this new SH variant?
It will introduce a couple of new real registers which requires to
increment the pseudo double precision register numbers. At the moment
I can't go into too much detail otherwise.
> Is the test in the
> function conflicting with a different test for the new variant?
Actually, it was a thinko on my side. The new variant will result
in incrementing SH_NUM_REGS but when I sent this patch, I was still
using another register count for this very cpu. Therefore, the
register test is only superfluous, nothing else. It does not conflict
with anything.
So, if you think that the test should be kept in that function, that's
fine with me. The only remaining bit is the naming of the function then.
The new cpu is not a sh4 type, but it's using the same pseudo register
functions as the sh4. The function would just not be sh4 specific anymore.
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
2004-02-16 15:55 ` Corinna Vinschen
@ 2004-02-16 16:20 ` Elena Zannoni
2004-02-16 16:52 ` Corinna Vinschen
0 siblings, 1 reply; 6+ messages in thread
From: Elena Zannoni @ 2004-02-16 16:20 UTC (permalink / raw)
To: gdb-patches
Corinna Vinschen writes:
> On Feb 16 10:25, Elena Zannoni wrote:
> > Corinna Vinschen writes:
> > > Hi,
> > >
> > > the functions sh_sh4_register_convert_to_virtual and
> > > sh_sh4_register_convert_to_raw are only called once each. In both
> > > cases, the register numbers are already tested for the correct range,
> > > before the function is actually called. Therefore it's possible to
> > > optimize the register number tests away from both functions.
> > >
> > > Also, I'd like to propose to rename both functions to get rid of the
> > > "sh4" in the name. The functions are universal so I'd like to reuse
> > > them for an upcoming SH variant with different virtual register numbering,
> > > if that's ok.
> >
> >
> > Can you elaborate a bit about this new SH variant?
>
> It will introduce a couple of new real registers which requires to
> increment the pseudo double precision register numbers. At the moment
> I can't go into too much detail otherwise.
>
> > Is the test in the
> > function conflicting with a different test for the new variant?
>
> Actually, it was a thinko on my side. The new variant will result
> in incrementing SH_NUM_REGS but when I sent this patch, I was still
> using another register count for this very cpu. Therefore, the
> register test is only superfluous, nothing else. It does not conflict
> with anything.
>
> So, if you think that the test should be kept in that function, that's
> fine with me. The only remaining bit is the naming of the function then.
> The new cpu is not a sh4 type, but it's using the same pseudo register
> functions as the sh4. The function would just not be sh4 specific anymore.
Ok, thanks. Just rename the function for now, we can revisit later.
elena
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions
2004-02-16 16:20 ` Elena Zannoni
@ 2004-02-16 16:52 ` Corinna Vinschen
0 siblings, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2004-02-16 16:52 UTC (permalink / raw)
To: gdb-patches
On Feb 16 11:16, Elena Zannoni wrote:
> Corinna Vinschen writes:
> > So, if you think that the test should be kept in that function, that's
> > fine with me. The only remaining bit is the naming of the function then.
> > The new cpu is not a sh4 type, but it's using the same pseudo register
> > functions as the sh4. The function would just not be sh4 specific anymore.
>
> Ok, thanks. Just rename the function for now, we can revisit later.
OK, thank you. I've applied the below patch.
Corinna
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.160
diff -u -p -r1.160 sh-tdep.c
--- sh-tdep.c 16 Feb 2004 16:04:18 -0000 1.160
+++ sh-tdep.c 16 Feb 2004 16:51:45 -0000
@@ -1519,8 +1519,8 @@ sh_default_register_type (struct gdbarch
because they are stored as 4 individual FP elements. */
static void
-sh_sh4_register_convert_to_virtual (int regnum, struct type *type,
- char *from, char *to)
+sh_register_convert_to_virtual (int regnum, struct type *type,
+ char *from, char *to)
{
if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
{
@@ -1535,8 +1535,8 @@ sh_sh4_register_convert_to_virtual (int
}
static void
-sh_sh4_register_convert_to_raw (struct type *type, int regnum,
- const void *from, void *to)
+sh_register_convert_to_raw (struct type *type, int regnum,
+ const void *from, void *to)
{
if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
{
@@ -1587,10 +1587,9 @@ sh_pseudo_register_read (struct gdbarch
+ register_size (gdbarch,
base_regnum) * portion));
/* We must pay attention to the endiannes. */
- sh_sh4_register_convert_to_virtual (reg_nr,
- gdbarch_register_type (gdbarch,
- reg_nr),
- temp_buffer, buffer);
+ sh_register_convert_to_virtual (reg_nr,
+ gdbarch_register_type (gdbarch, reg_nr),
+ temp_buffer, buffer);
}
else if (reg_nr >= FV0_REGNUM && reg_nr <= FV_LAST_REGNUM)
{
@@ -1617,8 +1616,8 @@ sh_pseudo_register_write (struct gdbarch
base_regnum = dr_reg_base_num (reg_nr);
/* We must pay attention to the endiannes. */
- sh_sh4_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr),
- reg_nr, buffer, temp_buffer);
+ sh_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr),
+ reg_nr, buffer, temp_buffer);
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-02-16 16:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-10 16:14 [RFA] sh-tdep.c: optimize and rename virtual register conversion functions Corinna Vinschen
2004-02-10 16:17 ` Corinna Vinschen
2004-02-16 15:29 ` Elena Zannoni
2004-02-16 15:55 ` Corinna Vinschen
2004-02-16 16:20 ` Elena Zannoni
2004-02-16 16:52 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox