This is the mail archive of the
mailing list for the GCC project.
Re: function structure
- From: 王 逸 <cnnjuwy at hotmail dot com>
- To: "Jim Wilson" <wilson at specifixinc dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Tue, 6 Jul 2004 08:05:33 +0800
- Subject: Re: function structure
- References: <Sea1-DAV61MfzMCzfDf0000d18c@hotmail.com> <40DB0829.email@example.com>
----- Original Message -----
From: "Jim Wilson" <firstname.lastname@example.org>
To: "王 逸" <email@example.com>
Sent: Friday, June 25, 2004 12:58 AM
Subject: Re: function structure
> 王 逸 wrote:
> > RTL representation of function-call insns looks like:
> > (call (mem:fm addr) nbytes)
> > here the nbytes refers to the number of bytes of arguments being passed to the subroutine.
> See the documentation in gcc/gcc/doc/rtl.texi, search for "(call".
> See the code in emit-call.c, search for GEN_CALL. Note that the value
> passed in is rounded_stack_size_rtx which is a highly suggestive
> variable name. You can look at the code a bit more to see exactly what
> value this value is going to have.
> > If this is wrong, please tell me how to determine whether a function has arguments, thanks.
> If you have a tree, then try looking at DECL_ARGUMENTS. There is also
> TYPE_ARG_TYPES (TREE_TYPE (function)), but that only works if you have a
Yes, list_length(DECL_ARGUMENTS(fn_decl)) should return the number of arguments, right?
> If you have RTL, then there is probably no safe and easy way to
> determine this. You can try looking up the function decl from the
> symbol_ref in the call, but you may not always have one. You can try
> using the nargs field, but there is no guarantee that it will be
> non-zero if there are arguments, though it may be for your target if all
> arguments go on the stack.
But I'm afraid that I can only get the RTL.
After the RTL of a function is generated, I looked through this RTL unit. When a call_insn is met, I need to determine the number of arguments of the called routine.
What can I do?
From the call_insn, I can get the called routine's name, maybe I can go through the current_file_decl list and try to find
the correspond function declaration tree?(if it exists)
Is this method feasible?
> Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com