Retrieving argument value from __attribute__

naga raj gnuuser.raj@gmail.com
Wed Feb 27 11:49:00 GMT 2013


On Wed, Feb 27, 2013 at 9:19 AM, Chung-Ju Wu <jasonwucj@gmail.com> wrote:
> 2013/2/26 naga raj <gnuuser.raj@gmail.com>:
>>
>> Is it possible to the compiler to get the information about the
>> attributes when a function is called. so that I can move the attribute
>> value to the temp register at function call itself instead of moving
>> it in the prologue..
>>
>> Ex:
>> void matrix_const(int ) __attribute__((svc_handler(777)));
>> matrix_const(int a)
>> {
>>    .....     -------------------------> Currently with your suggestion
>> I am able to move 777 to temp register at function prologue
>>    .....
>> }
>> main()
>> {
>>    ...
>>    ...
>>   matrix_const(10);    ------> Is it possible to find out about the
>> attributes of calling function matrix_const at this point??
>> }
>>
>> What I have observed is that compiler code is using only current
>> function tree information. Does it maintain information about the
>> functions that it is going to call.
>>
>> Does Gcc maintains any information.. Can you please help me in finding
>> the correct tree attribute to understand this.
>>
>> Thanks in Advance,
>> Nagaraju
>
> At the time when you calculate frame size or generate prologue,
> a tree variable 'current_function_decl' may be helpful to you.
> For example:
>
>   attrs = DECL_ATTRIBUTES (current_function_decl);
>
> By that, you can save any attribute information of current function in
> particular sections,
> (Certainly you have to traverse and parse tree list by yourself.)
> and then generate some assembly code to access content from the sections.
>
> There might be a better solution, but so far using particular sections
> is one apporach I can figure out.
>
> For more information of using tree structure in GCC,
> refer to the 'Chapter 11 GENERIC' of GCC Internals documentation.
>
>
> Best regards,
> jasonwucj

Thanks for the reply.  I will dig depper with your inputs.

Thanks,
Nagaraju



More information about the Gcc-help mailing list