Re: Help with building ADDR_EXPR node

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

 



zahed khurasani <sdzahed@xxxxxxxxx> writes:

> I need to build a node that is equivalent to the address of the memory
> being derenferenced.
> MEM_REF would help with the first parameter. But what about the third parameter?
> I would need an ADDR_EXPR for this parameter. However, the code I am using
> is failing.
> Thanks for the help.

I'm not sure I completely understand, but I will say that a
POINTER_PLUS_EXPR would be the address equivalent of a MEM_REF.

Ian

> On Fri, Mar 9, 2012 at 6:04 PM, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
>> zahed khurasani <sdzahed@xxxxxxxxx> writes:
>>
>>> My check function accepts three parameters: the value being
>>> dereferenced, the size of the object and the address in memory. I am
>>> using the following two lines to get the third address parameter.
>>>
>>> addr = build1 (ADDR_EXPR, build_pointer_type (type), t); // t is the
>>> ARRAY_REF node
>>> fold_convert_loc(location, ptr_type_node, addr); // type case to void *
>>>
>>> However, this is failing whenever the array_ref contains a
>>> non-constant expression, say like a[i+1]. The specific failure is
>>> inside the expand_expr_real_1 method in the file expr.c. Looks like
>>> such non-constant indices are not allowed at this stage in the
>>> compilation (I've inserted the pass just before lowering to RTL
>>> happens).
>>>
>>> My question is, what would be the right way to get the address? I am
>>> looking for something that will preferably work for all dereferences
>>> like MEM_REF, INDIRECT_REF etc.
>>
>> ARRAY_REF certainly permits non-constant indices, so I don't think that
>> is your problem.
>>
>> However, MEM_REF is the most general memory reference expression.
>>
>> Ian


[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