25 #include "pips_config.h"
97 #include "constants.h"
101 #define LABEL_TABLES_SIZE 10
150 #define ADD_PRED_IF_NOT_ALREADY_HERE(pred,c) (gen_once(pred,control_predecessors(c)))
151 #define ADD_PRED_AND_COPY_IF_NOT_ALREADY_HERE(pred,c) (gen_once(pred,gen_copy_seq(control_predecessors(c))))
161 #define UPDATE_CONTROL(c,s,pd,sc) { \
162 control_statement(c)=s; \
163 MAPL(preds, {control_predecessors(c) = \
164 ADD_PRED_IF_NOT_ALREADY_HERE(CONTROL(CAR(preds)), c);}, \
167 gen_free_list( control_successors(c));\
168 control_successors(c)=sc; \
171 #define PREDS_OF_SUCCS 1
172 #define SUCCS_OF_PREDS 2
287 hash_put(used_labels, name, new_sts);
288 debug(5,
"update_used_labels",
"Reference to statement %d seen\n",
351 pips_debug(5,
"does not cover label %s\n", (
char *) name);
359 fprintf(stderr,
"covers its label usage\n");
406 "a test control node may have one or two successors",
430 pips_debug(5,
"(st = %p, pred = %p, succ = %p, c_res = %p)\n",
431 st, pred, succ, c_res);
491 " with exit had to be desugared\n",
549 pips_debug(5,
"(st = %p, pred = %p, succ = %p, c_res = %p)\n",
550 st, pred, succ, c_res);
652 "with GO TO exit had to be desugared\n",
660 " with GO TO exit had to be desugared\n",
703 pips_debug(5,
"(st = %p, pred = %p, succ = %p, c_res = %p)\n",
704 st, pred, succ, c_res);
833 bool controlized =
false;
836 pips_debug(5,
"(st = %p, pred = %p, succ = %p, c_res = %p)\n",
837 st, pred, succ, c_res);
979 statement s_above = scoping_statement_nth(2);
980 pips_debug(2,
"Dealing with block statement %p included into block"
981 " statement %p\n", s, s_above);
998 pips_debug(2,
"Comparing variables %s and %s\n",
1001 if (strcmp(name, name_above) == 0) {
1044 }, old_to_new_variables);
1067 set processed_nodes;
1072 pips_debug(5,
"Begin with list c_end %p, ctls:", c_end);
1087 for(ctls =
CDR(ctls); !
ENDP(ctls); ctls =
CDR(ctls)) {
1088 cons *succs, *succs_of_succ;
1122 pips_assert(
"st is a block or a continue or st carries no delarations",
1145 pips_debug(2,
"Do not fuse control %p since we will have a latent goto on it through label \"%s\"\n",
1153 "same label points towards two different controls");
1178 " which is not a block nor a continue!\n",
1195 pips_debug(8,
"Free statement %p with identification %s from control succ %p\n",
1209 pips_assert(
"control succ and its statement are consistent",
1217 if(succ == c_last) {
1256 for(; !
ENDP(sts); sts =
CDR(sts)) {
1266 pips_debug(5,
"Nodes linked with pred %p:\n", pred);
1278 controlized =
controlize(st, pred, c_next, c_res, used_labels);
1313 pred = (unreachable) ?
1334 pips_debug(5,
"(pred = %p, succ = %p, c_res = %p)\n",
1340 pips_debug(5,
"Nodes from c_res %p\n", c_res);
1371 bool hierarchized_labels;
1374 pips_debug(5,
"Begin with (st = %p, pred = %p, succ = %p, c_res = %p)\n",
1375 st, pred, succ, c_res);
1377 pips_debug(8,
"\nControl nodes linked to pred = %p:\n", pred);
1434 if (!hierarchized_labels) {
1449 pips_debug(5,
"Nodes from c_block %p\n", c_block);
1451 pips_debug(5,
"Nodes from c_last %p\n", c_last);
1460 if (hierarchized_labels) {
1485 pips_assert(
"the declarations are carried by a block",
1488 pips_debug(8,
"Block declarations to copy: ");
1592 controlized =
false;
1595 pips_debug(2,
"There are goto to/from outside this statement list\n");
1623 pips_debug(5,
"Exiting with controlized = %s\n",
1627 pips_debug(8,
"\nNodes linked to pred %p\n", pred);
1642 return(controlized);
1668 pips_debug(5,
"Entering (st = %p, pred = %p, succ = %p, c_res = %p)\n",
1669 st, pred, succ, c_res);
1685 controlize(s_t, c_res, c_join, c1, t_used_labels);
1690 controlize(s_f, c_res, c_join, c2, f_used_labels);
1717 controlized =
false;
1762 return(controlized);
1786 pips_debug(8,
"control %p allocated for label \"%s\"", c, name);
1853 pips_debug(4,
"Accessible nodes from top:\n");
1856 pips_debug(1,
"Accessible nodes from bottom:\n");
1859 pips_debug(1,
"Accessible nodes from res:\n");
1888 pips_assert(
"The successor of \"top\" is \"res\"",
1978 bool controlized =
false;
1983 "Begin with (st = %p, pred = %p, succ = %p, c_res = %p)\n"
1985 st, pred, succ, c_res);
1996 pips_debug(1,
"Begin with result c_res %p:\n", c_res);
2019 scoping_statement_push(st);
2021 pred, succ, c_res, used_labels);
2027 pips_debug(1,
"CFG consistency check before list6 controlization."
2028 " Control \"pred\" %p:\n", pred);
2030 pips_debug(1,
"Control \"succ\" %p:\n", succ);
2044 scoping_statement_pop();
2053 pred, succ, c_res, used_labels);
2060 pred, succ, c_res, used_labels);
2067 pred, succ, c_res, used_labels);
2086 pips_debug(1,
"CFG consistency check before goto controlization."
2087 " Control \"pred\" %p:\n", pred);
2089 pips_debug(1,
"Control \"n_succ\" %p:\n", n_succ);
2128 pips_assert(
"We are really dealing with a for loop",
2131 pred, succ, c_res, used_labels);
2164 pips_debug(1,
"Resulting Control c_res %p at exit:\n", c_res);
2185 return(controlized);
2226 make_scoping_statement_stack();
2229 (void)
controlize(st, top, bottom, result, used_labels);
2232 free_scoping_statement_stack();
2256 "Nodes in unstructured %p (entry %p, exit %p) from entry:\n",
2259 pips_debug(1,
"Accessible nodes from exit:\n");
unstructured make_unstructured(control a1, control a2)
call make_call(entity a1, list a2)
bool unstructured_consistent_p(unstructured p)
instruction make_instruction_forloop(forloop _field_)
expression make_expression(syntax a1, normalized a2)
whileloop make_whileloop(expression a1, statement a2, entity a3, evaluation a4)
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
void free_control(control p)
list gen_entity_cons(entity p, list l)
instruction make_instruction_expression(expression _field_)
control check_control(control p)
expression copy_expression(expression p)
EXPRESSION.
bool statement_consistent_p(statement p)
test make_test(expression a1, statement a2, statement a3)
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
instruction make_instruction_sequence(sequence _field_)
instruction make_instruction(enum instruction_utype tag, void *val)
bool control_consistent_p(control p)
syntax make_syntax(enum syntax_utype tag, void *val)
synchronization make_synchronization_none(void)
extensions copy_extensions(extensions p)
EXTENSIONS.
control make_control(statement a1, list a2, list a3)
void free_statement(statement p)
forloop make_forloop(expression a1, expression a2, expression a3, statement a4)
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
sequence for_to_do_loop_conversion(forloop, statement)
Try to convert a C-like for-loop into a Fortran-like do-loop.
sequence for_to_while_loop_conversion(expression, expression, expression, statement, extensions)
Build a sequence with a while-loop from for-loop parameters.
static string c_test(test t, bool breakable)
bool return_label_p(const char *s)
bool empty_global_label_p(const char *gln)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_recurse(start, domain_number, flt, rwt)
statement make_block_statement(list)
Make a block statement from a list of statement.
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
statement make_empty_statement_with_declarations_and_comments(list, string, string)
Build an empty statement with declaration list, declaration text and comment.
void unlink_2_control_nodes(control source, control target)
Remove all edged between 2 control nodes.
void display_linked_control_nodes(control c)
Display all the control nodes reached or reachable from c for debugging purpose.
void display_address_of_control_nodes(list cs)
Display the adresses a list of control nodes.
void link_2_control_nodes(control source, control target)
Add an edge between 2 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 check_control_coherency(control c)
Test the coherency of a control node network from a control node.
statement loop_header(statement sl)
LOOP_HEADER, LOOP_TEST and LOOP_INC build the desugaring phases of a do-loop L for the loop header (i...
static bool controlize_call(statement st, control pred, control succ, control c_res)
CONTROLIZE_CALL controlizes the call C of statement ST in C_RES.
statement loop_test(statement sl)
static statement whileloop_test(statement sl)
Generate a test statement ts for exiting loop sl.
static hash_table Label_control
LABEL_CONTROL maps label names to their (possible forward) control nodes.
unstructured control_graph(statement st)
CONTROL_GRAPH returns the control graph of the statement ST.
static control compact_list(list ctls, control c_end)
Take a list of controls ctls coming from a controlize_list() and compact the successive statements,...
statement forloop_header(statement sl)
static bool controlize_forloop(statement st, forloop l, control pred, control succ, control c_res, hash_table used_labels)
static list Unreachable
UNREACHABLE is the hook used as a predecessor of statements that are following a goto.
static list controlize_list_1(list sts, control i_pred, control i_succ, control i_c_res, hash_table used_labels)
Do the equivalent of a mapcar of controlize on statement list sts.
static void init_label(string name, statement st)
INIT_LABEL puts the reference in the statement ST to the label NAME int the Label_statements table an...
statement forloop_inc(statement sl)
static void create_statements_of_labels(st)
static hash_table Label_statements
LABEL_STATEMENTS maps label names to the list of statements where they appear (either as definition o...
statement loop_inc(statement sl)
#define ADD_PRED_AND_COPY_IF_NOT_ALREADY_HERE(pred, c)
static bool controlize_test(statement st, test t, control pred, control succ, control c_res, hash_table used_labels)
Builds the control node of a statement st in c_res which is a test statement t.
static void add_proper_successor_to_predecessor(control pred, control c_res)
static bool controlize_whileloop(statement st, whileloop l, control pred, control succ, control c_res, hash_table used_labels)
CONTROLIZE_WHILELOOP computes in C_RES the control graph of the loop L (of statement ST) with PREDece...
#define ADD_PRED_IF_NOT_ALREADY_HERE(pred, c)
In C, we can have some "goto" inside a block from outside, that translate as any complex control grap...
#define LABEL_TABLES_SIZE
statement forloop_test(statement sl)
static bool controlize(statement st, control pred, control succ, control c_res, hash_table used_labels)
Computes in c_res the control node of the statement st whose predecessor control node is pred and suc...
static bool controlize_loop(statement st, loop l, control pred, control succ, control c_res, hash_table used_labels)
CONTROLIZE_LOOP computes in C_RES the control graph of the loop L (of statement ST) with PREDecessor ...
static void patch_references(int how, control fnode, control tnode)
PATCH_REFERENCES replaces all occurrences of FNODE by TNODE in the predecessors or successors lists o...
#define UPDATE_CONTROL(c, s, pd, sc)
Update control c by setting its statement to s, by unioning its predecessor set with pd,...
static unstructured simplified_unstructured(control top, control bottom, control res)
SIMPLIFIED_UNSTRUCTURED tries to get rid of top-level and useless unstructured nodes.
static bool controlize_list(statement st, list sts, control pred, control succ, control c_res, hash_table used_labels)
Computes in c_res the control graph of the list sts (of statement st) with pred predecessor and succ ...
void replace_entity(void *s, entity old, entity new)
per variable version of replace_entities.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
bool return_instruction_p(instruction i)
Test if an instruction is a C or Fortran "return".
#define ENDP(l)
Test if a list is empty.
list gen_nreverse(list cp)
reverse a list in place
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
#define NIL
The empty list (nil in Lisp)
list gen_once(const void *vo, list l)
Prepend an item to a list only if it is not already in the list.
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
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_full_copy_list(list l)
Copy a list structure with element copy.
loop statement_loop(statement)
Get the loop of a statement.
bool statement_test_p(statement)
statement make_assign_statement(expression, expression)
string statement_identification(statement)
Like external_statement_identification(), but with internal information, the hexadecimal address of t...
bool continue_statement_p(statement)
Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
statement make_continue_statement(entity)
void fix_statement_attributes_if_sequence(statement)
Apply fix_sequence_statement_attributes() on the statement only if it really a sequence.
bool empty_comments_p(const char *)
statement normalize_statement(statement)
Make (a bit more) sure that s is gen_defined_p in spite of poor decision for empty fields and that st...
statement make_plain_continue_statement(void)
Make a simple continue statement to be used as a NOP or ";" in C.
string comment_sentinel(tag)
Start a single line comment.
hash_table hash_table_make(hash_key_type key_type, size_t size)
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.
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
void hash_update(hash_table htp, const void *key, const void *val)
update key->val in htp, that MUST be pre-existent.
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
list hash_get_default_empty_list(const hash_table h, const void *k)
Like hash_get() but returns an empty list instead of HASH_UNDEFINED_VALUE when a key is not found.
struct _newgen_struct_control_ * control
enum language_utype get_prettyprint_language_tag()
#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
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
string bool_to_string(bool)
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define DEFINE_LOCAL_STACK(name, type)
#define HASH_MAP(k, v, code, ht)
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
#define hash_put_or_update(h, k, v)
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 *)
#define string_undefined_p(s)
char vcid_control_old_controlizer[]
old_controlizer.c
static control make_conditional_control(statement st)
Make a control node from a statement if needed.
static bool covers_labels_p(statement st, hash_table used_labels)
Compute whether all the label references in a statement are in a given label name to statement list m...
static void update_used_labels(hash_table used_labels, string name, statement st)
Add the reference to the label NAME in the statement ST.
static void create_statements_of_label(statement st)
CREATE_STATEMENTS_OF_LABELS gathers in the Label_statements table all the references to the useful la...
static void move_declaration_control_node_declarations_to_statement(list ctls)
Move all the declarations found in a list of control to a given statement.
static control get_label_control(string name)
Get the control node associated to a label name.
static hash_table union_used_labels(hash_table l1, hash_table l2)
Unions 2 used-label hash maps.
text statement_to_text(statement)
void set_bool_property(const char *, bool)
void reset_unstructured_number()
Reset the unstructured number for a new module reordering.
bool unstructured_reorder(unstructured u)
Reorder an unstructured.
#define instruction_block_p(i)
#define GREATER_THAN_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define statement_block_p(stat)
#define STATEMENT_NUMBER_UNDEFINED
default values
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define C_NOT_OPERATOR_NAME
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define empty_comments
Empty comments (i.e.
#define NOT_OPERATOR_NAME
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
bool same_entity_p(entity e1, entity e2)
predicates on entities
entity entity_to_module_entity(entity e)
Find the enclosing module of an entity.
entity entity_empty_label(void)
void print_entities(list l)
bool entity_empty_label_p(entity e)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
const char * label_local_name(entity e)
END_EOLE.
expression make_entity_expression(entity e, cons *inds)
bool empty_extensions_p(extensions es)
extensions empty_extensions(void)
extension.c
entity clone_variable_with_unique_name(entity, statement, string, string, entity)
Clone a variable with a new user name.
#define normalized_undefined
#define control_undefined
#define loop_execution(x)
#define forloop_initialization(x)
#define extensions_undefined_p(x)
#define control_predecessors(x)
#define forloop_increment(x)
#define instruction_loop(x)
#define instruction_goto(x)
#define whileloop_evaluation(x)
#define unstructured_undefined
#define statement_domain
newgen_sizeofexpression_domain_defined
#define instruction_undefined_p(x)
#define CONTROL(x)
CONTROL.
#define range_increment(x)
#define EXPRESSION(x)
EXPRESSION.
#define instruction_forloop_p(x)
#define instruction_undefined
#define statement_label(x)
#define expression_undefined
@ is_instruction_unstructured
@ is_instruction_whileloop
@ is_instruction_expression
@ is_instruction_multitest
#define instruction_tag(x)
#define whileloop_label(x)
#define statement_extensions(x)
#define instruction_forloop(x)
#define control_successors(x)
#define control_undefined_p(x)
#define unstructured_exit(x)
#define instruction_unstructured_p(x)
#define test_condition(x)
#define instruction_whileloop(x)
#define whileloop_body(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define statement_comments(x)
#define statement_decls_text(x)
#define forloop_condition(x)
#define extensions_extension(x)
#define control_statement(x)
#define instruction_test(x)
#define statement_undefined_p(x)
#define whileloop_condition(x)
#define statement_number(x)
#define sequence_undefined_p(x)
#define instruction_unstructured(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
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.
string text_to_string(text t)
SG: moved here from ricedg.