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: 03 Jul 2004 13:33:22 -0700
- Subject: Re: function structure
- References: <Sea1-DAV61MfzMCzfDf0000d18c@hotmail.com><40DB0829.5040008@specifixinc.com> <SEA1-DAV208LKDTndmc00046383@hotmail.com>
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