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


On Mon, 2004-07-05 at 17:05, ç é wrote:
> 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?

I don't know what you are doing, or why you are doing it, so this is
hard to answer.  But one thing you should consider is why you are doing
this at the RTL level instead of doing this at the tree or gimple level,
where it might be easier to do.

There are 3 things of interest here.  The number of parameters a
function is defined with.  The number of parameters a function is
declared with.  The number of arguments passed to a function at a call
site.  All 3 of these numbers can be different.  There is also the issue
of stdarg functions which is another complication.  Function definitions
might be in another file, in which case this info might be unavailable
with current gcc sources.

If you have a CALL_EXPR tree, then you can see how many arguments as
being passed to a function call.  If you have a FUNCTION_DECL tree, then
you can see how many parameters the declaration/definition contains,
assuming it contains any.  A declaration contains parameters only if it
is a prototype, and it is common in older code to declare functions
without listing the parameters.  So if you really need to know the
number of arguments, then looking at FUNCTION_DECL trees may be
misleading.

I don't think you can get the info you want simply from looking at a
CALL rtl.  You need to go higher up, e.g. to the CALL_EXPR, see for
example where expand_expr calls expand_call.
-- 
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]