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: function structure


----- Original Message ----- 
From: "Jim Wilson" <wilson@specifixinc.com>
To: "王 逸" <cnnjuwy@hotmail.com>
Cc: <gcc@gcc.gnu.org>
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
> prototype.

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?

WangYi

> -- 
> Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
> 
> 

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