PIPS
Statement predicate methods

detects a statement with no special effect... More...

+ Collaboration diagram for Statement predicate methods:

Modules

 Direct test of the instruction
 type of statement
 
 Block/sequence statement constructors
 
 Direct statement accessors to
 second level fields
 

Data Structures

struct  add_statement_declarations_t
 
struct  entities_t
 
struct  fswl
 structure used by find_statements_with_label_walker More...
 
struct  fswp
 used to pass parameters to find_statements_with_comment_walker More...
 
struct  sb
 
struct  replace_statement_context
 

Macros

#define ERROR_PREFIX   "!ERROR: "
 as name indicate, a comment is added. More...
 
#define BUFSIZE   1024
 
#define PIPS_DECLARATION_COMMENT   "PIPS generated variable\n"
 
#define MAX_COMMENTERS   8
 

Typedefs

typedef string(* generated_variable_commenter) (entity)
 commenters are function used to add comments to pips-created variables they are handled as a limited size stack all commenters are supposed to return allocated data More...
 

Functions

static bool cannot_be_empty (bool *statement_is_empty)
 
static bool call_filter (call c, bool *statement_is_empty)
 
bool empty_code_p (statement s)
 statement.c More...
 
bool empty_code_list_p (list l)
 
bool empty_comments_p (const char *s)
 
bool comments_equal_p (string c1, string c2)
 
bool statement_with_empty_comment_p (statement s)
 Return true if the statement has an empty statement: More...
 
bool assignment_statement_p (statement s)
 Test if a statement is an assignment. More...
 
bool assignment_block_or_statement_p (statement s)
 
bool return_statement_p (statement s)
 Test if a statement is a C or Fortran "return". More...
 
bool exit_statement_p (statement s)
 
bool abort_statement_p (statement s)
 
bool fortran_return_statement_p (statement s)
 Test if a statement is a Fortran "return". More...
 
bool C_return_statement_p (statement s)
 Test if a statement is a C "return". More...
 
bool continue_statement_p (statement s)
 Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python... More...
 
bool forloop_statement_p (statement s)
 
bool declaration_statement_p (statement s)
 Had to be optimized according to Beatrice Creusillet. More...
 
bool continue_statements_p (list sl)
 Check that all statements contained in statement list sl are a continue statements. More...
 
bool stop_statement_p (statement s)
 Test if a statement is a Fortran STOP. More...
 
bool format_statement_p (statement s)
 Test if a statement is a Fortran FORMAT. More...
 
bool write_statement_p (statement s)
 
bool statement_less_p (statement st1, statement st2)
 
bool statement_possible_less_p (statement st1, statement st2)
 
string comments_dup (string comment)
 functions to generate statements More...
 
string decls_text_dup (string dt)
 Duplicate statement decls_text. More...
 
statement make_assign_statement (expression l, expression r)
 
statement make_return_statement (entity module)
 
instruction make_simple_Fortran_io_instruction (bool is_read_p, expression f, list io_list)
 Derived from the Fortran parser code. More...
 
statement make_print_statement (string message)
 Make a Fortran print statement. More...
 
statement make_C_print_statement (string message)
 
statement make_any_print_statement (string message)
 Generate a print of a constant character string on stderr for C or on stdout for Fortran. More...
 
statement make_stop_statement (string message)
 This function returns a Fortran stop statement with an error message. More...
 
statement make_exit_statement (int n, string errmess)
 This function returns a statement ending with a C exit statement. More...
 
statement make_continue_statement (entity l)
 
statement make_plain_continue_statement ()
 Make a simple continue statement to be used as a NOP or ";" in C. More...
 
statement make_declarations_statement (list idl, int sn, string cs)
 Make a declaration(s) statement. More...
 
statement make_declaration_statement (entity v, int sn, string cs)
 Make one declaration statement. More...
 
bool declaration_statements_p (list sl)
 Check that all statements contained in statement list sl are declaration statements. More...
 
statement add_initialization_information_to_declaration_statement (statement s, list iel)
 The initialization expression list is integrated into the internal representation as an argument list. More...
 
list declaration_statement_to_initializations (statement s)
 
statement make_whileloop_statement (expression condition, statement body, int line_number, bool before)
 Build a while loop statement. More...
 
statement make_loop_statement (entity i, expression low, expression up, expression inc, statement b)
 Build a loop statement. More...
 
statement make_forloop_statement (expression init, expression cond, expression inc, statement body)
 
statement make_test_statement (expression cond, statement truebody, statement falsebody)
 
statement make_call_statement (string function_name, list args, entity l, string c)
 This function is limited to intrinsics calls... More...
 
statement make_expression_statement (expression e)
 Build a statement from a given expression. More...
 
static void update_number_to_statement (statement s)
 
statement apply_number_to_statement (hash_table nts, _int n)
 
hash_table build_number_to_statement (hash_table nts, statement s)
 
hash_table allocate_number_to_statement ()
 
statement clear_labels (statement s)
 Get rid of all labels in controlized code before duplication. More...
 
void clear_label (statement s)
 
statement st_make_nice_test (expression condition, list ltrue, list lfalse)
 
statement makeloopbody (loop l, statement s_old, bool inner_p)
 statement makeloopbody(l, s_old) make a statement for a loop body, using the fields of a previously existing statement More...
 
string external_statement_identification (statement s)
 Does work neither with undefined statements nor with defined statements with undefined instructions. More...
 
string statement_identification (statement s)
 Like external_statement_identification(), but with internal information, the hexadecimal address of the statement. More...
 
string safe_statement_identification (statement s)
 
static bool gather_all_comments_of_a_statement_filter (statement s, string *all_comments)
 
string gather_all_comments_of_a_statement (statement s)
 Gather all the comments recursively found in the given statement and return them in a strduped string (NULL if no comment found). More...
 
char ** find_first_statement_comment (statement s)
 Find the first non-empty comment of a statement, if any returns a pointer to the comment if found, pointer to a "string_undefined" otherwise. More...
 
static char ** find_first_comment (statement s)
 Find the first comment of a statement, if any. More...
 
bool try_to_put_a_comment_on_a_statement (statement s, string the_comments)
 Put a comment on a statement in a safe way. More...
 
void put_a_comment_on_a_statement (statement s, string the_comments)
 Similar to try_to_put_a_comment_on_a_statement() but insert a CONTINUE to put the comment on it if there is only empty sequence(s) More...
 
void append_comments_to_statement (statement s, string the_comments)
 Append a comment string (if non empty) to the comments of a statement, if the c. More...
 
void insert_comments_to_statement (statement s, const char *the_comments)
 Insert a comment string (if non empty) at the beginning of the comments of a statement. More...
 
void add_one_line_of_comment (statement s, string format,...)
 
statement add_comment_and_line_number (statement s, string sc, int sn)
 Since block cannot carry comments nor line numbers, they must be moved to an internal continue statement. More...
 
void fix_sequence_statement_attributes (statement s)
 Since blocks are not represented in Fortran, they cannot carry a label. More...
 
void fix_statement_attributes_if_sequence (statement s)
 Apply fix_sequence_statement_attributes() on the statement only if it really a sequence. More...
 
entity statement_to_label (statement s)
 See if statement s is labelled and can be reached by a GO TO. More...
 
statement add_label_to_statement (entity label, statement s, statement *labeled_statement)
 Add a label to a statement. More...
 
bool statement_does_return (statement s)
 Returns false is no syntactic control path exits s (i.e. More...
 
bool unstructured_does_return (unstructured u)
 
void gather_and_remove_all_format_statements_rewrite (statement s, list *all_formats)
 
list gather_and_remove_all_format_statements (statement s)
 Used to keep aside the FORMAT before many code transformation that could remove them either. More...
 
void put_formats_at_module_beginning (statement s)
 Transfer all the FORMATs at the very beginning of a module: More...
 
void put_formats_at_module_end (statement s)
 Transfer all the FORMATs at the very end of a module: More...
 
bool figure_out_if_it_is_a_format (instruction i, bool *format_inside_statement_has_been_found)
 
bool format_inside_statement_p (statement s)
 
int statement_to_comment_length (statement stmt)
 Number of comment line directly attached to a statement. More...
 
static bool down_counter (statement s)
 
static void up_counter (statement s)
 
persistant_statement_to_int statement_to_line_number (statement s)
 
static void generic_insert_statement (statement s, statement s1, bool before)
 insert statement s1 before or after statement s More...
 
void insert_statement (statement s, statement s1, bool before)
 This is the normal entry point. More...
 
void insert_statement_no_matter_what (statement s, statement s1, bool before)
 Break the IR consistency or, at the very least, do not insert new declarations at the usual place, i.e. More...
 
void append_statement_to_block_statement (statement b, statement s)
 
static string default_generated_variable_commenter (__attribute__((unused)) entity e)
 
void push_generated_variable_commenter (string(*commenter)(entity))
 
void pop_generated_variable_commenter ()
 
string generated_variable_comment (entity e)
 
static bool add_declaration_to_declaration_statement_p (statement s, string c, entity nv)
 Check if declaration of variable nv can be added to the declaration list of statement s. More...
 
static statement generic_add_declaration_statement (statement s, entity e, bool before_p)
 Add a new declaration statement. More...
 
statement add_declaration_statement (statement s, entity e)
 
statement add_declaration_statement_at_beginning (statement s, entity e)
 
statement add_declaration_statement_here (statement block_statement, statement s, entity e, bool before_p)
 Add a new declaration statement (inspired by generic_add_declaration_statement) More...
 
void fix_block_statement_declarations (statement s)
 s is assumed to be a block statement and its declarations field is assumed to be correct, but not necessarily the declaration statements within the block s. More...
 
statement remove_declaration_statement (statement s, entity e)
 Declarations are not only lists of entities, but also statement to carry the line number, comments,... More...
 
statement update_statement_instruction (statement s, instruction i)
 Replace the instruction in statement s by instruction i. More...
 
void statement_replace_with_statement_list (statement as, statement rs, list sl)
 Assume that statement rs appears in statement as and replaced it by a statement list. More...
 
static bool find_implicit_goto (statement s, list *tl)
 
list statement_to_implicit_target_labels (statement s)
 Look for labels appearing in END= or ERR= IO clauses and allocate a label list. More...
 
static bool collect_labels (statement s, list *pll)
 
list statement_to_labels (statement s)
 Look for non-empty labels appearing directly or indirectly and allocate a label list. More...
 
static bool undefined_statement_found_p (statement s, bool *p_undefined_p)
 
bool all_statements_defined_p (statement s)
 
static bool add_statement_declarations (statement s, add_statement_declarations_t *ctxt)
 Add the declarations of a statement to a list if not already here. More...
 
list statement_to_declarations (void *s)
 Get a list of all variables declared recursively within a statement. More...
 
list statements_to_declarations (list sl)
 Returns the declarations contained in a list of statement. More...
 
list instruction_to_declarations (instruction i)
 Get a list of all variables declared recursively within an instruction. More...
 
static list internal_statement_to_direct_declarations (statement st)
 No recursive descent. More...
 
static list unstructured_to_direct_declarations (unstructured u)
 
list statements_to_direct_declarations (list sl)
 Returns the declarations contained directly in the declaration statements of a list of statements. More...
 
list statement_to_direct_declarations (statement s)
 Returns the declarations contained directly in a statement s. More...
 
static bool add_stat_referenced_entities (reference r, entities_t *vars)
 
static bool add_loop_index_entity (loop l, entities_t *vars)
 
static bool add_ref_entities_in_init (statement s, entities_t *vars)
 
list statement_to_referenced_entities (statement s)
 Get a list of all variables referenced recursively within a statement: More...
 
static bool add_stat_called_user_entities (call c, entities_t *funcs)
 
static bool add_stat_called_in_inits (statement s, entities_t *funcs)
 
list statement_to_called_user_entities (statement s)
 Get a list of all user function called recursively within a statement: More...
 
static bool first_reference_to_v_p (reference r)
 
static bool declarations_first_reference_to_v_p (statement st)
 
reference find_reference_to_variable (statement s, entity v)
 
static bool count_static_references_to_v_p (reference r)
 Count static references. More...
 
int count_static_references_to_variable (statement s, entity v)
 
static bool count_references_to_v_p (reference r)
 
static bool declarations_count_references_to_v_p (statement st)
 
static bool count_element_references_to_v_p (reference r)
 This function checks reference to proper elements, not slices. More...
 
static bool declarations_count_element_references_to_v_p (statement st)
 
static bool count_loop_in (loop __attribute__((unused)) l)
 
static void count_loop_out (loop __attribute__((unused)) l)
 
int count_references_to_variable (statement s, entity v)
 
int count_references_to_variable_element (statement s, entity v)
 
static bool statement_in_statement_walker (statement st, struct sb *sb)
 
bool statement_in_statement_p (statement s, statement st)
 
bool statement_in_statements_p (statement s, list l)
 
static bool replace_statement_walker (statement s, struct replace_statement_context *ctx)
 
bool statement_replace_in_root_statement (statement old_stat, statement new_stat, statement root_stat)
 replace old_stat by new_stat in root_stat this pass does not free old_stat similar to replace_in_sequence_statement_with() in phrase/phrase_tools.c but without the constraint that old_stat is in a sequence More...
 

Variables

static hash_table number_to_statement = hash_table_undefined
 Mapping from statement number to statement. More...
 
static set duplicate_numbers = set_undefined
 To keep track of duplicate numbers. More...
 
static int current_line = -1
 Poor attempt at associating physical line numbers to statement. More...
 
static persistant_statement_to_int stmt_to_line = persistant_statement_to_int_undefined
 
static generated_variable_commenter generated_variable_commenters [MAX_COMMENTERS]
 
static size_t nb_commenters =1
 
static reference first_reference_to_v = reference_undefined
 Return first reference found. More...
 
static entity variable_searched = entity_undefined
 
static int reference_count = -1
 
static int loop_depth
 Estimate count of dynamic references. More...
 

get_statement_depth and its auxilary functions

static bool is_substatement = false
 
bool statement_substatement_walker (statement some, statement s)
 
bool statement_substatement_p (statement s, statement root)
 search a statement inside a statement More...
 
int get_statement_depth (statement s, statement root)
 computes the block-depth of a statement NOT INTENDED to generate entity name declared at particular block level : The block scope depends on the number of different blocks at the same depth ! More...
 

statement finders

find statements with particular constraints

static bool find_statements_with_label_walker (statement s, struct fswl *p)
 helper to find statement with a particular label as label should be unique, the function stops once a statement is found More...
 
statement find_statement_from_label (statement s, entity label)
 find a statement in s with entity label More...
 
statement find_statement_from_label_name (statement s, const char *module_name, const char *label_name)
 
bool statement_with_pragma_p (statement s)
 Test if a statement has some pragma. More...
 
list statement_pragmas (statement s)
 get the list of pragma of a statement s More...
 
extension get_extension_from_statement_with_pragma (statement s, const char *seed)
 Get the extension of a statement with pragma beginning with a prefix. More...
 
static bool find_statements_with_pragma_walker (statement s, struct fswp *p)
 
list find_statements_with_pragma (statement s, const char *begin)
 Get a list of statements with pragma begining with a prefix. More...
 
static bool look_for_user_call (call c, bool *user_call_p)
 
bool statement_contains_user_call_p (statement s)
 
static bool look_for_control_effects (call c, bool *control_effect_p)
 
bool statement_may_have_control_effects_p (statement s)
 
static bool look_for_exiting_intrinsic_calls (call c, bool *control_effect_p)
 
bool statement_may_contain_exiting_intrinsic_call_p (statement s)
 
statement normalize_statement (statement s)
 Make (a bit more) sure that s is gen_defined_p in spite of poor decision for empty fields and that strdup can be used on the string fields. More...
 

Detailed Description

detects a statement with no special effect...

Look if at least one statement of a list of statements is in another one.

Look if a statement is another one.

Check if a statement s contains a call to a user-defined function or to an intrinsic with control effects.

Check if a statement s contains a call to a user-defined function.

Make sure that s and all its substatements are defined.

Return true only if there is a FORMAT inside the statement:

This may be useful because PIPS does not contain a control effect analysis and because a user-defined function can hide a control effect such as exit(), abort() or STOP.

Parameters
sis the potentially inside statement
stis the outside statement
Returns
true is s is inside st
Parameters
lis the list of statements
stis the outside statement
Returns
true is at least one statement of l is inside st

Macro Definition Documentation

◆ BUFSIZE

#define BUFSIZE   1024

Definition at line 1938 of file statement.c.

◆ ERROR_PREFIX

#define ERROR_PREFIX   "!ERROR: "

as name indicate, a comment is added.

Definition at line 1937 of file statement.c.

◆ MAX_COMMENTERS

#define MAX_COMMENTERS   8

Definition at line 2603 of file statement.c.

◆ PIPS_DECLARATION_COMMENT

#define PIPS_DECLARATION_COMMENT   "PIPS generated variable\n"

Definition at line 2595 of file statement.c.

Typedef Documentation

◆ generated_variable_commenter

typedef string(* generated_variable_commenter) (entity)

commenters are function used to add comments to pips-created variables they are handled as a limited size stack all commenters are supposed to return allocated data

Definition at line 2609 of file statement.c.

Function Documentation

◆ abort_statement_p()

bool abort_statement_p ( statement  s)

Definition at line 182 of file statement.c.

182  {
184  return abort_instruction_p(i);
185 }
bool abort_instruction_p(instruction i)
Definition: instruction.c:205
#define statement_instruction(x)
Definition: ri.h:2458

References abort_instruction_p(), and statement_instruction.

+ Here is the call graph for this function:

◆ add_comment_and_line_number()

statement add_comment_and_line_number ( statement  s,
string  sc,
int  sn 
)

Since block cannot carry comments nor line numbers, they must be moved to an internal continue statement.

A prettier version could be to make a new block containing the continue and then the old block. Comments might be better located.

A continue statement must be inserted as first block statement

Parameters
scc
snn

Definition at line 1980 of file statement.c.

1981 {
1982  string osc = statement_comments(s);
1983  statement ns = s;
1984 
1985  if(osc!=NULL && !string_undefined_p(osc)) {
1986  free(osc);
1987  }
1988 
1989  if(!statement_block_p(s)) {
1990  statement_comments(s) = sc;
1991  statement_number(s) = sn;
1992  }
1993  else if(!string_undefined_p(sc)) {
1994  /* A continue statement must be inserted as first block statement*/
1997  statement_comments(nops) = sc;
1998  statement_number(nops) = sn;
2000  CONS(STATEMENT, nops, sss);
2001  }
2002  return ns;
2003 }
void free(void *)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
statement make_continue_statement(entity l)
Definition: statement.c:953
#define string_undefined_p(s)
Definition: newgen_types.h:41
#define statement_block_p(stat)
#define entity_undefined
Definition: ri.h:2761
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define statement_comments(x)
Definition: ri.h:2456
#define statement_number(x)
Definition: ri.h:2452
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, entity_undefined, free(), instruction_sequence, make_continue_statement(), sequence_statements, STATEMENT, statement_block_p, statement_comments, statement_instruction, statement_number, and string_undefined_p.

Referenced by MakeForloop().

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

◆ add_declaration_statement()

statement add_declaration_statement ( statement  s,
entity  e 
)

Definition at line 2790 of file statement.c.

2791 {
2792  return generic_add_declaration_statement(s, e, false);
2793 }
static statement generic_add_declaration_statement(statement s, entity e, bool before_p)
Add a new declaration statement.
Definition: statement.c:2711

References generic_add_declaration_statement().

Referenced by add_induction_var_to_local_declarations(), copy_write_statement_with_cumulated_regions(), fix_block_statement_declarations(), freia_compile(), GenericAddLocalEntityToDeclarations(), make_send_receive_conversion(), outliner_patch_parameters(), regions_to_loops(), and spire_distributed_unstructured_to_structured().

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

◆ add_declaration_statement_at_beginning()

statement add_declaration_statement_at_beginning ( statement  s,
entity  e 
)

Definition at line 2795 of file statement.c.

2796 {
2797  return generic_add_declaration_statement(s, e, true);
2798 }

References generic_add_declaration_statement().

Referenced by cluster_stage_spire_generation(), and initilization().

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

◆ add_declaration_statement_here()

statement add_declaration_statement_here ( statement  block_statement,
statement  s,
entity  e,
bool  before_p 
)

Add a new declaration statement (inspired by generic_add_declaration_statement)

A new declaration statement is generated to declare e. This statement is inserted before or after the statements s in statement block_statement. s must be a statement directly (no recursively) present in statement block_statement

Declarations are not only lists of entities at the block level and in the symbol table, but also declaration statement to carry the line number, comments, and the declarations local to the declaration statement. This function is low-level and does not maintain the consistency of the PIPS internal representation.

Parameters
block_statementmust be a sequence that contain statement s strictly the same pointer than s and not a copy.
sStatement after or before which declaration is inserted
eVariable to declare. The declaration of e at block_statement level is not checked. The existence of a previous declaration statement for e is not checked either. The caller is responsible for the consistency management between the declaration statements in block_statement and the list of declaration at block_statement level.
before_pdeclaration add before s if before_p==true
Returns
statement declaration generated or modified statement_undefined if the add fail

For the time being, a declaration statement is a continue statement. Beware that the possible dependencies between the new declaration and existing declarations are not checked. WARNING : block_statement is modify by side effect

Look for the statement s: it is pointed to by pl

Do we have previous declarations to skip?

SG: if CAR(pl) has same comment and same type as ds, merge them

SG: otherwise, insert ds

The new declaration is inserted before sl

ifdebug(8) {

pips_debug(8, "Statement after declaration insertion:\n");

print_statement(block_statement);

}

Parameters
block_statementlock_statement
before_pefore_p

Definition at line 2839 of file statement.c.

2840 {
2842  if(statement_block_p(block_statement)) {
2843  list sl = statement_block(block_statement); //statement list
2844  list cl = list_undefined; // current statement list
2845  list pl = NIL; // previous statement list
2846  list nsl = list_undefined; // new statement list
2847  string comment = generated_variable_comment(e);
2850  comment);
2851 
2852  bool find = false;
2853  /* Look for the statement s: it is pointed to by pl */
2854  for(cl=sl; !ENDP(cl) && !find; POP(cl)) {
2855  statement cs = STATEMENT(CAR(cl));
2856  // if ( statement_number(cs) == statement_number(s)
2857  // && statement_ordering(cs) == statement_ordering(s) )
2858  if (cs == s)
2859  {
2860  find = true;
2861  if (!before_p) {
2862  POP(cl);
2863  pl = cl;
2864  }
2865  break;
2866  }
2867  pl = cl;
2868  }
2869  if (!find) {
2870  pips_internal_error("statement s:%p (%d) must be in block block_statement:%p (%d) (not recursively but directly)\n",
2871  s, statement_number(s), block_statement, statement_number(block_statement));
2872  }
2873 
2874  /* Do we have previous declarations to skip? */
2875  if(!ENDP(pl)) {
2876  /* SG: if CAR(pl) has same comment and same type as ds, merge them */
2877  statement spl = STATEMENT(CAR(pl));
2879  free_statement(ds);
2880  ds = spl;
2882  nsl=sl;
2883  }
2884  /* SG: otherwise, insert ds */
2885  else {
2886  CDR(pl) = NIL; // Truncate sl
2887  nsl = gen_nconc(sl, CONS(STATEMENT, ds, cl));
2888  }
2889  }
2890  else { // pl == NIL
2891  /* The new declaration is inserted before sl*/
2892  pips_assert("The above loop was entered at most once", sl==cl);
2893  if (before_p && !ENDP(sl) && declaration_statement_p(STATEMENT(CAR(sl)))) {
2894  statement ssl = STATEMENT(CAR(sl));
2896  free_statement(ds);
2897  ds = ssl;
2899  nsl=sl;
2900  }
2901  else
2902  nsl = CONS(STATEMENT, ds, sl);
2903  }
2904  else
2905  nsl = CONS(STATEMENT, ds, sl);
2906  }
2907 
2908  instruction_block(statement_instruction(block_statement)) = nsl;
2909  }
2910  else {
2911  pips_internal_error("can only add declarations to statement blocks");
2912  }
2913 
2914  // FI: avoid the ri/prettyprint cycle
2915  /* ifdebug(8) { */
2916  /* pips_debug(8, "Statement after declaration insertion:\n"); */
2917  /* print_statement(block_statement); */
2918  /* } */
2919 
2920  return ds;
2921 }
void free_statement(statement p)
Definition: ri.c:2189
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
Definition: freia_spoc.c:52
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
list statement_block(statement s)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
string generated_variable_comment(entity e)
Definition: statement.c:2629
statement make_declaration_statement(entity v, int sn, string cs)
Make one declaration statement.
Definition: statement.c:1091
static bool add_declaration_to_declaration_statement_p(statement s, string c, entity nv)
Check if declaration of variable nv can be added to the declaration list of statement s.
Definition: statement.c:2657
bool declaration_statement_p(statement s)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
#define STATEMENT_NUMBER_UNDEFINED
default values
#define instruction_block(i)
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_undefined
Definition: ri.h:2419

References add_declaration_to_declaration_statement_p(), CAR, CDR, comment(), CONS, declaration_statement_p(), ENDP, ENTITY, free_statement(), gen_nconc(), generated_variable_comment(), instruction_block, list_undefined, make_declaration_statement(), NIL, pips_assert, pips_internal_error, pl, POP, STATEMENT, statement_block(), statement_block_p, statement_declarations, statement_instruction, statement_number, STATEMENT_NUMBER_UNDEFINED, and statement_undefined.

Referenced by replicate_declaration().

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

◆ add_declaration_to_declaration_statement_p()

static bool add_declaration_to_declaration_statement_p ( statement  s,
string  c,
entity  nv 
)
static

Check if declaration of variable nv can be added to the declaration list of statement s.

This is considered legal if:

  • the comments match;
  • the basic of the types of nv and a variable already declared in s, fv, are equal;
  • the qualifiers of nv and fv are equal
  • the storage are equal if ram storage are used for both fv and nv

This function impacts the layout of the declarations and hence the prettyprint. Any modification is likely to disturb the validation.

This function is not safe. Statement s must be a declaration statement with a non-empty declaration list.

The code could be shortened by using a big logical expression, but this would not improve readability or debugability.

Definition at line 2657 of file statement.c.

2660 {
2661  bool add_p = false;
2662  if (statement_declarations(s) == NIL) {
2663  return add_p;
2664  }
2666  bool comment_p = comments_equal_p(statement_comments(s),c);
2667  bool basic_p = false;
2669  && !basic_undefined_p(entity_basic(fv))) {
2670  basic_p = basic_equal_p(entity_basic(nv),entity_basic(fv));
2671  }
2672  bool qualifiers_p =
2674  bool storage_p =
2677  ==ram_section(storage_ram(entity_storage(nv)))):false)
2678  :true;
2679 
2680  add_p = comment_p && basic_p && qualifiers_p && storage_p;
2681 
2682  return add_p;
2683 }
bool comments_equal_p(string c1, string c2)
Definition: statement.c:116
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
list entity_qualifiers(entity e)
return the qualifiers associated to entity e if it's a variable NIL otherwise
Definition: entity.c:1394
bool qualifiers_equal_p(list, list)
Definition: type.c:758
bool basic_equal_p(basic, basic)
Definition: type.c:927
#define entity_storage(x)
Definition: ri.h:2794
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define basic_undefined_p(x)
Definition: ri.h:557
#define storage_ram(x)
Definition: ri.h:2521

References basic_equal_p(), basic_undefined_p, CAR, comments_equal_p(), ENTITY, entity_basic(), entity_qualifiers(), entity_storage, NIL, qualifiers_equal_p(), ram_section, statement_comments, statement_declarations, storage_ram, and storage_ram_p.

Referenced by add_declaration_statement_here(), and generic_add_declaration_statement().

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

◆ add_initialization_information_to_declaration_statement()

statement add_initialization_information_to_declaration_statement ( statement  s,
list  iel 
)

The initialization expression list is integrated into the internal representation as an argument list.

For the time being, I am cheating because its a list of integer and not a list of expressions.

Parameters
ielel

Definition at line 1119 of file statement.c.

1120 {
1121  pips_assert("s is a declaration statement", declaration_statement_p(s));
1123  pips_assert("No arguments", ENDP(call_arguments(c)));
1124  call_arguments(c)= iel;
1125  return s;
1126 }
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711

References call_arguments, declaration_statement_p(), ENDP, instruction_call, pips_assert, and statement_instruction.

Referenced by add_prettyprint_control_list_to_declaration_statement().

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

◆ add_label_to_statement()

statement add_label_to_statement ( entity  label,
statement  s,
statement labeled_statement 
)

Add a label to a statement.

If the statement cannot accept a label (it is a sequence or it has already a label...), add a CONTINUE in front of the statement to carry it.

Returns
Parameters
swith the new
labelif it was possible to add it directly, or a new statement sequence with the new
labeladded to a CONTINUE followed by the old statement
s.
labelis the label to add to the statement
sis the statement to be labelled
labeled_statementis a pointer to a statement. It is initialized by the function to the statement that really get the label on. It is useful when we need to track it, for exemple for "goto" generation in the parser.

The caller is responsible to avoid garbage collecting on

Parameters
sif a new statements are allocated in this fonction since it is included in the return statement.

Test with statement_to_label to deal with a label inside an instruction block:

Add a continue as a label landing pad since a statement can not have more than 1 label and a sequence cannot have a label:

Parameters
labelabel
labeled_statementabeled_statement

Definition at line 2158 of file statement.c.

2160  {
2161  /* Test with statement_to_label to deal with a label inside an
2162  instruction block: */
2163  entity old_label = statement_to_label(s);
2164  if (old_label == entity_undefined
2166  && unlabelled_statement_p(s))) {
2167  statement_label(s) = label;
2168  *labeled_statement = s;
2169  return s;
2170  }
2171  else {
2172  /* Add a continue as a label landing pad since a statement can not
2173  have more than 1 label and a sequence cannot have a label: */
2175  *labeled_statement = c;
2176  list stmts = gen_statement_cons(s, NIL);
2177  stmts = gen_statement_cons(c, stmts);
2178  statement seq = make_block_statement(stmts);
2179  return seq;
2180  }
2181 }
list gen_statement_cons(statement p, list l)
Definition: ri.c:2202
statement make_block_statement(list body)
Make a block statement from a list of statement.
Definition: statement.c:616
bool unlabelled_statement_p(statement st)
Definition: statement.c:402
entity statement_to_label(statement s)
See if statement s is labelled and can be reached by a GO TO.
Definition: statement.c:2090
#define instruction_sequence_p(x)
Definition: ri.h:1512
#define statement_label(x)
Definition: ri.h:2450

References entity_undefined, gen_statement_cons(), instruction_sequence_p, make_block_statement(), make_continue_statement(), NIL, statement_instruction, statement_label, statement_to_label(), and unlabelled_statement_p().

Referenced by MakeLabeledStatement().

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

◆ add_loop_index_entity()

static bool add_loop_index_entity ( loop  l,
entities_t vars 
)
static

Definition at line 3399 of file statement.c.

3400 {
3401  entity idx = loop_index(l);
3402  if (!set_belong_p(vars->sents, idx))
3403  {
3404  vars->lents = CONS(entity, idx, vars->lents);
3405  set_add_element(vars->sents, vars->sents, idx);
3406  }
3407  return true;
3408 }
list lents
Definition: statement.c:3383
bool set_belong_p(const set, const void *)
Definition: set.c:194
set set_add_element(set, const set, const void *)
Definition: set.c:152
#define loop_index(x)
Definition: ri.h:1640

References CONS, entities_t::lents, loop_index, entities_t::sents, set_add_element(), and set_belong_p().

Referenced by statement_to_referenced_entities().

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

◆ add_one_line_of_comment()

void add_one_line_of_comment ( statement  s,
string  format,
  ... 
)
Parameters
formatormat

Definition at line 1940 of file statement.c.

1941 {
1942  char buffer[BUFSIZE];
1943  int error;
1944  va_list some_arguments;
1945 
1946  va_start(some_arguments, format);
1947  error = vsnprintf(buffer, BUFSIZE, format, some_arguments);
1948  if (error<0) {
1949  pips_internal_error("buffer too small");
1950  }
1951  va_end(some_arguments);
1952 
1953  if (s)
1954  {
1956  {
1958  }
1959  else
1960  {
1961  string newcom =
1964  statement_comments(s) = newcom;
1965  }
1966  }
1967  else
1968  {
1969  fprintf(stderr, ERROR_PREFIX "%s\n", buffer);
1970  }
1971 }
#define error(fun, msg)
NewGen interface with C3 type Psysteme for PIPS project.
Definition: Psc.c:78
#define ERROR_PREFIX
as name indicate, a comment is added.
Definition: statement.c:1937
#define BUFSIZE
Definition: statement.c:1938
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
static string buffer
Definition: string.c:113

References buffer, BUFSIZE, concatenate(), error, ERROR_PREFIX, fprintf(), free(), pips_internal_error, statement_comments, strdup(), and string_undefined_p.

Referenced by arguments_are_something(), check_format(), check_io_list(), check_spec(), check_this_loop(), check_this_test(), check_this_whileloop(), is_integer_specifier(), is_label_integer_string_specifier(), is_label_specifier(), is_string_specifier(), is_unit_specifier(), is_varibale_array_element_specifier(), statement_with_at_most_one_expression_integer(), statement_with_at_most_one_integer_or_character(), statement_without_argument(), type_this_entity_if_needed(), type_this_expression(), type_this_instruction(), typing_arguments_of_user_function(), typing_assign_substring(), typing_buffer_inout(), typing_function_argument_type_to_return_type(), typing_implied_do(), typing_of_assign(), and typing_substring().

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

◆ add_ref_entities_in_init()

static bool add_ref_entities_in_init ( statement  s,
entities_t vars 
)
static

Definition at line 3410 of file statement.c.

3411 {
3413  {
3414  value init = entity_initial(var);
3415  if (value_expression_p(init))
3416  // only references down there
3419  }
3420  return true;
3421 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
static bool add_stat_referenced_entities(reference r, entities_t *vars)
Definition: statement.c:3387
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define value_expression_p(x)
Definition: ri.h:3080
#define value_expression(x)
Definition: ri.h:3082
#define entity_initial(x)
Definition: ri.h:2796

References add_stat_referenced_entities(), entity_initial, FOREACH, gen_context_recurse, gen_null2(), init, reference_domain, statement_declarations, value_expression, and value_expression_p.

Referenced by statement_to_referenced_entities().

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

◆ add_stat_called_in_inits()

static bool add_stat_called_in_inits ( statement  s,
entities_t funcs 
)
static

Definition at line 3462 of file statement.c.

3463 {
3465  {
3466  value init = entity_initial(var);
3467  if (value_expression_p(init))
3470  }
3471  return true;
3472 }
static bool add_stat_called_user_entities(call c, entities_t *funcs)
Definition: statement.c:3447
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58

References add_stat_called_user_entities(), call_domain, entity_initial, FOREACH, gen_context_recurse, gen_null2(), init, statement_declarations, value_expression, and value_expression_p.

Referenced by statement_to_called_user_entities().

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

◆ add_stat_called_user_entities()

static bool add_stat_called_user_entities ( call  c,
entities_t funcs 
)
static

FI: I do not know what should be done for pointers to function, assuming they can be called.

Definition at line 3447 of file statement.c.

3448 {
3449  /* FI: I do not know what should be done for pointers to function,
3450  assuming they can be called. */
3451  entity f = call_function(c);
3452  value fv = entity_initial(f);
3453 
3454  if(!set_belong_p(funcs->sents, f) && value_code_p(fv))
3455  {
3456  funcs->lents = CONS(entity, f, funcs->lents);
3457  set_add_element(funcs->sents, funcs->sents, f);
3458  }
3459  return true;
3460 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define value_code_p(x)
Definition: ri.h:3065
#define call_function(x)
Definition: ri.h:709

References call_function, CONS, entity_initial, f(), entities_t::lents, entities_t::sents, set_add_element(), set_belong_p(), and value_code_p.

Referenced by add_stat_called_in_inits(), and statement_to_called_user_entities().

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

◆ add_stat_referenced_entities()

static bool add_stat_referenced_entities ( reference  r,
entities_t vars 
)
static

Definition at line 3387 of file statement.c.

3388 {
3389  // a function may be referenced, eg in a function pointer assignment.
3390  entity var = reference_variable(r);
3391  if (!set_belong_p(vars->sents, var))
3392  {
3393  vars->lents = CONS(entity, var, vars->lents);
3394  set_add_element(vars->sents, vars->sents, var);
3395  }
3396  return true;
3397 }
#define reference_variable(x)
Definition: ri.h:2326

References CONS, entities_t::lents, reference_variable, entities_t::sents, set_add_element(), and set_belong_p().

Referenced by add_ref_entities_in_init(), and statement_to_referenced_entities().

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

◆ add_statement_declarations()

static bool add_statement_declarations ( statement  s,
add_statement_declarations_t ctxt 
)
static

Add the declarations of a statement to a list if not already here.

This function is indeed to be used by statement_to_declarations() and instruction_to_declarations() but not by its own.

Returns
true (to go on diving in a gen_recurse())

no declaration in a declaration!

Definition at line 3235 of file statement.c.

3236 {
3238  {
3240  if(!set_belong_p(ctxt->cache,e)) {
3242  set_add_element(ctxt->cache,ctxt->cache,e);
3243  }
3244  return false;/* no declaration in a declaration!*/
3245  }
3246  return true;
3247 }

References add_statement_declarations_t::cache, CONS, declaration_statement_p(), ENTITY, FOREACH, set_add_element(), set_belong_p(), statement_declarations, and add_statement_declarations_t::statement_to_all_included_declarations.

Referenced by statement_to_declarations().

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

◆ all_statements_defined_p()

bool all_statements_defined_p ( statement  s)

Definition at line 3213 of file statement.c.

3214 {
3215  bool undefined_p = false;
3216 
3217  gen_context_recurse(s, (void *) &undefined_p ,statement_domain,
3219  return !undefined_p;
3220 }
static bool undefined_statement_found_p(statement s, bool *p_undefined_p)
Definition: statement.c:3187
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References gen_context_recurse, gen_null2(), statement_domain, and undefined_statement_found_p().

Referenced by statement_to_transformer(), and statement_to_transformer_list().

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

◆ allocate_number_to_statement()

hash_table allocate_number_to_statement ( void  )

let's assume that 50 statements is a good approximation of a module size.

Definition at line 1540 of file statement.c.

1541 {
1543 
1544  /* let's assume that 50 statements is a good approximation of a
1545  * module size.
1546  */
1547  nts = hash_table_make(hash_int, 50);
1548 
1549  return nts;
1550 }
static hash_table nts
Definition: prettyprint.c:63
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_int
Definition: newgen_hash.h:32
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References hash_int, hash_table_make(), hash_table_undefined, and nts.

Referenced by get_any_comp_regions_text(), get_continuation_condition_text(), get_semantic_text(), and print_code_or_source_comp().

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

◆ append_comments_to_statement()

void append_comments_to_statement ( statement  s,
string  the_comments 
)

Append a comment string (if non empty) to the comments of a statement, if the c.

Parameters
the_commentsis strdup'ed in this function.

Nothing to add...

There is no comment yet:

Parameters
the_commentshe_comments

Definition at line 1889 of file statement.c.

1891 {
1892 
1893 
1894  if (empty_comments_p(the_comments))
1895  /* Nothing to add... */
1896  return;
1897 
1898  char **old = find_first_statement_comment(s);
1899  if (empty_comments_p(*old))
1900  /* There is no comment yet: */
1901  put_a_comment_on_a_statement(s, strdup(the_comments));
1902  else {
1903  char * new = strdup(concatenate(*old, the_comments, NULL));
1904  free(*old);
1905  *old=empty_comments;
1907  }
1908 }
void put_a_comment_on_a_statement(statement s, string the_comments)
Similar to try_to_put_a_comment_on_a_statement() but insert a CONTINUE to put the comment on it if th...
Definition: statement.c:1863
char ** find_first_statement_comment(statement s)
Find the first non-empty comment of a statement, if any returns a pointer to the comment if found,...
Definition: statement.c:1772
bool empty_comments_p(const char *s)
Definition: statement.c:107
#define empty_comments
Empty comments (i.e.

References concatenate(), empty_comments, empty_comments_p(), find_first_statement_comment(), free(), put_a_comment_on_a_statement(), and strdup().

Referenced by region_to_loop_nest().

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

◆ append_statement_to_block_statement()

void append_statement_to_block_statement ( statement  b,
statement  s 
)

Definition at line 2586 of file statement.c.

2587 {
2588  pips_assert("b is a block statement", statement_block_p(b));
2589  list sl = statement_block(b);
2591  gen_nconc(sl, CONS(STATEMENT, s, NIL));
2592 }
sequence statement_sequence(statement s)
Get the sequence of a statement sequence.
Definition: statement.c:1328

References CONS, gen_nconc(), NIL, pips_assert, sequence_statements, STATEMENT, statement_block(), statement_block_p, and statement_sequence().

Referenced by MakeForloopWithIndexDeclaration().

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

◆ apply_number_to_statement()

statement apply_number_to_statement ( hash_table  nts,
_int  n 
)

This function used to be inline in prettyprinting functions for user views. It was assumed that all statements produced by the parser had a defined statement number. In order to keep a nice statement numbering scheme, GO TO statements are not (always) numbered. So n hasa to be tested.

Parameters
ntsts

Definition at line 1495 of file statement.c.

1496 {
1497  /* This function used to be inline in prettyprinting functions for user views.
1498  * It was assumed that all statements produced by the parser had a defined
1499  * statement number. In order to keep a nice statement numbering scheme,
1500  * GO TO statements are not (always) numbered. So n hasa to be tested.
1501  */
1502 
1504 
1506  s = (statement) hash_get(nts, (char *) n);
1507  if (s == (statement) HASH_UNDEFINED_VALUE) {
1508  s = statement_undefined;
1509  }
1510  }
1511 
1512  return s;
1513 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
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 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

References hash_get(), HASH_UNDEFINED_VALUE, nts, STATEMENT_NUMBER_UNDEFINED, and statement_undefined.

Referenced by semantic_to_text(), and text_complexity().

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

◆ assignment_block_or_statement_p()

bool assignment_block_or_statement_p ( statement  s)

Definition at line 142 of file statement.c.

143 {
145 
146  switch(instruction_tag(i)) {
149  break;
150  case is_instruction_test:
151  break;
152  case is_instruction_loop:
153  break;
155  break;
156  case is_instruction_goto:
157  pips_internal_error("unexpected GO TO");
158  break;
159  case is_instruction_call:
160  return assignment_statement_p(s);
162  break;
163  default:
164  pips_internal_error("ill. instruction tag %d", instruction_tag(i));
165  break;
166  }
167  return false;
168 }
bool assignment_block_p(instruction i)
Checks if an instruction block is a list of assignments, possibly followed by a continue.
Definition: instruction.c:230
bool assignment_statement_p(statement s)
Test if a statement is an assignment.
Definition: statement.c:135
#define is_instruction_block
soft block->sequence transition
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511

References assignment_block_p(), assignment_statement_p(), instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, pips_internal_error, and statement_instruction.

+ Here is the call graph for this function:

◆ assignment_statement_p()

◆ build_number_to_statement()

hash_table build_number_to_statement ( hash_table  nts,
statement  s 
)

Eliminate duplicate and hence meaningless numbers

nts is updated by side effect on number_to_statement

Parameters
ntsts

Definition at line 1516 of file statement.c.

1519 {
1520  pips_assert("build_number_to_statement", nts!=hash_table_undefined
1522 
1525 
1527 
1528  /* Eliminate duplicate and hence meaningless numbers */
1529  SET_MAP(n, {
1531  }, duplicate_numbers);
1532 
1533  /* nts is updated by side effect on number_to_statement */
1537  return nts;
1538 }
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
static void update_number_to_statement(statement s)
Definition: statement.c:1479
static set duplicate_numbers
To keep track of duplicate numbers.
Definition: statement.c:1477
static hash_table number_to_statement
Mapping from statement number to statement.
Definition: statement.c:1475
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:439
#define set_undefined
Definition: newgen_set.h:48
#define SET_MAP(element, code, the_set)
Definition: newgen_set.h:54
void set_free(set)
Definition: set.c:332
@ set_int
Definition: newgen_set.h:43
#define set_undefined_p(s)
Definition: newgen_set.h:49
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
#define statement_undefined_p(x)
Definition: ri.h:2420

References duplicate_numbers, gen_recurse, gen_true(), hash_del(), hash_table_undefined, nts, number_to_statement, pips_assert, set_free(), set_int, set_make(), SET_MAP, set_undefined, set_undefined_p, statement_domain, statement_undefined_p, and update_number_to_statement().

Referenced by get_any_comp_regions_text(), get_continuation_condition_text(), get_semantic_text(), and print_code_or_source_comp().

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

◆ C_return_statement_p()

bool C_return_statement_p ( statement  s)

Test if a statement is a C "return".

Definition at line 194 of file statement.c.

194  {
196  return C_return_instruction_p(i);
197 }
bool C_return_instruction_p(instruction i)
Definition: instruction.c:196

References C_return_instruction_p(), and statement_instruction.

+ Here is the call graph for this function:

◆ call_filter()

static bool call_filter ( call  c,
bool statement_is_empty 
)
static

Definition at line 76 of file statement.c.

77 {
78  entity e = call_function(c);
80  return false;
81  else
82  return cannot_be_empty(statement_is_empty);
83 }
static bool cannot_be_empty(bool *statement_is_empty)
Definition: statement.c:70
#define ENTITY_CONTINUE_P(e)
#define ENTITY_RETURN_P(e)

References call_function, cannot_be_empty(), ENTITY_CONTINUE_P, and ENTITY_RETURN_P.

Referenced by empty_code_p().

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

◆ cannot_be_empty()

static bool cannot_be_empty ( bool statement_is_empty)
static

Definition at line 70 of file statement.c.

71 {
72  gen_recurse_stop(NULL);
73  return *statement_is_empty = false;;
74 }
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251

References gen_recurse_stop().

Referenced by call_filter().

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

◆ clear_label()

void clear_label ( statement  s)

Definition at line 1568 of file statement.c.

1570 {
1571  if(format_statement_p(s)) {
1572  user_error("clear_label", "Cannot clear label for FORMAT %s!\n",
1574  }
1575 
1577 
1581 }
bool format_statement_p(statement s)
Test if a statement is a Fortran FORMAT.
Definition: statement.c:273
#define user_error(fn,...)
Definition: misc-local.h:265
entity entity_empty_label(void)
Definition: entity.c:1105
const char * label_local_name(entity e)
END_EOLE.
Definition: entity.c:604
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
#define loop_label(x)
Definition: ri.h:1646

References entity_empty_label(), format_statement_p(), instruction_loop, instruction_loop_p, label_local_name(), loop_label, statement_instruction, statement_label, and user_error.

Referenced by clear_labels(), and code_generation().

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

◆ clear_labels()

statement clear_labels ( statement  s)

Get rid of all labels in controlized code before duplication.

All labels have become useless and they cannot be freely duplicated.

One caveat: FORMAT statements!

Definition at line 1560 of file statement.c.

1560  {
1562  clean_up_sequences(s);
1563  return s;
1564 }
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
void clear_label(statement s)
Definition: statement.c:1568

References clean_up_sequences(), clear_label(), gen_recurse, gen_true(), and statement_domain.

Referenced by do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), and full_loop_unroll().

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

◆ collect_labels()

static bool collect_labels ( statement  s,
list pll 
)
static

Definition at line 3154 of file statement.c.

3155 {
3156  entity l = statement_label(s);
3157  if(!entity_empty_label_p(l))
3158  *pll = CONS(ENTITY, l, *pll);
3159  return true;
3160 }
bool entity_empty_label_p(entity e)
Definition: entity.c:666

References CONS, ENTITY, entity_empty_label_p(), and statement_label.

Referenced by statement_to_labels().

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

◆ comments_dup()

string comments_dup ( string  comment)

functions to generate statements

Duplicate statement comments

Parameters
commentis the comment to duplicate
Returns
the duplicated comment. If it was an allocated string, it is strdup()ed

Not allocated, just the same:

Parameters
commentomment

Definition at line 557 of file statement.c.

557  {
558  if (comment == NULL || string_undefined_p(comment))
559  /* Not allocated, just the same: */
560  return comment;
561  else
562  return strdup(comment);
563 }

References comment(), strdup(), and string_undefined_p.

Referenced by copy_statement_attributes().

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

◆ comments_equal_p()

bool comments_equal_p ( string  c1,
string  c2 
)
Parameters
c11
c22

Definition at line 116 of file statement.c.

117 {
118  return
119  ( empty_comments_p(c1) && empty_comments_p(c2)) ||
120  (!empty_comments_p(c1) && !empty_comments_p(c2) && same_string_p(c1,c2));
121 }
#define same_string_p(s1, s2)

References empty_comments_p(), and same_string_p.

Referenced by add_declaration_to_declaration_statement_p(), and prepare_context().

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

◆ continue_statement_p()

bool continue_statement_p ( statement  s)

Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python...

according to the language.

Definition at line 203 of file statement.c.

203  {
205 
206  return instruction_continue_p(i);
207 }
bool instruction_continue_p(instruction i)
Test if an instruction is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
Definition: instruction.c:173

References instruction_continue_p(), and statement_instruction.

Referenced by assignment_block_p(), compact_list(), continue_statements_p(), empty_statement_or_continue_p(), empty_statement_or_continue_without_comment_p(), empty_statement_or_labelless_continue_p(), get_first_inner_perfectly_nested_loop(), inline_statement_crawler(), IsolatedStatement(), iteration_domain_from_statement(), LinkInstToCurrentBlock(), loop_nest_to_wp65_code(), perfectly_nested_loop_p(), safe_print_statement(), sequence_call(), sequence_loop(), statement_does_return(), statement_to_label(), terapix_optimize_accumulator(), text_block_else(), text_test(), undefined_statement_list_p(), unstructured_consistency_p(), unstructured_to_flow_insensitive_transformer(), and xml_statement_from_sequence().

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

◆ continue_statements_p()

bool continue_statements_p ( list  sl)

Check that all statements contained in statement list sl are a continue statements.

Parameters
sll

Definition at line 246 of file statement.c.

247 {
248  bool continue_p = true;
249 
250  FOREACH(STATEMENT, s, sl) {
251  if(!continue_statement_p(s)) {
252  continue_p = false;
253  break;
254  }
255  }
256 
257  return continue_p;
258 }
bool continue_statement_p(statement s)
Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
Definition: statement.c:203

References continue_statement_p(), FOREACH, and STATEMENT.

+ Here is the call graph for this function:

◆ count_element_references_to_v_p()

static bool count_element_references_to_v_p ( reference  r)
static

This function checks reference to proper elements, not slices.

10: arbitrary value for references nested in at least one loop

Definition at line 3613 of file statement.c.

3614 {
3615  bool result= true;
3616  entity rv = reference_variable(r);
3617  if (rv == variable_searched) {
3618  list inds = reference_indices(r);
3619  size_t d = type_depth(ultimate_type(entity_type(rv)));
3620  if (gen_length(inds) == d) {
3621  /* 10: arbitrary value for references nested in at least one loop */
3622  reference_count += (loop_depth > 0 ? 10 : 1 );
3623  }
3624  }
3625  return result;
3626 }
size_t gen_length(const list l)
Definition: list.c:150
static int loop_depth
Estimate count of dynamic references.
Definition: statement.c:3581
static int reference_count
Definition: statement.c:3558
static entity variable_searched
Definition: statement.c:3496
type ultimate_type(type)
Definition: type.c:3466
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
Definition: type.c:4880
#define reference_indices(x)
Definition: ri.h:2328
#define entity_type(x)
Definition: ri.h:2792

References entity_type, gen_length(), loop_depth, reference_count, reference_indices, reference_variable, type_depth(), ultimate_type(), and variable_searched.

Referenced by count_references_to_variable_element(), and declarations_count_element_references_to_v_p().

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

◆ count_loop_in()

static bool count_loop_in ( loop __attribute__((unused))  l)
static

Definition at line 3644 of file statement.c.

3645 {
3646  loop_depth++;
3647  return true;
3648 }

References loop_depth.

Referenced by count_references_to_variable(), and count_references_to_variable_element().

+ Here is the caller graph for this function:

◆ count_loop_out()

static void count_loop_out ( loop __attribute__((unused))  l)
static

Definition at line 3650 of file statement.c.

3651 {
3652  loop_depth--;
3653 }

References loop_depth.

Referenced by count_references_to_variable(), and count_references_to_variable_element().

+ Here is the caller graph for this function:

◆ count_references_to_v_p()

static bool count_references_to_v_p ( reference  r)
static

10: arbitrary value for references nested in at least one loop

Definition at line 3584 of file statement.c.

3585 {
3586  bool result= true;
3587  entity rv = reference_variable(r);
3588  if (rv == variable_searched) {
3589  /* 10: arbitrary value for references nested in at least one loop */
3590  reference_count += (loop_depth > 0 ? 10 : 1 );
3591  }
3592  return result;
3593 }

References loop_depth, reference_count, reference_variable, and variable_searched.

Referenced by count_references_to_variable(), and declarations_count_references_to_v_p().

+ Here is the caller graph for this function:

◆ count_references_to_variable()

int count_references_to_variable ( statement  s,
entity  v 
)

Definition at line 3655 of file statement.c.

3656 {
3657  reference_count = 0;
3658  loop_depth = 0;
3659  variable_searched = v;
3664  return reference_count;
3665 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
static bool count_loop_in(loop __attribute__((unused)) l)
Definition: statement.c:3644
static bool declarations_count_references_to_v_p(statement st)
Definition: statement.c:3595
static void count_loop_out(loop __attribute__((unused)) l)
Definition: statement.c:3650
static bool count_references_to_v_p(reference r)
Definition: statement.c:3584
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218

References count_loop_in(), count_loop_out(), count_references_to_v_p(), declarations_count_references_to_v_p(), entity_undefined, gen_multi_recurse(), gen_null(), loop_depth, loop_domain, reference_count, reference_domain, statement_domain, and variable_searched.

+ Here is the call graph for this function:

◆ count_references_to_variable_element()

int count_references_to_variable_element ( statement  s,
entity  v 
)

Definition at line 3666 of file statement.c.

3667 {
3668  reference_count = 0;
3669  loop_depth = 0;
3670  variable_searched = v;
3675  return reference_count;
3676 }
static bool declarations_count_element_references_to_v_p(statement st)
Definition: statement.c:3628
static bool count_element_references_to_v_p(reference r)
This function checks reference to proper elements, not slices.
Definition: statement.c:3613

References count_element_references_to_v_p(), count_loop_in(), count_loop_out(), declarations_count_element_references_to_v_p(), entity_undefined, gen_multi_recurse(), gen_null(), loop_depth, loop_domain, reference_count, reference_domain, statement_domain, and variable_searched.

+ Here is the call graph for this function:

◆ count_static_references_to_v_p()

static bool count_static_references_to_v_p ( reference  r)
static

Count static references.

Definition at line 3561 of file statement.c.

3562 {
3563  bool result= true;
3564  entity rv = reference_variable(r);
3565  if (rv == variable_searched) {
3566  reference_count++;
3567  }
3568  return result;
3569 }

References reference_count, reference_variable, and variable_searched.

Referenced by count_static_references_to_variable().

+ Here is the caller graph for this function:

◆ count_static_references_to_variable()

int count_static_references_to_variable ( statement  s,
entity  v 
)

Definition at line 3571 of file statement.c.

3572 {
3573  reference_count = 0;
3574  variable_searched = v;
3577  return reference_count;
3578 }
static bool count_static_references_to_v_p(reference r)
Count static references.
Definition: statement.c:3561

References count_static_references_to_v_p(), entity_undefined, gen_null(), gen_recurse, reference_count, reference_domain, and variable_searched.

+ Here is the call graph for this function:

◆ declaration_statement_p()

bool declaration_statement_p ( statement  s)

Had to be optimized according to Beatrice Creusillet.

We assume that false is returned most of the time. String operations are avoided (almost) as much as possible.

For the time being a declaration statement is a call to continue with non-empty declarations.

FI: This could be fixed by adding + declaration in the instruction domainn

Initial implementation. It would have been better to check !ENDP() first.

ENDP(statement_declarations(s));

Definition at line 224 of file statement.c.

224  {
225  bool declaration_p = false;
226 
227  /* Initial implementation. It would have been better to check
228  !ENDP() first. */
229  //return instruction_continue_p(i) &&
230  //!ENDP(statement_declarations(s));
231 
232  if(!ENDP(statement_declarations(s))) {
234  if(instruction_call_p(i)) {
235  call c = instruction_call(i);
236  entity f = call_function(c);
237  declaration_p = entity_continue_p(f);
238  }
239  }
240 
241  return declaration_p;
242 }
bool entity_continue_p(entity f)
Definition: entity.c:1731
#define instruction_call_p(x)
Definition: ri.h:1527

References call_function, ENDP, entity_continue_p(), f(), instruction_call, instruction_call_p, statement_declarations, and statement_instruction.

Referenced by add_declaration_statement_here(), add_initialization_information_to_declaration_statement(), add_pragma_to_sequence(), add_statement_declarations(), BDSC(), bdsc_code_instrumentation(), compute_private_entity_list(), copy_write_statement(), create_block_if_needed(), declaration_statement_add_call_to_callees(), declaration_statement_to_initializations(), declaration_statements_p(), declarations_count_element_references_to_v_p(), declarations_count_references_to_v_p(), declarations_first_reference_to_v_p(), dependencies_filter(), depth_of_parallel_perfect_loop_nest(), depth_of_perfect_loop_nest(), do_isolate_statement(), do_redundant_load_store_elimination(), do_remove_redundant_communications_in_anyloop(), do_scalar_renaming_in_graph(), do_simplify_constant_address_expression_in_decl(), do_slightly_rename_entities(), do_split_decl_block_statements(), do_terapix_warmup(), DoInvariantsStatements(), gather_call_sites_in_block(), gen_omp_parallel(), generic_add_declaration_statement(), generic_insert_statement(), GenericAddLocalEntityToDeclarations(), inline_split_declarations(), insert_statement(), insert_statements_after_declarations(), internal_statement_to_direct_declarations(), IsolatedStatement(), live_in_paths_of_statement(), make_declaration_replication(), make_mpi_conversion(), memorize_precondition_for_summary_precondition(), move_declaration_control_node_declarations_to_statement(), mpi_initialize(), partial_eval_statement(), perfectly_nested_loop_index_at_depth(), perfectly_nested_loop_to_body_at_depth(), pragma_nonscop(), pragma_scop(), prepare_context(), process_true_call_stat(), rebuild_topological_sort(), remove_declaration_statement(), remove_unread_variable(), RemoveLocalEntityFromDeclarations(), rename_statement_declarations(), sequence_proper_declarations_rename_in_place(), sequence_to_post_pv(), simdize_simple_statements(), split_initializations_in_statement(), split_update_operator_statement_walker(), statement_purge_declarations_walker(), statement_to_points_to(), statement_to_post_pv(), statement_to_postcondition(), statement_to_transformer(), statement_to_transformer_list(), static_controlize_statement(), store_declarations_references(), store_local_array_declaration(), and taskify_statement().

+ Here is the call graph for this function:

◆ declaration_statement_to_initializations()

list declaration_statement_to_initializations ( statement  s)

Definition at line 1128 of file statement.c.

1129 {
1130  pips_assert("s is a declaration statement", declaration_statement_p(s));
1132  list iel = call_arguments(c);
1133  return iel;
1134 }

References call_arguments, declaration_statement_p(), instruction_call, pips_assert, and statement_instruction.

+ Here is the call graph for this function:

◆ declaration_statements_p()

bool declaration_statements_p ( list  sl)

Check that all statements contained in statement list sl are declaration statements.

Parameters
sll

Definition at line 1099 of file statement.c.

1100 {
1101  bool declaration_p = true;
1102 
1103  FOREACH(STATEMENT, s, sl) {
1104  if(!declaration_statement_p(s)) {
1105  declaration_p = false;
1106  break;
1107  }
1108  }
1109 
1110  return declaration_p;
1111 }

References declaration_statement_p(), FOREACH, and STATEMENT.

+ Here is the call graph for this function:

◆ declarations_count_element_references_to_v_p()

static bool declarations_count_element_references_to_v_p ( statement  st)
static

Definition at line 3628 of file statement.c.

3629 {
3630  if (declaration_statement_p(st))
3631  {
3633  {
3634  value init_val = entity_initial(decl);
3635  if (! value_undefined_p(init_val))
3636  {
3638  }
3639  }
3640  }
3641  return true;
3642 }
#define value_undefined_p(x)
Definition: ri.h:3017

References count_element_references_to_v_p(), declaration_statement_p(), ENTITY, entity_initial, FOREACH, gen_null(), gen_recurse, reference_domain, statement_declarations, and value_undefined_p.

Referenced by count_references_to_variable_element().

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

◆ declarations_count_references_to_v_p()

static bool declarations_count_references_to_v_p ( statement  st)
static

Definition at line 3595 of file statement.c.

3596 {
3597  if (declaration_statement_p(st))
3598  {
3600  {
3601  value init_val = entity_initial(decl);
3602  if (! value_undefined_p(init_val))
3603  {
3605  }
3606  }
3607  }
3608  return true;
3609 }

References count_references_to_v_p(), declaration_statement_p(), ENTITY, entity_initial, FOREACH, gen_null(), gen_recurse, reference_domain, statement_declarations, and value_undefined_p.

Referenced by count_references_to_variable().

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

◆ declarations_first_reference_to_v_p()

static bool declarations_first_reference_to_v_p ( statement  st)
static

Definition at line 3515 of file statement.c.

3516 {
3517  bool result = true;
3519  {
3520  if (declaration_statement_p(st))
3521  {
3523  {
3524  value init_val = entity_initial(decl);
3525  if (! value_undefined_p(init_val))
3526  {
3529  {
3530  result = false;
3531  break;
3532  }
3533  }
3534  }
3535  }
3536  }
3537  else
3538  result = false;
3539 
3540  return result;
3541 }
static bool first_reference_to_v_p(reference r)
Definition: statement.c:3498
static reference first_reference_to_v
Return first reference found.
Definition: statement.c:3495
#define reference_undefined_p(x)
Definition: ri.h:2303

References declaration_statement_p(), ENTITY, entity_initial, first_reference_to_v, first_reference_to_v_p(), FOREACH, gen_null(), gen_recurse, reference_domain, reference_undefined_p, statement_declarations, and value_undefined_p.

Referenced by find_reference_to_variable().

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

◆ decls_text_dup()

string decls_text_dup ( string  dt)

Duplicate statement decls_text.

Parameters
dtis the decls_text to duplicate
Returns
the duplicated decls_text. If it was an allocated string, it is strdup()ed

Not allocated, just the same:

Parameters
dtt

Definition at line 574 of file statement.c.

574  {
575  if (dt == NULL)
576  /* Not allocated, just the same: */
577  return dt;
578  else
579  return strdup(dt);
580 }

References strdup().

Referenced by copy_statement_attributes().

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

◆ default_generated_variable_commenter()

static string default_generated_variable_commenter ( __attribute__((unused)) entity  e)
static

Definition at line 2597 of file statement.c.

2598 {
2600 }
#define PIPS_DECLARATION_COMMENT
Definition: statement.c:2595

References PIPS_DECLARATION_COMMENT, and strdup().

+ Here is the call graph for this function:

◆ down_counter()

static bool down_counter ( statement  s)
static

Is it printable on one line?

Must be an unlabelled CONTINUE

Definition at line 2409 of file statement.c.

2410 {
2412 
2414 
2415  /* Is it printable on one line? */
2416  if(instruction_sequence_p(i)) {
2417  current_line += 0;
2418  }
2420  /* Must be an unlabelled CONTINUE */
2421  current_line += 0;
2422  }
2423  else {
2424  current_line += 1;
2425  }
2426 
2428 
2429  return true;
2430 }
void extend_persistant_statement_to_int(persistant_statement_to_int f, statement k, intptr_t v)
Definition: ri.c:1660
bool empty_statement_or_labelless_continue_p(statement st)
Return true if the statement is an empty instruction block without label or a continue without label ...
Definition: statement.c:446
static int current_line
Poor attempt at associating physical line numbers to statement.
Definition: statement.c:2405
int statement_to_comment_length(statement stmt)
Number of comment line directly attached to a statement.
Definition: statement.c:2375
static persistant_statement_to_int stmt_to_line
Definition: statement.c:2406

References current_line, empty_statement_or_labelless_continue_p(), extend_persistant_statement_to_int(), instruction_sequence_p, statement_instruction, statement_to_comment_length(), and stmt_to_line.

Referenced by statement_to_line_number().

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

◆ empty_code_list_p()

bool empty_code_list_p ( list  l)

Definition at line 99 of file statement.c.

100 {
101  MAP(STATEMENT, s, if (!empty_code_p(s)) return false, l);
102  return true;
103 }
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
bool empty_code_p(statement s)
statement.c
Definition: statement.c:86

References empty_code_p(), MAP, and STATEMENT.

+ Here is the call graph for this function:

◆ empty_code_p()

bool empty_code_p ( statement  s)

statement.c

Definition at line 86 of file statement.c.

87 {
88  if ((!s) || statement_undefined_p(s))
89  return true;
90 
91  bool statement_is_empty = true;
92  gen_context_recurse(s,&statement_is_empty, call_domain, call_filter, gen_null2);
93 
94  pips_debug(3, "returning %d\n", statement_is_empty);
95 
96  return statement_is_empty;
97 }
static bool call_filter(call c, bool *statement_is_empty)
Definition: statement.c:76
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145

References call_domain, call_filter(), gen_context_recurse, gen_null2(), pips_debug, and statement_undefined_p.

Referenced by empty_code_list_p(), hpf_compile_sequential_loop(), io_efficient_compile(), and number_of_non_empty_statements().

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

◆ empty_comments_p()

◆ exit_statement_p()

bool exit_statement_p ( statement  s)

Definition at line 177 of file statement.c.

177  {
179  return exit_instruction_p(i);
180 }
bool exit_instruction_p(instruction i)
Definition: instruction.c:201

References exit_instruction_p(), and statement_instruction.

+ Here is the call graph for this function:

◆ external_statement_identification()

string external_statement_identification ( statement  s)

Does work neither with undefined statements nor with defined statements with undefined instructions.

Returns a statement identity, its number and the breakdown of its ordering, as well as information about the instruction.

Definition at line 1671 of file statement.c.

1672 {
1673  string buffer;
1675  string instrstring = instruction_identification(i);
1676  int so = statement_ordering(s);
1677  entity called = entity_undefined;
1678 
1679  if(same_string_p(instrstring, "CALL")) {
1680  called = call_function(instruction_call(i));
1681  }
1682 
1683  int n = asprintf(&buffer, "%td (%d, %d): %s %s\n",
1684  statement_number(s),
1685  ORDERING_NUMBER(so),
1686  ORDERING_STATEMENT(so),
1687  instrstring,
1688  entity_undefined_p(called)? "" : module_local_name(called));
1689 
1690  pips_assert("asprintf ok", n!=-1);
1691 
1692  return buffer;
1693 }
string instruction_identification(instruction i)
Return a constant string representing symbolically the instruction type.
Definition: instruction.c:284
#define asprintf
Definition: misc-local.h:225
#define ORDERING_NUMBER(o)
#define ORDERING_STATEMENT(o)
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
#define statement_ordering(x)
Definition: ri.h:2454
#define entity_undefined_p(x)
Definition: ri.h:2762

References asprintf, buffer, call_function, entity_undefined, entity_undefined_p, instruction_call, instruction_identification(), module_local_name(), ORDERING_NUMBER, ORDERING_STATEMENT, pips_assert, same_string_p, statement_instruction, statement_number, and statement_ordering.

+ Here is the call graph for this function:

◆ figure_out_if_it_is_a_format()

bool figure_out_if_it_is_a_format ( instruction  i,
bool format_inside_statement_has_been_found 
)

Useless to go on further:

Parameters
format_inside_statement_has_been_foundormat_inside_statement_has_been_found

Definition at line 2343 of file statement.c.

2344 {
2345  if (instruction_format_p(i)) {
2346  *format_inside_statement_has_been_found = true;
2347  /* Useless to go on further: */
2348  gen_recurse_stop(NULL);
2349  return false;
2350  }
2351  return true;
2352 }
bool instruction_format_p(instruction i)
Test if an instruction is a Fortran FORMAT.
Definition: instruction.c:222

References gen_recurse_stop(), and instruction_format_p().

Referenced by format_inside_statement_p().

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

◆ find_first_comment()

static char** find_first_comment ( statement  s)
static

Find the first comment of a statement, if any.

returns a pointer to the comment if found, NULL otherwise

Unfortunately empty_comments may be used to decorate a statement although this makes the statement !gen_defined_p(). empty_comments is also used as a return value to signal that non statement legally carrying a comment has been found.

The whole comment business should be cleaned up.

let's hope the parser generates an empty string as comment rather than empty_comments which is defined as empty_string

We've found it!

No comment found:

comment carrying statement:

Definition at line 1801 of file statement.c.

1802 {
1803  static char * an_empty_comment = empty_comments;
1804  if (statement_block_p(s)) {
1807  /* let's hope the parser generates an empty string as
1808  comment rather than empty_comments which is defined as
1809  empty_string */
1810  if (*comment!=empty_comments)
1811  /* We've found it! */
1812  return comment;
1813  }
1814  /* No comment found: */
1815  return &an_empty_comment;
1816  }
1817  else
1818  /* comment carrying statement: */
1819  return &statement_comments(s);
1820 }

References comment(), empty_comments, find_first_statement_comment(), FOREACH, STATEMENT, statement_block(), statement_block_p, and statement_comments.

Referenced by insert_comments_to_statement().

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

◆ find_first_statement_comment()

char** find_first_statement_comment ( statement  s)

Find the first non-empty comment of a statement, if any returns a pointer to the comment if found, pointer to a "string_undefined" otherwise.

We've found it!

No comment found:

Ok, plain statement:

Definition at line 1772 of file statement.c.

1773 {
1774  static char * an_empty_comment = empty_comments;
1775  if (statement_block_p(s)) {
1778  if (!empty_comments_p(*comment))
1779  /* We've found it! */
1780  return comment;
1781  }
1782  /* No comment found: */
1783  return &an_empty_comment;
1784  }
1785  else
1786  /* Ok, plain statement: */
1787  return &statement_comments(s);
1788 }

References comment(), empty_comments, empty_comments_p(), find_first_statement_comment(), FOREACH, STATEMENT, statement_block(), statement_block_p, and statement_comments.

Referenced by append_comments_to_statement(), find_first_comment(), find_first_statement_comment(), and parallelize_annotated_loop_nest().

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

◆ find_implicit_goto()

static bool find_implicit_goto ( statement  s,
list tl 
)
static

Next Expression

No need to go down in call statements

Definition at line 3107 of file statement.c.

3108 {
3109  bool found = false;
3110 
3111  if(statement_call_p(s)) {
3113  entity f = call_function(c);
3114 
3116  list ce = list_undefined;
3117 
3118  for(ce = call_arguments(c); !ENDP(ce); ce = CDR(CDR(ce))) {
3119  expression e = EXPRESSION(CAR(ce));
3121 
3122  pips_assert("expression e must be a call", expression_call_p(e));
3123 
3124  if (strcmp(entity_local_name(f1), "ERR=") == 0 ||
3125  strcmp(entity_local_name(f1), "END=") == 0) {
3126  expression ne = EXPRESSION(CAR(CDR(ce))); /* Next Expression */
3128 
3129  pips_assert("expression ne must be a call", expression_call_p(ne));
3130  pips_assert("l is a label", entity_label_p(l));
3131 
3132  *tl = CONS(ENTITY, l, *tl);
3133  }
3134  }
3135  }
3136  /* No need to go down in call statements */
3137  found = true;
3138  }
3139 
3140  return !found;
3141 }
bool statement_call_p(statement s)
Definition: statement.c:364
#define ENTITY_WRITE_P(e)
Fortran IO Management.
#define ENTITY_CLOSE_P(e)
#define ENTITY_OPEN_P(e)
#define ENTITY_READ_P(e)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool entity_label_p(entity e)
Definition: entity.c:678
bool expression_call_p(expression e)
Definition: expression.c:415
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References call_arguments, call_function, CAR, CDR, CONS, ENDP, ENTITY, ENTITY_CLOSE_P, entity_label_p(), entity_local_name(), ENTITY_OPEN_P, ENTITY_READ_P, ENTITY_WRITE_P, EXPRESSION, expression_call_p(), expression_syntax, f(), instruction_call, list_undefined, pips_assert, statement_call_p(), statement_instruction, and syntax_call.

Referenced by statement_to_implicit_target_labels().

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

◆ find_reference_to_variable()

reference find_reference_to_variable ( statement  s,
entity  v 
)

Definition at line 3543 of file statement.c.

3544 {
3547  variable_searched = v;
3551  NULL);
3555  return r;
3556 }
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
static bool declarations_first_reference_to_v_p(statement st)
Definition: statement.c:3515
#define reference_undefined
Definition: ri.h:2302

References copy_reference(), declarations_first_reference_to_v_p(), entity_undefined, first_reference_to_v, first_reference_to_v_p(), gen_multi_recurse(), gen_null2(), reference_domain, reference_undefined, statement_domain, and variable_searched.

+ Here is the call graph for this function:

◆ find_statement_from_label()

statement find_statement_from_label ( statement  s,
entity  label 
)

find a statement in s with entity label

Parameters
sstatement to search into
labellabel of the searched statement
Returns
statement found or statement_undefined
Parameters
labelabel

Definition at line 3810 of file statement.c.

3811 {
3812  struct fswl p = { statement_undefined , label };
3814  return p.st;
3815 }
static bool find_statements_with_label_walker(statement s, struct fswl *p)
helper to find statement with a particular label as label should be unique, the function stops once a...
Definition: statement.c:3791
statement st
statement matching condition
Definition: statement.c:3778
structure used by find_statements_with_label_walker
Definition: statement.c:3777

References find_statements_with_label_walker(), gen_context_recurse, gen_null2(), fswl::st, statement_domain, and statement_undefined.

Referenced by find_statement_from_label_name().

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

◆ find_statement_from_label_name()

statement find_statement_from_label_name ( statement  s,
const char *  module_name,
const char *  label_name 
)
Parameters
module_nameodule_name
label_nameabel_name

Definition at line 3816 of file statement.c.

3817 {
3818  entity label = find_label_entity(module_name,label_name);
3819  if(entity_undefined_p(label))
3820  return statement_undefined;
3821  else
3822  return find_statement_from_label(s,label);
3823 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
statement find_statement_from_label(statement s, entity label)
find a statement in s with entity label
Definition: statement.c:3810
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43

References entity_undefined_p, find_label_entity(), find_statement_from_label(), module_name(), and statement_undefined.

Referenced by group_constants(), isolate_statement(), outline(), outliner(), and solve_hardware_constraints().

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

◆ find_statements_with_label_walker()

static bool find_statements_with_label_walker ( statement  s,
struct fswl p 
)
static

helper to find statement with a particular label as label should be unique, the function stops once a statement is found

Parameters
sstatement to inspect
pstruct containing the list to fill and the label to search
Returns

Definition at line 3791 of file statement.c.

3792 {
3793  if( same_entity_p(statement_label(s),p->key) ||
3795  {
3796  p->st=s;
3797  gen_recurse_stop(NULL);
3798  }
3799  return true;
3800 }
loop statement_loop(statement s)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement s)
Definition: statement.c:349
entity key
used for the condition
Definition: statement.c:3779
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References gen_recurse_stop(), fswl::key, loop_label, same_entity_p(), fswl::st, statement_label, statement_loop(), and statement_loop_p().

Referenced by find_statement_from_label().

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

◆ find_statements_with_pragma()

list find_statements_with_pragma ( statement  s,
const char *  begin 
)

Get a list of statements with pragma begining with a prefix.

Parameters
sis the statement to start to recurse
beginis the prefix a pragma has to begin with to be selected
Returns
a list of statement
Parameters
beginegin

Definition at line 3912 of file statement.c.

3913 {
3914  struct fswp p = { NIL, begin };
3916  return gen_nreverse(p.l);
3917 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
static bool find_statements_with_pragma_walker(statement s, struct fswp *p)
Definition: statement.c:3893
list l
Definition: statement.c:3889
const char * begin
Definition: statement.c:3890
used to pass parameters to find_statements_with_comment_walker
Definition: statement.c:3888

References fswp::begin, find_statements_with_pragma_walker(), gen_context_recurse, gen_nreverse(), gen_null2(), fswp::l, NIL, and statement_domain.

Referenced by do_statement_insertion(), loop_expansion(), and outline().

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

◆ find_statements_with_pragma_walker()

static bool find_statements_with_pragma_walker ( statement  s,
struct fswp p 
)
static

Definition at line 3893 of file statement.c.

3894 {
3896  {
3897  p->l=CONS(STATEMENT,s,p->l);
3898  gen_recurse_stop(NULL);
3899  }
3900  return true;
3901 }
extension get_extension_from_statement_with_pragma(statement s, const char *seed)
Get the extension of a statement with pragma beginning with a prefix.
Definition: statement.c:3871

References fswp::begin, CONS, gen_recurse_stop(), get_extension_from_statement_with_pragma(), fswp::l, and STATEMENT.

Referenced by find_statements_with_pragma().

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

◆ first_reference_to_v_p()

static bool first_reference_to_v_p ( reference  r)
static

Definition at line 3498 of file statement.c.

3499 {
3500  bool result= true;
3502  entity rv = reference_variable(r);
3503  if (rv == variable_searched) {
3505  result = false;
3506  }
3507  }
3508  else
3509  result = false;
3510 
3511  return result;
3512 }

References first_reference_to_v, reference_undefined_p, reference_variable, and variable_searched.

Referenced by declarations_first_reference_to_v_p(), and find_reference_to_variable().

+ Here is the caller graph for this function:

◆ fix_block_statement_declarations()

void fix_block_statement_declarations ( statement  s)

s is assumed to be a block statement and its declarations field is assumed to be correct, but not necessarily the declaration statements within the block s.

This function checks that no variable is declared by a declaration statement within the block but not declared at the block level. Also, if a variable is declared at the block level but not by a declaration statement, a new declaration statement is added.

Definition at line 2930 of file statement.c.

2931 {
2932  list bdvl = gen_copy_seq(statement_declarations(s)); // block declarations
2933 
2934  pips_assert("s is a block statement", statement_block_p(s));
2935  pips_assert("No multiple declarations in declarations of s", gen_once_p(bdvl));
2936 
2937  if(!ENDP(bdvl)) {
2938  list sl = statement_block(s);
2939  list edvl = statements_to_direct_declarations(sl); // effective declarations
2940  list mdvl = gen_copy_seq(statement_declarations(s)); // block declarations
2941 
2942  // List of variables declared within the block but not at the
2943  // block level
2944  gen_list_and_not(&mdvl, edvl); // missing declarations
2945 
2946  // Add the missing declaration statements.
2947  // Might be better to add only one statement for all missing variables...
2948  FOREACH(ENTITY, v, mdvl) {
2950  }
2951  gen_free_list(mdvl);
2952 
2953  // List of variables declared within the block but not at the
2954  // block level
2955  gen_list_and_not(&edvl, bdvl);
2956 
2957  pips_assert("edvl-bdvl=empty set", ENDP(edvl));
2958  gen_free_list(edvl);
2959  }
2960  gen_free_list(bdvl);
2961 }
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
Definition: list.c:963
bool gen_once_p(list l)
FC: ARGH...O(n^2)!
Definition: list.c:758
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
list statements_to_direct_declarations(list sl)
Returns the declarations contained directly in the declaration statements of a list of statements.
Definition: statement.c:3334
statement add_declaration_statement(statement s, entity e)
Definition: statement.c:2790

References add_declaration_statement(), ENDP, ENTITY, FOREACH, gen_copy_seq(), gen_free_list(), gen_list_and_not(), gen_once_p(), pips_assert, statement_block(), statement_block_p, statement_declarations, and statements_to_direct_declarations().

Referenced by controlize_sequence().

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

◆ fix_sequence_statement_attributes()

void fix_sequence_statement_attributes ( statement  s)

Since blocks are not represented in Fortran, they cannot carry a label.

A continue could be added by the prettyprinter but it was decided not to support this facility. For debugging, it's better to have a transparent prettyprinter and no ghost statement with no ordering and no number.

Insert a CONTINUE and move the label, comment and statement number if any from the statement to the CONTINUE, if label there is.

The statement block has no label and no comment: just do nothing.

FI: why don't you try to keep them on the first statement, just in case it has empty slots?

There are some informations we need to keep: just add a CONTINUE to keep them:

This the label of a RETURN, do not forward it:

FI: at least in for loop to while loop conversion, the extensions is moved down to the while loop. I'm not sure this is the best source code location to fix the problem. I do not know if the extensions have been reused directly and so do not need to be freed here or not. In fact, it is copied below and could be freed.

Definition at line 2016 of file statement.c.

2017 {
2018  pips_assert("Should be an instruction block...",
2020 
2022  /* The statement block has no label and no comment: just do
2023  nothing. */
2025  }
2026  else {
2027  /* FI: why don't you try to keep them on the first statement,
2028  just in case it has empty slots? */
2029  /* There are some informations we need to keep: just add a
2030  CONTINUE to keep them: */
2031  list instructions;
2032  statement continue_s;
2033  const char* label_name =
2035 
2036  instructions = instruction_block(statement_instruction(s));
2037 
2038  if (strcmp(label_name, RETURN_LABEL_NAME) == 0)
2039  /* This the label of a RETURN, do not forward it: */
2041  else
2042  continue_s = make_continue_statement(statement_label(s));
2043 
2045  statement_comments(continue_s) = statement_comments(s);
2047  statement_number(continue_s) = statement_number(s);
2049 
2050  /* FI: at least in for loop to while loop conversion, the
2051  extensions is moved down to the while loop. I'm not sure
2052  this is the best source code location to fix the
2053  problem. I do not know if the extensions have been reused
2054  directly and so do not need to be freed here or not. In
2055  fact, it is copied below and could be freed. */
2056  // FI: This leads to an inconsistency in gen_recurse() when the
2057  // while loop is reached, but only when the new_controlizer is
2058  // used; I cannot spend more time on this right now
2059  // See: transform_a_for_loop_into_a_while_loop(). it might be
2060  // safer to operate at the statement level with a test for
2061  // forloop statements rather than use ancestors
2063  free_extensions(ext);
2065 
2066  instructions = CONS(STATEMENT, continue_s, instructions);
2067  instruction_block(statement_instruction(s)) = instructions;
2068 
2069  //pips_assert("The transformed statement s is consistent",
2070  // statement_consistent_p(s));
2071  }
2072 }
void free_extensions(extensions p)
Definition: ri.c:950
extensions make_extensions(list a)
Definition: ri.c:983
#define LABEL_PREFIX
Definition: naming-local.h:31
#define RETURN_LABEL_NAME
Definition: naming-local.h:106
#define instruction_block_p(i)
#define statement_extensions(x)
Definition: ri.h:2464

References CONS, empty_comments, empty_comments_p(), entity_empty_label(), entity_local_name(), free_extensions(), instruction_block, instruction_block_p, LABEL_PREFIX, make_continue_statement(), make_extensions(), NIL, pips_assert, RETURN_LABEL_NAME, STATEMENT, statement_comments, statement_extensions, statement_instruction, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, and unlabelled_statement_p().

Referenced by clean_statement(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), fix_statement_attributes_if_sequence(), full_loop_unroll(), hpfc_translate_call_with_distributed_args(), io_filter(), loop_rewrite(), transform_a_for_loop_into_a_while_loop(), and transform_a_for_loop_statement_into_a_while_loop().

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

◆ fix_statement_attributes_if_sequence()

void fix_statement_attributes_if_sequence ( statement  s)

Apply fix_sequence_statement_attributes() on the statement only if it really a sequence.

Definition at line 2078 of file statement.c.

2079 {
2081  if (!instruction_undefined_p(i)) {
2082  if (instruction_sequence_p(i))
2084  }
2085 }
void fix_sequence_statement_attributes(statement s)
Since blocks are not represented in Fortran, they cannot carry a label.
Definition: statement.c:2016
#define instruction_undefined_p(x)
Definition: ri.h:1455

References fix_sequence_statement_attributes(), instruction_sequence_p, instruction_undefined_p, and statement_instruction.

Referenced by controlize_forloop(), inline_expression_call(), MakeStatementLike(), rice_loop(), and test_rewrite().

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

◆ forloop_statement_p()

bool forloop_statement_p ( statement  s)

Definition at line 209 of file statement.c.

209  {
211 
212  return instruction_forloop_p(i);
213 }
#define instruction_forloop_p(x)
Definition: ri.h:1536

References instruction_forloop_p, and statement_instruction.

Referenced by transform_a_for_loop_statement_into_a_while_loop().

+ Here is the caller graph for this function:

◆ format_inside_statement_p()

bool format_inside_statement_p ( statement  s)

Definition at line 2360 of file statement.c.

2361 {
2362  bool format_inside_statement_has_been_found = false;
2363 
2364  gen_context_recurse(s,&format_inside_statement_has_been_found,
2366 
2367  return format_inside_statement_has_been_found;
2368 }
bool figure_out_if_it_is_a_format(instruction i, bool *format_inside_statement_has_been_found)
Definition: statement.c:2343
#define instruction_domain
newgen_functional_domain_defined
Definition: ri.h:202

References figure_out_if_it_is_a_format(), gen_context_recurse, gen_null2(), and instruction_domain.

Referenced by remove_all_unreachable_controls_of_an_unstructured(), and remove_unreachable_following_control().

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

◆ format_statement_p()

bool format_statement_p ( statement  s)

Test if a statement is a Fortran FORMAT.

Definition at line 273 of file statement.c.

274 {
276 
277  return instruction_format_p(i);
278 }

References instruction_format_p(), and statement_instruction.

Referenced by clear_label(), and statement_to_label().

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

◆ fortran_return_statement_p()

bool fortran_return_statement_p ( statement  s)

Test if a statement is a Fortran "return".

Definition at line 188 of file statement.c.

188  {
191 }
bool fortran_return_instruction_p(instruction i)
Definition: instruction.c:191

References fortran_return_instruction_p(), and statement_instruction.

Referenced by statement_remove_useless_label().

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

◆ gather_all_comments_of_a_statement()

string gather_all_comments_of_a_statement ( statement  s)

Gather all the comments recursively found in the given statement and return them in a strduped string (NULL if no comment found).

Do not forget to free the string returned later when no longer used.

Definition at line 1760 of file statement.c.

1761 {
1762  string comments = NULL;
1763  gen_context_recurse(s, &comments, statement_domain,
1765  return comments?comments:empty_comments;
1766 }
static bool gather_all_comments_of_a_statement_filter(statement s, string *all_comments)
Definition: statement.c:1740

References empty_comments, gather_all_comments_of_a_statement_filter(), gen_context_recurse, gen_null2(), and statement_domain.

Referenced by fuse_2_control_nodes().

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

◆ gather_all_comments_of_a_statement_filter()

static bool gather_all_comments_of_a_statement_filter ( statement  s,
string all_comments 
)
static

Definition at line 1740 of file statement.c.

1741 {
1742  string the_comments = statement_comments(s);
1743  if (!empty_comments_p(the_comments)) {
1744  string old = *all_comments;
1745  *all_comments = strdup(
1746  old==NULL?
1747  the_comments:
1748  concatenate(old, the_comments, NULL));
1749  free(old);
1750  }
1751  return true;
1752 }

References concatenate(), empty_comments_p(), free(), statement_comments, and strdup().

Referenced by gather_all_comments_of_a_statement().

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

◆ gather_and_remove_all_format_statements()

list gather_and_remove_all_format_statements ( statement  s)

Used to keep aside the FORMAT before many code transformation that could remove them either.

It just return a list of all the FORMAT statement and replace them with NOP.

Definition at line 2298 of file statement.c.

2299 {
2300  list all_formats = NIL;
2301 
2302  gen_context_recurse(s,&all_formats, statement_domain,
2304 
2305  return all_formats = gen_nreverse(all_formats);
2306 }
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
void gather_and_remove_all_format_statements_rewrite(statement s, list *all_formats)
Definition: statement.c:2270

References gather_and_remove_all_format_statements_rewrite(), gen_context_recurse, gen_nreverse(), gen_true2(), NIL, and statement_domain.

Referenced by put_formats_at_module_beginning(), and put_formats_at_module_end().

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

◆ gather_and_remove_all_format_statements_rewrite()

void gather_and_remove_all_format_statements_rewrite ( statement  s,
list all_formats 
)

Put the instruction with the statement attributes in new_format.

Replace the old FORMAT with a NOP:

Parameters
all_formatsll_formats

Definition at line 2270 of file statement.c.

2271 {
2273  if (instruction_format_p(i)) {
2274  /* Put the instruction with the statement attributes in
2275  new_format. */
2276  statement new_format = instruction_to_statement(i);
2277  statement_label(new_format) = statement_label(s);
2278  statement_number(new_format) = statement_number(s);
2279  statement_comments(new_format) = statement_comments(s);
2280  statement_extensions(new_format) = statement_extensions(s);
2281  /* Replace the old FORMAT with a NOP: */
2288 
2289  *all_formats = CONS(STATEMENT, new_format,*all_formats);
2290  }
2291 }
statement instruction_to_statement(instruction instr)
Build a statement from a give instruction.
Definition: statement.c:597
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
extensions empty_extensions(void)
extension.c
Definition: extension.c:43

References CONS, empty_comments, empty_extensions(), entity_empty_label(), instruction_format_p(), instruction_to_statement(), make_instruction_block(), NIL, STATEMENT, statement_comments, statement_extensions, statement_instruction, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_ordering, and STATEMENT_ORDERING_UNDEFINED.

Referenced by gather_and_remove_all_format_statements().

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

◆ generated_variable_comment()

string generated_variable_comment ( entity  e)

Definition at line 2629 of file statement.c.

2630 {
2632 }
static generated_variable_commenter generated_variable_commenters[MAX_COMMENTERS]
Definition: statement.c:2611
static size_t nb_commenters
Definition: statement.c:2614

References generated_variable_commenters, and nb_commenters.

Referenced by add_declaration_statement_here(), and generic_add_declaration_statement().

+ Here is the caller graph for this function:

◆ generic_add_declaration_statement()

static statement generic_add_declaration_statement ( statement  s,
entity  e,
bool  before_p 
)
static

Add a new declaration statement.

Declarations are not only lists of entities at the block level and in the symbol table, but also declaration statement to carry the line number, comments, and the declarations local to the declaration statement. This function is low-level and does not maintain the consistency of the PIPS internal representation.

Parameters
sStatement s must be a sequence. A new declaration statement is generated to declare e. This statement is inserted after the existing declaration statements in s, or, if no declaration statement is present, at the beginning of the sequence in s.
eVariable to declare. The declaration of e at s level is not checked. The existence of a previous declaration statement for e is not checked either. The caller is responsible for the consistency management between the declaration statements in s and the list of declaration at s level.
Returns
statement s modified by side-effects.

For the time being, a declaration statement is a continue statement. Beware that the possible dependencies between the new declaration and existing declarations are not checked.

Look for the last declaration: it is pointed to by pl

Do we have previous declarations to skip?

SG: if CAR(pl) has same comment and same type as ds, merge them

SG: otherwise, insert ds

The new declaration is inserted before sl

ifdebug(8) {

pips_debug(8, "Statement after declaration insertion:\n");

print_statement(s);

}

Definition at line 2711 of file statement.c.

2712 {
2713  if(statement_block_p(s)) {
2714  list sl = statement_block(s); //statement list
2715  list cl = list_undefined; // current statement list
2716  list pl = NIL; // previous statement list
2717  list nsl = list_undefined; // new statement list
2718  string comment = generated_variable_comment(e);
2721  comment);
2722 
2723  if (before_p)
2724  cl = sl;
2725  else
2726  {
2727  /* Look for the last declaration: it is pointed to by pl */
2728  for(cl=sl; !ENDP(cl); POP(cl)) {
2729  statement cs = STATEMENT(CAR(cl));
2730  if(declaration_statement_p(cs)) {
2731  pl = cl;
2732  }
2733  else {
2734  break;
2735  }
2736  }
2737  }
2738 
2739  /* Do we have previous declarations to skip? */
2740  if(!ENDP(pl)) {
2741  /* SG: if CAR(pl) has same comment and same type as ds, merge them */
2742  statement spl = STATEMENT(CAR(pl));
2744  free_statement(ds);
2746  nsl=sl;
2747  }
2748  /* SG: otherwise, insert ds */
2749  else
2750  {
2751  CDR(pl) = NIL; // Truncate sl
2752  nsl = gen_nconc(sl, CONS(STATEMENT, ds, cl));
2753  }
2754  }
2755  else { // pl == NIL
2756  /* The new declaration is inserted before sl*/
2757  pips_assert("The above loop was entered at most once", sl==cl);
2758  if (before_p && !ENDP(sl) && declaration_statement_p(STATEMENT(CAR(sl))))
2759  {
2760  statement ssl = STATEMENT(CAR(sl));
2762  {
2763  free_statement(ds);
2765  nsl=sl;
2766  }
2767  else
2768  nsl = CONS(STATEMENT, ds, sl);
2769  }
2770  else
2771  nsl = CONS(STATEMENT, ds, sl);
2772  }
2773 
2775  }
2776  else
2777  {
2778  pips_internal_error("can only add declarations to statement blocks");
2779  }
2780 
2781  // FI: avoid the ri/prettyprint cycle
2782  /* ifdebug(8) { */
2783  /* pips_debug(8, "Statement after declaration insertion:\n"); */
2784  /* print_statement(s); */
2785  /* } */
2786 
2787  return s;
2788 }

References add_declaration_to_declaration_statement_p(), CAR, CDR, comment(), CONS, declaration_statement_p(), ENDP, ENTITY, free_statement(), gen_nconc(), generated_variable_comment(), instruction_block, list_undefined, make_declaration_statement(), NIL, pips_assert, pips_internal_error, pl, POP, STATEMENT, statement_block(), statement_block_p, statement_declarations, statement_instruction, and STATEMENT_NUMBER_UNDEFINED.

Referenced by add_declaration_statement(), and add_declaration_statement_at_beginning().

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

◆ generic_insert_statement()

static void generic_insert_statement ( statement  s,
statement  s1,
bool  before 
)
static

insert statement s1 before or after statement s

If statement s is a sequence, simply insert s1 at the beginning or at the end of the sequence s.

If not, create a new statement s2 with s's fields and update s as a sequence with no comments and undefined number and ordering. The sequence is either "s1;s2" if "before" is true or "s2;s1" else.

ATTENTION !!! : this version is not for unstructured case and this is not asserted.

s cannot be a declaration statement, because the insertion scheme used would modify its scope. Also s1 cannot be a declaration if s is not a sequence. And if s is a sequence add_declaration_statement() should be used instead to insert the new declaration at the best possible place.

no duplication

Definition at line 2494 of file statement.c.

2497 {
2498  list ls;
2500  if (instruction_sequence_p(i))
2501  {
2502  ls = instruction_block(i);
2503  if (before)
2504  {
2505  if(!ENDP(ls) && declaration_statement_p(STATEMENT(CAR(ls))))
2506  {
2507  while( !ENDP(CDR(ls)) && declaration_statement_p(STATEMENT(CAR(CDR(ls))))) POP(ls);
2508  CDR(ls)=CONS(STATEMENT,s1,CDR(ls));
2509  ls=instruction_block(i);
2510  }
2511  else
2512  ls = CONS(STATEMENT,s1,ls);
2513  }
2514  else
2515  ls = gen_nconc(ls,CONS(STATEMENT,s1,NIL));
2516  instruction_block(i) = ls;
2517  }
2518  else
2519  {
2521  statement_label(s),
2522  statement_number(s),
2523  statement_ordering(s),
2524  statement_comments(s),
2529  );
2530  /* no duplication */
2537  statement_decls_text(s)=NULL;
2539 
2540  if (before)
2541  ls = CONS(STATEMENT,s1,CONS(STATEMENT,s2,NIL));
2542  else
2543  ls = CONS(STATEMENT,s2,CONS(STATEMENT,s1,NIL));
2544 
2546  }
2547 }
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
synchronization make_synchronization_none(void)
Definition: ri.c:2424
sequence make_sequence(list a)
Definition: ri.c:2125
statement update_statement_instruction(statement s, instruction i)
Replace the instruction in statement s by instruction i.
Definition: statement.c:3039
#define string_undefined
Definition: newgen_types.h:40
#define instruction_undefined
Definition: ri.h:1454
#define statement_decls_text(x)
Definition: ri.h:2462
s1
Definition: set.c:247

References CAR, CDR, CONS, declaration_statement_p(), empty_extensions(), ENDP, entity_empty_label(), gen_nconc(), instruction_block, instruction_sequence_p, instruction_undefined, make_instruction_sequence(), make_sequence(), make_statement(), make_synchronization_none(), NIL, POP, s1, STATEMENT, statement_comments, statement_declarations, statement_decls_text, statement_extensions, statement_instruction, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_ordering, STATEMENT_ORDERING_UNDEFINED, string_undefined, and update_statement_instruction().

Referenced by insert_statement(), and insert_statement_no_matter_what().

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

◆ get_extension_from_statement_with_pragma()

extension get_extension_from_statement_with_pragma ( statement  s,
const char *  seed 
)

Get the extension of a statement with pragma beginning with a prefix.

Parameters
sis the statement to work on
seedis the prefix a pragma has to begin with to be selected
Returns
the first extension matching the pragma
Parameters
seedeed

Definition at line 3871 of file statement.c.

3872 {
3874  FOREACH(EXTENSION,ex,exs)
3875  {
3876  pragma pr = extension_pragma(ex);
3877  if(pragma_string_p(pr) && strstr(pragma_string(pr),seed))
3878  {
3879  return ex;
3880  }
3881  }
3882  return NULL;
3883 }
#define pragma_string(x)
Definition: ri.h:2033
#define pragma_string_p(x)
Definition: ri.h:2031
#define extension_pragma(x)
Definition: ri.h:1295
#define EXTENSION(x)
EXTENSION.
Definition: ri.h:1253
#define extensions_extension(x)
Definition: ri.h:1330

References EXTENSION, extension_pragma, extensions_extension, FOREACH, pragma_string, pragma_string_p, and statement_extensions.

Referenced by find_statements_with_pragma_walker(), and if_conv_statement().

+ Here is the caller graph for this function:

◆ get_statement_depth()

int get_statement_depth ( statement  s,
statement  root 
)

computes the block-depth of a statement NOT INTENDED to generate entity name declared at particular block level : The block scope depends on the number of different blocks at the same depth !

Parameters
sstatement we compute the depth of
rootouter statement containing s
Returns
positive integer
Parameters
rootoot

Definition at line 3725 of file statement.c.

3726 {
3727  if( s == root )
3728  return 0;
3729  else {
3731  switch(instruction_tag(i))
3732  {
3734  {
3736  {
3738  return 1+get_statement_depth(s,stmt);
3739  }
3740  pips_internal_error("you should never reach this point");
3741  return -1;
3742  }
3743  case is_instruction_test:
3744  return
3748  case is_instruction_loop:
3755  pips_internal_error("not implemented for unstructured");
3756  return -1;
3757  default:
3758  pips_internal_error("you should never reach this point");
3759  return -1;
3760  };
3761  }
3762 
3763 }
int get_statement_depth(statement s, statement root)
computes the block-depth of a statement NOT INTENDED to generate entity name declared at particular b...
Definition: statement.c:3725
bool statement_substatement_p(statement s, statement root)
search a statement inside a statement
Definition: statement.c:3702
#define loop_body(x)
Definition: ri.h:1644
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_forloop
Definition: ri.h:1477
#define test_true(x)
Definition: ri.h:2835
#define instruction_forloop(x)
Definition: ri.h:1538
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
Definition: statement.c:54

References FOREACH, forloop_body, get_statement_depth(), instruction_block, instruction_forloop, instruction_loop, instruction_tag, instruction_test, instruction_whileloop, is_instruction_forloop, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, loop_body, pips_internal_error, STATEMENT, statement_instruction, statement_substatement_p(), test_false, test_true, and whileloop_body.

Referenced by get_statement_depth().

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

◆ insert_comments_to_statement()

void insert_comments_to_statement ( statement  s,
const char *  the_comments 
)

Insert a comment string (if non empty) at the beginning of the comments of a statement.

Parameters
the_commentsis strdup'ed in this function.

Nothing to add...

There are no comments yet:

Parameters
the_commentshe_comments

Definition at line 1916 of file statement.c.

1917  {
1918  if (empty_comments_p(the_comments))
1919  /* Nothing to add... */
1920  return;
1921 
1922  char **old = find_first_comment(s);
1923  if ( empty_comments_p(*old) ) {
1924  /* There are no comments yet: */
1925  put_a_comment_on_a_statement(s, strdup(the_comments));
1926  } else {
1927  char * new = strdup(concatenate(the_comments, *old, NULL));
1928  free(*old);
1929  *old=empty_comments;
1931  }
1932 }
static char ** find_first_comment(statement s)
Find the first comment of a statement, if any.
Definition: statement.c:1801

References concatenate(), empty_comments, empty_comments_p(), find_first_comment(), free(), put_a_comment_on_a_statement(), and strdup().

Referenced by copy_from_statement(), copy_to_statement(), copy_write_statement_with_cumulated_regions(), deal_with_pending_comment(), fuse_2_control_nodes(), generate_all_liveness_but(), generate_dynamic_liveness_for_primary(), generate_dynamic_liveness_management(), generate_io_statements_for_shared_arrays(), generate_remapping_code(), generate_remapping_include(), GENERATION(), gpu_ify_statement(), hpf_compile_loop(), inline_statement_crawler(), insert_impact_description_as_comment(), isolate_code_portion(), make_layout_statement(), make_shared_statement(), MakeLabeledStatement(), prepend_comment(), remapping_compile(), remapping_stats(), st_one_message(), transfert_statement(), and update_runtime_for_remapping().

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

◆ insert_statement()

void insert_statement ( statement  s,
statement  s1,
bool  before 
)

This is the normal entry point.

See previous function for comments.

insert statement s1 before or after statement s

If statement s is a sequence, simply insert s1 at the beginning or at the end of the sequence s.

If not, create a new statement s2 with s's fields and update s as a sequence with no comments and undefined number and ordering. The sequence is either "s1;s2" if "before" is true or "s2;s1" else.

ATTENTION !!! : this version is not for unstructured case and this is not asserted.

s cannot be a declaration statement, because the insertion scheme used would modify its scope. Also s1 cannot be a declaration if s is not a sequence. And if s is a sequence add_declaration_statement() should be used instead to insert the new declaration at the best possible place.

Parameters
s11
beforeefore

Definition at line 2570 of file statement.c.

2571 {
2572  pips_assert("Neither s nor s1 are declaration statements",
2575  generic_insert_statement(s, s1, before);
2576 }
static void generic_insert_statement(statement s, statement s1, bool before)
insert statement s1 before or after statement s
Definition: statement.c:2494

References declaration_statement_p(), generic_insert_statement(), pips_assert, and s1.

Referenced by abc_instrumentation_insert_before_statement(), add_counter(), add_pragma(), atomize_statement(), bottom_up_abc_insert_before_statement(), compile_barrier(), compile_body(), compile_omp(), compile_reduction(), compile_regions(), compute_region(), copy_n_reference(), copy_n_statement(), copy_write_statement_with_cumulated_regions(), ctx_generate_new_statement_cluster_dependant(), delay_communications_intraprocedurally(), do_add_pragma(), do_delay_communications_interprocedurally(), do_expression_reduction(), do_group_constants_terapix(), do_isolate_statement(), do_loop_expansion(), do_loop_expansion_init(), do_remove_redundant_communications_in_anyloop(), do_scalar_renaming_in_successors(), do_solve_hardware_constraints_on_volume(), do_split_structure(), do_split_structure_return_hook(), do_split_structure_return_hook_walker(), do_terapix_argument_handler(), dowhile_to_while_walker(), finalization(), FixCReturnStatements(), for_to_do_loop_conversion(), freia_allocate_new_images_if_needed(), generate_call_construct_begin_construct_end(), generate_call_flush(), generate_call_get_workchunk_loopbounds(), generate_call_init_regionArray(), generate_call_set_regionarray(), generate_call_stepalltoall(), generate_loop_workchunk(), generate_starpu_pragma(), GenericAddLocalEntityToDeclarations(), initilization(), inline_expression(), inline_expression_call(), inline_split_declarations(), inline_statement_crawler(), insert_endscop_in_sequence(), insert_statement_in_block(), insert_statements_after_declarations(), interprocedural_abc_insert_before_statement(), make_bottom_up_abc_tests(), make_interprocedural_abc_tests(), make_loadsave_statement(), make_mpi_conversion(), MakeForloop(), MakeSwitchStatement(), MakeWhileLoop(), new_local_image_variable(), openmp_task_generation(), outliner_file(), outliner_patch_parameters(), prepend_call(), process_true_call_stat(), put_formats_at_module_beginning(), put_formats_at_module_end(), reductions_rewrite(), region_to_statement(), sequence_working_false(), sesamify(), simd_loop_unroll(), simplify_subscript(), spire_distributed_unstructured_to_structured(), spire_shared_unstructured_to_structured(), step_compile_analysed_module(), terapix_loop_optimizer(), top_down_abc_array(), top_down_abc_insert_before_statement(), transfert_loop(), two_addresses_code_generator(), verify_array_element(), verify_array_variable(), and verify_scalar_variable().

+ Here is the call graph for this function:

◆ insert_statement_no_matter_what()

void insert_statement_no_matter_what ( statement  s,
statement  s1,
bool  before 
)

Break the IR consistency or, at the very least, do not insert new declarations at the usual place, i.e.

at the end of the already existing declarations.

Parameters
s11
beforeefore

Definition at line 2581 of file statement.c.

2582 {
2583  generic_insert_statement(s, s1, before);
2584 }

References generic_insert_statement(), and s1.

Referenced by do_split_decl_block_statements(), if_conversion_init(), make_mpi_conversion(), and simdize_simple_statements().

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

◆ instruction_to_declarations()

list instruction_to_declarations ( instruction  i)

Get a list of all variables declared recursively within an instruction.

Definition at line 3279 of file statement.c.

3280 {
3281  return statement_to_declarations(i);
3282 }
list statement_to_declarations(void *s)
Get a list of all variables declared recursively within a statement.
Definition: statement.c:3253

References statement_to_declarations().

Referenced by statement_flatten_declarations().

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

◆ internal_statement_to_direct_declarations()

static list internal_statement_to_direct_declarations ( statement  st)
static

No recursive descent.

Definition at line 3308 of file statement.c.

3309 {
3310  list sdl = NIL;
3311 
3312  if(declaration_statement_p(st)) {
3314  }
3315  else if(statement_unstructured_p(st)) {
3318  }
3319  return sdl;
3320 }
unstructured statement_unstructured(statement s)
Get the unstructured of a statement.
Definition: statement.c:1416
bool statement_unstructured_p(statement s)
Definition: statement.c:369
static list unstructured_to_direct_declarations(unstructured u)
Definition: statement.c:3288

References declaration_statement_p(), gen_copy_seq(), NIL, statement_declarations, statement_unstructured(), statement_unstructured_p(), and unstructured_to_direct_declarations().

Referenced by statement_to_direct_declarations(), statements_to_direct_declarations(), and unstructured_to_direct_declarations().

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

◆ look_for_control_effects()

static bool look_for_control_effects ( call  c,
bool control_effect_p 
)
static

Definition at line 3946 of file statement.c.

3947 {
3948  entity f = call_function(c);
3949  bool go_on_p = true;
3950  value fv = entity_initial(f);
3951 
3952  if(value_code_p(fv)) {
3953  * control_effect_p = true;
3954  go_on_p = false;
3955  }
3956  else if(value_intrinsic_p(fv)) {
3959  || ENTITY_C_RETURN_P(f)
3960  || ENTITY_RETURN_P(f)
3963  * control_effect_p = true;
3964  go_on_p = false;
3965  }
3966  }
3967  return go_on_p;
3968 }
#define ENTITY_ASSERT_SYSTEM_P(e)
include <assert.h>
#define ENTITY_EXIT_SYSTEM_P(e)
#define ENTITY_ABORT_SYSTEM_P(e)
#define ENTITY_C_RETURN_P(e)
#define ENTITY_ASSERT_FAIL_SYSTEM_P(e)
#define value_intrinsic_p(x)
Definition: ri.h:3074

References call_function, ENTITY_ABORT_SYSTEM_P, ENTITY_ASSERT_FAIL_SYSTEM_P, ENTITY_ASSERT_SYSTEM_P, ENTITY_C_RETURN_P, ENTITY_EXIT_SYSTEM_P, entity_initial, ENTITY_RETURN_P, f(), value_code_p, and value_intrinsic_p.

Referenced by statement_may_have_control_effects_p().

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

◆ look_for_exiting_intrinsic_calls()

static bool look_for_exiting_intrinsic_calls ( call  c,
bool control_effect_p 
)
static

Definition at line 4002 of file statement.c.

4003 {
4004  entity f = call_function(c);
4005  bool go_on_p = true;
4006  value fv = entity_initial(f);
4007 
4008  if(value_intrinsic_p(fv)) {
4011  || ENTITY_C_RETURN_P(f)
4012  || ENTITY_RETURN_P(f)
4015  * control_effect_p = true;
4016  go_on_p = false;
4017  }
4018  }
4019  return go_on_p;
4020 }

References call_function, ENTITY_ABORT_SYSTEM_P, ENTITY_ASSERT_FAIL_SYSTEM_P, ENTITY_ASSERT_SYSTEM_P, ENTITY_C_RETURN_P, ENTITY_EXIT_SYSTEM_P, entity_initial, ENTITY_RETURN_P, f(), and value_intrinsic_p.

Referenced by statement_may_contain_exiting_intrinsic_call_p().

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

◆ look_for_user_call()

static bool look_for_user_call ( call  c,
bool user_call_p 
)
static

Definition at line 3920 of file statement.c.

3921 {
3922  entity f = call_function(c);
3923  bool go_on_p = true;
3924 
3925  if(value_code_p(entity_initial(f))) {
3926  * user_call_p = true;
3927  go_on_p = false;
3928  }
3929  return go_on_p;
3930 }
bool user_call_p(call c)
Test if a call is a user call.
Definition: expression.c:4361

References call_function, entity_initial, f(), user_call_p(), and value_code_p.

Referenced by statement_contains_user_call_p().

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

◆ make_any_print_statement()

statement make_any_print_statement ( string  message)

Generate a print of a constant character string on stderr for C or on stdout for Fortran.

This is not clever as the format of the message is language dependent: simple quotes are used as delimiters in Fortran and double quotes in C. Should message be language independent and the delimiters added in this function instead? I did not do it to avoid yet another strdup() when strdup is used to generate "message", but this is questionable.

This is not clever as this function could easily be generalized with a vararg to generate more general print statements.

Parameters
messageessage

Definition at line 893 of file statement.c.

894 {
897 
898  if(fortran_module_p(m))
900  else
902 
903  return s;
904 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
statement make_print_statement(string message)
Make a Fortran print statement.
Definition: statement.c:835
statement make_C_print_statement(string message)
Definition: statement.c:852
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799

References fortran_module_p(), get_current_module_entity(), make_C_print_statement(), make_print_statement(), and statement_undefined.

Referenced by make_bottom_up_abc_tests().

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

◆ make_assign_statement()

statement make_assign_statement ( expression  l,
expression  r 
)

Definition at line 583 of file statement.c.

585 {
587 }
instruction make_assign_instruction(expression l, expression r)
Definition: instruction.c:87

References instruction_to_statement(), and make_assign_instruction().

Referenced by add_index_out_effect_proc(), alloc_instrumentation(), array_indices_communication(), assign_tmp_to_exp(), atom_cse_expression(), atomize_this_expression(), atomizer_of_external(), bound_to_statement(), comEngine_generate_procCode(), compile_reduction(), cstr_args_check(), define_node_processor_id(), do_atomize_call(), do_brace_expression_to_statements(), do_clone_statement(), do_expression_reduction(), do_group_constants_terapix(), do_loop_expansion(), do_loop_to_while_loop(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_scalar_renaming_in_successors(), do_solve_hardware_constraints_on_volume(), do_symbolic_tiling(), do_terapix_argument_handler(), full_loop_unroll(), gen(), generate_all_liveness_but(), generate_c1_alpha(), generate_copy_loop_nest(), generate_dynamic_liveness_for_primary(), generate_full_copy(), generate_get_value_locally(), generate_parallel_body(), generate_remapping_guard(), generate_update_values_on_computer_and_nodes(), hpfc_add_2(), hpfc_add_n(), hpfc_buffer_packing(), hpfc_compute_lid(), icm_loop_rwt(), initialization_list_to_statements(), initialize_array_variable(), initialize_scalar_variable(), inline_expression_call(), inline_return_crawler(), inline_split_declarations(), insert_flag_before_call_site(), insert_test_before_caller(), loop_header(), loop_inc(), loop_normalize_of_loop(), loop_rewrite(), make_abc_count_statement(), make_fields_assignment_instruction(), make_increment_statement(), make_lInitStats(), make_loadsave_statement(), make_loop_nest_for_overlap(), make_lSwitchStats(), make_read_loopbody(), make_read_write_fifo_stat(), make_scanning_over_tiles(), make_send_receive_conversion(), make_set_rc_statement(), make_statement_copy_i(), make_step_inc_statement(), make_temporary_scalar_entity(), make_toggle_inc_statement(), make_toggle_init_statement(), make_transStat(), make_write_loopbody(), MakeAssignedOrComputedGotoInst(), move_declaration_control_node_declarations_to_statement(), mpic_make_mpi_comm_rank(), mpic_make_mpi_comm_size(), mpic_make_mpi_finalize(), mpic_make_mpi_init(), mpic_make_mpi_irecv(), mpic_make_mpi_isend(), mpic_make_mpi_recv(), mpic_make_mpi_send(), new_local_image_variable(), outliner_patch_parameters(), Pvecteur_to_assign_statement(), reference_conversion_computation(), rename_statement_declarations(), set_array_status_to_target(), set_live_status(), simd_atomize_this_expression(), simd_loop_unroll(), simplify_subscript(), split_initializations_in_statement(), systeme_to_loop_nest(), text_loop_90(), Tiling_buffer_allocation(), two_addresses_code_generator(), unsugared_loop_header(), unsugared_loop_inc(), verify_array_element(), verify_array_variable(), and verify_scalar_variable().

+ Here is the call graph for this function:

◆ make_C_print_statement()

statement make_C_print_statement ( string  message)

MakeConstant() generates a Fortran constant... Does not seem to matter for strings...

stderr has not yet been encountered by the parser... Should it be defined by bootstrap.c or by the C parser no matter what?

Parameters
messageessage

Definition at line 852 of file statement.c.

853 {
855  list args = NIL;
856  /* MakeConstant() generates a Fortran constant... Does not seem
857  to matter for strings... */
858  expression eb =
861  STDERR_NAME);
863 
864  if(entity_undefined_p(lun)) {
865  /* stderr has not yet been encountered by the parser... Should
866  it be defined by bootstrap.c or by the C parser no matter
867  what? */
868  lun = make_stderr_variable();
869  }
870  ea = entity_to_expression(lun);
871 
872  args = CONS(EXPRESSION,ea, CONS(EXPRESSION,eb,NIL));
874  args,
877  return s;
878 }
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
Definition: constant.c:351
statement make_call_statement(string function_name, list args, entity l, string c)
This function is limited to intrinsics calls...
Definition: statement.c:1274
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define STDERR_NAME
#define FPRINTF_FUNCTION_NAME
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
entity make_stderr_variable(void)
If the parser has not (yet) encountered "stderr", a PIPS transformation or instrumentation phase may ...
Definition: variable.c:302
@ is_basic_string
Definition: ri.h:576
#define expression_undefined
Definition: ri.h:1223

References CONS, empty_comments, entity_to_expression(), entity_undefined, entity_undefined_p, EXPRESSION, expression_undefined, FindEntity(), FPRINTF_FUNCTION_NAME, is_basic_string, make_call_expression(), make_call_statement(), make_stderr_variable(), MakeConstant(), NIL, statement_undefined, STDERR_NAME, and TOP_LEVEL_MODULE_NAME.

Referenced by make_any_print_statement(), and make_exit_statement().

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

◆ make_call_statement()

statement make_call_statement ( string  function_name,
list  args,
entity  l,
string  c 
)

This function is limited to intrinsics calls...

A full function name or an entity could be passed as first argument. comments, default empty_comments (was: "" (was: string_undefined))

ifdebug(8) {

pips_debug(8, "cs is call to %s\n", function_name);

safe_print_statement(cs);

}

Parameters
function_nameunction_name
argsrgs
cA full function name or an entity could be passed as first argument. label, default entity_undefined

Definition at line 1274 of file statement.c.

1279 {
1280  entity called_function;
1281  statement cs;
1282 
1283  called_function = entity_intrinsic(function_name);
1284 
1285  l = (l==entity_undefined)? entity_empty_label() : l;
1286  cs = make_statement(l,
1289  c,
1291  make_call(called_function,args)),
1292  NIL,
1293  NULL,
1295 
1296  // To avoid a cycle between ri-util and prettyprint
1297  /* ifdebug(8) { */
1298  /* pips_debug(8, "cs is call to %s\n", function_name); */
1299  /* safe_print_statement(cs); */
1300  /* } */
1301 
1302  return cs;
1303 }
call make_call(entity a1, list a2)
Definition: ri.c:269
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292

References empty_extensions(), entity_empty_label(), entity_intrinsic(), entity_undefined, is_instruction_call, make_call(), make_instruction(), make_statement(), make_synchronization_none(), NIL, STATEMENT_NUMBER_UNDEFINED, and STATEMENT_ORDERING_UNDEFINED.

Referenced by array_bound_check_display(), build_call_STEP_init_regionArray(), call_STEP_subroutine(), call_STEP_subroutine2(), call_STEP_subroutine3(), edge_cost_polynome(), make_C_print_statement(), make_c_stop_statement(), make_com_loopbody(), make_continue_statement(), make_exit_statement(), make_increment_statement(), make_return_statement(), make_stop_statement(), MakeDataStatement(), mpi_finalize(), and task_time_polynome().

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

◆ make_continue_statement()

statement make_continue_statement ( entity  l)

Definition at line 953 of file statement.c.

954 {
957 }
#define CONTINUE_FUNCTION_NAME

References CONTINUE_FUNCTION_NAME, empty_comments, make_call_statement(), and NIL.

Referenced by __attribute__(), add_comment_and_line_number(), add_label_to_statement(), bound_generation(), build_call_STEP_WaitAll(), com_call(), controlize(), do_loop_unroll_with_prologue(), fix_sequence_statement_attributes(), full_loop_unroll(), full_spaghettify_module(), gen_omp_taskwait(), generate_guarded_statement(), generate_io_collect_or_update(), generate_update_values_on_computer_and_nodes(), GenericAddLocalEntityToDeclarations(), gfc2pips_code2instruction(), gfc2pips_code2instruction_(), hpf_compile_loop(), hpf_compile_parallel_loop(), hpf_compile_sequential_loop(), hpfc_broadcast_if_necessary(), hpfc_buffer_initialization(), hpfc_lazy_buffer_packing(), init_label(), inline_expression_call(), insert_endscop_after_stmt(), insert_endscop_before_stmt(), insert_endscop_in_sequence(), loop_normalize_of_loop(), make_communication_statement(), make_condition_from_forloop(), make_condition_from_loop(), make_condition_from_test(), make_condition_from_whileloop(), make_exit_from_forloop(), make_exit_from_loop(), make_exit_from_test(), make_exit_from_whileloop(), make_movements_loop_body_wp65(), make_plain_continue_statement(), make_scalar_communication_module(), make_scanning_over_one_tile(), make_scanning_over_tiles(), make_start_ru_module(), make_transition_statement(), make_undefined_list(), MakeAssignInst(), MakeCaseStatement(), MakeDefaultStatement(), MakeEntry(), MakeGotoStatement(), MakeNewLabelledStatement(), Overlap_Analysis(), put_a_comment_on_a_statement(), recover_structured_while(), st_make_nice_test(), take_out_the_entry_node_of_the_unstructured(), and update_statement_instruction().

+ Here is the call graph for this function:

◆ make_declaration_statement()

statement make_declaration_statement ( entity  v,
int  sn,
string  cs 
)

Make one declaration statement.

Parameters
snn
css

Definition at line 1091 of file statement.c.

1092 {
1093  return make_declarations_statement(CONS(ENTITY, v, NIL), sn, cs);
1094 }
statement make_declarations_statement(list idl, int sn, string cs)
Make a declaration(s) statement.
Definition: statement.c:990

References CONS, ENTITY, make_declarations_statement(), and NIL.

Referenced by add_declaration_statement_here(), and generic_add_declaration_statement().

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

◆ make_declarations_statement()

statement make_declarations_statement ( list  idl,
int  sn,
string  cs 
)

Make a declaration(s) statement.

To preserve declaration lines and comments, declaration statements are used

Parameters
idlis a sorted list of variables that is copied and modified for insertion in the declaration. The order is preserved. No sharing is created between idl and s.
snis the statement number
csis the comment string associated to the declaration

Note that additional information is dangerously hidden later as arguments to the call to CONTINUE.

Note also that this function is closely linked to the C parser but is unfortunately used by transformations/registers.c in a much simpler form.

If a place holder variable has been inserted by the C parser, it may be uselss. If several place holder variables have been inserted, they certainly are useless.

Do not create sharing with the caller

Remove useless place holder entities if any

Build the list of derived entities defined.

A derived entity is defined if its fields or elements appear in "l". Otherwise, it is simply referenced in the definition of another derived entity. Or it is simply "mentioned" as in "struct s;". Such statements can move around and do not really require strong dependences. See our 2015 LCPC paper.

list defined_l = NIL;

FOREACH(ENTITY, e, l) {

if(derived_entity_p(e)) {

type dt = entity_type(e);

list fl = NIL;

if(type_struct_p(dt))

fl = type_struct(dt);

else if(type_union_p(dt))

fl = type_union(dt);

else if(type_enum_p(dt))

fl = type_enum(dt);

else

pips_internal_error("Unexpected type for a derived entity.\n");

if(!ENDP(fl)) {// The derived type may not yet be fully defined

entity f = ENTITY(CAR(fl));

if(gen_in_list_p(f, l))

defined_l = CONS(ENTITY, e, defined_l);

}

}

}

Remove field entities from the declaration list and make sure that each derived entity is declared at most once, and really declared

&& (!derived_entity_p(e) || gen_in_list_p(e, defined_l))) // Declare only defined derived entities and all other kinds of entities

gen_free_list(defined_l);

if(ENDP(dl)) {

if(!ENDP(l)) {

/* Must be a case such as "struct s;" *\/

entity de = ENTITY(CAR(l));

if(derived_entity_p(de)) {

entity ph = make_place_holder_variable(de);

dl = CONS(ENTITY, ph, NIL);

}

}

else

pips_internal_error("Empty declaration_list.\n");

}

Parameters
idldl
snn
css

Definition at line 990 of file statement.c.

991 {
993 
994  /* If a place holder variable has been inserted by the C parser, it
995  may be uselss. If several place holder variables have been
996  inserted, they certainly are useless. */
997  list l = NIL;
998  if(gen_length(idl)>2) {
999  FOREACH(ENTITY, v, idl) {
1000  if(!place_holder_variable_p(v))
1001  l = CONS(ENTITY, v, l);
1002  else {
1003  // FI: the variable should be removed
1004  // free_entity(v);
1005  ;
1006  // FI: as well as its initialization expression :-(
1007  ;
1008  }
1009  }
1010  l = gen_nreverse(l);
1011  // Do not free idl because it is re-used later... by the C parser
1012  // gen_free_list(idl);
1013  }
1014  else {
1015  /* Do not create sharing with the caller */
1016  l = gen_copy_seq(idl);
1017  }
1018 
1019  /* Remove useless place holder entities if any */
1020 
1021  /* Build the list of derived entities defined.
1022  *
1023  * A derived entity is defined if its fields or elements appear in
1024  * "l". Otherwise, it is simply referenced in the definition of
1025  * another derived entity. Or it is simply "mentioned" as in "struct
1026  * s;". Such statements can move around and do not really require
1027  * strong dependences. See our 2015 LCPC paper.
1028  *
1029  */
1030  /* list defined_l = NIL; */
1031  /* FOREACH(ENTITY, e, l) { */
1032  /* if(derived_entity_p(e)) { */
1033  /* type dt = entity_type(e); */
1034  /* list fl = NIL; */
1035  /* if(type_struct_p(dt)) */
1036  /* fl = type_struct(dt); */
1037  /* else if(type_union_p(dt)) */
1038  /* fl = type_union(dt); */
1039  /* else if(type_enum_p(dt)) */
1040  /* fl = type_enum(dt); */
1041  /* else */
1042  /* pips_internal_error("Unexpected type for a derived entity.\n"); */
1043  /* if(!ENDP(fl)) {// The derived type may not yet be fully defined */
1044  /* entity f = ENTITY(CAR(fl)); */
1045  /* if(gen_in_list_p(f, l)) */
1046  /* defined_l = CONS(ENTITY, e, defined_l); */
1047  /* } */
1048  /* } */
1049  /* } */
1050 
1051  /* Remove field entities from the declaration list and make sure
1052  that each derived entity is declared at most once, and really
1053  declared */
1054  list dl = NIL;
1055  if(!ENDP(l)) {
1056  list cl = CDR(l);
1057  FOREACH(ENTITY, e, l) {
1058  if(!entity_field_p(e)) { // Fields are declared via derived entities
1059  if(!gen_in_list_p(e, cl)) // Do not declare entities more than once
1060  /* && (!derived_entity_p(e) || gen_in_list_p(e, defined_l))) // Declare only defined derived entities and all other kinds of entities */
1061  dl = CONS(ENTITY, e, dl);
1062  }
1063  if(!ENDP(cl))
1064  cl = CDR(cl);
1065  }
1066  dl = gen_nreverse(dl);
1067  }
1068  /* gen_free_list(defined_l); */
1069 
1070  /* if(ENDP(dl)) { */
1071  /* if(!ENDP(l)) { */
1072  /* /\* Must be a case such as "struct s;" *\/ */
1073  /* entity de = ENTITY(CAR(l)); */
1074  /* if(derived_entity_p(de)) { */
1075  /* entity ph = make_place_holder_variable(de); */
1076  /* dl = CONS(ENTITY, ph, NIL); */
1077  /* } */
1078  /* } */
1079  /* else */
1080  /* pips_internal_error("Empty declaration_list.\n"); */
1081  /* } */
1082 
1083  statement_declarations(ds) = dl;
1084  statement_number(ds) = sn;
1085  statement_comments(ds) = cs;
1086  return ds;
1087 }
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
statement make_plain_continue_statement()
Make a simple continue statement to be used as a NOP or ";" in C.
Definition: statement.c:964
bool entity_field_p(entity e)
e is the field of a structure
Definition: entity.c:857
bool place_holder_variable_p(entity)
Definition: variable.c:2069

References CDR, CONS, ENDP, ENTITY, entity_field_p(), FOREACH, gen_copy_seq(), gen_in_list_p(), gen_length(), gen_nreverse(), make_plain_continue_statement(), NIL, place_holder_variable_p(), statement_comments, statement_declarations, and statement_number.

Referenced by make_declaration_statement().

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

◆ make_exit_statement()

statement make_exit_statement ( int  n,
string  errmess 
)

This function returns a statement ending with a C exit statement.

A "fprintf(stderr, errmess);" is generated before "exit(n);" if errmess is not empty and a sequence statement ending wih exit() is returned.

There must be a nicer vararg function... make_statement_from_statement_varargs_list(s2, s1, NULL)

Parameters
errmessrrmess

Definition at line 926 of file statement.c.

927 {
931  list args1 = CONS(EXPRESSION,e1,NIL);
932 
934  args1,
937 
938  if(strlen(errmess)>0) {
939  statement s2 = make_C_print_statement(errmess);
940  /* There must be a nicer vararg
941  function... make_statement_from_statement_varargs_list(s2, s1, NULL) */
943  }
944  else
945  s = s1;
946 
947  return s;
948 
949 }
#define EXIT_FUNCTION_NAME
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188

References CONS, empty_comments, entity_undefined, EXIT_FUNCTION_NAME, EXPRESSION, int_to_expression(), make_block_statement(), make_C_print_statement(), make_call_statement(), NIL, s1, STATEMENT, and statement_undefined.

Referenced by emit_message_and_stop().

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

◆ make_expression_statement()

statement make_expression_statement ( expression  e)

Build a statement from a given expression.

Definition at line 1308 of file statement.c.

1309 {
1312 
1313  return s;
1314 }
instruction make_instruction_expression(expression _field_)
Definition: ri.c:1196

References instruction_to_statement(), and make_instruction_expression().

Referenced by for_to_while_loop_conversion(), set_entity_initial(), and task_time_polynome().

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

◆ make_forloop_statement()

statement make_forloop_statement ( expression  init,
expression  cond,
expression  inc,
statement  body 
)
Parameters
initnit
condond
incnc
bodyody

Definition at line 1220 of file statement.c.

1220  {
1221  forloop l = make_forloop(
1222  init,
1223  cond,
1224  inc,
1225  body);
1226  ifdebug(9) {
1227  pips_assert("new forloop is consistent", forloop_consistent_p(l));
1228  }
1229 
1236  NIL,
1238  empty_extensions(),
1240  ifdebug(9) {
1241  pips_assert("stmt is consistent",
1243  }
1244 
1245  return stmt;
1246 }
instruction make_instruction_forloop(forloop _field_)
Definition: ri.c:1193
bool statement_consistent_p(statement p)
Definition: ri.c:2195
bool forloop_consistent_p(forloop p)
Definition: ri.c:998
forloop make_forloop(expression a1, expression a2, expression a3, statement a4)
Definition: ri.c:1025
#define ifdebug(n)
Definition: sg.c:47

References empty_extensions(), entity_empty_label(), forloop_consistent_p(), ifdebug, init, make_forloop(), make_instruction_forloop(), make_statement(), make_synchronization_none(), NIL, pips_assert, statement_consistent_p(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and string_undefined.

Referenced by make_send_receive_conversion().

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

◆ make_loop_statement()

statement make_loop_statement ( entity  i,
expression  low,
expression  up,
expression  inc,
statement  b 
)

Build a loop statement.

Parameters
iindex of the loop
lowlower bound of the loop (an int expression)
upupper bound of the loop (an int expression)
incincrement step of the loop (an int expression)
bbody of the loop
Returns
a loop statement with the condition low<i<up, with step inc and body b see also make_new_loop_statement Unlike make_new_loop_statement, make_loop_statement doesn't clone the body

Loop range is created

Parameters
lowow
upp
incnc

Definition at line 1181 of file statement.c.

1187 {
1188  /* Loop range is created */
1189  range rg = make_range(low, up, inc);
1190  ifdebug(9) {
1191  pips_assert("new range is consistent", range_consistent_p(rg));
1192  }
1193 
1194  loop l = make_loop(
1195  i,
1196  rg,
1197  b,
1200  NIL);
1201 
1208  NIL,
1210  empty_extensions(),
1212  ifdebug(9) {
1213  pips_assert("stmt is consistent",
1215  }
1216 
1217  return stmt;
1218 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
bool range_consistent_p(range p)
Definition: ri.c:2014
execution make_execution_sequential(void)
Definition: ri.c:841
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041

References empty_extensions(), entity_empty_label(), ifdebug, make_execution_sequential(), make_instruction_loop(), make_loop(), make_range(), make_statement(), make_synchronization_none(), NIL, pips_assert, range_consistent_p(), statement_consistent_p(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and string_undefined.

Referenced by make_send_receive_conversion().

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

◆ make_plain_continue_statement()

◆ make_print_statement()

statement make_print_statement ( string  message)

Make a Fortran print statement.

This function has been moved from alias_check.c and uses a Fortran only function. alias_check was designed from Fortran.

Parameters
messageessage

Definition at line 835 of file statement.c.

836 {
840  list args = CONS(EXPRESSION,e1,CONS(EXPRESSION,e2,NIL));
841  /* This function has been moved from alias_check.c and uses a
842  Fortran only function. alias_check was designed from Fortran. */
844 #if 1
845  ins = make_simple_Fortran_io_instruction(false,fmt,args);
846 #else
847  ins = MakeSimpleIoInst2(301,fmt,args);
848 #endif
849  return instruction_to_statement(ins);
850 }
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573
instruction make_simple_Fortran_io_instruction(bool is_read_p, expression f, list io_list)
Derived from the Fortran parser code.
Definition: statement.c:807
#define LIST_DIRECTED_FORMAT_NAME
Definition: naming-local.h:97
instruction MakeSimpleIoInst2(int keyword, expression f, list io_list)
Definition: statement.c:1899

References CONS, EXPRESSION, instruction_to_statement(), instruction_undefined, LIST_DIRECTED_FORMAT_NAME, make_simple_Fortran_io_instruction(), MakeCharacterConstantExpression(), MakeSimpleIoInst2(), and NIL.

Referenced by insert_test_before_statement(), make_any_print_statement(), make_bottom_up_abc_tests(), make_interprocedural_abc_tests(), top_down_abc_array(), verify_array_element(), verify_array_variable(), and verify_scalar_variable().

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

◆ make_return_statement()

statement make_return_statement ( entity  module)
Parameters
moduleodule

Definition at line 779 of file statement.c.

780 {
781  const char *module_name = entity_local_name(module);
785 }
static char * module
Definition: pips.c:74
#define RETURN_FUNCTION_NAME
#define C_RETURN_FUNCTION_NAME
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
entity make_label(const char *module_name, const char *local_name)
Definition: entity.c:308

References c_module_p(), C_RETURN_FUNCTION_NAME, empty_comments, entity_local_name(), entity_undefined_p, FindEntity(), LABEL_PREFIX, make_call_statement(), make_label(), module, module_name(), NIL, RETURN_FUNCTION_NAME, and RETURN_LABEL_NAME.

Referenced by ensure_comment_consistency(), make_scalar_communication_module(), make_start_ru_module(), make_wait_ru_module(), module_to_wp65_modules(), and outliner_file().

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

◆ make_simple_Fortran_io_instruction()

instruction make_simple_Fortran_io_instruction ( bool  is_read_p,
expression  f,
list  io_list 
)

Derived from the Fortran parser code.

Should be generalized to generate C code...

Parameters
is_read_ps_read_p
io_listo_list

Definition at line 807 of file statement.c.

810 {
815 
816  list cil = CONS(EXPRESSION, unit,
817  CONS(EXPRESSION, std,
818  CONS(EXPRESSION, format,
819  CONS(EXPRESSION, f, NULL))));
820 
821  // Initial implementation:
822  // inst = MakeIoInstA((keyword==TK_PRINT)?TK_WRITE:TK_READ,
823  // cil, io_list);
824 
825  list lci = gen_nconc(cil, io_list);
826 
829  instruction io_call = make_instruction_call(make_call(op, lci));
830 
831  return io_call;
832 }
instruction make_instruction_call(call _field_)
Definition: ri.c:1184
int unit
UNIT.
Definition: newgen_types.h:97
#define READ_FUNCTION_NAME
#define WRITE_FUNCTION_NAME
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
expression MakeNullaryCall(entity f)
Creates a call expression to a function with zero arguments.
Definition: expression.c:331

References CONS, CreateIntrinsic(), entity_intrinsic(), EXPRESSION, f(), gen_nconc(), LIST_DIRECTED_FORMAT_NAME, make_call(), make_instruction_call(), MakeCharacterConstantExpression(), MakeNullaryCall(), READ_FUNCTION_NAME, and WRITE_FUNCTION_NAME.

Referenced by make_print_statement(), and MakeSimpleIoInst2().

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

◆ make_stop_statement()

statement make_stop_statement ( string  message)

This function returns a Fortran stop statement with an error message.

Parameters
messageessage

Definition at line 908 of file statement.c.

909 {
910  list args=NIL;
911  expression e;
912 
914 
915  args = CONS(EXPRESSION,e,NIL);
916 
918 
919 }
#define STOP_FUNCTION_NAME

References CONS, empty_comments, entity_undefined, EXPRESSION, is_basic_string, make_call_expression(), make_call_statement(), MakeConstant(), NIL, and STOP_FUNCTION_NAME.

Referenced by emit_message_and_stop(), insert_test_before_statement(), make_interprocedural_abc_tests(), top_down_abc_array(), verify_array_element(), verify_array_variable(), and verify_scalar_variable().

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

◆ make_test_statement()

statement make_test_statement ( expression  cond,
statement  truebody,
statement  falsebody 
)
Parameters
condond
truebodyruebody
falsebodyalsebody

Definition at line 1248 of file statement.c.

1248  {
1249  test t = make_test(cond, truebody, falsebody);
1250  ifdebug(9) {
1251  pips_assert("new test is consistent", test_consistent_p(t));
1252  }
1253 
1260  NIL,
1262  empty_extensions(),
1264  ifdebug(9) {
1265  pips_assert("stmt is consistent",
1267  }
1268 
1269  return stmt;
1270 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction_test(test _field_)
Definition: ri.c:1172
bool test_consistent_p(test p)
Definition: ri.c:2580

References empty_extensions(), entity_empty_label(), ifdebug, make_instruction_test(), make_statement(), make_synchronization_none(), make_test(), NIL, pips_assert, statement_consistent_p(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, string_undefined, and test_consistent_p().

Referenced by array_scalar_access_to_bank_communication(), ctx_generate_new_statement_cluster_dependant(), and test_working_false().

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

◆ make_whileloop_statement()

statement make_whileloop_statement ( expression  condition,
statement  body,
int  line_number,
bool  before 
)

Build a while loop statement.

If before is true, build a while (condition) body;

else build a do body; while (condition);

Parameters
line_numberis used to specify a source-line number to the statement
Parameters
conditionondition
bodyody
line_numberine_number
beforeefore

Definition at line 1150 of file statement.c.

1153  {
1154  whileloop w;
1155  statement smt;
1156 
1157  w = make_whileloop(condition, body, entity_empty_label(),
1160  line_number,
1162  //pop_current_C_comment(),
1167  return smt;
1168 }
evaluation make_evaluation_before(void)
Definition: ri.c:786
whileloop make_whileloop(expression a1, statement a2, entity a3, evaluation a4)
Definition: ri.c:2937
instruction make_instruction_whileloop(whileloop _field_)
Definition: ri.c:1178
evaluation make_evaluation_after(void)
Definition: ri.c:789

References empty_extensions(), entity_empty_label(), make_evaluation_after(), make_evaluation_before(), make_instruction_whileloop(), make_statement(), make_synchronization_none(), make_whileloop(), NIL, STATEMENT_ORDERING_UNDEFINED, and string_undefined.

Referenced by for_to_while_loop_conversion(), make_send_receive_conversion(), MakeWhileLoop(), and recover_structured_while().

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

◆ makeloopbody()

statement makeloopbody ( loop  l,
statement  s_old,
bool  inner_p 
)

statement makeloopbody(l, s_old) make a statement for a loop body, using the fields of a previously existing statement

Preserving the labels may be sometimes a good thing (hyperplane or tiling transformation, outermostloop) or a bad thing for innermost loops, sometimes replicated loops

FI: the name of this function is not well chosen.

Parameters
s_old_old
inner_pnner_p

Definition at line 1641 of file statement.c.

1642 {
1643  statement state_l;
1644  instruction instr_l;
1645  statement l_body;
1646 
1648  state_l = make_statement(inner_p? entity_empty_label() : statement_label(s_old),
1649  statement_number(s_old),
1650  statement_ordering(s_old),
1651  statement_comments(s_old),
1652  instr_l,NIL,NULL,
1659  NIL,NULL,
1661 
1662  return(l_body);
1663 }

References CONS, empty_comments, empty_extensions(), entity_empty_label(), is_instruction_loop, make_instruction(), make_instruction_block(), make_statement(), make_synchronization_none(), NIL, STATEMENT, statement_comments, statement_extensions, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_ordering, and STATEMENT_ORDERING_UNDEFINED.

Referenced by code_generation().

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

◆ normalize_statement()

statement normalize_statement ( statement  s)

Make (a bit more) sure that s is gen_defined_p in spite of poor decision for empty fields and that strdup can be used on the string fields.

Definition at line 4035 of file statement.c.

4036 {
4038  || statement_decls_text(s)==NULL)
4039  statement_decls_text(s) = strdup("");
4041  || statement_comments(s)==NULL)
4042  statement_comments(s) = strdup("");
4043  return s;
4044 }

References empty_comments_p(), statement_comments, statement_decls_text, strdup(), and string_undefined_p.

Referenced by controlize_forloop(), controlize_list(), controlize_loop(), controlize_test(), and controlize_whileloop().

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

◆ pop_generated_variable_commenter()

void pop_generated_variable_commenter ( void  )

Definition at line 2623 of file statement.c.

2624 {
2625  pips_assert("not removing default commenter",nb_commenters!=1);
2626  --nb_commenters;
2627 }

References nb_commenters, and pips_assert.

Referenced by add_induction_var_to_local_declarations(), copy_write_statement_with_cumulated_regions(), freia_compiler(), initilization(), make_send_receive_conversion(), outliner_patch_parameters(), outliner_scan(), replicate_declaration(), and simdizer().

+ Here is the caller graph for this function:

◆ push_generated_variable_commenter()

void push_generated_variable_commenter ( string(*)(entity commenter)

Definition at line 2616 of file statement.c.

2617 {
2618  pips_assert("not exceeding stack commenters stack limited size\n",
2621 }
#define MAX_COMMENTERS
Definition: statement.c:2603
static string commenter(__attribute__((unused)) entity e)

References commenter(), generated_variable_commenters, MAX_COMMENTERS, nb_commenters, and pips_assert.

Referenced by add_induction_var_to_local_declarations(), copy_write_statement_with_cumulated_regions(), freia_compiler(), initilization(), make_send_receive_conversion(), outliner_patch_parameters(), outliner_scan(), replicate_declaration(), and simdizer().

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

◆ put_a_comment_on_a_statement()

void put_a_comment_on_a_statement ( statement  s,
string  the_comments 
)

Similar to try_to_put_a_comment_on_a_statement() but insert a CONTINUE to put the comment on it if there is only empty sequence(s)

The comment should have been malloc()'ed before.

Nothing to add...

It failed because it is an empty sequence. So add a CONTINUE to attach the statement on it:

Parameters
the_commentshe_comments

Definition at line 1863 of file statement.c.

1865 {
1866  if (empty_comments_p(the_comments))
1867  /* Nothing to add... */
1868  return;
1869 
1870  if (!try_to_put_a_comment_on_a_statement(s, the_comments)) {
1871  /* It failed because it is an empty sequence. So add a
1872  CONTINUE to attach the statement on it: */
1875  statement_comments(s_cont) = the_comments;
1877  s_cont,
1878  sequence_statements(seq));
1879  }
1880 }
bool try_to_put_a_comment_on_a_statement(statement s, string the_comments)
Put a comment on a statement in a safe way.
Definition: statement.c:1831

References CONS, empty_comments_p(), entity_empty_label(), instruction_sequence, make_continue_statement(), sequence_statements, STATEMENT, statement_comments, statement_instruction, and try_to_put_a_comment_on_a_statement().

Referenced by append_comments_to_statement(), build_call_STEP_WaitAll(), compile_body(), compile_regions(), compute_region(), cstr_args_check(), insert_comments_to_statement(), and region_to_statement().

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

◆ put_formats_at_module_beginning()

void put_formats_at_module_beginning ( statement  s)

Transfer all the FORMATs at the very beginning of a module:

Pick up all the FORMATs of the module:

And put them at the very beginning of the module:

Definition at line 2311 of file statement.c.

2312 {
2313  /* Pick up all the FORMATs of the module: */
2315  ifdebug (1)
2316  pips_assert("Incorrect statements...", statement_consistent_p(s));
2317  /* And put them at the very beginning of the module: */
2318  formats=gen_nreverse(formats);
2319  FOREACH(STATEMENT,f,formats)
2320  insert_statement(s,f,true);
2321  ifdebug (1)
2322  pips_assert("Incorrect statements...", statement_consistent_p(s));
2323 }
list gather_and_remove_all_format_statements(statement s)
Used to keep aside the FORMAT before many code transformation that could remove them either.
Definition: statement.c:2298
void insert_statement(statement s, statement s1, bool before)
This is the normal entry point.
Definition: statement.c:2570
#define true
Definition: newgen_types.h:81

References f(), FOREACH, gather_and_remove_all_format_statements(), gen_nreverse(), ifdebug, insert_statement(), pips_assert, STATEMENT, and statement_consistent_p().

Referenced by unspaghettify_or_restructure_statement().

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

◆ put_formats_at_module_end()

void put_formats_at_module_end ( statement  s)

Transfer all the FORMATs at the very end of a module:

Pick up all the FORMATs of the module:

And put them at the very beginning of the module:

Definition at line 2328 of file statement.c.

2329 {
2330  /* Pick up all the FORMATs of the module: */
2332  ifdebug (1)
2333  pips_assert("Incorrect statements...", statement_consistent_p(s));
2334  /* And put them at the very beginning of the module: */
2335  FOREACH(STATEMENT,f,formats)
2337  ifdebug (1)
2338  pips_assert("Incorrect statements...", statement_consistent_p(s));
2339 }
#define false
Definition: newgen_types.h:80

References f(), FOREACH, gather_and_remove_all_format_statements(), ifdebug, insert_statement(), pips_assert, STATEMENT, and statement_consistent_p().

Referenced by unspaghettify_or_restructure_statement().

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

◆ remove_declaration_statement()

statement remove_declaration_statement ( statement  s,
entity  e 
)

Declarations are not only lists of entities, but also statement to carry the line number, comments,...

For the time begin, a declaration statement is a continue statement.

Look for the last declaration: it is pointed to by pl

ifdebug(8) {

pips_debug(8, "Statement after declaration insertion:\n");

print_statement(s);

}

Definition at line 2966 of file statement.c.

2967 {
2968  if(statement_block_p(s)) {
2969  list sl = statement_block(s); //statement list
2970  list cl = list_undefined; // current statement list
2971 
2972  /* Look for the last declaration: it is pointed to by pl */
2973  for(cl=sl; !ENDP(cl); POP(cl)) {
2974  statement cs = STATEMENT(CAR(cl));
2975  if(declaration_statement_p(cs)) {
2976  // We don't use FOREACH because we aim to delete an element while iterating
2977  list prev=NULL;
2979  !ENDP(current);
2980  POP(current)) {
2981  if(e == ENTITY(CAR(current))) {
2982  pips_debug(0,"Removing %s\n",entity_name(e));
2983  // For replacing it, we have first to remove the old one from the list
2984  if(prev == NULL) {
2986  } else {
2987  CDR(prev) = CDR(current);
2988  }
2989  free(current);
2990  break;
2991  }
2992  prev=current; // Save current iterator, because we might remove the next one
2993  }
2994  }
2995  }
2996  }
2997  else
2998  {
2999  pips_internal_error("can only add declarations to statement blocks");
3000  }
3001 
3002  // FI: to avoid a cycle between the ri-util and prettyprint libraries
3003  /* ifdebug(8) { */
3004  /* pips_debug(8, "Statement after declaration insertion:\n"); */
3005  /* print_statement(s); */
3006  /* } */
3007 
3008  return s;
3009 }
#define entity_name(x)
Definition: ri.h:2790
static size_t current
Definition: string.c:115

References CAR, CDR, current, declaration_statement_p(), ENDP, ENTITY, entity_name, free(), list_undefined, pips_debug, pips_internal_error, POP, STATEMENT, statement_block(), statement_block_p, and statement_declarations.

Referenced by RemoveEntityFromCompilationUnit().

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

◆ replace_statement_walker()

static bool replace_statement_walker ( statement  s,
struct replace_statement_context ctx 
)
static

Definition at line 4111 of file statement.c.

4112 {
4114  if(instruction_sequence_p(i)) {
4116  //This code come from search_sequence_containing
4117  MAP (STATEMENT, s2, {
4118  if (s2 == ctx->old_stat) {
4119  ctx->found_p = true;
4120  }
4121  }, stats_list );
4122 
4123  if (ctx->found_p == true) {
4124  //This code come from replace_in_sequence_statement_with
4125  list new_stats_list = NIL;
4126 
4127  MAP (STATEMENT, s, {
4128  ifdebug(7) {
4129  pips_debug(7, "Iterate on statement %"_intFMT"\n", statement_number(s));
4130  // NO CYCLE! print_statement(s);
4131  }
4132  if (s == ctx->old_stat) {
4133  pips_debug(7, "Replace this statement:\n");
4134  new_stats_list = CONS(STATEMENT,ctx->new_stat,new_stats_list);
4135  }
4136  else {
4137  pips_debug(7, "Keep this statement:\n");
4138  new_stats_list = CONS(STATEMENT,s,new_stats_list);
4139  }
4140  }, stats_list);
4141 
4143  //NL: it can make some bug if we had a exploration of stats_list outside this function?
4144  //gen_free_list(stats_list);
4145  gen_recurse_stop(0);
4146  }
4147  }
4148  else if(instruction_test_p(i)) {
4149  test t = instruction_test(i);
4150  if (test_true(t) == ctx->old_stat) {
4151  ctx->found_p = true;
4152  test_true(t) = ctx->new_stat;
4153  gen_recurse_stop(0);
4154  }
4155  else if (test_false(t) == ctx->old_stat) {
4156  ctx->found_p = true;
4157  test_false(t) = ctx->new_stat;
4158  gen_recurse_stop(0);
4159  }
4160  }
4161  else if(instruction_loop_p(i)) {
4162  loop l = instruction_loop(i);
4163  if (loop_body(l) == ctx->old_stat) {
4164  ctx->found_p = true;
4165  loop_body(l) = ctx->new_stat;
4166  gen_recurse_stop(0);
4167  }
4168  }
4169  else if(instruction_whileloop_p(i)) {
4171  if (whileloop_body(l) == ctx->old_stat) {
4172  ctx->found_p = true;
4173  whileloop_body(l) = ctx->new_stat;
4174  gen_recurse_stop(0);
4175  }
4176  }
4177  else if(instruction_forloop_p(i)) {
4179  if (forloop_body(l) == ctx->old_stat) {
4180  ctx->found_p = true;
4181  forloop_body(l) = ctx->new_stat;
4182  gen_recurse_stop(0);
4183  }
4184  }
4185  else if(instruction_multitest_p(i)) {
4187  if (multitest_body(mt) == ctx->old_stat) {
4188  ctx->found_p = true;
4189  multitest_body(mt) = ctx->new_stat;
4190  gen_recurse_stop(0);
4191  }
4192  }
4193  else if(instruction_goto_p(i)) {
4194  if (instruction_goto(i) == ctx->old_stat) {
4195  ctx->found_p = true;
4196  instruction_goto(i) = ctx->new_stat;
4197  gen_recurse_stop(0);
4198  }
4199  }
4200  else if(instruction_unstructured_p(i)) {
4202  if (control_statement(unstructured_entry(u)) == ctx->old_stat) {
4203  ctx->found_p = true;
4205  gen_recurse_stop(0);
4206  }
4207  else if (control_statement(unstructured_exit(u)) == ctx->old_stat) {
4208  ctx->found_p = true;
4210  gen_recurse_stop(0);
4211  }
4212  }
4213  else if(instruction_call_p(i) || instruction_expression_p(i)) {
4214  //nothing to do
4215  }
4216  else {
4217  pips_internal_error("unknown instruction tag %d", instruction_tag(i));
4218  }
4219 
4220  return true;
4221 }
#define _intFMT
Definition: newgen_types.h:57
#define instruction_multitest_p(x)
Definition: ri.h:1533
#define instruction_multitest(x)
Definition: ri.h:1535
#define instruction_goto(x)
Definition: ri.h:1526
#define unstructured_exit(x)
Definition: ri.h:3006
#define instruction_unstructured_p(x)
Definition: ri.h:1530
#define unstructured_entry(x)
Definition: ri.h:3004
#define instruction_whileloop_p(x)
Definition: ri.h:1521
#define multitest_body(x)
Definition: ri.h:1735
#define instruction_test_p(x)
Definition: ri.h:1515
#define control_statement(x)
Definition: ri.h:941
#define instruction_goto_p(x)
Definition: ri.h:1524
#define instruction_unstructured(x)
Definition: ri.h:1532
#define instruction_expression_p(x)
Definition: ri.h:1539

References _intFMT, CONS, control_statement, forloop_body, replace_statement_context::found_p, gen_nreverse(), gen_recurse_stop(), ifdebug, instruction_call_p, instruction_expression_p, instruction_forloop, instruction_forloop_p, instruction_goto, instruction_goto_p, instruction_loop, instruction_loop_p, instruction_multitest, instruction_multitest_p, instruction_sequence, instruction_sequence_p, instruction_tag, instruction_test, instruction_test_p, instruction_unstructured, instruction_unstructured_p, instruction_whileloop, instruction_whileloop_p, loop_body, MAP, multitest_body, replace_statement_context::new_stat, NIL, replace_statement_context::old_stat, pips_debug, pips_internal_error, sequence_statements, STATEMENT, statement_instruction, statement_number, test_false, test_true, unstructured_entry, unstructured_exit, and whileloop_body.

Referenced by statement_replace_in_root_statement().

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

◆ return_statement_p()

◆ safe_statement_identification()

string safe_statement_identification ( statement  s)

Definition at line 1726 of file statement.c.

1727 {
1728  if(statement_undefined_p(s)) {
1729  return "undefined statement\n";
1730  }
1732  return "statement with undefined intruction\n";
1733  }
1734  else
1735  return statement_identification(s);
1736 }
string statement_identification(statement s)
Like external_statement_identification(), but with internal information, the hexadecimal address of t...
Definition: statement.c:1700

References instruction_undefined_p, statement_identification(), statement_instruction, and statement_undefined_p.

Referenced by print_and_check_control_node(), print_control_node(), print_control_node_uns(), print_control_node_unss_sem(), print_control_nodes(), print_control_nodes_without_check(), process_unreachable_node(), step_analyse_CHAINS_DG(), step_print_effect_path(), and step_translate_and_map_step_regions().

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

◆ st_make_nice_test()

statement st_make_nice_test ( expression  condition,
list  ltrue,
list  lfalse 
)
Parameters
conditionondition
ltruetrue
lfalsefalse

Definition at line 1585 of file statement.c.

1588 {
1589  statement
1590  stattrue = make_statement_from_statement_list(ltrue),
1591  statfalse = make_statement_from_statement_list(lfalse);
1592  bool
1593  notrue=(stattrue==statement_undefined),
1594  nofalse=(statfalse==statement_undefined);
1595 
1596  if ((notrue) && (nofalse))
1598 
1599  if (nofalse)
1600  {
1601  return
1605  make_test(condition,
1606  stattrue,
1608  }
1609 
1610  if (notrue)
1611  {
1612  expression
1614  condition);
1615 
1616  return
1620  make_test(newcond,
1621  statfalse,
1623  }
1624 
1626  make_test(condition,
1627  stattrue,
1628  statfalse))));
1629 }
statement make_statement_from_statement_list(list l)
Build a statement sequence from a statement list.
Definition: statement.c:719
#define NOT_OPERATOR_NAME
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342

References entity_intrinsic(), entity_undefined, instruction_to_statement(), is_instruction_test, make_continue_statement(), make_instruction(), make_statement_from_statement_list(), make_test(), MakeUnaryCall(), NOT_OPERATOR_NAME, and statement_undefined.

Referenced by build_third_comb(), generate_c1_alpha(), generate_optional_if(), generate_parallel_body(), generate_update_distributed_value_from_host(), generate_update_values_on_computer_and_nodes(), generate_update_values_on_nodes(), st_get_value_for_all(), st_get_value_for_computer(), st_send_to_computer_if_necessary(), and st_send_to_host_and_nodes().

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

◆ statement_contains_user_call_p()

bool statement_contains_user_call_p ( statement  s)

Definition at line 3939 of file statement.c.

3940 {
3941  bool user_call_p = false;
3943  return user_call_p;
3944 }
static bool look_for_user_call(call c, bool *user_call_p)
Definition: statement.c:3920

References call_domain, gen_context_recurse, gen_null2(), look_for_user_call(), and user_call_p().

Referenced by costly_task(), static_controlize_statement(), and taskify_statement().

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

◆ statement_does_return()

bool statement_does_return ( statement  s)

Returns false is no syntactic control path exits s (i.e.

even if true is returned there might be no control path). Subroutines and functions are assumed to always return to keep the analysis intraprocedural. See the continuation library for more advanced precondition-based analyses.

true is a safe default value.

The function name is misleading: a RETURN statement does not return... It should be called "statement_does_continue()"

the third condition is due to a bug/feature of unspaghettify

No precise answer, unless you can prove the loop executes at least one iteration.

returns = statement_does_return(instruction_goto(i));

Definition at line 2195 of file statement.c.

2196 {
2197  bool returns = true;
2199  test t = test_undefined;
2200 
2201  switch(instruction_tag(i)) {
2203  MAPL(sts,
2204  {
2205  statement st = STATEMENT(CAR(sts)) ;
2206  if (!statement_does_return(st)) {
2207  returns = false;
2208  break;
2209  }
2210  },
2212 
2213  break;
2216  break;
2217  case is_instruction_call:
2218  /* the third condition is due to a bug/feature of unspaghettify */
2219  returns = !stop_statement_p(s) && !return_statement_p(s) &&
2221  break;
2222  case is_instruction_test:
2223  t = instruction_test(i);
2224  returns = statement_does_return(test_true(t)) ||
2226  break;
2227  case is_instruction_loop:
2229  /* No precise answer, unless you can prove the loop executes at
2230  * least one iteration.
2231  */
2232  returns = true;
2233  break;
2234  case is_instruction_goto:
2235  /* returns = statement_does_return(instruction_goto(i)); */
2236  returns = false;
2237  break;
2239  break;
2241  break;
2242  default:
2243  pips_internal_error("Ill. tag %d for instruction",
2244  instruction_tag(i));
2245  }
2246 
2247  debug(8, "statement_does_return", "stmt %s, does return= %d\n",
2248  statement_identification(s), returns);
2249 
2250  return returns;
2251 }
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
bool unstructured_does_return(unstructured u)
Definition: statement.c:2254
bool return_statement_p(statement s)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
bool stop_statement_p(statement s)
Test if a statement is a Fortran STOP.
Definition: statement.c:263
bool statement_does_return(statement s)
Returns false is no syntactic control path exits s (i.e.
Definition: statement.c:2195
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
bool entity_return_label_p(entity e)
Definition: entity.c:673
#define test_undefined
Definition: ri.h:2808
@ is_instruction_expression
Definition: ri.h:1478

References CAR, continue_statement_p(), debug(), entity_return_label_p(), instruction_sequence, instruction_tag, instruction_test, instruction_unstructured, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, MAPL, pips_internal_error, return_statement_p(), sequence_statements, STATEMENT, statement_does_return(), statement_identification(), statement_instruction, statement_label, stop_statement_p(), test_false, test_true, test_undefined, and unstructured_does_return().

Referenced by c_unstructured(), decorate_trail(), statement_does_return(), and text_trail().

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

◆ statement_identification()

string statement_identification ( statement  s)

Like external_statement_identification(), but with internal information, the hexadecimal address of the statement.

Allocate a new string.

Definition at line 1700 of file statement.c.

1701 {
1702  char * buffer;
1704  string instrstring = instruction_identification(i);
1705  int so = statement_ordering(s);
1706  entity called = entity_undefined;
1707 
1708  if(same_string_p(instrstring, "CALL")) {
1709  called = call_function(instruction_call(i));
1710  }
1711 
1712  int n = asprintf(&buffer, "%td (%d, %d) at %p: %s %s\n",
1713  statement_number(s),
1714  ORDERING_NUMBER(so),
1715  ORDERING_STATEMENT(so),
1716  s,
1717  instrstring,
1718  entity_undefined_p(called)? "" : module_local_name(called));
1719 
1720  pips_assert("asprintf ok", n!=-1);
1721 
1722  return buffer;
1723 }

References asprintf, buffer, call_function, entity_undefined, entity_undefined_p, instruction_call, instruction_identification(), module_local_name(), ORDERING_NUMBER, ORDERING_STATEMENT, pips_assert, same_string_p, statement_instruction, statement_number, and statement_ordering.

Referenced by build_trail(), clean_up_sequences_rewrite(), compact_list(), control_to_ancestor(), control_to_label_name(), copy_n_statement(), dag_or_cycle_to_flow_sensitive_postconditions_or_transformers(), dag_to_flow_sensitive_preconditions(), decorate_trail(), dump_control_to_label_name(), dump_trail(), ensure_comment_consistency(), genref_statement(), get_control_precondition(), node_to_path_transformer_or_postcondition(), pipsdbm_write_statement_function(), print_control_postcondition_map(), print_cycle_head_to_fixpoint(), print_ordering_to_statement(), print_statement_temporary_precondition(), process_ready_node(), process_unreachable_node(), ready_to_be_processed_p(), remove_useless_continue_or_empty_code_in_unstructured(), safe_print_statement(), safe_statement_identification(), set_control_to_label(), statement_does_return(), statement_to_label(), store_control_fix_point(), store_control_postcondition(), text_trail(), text_unstructured(), unreachable_node_to_transformer(), unstructured_to_flow_sensitive_postconditions_or_transformers(), update_control_postcondition(), update_cycle_temporary_precondition(), and update_statement_temporary_precondition().

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

◆ statement_in_statement_p()

bool statement_in_statement_p ( statement  s,
statement  st 
)
Parameters
stt

Definition at line 4076 of file statement.c.

4077 {
4078  struct sb sb;
4079  sb.searched_statement = s;
4080  sb.found_p = false;
4082  return sb.found_p;
4083 }
static bool statement_in_statement_walker(statement st, struct sb *sb)
Definition: statement.c:4052
statement searched_statement
Definition: statement.c:4048
bool found_p
Definition: statement.c:4049
Definition: statement.c:4047

References sb::found_p, gen_context_recurse, gen_null2(), sb::searched_statement, statement_domain, and statement_in_statement_walker().

Referenced by some_conflicts_between(), and statement_in_statements_p().

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

◆ statement_in_statement_walker()

static bool statement_in_statement_walker ( statement  st,
struct sb sb 
)
static

ifdebug(7) {

pips_debug(7,"considering statement:\n");

print_statement(st);

}

Definition at line 4052 of file statement.c.

4053 {
4054  // FI: no cycle between ri-util and prettyprint
4055  /* ifdebug(7) { */
4056  /* pips_debug(7,"considering statement:\n"); */
4057  /* print_statement(st); */
4058  /* } */
4059  if(sb->searched_statement==st)
4060  {
4061  sb->found_p=true; gen_recurse_stop(0);
4062  }
4063  return true;
4064 }

References sb::found_p, gen_recurse_stop(), and sb::searched_statement.

Referenced by statement_in_statement_p().

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

◆ statement_in_statements_p()

bool statement_in_statements_p ( statement  s,
list  l 
)

Definition at line 4097 of file statement.c.

4098 {
4099  FOREACH(STATEMENT,st,l)
4100  if(statement_in_statement_p(s,st)) return true;
4101  return false;
4102 }
bool statement_in_statement_p(statement s, statement st)
Definition: statement.c:4076

References FOREACH, STATEMENT, and statement_in_statement_p().

+ Here is the call graph for this function:

◆ statement_less_p()

bool statement_less_p ( statement  st1,
statement  st2 
)
Parameters
st1t1
st2t2

Definition at line 288 of file statement.c.

289 {
290  int o1 = statement_ordering( st1 ) ;
291  int o2 = statement_ordering( st2 ) ;
292 
293  if (ORDERING_NUMBER( o1 ) != ORDERING_NUMBER( o2 )) {
294  fprintf(stderr, "cannot compare %td (%d,%d) and %td (%d,%d)\n",
295  statement_number(st1),
296  ORDERING_NUMBER( o1 ), ORDERING_STATEMENT( o1 ),
297  statement_number(st2),
298  ORDERING_NUMBER( o2 ), ORDERING_STATEMENT( o2 ));
299 
300  abort();
301  }
302 
303  return( ORDERING_STATEMENT(o1) < ORDERING_STATEMENT(o2)) ;
304 }
#define abort()
Definition: misc-local.h:53

References abort, fprintf(), ORDERING_NUMBER, ORDERING_STATEMENT, statement_number, and statement_ordering.

+ Here is the call graph for this function:

◆ statement_may_contain_exiting_intrinsic_call_p()

bool statement_may_contain_exiting_intrinsic_call_p ( statement  s)

Definition at line 4022 of file statement.c.

4023 {
4024  bool control_effect_p = false;
4025 
4026  if(!control_effect_p)
4028 
4029  return control_effect_p;
4030 }
static bool look_for_exiting_intrinsic_calls(call c, bool *control_effect_p)
Definition: statement.c:4002

References call_domain, gen_context_recurse, gen_null2(), and look_for_exiting_intrinsic_calls().

+ Here is the call graph for this function:

◆ statement_may_have_control_effects_p()

bool statement_may_have_control_effects_p ( statement  s)

Preserve branch targets, without checking if they are useful or not because it can be done by another pass

These statements may hide a non-terminating loop. I assume that do loops always terminate. They also always have a memory write effect for the index, which may not be true for the other kinds of loops. Unstructured could be tested to see if they have a syntactical control cycle or not.

Definition at line 3978 of file statement.c.

3979 {
3980  bool control_effect_p = false;
3981 
3982  /* Preserve branch targets, without checking if they are useful or
3983  not because it can be done by another pass */
3984  control_effect_p = !entity_empty_label_p(statement_label(s));
3985 
3986  if(!control_effect_p) {
3987  /* These statements may hide a non-terminating loop. I assume that
3988  do loops always terminate. They also always have a memory
3989  write effect for the index, which may not be true for the
3990  other kinds of loops. Unstructured could be tested to see if
3991  they have a syntactical control cycle or not. */
3992  control_effect_p = statement_whileloop_p(s) || statement_forloop_p(s)
3994  if(!control_effect_p)
3996  }
3997 
3998  return control_effect_p;
3999 }
bool statement_whileloop_p(statement s)
Definition: statement.c:354
bool statement_forloop_p(statement s)
Definition: statement.c:374
static bool look_for_control_effects(call c, bool *control_effect_p)
Definition: statement.c:3946

References call_domain, entity_empty_label_p(), gen_context_recurse, gen_null2(), look_for_control_effects(), statement_forloop_p(), statement_label, statement_unstructured_p(), and statement_whileloop_p().

+ Here is the call graph for this function:

◆ statement_possible_less_p()

bool statement_possible_less_p ( statement  st1,
statement  st2 
)
Parameters
st1t1
st2t2

Definition at line 306 of file statement.c.

307 {
308  int o1 = statement_ordering( st1 ) ;
309  int o2 = statement_ordering( st2 ) ;
310 
311  if (ORDERING_NUMBER( o1 ) != ORDERING_NUMBER( o2 )) {
312  return(true);
313  }
314  else
315  return( ORDERING_STATEMENT(o1) < ORDERING_STATEMENT(o2));
316 }

References ORDERING_NUMBER, ORDERING_STATEMENT, and statement_ordering.

Referenced by TestCoupleOfReferences(), and TestDiVariables().

+ Here is the caller graph for this function:

◆ statement_pragmas()

list statement_pragmas ( statement  s)

get the list of pragma of a statement s

Parameters
sthe statement to work on
Returns
list of pragma of the statement s, NIL if the statement doesn't have pragma

Definition at line 3851 of file statement.c.

3851  {
3852  list lpragmas = NIL;
3855  FOREACH(EXTENSION, ex, exs) {
3856  if(extension_pragma_p(ex)) {
3857  lpragmas = CONS(PRAGMA, extension_pragma(ex), lpragmas);
3858  }
3859  }
3860  return gen_nreverse(lpragmas);
3861 }
#define PRAGMA(x)
PRAGMA.
Definition: ri.h:1991
#define extension_pragma_p(x)
Definition: ri.h:1293
#define extensions_undefined_p(x)
Definition: ri.h:1309

References CONS, EXTENSION, extension_pragma, extension_pragma_p, extensions_extension, extensions_undefined_p, FOREACH, gen_nreverse(), NIL, PRAGMA, and statement_extensions.

Referenced by make_task_mapping().

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

◆ statement_replace_in_root_statement()

bool statement_replace_in_root_statement ( statement  old_stat,
statement  new_stat,
statement  root_stat 
)

replace old_stat by new_stat in root_stat this pass does not free old_stat similar to replace_in_sequence_statement_with() in phrase/phrase_tools.c but without the constraint that old_stat is in a sequence

Parameters
old_statstatement to be replaced
new_statstatement that will replace old_stat
root_statstatement where old_stat is searched to be replaced
Returns
true if old_stat is found and replaced by new_stat think to freed old_stat outside this function if the return is true
Parameters
old_statld_stat
new_statew_stat
root_statoot_stat

Definition at line 4235 of file statement.c.

4238 {
4239  pips_debug(5, "BEGIN\n");
4240 
4241  struct replace_statement_context ctx;
4242  ctx.new_stat = new_stat;
4243  ctx.old_stat = old_stat;
4244  ctx.found_p = false;
4245 
4246  gen_context_recurse(root_stat, &ctx,
4248 
4249  if (!ctx.found_p) {
4250  pips_user_warning("does not found the statement to replace.\n");
4251  }
4252 
4253  pips_debug(5, "END\n");
4254  return ctx.found_p;
4255 }
static bool replace_statement_walker(statement s, struct replace_statement_context *ctx)
Definition: statement.c:4111
#define pips_user_warning
Definition: misc-local.h:146

References replace_statement_context::found_p, gen_context_recurse, gen_null2(), replace_statement_context::new_stat, replace_statement_context::old_stat, pips_debug, pips_user_warning, replace_statement_walker(), and statement_domain.

Referenced by make_send_receive_conversion().

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

◆ statement_replace_with_statement_list()

void statement_replace_with_statement_list ( statement  as,
statement  rs,
list  sl 
)

Assume that statement rs appears in statement as and replaced it by a statement list.

ifdebug(8) {

pips_debug(8, "Ancestor statement before substitution:\n");

print_statement(as);

}

ifdebug(8) {

pips_debug(8, "Ancestor statement after substitution:\n");

print_statement(as);

}

Parameters
ass
rss
sll

Definition at line 3081 of file statement.c.

3082 {
3083  // FI: to avoid a cycle between the ri-util and prettyprint libraries
3084  /* ifdebug(8) { */
3085  /* pips_debug(8, "Ancestor statement before substitution:\n"); */
3086  /* print_statement(as); */
3087  /* } */
3088  if(statement_block_p(as)) {
3089  list asl = statement_block(as);
3091  if(asl==NULL) {
3092  pips_internal_error("The statement is not part of its ancestor");
3093  }
3094  gen_substitute_chunk_by_list(&asl, (void *) rs, sl);
3095  instruction_block(asi) = asl;
3096  }
3097  else {
3098  pips_internal_error("not implemented yet");
3099  }
3100  // FI: to avoid a cycle between the ri-util and prettyprint libraries
3101  /* ifdebug(8) { */
3102  /* pips_debug(8, "Ancestor statement after substitution:\n"); */
3103  /* print_statement(as); */
3104  /* } */
3105 }
void gen_substitute_chunk_by_list(list *pl, const void *o, list sl)
substitute item o by list sl in list *pl, which is modified as a side effect.
Definition: list.c:591

References gen_substitute_chunk_by_list(), instruction_block, pips_internal_error, statement_block(), statement_block_p, and statement_instruction.

+ Here is the call graph for this function:

◆ statement_substatement_p()

bool statement_substatement_p ( statement  s,
statement  root 
)

search a statement inside a statement

Parameters
ssearched statement
rootwhere to start searching from
Returns
true if found

NL: What is the difference with statement_in_statement_p? statement_in_statement_p certainly be better to keep, no global variable and use of gen_recurse_stop to stop the recursion

Parameters
rootoot

Definition at line 3702 of file statement.c.

3703 {
3704  is_substatement= false;
3705  //printf("searching::::::::::::::\n");
3706  //print_statement(s);
3707  //printf("inside::::::::::::\n");
3708  //print_statement(root);
3710  //if(is_substatement) printf(":::::::::found !\n");
3711  //else printf("::::::::not found !\n");
3712  return is_substatement;
3713 }
bool statement_substatement_walker(statement some, statement s)
Definition: statement.c:3683
static bool is_substatement
Definition: statement.c:3681

References gen_context_recurse, gen_null2(), is_substatement, statement_domain, and statement_substatement_walker().

Referenced by get_statement_depth().

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

◆ statement_substatement_walker()

bool statement_substatement_walker ( statement  some,
statement  s 
)
Parameters
someome

Definition at line 3683 of file statement.c.

3684 {
3685  if( !is_substatement)
3686  is_substatement = (some==s);
3687  return !is_substatement;
3688 }

References is_substatement.

Referenced by statement_substatement_p().

+ Here is the caller graph for this function:

◆ statement_to_called_user_entities()

list statement_to_called_user_entities ( statement  s)

Get a list of all user function called recursively within a statement:

  • in the code
  • in initialisations

Definition at line 3478 of file statement.c.

3479 {
3480  entities_t funcs;
3481  funcs.lents = NIL;
3482  funcs.sents = set_make(set_pointer);
3483 
3485  (s, &funcs,
3488  NULL);
3489 
3490  set_free(funcs.sents), funcs.sents = NULL;
3491  return gen_nreverse(funcs.lents);
3492 }
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
static bool add_stat_called_in_inits(statement s, entities_t *funcs)
Definition: statement.c:3462
@ set_pointer
Definition: newgen_set.h:44

References add_stat_called_in_inits(), add_stat_called_user_entities(), call_domain, gen_context_multi_recurse(), gen_nreverse(), gen_null2(), entities_t::lents, NIL, entities_t::sents, set_free(), set_make(), set_pointer, and statement_domain.

Referenced by loop_fully_unrollable_p(), and update_unstructured_declarations().

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

◆ statement_to_comment_length()

int statement_to_comment_length ( statement  stmt)

Number of comment line directly attached to a statement.

Should be zero for sequences.

Is it allowed? Should be the empty string...

Parameters
stmttmt

Definition at line 2375 of file statement.c.

2376 {
2377  int length = 0;
2378  string cmt = statement_comments(stmt);
2379 
2380  if(string_undefined_p(cmt)) {
2381  /* Is it allowed? Should be the empty string... */
2382  length = 0;
2383  }
2384  else {
2385  char c;
2386  while((c=*cmt++)!= '\0')
2387  if(c=='\n')
2388  length++;
2389  }
2390 
2391  return length;
2392 }

References statement_comments, and string_undefined_p.

Referenced by down_counter().

+ Here is the caller graph for this function:

◆ statement_to_declarations()

list statement_to_declarations ( void *  s)

Get a list of all variables declared recursively within a statement.

It works for any newgen type, not only statements. Warning: the list must be freed !

Definition at line 3253 of file statement.c.

3254 {
3256  gen_context_multi_recurse(s, &ctxt,
3259  NULL);
3260  set_free(ctxt.cache);
3262 }
bool gen_false2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2801
static bool add_statement_declarations(statement s, add_statement_declarations_t *ctxt)
Add the declarations of a statement to a list if not already here.
Definition: statement.c:3235

References add_statement_declarations(), add_statement_declarations_t::cache, call_domain, gen_context_multi_recurse(), gen_false2(), gen_null2(), NIL, set_free(), set_make(), set_pointer, statement_domain, and add_statement_declarations_t::statement_to_all_included_declarations.

Referenced by cusq_ctxt_init(), guard_expanded_statement_if_needed(), instruction_to_declarations(), merge_on_outer(), module_to_all_declarations(), outliner_statements_referenced_entities(), statements_to_declarations(), and update_unstructured_declarations().

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

◆ statement_to_direct_declarations()

list statement_to_direct_declarations ( statement  s)

Returns the declarations contained directly in a statement s.

Parameters
sany kind of statement
Returns
a newly allocated list of entities appearing statement s. If s is a sequence, look for all declaration statements in the statement list of s.

No recursive descent in loops or tests or sequences because only variables of the current scope are returned. Recursive descent in unstructured statements because their statements are in the same scope as the statements in list sl

Definition at line 3366 of file statement.c.

3367 {
3368  list dl = NIL;
3369  if(statement_block_p(s)) {
3370  list sl = statement_block(s);
3372  }
3373  else
3375  return dl;
3376 }
static list internal_statement_to_direct_declarations(statement st)
No recursive descent.
Definition: statement.c:3308

References internal_statement_to_direct_declarations(), NIL, statement_block(), statement_block_p, and statements_to_direct_declarations().

Referenced by clean_up_sequences_rewrite(), and copy_write_statement_with_cumulated_regions().

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

◆ statement_to_implicit_target_labels()

list statement_to_implicit_target_labels ( statement  s)

Look for labels appearing in END= or ERR= IO clauses and allocate a label list.

Label List

Definition at line 3145 of file statement.c.

3146 {
3147  list ll = NIL; /* Label List */
3148 
3150 
3151  return ll;
3152 }
static bool find_implicit_goto(statement s, list *tl)
Definition: statement.c:3107

References find_implicit_goto(), gen_context_recurse, gen_null2(), NIL, and statement_domain.

Referenced by fuse_sequences_in_unstructured().

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

◆ statement_to_label()

entity statement_to_label ( statement  s)

See if statement s is labelled and can be reached by a GO TO.

You cannot jump onto a non-executable statement

The initial statement may be an unlabelled CONTINUE...

Definition at line 2090 of file statement.c.

2091 {
2092  entity l = statement_label(s);
2093 
2094  if(format_statement_p(s)) {
2095  /* You cannot jump onto a non-executable statement */
2096  l = entity_empty_label();
2097  }
2098  else if(entity_empty_label_p(l)) {
2100 
2101  switch(instruction_tag(i)) {
2102 
2104  /* The initial statement may be an unlabelled CONTINUE... */
2105  MAPL(cs, {
2106  statement stmt = STATEMENT(CAR(cs));
2107  l = statement_to_label(stmt);
2109  break;
2111  break;
2114  break;
2115  case is_instruction_call:
2116  case is_instruction_test:
2117  case is_instruction_loop:
2119  case is_instruction_goto:
2122  break;
2123  default:
2124  pips_internal_error("Ill. tag %d for instruction",
2125  instruction_tag(i));
2126  }
2127  }
2128 
2129  debug(8, "statement_to_label", "stmt %s, pointed by = %s\n",
2131 
2132  return l;
2133 }
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...

References CAR, continue_statement_p(), control_statement, debug(), entity_empty_label(), entity_empty_label_p(), entity_local_name(), format_statement_p(), instruction_sequence, instruction_tag, instruction_unstructured, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, MAPL, pips_internal_error, sequence_statements, STATEMENT, statement_identification(), statement_instruction, statement_label, statement_to_label(), and unstructured_control.

Referenced by add_label_to_statement(), fuse_2_control_nodes(), fuse_sequences_in_unstructured(), set_control_to_label(), statement_to_label(), and text_trail().

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

◆ statement_to_labels()

list statement_to_labels ( statement  s)

Look for non-empty labels appearing directly or indirectly and allocate a label list.

The code is assumed correct. Usage of labels, for instance in Fortran IOs, are not checked. Only the statement label field is checked.

Label List

To have labels in order of appearance

Definition at line 3169 of file statement.c.

3170 {
3171  list ll = NIL; /* Label List */
3172 
3173  gen_context_recurse(s, (void *) &ll, statement_domain,
3175 
3176  /* To have labels in order of appearance */
3177  ll = gen_nreverse(ll);
3178 
3179  return ll;
3180 }
static bool collect_labels(statement s, list *pll)
Definition: statement.c:3154

References collect_labels(), gen_context_recurse, gen_nreverse(), gen_null2(), NIL, and statement_domain.

Referenced by FixCInternalLabels().

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

◆ statement_to_line_number()

persistant_statement_to_int statement_to_line_number ( statement  s)

Definition at line 2460 of file statement.c.

2461 {
2463 
2465 
2466  current_line = 0;
2467 
2469 
2470  s_to_l = stmt_to_line;
2472  return s_to_l;
2473 }
persistant_statement_to_int make_persistant_statement_to_int(void)
Definition: ri.c:1651
static void up_counter(statement s)
Definition: statement.c:2433
static bool down_counter(statement s)
Definition: statement.c:2409
#define persistant_statement_to_int_undefined
Definition: ri.h:1915

References current_line, down_counter(), gen_multi_recurse(), make_persistant_statement_to_int(), persistant_statement_to_int_undefined, statement_domain, stmt_to_line, and up_counter().

Referenced by make_filtered_dg_or_dvdg(), and prettyprint_dependence_graph().

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

◆ statement_to_referenced_entities()

list statement_to_referenced_entities ( statement  s)

Get a list of all variables referenced recursively within a statement:

  • as reference in expressions in the code
  • as loop indexes, which may not be used anywhere else
  • as references in initializations

Definition at line 3428 of file statement.c.

3429 {
3430  entities_t vars;
3431  vars.lents = NIL;
3432  vars.sents = set_make(set_pointer);
3433 
3435  (s, &vars,
3439  NULL);
3440 
3441  set_free(vars.sents), vars.sents = NULL;
3442  return gen_nreverse(vars.lents);
3443 }
static bool add_loop_index_entity(loop l, entities_t *vars)
Definition: statement.c:3399
static bool add_ref_entities_in_init(statement s, entities_t *vars)
Definition: statement.c:3410

References add_loop_index_entity(), add_ref_entities_in_init(), add_stat_referenced_entities(), gen_context_multi_recurse(), gen_nreverse(), gen_null2(), entities_t::lents, loop_domain, NIL, reference_domain, entities_t::sents, set_free(), set_make(), set_pointer, and statement_domain.

Referenced by redeclaration_enter_statement(), and update_unstructured_declarations().

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

◆ statement_with_empty_comment_p()

bool statement_with_empty_comment_p ( statement  s)

Return true if the statement has an empty statement:

Definition at line 126 of file statement.c.

127 {
128  string the_comments = statement_comments(s);
129  return empty_comments_p(the_comments);
130 }

References empty_comments_p(), and statement_comments.

Referenced by check_if_statement_contains_comment(), clean_statement_from_tags(), clean_up_sequences_rewrite(), debug_statement(), fsmize_statement(), get_externalized_and_analyzed_function_name(), get_function_name_by_searching_tag(), rename_statement_declarations(), spaghettify_statement(), take_out_the_entry_node_of_the_unstructured(), text_block_else(), and update_statement_instruction().

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

◆ statement_with_pragma_p()

bool statement_with_pragma_p ( statement  s)

Test if a statement has some pragma.

Parameters
sis the statement to test
Returns
true if a statement has a pragma

Definition at line 3836 of file statement.c.

3836  {
3838  FOREACH(EXTENSION, ex, exs) {
3839  if(extension_pragma_p(ex)) {
3840  return true;
3841  }
3842  }
3843  return false;
3844 }

References EXTENSION, extension_pragma_p, extensions_extension, FOREACH, and statement_extensions.

Referenced by is_SCOP_rich(), make_task_mapping(), pragma_nonscop(), and statement_with_pragma_p_inv().

+ Here is the caller graph for this function:

◆ statements_to_declarations()

list statements_to_declarations ( list  sl)

Returns the declarations contained in a list of statement.

Parameters
sll

Definition at line 3265 of file statement.c.

3266 {
3267  list tail = NIL; //< avoid a costly gen_nconc
3268  list head = NIL; //< by managing the tail by end
3269  FOREACH(STATEMENT,st,sl) {
3270  list s2d = statement_to_declarations(st);
3271  if(ENDP(head)) head=tail=s2d;
3272  else CDR(tail)=s2d;
3273  tail = gen_last(tail);
3274  }
3275  return head;
3276 }
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578

References CDR, ENDP, FOREACH, gen_last(), NIL, STATEMENT, and statement_to_declarations().

Referenced by outliner(), outliner_scan(), statements_localize_declarations(), and update_referenced_entities().

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

◆ statements_to_direct_declarations()

list statements_to_direct_declarations ( list  sl)

Returns the declarations contained directly in the declaration statements of a list of statements.

Parameters
slList of statements
Returns
a newly allocated list of entities appearing in the statement declarations of the list. No recursive descent in loops or tests or sequences because only variables of the current scope are returned. Recursive descent in unstructured statements because their statements are in the same scope as the statements in list sl
Parameters
sll

Definition at line 3334 of file statement.c.

3335 {
3336  list dl = NIL;
3337  FOREACH(STATEMENT,st,sl) {
3339  // Derived entities may be declared several times
3340  list nsdl = NIL;
3341  FOREACH(ENTITY, e, sdl) {
3342  if(!gen_in_list_p(e, dl))
3343  nsdl = CONS(ENTITY, e, nsdl);
3344  }
3345  nsdl = gen_nreverse(nsdl);
3346  dl = gen_nconc(dl, nsdl);
3347  }
3348 
3349  return dl;
3350 }

References CONS, ENTITY, FOREACH, gen_in_list_p(), gen_nconc(), gen_nreverse(), internal_statement_to_direct_declarations(), NIL, and STATEMENT.

Referenced by fix_block_statement_declarations(), MakeBlock(), MakeForloopWithIndexDeclaration(), and statement_to_direct_declarations().

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

◆ stop_statement_p()

bool stop_statement_p ( statement  s)

Test if a statement is a Fortran STOP.

Definition at line 263 of file statement.c.

264 {
266 
267  return instruction_stop_p(i);
268 }
bool instruction_stop_p(instruction i)
Test if an instruction is a Fortran STOP.
Definition: instruction.c:214

References instruction_stop_p(), and statement_instruction.

Referenced by abc_bound_violation_stop_statement_p(), initial_code_abc_statement_rwt(), interprocedural_abc_statement_rwt(), MakeAssignedOrComputedGotoInst(), pips_code_abc_statement_rwt(), statement_does_return(), and wp65_conform_p().

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

◆ try_to_put_a_comment_on_a_statement()

bool try_to_put_a_comment_on_a_statement ( statement  s,
string  the_comments 
)

Put a comment on a statement in a safe way.

That is it find the first non-block statement to attach it or insert a CONTINUE and put the statement on it. You should free the old one...

The comment should have been malloc()'ed before.

Return true on success, false else.

We are not allowed to put a comment on a sequence, find the first non sequence statement if any:

Ok, we succeed to put the comment:

Hmm, no good statement found to attach a comment:

Ok, it is a plain statement, we can put a comment on it:

Parameters
the_commentshe_comments

Definition at line 1831 of file statement.c.

1833 {
1835  if (instruction_sequence_p(i)) {
1836  /* We are not allowed to put a comment on a sequence, find the
1837  first non sequence statement if any: */
1838  MAP(STATEMENT, st,
1839  {
1840  if (try_to_put_a_comment_on_a_statement(st, the_comments))
1841  /* Ok, we succeed to put the comment: */
1842  return true;
1843  },
1845  /* Hmm, no good statement found to attach a comment: */
1846  return false;
1847  }
1848  else {
1849  /* Ok, it is a plain statement, we can put a comment on it: */
1850  statement_comments(s) = the_comments;
1851  return true;
1852  }
1853 }

References instruction_sequence, instruction_sequence_p, MAP, sequence_statements, STATEMENT, statement_comments, statement_instruction, and try_to_put_a_comment_on_a_statement().

Referenced by put_a_comment_on_a_statement(), and try_to_put_a_comment_on_a_statement().

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

◆ undefined_statement_found_p()

static bool undefined_statement_found_p ( statement  s,
bool p_undefined_p 
)
static

The recursive descent in s is fatal when there is a problem.

print_statement(s);

You probably want a breakpoint here...

Definition at line 3187 of file statement.c.

3188 {
3189  if(!(* p_undefined_p)) {
3190  ifdebug(9) {
3191  fprintf(stderr, "----\n");
3192  /* The recursive descent in s is fatal when there is a problem. */
3193  /* print_statement(s); */
3194  if(statement_undefined_p(s)) {
3195  /* You probably want a breakpoint here... */
3196  abort();
3197  }
3198  else {
3199  pips_debug(9,"checking statement %03td (%td,%td) with address %p:\n",
3202  }
3203  }
3204  * p_undefined_p = statement_undefined_p(s);
3205  }
3206  return !(* p_undefined_p);
3207 }

References abort, fprintf(), ifdebug, ORDERING_NUMBER, ORDERING_STATEMENT, pips_debug, statement_number, statement_ordering, and statement_undefined_p.

Referenced by all_statements_defined_p().

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

◆ unstructured_does_return()

bool unstructured_does_return ( unstructured  u)

Definition at line 2254 of file statement.c.

2255 {
2256  bool returns = false;
2257  control entry = unstructured_control(u);
2259  list nodes = NIL;
2260 
2261  FORWARD_CONTROL_MAP(c, {
2262  returns = returns || (c==exit);
2263  }, entry, nodes);
2264  gen_free_list(nodes);
2265 
2266  return returns;
2267 }
#define FORWARD_CONTROL_MAP(ctl, code, c, list)
Walk through all the controls forward-reachable from a given control node of an unstructured.
#define exit(code)
Definition: misc-local.h:54

References exit, FORWARD_CONTROL_MAP, gen_free_list(), NIL, unstructured_control, and unstructured_exit.

Referenced by statement_does_return().

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

◆ unstructured_to_direct_declarations()

static list unstructured_to_direct_declarations ( unstructured  u)
static

Definition at line 3288 of file statement.c.

3289 {
3290  list blocks = NIL; // list of statements
3291  control c_in = unstructured_control(u); // entry point of u
3292  list dl = NIL; // declaration list
3293 
3294  CONTROL_MAP(c,
3295  {
3298  dl = gen_nconc(dl, sdl);
3299  },
3300  c_in,
3301  blocks);
3302 
3304  return dl;
3305 }
FILE * c_in
Definition: c_syntax.h:291
static list blocks
lisp of loops
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.

References blocks, c_in, CONTROL_MAP, control_statement, gen_free_list(), gen_nconc(), internal_statement_to_direct_declarations(), NIL, and unstructured_control.

Referenced by internal_statement_to_direct_declarations().

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

◆ up_counter()

static void up_counter ( statement  s)
static

There must be an ENDDO here

There must be an ENDIF here

I doubt it's a real good way to detect synthetic IFs

What could be done for ELSE and ELSEIF?

An else stack should be built. Use DEFINE_LOCAL_STACK(name, type) DEFINE_LOCAL_STACK(else_stack, statement) Note that it should be pushed and poped in the down_counter() function

Definition at line 2433 of file statement.c.

2434 {
2436 
2437  if(instruction_loop_p(i)) {
2438  loop l = instruction_loop(i);
2439 
2441  /* There must be an ENDDO here */
2442  current_line += 1;
2443  }
2444  }
2445  else if(instruction_test_p(i)
2447  /* There must be an ENDIF here */
2448  /* I doubt it's a real good way to detect synthetic IFs */
2449  current_line += 1;
2450  }
2451  /* What could be done for ELSE and ELSEIF? */
2452  /* An else stack should be built. Use
2453  * DEFINE_LOCAL_STACK(name, type)
2454  * DEFINE_LOCAL_STACK(else_stack, statement)
2455  * Note that it should be pushed and poped in the down_counter() function
2456  */
2457 }

References current_line, entity_empty_label_p(), instruction_loop, instruction_loop_p, instruction_test_p, loop_label, statement_instruction, statement_number, and STATEMENT_NUMBER_UNDEFINED.

Referenced by statement_to_line_number().

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

◆ update_number_to_statement()

static void update_number_to_statement ( statement  s)
static

Definition at line 1479 of file statement.c.

1480 {
1483  != HASH_UNDEFINED_VALUE) {
1486  (char *) statement_number(s));
1487  }
1488  else {
1489  hash_put(number_to_statement, (char *) statement_number(s), (char *) s);
1490  }
1491  }
1492 }
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.
Definition: hash.c:364

References duplicate_numbers, hash_get(), hash_put(), HASH_UNDEFINED_VALUE, number_to_statement, set_add_element(), statement_number, and STATEMENT_NUMBER_UNDEFINED.

Referenced by build_number_to_statement().

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

◆ update_statement_instruction()

statement update_statement_instruction ( statement  s,
instruction  i 
)

Replace the instruction in statement s by instruction i.

Free the old instruction.

If the new instruction is a sequence, add a CONTINUE to carry the label and/or the comments. The statement number and ordering are set to undefined.

Else if the new instruction is not a sequence, the statement number and the ordering are also set to undefined because the connexion with the parsed line is lost and the ordering most likely obsolete. If the parsed statement number is still meaningfull, the caller must take care of it.

If the initial instruction has been re-used, do not forget to dereference it before calling this function:

statement_instruction(s) = instruction_undefined;

Be careful with the label and the comments too: they may have been reused.

ATTENTION !!! : this version is not for unstructured case

reset numbering and ordering

try hard to keep comments and label when relevant

G:note the special return-label case

add the CONTINUE statement before the sequence instruction i

SG: if the old statement had declarations, they are removed maybe we should regenerate the new one if any to keep global coherency ?

Definition at line 3039 of file statement.c.

3040 {
3041  /* reset numbering and ordering */
3044 
3045  /* try hard to keep comments and label when relevant */
3046  if (instruction_sequence_p(i) && (
3048  (!unlabelled_statement_p(s) && !entity_return_label_p(statement_label(s))) /*SG:note the special return-label case */
3049  ) )
3050  {
3055 
3056  /* add the CONTINUE statement before the sequence instruction i */
3058 
3061  }
3062 
3063  else
3064  {
3066  statement_instruction(s) = i;
3067  /* SG: if the old statement had declarations, they are removed
3068  * maybe we should regenerate the new one if any to keep global coherency ?*/
3075  }
3076  return s;
3077 }
void free_instruction(instruction p)
Definition: ri.c:1118
bool statement_with_empty_comment_p(statement s)
Return true if the statement has an empty statement:
Definition: statement.c:126
#define make_statement_list(stats...)
easy list constructor

References empty_comments, empty_extensions(), entity_empty_label(), entity_return_label_p(), free_extensions(), free_instruction(), gen_free_list(), instruction_sequence_p, instruction_to_statement(), make_continue_statement(), make_instruction_sequence(), make_sequence(), make_statement_list, NIL, return_statement_p(), statement_comments, statement_declarations, statement_extensions, statement_instruction, statement_label, statement_number, STATEMENT_NUMBER_UNDEFINED, statement_ordering, STATEMENT_ORDERING_UNDEFINED, statement_with_empty_comment_p(), and unlabelled_statement_p().

Referenced by compact_phi_functions(), create_block_if_needed(), delay_communications_call(), do_loop_to_for_loop(), do_loop_to_while_loop(), do_redundant_load_store_elimination(), do_symbolic_tiling(), dowhile_to_while_walker(), fs_filter(), gen_flat_mpi(), generic_insert_statement(), guard_expanded_statement(), icm_loop_rwt(), if_conv_init_statement(), inline_return_crawler(), inline_return_remover(), inline_statement_crawler(), insert_rwt(), loop_expansion(), process_true_call_stat(), process_true_stat(), and terapixify_loop_purge().

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

◆ write_statement_p()

bool write_statement_p ( statement  s)

Definition at line 281 of file statement.c.

282 {
284 
286 }
bool native_instruction_p(instruction i, string op_name)
Test if an instruction is a native instruction of the language.
Definition: instruction.c:144

References native_instruction_p(), statement_instruction, and WRITE_FUNCTION_NAME.

+ Here is the call graph for this function:

Variable Documentation

◆ current_line

int current_line = -1
static

Poor attempt at associating physical line numbers to statement.

Lines used for declarations are counted elsewhere: see module_to_declaration_length()

It is assumed that each statement fits on one physical line, excepts sequences which require 0 line. Non statement such as ENDIF, ELSE, ENDDO,... must be taken care of too.

Definition at line 2405 of file statement.c.

Referenced by down_counter(), safe_copy_line_interval(), safe_read_nth_line(), statement_to_line_number(), and up_counter().

◆ duplicate_numbers

set duplicate_numbers = set_undefined
static

To keep track of duplicate numbers.

Definition at line 1477 of file statement.c.

Referenced by build_number_to_statement(), and update_number_to_statement().

◆ first_reference_to_v

reference first_reference_to_v = reference_undefined
static

Return first reference found.

Definition at line 3495 of file statement.c.

Referenced by declarations_first_reference_to_v_p(), find_reference_to_variable(), and first_reference_to_v_p().

◆ generated_variable_commenters

generated_variable_commenter generated_variable_commenters[MAX_COMMENTERS]
static
Initial value:
= {
}
static string default_generated_variable_commenter(__attribute__((unused)) entity e)
Definition: statement.c:2597

Definition at line 2611 of file statement.c.

Referenced by generated_variable_comment(), and push_generated_variable_commenter().

◆ is_substatement

bool is_substatement = false
static

Definition at line 3681 of file statement.c.

Referenced by statement_substatement_p(), and statement_substatement_walker().

◆ loop_depth

int loop_depth
static

◆ nb_commenters

size_t nb_commenters =1
static

◆ number_to_statement

hash_table number_to_statement = hash_table_undefined
static

Mapping from statement number to statement.

Warning: STATEMENT_NUMBER_UNDEFINED may be equal to HASH_ENTRY_FREE_FOR_PUT

Two statements in the same piece of code may have the same number because:

  • they were generated by the parser to simulate a unique user statement (e.g. a computed GO TO)
  • they were generated by a program transformation from the same user statement (e.g. DO statements by a loop distribution)

A statement may be not numbered because:

  • the parser assumed that it did not matter (e.g. a GO TO transformed into an arc by the controlizer); but the parser is not really consistent...
  • a program generation phase has no way to generate a realistic statement number from a user statement number (e.g. code for banks in WP65) static variable temporarily required to use gen_recurse()

Definition at line 1475 of file statement.c.

Referenced by build_number_to_statement(), and update_number_to_statement().

◆ reference_count

◆ stmt_to_line

◆ variable_searched