25 #include "pips_config.h"
260 while(!
ENDP(frontier)) {
270 frontier = new_frontier;
434 controls_to_change =
gen_nconc(controls_to_change,
439 pips_debug(8,
"Transfer old node %p to new node %p in successor %p\n", old_node, new_node, c);
458 }, controls_to_change);
463 controls_to_change =
NIL;
467 controls_to_change =
gen_nconc(controls_to_change,
472 pips_debug(8,
"Transfer old node %p to new node %p in predecessor %p\n", old_node, new_node, c);
474 }, controls_to_change);
503 pips_debug(0,
"Control node %p not in the predecessor list of %p\n", ctl, cc);
506 pips_debug(0,
"Control %p occurs %d times in the predecessor list of %p"
507 " while control %p occurs %d times in the successor list of %p\n",
508 ctl, i1, cc, cc, i2, ctl);
520 bool consistent_p =
false;
522 pips_debug(0,
"Control node %p not in the successor list of %p\n", ctl, cc);
529 pips_debug(0,
"Control %p occurs %d times in the successor list of %p"
530 " while control %p occurs %d times in the predecessor list of %p\n",
531 ctl, i1, cc, cc, i2, ctl);
536 pips_debug(8,
"control %p is not correct\n", cc);
550 pips_assert(
"each statement appears in at most one control node",
false);
569 "ctr %p, %zd preds, %zd succs: %s",
574 fprintf(stderr,
"\tsuccessors:\n");
576 fprintf(stderr,
"\t\t%p %s", s,
579 fprintf(stderr,
"\tpredecessors:\n");
581 fprintf(stderr,
"\t\t%p %s", p,
592 fprintf(stderr,
"empty control list");
635 fprintf(stderr,
"%p (pred (#%zd)=", ctl,
648 fprintf(stderr,
"Statement %p is pointed by two different control nodes\n",
684 control do_not_delete_node_either)
689 if (c == do_not_delete_node || c == do_not_delete_node_either)
710 do_not_delete_node_either);
715 pips_debug(7,
"Discarding control node %p.\n", c);
733 list control_remove_list =
NIL;
738 bool exit_node_has_been_seen =
false;
739 pips_debug(7,
"From control %p, exit %p.\n", entry_node, exit_node);
752 pips_debug(7,
"Want to discard control %p.\n", c);
755 control_remove_list);
760 exit_node_has_been_seen =
true;
771 control_remove_list);
774 if (!exit_node_has_been_seen) {
778 control_remove_list =
NIL;
788 control_remove_list);
799 control_remove_list);
822 pips_debug(7,
"From control %p, exit %p.\n", entry_node, exit_node);
829 pips_debug(5,
"Forward visiting control node %p.\n", c);
841 pips_debug(5,
"Testing control node %p.\n", c);
843 pips_debug(5,
"Adding to the removing list control node %p.\n", c);
845 unreachable_controls,
857 pips_debug(5,
"Testing from exit control node %p.\n", c);
859 pips_debug(5,
"From exit node: Adding to the removing list control node %p.\n", c);
861 unreachable_controls,
872 if (c == exit_node) {
873 pips_debug(5,
"Skipping discarding exit control node %p.\n", c);
876 pips_debug(5,
"Discarding control node %p.\n", c);
880 "Try to use the GATHER_FORMATS_AT_BEGINNING "
885 unreachable_controls);
914 list a_source_control_list_of_c,
915 list a_dest_control_list_of_c,
920 list *the_dest_of_a_source_list = NULL;
922 list the_position_before_c =
NIL;
936 pips_assert(
"remove_a_control_from_a_list_and_relink with not a good \"which_way\".\n",
false);
940 the_position_before_c =
NIL;
944 if (
CONTROL(
CAR(the_position_of_c = a_list)) == c)
946 the_position_before_c = the_position_of_c;
948 *the_dest_of_a_source_list);
953 l =
gen_append(a_dest_control_list_of_c,
CDR(the_position_of_c));
957 if (the_position_before_c ==
NIL)
959 *the_dest_of_a_source_list = l;
961 CDR(the_position_before_c) = l;
964 CDR(the_position_of_c) =
NIL;
967 a_source_control_list_of_c);
997 int number_of_successors =
gen_length(the_successors);
1002 pips_assert(
"remove_a_control_from_an_unstructured:"
1003 " no more than one successor",
1004 number_of_successors <= 1);
1039 }, the_predecessors);
1047 pips_assert(
"The control node should not have any connection here,",
1115 list successor_list;
1132 for(c = begin; ; c =
CONTROL(
CAR(successor_list))) {
1136 pips_assert(
"discard_a_control_sequence_without_its_statements: not a sequence.",
gen_length(successor_list) <= 1);
1160 list the_statements_of_the_sequence =
NIL;
1167 pips_assert(
"discard_a_control_sequence_without_its_statements: not a sequence.", number_of_predecessor <= 1);
1172 the_statements_of_the_sequence);
1177 return the_statements_of_the_sequence;
1309 pips_assert(
"c is not already a successor of before",
1352 pips_assert(
"after and before were linked", success1 && success2);
1353 pips_debug(8,
"control %p inserted between before=%p and after=%p\n",
1401 string first_comment =
void free_control(control p)
bool statement_consistent_p(statement p)
void free_unstructured(unstructured p)
bool control_consistent_p(control p)
static string c_test(test t, bool breakable)
void remove_some_unreachable_controls_of_an_unstructured(unstructured u)
Remove all the control sequences that are unreachable and that begin with a node without any predeces...
void insert_control_in_arc(control c, control before, control after)
Insert a control node between 2 connected control nodes.
void unlink_2_control_nodes(control source, control target)
Remove all edged between 2 control nodes.
void remove_all_unreachable_controls_of_an_unstructured(unstructured u)
Remove all control nodes that are not forward reachable from the entry node.
void display_linked_control_nodes(control c)
Display all the control nodes reached or reachable from c for debugging purpose.
void transfer_control_successor(control old_node, control new_node, control c)
Transfer a control node as a successor of one node to another one.
void display_address_of_control_nodes(list cs)
Display the adresses a list of control nodes.
void remove_a_control_from_a_list_and_relink(control c, list a_source_control_list_of_c, list a_dest_control_list_of_c, remove_a_control_from_a_list_and_relink_direction which_way)
Replace each occurence of c in a_source_control_list_of_c with a a_dest_control_list_of_c:
void remove_unreachable_following_control(control c, control do_not_delete_node, control do_not_delete_node_either)
Remove all the control nodes (with their statements) from c in the successor tree of c up to the node...
void link_3_control_nodes(control c_test, control c_then, control c_else)
Add an edge between 2 control nodes.
void link_2_control_nodes(control source, control target)
Add an edge between 2 control nodes.
void print_control_node(control c)
void remove_a_control_from_an_unstructured_without_relinking(control c)
It removes a control node from its successor and predecessor.
void transfer_control_predecessor(control old_node, control new_node, control c)
Transfer a control node as a predecessor from one node to another one.
void discard_an_unstructured_without_its_statements(unstructured u)
Used to discard an unstructured without touching its statements.
void replace_control_related_to_a_list(control old_node, control new_node, list controls)
Replace all the references to a control node by a new one in the successors & predecessors of a list ...
bool is_control_in_list_p(control c, list cs)
Test if a control node is in a list of control nodes.
void free_a_control_without_its_statement(control c)
Remove a control node without touching its statement, its predecessors and successors,...
void remove_a_control_from_an_unstructured(control c)
Remove a control node from a control graph.
void control_list_patch(list l, control c_old, control c_new)
Replace in a list of control nodes all the instance of a control node by another one.
void discard_a_control_sequence_without_its_statements(control begin, control end)
Remove a control sequence without touching its statements.
void print_control_nodes(list l)
Display identification of a list of control nodes.
void fuse_2_control_nodes(control first, control second)
Fuse a 2 control nodes.
void check_control_coherency(control c)
Test the coherency of a control node network from a control node.
list generate_a_statement_list_from_a_control_sequence(control begin, control end)
Take a control sequence and return a list of all the statements in the sequence (in the same order....
int occurences_in_control_list(control c, list cs)
Count the number of occurences of a control node in a list of control nodes.
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
void forward_control_map_get_blocs(c, l)
Build recursively the list of all controls forward-reachable from a control of an unstructured.
void backward_control_map_get_blocs_but(control c, control f, list *l)
Transitive closure of c's predecessors, but for control f.
void control_map_get_blocs(control c, list *l)
Build recursively the list of all controls reachable from a control of an unstructured.
void forward_control_map_get_blocs_but(control c, control f, list *l)
Transitive closure of c's successors, but for control f.
#define FORWARD_CONTROL_MAP(ctl, code, c, list)
Walk through all the controls forward-reachable from a given control node of an unstructured.
void find_a_control_path(control b, control e, list *pp, list *vp, int dir)
Build recursively a control path from b to e.
void backward_control_map_get_blocs(c, l)
Build recursively the list of all controls backward-reachable from a control of an unstructured.
void wide_forward_control_map_get_blocs(c, l)
Same as above, but follows successors by minimal path lengths.
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
#define ENDP(l)
Test if a list is empty.
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
#define NIL
The empty list (nil in Lisp)
list gen_copy_seq(list l)
Copy a list structure.
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
list gen_last(list l)
Return the last element of a list.
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
list gen_append(list l1, const list l2)
int gen_occurences(const void *vo, const list l)
count occurences of vo in l
void gen_list_patch(list l, const void *x, const void *y)
Replace all the reference to x in list l by a reference to y:
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
bool gen_replace_in_list(list l, const void *s, const void *t)
substitute all item s by t in list l
bool statement_test_p(statement)
entity statement_to_label(statement)
See if statement s is labelled and can be reached by a GO TO.
void insert_comments_to_statement(statement, const char *)
Insert a comment string (if non empty) at the beginning of the comments of a statement.
string safe_statement_identification(statement)
string gather_all_comments_of_a_statement(statement)
Gather all the comments recursively found in the given statement and return them in a strduped string...
bool format_inside_statement_p(statement)
struct _newgen_struct_control_ * control
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define SET_MAP(element, code, the_set)
bool set_belong_p(const set, const void *)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
remove_a_control_from_a_list_and_relink_direction
For the control graph modifiers:
@ source_is_predecessor_and_dest_is_successor
Put some strange number to avoid random clash as much as possible...
@ source_is_successor_and_dest_is_predecessor
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define make_empty_statement
An alias for make_empty_block_statement.
char vcid_ri_util_control[]
Some utilities to deal with the control graph.
bool entity_empty_label_p(entity e)
#define control_predecessors(x)
#define CONTROL(x)
CONTROL.
#define statement_label(x)
#define control_successors(x)
#define unstructured_exit(x)
#define statement_instruction(x)
#define control_statement(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
A gen_chunk is used to store every object.