This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Help with building ADDR_EXPR node


Ian,

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.

Zahed

On Fri, Mar 9, 2012 at 6:04 PM, Ian Lance Taylor <iant@google.com> wrote:
> zahed khurasani <sdzahed@gmail.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]