[PATCH 10/11] powerpc: Add helper functions for synthesising instructions at runtime

Olof Johansson olof at lixom.net
Wed Oct 19 06:56:08 EST 2005


On Tue, Oct 18, 2005 at 03:39:42PM +1000, Michael Ellerman wrote:
> On Tue, 18 Oct 2005 00:44, Segher Boessenkool wrote:
> > > +typedef enum {
> > > +	BRANCH_RELATIVE,
> > > +	BRANCH_RELATIVE_LINK,
> > > +	BRANCH_ABSOLUTE,
> > > +	BRANCH_ABSOLUTE_LINK
> > > +} branch_t;
> >
> > Why not say BRANCH_RELATIVE = 0, BRANCH_RELATIVE_LINK = 1, etc.,
> > and then later just or this value into the insn?
> 
> I thought that might be too tricky, but perhaps you're right.

I agree with you, Segher's code is obfuscated. Your current coding
is much easier to read for someone that doesn't know the instruction
bitfield layout by heart. The saved instructions on doing it Segher's
way are not critical since it's not during a runtime hot path that this
is called. Go for readability instead.

Actually documenting Segher's code so it's as easy to understand will
make it just as large as your current one (i.e. your 7 lines, his 3
lines).


-Olof



More information about the Linuxppc64-dev mailing list