PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "ri-util.h"
#include "control.h"
Go to the source code of this file.
Functions | |
bool | unstructured_consistency_p (unstructured u, bool assert_p) |
Basic functions about control flow graphs (CFG), aka unstructured data structure. More... | |
bool | unstructured_while_p (unstructured u) |
Test if an unstructured is found to be like a structured while-loop. More... | |
bool unstructured_consistency_p | ( | unstructured | u, |
bool | assert_p | ||
) |
Basic functions about control flow graphs (CFG), aka unstructured data structure.
Francois Irigoin, 1997. Check some nice properties expected to be true after a powerful enough controlizer phase.
The calls to pips_assert could be replaced by calls to user_warning, the control graph could be printed out before core dumping,...
See also check_control_coherency().
the exit and entry nodes must be different or the unstructured would have been reduced to one structured statement
The entry node must have at least one predecessor: else it should have been moved out of the unstructured. Note that it has in fact TWO predecessors since it is the unstructured entry point.
The exit node should have no successors: its real successor is the statement following the unstructured
The exit node should not be a test: else one of its successors should be control_undefined since it would be outside of the unstructured, or the exit condition would be unknown.
The exit node may have no predecessor because an infinite loop appears in the code. Or it is a successor of the entry node.
RK: ??? If the exit node is unreachable, it should be a CONTINUE Since a CONTINUE has no effects, it does not perturb analyses even if they do not check reachability. RK: The NOP might be the empty sequence instead of a CONTINUE?
If the exit node has only one predecessor, it should be a test or the exit node would have been moved outside of the unstructured.
Since sequences are merged into a unique node, if a node c1 has only one successor c2, and if c2 has only one predecessor c3, c3 must be c1 and either c1 is the exit node which is impossible because there would be no exit condition and the exit node would have a successor, c2, or c2 is the entry node. So c2 must be the entry node.
Well, this is not true because only tests can have two successors. hence, a test node cannot be merged.
assert_p | ssert_p |
Definition at line 52 of file cfg.c.
References CAR, continue_statement_p(), CONTROL, control_predecessors, control_statement, control_successors, display_linked_control_nodes(), ENDP, forward_control_map_get_blocs(), fprintf(), gen_find_eq(), gen_free_list(), gen_length(), MAP, NIL, pips_assert, statement_test_p(), unstructured_control, and unstructured_exit.
Referenced by unstructured_while_p().
bool unstructured_while_p | ( | unstructured | u | ) |
Test if an unstructured is found to be like a structured while-loop.
Make sure that the unstructured has been "normalized"
while_p = unstructured_consistency_p(u, true);
An unstructured is a while loop if and only if the exit node has only one predecessor and if the entry node is a successor of the predecessor of the exit node.
A loop with two exit conditions is not recognized as a while loop.
A loop with an exit test on entry, a final exit test (do...while) or an exit test anywhere is recognized as a while loop.
Definition at line 191 of file cfg.c.
References bool_to_string(), CAR, CONTROL, control_predecessors, debug(), display_linked_control_nodes(), forward_control_map_get_blocs(), fprintf(), gen_find_eq(), gen_free_list(), gen_length(), ifdebug, NIL, unstructured_consistency_p(), unstructured_control, and unstructured_exit.
Referenced by instruction_flt(), and instruction_rwt().