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: How to get the line info about a function when outputing the funciton prolog?


>    I am developing a new target for GCC. But my assember need the
>    source 
> line information about a function(its begin line and end line ) before
> the function body is outputted. 
> 
>   I think the proper place to output this information is the function 
> prologue macro. But when this macro is called, I don't know how to get
> the source file line information about the function?

You can get the begin and end lines of a function by parsing the
program's insn list. If you run GCC with the -dr option, it will
generate a .00.rtl file that contain a RTL dump of your program. You'll
see that there are "note" insn, some of them labelled
"NOTE_INSN_FUNCTION_BEG" and "NOTE_INSN_FUNCTION_END" With the
NOTE_LINE_NUMBER and NOTE_SOURCE_FILE macros applied on a note insn you
can get the line number and source file name respectively. It is
documented in http://gcc.gnu.org/onlinedocs/gccint/Insns.html, look for
the "note" insns.

Getting the corresponding note insn in your prologue should be easy I
guess, but I don't know if it would be the preferred way, and right now
I don't know precisely how you could do that. Maybe someone with more
experience than me could emphasize on this, and confirm/infirm my
suggestion.

See you!
Alex.
-- 
http://www.gnurou.org


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