This is the mail archive of the gcc@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]

Pointer addition/subtraction tree node


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.

Subtraction is not a problem.  The real pointer always seems to be the first
operand (makes sense).

If the integer is a constant (e.g. p = p + 4) I can catch it by checking the
type: 
  TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST

But in other cases (e.g. p = p + i) I can't do this by looking at the type
as they both have the same type as the result pointer.  

Is there another way to find out which is which?

Thanks.
Alex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]