PIPS
NewGen inheritance tracking during visiting object

Methods to get parent information constructed during recursion. More...

+ Collaboration diagram for NewGen inheritance tracking during visiting object:

Functions

gen_chunkgen_get_recurse_previous_visited_object (void)
 Get the previously visited object. More...
 
gen_chunkgen_get_recurse_current_ancestor (void)
 Get the ancestor of the current object. More...
 
gen_chunkgen_get_recurse_ancestor (const void *object)
 Get the first ancestor object encountered during the recursion for the given object. More...
 
gen_chunkgen_get_ancestor (int type, const void *obj)
 return the first ancestor object found of the given type. More...
 
gen_chunkgen_get_current_object (void)
 return the current visited object, or NULL if not in a recursion. More...
 
gen_chunkgen_get_current_ancestor (int type)
 Return current object of that type... More...
 

Detailed Description

Methods to get parent information constructed during recursion.

To have example of usage, have a look at the caller-graph in the Doxygen documentation of its functions, for example gen_get_recurse_ancestor(), that will point you to phases such as try_to_recover_for_loop_in_a_while().

Function Documentation

◆ gen_get_ancestor()

gen_chunk* gen_get_ancestor ( int  type,
const void *  obj 
)

return the first ancestor object found of the given type.

Parameters
typenewgen domain of the ancestor looked for.
objectwe want the ancestor of.
Returns
NULL if the root is reached without finding the said type

maybe it could move the search in the upper recursion if any...

Definition at line 3560 of file genClib.c.

3561 {
3562  message_assert("in a recursion", current_mrc!=NULL);
3563  while (true)
3564  {
3565  gen_chunk * prev = hash_get(current_mrc->seen, obj);
3566  message_assert("some ancestor or NULL", prev!=HASH_UNDEFINED_VALUE);
3567  if (prev==NULL)
3568  return NULL;
3569  else if (prev->i == type)
3570  return prev;
3571  obj = prev;
3572  }
3573 }
static struct multi_recurse * current_mrc
the current multi recurse driver.
Definition: genClib.c:3137
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
hash_table seen
Definition: genClib.c:3111
A gen_chunk is used to store every object.
Definition: genC.h:58
_int i
Definition: genC.h:62

References current_mrc, hash_get(), HASH_UNDEFINED_VALUE, gen_chunk::i, message_assert, and multi_recurse::seen.

Referenced by add_loop_parallel_threshold(), build_outer(), call_flt(), check_ref(), compute_cumulated_reductions(), do_check_isolate_statement_preconditions_on_call(), do_delay_communications_interprocedurally(), do_grouping_filter_out_self(), do_loop_nest_unswitching(), do_outliner_smart_replacment(), do_remove_redundant_communications_in_forloop(), do_remove_redundant_communications_in_loop(), do_remove_redundant_communications_in_whileloop(), entity_from_user_name(), find_loop_from_label_walker(), find_pragma(), fsi_stmt_flt(), gen_get_current_ancestor(), inline_statement_crawler(), inner_rewrite(), insert_optional_pragma(), isolate_patch_reference(), live_in_paths_of_loop(), live_in_paths_of_whileloop(), live_out_paths_from_call_site_to_callee(), live_out_paths_from_forloop_to_body(), live_out_paths_from_loop_to_body(), live_out_paths_from_test_to_branches(), live_out_paths_from_unstructured_to_nodes(), live_out_paths_from_whileloop_to_body(), live_paths_from_block_to_statements(), loop_annotate(), loop_push(), reference_written_p(), rename_reference(), replace_entities_expression_walker(), rssp_ref(), simplify_subscript(), statement_filter(), statement_purge_declarations_walker(), and subtsitute_variable_in_reference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_get_current_ancestor()

gen_chunk* gen_get_current_ancestor ( int  type)

Return current object of that type...

or NULL if none found

Definition at line 3587 of file genClib.c.

3588 {
3590  return current? gen_get_ancestor(type, current): NULL;
3591 }
gen_chunk * gen_get_current_object(void)
return the current visited object, or NULL if not in a recursion.
Definition: genClib.c:3580
gen_chunk * gen_get_ancestor(int type, const void *obj)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
static size_t current
Definition: string.c:115

References current, gen_get_ancestor(), and gen_get_current_object().

Referenced by glc_call(), glc_cast(), and glc_ref().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_get_current_object()

gen_chunk* gen_get_current_object ( void  )

return the current visited object, or NULL if not in a recursion.

Ok, we should have it, but its name may not be known in a macro, or deep in a called function...

Definition at line 3580 of file genClib.c.

3581 {
3582  return current_mrc? current_mrc->current: NULL;
3583 }
gen_chunk * current
Definition: genClib.c:3129

References multi_recurse::current, and current_mrc.

Referenced by gen_get_current_ancestor().

+ Here is the caller graph for this function:

◆ gen_get_recurse_ancestor()

gen_chunk* gen_get_recurse_ancestor ( const void *  object)

Get the first ancestor object encountered during the recursion for the given object.

The heritage relation is built during the top-down phase (the filter-down phase), so if the objects are rewriten during the top-down rewriting phase (that should never happend, rewrite should be performed on the bottom-up pass, when the "rewrite" function is called), the heritage relation are not up-to-date for these objects.

is the object we want the ancestor

Returns
the object parent. If it fails, it returns:
  • NULL if the current object is the root of the recursion (so no parent)
  • HASH_UNDEFINED_VALUE if the current object does not have any ancestor.

Definition at line 3546 of file genClib.c.

3547 {
3548  message_assert("in a recursion", current_mrc!=NULL);
3549  return (gen_chunk *) hash_get(current_mrc->seen, object);
3550 }

References current_mrc, hash_get(), message_assert, and multi_recurse::seen.

Referenced by replace_field_by_reference_walker(), transform_a_for_loop_into_a_while_loop(), and try_to_transform_a_for_loop_into_a_do_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_get_recurse_current_ancestor()

gen_chunk* gen_get_recurse_current_ancestor ( void  )

Get the ancestor of the current object.

Returns
the ancestor of the current object. If it fails to do it, it returns:
  • NULL if the current object is the root of the recursion (since it does not have any parent inside the reduction scope)

Definition at line 3526 of file genClib.c.

3527 {
3528  message_assert("in a recursion", current_mrc!=NULL);
3529  return stack_head(current_mrc->upwards);
3530 }
void * stack_head(const stack)
returns the item on top of stack s
Definition: stack.c:420
stack upwards
Definition: genClib.c:3125

References current_mrc, message_assert, stack_head(), and multi_recurse::upwards.

Referenced by if_conv_init_statement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_get_recurse_previous_visited_object()

gen_chunk* gen_get_recurse_previous_visited_object ( void  )

Get the previously visited object.

Returns
the previously visited object

It may be a sibling, a parent, or an child.

Definition at line 3513 of file genClib.c.

3514 {
3515  message_assert("in a recursion", current_mrc!=NULL);
3516  return current_mrc->previous;
3517 }
gen_chunk * previous
Definition: genClib.c:3127

References current_mrc, message_assert, and multi_recurse::previous.