public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Accessing called function attributes in FUNCTION_ARG macro
@ 2009-05-28 17:48 Weddington, Eric
  2009-05-28 18:11 ` Georg-Johann Lay
  0 siblings, 1 reply; 2+ messages in thread
From: Weddington, Eric @ 2009-05-28 17:48 UTC (permalink / raw)
  To: gcc

Hi All,

This may be a dumb question, but I'm having difficulty finding the answer to this.

I'm working on a back-end and I have a function being called for the FUNCTION_ARG macro, and in that function I need to find out the attributes of the called function as this will affect the calling convention. I've tried looking at many of the other ports to see if anyone else is doing anything similar but so far I haven't found any other port that does that.

Could someone could point me in the right direction to do this?

Thanks,
Eric Weddington

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Accessing called function attributes in FUNCTION_ARG macro
  2009-05-28 17:48 Accessing called function attributes in FUNCTION_ARG macro Weddington, Eric
@ 2009-05-28 18:11 ` Georg-Johann Lay
  0 siblings, 0 replies; 2+ messages in thread
From: Georg-Johann Lay @ 2009-05-28 18:11 UTC (permalink / raw)
  To: Weddington, Eric; +Cc: gcc

Weddington, Eric schrieb:
> Hi All,
> 
> This may be a dumb question, but I'm having difficulty finding the answer to this.
> 
> I'm working on a back-end and I have a function being called for the FUNCTION_ARG macro, and in that function I need to find out the attributes of the called function as this will affect the calling convention. I've tried looking at many of the other ports to see if anyone else is doing anything similar but so far I haven't found any other port that does that.
> 
> Could someone could point me in the right direction to do this?

Hi Eric,

1) Scan for the attributes in INIT_CUMULATIVE_ARGS
    and set up some "call-cookie" that stores the
    information as part of CUMULATIVE_ARGS structure.
    To do this, scan the provided tree for the attribute:
       if (fntype && has_attribute_p (fntype)) cookie = ...
2) Update te cookie as needed in FUNCTION_ARG et al.
    resp. use it to generate the arguments' locations.
3) If FUNCTION_ARG et al. gets called with VOIDmode,
    return a CONST_INT representing the cookie.
    The CONST_INT will then appear as op2 resp op3
    in expander of call/sibcall resp call_value/sibcall_value
4) If insn output depends on the cookie, use it to print asm

The trouble is, that if FUNCTION_OK_FOR_SIBCALL depends on the
information gathered in CUMULATIVE_ARGS, calls.c doesn't pass
that information to the backend. This is important if a sibcall
must not be done depending on where callee's args are being passed.
sibcall patterns must not fail, so you had to hack around that.
Or more probably, I am just missing that part :-/

To look up the attribute, I am using code like

static bool has_attribute_p (tree func, const char *name)
{
     tree a;
     if (FUNCTION_DECL == TREE_CODE (func))
        func = TREE_TYPE (func);
     gcc_assert (TREE_CODE (func) == FUNCTION_TYPE);
     a = lookup_attribute (name, TYPE_ATTRIBUTES (func));

     return a != NULL_TREE;
}

Georg-Johann

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-28 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-28 17:48 Accessing called function attributes in FUNCTION_ARG macro Weddington, Eric
2009-05-28 18:11 ` Georg-Johann Lay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).