Re: Retrieving argument value from __attribute__

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi jasonwucj,

On Tue, Feb 26, 2013 at 1:42 AM, Chung-Ju Wu <jasonwucj@xxxxxxxxx> wrote:
> 2013/2/25 naga raj <gnuuser.raj@xxxxxxxxx>:
>> Hi All,
>>
>>    I am working on Microblaze port. I have a requirement in which user
>> will declare a handler number in the function prototype as below
>>    ex: void matrix_const(int ) __attribute__((svc_handler(777)));
>>
> [deleted]
>>
>> My question is how to find the argument value(777) using
>> "microblaze_svc_handler_function_p" ?? Do we have any ATTRIBUTE
>> related function to do this.
>>  Please suggest a solution/document by which we can extract the
>> argument value...
>>
>>
>> Thanks in Advance,
>> Nagaraju
>
> Try following statement:
>
>   tree attrs;
>   tree name, args;
>
>   attrs = DECL_ATTRIBUTES (func);
>   name  = TREE_PURPOSE (attrs);
>   args  = TREE_VALUE (attrs);
>
>
> After that, you can use:
>
>   TREE_INT_CST_LOW (TREE_VALUE (args))
>
> to extract its constant value.
>
>
> Best regards,
> jasonwucj

Thanks for you suggestions. They have worked for me. I am able to
retrieve the svc handler attribute number.


Extending to this I want to learn one more thing

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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux