This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Mapping calls to declarations
- To: Daniel Berlin <dan at cgsoftware dot com>
- Subject: Re: Mapping calls to declarations
- From: James Montgomerie <jrmg at dcs dot ed dot ac dot uk>
- Date: Mon, 13 Aug 2001 17:45:48 +0100
- CC: <gcc at gcc dot gnu dot org>
on 13/8/01 4:54 pm, Daniel Berlin at dan@cgsoftware.com wrote:
>>
>> I need to be able to, in the function call instruction patterns (or
>> functions called by them), map from a function call to a declaration. I
>> first tried looking up the SYMBOL_REF in the symbol table, but this does not
>> work*.
> Err.
> I can do what you said in the message, and the function decls i get
> correspond exactly to the function in question, as they should.
I'm trying to do this in the output template substitution function (i.e. the
one called by the PRINT_OPERAND macro) like (quoting from my own previous
mail) this:
> tree t = lookup_name(get_identifier (XSTR(x, 0)));
>
> if (t && TREE_CODE (t) == FUNCTION_DECL)
> {
> jvm_write_function_args(t);
> }
>
> where x is the SYMBOL_REF for the function. Though this works, in the
> sense that it doesn't crash, the declarations I get out always seem to
> correspond to either a "void function(void);" or "int function(void);"
> declaration, which is wrong.
I should add that I /do/ get a valid FUNCTION_DECL node out, it's just one
with no arguments (i.e. DECL_ARGUMENTS(t) returns 0) and seems to always
return void or int (as examined by DECL_RESULT).
>> My next thought was to get the declaration via get_callee_fndecl,
>> somehow getting the tree for the call expression first, but I can't see a
>> way to do that.
>
> How early do you need to be able to do this?
> If you want to do it when creating the call instruction pattern itself,
> it's trivial.
> You'll be passed all the info you need.
Again, I need to do this in the output template substitution function (i.e.
the one called by the PRINT_OPERAND macro).
How can I get the tree expression for the call from within the instruction
pattern?
Either method (or another) would be equally good - so long as I can map back
to the declaration from within the call instruction pattern.
Jamie.