I'd need some help to develop a function, for a new gcc pass,
located after the value range propagation pass.

I'm working on the last release of gcc 4.1.

I'd like to have a function that receiving a stmt (that is
a CALL_EXPR) and an index (to specify the position of the
argument), has to return, for the argument specified, the variable
"defined" (i.e. the variable between those obtainable by code like
"FOR_EACH_SSA_TREE_OPERAND (def, ..., stmt, SSA_OP_ALL_DEFS)" ).
The function has to return a NULL_TREE, when there is not a
definition for the given argument.

The function prototype should be:
static tree get_def_operand(tree stmt, int i);


To explain me better, I use an example.

Supposing to have an fgets call.

  #   stdin_12 = V_MAY_DEF <stdin_1>;
  #   buf_13 = V_MAY_DEF <buf_3>;
  #   dst_14 = V_MAY_DEF <dst_11>;
  [test.c : 10] fgets (&buf, 10, stdin.23_2);

Calling the get_def_operand for this statement with index 0, the
function has to return the tree corresponding to buf_13.

Thanks for the attention!

Davide

Reply via email to