On Fri, Dec 11, 2009 at 5:16 AM, Aravinda <aravindakida...@gmail.com> wrote:
> Hi,
>
> Im trying to identify all indirect references in a loop so that, after
> this analysis, I have a list of tree_nodes of pointer_type that are
> dereferenced in a loop along with their step size, if any.
>
> E.g.
> while(i++ < n)
> {
>   *(p+i);
> }
>
> I want to get the pointer_type_node for 'p' and identify the step size
> as '1', since 'i' has a step size of 1.
>
> I am able to identify 'INDIRECT_REF' nodes in the loop. But since
> these are generally the expression_temporaries, I will not get the
> tree_node for 'p'. But I believe INDIRECT_REF is an expression who's
> arg0 is an SSA_NAME node  from which I will be able to use the
> SSA_NAME_DEF_STMT to ultimately reach the tree_node for 'p'.
>
> But I dont know how to get the SSA_NAME node from the given
> INDIRECT_REF. Could someone please point out how to do this.
>
> Also, I find it very difficult to know how the tree_nodes and types
> are contained one within the other. Is there a general technique by
> which I can know when a tree node will be nested within another and
> how to retrieve them ?

Look into the tree.def file.  Operands can be retrieved with the
TREE_OPERAND macro (see tree.h).  So if you have an
INDIRECT_REF expression tree node you can get the
variable or SSA_NAME that is dereferenced using TREE_OPERAND (e, 0)
if e is the INDIRECT_REF expression tree.  The pointer type
is then simply TREE_TYPE of that operand.

Btw, I think you want to use the existing data dependence analysis
which provides you with a list of data references in a loop.
See tree-data-ref.[ch].

Richard.

> Thanks,
> Aravinda
>

Reply via email to