This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: More space efficient virtual function calls


Mike,

Thanks I'll try it,

Wink

----- Original Message -----
From: "mike stump" <mrs@windriver.com>
To: <gcc@gcc.gnu.org>; <wink@saville.com>
Sent: Sunday, July 07, 2002 12:17 PM
Subject: Re: More space efficient virtual function calls


> > From: "Wink Saville" <wink@saville.com>
> > To: <gcc@gcc.gnu.org>
> > Date: Sat, 6 Jul 2002 17:29:11 -0700
>
> > I was wondering if there was switch in gcc that would cause it to
> > generate smaller code when invoking virtual functions.
>
> Most likely not, other than -Os.
>
> > Is this already possible with an existing switch/pragma?
>
> No.
>
> > Is this practical?
>
> Yes.
>
> > Would most of the modifications be need to needed to the front end, back
end
> > or both?
>
> It could be done in the port file.
>
> > Could someone point me to the places I would need to change to try this
out?
>
> Sure.
>
> Just create a peephole to find the code you want to replace:
>
> >     LDR    R1,[R4]        /* Fetch the vtable pointer */
> >     MOV    R0,R4        /* R0 = this */
> >     MOV LR, PC          /* Set of the link register */
> >     LDR PC,[R1, #4]  /* Call virtual function 1, the second entry */
>
> and replace it with what you want:
>
> >     LDR    R0,R4    /* R0 = this */
> >     BL    __VTFunc1     /* Branch and Link to virtual thunk function 1
*/
>
> [ or whatever the right version is ], and do this when -Os is given.
> You should then be able to `see' the compiler generate this code.
> Then you will discover there is no definition for __VTFunc1, and you
> will discover you want to added it to the .asm or .s file for the port
> so it will wind up in libgcc.a.  Or, you can put it in a linkonce
> section if the port supports it, and always emit them in each unit,
> or, after you discover what longcall is, you might want to do it as
> private in each unit.  I might recommend the last alternative.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]