>Could someone please explain what this function is supposed to do? It
For public functions, you can (usually) get a descrption from the
cooresponding header:
* OP *TN_Reaching_Value_At_Op(TN *tn, OP *op, DEF_KIND *kind,
* BOOL reaching_def)
* The routine can be used to find (1) the reaching definition of
* operand <tn> of <op>, or (2) the following use of the result <tn>
* of <op>. The knob is controlled by the flag <reaching_def>.
* If <reaching_def> is TRUE, find the reaching definition of the <tn>,
* if <reaching_def> is FALSE, find the reaching use of the <tn>.
* If none is found, return NULL. <kind> determines the definition kind
* property returned by the function, i.e if the value definition
* of <tn> is VAL_KNOWN, VAL_UNKNOWN, VAL_COND_DEF, VAL_COND_USE, .. etc.
*
* Note that not all reaching definitions are found, dominator
* information is necessary to handle more cases and it's not
* proven to be worth it.
*
>seems like it is trying to find the unique instruction that defines or
>uses the value of a TN from a given position by tracing through OP lists
>and BB lists. However, there are questionable lines with comments like:
> if (cur_bb == bb) continue; // ignore self successor
>which seem to indicate that definitions or uses inside single block
>loops are skipped. Why is this done?
I originally wrote this function because I was trying to do some simple
optimizations (detecting division by constant for example). Others
(no longer with sgi) greatly enhanced it for their purposes, so I no
longer fully understand it either.
I would have to assume however that the check for a self successor
is to avoid endlessly re-examining the same BB.
Ken
|