This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: function structure
- From: Jim Wilson <wilson at specifixinc dot com>
- To: 王 逸 <cnnjuwy at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 24 Jun 2004 09:58:17 -0700
- Subject: Re: function structure
- References: <Sea1-DAV61MfzMCzfDf0000d18c@hotmail.com>
王 逸 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
prototype.
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.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com