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: profiling on sh


Given the delay slot, could one also do this?

     jsr @r0
     mov.l lab,r0
     .align 4
     .long .LP0
 lab:
     .long _mcount

I'm also wondering about the label 'lab'.  Does that need to be done every
time and does the label need to be unique?  This profiling code is inserted
with every function call so I'm wondering if there's some way to globally
insert this.

Both the arm and thumb just do a 'bl mcount' but that didn't look to me like
the way functions were called on sh (but then again, a couple days ago is
the first time I've ever looked at arm or sh assembly so what do I know ;-)
Thanks very much for the help.

cheers,

Kris

----- Original Message -----
From: "Stephen Clarke" <Stephen.Clarke@st.com>
To: <kewarken@qnx.com>
Cc: <aoliva@redhat.com>; <gcc@gcc.gnu.org>
Sent: Friday, March 15, 2002 6:59 PM
Subject: Re: profiling on sh


> kewarken@qnx.com wrote:
> >
> > Here's what I've been trying to do Alexandre.  I'm modeling this after
the
> > way arm does it - most of the platforms seem to do something similar:
call
> > _mcount and then set a label afterwards - the code in mcount seems to
figure
> > out where it was called from and then gprof looks at the labels later to
> > print the call graph and timing information.  I hope you forgive my
> > ignorance...I've only been looking at sh for a couple of days now.  The
> > problem with this is that it generates code that the assembler chokes
on,
> > giving 'pcrel too far' errors.  I'm looking for the proper way to call
> > _mcount() in this situation.
> >
> > My output is:
> >
> >  mov.l _mcount,r0
> >  jsr @r0
> >  .long .LP0
>
> The 'mov.l _mcount, r0' instruction doesn't do what you want: it
> tries to load the longword at address _mcount.  You want something like:
>
>     mov.l lab,r0
>     jsr @r0
>     nop
>     .align 4
>     .long .LP0
> lab:
>     .long _mcount
>
> You'll need extra work in _mcount to calculate the correct return
> address, taking in the alignment and literals embedded in the code.
>
> Also note that jsr has a delay slot - hence the nop after it.
>
> The thumb ISA is closer to sh than arm, so maybe that could provide some
> clues?
>
> Steve.
> --
> Stephen Clarke, Principal Engineer, SuperH Inc.
> Phone:1-408-922-4062, Fax:1-408-954-8507, mailto:Stephen.Clarke@st.com
> Mail:  SuperH Inc., 3801 Zanker Rd., San Jose, CA 95134, USA.
>


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