Re: [rfa] Add e500 function call support to PPC

Kevin Buettner
2003-03-10T21:47:00Z

On Mar 10, 2:56pm, Andrew Cagney wrote:

> > On Mar 10, 10:11am, Andrew Cagney wrote:
> >
> >> > This construct bothers me. If it occurred only once, it might not
> >> > bother me so much, but (arch_info->mach != bfd_mach_ppc_e500) appears
> >> > far too often in the code for me to be comfortable with it. Suppose
> >> > we have another core with a similar property (of passing everything
> >> > in GPRs). If this happens, we'll end up with a proliferation of
> >> > additional checks for all of these different cores and things will
> >> > become quite unreadable. Please introduce a predicate into which
> >> > we can put this test and perhaps others as they arise. Then, only
> >> > the predicate will need to be modified.
> >
> >>
> >> Such as:
> >>
> >> if (.....
> >> && tdep->ppc_fp0_regnum >= 0)
> >>
> >> ?
> >
> > If the ppc's tdep struct had such a member that would probably be okay.
>
> It currently doesn't. However, it occured to me that it should be added
> anyway. There is nothing indicating to the shared PPC code that the
> e500 doesn't have FPRs.

For the time being, how about introducing a predicate (function) to
ppc-sysv-tdep.c (or perhaps rs6000-tdep.c) named
have_floating_point_registers_p() (or something along those lines).

In the short term this could be defined as:

int
have_floating_point_registers_p (struct gdbarch *gdbarch)
{
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);

/* Note: It has been proposed that a ``ppc_fp0_regnum'' member be added
to the ppc tdep struct. If/when this occurs, it may be preferable to
implement this as:

struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

return tdep->ppc_fp0_regnum >= 0;
*/

return arch_info->mach != bfd_mach_ppc_e500;
}

It occurs to me that such a predicate would be useful for checking
the state of a global variable in the event that a command similar to
``set nomipsfpu'' were added for the powerpc. (Well, maybe. Then
again, maybe it'd be better to just set ppc_fp0_regnum to -1 when
such a setting were made.)

In any event, a name like have_floating_point_registers_p() is
reasonably self docuementing whereas ``tdep->ppc_fp0_regnum >= 0''
requires a little bit more thought to discern the meaning.

Kevin