Subject: Re: com rumblings...
To: Garrett D'Amore <garrett_damore@tadpole.com>
From: Charles M. Hannum <mycroft@MIT.EDU>
List: tech-kern
Date: 06/19/2006 15:01:28
On Mon, Jun 19, 2006 at 11:53:43AM -0700, Garrett D'Amore wrote:
> Charles M. Hannum wrote:
> > On Mon, Jun 19, 2006 at 11:20:20AM -0700, Bill Studenmund wrote:
> >   
> >> On Thu, Jun 15, 2006 at 02:38:24PM -0700, Garrett D'Amore wrote:
> >>     
> >>> I'm not sure how good gcc's optimizer is at detecting that:
> >>>
> >>>     struct {
> >>>        bus_space_handle_t h;
> >>>        bus_space_tag_t   t;
> >>>     } s;
> >>>
> >>>     bus_space_write_1(s->t, s->h, OFFSET1, VAL1);
> >>>     /* possibly insert code that doesn't modify s */
> >>>     bus_space_write_1(s->t, s->h, OFFSET2, VAL2);
> >>>
> >>> both values of s->t and s->h are really the same and could be cached in
> >>> registers without having to dereference thru s for each
> >>> bus_space_write_1 call.
> >>>       
> >> It probably can't assume that if there's a function call in there
> >> somewhere. Assign them to local variables & be explicit that they can be
> >> cached. :-)
> >>     
> >
> > I thought I already mentioned this, but maybe not.
> >
> > If you use accessor functions, and mark them "pure", GCC should do CSE
> > on the calls.  This is sort of gross, but it would give the effect
> > you're looking for.
> >   
> 
> You did say this.  My understanding is that then the individual ports
> should mark the functions as appropriate in their bus.h files.

No, you'd need accessor functions for the "s->t" and "s->h" references.
You can't mark the bus_space functions "pure" -- it wouldn't work, and
it would break many things.