How to get attribute of callee

Phung Nguyen nhphung@gmail.com
Thu Sep 2 15:15:00 GMT 2010


Hi Jakub,

Thank you for your help.

For direct call, I solved the problem based on your suggestion.
For indirect call, I don't understand much your idea. Could you please
clarify it?

Phung

On Thu, Sep 2, 2010 at 7:59 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Sep 02, 2010 at 07:18:29PM +0700, Phung Nguyen wrote:
>> I am porting GCC to a new target. I don't know how to get attribute of
>> callee of a call.
>>
>> I defined a new attribute to assign to a function but when writing for
>> pattern name "call" or "call_value", I don't know how to know if the
>> callee is assigned the attribute.  As the code for the call depends on
>> the attribute of the callee, I need to get the corresponding function
>> decl tree. As the operand of "call" or "call_value" might be
>> SYMBOL_REF (direct call) or REG (indirect call), I don't know how to
>> get the function declaration (fndecl).
>
> From SYMBOL_REF you just look at SYMBOL_REF_DECL, which will most often be a
> FUNCTION_DECL of the called function.
> For indirect call, most often (unless the optimizers have done a bad job)
> you don't know what function will be called.  So, if your attribute is
> supposed to change behavior of a call, including indirect calls, you'd
> better make it a type attribute and arrange during expand to use a different
> call pattern if the called function's type has that attribute.  At final
> time for indirect calls the called fn FUNCTION_TYPE is no longer available.
>
>        Jakub
>



More information about the Gcc mailing list