PIPS
statement.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "properties.h"
#include "ri-util.h"
#include "text-util.h"
#include "prettyprint.h"
+ Include dependency graph for statement.c:

Go to the source code of this file.

Functions

void print_statement_set (FILE *fd, set r)
 statement.c More...
 
void fprint_statement (FILE *fd, statement s)
 Print statement "s" on file descriptor "fd". More...
 
void print_statement (statement s)
 Print a statement on stderr. More...
 
void print_statements (list sl)
 
void print_statement_of_module (statement s, const char *mn)
 
text statement_to_text (statement s)
 
void safe_print_statement (statement s)
 
void print_parallel_statement (statement s)
 
statement last_statement (statement s)
 A simplified version of find_last_statement() located in prettyprint.c and designed to be used within the prettyprinter. More...
 
void print_number_to_statement (hash_table nts)
 
static bool find_statements_interactively_walker (statement s, list *l)
 
list find_statements_interactively (statement s)
 prompt the user to select contiguous statement in s More...
 

Function Documentation

◆ find_statements_interactively()

list find_statements_interactively ( statement  s)

prompt the user to select contiguous statement in s

Parameters
sstatement to search into
Returns
list of selected statement

Definition at line 258 of file statement.c.

259 {
260  list l =NIL;
262  return gen_nreverse(l);
263 }
#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
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
static bool find_statements_interactively_walker(statement s, list *l)
Definition: statement.c:218
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

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

Referenced by outline().

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

◆ find_statements_interactively_walker()

static bool find_statements_interactively_walker ( statement  s,
list l 
)
static

Definition at line 218 of file statement.c.

219 {
220  string answer = string_undefined;
221  do {
222  while( string_undefined_p(answer) || empty_string_p(answer) )
223  {
224  user_log("Do you want to pick the following statement ?\n"
225  "*********************************************\n");
226  print_statement(s);
227 
228  answer = user_request(
229  "*********************************************\n"
230  "[y/n] ?"
231  );
232  if( !answer ) pips_user_error("you did not answer !\n");
233  }
234  if( answer[0]!='y' && answer[0]!='n' )
235  {
236  pips_user_warning("answer by 'y' or 'n' !\n");
237  free(answer);
238  answer=string_undefined;
239  }
240  } while(string_undefined_p(answer));
241  bool pick = answer[0]=='y';
242  if(pick) {
243  *l=CONS(STATEMENT,s,*l);
244  return false;
245  }
246  else if( !ENDP(*l) )
247  gen_recurse_stop(NULL);
248  return true;
249 }
void user_log(const char *format,...)
Definition: message.c:234
bool empty_string_p(const char *s)
Definition: entity_names.c:239
void free(void *)
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define pips_user_warning
Definition: misc-local.h:146
#define pips_user_error
Definition: misc-local.h:147
string user_request(const char *,...)
#define string_undefined
Definition: newgen_types.h:40
#define string_undefined_p(s)
Definition: newgen_types.h:41
void print_statement(statement s)
Print a statement on stderr.
Definition: statement.c:98
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CONS, empty_string_p(), ENDP, free(), gen_recurse_stop(), pips_user_error, pips_user_warning, print_statement(), STATEMENT, string_undefined, string_undefined_p, user_log(), and user_request().

Referenced by find_statements_interactively().

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

◆ fprint_statement()

void fprint_statement ( FILE *  fd,
statement  s 
)

Print statement "s" on file descriptor "fd".

Print the statement according to the current PRETTYPRINT_LANGUAGE property

See text_named_module() for improvements.

Parameters
fdd

Definition at line 68 of file statement.c.

69 {
71  fprintf(fd, "Undefined statement\n");
72  // For debugging with gdb, dynamic type checking
74  (void) fprintf(fd,"Arg. \"s\"is not a statement.\n");
75  else {
76  debug_on("TEXT_DEBUG_LEVEL");
80  list pdl = NIL;
81  text txt = text_statement(entity_undefined, 0, s, &pdl);
82  gen_free_list(pdl);
83  print_text(fd, txt);
84  free_text(txt);
87  debug_off();
88  }
89 }
void free_text(text p)
Definition: text.c:74
void push_current_module_statement(statement)
Set the statement of the current module and push the statement of the previous one on a stack.
Definition: static.c:180
void pop_current_module_statement(void)
Pop the current module statement stack and use it as the current module statement.
Definition: static.c:194
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
void set_alternate_return_set()
Definition: misc.c:795
void reset_alternate_return_set()
Definition: misc.c:804
text text_statement(entity, int, statement, list *)
void reset_label_counter()
Definition: entity.c:322
#define entity_undefined
Definition: ri.h:2761
#define statement_domain_number(x)
Definition: ri.h:2448
#define statement_undefined_p(x)
Definition: ri.h:2420
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void print_text(FILE *fd, text t)
Definition: print.c:195

References debug_off, debug_on, entity_undefined, fprintf(), free_text(), gen_free_list(), NIL, pop_current_module_statement(), print_text(), push_current_module_statement(), reset_alternate_return_set(), reset_label_counter(), set_alternate_return_set(), statement_domain, statement_domain_number, statement_undefined_p, and text_statement().

Referenced by initialize_array_variable(), initialize_scalar_variable(), insert_check_alias_before_statement(), insert_flag_before_call_site(), insert_test_before_caller(), insert_test_before_statement(), print_statement(), and step_compile_generated_module().

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

◆ last_statement()

statement last_statement ( statement  s)

A simplified version of find_last_statement() located in prettyprint.c and designed to be used within the prettyprinter.

Hopefully it is a return statement. Since the semantics of STOP is ignored by the parser, a final STOp should be followed by a RETURN.

Definition at line 168 of file statement.c.

169 {
171 
172  pips_assert("statement is defined", !statement_undefined_p(s));
173 
174  if(statement_sequence_p(s)) {
176 
177  last = (ENDP(ls)? statement_undefined :
179  }
180  else if(statement_unstructured_p(s)) {
182  list trail = unstructured_to_trail(u);
183 
184  last = control_statement(CONTROL(CAR(trail)));
185 
186  gen_free_list(trail);
187  }
188  else if(statement_call_p(s)) {
189  /* Hopefully it is a return statement.
190  * Since the semantics of STOP is ignored by the parser, a
191  * final STOp should be followed by a RETURN.
192  */
193  last = s;
194  }
195  else if(statement_goto_p(s))
196  last = s;
197  else if(statement_expression_p(s))
198  last = s;
199  else if(statement_loop_p(s))
200  last = s;
201  else if(statement_whileloop_p(s))
202  last = s;
203  else if(statement_forloop_p(s))
204  last = s;
205 
206  return last;
207 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
unstructured statement_unstructured(statement s)
Get the unstructured of a statement.
Definition: statement.c:1416
bool statement_expression_p(statement s)
Definition: statement.c:384
bool statement_goto_p(statement s)
Definition: statement.c:359
bool statement_whileloop_p(statement s)
Definition: statement.c:354
bool statement_call_p(statement s)
Definition: statement.c:364
bool statement_forloop_p(statement s)
Definition: statement.c:374
bool statement_loop_p(statement s)
Definition: statement.c:349
bool statement_sequence_p(statement s)
Statement classes induced from instruction type.
Definition: statement.c:335
bool statement_unstructured_p(statement s)
Definition: statement.c:369
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
statement last_statement(statement s)
A simplified version of find_last_statement() located in prettyprint.c and designed to be used within...
Definition: statement.c:168
list unstructured_to_trail(unstructured)
Definition: unstructured.c:240
#define instruction_block(i)
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
#define statement_instruction(x)
Definition: ri.h:2458
#define control_statement(x)
Definition: ri.h:941
#define statement_undefined
Definition: ri.h:2419

References CAR, CONTROL, control_statement, ENDP, gen_free_list(), gen_last(), instruction_block, last_statement(), pips_assert, STATEMENT, statement_call_p(), statement_expression_p(), statement_forloop_p(), statement_goto_p(), statement_instruction, statement_loop_p(), statement_sequence_p(), statement_undefined, statement_undefined_p, statement_unstructured(), statement_unstructured_p(), statement_whileloop_p(), and unstructured_to_trail().

Referenced by compile_omp(), FixCReturnStatements(), last_statement(), and step_compile_analysed_module().

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

◆ print_number_to_statement()

void print_number_to_statement ( hash_table  nts)
Parameters
ntsts

Definition at line 209 of file statement.c.

210 {
211  HASH_MAP(number, stmt, {
212  fprintf(stderr,"%td\t", (_int) number);
214  }, nts);
215 }
static hash_table nts
Definition: prettyprint.c:63
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
intptr_t _int
_INT
Definition: newgen_types.h:53
Definition: statement.c:54

References fprintf(), HASH_MAP, nts, and print_statement().

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

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

◆ print_parallel_statement()

void print_parallel_statement ( statement  s)

Definition at line 156 of file statement.c.

157 {
160  print_statement(s);
162  free(cstyle);
163 }
char * get_string_property(const char *)
#define PRETTYPRINT_PARALLEL
void set_string_property(const char *, const char *)
char * strdup()

References free(), get_string_property(), PRETTYPRINT_PARALLEL, print_statement(), set_string_property(), and strdup().

Referenced by CodeGenerate(), do_it(), MakeLoopAs(), rice_loop(), and rice_statement().

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

◆ print_statement()

void print_statement ( statement  s)

Print a statement on stderr.

Print the statement according to the current PRETTYPRINT_LANGUAGE property

See text_named_module() for improvements.

Definition at line 98 of file statement.c.

99 {
100  fprint_statement(stderr, s);
101 }
void fprint_statement(FILE *fd, statement s)
Print statement "s" on file descriptor "fd".
Definition: statement.c:68

References fprint_statement().

Referenced by abc_instrumentation_insert_before_statement(), add_aliases_for_current_call_site(), adg_dataflowgraph(), adg_dataflowgraph_with_extremities(), assign_statement_task_mapping(), atomize_as_required(), bottom_up_abc_insert_before_statement(), bottom_up_abc_statement_rwt(), build_binary_operators_with_huffman(), c_code_string(), c_unstructured(), call_flt(), call_to_transformer(), comEngine_opt_loop_interchange(), compile_body(), compute_distribution_controlization_context(), compute_region(), connect_unstructured(), controlize_distribution(), copy_n_reference(), copy_n_statement(), copy_write_statement_with_cumulated_regions(), create_module_with_statement(), cse_expression_flt(), ctx_get_send_statement(), da_process_list(), debug_statement(), debug_unstructured(), distribute_code(), do_it(), do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), do_substitute(), dprint(), extract_matching_statements(), extract_non_conflicting_statements(), filter_live_out_regions_statement(), find_statements_interactively_walker(), fprint_bdt_with_stat(), fs_filter(), fsmize_statement(), full_loop_unroll(), full_spaghettify(), full_spaghettify_statement(), generate_code(), generate_code_loop(), generate_code_test_proc(), get_externalized_and_analyzed_function_name(), get_function_name_by_searching_tag(), get_points_to_graph_from_statement(), get_statements_with_comments_containing(), gpu_ify_statement(), gpu_memory_apply(), gpu_promote_sequential_on_sequence(), HRE_distribute(), HRE_distribute_stat(), icm_codegen(), identify_statements_to_distribute(), if_conv_init_statement(), if_conversion_compact_stats(), if_conversion_init(), init_statement_equivalence_table(), initial_code_abc_statement_rwt(), inline_calls(), inline_expression(), inline_expression_call(), inline_statement_crawler(), interprocedural_abc_insert_before_statement(), invariant_code_motion(), is_elsif_test_p(), isolate_code_portion(), loop_strip_mine(), make_array_communication_statement(), make_bottom_up_abc_tests(), make_interprocedural_abc_tests(), make_lInitStats(), make_lSwitchStats(), make_mpi_conversion(), make_send_receive_conversion(), make_statement_copy_i(), make_task_mapping(), mark_loop_to_outline(), mpi_initialize(), opt_loop_interchange_fill_lists(), outliner_patch_parameters(), outliner_statements_referenced_entities(), partial_eval_statement(), phrase_distributor_control_code(), phrase_remove_dependences_rwt(), postcondition_filter(), prepare_context(), prettyprint_dot_dependence_graph(), print_number_to_statement(), print_parallel_statement(), print_statement_of_module(), print_statements(), process_true_call_stat(), reduce_sequence(), reductions_rewrite(), remove_begin_tag(), remove_end_tag(), rename_statement_reductions(), replace_in_sequence_statement_with(), replace_reductions_in_statement(), replicate_declaration(), rice_loop(), rm_db_block(), safe_print_statement(), safescale_distributor(), safescale_module_analysis(), seq_flt(), sequence_to_post_pv(), simdize_simple_statements_pass2(), SimplifyGraph(), smalltalk_code_string(), some_conflicts_between(), spaghettify_statement(), st_statement(), statement_convert_to_statement_with_sequence_of_intruction(), statement_filter(), statement_rewrite(), step_directive_print(), step_update_comm(), store_new_module(), SupressDependances(), taskify_statement(), Tiling2_buffer(), top_down_abc_flt(), top_down_abc_rwt(), variable_private_to_loop_p(), verify_array_element(), verify_array_variable(), verify_scalar_variable(), verify_used_before_set_statement_flt(), wp65_debug_print_text(), and xml_code_string().

+ Here is the call graph for this function:

◆ print_statement_of_module()

void print_statement_of_module ( statement  s,
const char *  mn 
)
Parameters
mnn

Definition at line 111 of file statement.c.

112 {
117  print_statement(s);
119  }
120  else
121  print_statement(s);
122 }
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
#define entity_undefined_p(x)
Definition: ri.h:2762

References entity_undefined_p, get_current_module_entity(), local_name_to_top_level_entity(), print_statement(), reset_current_module_entity(), reset_label_counter(), and set_current_module_entity().

+ Here is the call graph for this function:

◆ print_statement_set()

void print_statement_set ( FILE *  fd,
set  r 
)

statement.c

Parameters
fdd

Definition at line 49 of file statement.c.

50 {
51  fprintf(fd, "Set contains statements");
52 
53  SET_MAP(s, {
54  fprintf(fd, " %02td", statement_number((statement) s));
55  }, r);
56 
57  fprintf(fd, "\n");
58 }
#define SET_MAP(element, code, the_set)
Definition: newgen_set.h:54
#define statement_number(x)
Definition: ri.h:2452

References fprintf(), SET_MAP, and statement_number.

Referenced by CodeGenerate(), rdg_loop(), rice_loop(), and rice_update_dependence_graph().

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

◆ print_statements()

void print_statements ( list  sl)
Parameters
sll

Definition at line 103 of file statement.c.

104 {
105  FOREACH(STATEMENT, s, sl) {
106  print_statement(s);
107  }
108 }
#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

References FOREACH, print_statement(), and STATEMENT.

Referenced by dprint(), rename_statement_declarations(), and simdize_simple_statements_pass2().

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

◆ safe_print_statement()

void safe_print_statement ( statement  s)

The return label only can be associated to a RETURN call, however the controlizer does not follow this consistency rule.

Definition at line 140 of file statement.c.

141 {
142  if(statement_undefined_p(s)) {
143  fprintf(stderr, "Statement undefined\n");
144  }
145  else if(continue_statement_p(s)
147  /* The return label only can be associated to a RETURN call,
148  however the controlizer does not follow this consistency
149  rule. */
150  fprintf(stderr, "%s\n", statement_identification(s));
151  }
152  else
153  print_statement(s);
154 }
string statement_identification(statement s)
Like external_statement_identification(), but with internal information, the hexadecimal address of t...
Definition: statement.c:1700
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
bool entity_return_label_p(entity e)
Definition: entity.c:673
#define statement_label(x)
Definition: ri.h:2450

References continue_statement_p(), entity_return_label_p(), fprintf(), print_statement(), statement_identification(), statement_label, and statement_undefined_p.

Referenced by check_new_arc_for_structured_statement(), and IsolatedStatement().

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

◆ statement_to_text()

text statement_to_text ( statement  s)

Definition at line 124 of file statement.c.

125 {
126  text t = text_undefined;
127 
128  debug_on("PRETTYPRINT_DEBUG_LEVEL");
131  list pdl = NIL;
132  t = text_statement(entity_undefined, 0, s, &pdl);
133  gen_free_list(pdl);
135  debug_off();
136 
137  return t;
138 }
#define text_undefined
Definition: text.h:91

References debug_off, debug_on, entity_undefined, gen_free_list(), NIL, reset_alternate_return_set(), reset_label_counter(), set_alternate_return_set(), text_statement(), and text_undefined.

Referenced by control_graph(), insert_impact_description_as_comment(), and subtsitute_variable_in_reference().

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