> -----Original Message-----
> From: Andrew Pinski [mailto:[EMAIL PROTECTED]
> Sent: 19 March 2007 00:47
> To: Alexander Lamaison
> Cc: gcc@gcc.gnu.org
> Subject: Re: Pointer addition/subtraction tree node
> 
> On 3/18/07, Alexander Lamaison <[EMAIL PROTECTED]> wrote:
> > As part of adding a new pass to GCC I am intercepting addition to and
> > subtraction from pointers.  These are represented by PLUS_EXPR and
> > MINUS_EXPR tree nodes.  I need to be able to find out which of the
> node's
> > two operands is the actual pointer and which is the integer that has
> been
> > added to it.
> >
> > Is there another way to find out which is which?
> 
> Not right now, I have been working on a new representation of pointer
> arithmetic for the tree level.  The basic implementation is already
> done, see the pointer_plus branch.
> 
> Thanks,
> Andrew Pinski

Apologies for top-posting before:

Code of the form

        int[10] a;
        int* p = a; int* q = a;
        int i = 3;

        p = q + i;

is transformed into

        int * D.900;
        unsigned int D.899;
        unsigned int i.0;

<bb 0>:
        i = 3;
        p = &a;
        q = &a;
        i.0 = (unsigned int) i;
        D.899 = i.0 * 4;
        D.900 = (int *) D.899;
        p = D.900 + q;

by the time it reaches the fixupcfg pass.

It has been suggested to me that a solution might be to trace back through the 
tree to find which of the operands is derived from a non-pointer variable.  I 
am new to GCC development.  How might I go about doing this?

Another approach I tried was to detect which of the operands was a compiler 
intermediate (my theory being that this would always be the non-pointer 
operand) by using DECL_ARTIFICIAL (TREE_OPERAND (t, 0)) but this breaks if 
tried on an operand that is not a VAR_DECL.  I don't think my theory is sounds 
but if it is, is there a way to get this to work?

Thanks.
Alex.

Reply via email to