PIPS
transformations.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum dead_test dead_test
 

Enumerations

enum  dead_test {
  nothing_about_test , then_is_dead , else_is_dead , nothing_about_test ,
  then_is_dead , else_is_dead
}
 Warning! Do not modify this file that is automatically generated! More...
 

Functions

void statement_clean_declarations (statement)
 cproto-generated files More...
 
void entity_clean_declarations (entity, statement)
 remove all entities declared in module but never used in s More...
 
statement find_loop_from_label (statement, entity)
 
bool clean_labels (const string)
 
int get_processor_number (void)
 
int get_vector_register_length (void)
 
int get_vector_register_number (void)
 
void do_loop_unroll (statement, int, void(*)(statement))
 loop_unroll.c More...
 
void loop_unroll (statement, int)
 fallbacks on do_loop_unroll without statement post processing More...
 
bool loop_fully_unrollable_p (loop)
 
void full_loop_unroll (statement)
 get rid of the loop by body replication; More...
 
bool unroll (const string)
 Top-level functions. More...
 
bool full_unroll (const string)
 
bool full_unroll_pragma (const string)
 
bool print_parallelizedcray_code (char *)
 prettyprintcray.c More...
 
statement loop_strip_mine (statement, int, int)
 strip_mine.c More...
 
bool strip_mine (const string)
 Top-level function. More...
 
bool selected_loop_p (statement)
 
bool interactive_loop_transformation (const char *, statement(*)(list, bool(*)(statement)))
 
bool print_loops (const string)
 
bool flag_loops (const string)
 put a label on each doloop without label More...
 
char * loop_pragma (const char *, const char *)
 
char * module_loops (const char *, const char *)
 gather the list of enclosing loops expect flag_loops has been called before More...
 
void loop_normalize_statement (statement)
 loop_normalize.c More...
 
bool loop_normalize (const string)
 
bool linearize_loop_range (const char *)
 
statement interchange_inner_outermost_loops (list, bool(*)(statement))
 interchange.c More...
 
statement interchange_two_loops (list, int, int)
 
bool loop_interchange (const string)
 
bool nest_parallelization (const char *)
 nest_parallelization.c More...
 
bool coarse_grain_parallelization (const string)
 coarse_grain_parallelization.c More...
 
bool coarse_grain_parallelization_with_reduction (const string)
 
bool dead_code_elimination_on_module (char *, bool)
 dead_code_elimination.c More...
 
bool dead_code_elimination (char *)
 
bool dead_code_elimination_with_out_regions (char *)
 
bool use_def_elimination (char *)
 
bool suppress_trivial_test (const string)
 trivial_test_elimination.c More...
 
bool privatize_module (const string)
 privatize.c More...
 
bool privatize_module_even_globals (const string)
 
bool localize_declaration (const string)
 
bool array_privatizer (const string)
 array_privatization.c More...
 
bool array_section_privatizer (const string)
 
bool print_code_privatized_regions (const string)
 
bool declarations_privatizer (const string)
 
bool stf (const string)
 standardize_structure.c More...
 
bool simplify_control (const string)
 simplify_control.c More...
 
bool simplify_control_directly (const string)
 
bool suppress_dead_code (const string)
 
bool remove_useless_label (const string)
 
void module_clean_declarations (entity, statement)
 declarations.c More...
 
bool clean_declarations (const string)
 A phase to remove the declaration of useless variables. More...
 
bool clean_unused_dynamic_variables (string)
 dynamic_declarations.c More...
 
bool transformation_test (const string)
 transformation_test.c More...
 
bool freeze_variables (char *)
 freeze_variables.c More...
 
bool array_resizing_bottom_up (char *)
 array_resizing_bottom_up.c More...
 
bool array_resizing_full_bottom_up (char *)
 
bool array_resizing_top_down (const char *)
 array_resizing_top_down.c More...
 
bool array_resizing_statistic (const string)
 array_resizing_statistic.c More...
 
bool partial_redundancy_elimination (const string)
 partial_redundancy_elimination.c More...
 
bool variable_expansion (const char *)
 variable_expansion.c More...
 
bool reduction_variable_expansion (const char *)
 
bool internalize_parallel_code (const string)
 internalize_parallel_code.c More...
 
bool index_set_splitting (const string)
 index_set_splitting.c More...
 
bool force_loop_fusion (const string)
 
bool recover_for_loop (const string)
 for_loop_recovering.c More...
 
bool scalarization (const string)
 scalarization.c More...
 
bool constant_array_scalarization (const string)
 
bool quick_scalarization (const string)
 
bool statement_flatten_declarations (entity, statement)
 flatten_code.c More...
 
bool flatten_code (const string)
 Pipsmake 'flatten_code' phase. More...
 
void statement_split_initializations (statement)
 Recurse through the statements of s and split local declarations. More...
 
bool split_initializations (const char *)
 Pipsmake 'split_initializations' phase. More...
 
void split_update_call (call)
 
bool split_update_operator (const char *)
 
bool induction_substitution (const string)
 induction_substitution.c More...
 
bool strength_reduction (const string)
 strength_reduction.c More...
 
bool loop_fusion (char *)
 loop_fusion.c More...
 
bool loop_fusion_with_regions (char *)
 
bool set_return_type_as_typedef (const string)
 set_return_type.c More...
 
bool cast_at_call_sites (const string)
 cast_at_call_sites.c More...
 
bool limit_nested_parallelism (const string)
 manage_parallel_loops.c More...
 
bool limit_parallelism_using_complexity (const string)
 
bool force_register_declarations (const char *)
 registers.c More...
 
bool identity_elimination (const char *)
 identity_elimination.c More...
 
bool identity_elimination_with_points_to (const char *)
 
bool loop_bound_minimization_with_out_regions_on_statement (statement)
 loop_bound_minimization.c More...
 
bool loop_bound_minimization_with_out_regions (const char *)
 
bool print_interface (const char *)
 cprettyprinter.c More...
 
bool print_crough (const char *)
 
bool print_c_code (const char *)
 C indentation thru indent. More...
 
bool check_initialize_vla_with_preconditions (const string)
 initialized_vla.c More...
 
bool check_initialize_vla_with_effects (const string)
 
bool check_initialize_vla_with_regions (const string)
 
bool initialize_vla_with_preconditions (const char *)
 
bool initialize_vla_with_effects (const char *)
 
bool initialize_vla_with_regions (const char *)
 

Variables

entity selected_label
 interactive_loop_transformation.c More...
 

Typedef Documentation

◆ dead_test

typedef enum dead_test dead_test

Definition at line 1 of file transformations.h.

Enumeration Type Documentation

◆ dead_test

enum dead_test

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/transformations/transformations-local.h instead, to add your own modifications. header file built by cproto transformations-local.h What is returned by dead_test_filter :

Enumerator
nothing_about_test 
then_is_dead 
else_is_dead 
nothing_about_test 
then_is_dead 
else_is_dead 

Definition at line 35 of file transformations.h.

@ else_is_dead
@ then_is_dead
@ nothing_about_test

Function Documentation

◆ array_privatizer()

bool array_privatizer ( const  string)

array_privatization.c

Parameters
stringodule_name

◆ array_resizing_bottom_up()

bool array_resizing_bottom_up ( char *  )

◆ array_resizing_full_bottom_up()

bool array_resizing_full_bottom_up ( char *  )

◆ array_resizing_statistic()

bool array_resizing_statistic ( const  string)

array_resizing_statistic.c

Parameters
stringodule_name

◆ array_resizing_top_down()

bool array_resizing_top_down ( const char *  )

◆ array_section_privatizer()

bool array_section_privatizer ( const  string)
Parameters
stringodule_name

◆ cast_at_call_sites()

bool cast_at_call_sites ( const  string)

cast_at_call_sites.c

Parameters
stringod_name

◆ check_initialize_vla_with_effects()

bool check_initialize_vla_with_effects ( const  string)
Parameters
stringodule_name

◆ check_initialize_vla_with_preconditions()

bool check_initialize_vla_with_preconditions ( const  string)

initialized_vla.c

Parameters
stringodule_name

◆ check_initialize_vla_with_regions()

bool check_initialize_vla_with_regions ( const  string)
Parameters
stringodule_name

◆ clean_declarations()

bool clean_declarations ( const string  module_name)

A phase to remove the declaration of useless variables.

It recursively calls statement_remove_unused_declarations on all module statement

Parameters
[in]module_nameis the name of the module to process
Returns
true because always successful

prelude

first remove any statement that writes only variable that are never read

body

ostlude

Parameters
module_nameodule_name

Definition at line 155 of file declarations.c.

156 {
157  /* prelude */
161 
162  debug_on("CLEAN_DECLARATIONS_DEBUG_LEVEL");
163 
164  /* first remove any statement that writes only variable that are never read */
166 
167  /* body*/
169 
171 
172  debug_off();
173 
174  /*postlude */
178  return true;
179 }
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
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
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
static void remove_unread_variables(statement s)
Definition: declarations.c:116
void module_clean_declarations(entity module, statement module_statement)
declarations.c
Definition: declarations.c:140

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), get_current_module_entity(), get_current_module_statement(), module_clean_declarations(), module_name(), module_name_to_entity(), remove_unread_variables(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ clean_labels()

bool clean_labels ( const  string)
Parameters
stringod_name

Definition at line 238 of file util.c.

239 {
240  statement mod_stmt = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
241 
243  set_current_module_statement( mod_stmt);
244 
246 
247  DB_PUT_MEMORY_RESOURCE(DBR_CODE,
248  strdup(mod_name),
249  (char*) mod_stmt);
250 
253 
254  return true;
255 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
char * strdup()
static bool clean_statement_label(statement st)
Definition: util.c:226

References clean_statement_label(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, gen_null(), gen_recurse, module_name_to_entity(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, and strdup().

+ Here is the call graph for this function:

◆ clean_unused_dynamic_variables()

bool clean_unused_dynamic_variables ( string  )

◆ coarse_grain_parallelization()

bool coarse_grain_parallelization ( const  string)

coarse_grain_parallelization.c

Parameters
stringodule_name

◆ coarse_grain_parallelization_with_reduction()

bool coarse_grain_parallelization_with_reduction ( const  string)
Parameters
stringodule_name

◆ constant_array_scalarization()

bool constant_array_scalarization ( const  string)
Parameters
stringodule_name

◆ dead_code_elimination()

bool dead_code_elimination ( char *  )

◆ dead_code_elimination_on_module()

bool dead_code_elimination_on_module ( char *  ,
bool   
)

◆ dead_code_elimination_with_out_regions()

bool dead_code_elimination_with_out_regions ( char *  )

◆ declarations_privatizer()

bool declarations_privatizer ( const  string)
Parameters
stringod_name

◆ do_loop_unroll()

void do_loop_unroll ( statement  loop_statement,
int  rate,
void(*)(statement statement_post_processor 
)

loop_unroll.c

Parameters
loop_statementoop_statement
rateate

Definition at line 714 of file loop_unroll.c.

717 {
718  pips_debug(2, "unroll %d times\n", rate);
719  pips_assert("the statement is a loop",
720  instruction_loop_p(statement_instruction(loop_statement)));
721  pips_assert("the unrolling factor is strictly positive", rate > 0);
722 
723  if(rate>1) {
724  loop il = instruction_loop(statement_instruction(loop_statement));
725  range lr = loop_range(il);
726  expression inc = range_increment(lr);
727  intptr_t incval;
728 
729  // FI: a property should be checked because epilogue cannot be
730  // used if backward compatibility must be maintained
731  if(expression_integer_value(inc, &incval) && incval==1
732  && !get_bool_property("LOOP_UNROLL_WITH_PROLOGUE"))
733  do_loop_unroll_with_epilogue(loop_statement,
734  rate,
735  statement_post_processor);
736  else
737  do_loop_unroll_with_prologue(loop_statement,
738  rate,
739  statement_post_processor);
740  }
741  pips_debug(3, "done\n");
742 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static void do_loop_unroll_with_epilogue(statement loop_statement, int rate, void(*statement_post_processor)(statement))
db_get_current_module_name() unusable because module not set, and setting it causes previous current ...
Definition: loop_unroll.c:95
static void do_loop_unroll_with_prologue(statement loop_statement, int rate, void(*statement_post_processor)(statement))
This function unrolls any DO loop by a constant factor "rate".
Definition: loop_unroll.c:341
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
#define range_increment(x)
Definition: ri.h:2292
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define intptr_t
Definition: stdint.in.h:294

References do_loop_unroll_with_epilogue(), do_loop_unroll_with_prologue(), expression_integer_value(), get_bool_property(), instruction_loop, instruction_loop_p, intptr_t, loop_range, pips_assert, pips_debug, range_increment, and statement_instruction.

Referenced by loop_unroll(), and simd_loop_unroll().

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

◆ entity_clean_declarations()

void entity_clean_declarations ( entity  module,
statement  s 
)

remove all entities declared in module but never used in s

Parameters
modulemodule to check
sstatement where entites may be used

to keep backward compatibility with hpfc

Parameters
moduleodule

Definition at line 177 of file util.c.

178 {
180  if( ! same_entity_p(curr,module)) {
183  }
184  else
185  curr=entity_undefined;
186 
188  if(fortran_module_p(module)) /* to keep backward compatibility with hpfc*/
190 
191  if(!entity_undefined_p(curr)){
194  }
195 }
static char * module
Definition: pips.c:74
#define entity_declarations(e)
MISC: newgen shorthands.
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
static void entity_generate_missing_declarations(entity module, statement s)
check if all entities used in s and module are declared in module does not work as well as expected o...
Definition: util.c:140
static void statement_clean_declarations_helper(list declarations, statement stmt)
remove useless entities from declarations an entity is flagged useless when no reference is found in ...
Definition: util.c:80

References entity_declarations, entity_generate_missing_declarations(), entity_undefined, entity_undefined_p, fortran_module_p(), get_current_module_entity(), module, reset_current_module_entity(), same_entity_p(), set_current_module_entity(), and statement_clean_declarations_helper().

Referenced by compile_module(), and module_clean_declarations().

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

◆ find_loop_from_label()

statement find_loop_from_label ( statement  s,
entity  label 
)
Parameters
labelabel

Definition at line 218 of file util.c.

219 {
220  struct flfl ctx = { label, statement_undefined };
221  gen_context_recurse(s, &ctx,
223  return ctx.found;
224 }
#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 loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_undefined
Definition: ri.h:2419
Definition: util.c:199
entity label
Definition: util.c:200
statement found
Definition: util.c:201
static bool find_loop_from_label_walker(loop l, struct flfl *p)
Definition: util.c:204

References find_loop_from_label_walker(), flfl::found, gen_context_recurse, gen_null2(), flfl::label, loop_domain, and statement_undefined.

Referenced by full_unroll(), loop_auto_unroll(), loop_expansion(), loop_expansion_init(), loop_pragma(), module_loops(), print_loopnest_dependence_cone(), simdizer_auto_tile(), symbolic_tiling(), and unroll().

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

◆ flag_loops()

bool flag_loops ( const string  module_name)

put a label on each doloop without label

Parameters
module_name
Returns

prelude

run loop labeler

validate

ostlude

Parameters
module_nameodule_name

Definition at line 191 of file interactive_loop_transformation.c.

192 {
193  /* prelude */
196  ((statement) db_get_memory_resource(DBR_CODE, module_name, true) );
197  flag_loop_param_t flp = { .loops = NIL, .new_label_created = false };
198 
199  /* run loop labeler */
202 
203  /* validate */
206 
207  /*postlude*/
210  return true;
211 }
callees make_callees(list a)
Definition: ri.c:227
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
static void flag_loop(statement st, flag_loop_param_t *flp)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, flag_loop(), gen_context_recurse, gen_true2(), get_current_module_statement(), flag_loop_param_t::loops, make_callees(), module_name(), module_name_to_entity(), flag_loop_param_t::new_label_created, NIL, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_domain.

+ Here is the call graph for this function:

◆ flatten_code()

bool flatten_code ( const string  module_name)

Pipsmake 'flatten_code' phase.

This function is be composed of several steps:

1 flatten declarations inside statement: declarations are moved as high as possible in the control structure; this may serialize parallel loops, but this pass was designed for sequential code.

2 clean_up_sequences: remove useless braces when they are nested.

3 unroll looops with statically known iteration number.

4 clean_up_sequences: remove useless braces when they are nested.

It is assumed that the function main statement will contain at least one local variable. This is used to preserve the scoping mechanism used by the parser. Thus, "void foo(void){{{}}}" cannot be flatten. Note that clean_up_sequences could be used first to avoid such cases. Function "void foo(void){{{extern int i;}}}" cannot be flatten either, but clean_up_sequences might help.

Is it a top-level entity?

Parameters
module_nameodule_name

Definition at line 648 of file flatten_code.c.

649 {
650  bool good_result_p = true;
651 
655  code c = value_code(mv); // No check on value's kind
656  list dl = code_declarations(c);
657 
658  debug_on("FLATTEN_CODE_DEBUG_LEVEL");
659  pips_debug(1, "begin\n");
660 
661  // Step 0: the algorithms used do not deal with dependent or
662  // variable-length array (VLA) types unless they are formal parameters
663  // or appear at top-level... (see TRAC ticket 751)
664  // Declarations are moved to the top, without any regard to data dependencies
665  FOREACH(ENTITY, v, dl) {
666  if(!entity_formal_p(v)) {
667  type t = entity_type(v);
668  if(dependent_type_p(t)) {
669  string eln = (string) entity_local_name(v);
670  string s = local_name_to_scope(eln);
671  /* Is it a top-level entity? */
672  if(strlen(s)>2) {
673  good_result_p = false;
674  break;
675  }
676  else {
677  pips_user_warning("Code generated by pass Flatten_code may be wrong"
678  " because of VLA type of variable \"%s\"\n",
679  entity_user_name(v));
680  }
681  }
682  }
683  }
684 
685  if(!good_result_p) {
686  pips_user_warning("Module \"%s\" could not be flattened because it uses a variable-length array (VLA).\n", entity_user_name(module));
687  }
688  else {
690  db_get_memory_resource(DBR_CODE, module_name, true) );
691  statement module_stat = get_current_module_statement();
692 
693  // Step 1 and 2: flatten declarations and clean up sequences
694  if ((good_result_p=statement_flatten_declarations(module,module_stat)))
695  {
696  statement_purge_declarations(module_stat);
697  // call sequence flattening as some declarations may have been moved up
698  clean_up_sequences(module_stat);
699 
700  // Step 3 and 4: unroll loops and clean up sequences
701  if(get_bool_property("FLATTEN_CODE_UNROLL"))
702  {
703  gen_recurse(module_stat,
705  clean_up_sequences(module_stat); // again
706  }
707 
708  // This might not be necessary, thanks to clean_up_sequences
709  module_reorder(module_stat);
710  // Save modified code to database
711  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(module_name), module_stat);
712  }
714  }
715 
716  pips_debug(1, "end\n");
717  debug_off();
718 
720 
721  return good_result_p;
722 }
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
bool statement_flatten_declarations(entity module, statement s)
flatten_code.c
Definition: flatten_code.c:509
static void statement_purge_declarations(statement s)
Definition: flatten_code.c:620
static void unroll_loops_in_statement(statement s)
Definition: flatten_code.c:591
#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
#define pips_user_warning
Definition: misc-local.h:146
char * string
STRING.
Definition: newgen_types.h:39
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
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_formal_p(entity p)
is p a formal parameter?
Definition: entity.c:1935
string local_name_to_scope(const char *ln)
allocates a new string
Definition: entity.c:563
bool dependent_type_p(type)
A type is dependent in many ways according to definitions given in Wikipedia.
Definition: type.c:5849
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define code_declarations(x)
Definition: ri.h:784
#define value_code(x)
Definition: ri.h:3067
#define entity_type(x)
Definition: ri.h:2792
#define entity_initial(x)
Definition: ri.h:2796
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References clean_up_sequences(), code_declarations, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dependent_type_p(), ENTITY, entity_formal_p(), entity_initial, entity_local_name(), entity_type, entity_user_name(), FOREACH, gen_recurse, gen_true(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), local_name_to_scope(), module, module_name(), module_name_to_entity(), module_reorder(), pips_debug, pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, statement_flatten_declarations(), statement_purge_declarations(), strdup(), unroll_loops_in_statement(), and value_code.

+ Here is the call graph for this function:

◆ force_loop_fusion()

bool force_loop_fusion ( const  string)
Parameters
stringodule_name

◆ force_register_declarations()

bool force_register_declarations ( const char *  )

◆ freeze_variables()

bool freeze_variables ( char *  )

◆ full_loop_unroll()

void full_loop_unroll ( statement  loop_statement)

get rid of the loop by body replication;

the loop body is replicated as many times as there are iterations

FI: could be improved to handle symbolic lower bounds (18 January 1993)

final loop body label

Start debug in Newgen

Validity of transformation should be checked

ie.: - pas d'effets de bords dans les expressions duplique'es

Instruction block is created and will contain everything

get rid of labels in loop body: don't worry, useful labels have been transformed into arcs by controlizer, you just loose loop labels. However, the label of the last statement in the loop body might be used by an outer loop and, in doubt, should be preserved.

FI: clone_statement() has been used above to perform flatten_code. Hence the declarations are no longer accessible from "transformed_stmt". And when dependent types are used, they are not updated.

Try to update dependent types. Too bad the declarations are scanned again and again.

Add the transformated old loop body (transformed_stmt) at the end of the loop

Generate a CONTINUE to carry the final loop body label in case an outer loop uses it

Generate a statement to reinitialize old index

SG: only needed if index is not private

Free old instruction and replace with block

FI: according to me, gen_copy_tree() does not create a copy sharing nothing with its actual parameter; if the free is executed, Pvecteur normalized_linear is destroyed (18 January 1993)

Do not forget to move forbidden information associated with block:

?? Bad condition

Stop debug in Newgen

Parameters
loop_statementoop_statement

Definition at line 788 of file loop_unroll.c.

789 {
790  loop il = instruction_loop(statement_instruction(loop_statement));
791  range lr = loop_range(il);
792  entity ind = loop_index(il);
793  entity flbl = entity_undefined; /* final loop body label */
794  expression lb = range_lower(lr);
795  expression ub = range_upper(lr);
796  expression inc = range_increment(lr);
797  expression rhs_expr, expr;
798  statement stmt;
800  intptr_t lbval, ubval, incval;
801  int iter;
802 
803  pips_debug(2, "begin\n");
804 
805  ifdebug(7) {
806  /* Start debug in Newgen */
808  }
809  /* Validity of transformation should be checked */
810  /* ie.: - pas d'effets de bords dans les expressions duplique'es */
811 
812  if (expression_integer_value(lb, &lbval)
813  && expression_integer_value(ub, &ubval)
814  && expression_integer_value(inc, &incval)) {
815  pips_assert("full_loop_unroll", incval != 0);
816  }
817  else {
818  pips_user_error("loop range for loop %s must be numerically known\n",
820  // previous function is noreturn... but try to please lang.
821  return;
822  }
823 
824  /* Instruction block is created and will contain everything */
826 
827  /* get rid of labels in loop body: don't worry, useful labels have
828  been transformed into arcs by controlizer, you just loose loop
829  labels. However, the label of the last statement in the loop body
830  might be used by an outer loop and, in doubt, should be preserved. */
831 
833 
834  (void) clear_labels (loop_body (il));
835 
836  for(iter = lbval; iter <= ubval; iter += incval) {
837  statement transformed_stmt;
838 
842  NIL,
844  transformed_stmt = clone_statement(loop_body(il), cc);
845  free_clone_context(cc);
846 
847  ifdebug(9)
848  statement_consistent_p(transformed_stmt);
849  expr = int_to_expression(iter);
850  ifdebug(9) {
851  pips_assert("full_loop_unroll", expression_consistent_p(expr));
852  }
853  /* FI: clone_statement() has been used above to perform
854  flatten_code. Hence the declarations are no longer
855  accessible from "transformed_stmt". And when dependent
856  types are used, they are not updated. */
857  replace_entity_by_expression(transformed_stmt,ind,expr);
858  /* Try to update dependent types. Too bad the declarations are
859  scanned again and again. */
862 
863  ifdebug(9) {
864  pips_assert("full_loop_unroll", statement_consistent_p(transformed_stmt));
865  }
866  free_expression(expr);
867 
868  ifdebug(9) {
869  pips_assert("full_loop_unroll", statement_consistent_p(transformed_stmt));
870  }
871 
872  /* Add the transformated old loop body (transformed_stmt) at
873  * the end of the loop */
874  if( statement_block_p(transformed_stmt) && get_bool_property("LOOP_UNROLL_MERGE"))
875  {
876  if(ENDP(statement_declarations(loop_statement)))
877  statement_declarations(loop_statement)=statement_declarations(transformed_stmt);
878  else {
879  list declaration_initializations = NIL;
880  FOREACH(ENTITY,e,statement_declarations(transformed_stmt))
881  {
882  value v = entity_initial(e);
883  if( value_expression_p(v) )
884  {
888  declaration_initializations=CONS(STATEMENT,s,declaration_initializations);
889  }
890  }
891  declaration_initializations=gen_nreverse(declaration_initializations);
892  instruction_block(statement_instruction(transformed_stmt))=
893  gen_nconc(declaration_initializations,instruction_block(statement_instruction(transformed_stmt)));
894  }
897  instruction_block(statement_instruction(transformed_stmt)));
898  }
899  else {
902  CONS(STATEMENT, transformed_stmt, NIL));
903  }
904  }
905 
906  /* Generate a CONTINUE to carry the final loop body label in case an
907  outer loop uses it */
908  if(!entity_empty_label_p(flbl)) {
910  ifdebug(9) {
912  pips_assert("full_loop_unroll", statement_consistent_p(stmt));
913  }
915  CONS(STATEMENT, stmt, NIL ));
916  }
917 
918  /* Generate a statement to reinitialize old index */
919  /* SG: only needed if index is not private */
920  if(entity_in_list_p(ind,loop_locals(il))) {
921  rhs_expr = int_to_expression(iter);
922  expr = make_ref_expr(ind, NIL);
923  stmt = make_assign_statement(expr, rhs_expr);
924  ifdebug(9) {
926  pips_assert("full_loop_unroll", statement_consistent_p(stmt));
927  }
929  CONS(STATEMENT, stmt, NIL ));
930  }
931 
932 
933  /* Free old instruction and replace with block */
934  /* FI: according to me, gen_copy_tree() does not create a copy sharing nothing
935  * with its actual parameter; if the free is executed, Pvecteur normalized_linear
936  * is destroyed (18 January 1993) */
937  free_instruction(statement_instruction(loop_statement));
938  statement_instruction(loop_statement) = block;
939  /* Do not forget to move forbidden information associated with
940  block: */
941  fix_sequence_statement_attributes(loop_statement);
942  clean_up_sequences(loop_statement);
943 
944  ifdebug(9) {
945  print_statement(loop_statement);
946  pips_assert("full_loop_unroll", statement_consistent_p(loop_statement));
947  }
948  /* ?? Bad condition */
949  if(get_debug_level()==7) {
950  /* Stop debug in Newgen */
952  }
953 
954  pips_debug(3, "done\n");
955 }
clone_context make_clone_context(entity a1, entity a2, list a3, statement a4)
Definition: cloning.c:52
void free_clone_context(clone_context p)
Definition: cloning.c:19
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
bool statement_consistent_p(statement p)
Definition: ri.c:2195
bool expression_consistent_p(expression p)
Definition: ri.c:859
void free_expression(expression p)
Definition: ri.c:853
void free_instruction(instruction p)
Definition: ri.c:1118
statement clone_statement(statement s, clone_context cc)
clone_statement.c
int gen_debug
Function interface for user applications.
Definition: genClib.c:69
#define GEN_DBG_CHECK
Definition: genC.h:200
void replace_entity_by_expression(void *s, entity ent, expression exp)
replace all reference to entity ent by expression exp in s.
Definition: replace.c:220
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
statement make_assign_statement(expression, expression)
Definition: statement.c:583
statement make_continue_statement(entity)
Definition: statement.c:953
statement clear_labels(statement)
Get rid of all labels in controlized code before duplication.
Definition: statement.c:1560
void fix_sequence_statement_attributes(statement)
Since blocks are not represented in Fortran, they cannot carry a label.
Definition: statement.c:2016
entity find_final_statement_label(statement)
Find the label associated with the last statement executed within s.
Definition: statement.c:4360
#define pips_user_error
Definition: misc-local.h:147
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define statement_block_p(stat)
#define instruction_block(i)
bool entity_in_list_p(entity ent, list ent_l)
look for ent in ent_l
Definition: entity.c:2221
bool entity_empty_label_p(entity e)
Definition: entity.c:666
const char * label_local_name(entity e)
END_EOLE.
Definition: entity.c:604
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
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
expression make_ref_expr(entity ent, list args)
Definition: expression.c:4316
#define loop_body(x)
Definition: ri.h:1644
#define range_upper(x)
Definition: ri.h:2290
#define loop_label(x)
Definition: ri.h:1646
#define loop_locals(x)
Definition: ri.h:1650
#define range_lower(x)
Definition: ri.h:2288
#define statement_declarations(x)
Definition: ri.h:2460
#define value_expression_p(x)
Definition: ri.h:3080
#define value_expression(x)
Definition: ri.h:3082
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define ifdebug(n)
Definition: sg.c:47
Definition: statement.c:54
struct block block

References clean_up_sequences(), clear_labels(), clone_statement(), CONS, copy_expression(), ENDP, ENTITY, entity_empty_label_p(), entity_in_list_p(), entity_initial, entity_to_expression(), entity_type, entity_undefined, expression_consistent_p(), expression_integer_value(), find_final_statement_label(), fix_sequence_statement_attributes(), FOREACH, free_clone_context(), free_expression(), free_instruction(), GEN_DBG_CHECK, gen_debug, gen_nconc(), gen_nreverse(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), get_debug_level(), ifdebug, instruction_block, instruction_loop, int_to_expression(), intptr_t, label_local_name(), loop_body, loop_index, loop_label, loop_locals, loop_range, make_assign_statement(), make_clone_context(), make_continue_statement(), make_instruction_block(), make_ref_expr(), NIL, pips_assert, pips_debug, pips_user_error, print_statement(), range_increment, range_lower, range_upper, replace_entity_by_expression(), STATEMENT, statement_block_p, statement_consistent_p(), statement_declarations, statement_instruction, value_expression, and value_expression_p.

Referenced by apply_full_loop_unroll(), find_unroll_pragma_and_fully_unroll(), full_unroll(), simd_loop_unroll(), terapixify_loops(), unroll_loops_in_statement(), and unroll_recursive().

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

◆ full_unroll()

bool full_unroll ( const  string)

user interaction

prelude

do the job

Reorder the module, because new statements have been generated.

ostlude

Reorder the module, because new statements have been generated.

Parameters
stringod_name

Definition at line 1077 of file loop_unroll.c.

1078 {
1079  statement mod_stmt = statement_undefined;
1080  const char *lp_label = string_undefined;
1081  entity lb_ent = entity_undefined;
1082  bool return_status = true;
1083 
1084  debug_on("FULL_UNROLL_DEBUG_LEVEL");
1085 
1086  /* user interaction */
1087  lp_label = get_string_property_or_ask("LOOP_LABEL","loop to fully unroll ?");
1088  if( empty_string_p(lp_label) )
1089  return_status = false;
1090  else {
1091  lb_ent = find_label_entity(mod_name,lp_label);
1092  if( entity_undefined_p(lb_ent) )
1093  pips_user_warning("loop label `%s' does not exist, unrolling all loops\n", lp_label);
1094  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
1095 
1096  /* prelude */
1098  set_current_module_statement( mod_stmt);
1099 
1100  /* do the job */
1101  if(entity_undefined_p(lb_ent)) {
1102  gen_recurse (mod_stmt, statement_domain,
1103  (bool(*)(void*))apply_full_loop_unroll, gen_null);
1104  }
1105  else {
1106  statement loop_statement = find_loop_from_label(mod_stmt,lb_ent);
1107  if( statement_undefined_p(loop_statement) )
1108  pips_user_error("label '%s' is not put on a loop\n",lp_label);
1109  else
1110  full_loop_unroll(loop_statement);
1111  }
1112 
1113  /* Reorder the module, because new statements have been generated. */
1114  module_reorder(mod_stmt);
1115 
1116  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
1117  /*postlude*/
1120  }
1121  if( !return_status)
1122  user_log("transformation has been cancelled\n");
1123  pips_debug(2,"done for %s\n", mod_name);
1124  debug_off();
1125  /* Reorder the module, because new statements have been generated. */
1126  module_reorder(mod_stmt);
1127 
1128  return return_status;
1129 }
void user_log(const char *format,...)
Definition: message.c:234
bool empty_string_p(const char *s)
Definition: entity_names.c:239
static bool apply_full_loop_unroll(struct _newgen_struct_statement_ *s)
Definition: loop_unroll.c:1064
void full_loop_unroll(statement loop_statement)
get rid of the loop by body replication;
Definition: loop_unroll.c:788
#define string_undefined
Definition: newgen_types.h:40
const char * get_string_property_or_ask(const char *, const char[])
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43
#define statement_undefined_p(x)
Definition: ri.h:2420
statement find_loop_from_label(statement, entity)
Definition: util.c:218

References apply_full_loop_unroll(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, empty_string_p(), entity_undefined, entity_undefined_p, find_label_entity(), find_loop_from_label(), full_loop_unroll(), gen_null(), gen_recurse, get_string_property_or_ask(), module_name_to_entity(), module_reorder(), pips_debug, pips_user_error, pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, statement_undefined, statement_undefined_p, string_undefined, and user_log().

+ Here is the call graph for this function:

◆ full_unroll_pragma()

bool full_unroll_pragma ( const  string)

Keep track of effects on code

Perform the loop unrollings

Perform the transformation bottom up to reduce the scanning and the number of unrollings

Reorder the module, because new statements have been generated.

Provide statistics about changes performed

Parameters
stringod_name

Definition at line 1170 of file loop_unroll.c.

1171 {
1173  set_current_module_statement( (statement) db_get_memory_resource(DBR_CODE, mod_name, true) );
1174 
1175  statement mod_stmt = statement_undefined;
1176  bool return_status = false;
1177 
1178  debug_on("FULL_UNROLL_DEBUG_LEVEL");
1179 
1180  debug(1,"full_unroll_pragma","Fully unroll loops with pragma in module %s\n",
1181  mod_name);
1182 
1183  /* Keep track of effects on code */
1186 
1187  /* Perform the loop unrollings */
1188  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
1189 
1190  // gen_recurse (mod_stmt, statement_domain,
1191  // find_unroll_pragma_and_fully_unroll, gen_null);
1192 
1193  /* Perform the transformation bottom up to reduce the scanning and the
1194  number of unrollings */
1195  gen_recurse (mod_stmt, statement_domain,
1197 
1198  /* Reorder the module, because new statements have been generated. */
1199  module_reorder(mod_stmt);
1200 
1201  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
1202 
1203  /* Provide statistics about changes performed */
1205  user_log("%d loop%s unrolled as requested\n", number_of_unrolled_loops,
1206  number_of_unrolled_loops>1?"s":"");
1207  return_status = true;
1208  }
1209  else {
1211  user_log("%d loop%s unrolled as requested\n", number_of_unrolled_loops,
1212  number_of_unrolled_loops>1?"s":"");
1213  user_log("%d loop%s could not be unrolled as requested\n", failures,
1214  failures>1?"s":"");
1215  return_status = false;
1216  }
1217 
1218  debug(1,"full_unroll_pragma","done for %s\n", mod_name);
1219  debug_off();
1220 
1223 
1224  return return_status;
1225 }
static void find_unroll_pragma_and_fully_unroll(statement s)
Definition: loop_unroll.c:1151
static int number_of_requested_unrollings
Definition: loop_unroll.c:1134
static int number_of_unrolled_loops
Definition: loop_unroll.c:1133
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug(), debug_off, debug_on, find_unroll_pragma_and_fully_unroll(), gen_recurse, gen_true(), module_name_to_entity(), module_reorder(), number_of_requested_unrollings, number_of_unrolled_loops, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, statement_undefined, and user_log().

+ Here is the call graph for this function:

◆ get_processor_number()

int get_processor_number ( void  )

Definition at line 261 of file util.c.

262 {
263  return 16;
264 }

◆ get_vector_register_length()

int get_vector_register_length ( void  )

Definition at line 266 of file util.c.

267 {
268  return 64;
269 }

◆ get_vector_register_number()

int get_vector_register_number ( void  )

Definition at line 271 of file util.c.

272 {
273  return 8;
274 }

◆ identity_elimination()

bool identity_elimination ( const char *  )

◆ identity_elimination_with_points_to()

bool identity_elimination_with_points_to ( const char *  )

◆ index_set_splitting()

bool index_set_splitting ( const  string)

index_set_splitting.c

Parameters
stringodule_name

◆ induction_substitution()

bool induction_substitution ( const  string)

induction_substitution.c

Parameters
stringodule_name

◆ initialize_vla_with_effects()

bool initialize_vla_with_effects ( const char *  )

◆ initialize_vla_with_preconditions()

bool initialize_vla_with_preconditions ( const char *  )

◆ initialize_vla_with_regions()

bool initialize_vla_with_regions ( const char *  )

◆ interactive_loop_transformation()

bool interactive_loop_transformation ( const char *  module_name,
statement(*)(list, bool(*)(statement))  loop_transformation 
)

DBR_CODE will be changed: argument "pure" should take false but this would be useless since there is only one version of code; a new version will be put back in the data base after transforming the loops

Get the loop label from the user

Reorder the module, because new statements have been generated.

Parameters
module_nameodule_name

Definition at line 73 of file interactive_loop_transformation.c.

77 {
78  const char *lp_label=NULL;
81  bool return_status = false;
82 
83  pips_assert("interactive_loop_transformation", entity_module_p(module));
84 
85  /* DBR_CODE will be changed: argument "pure" should take false but
86  this would be useless since there is only *one* version of code;
87  a new version will be put back in the data base after transforming
88  the loops */
89  s = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
92 
93  /* Get the loop label from the user */
94  lp_label = get_string_property_or_ask("LOOP_LABEL","Which loop do you want to transform?\n"
95  "(give its label): ");
96  if( string_undefined_p( lp_label ) )
97  {
98  pips_user_error("please set %s property to a valid label\n","LOOP_LABEL");
99  }
100 
101  if(lp_label)
102  {
105  pips_user_error("loop label `%s' does not exist\n", lp_label);
106  }
107 
108  debug_on("INTERACTIVE_LOOP_TRANSFORMATION_DEBUG_LEVEL");
109 
110  look_for_nested_loop_statements(s, loop_transformation, selected_loop_p);
111 
112  debug_off();
113 
114  /* Reorder the module, because new statements have been generated. */
115  module_reorder(s);
116 
117  DB_PUT_MEMORY_RESOURCE(DBR_CODE,
119  (char*) s);
120  return_status = true;
121  }
124 
125  return return_status;
126 }
void look_for_nested_loop_statements(statement, statement(*)(list, bool(*)(statement)), bool(*)(statement))
look_for_nested_loops.c
entity selected_label
Interface with pipsmake for interactive loop transformations: loop interchange, hyperplane method,...
bool selected_loop_p(statement s)
#define string_undefined_p(s)
Definition: newgen_types.h:41
bool entity_module_p(entity e)
Definition: entity.c:683

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_module_p(), entity_undefined_p, find_label_entity(), get_string_property_or_ask(), look_for_nested_loop_statements(), module, module_name(), module_name_to_entity(), module_reorder(), pips_assert, pips_user_error, reset_current_module_entity(), reset_current_module_statement(), selected_label, selected_loop_p(), set_current_module_entity(), set_current_module_statement(), statement_undefined, strdup(), and string_undefined_p.

Referenced by loop_hyperplane(), loop_tiling(), and parallel_loop_tiling().

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

◆ interchange_inner_outermost_loops()

statement interchange_inner_outermost_loops ( list  ,
bool(*)(statement  
)

◆ interchange_two_loops()

statement interchange_two_loops ( list  ,
int  ,
int   
)

◆ internalize_parallel_code()

bool internalize_parallel_code ( const  string)

internalize_parallel_code.c

Parameters
stringod_name

◆ limit_nested_parallelism()

bool limit_nested_parallelism ( const  string)

manage_parallel_loops.c

Parameters
stringodule_name

◆ limit_parallelism_using_complexity()

bool limit_parallelism_using_complexity ( const  string)
Parameters
stringodule_name

◆ linearize_loop_range()

bool linearize_loop_range ( const char *  )

◆ localize_declaration()

bool localize_declaration ( const  string)
Parameters
stringod_name

◆ loop_bound_minimization_with_out_regions()

bool loop_bound_minimization_with_out_regions ( const char *  )

◆ loop_bound_minimization_with_out_regions_on_statement()

bool loop_bound_minimization_with_out_regions_on_statement ( statement  )

◆ loop_fully_unrollable_p()

bool loop_fully_unrollable_p ( loop  l)

Definition at line 753 of file loop_unroll.c.

754 {
755  bool unroll_p = false;
756  range lr = loop_range(l);
757  expression lb = range_lower(lr);
758  expression ub = range_upper(lr);
759  expression inc = range_increment(lr);
760  intptr_t lbval, ubval, incval;
761 
762  pips_debug(2, "begin\n");
763 
764  unroll_p = expression_integer_value(lb, &lbval)
765  && expression_integer_value(ub, &ubval)
766  && expression_integer_value(inc, &incval);
767 
768  if(unroll_p) {
769  const char* s = get_string_property("FULL_LOOP_UNROLL_EXCEPTIONS");
770  if(*s!=0) {
772  list exceptions = string_to_user_modules(s);
773  list p = arguments_intersection(callees, exceptions);
774  unroll_p = ENDP(p);
775  gen_free_list(p);
776  }
777  }
778 
779  return unroll_p;
780 }
list arguments_intersection(list a1, list a2)
Build a new list with all entities occuring in both a1 and a2.
Definition: arguments.c:158
char * get_string_property(const char *)
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
list statement_to_called_user_entities(statement)
Get a list of all user function called recursively within a statement:
Definition: statement.c:3478
list string_to_user_modules(const char *s)
Build a list of functions from a string s containing SPACE separated function names.
Definition: module.c:562

References arguments_intersection(), ENDP, expression_integer_value(), gen_free_list(), get_string_property(), intptr_t, loop_body, loop_range, pips_debug, range_increment, range_lower, range_upper, statement_to_called_user_entities(), and string_to_user_modules().

Referenced by unroll_loops_in_statement().

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

◆ loop_fusion()

bool loop_fusion ( char *  )

◆ loop_fusion_with_regions()

bool loop_fusion_with_regions ( char *  )

◆ loop_interchange()

bool loop_interchange ( const  string)
Parameters
stringodule_name

◆ loop_normalize()

bool loop_normalize ( const  string)
Parameters
stringod_name

◆ loop_normalize_statement()

void loop_normalize_statement ( statement  )

loop_normalize.c

Referenced by simd_loop_unroll().

+ Here is the caller graph for this function:

◆ loop_pragma()

char* loop_pragma ( const char *  module_name,
const char *  parent_loop 
)
Parameters
module_nameodule_name
parent_looparent_loop

Definition at line 225 of file interactive_loop_transformation.c.

226 {
227  // ensure pipsmake is ok with what we ask for
228  safe_make(DBR_LOOPS,module_name);
229 
230  // prelude
233  ((statement) db_get_memory_resource(DBR_CODE, module_name, true) );
234 
235  entity label = find_label_entity(module_name,parent_loop);
236  if(entity_undefined_p(label))
237  pips_user_error("label '%s' does not exist\n",parent_loop);
240  pips_user_error("label '%s' is not on a loop\n",parent_loop);
242  if(string_undefined_p(s)) s = strdup("");
245  return s;
246 }
bool safe_make(const char *res_n, const char *module_n)
Definition: pipsmake.c:1717
string extensions_to_string(extensions es, bool nl)
return a new allocated string with the string representation of the extensions.
Definition: extension.c:111
#define statement_extensions(x)
Definition: ri.h:2464

References db_get_memory_resource(), entity_undefined_p, extensions_to_string(), find_label_entity(), find_loop_from_label(), get_current_module_statement(), module_name(), module_name_to_entity(), pips_user_error, reset_current_module_entity(), reset_current_module_statement(), safe_make(), set_current_module_entity(), set_current_module_statement(), statement_extensions, statement_undefined_p, strdup(), and string_undefined_p.

+ Here is the call graph for this function:

◆ loop_strip_mine()

statement loop_strip_mine ( statement  loop_statement,
int  chunk_size,
int  chunk_number 
)

strip_mine.c

strip_mine.c

Sharing is (theoretically) avoided when the AST is built

Assumption:

  • a loop body can be a loop (no need for a block with one statement, a loop)

compute the expression for the chunk size

make sure that the outer loop does not use a continue that will end up in the inner loop body

derive a new loop index (FI: only one name :-(

build the inner loop preserving the initial index set

update the outer loop

Parameters
loop_statementoop_statement
chunk_sizehunk_size
chunk_numberhunk_number

Definition at line 64 of file strip_mine.c.

66 {
67  loop l = instruction_loop(statement_instruction(loop_statement));
68  loop new_l = loop_undefined;
74  entity index = loop_index(l);
75  statement b = loop_body(l);
76  entity new_index = entity_undefined;
77 
78  debug(9, "loop_strip_mine", "begin: chunk_size = %d,chunk_number = %d\n",
79  chunk_size, chunk_number);
80  pips_assert("loop_strip_mine", ( chunk_size > 1 && chunk_number == -1 )
81  ||
82  (chunk_size == -1 && chunk_number > 1) );
83 
84  if(loop_increment_value(l) != 1)
85  user_error("loop_strip_mine",
86  "Loop increment has to be one for strip-mining!\n");
87 
88  if(get_debug_level()>=9) {
89  print_statement(loop_statement);
90  pips_assert("loop_strip_mine", statement_consistent_p(loop_statement));
91  }
92 
93  /* compute the expression for the chunk size */
94  if(chunk_size==-1) {
95  expression e_number = int_to_expression(chunk_number);
96 
98  size = make_op_exp(PLUS_OPERATOR_NAME, size, copy_expression(e_number));
99  size = make_op_exp(DIVIDE_OPERATOR_NAME, size, e_number);
101  }
102  else {
103  size = int_to_expression(chunk_size);
104  sizem1 = int_to_expression(chunk_size-1);
105  }
106  ifdebug(9) {
107  pips_debug(8, "size = ");
108  print_expression(size);
109  pips_debug(8, "sizem1 = ");
110  print_expression(sizem1);
111  }
112 
113  /* make sure that the outer loop does not use a continue that will
114  end up in the inner loop body */
116 
117  /* derive a new loop index (FI: only *one* name :-( */
118  new_index = make_new_index_entity(index, "_1");
120 
121  /* build the inner loop preserving the initial index set */
122  expression fst_min_param=MakeBinaryCall(entity_intrinsic("+"),entity_to_expression(new_index),sizem1);
123  expression snd_min_parameter=copy_expression(ub);
124  expression min_exp =
125  MakeBinaryCall(entity_intrinsic(MIN_OPERATOR_NAME),fst_min_param,snd_min_parameter);
126  new_l = make_loop(index,
127  make_range(entity_to_expression(new_index),
128  min_exp,
129  int_to_expression(1)),
130  b,
135  NIL);
136 
138 
139  ifdebug(8) {
140  pips_debug(8, "new inner loop:");
141  print_statement(new_s);
142  pips_assert("loop_strip_mine", statement_consistent_p(new_s));
143  }
144 
145  /* update the outer loop */
146  loop_index(l) = new_index;
148  loop_body(l) = new_s;
149 
150  ifdebug(8) {
151  print_statement(loop_statement);
152  pips_assert("loop_statement consistent_p", statement_consistent_p(loop_statement));
153  }
154 
155  pips_debug(8, "end\n");
156  return(loop_statement);
157 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
int loop_increment_value(loop l)
Definition: loop.c:714
#define user_error(fn,...)
Definition: misc-local.h:265
#define UU
Definition: newgen_types.h:98
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define DIVIDE_OPERATOR_NAME
#define MIN_OPERATOR_NAME
entity entity_empty_label(void)
Definition: entity.c:1105
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
entity make_new_index_entity(entity, string)
Definition: variable.c:1851
#define loop_execution(x)
Definition: ri.h:1648
#define loop_undefined
Definition: ri.h:1612
#define expression_undefined
Definition: ri.h:1223
@ is_instruction_loop
Definition: ri.h:1471
#define execution_sequential_p(x)
Definition: ri.h:1208
@ is_execution_parallel
Definition: ri.h:1190
@ is_execution_sequential
Definition: ri.h:1189

References AddEntityToDeclarations(), copy_expression(), debug(), DIVIDE_OPERATOR_NAME, entity_empty_label(), entity_intrinsic(), entity_to_expression(), entity_undefined, execution_sequential_p, expression_undefined, get_current_module_entity(), get_debug_level(), ifdebug, instruction_loop, instruction_to_statement(), int_to_expression(), is_execution_parallel, is_execution_sequential, is_instruction_loop, loop_body, loop_execution, loop_increment_value(), loop_index, loop_label, loop_range, loop_undefined, make_execution(), make_instruction(), make_loop(), make_new_index_entity(), make_op_exp(), make_range(), MakeBinaryCall(), MIN_OPERATOR_NAME, MINUS_OPERATOR_NAME, NIL, pips_assert, pips_debug, PLUS_OPERATOR_NAME, print_expression(), print_statement(), range_increment, range_lower, range_upper, statement_consistent_p(), statement_instruction, statement_undefined, user_error, and UU.

Referenced by do_kernelize(), and loop_chunk_size_and_strip_mine().

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

◆ loop_unroll()

void loop_unroll ( statement  loop_statement,
int  rate 
)

fallbacks on do_loop_unroll without statement post processing

Parameters
loop_statementoop_statement
rateate

Definition at line 748 of file loop_unroll.c.

749 {
750  do_loop_unroll(loop_statement, rate, NULL);
751 }
void do_loop_unroll(statement loop_statement, int rate, void(*statement_post_processor)(statement))
loop_unroll.c
Definition: loop_unroll.c:714

References do_loop_unroll().

Referenced by unroll().

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

◆ module_clean_declarations()

void module_clean_declarations ( entity  module,
statement  module_statement 
)

declarations.c

Parameters
moduleodule
module_statementodule_statement

Definition at line 140 of file declarations.c.

140  {
142 
144 }
static statement module_statement
Definition: alias_check.c:125
void statement_clean_declarations(statement)
cproto-generated files
Definition: util.c:164
void entity_clean_declarations(entity, statement)
remove all entities declared in module but never used in s
Definition: util.c:177

References entity_clean_declarations(), gen_recurse, gen_true(), module, module_statement, statement_clean_declarations(), and statement_domain.

Referenced by clean_declarations(), and do_scalar_renaming().

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

◆ module_loops()

char* module_loops ( const char *  module_name,
const char *  parent_loop 
)

gather the list of enclosing loops expect flag_loops has been called before

Parameters
module_namemodule we want the loops of
parent_loopnull if we wat to gather outer loops, a loop_label if we want to gather enclosed loops
Returns
list of strings, one string per loop label

this function is needed by pyps?

Parameters
module_nameodule_name
parent_looparent_loop

Definition at line 259 of file interactive_loop_transformation.c.

260 {
261  // ensure pipsmake is ok with what we ask for
262  safe_make(DBR_LOOPS,module_name);
263 
264  // prelude
267  ((statement) db_get_memory_resource(DBR_CODE, module_name, true) );
268  list loops = NIL;
269 
271  if(empty_string_p(parent_loop))
273  else {
274  entity label = find_label_entity(module_name,parent_loop);
275  if(entity_undefined_p(label))
276  pips_user_error("label '%s' does not exist\n",parent_loop);
279  pips_user_error("label '%s' is not on a loop\n",parent_loop);
281  }
282 
283  // run loop gatherer
284  gen_context_recurse(seed, &loops,
287 
288  // postlude
291  string out = list_to_string(loops);
293  if(out) out[strlen(out)-1]=0;
294  return out;
295 }
static FILE * out
Definition: alias_check.c:128
string list_to_string(list l)
Return the malloc()ed version of the concatenation of all the strings in the list.
Definition: args.c:74
static list loops
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
static bool module_loops_walker(statement s, list *l)

References db_get_memory_resource(), empty_string_p(), entity_undefined_p, find_label_entity(), find_loop_from_label(), gen_context_recurse, gen_free_list(), gen_nreverse(), gen_null2(), get_current_module_statement(), list_to_string(), loop_body, loops, module_loops_walker(), module_name(), module_name_to_entity(), NIL, out, pips_user_error, reset_current_module_entity(), reset_current_module_statement(), safe_make(), set_current_module_entity(), set_current_module_statement(), statement_domain, statement_loop(), statement_undefined, and statement_undefined_p.

+ Here is the call graph for this function:

◆ nest_parallelization()

bool nest_parallelization ( const char *  )

◆ partial_redundancy_elimination()

bool partial_redundancy_elimination ( const  string)

partial_redundancy_elimination.c

Parameters
stringodule_name

◆ print_c_code()

bool print_c_code ( const char *  module_name)

C indentation thru indent.

Parameters
module_nameodule_name

Definition at line 2262 of file cprettyprinter.c.

2263 {
2264  string crough, cpretty, dir, cmd;
2265 
2266  crough = db_get_memory_resource(DBR_CROUGH, module_name, true);
2267  cpretty = db_build_file_resource_name(DBR_C_PRINTED_FILE, module_name, CPRETTY);
2269 
2270  cmd = strdup(concatenate(INDENT, " ",
2271  dir, "/", crough, " -st > ",
2272  dir, "/", cpretty, NULL));
2273 
2274  safe_system(cmd);
2275 
2276  DB_PUT_FILE_RESOURCE(DBR_C_PRINTED_FILE, module_name, cpretty);
2277  free(cmd);
2278  free(dir);
2279 
2280  return true;
2281 }
#define CPRETTY
#define INDENT
void free(void *)
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
void safe_system(string)
system.c
Definition: system.c:38
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
string db_get_current_workspace_directory(void)
Definition: workspace.c:96

References concatenate(), CPRETTY, db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, free(), INDENT, module_name(), safe_system(), and strdup().

+ Here is the call graph for this function:

◆ print_code_privatized_regions()

bool print_code_privatized_regions ( const  string)
Parameters
stringodule_name

◆ print_crough()

bool print_crough ( const char *  module_name)

save to file

Parameters
module_nameodule_name

Definition at line 2194 of file cprettyprinter.c.

2195 {
2196  FILE * out;
2197  string ppt, crough, dir, filename;
2198  entity module;
2199  statement stat;
2200  list l_effect = NULL;
2201 
2202  // get what is needed from PIPS DBM
2203  crough = db_build_file_resource_name(DBR_CROUGH, module_name, CROUGH);
2206  filename = strdup(concatenate(dir, "/", crough, NULL));
2207  stat = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
2208  l_effect = effects_to_list((effects)
2209  db_get_memory_resource(DBR_SUMMARY_EFFECTS,
2210  module_name, true));
2213 
2214  debug_on("CPRETTYPRINTER_DEBUG_LEVEL");
2215  pips_debug(1, "Begin C prettyprrinter for %s\n", entity_name(module));
2216 
2217  // init the list needed for the function pre and postlude
2218  l_type = NIL;
2219  l_name = NIL;
2220  l_rename = NIL;
2221  l_entity = NIL;
2222  l_written = NIL;
2223  // build the list of written entity
2224  build_written_list (l_effect);
2225 
2226  // get the c code as a string
2227  ppt = c_code_string(module, stat);
2228  pips_debug(1, "end\n");
2229  debug_off();
2230 
2231  /* save to file */
2232  out = safe_fopen(filename, "w");
2233  fprintf(out, "/* C pretty print for module %s. */\n", module_name);
2234  fprintf(out, "%s", ppt);
2235  safe_fclose(out, filename);
2236 
2237  // free and reset strin lists
2243  l_type = NIL;
2244  l_name = NIL;
2245  l_rename = NIL;
2246  l_entity = NIL;
2247  l_written = NIL;
2248  free(ppt);
2249  free(dir);
2250  free(filename);
2251 
2252  DB_PUT_FILE_RESOURCE(DBR_CROUGH, module_name, crough);
2253 
2256 
2257  return true;
2258 }
static void build_written_list(list l)
#define CROUGH
static list l_type
static string c_code_string(entity module, statement stat)
static list l_written
static list l_rename
static list l_entity
static list l_name
list effects_to_list(effects)
Definition: effects.c:209
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
void gen_free_string_list(list ls)
Definition: list.c:564
#define entity_name(x)
Definition: ri.h:2790
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References build_written_list(), c_code_string(), concatenate(), CROUGH, db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, debug_off, debug_on, effects_to_list(), entity_name, fprintf(), free(), gen_free_list(), gen_free_string_list(), l_entity, l_name, l_rename, l_type, l_written, module, module_name(), module_name_to_entity(), NIL, out, pips_debug, reset_current_module_entity(), reset_current_module_statement(), safe_fclose(), safe_fopen(), set_current_module_entity(), set_current_module_statement(), and strdup().

+ Here is the call graph for this function:

◆ print_interface()

bool print_interface ( const char *  module_name)

cprettyprinter.c

save to file

Parameters
module_nameodule_name

Definition at line 2151 of file cprettyprinter.c.

2152 {
2153  FILE * out;
2154  string interface_code, interface, dir, filename;
2155  entity module;
2156  statement stat;
2157 
2158  // get what is needed from PIPS DBM
2159  interface = db_build_file_resource_name(DBR_INTERFACE, module_name, INTERFACE);
2162  filename = strdup(concatenate(dir, "/", interface, NULL));
2163  stat = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
2164 
2167 
2168  debug_on("INTERFACE_DEBUG_LEVEL");
2169  pips_debug(1, "Begin print_interface for %s\n", entity_name(module));
2170 
2171  // get the inteface code as a string
2172  interface_code = interface_code_string(module, stat);
2173  pips_debug(1, "end\n");
2174  debug_off();
2175 
2176  /* save to file */
2177  out = safe_fopen(filename, "w");
2178  fprintf(out, "! Fortran interface module for %s. \n", module_name);
2179  fprintf(out, "%s", interface_code);
2180  safe_fclose(out, filename);
2181 
2182  DB_PUT_FILE_RESOURCE(DBR_INTERFACE, module_name, INTERFACE);
2183 
2186 
2187  free (interface_code);
2188  free (dir);
2189  free (filename);
2190 
2191  return true;
2192 }
static string interface_code_string(entity module, _UNUSED_ statement stat)
#define INTERFACE

References concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, debug_off, debug_on, entity_name, fprintf(), free(), INTERFACE, interface_code_string(), module, module_name(), module_name_to_entity(), out, pips_debug, reset_current_module_entity(), reset_current_module_statement(), safe_fclose(), safe_fopen(), set_current_module_entity(), set_current_module_statement(), and strdup().

+ Here is the call graph for this function:

◆ print_loops()

bool print_loops ( const  string)

prelude

do the job

ostlude

Parameters
stringodule_name

Definition at line 152 of file interactive_loop_transformation.c.

153 {
154  /* prelude */
158 
159  /* do the job */
160  {
161  string local = db_build_file_resource_name(DBR_LOOPS_FILE, module_name, ".loops");
162  string dir = db_get_current_workspace_directory();
163  string full = strdup(concatenate(dir,"/",local, NULL));
164  free(dir);
165  FILE * fp = safe_fopen(full,"w");
166  text r = make_text(NIL);
168  {
170  }
171  print_text(fp,r);
172  free_text(r);
173  safe_fclose(fp,full);
174  free(full);
175  DB_PUT_FILE_RESOURCE(DBR_LOOPS_FILE, module_name, local);
176  }
177 
178  /*postlude*/
181  return true;
182 }
text make_text(list a)
Definition: text.c:107
void free_text(text p)
Definition: text.c:74
#define STRING(x)
Definition: genC.h:87
struct _newgen_struct_callees_ * callees
Definition: ri.h:55
#define callees_callees(x)
Definition: ri.h:675
#define MAKE_ONE_WORD_SENTENCE(m, s)
#define ADD_SENTENCE_TO_TEXT(t, p)
void print_text(FILE *fd, text t)
Definition: print.c:195
@ full
Definition: union-local.h:65

References ADD_SENTENCE_TO_TEXT, callees_callees, concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, FOREACH, free(), free_text(), full, loops, MAKE_ONE_WORD_SENTENCE, make_text(), module_name(), module_name_to_entity(), NIL, print_text(), reset_current_module_entity(), reset_current_module_statement(), safe_fclose(), safe_fopen(), set_current_module_entity(), set_current_module_statement(), strdup(), and STRING.

+ Here is the call graph for this function:

◆ print_parallelizedcray_code()

bool print_parallelizedcray_code ( char *  )

◆ privatize_module()

bool privatize_module ( const  string)

privatize.c

Parameters
stringod_name

◆ privatize_module_even_globals()

bool privatize_module_even_globals ( const  string)
Parameters
stringod_name

◆ quick_scalarization()

bool quick_scalarization ( const  string)
Parameters
stringodule_name

◆ recover_for_loop()

bool recover_for_loop ( const  string)

for_loop_recovering.c

Parameters
stringodule_name

◆ reduction_variable_expansion()

bool reduction_variable_expansion ( const char *  )

◆ remove_useless_label()

bool remove_useless_label ( const  string)
Parameters
stringodule_name

Referenced by do_unfolding().

+ Here is the caller graph for this function:

◆ scalarization()

bool scalarization ( const  string)

scalarization.c

Parameters
stringodule_name

◆ selected_loop_p()

bool selected_loop_p ( statement  s)

SG+EC 2010: The loop_label(statement_loop(s)) is kept for compatibility reasons but is invalid and should eventually be removed

Definition at line 63 of file interactive_loop_transformation.c.

64 {
65  /* SG+EC 2010:
66  The loop_label(statement_loop(s)) is kept for compatibility reasons
67  but is invalid and should eventually be removed */
68  return statement_loop_p(s) &&
71 }
bool statement_loop_p(statement)
Definition: statement.c:349
#define statement_label(x)
Definition: ri.h:2450

References loop_label, selected_label, statement_label, statement_loop(), and statement_loop_p().

Referenced by interactive_loop_transformation(), and strip_mine().

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

◆ set_return_type_as_typedef()

bool set_return_type_as_typedef ( const  string)

set_return_type.c

Parameters
stringod_name

◆ simplify_control()

bool simplify_control ( const  string)

simplify_control.c

Parameters
stringod_name

◆ simplify_control_directly()

bool simplify_control_directly ( const  string)
Parameters
stringod_name

◆ split_initializations()

bool split_initializations ( const char *  module_name)

Pipsmake 'split_initializations' phase.

Save modified code to database

Parameters
module_nameodule_name

Definition at line 742 of file flatten_code.c.

743 {
744  statement module_stat;
745  bool good_result_p = true;
746 
749  db_get_memory_resource(DBR_CODE, module_name, true) );
750  module_stat = get_current_module_statement();
751 
752  debug_on("SPLIT_INITIALIZATIONS_DEBUG_LEVEL");
753  pips_debug(1, "begin\n");
754 
755  // Do split !
756  statement_split_initializations(module_stat);
757 
758  pips_debug(1, "end\n");
759  debug_off();
760 
761  /* Save modified code to database */
762  module_reorder(module_stat);
763  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(module_name), module_stat);
764 
767 
768  return (good_result_p);
769 }
void statement_split_initializations(statement s)
Recurse through the statements of s and split local declarations.
Definition: flatten_code.c:733

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_split_initializations(), and strdup().

+ Here is the call graph for this function:

◆ split_update_call()

void split_update_call ( call  c)

Definition at line 772 of file flatten_code.c.

773 {
774  entity op = call_function(c);
775  list args = call_arguments(c);
777  if(!entity_undefined_p(new_op))
778  {
779  if(ENTITY_PLUS_C_P(new_op)||ENTITY_MINUS_C_P(new_op))
780  {
781  bool has_pointer =false;
783  {
785  if(basic_pointer_p(b)) { has_pointer=true;}
786  free_basic(b);
787  }
788  if(!has_pointer) {
791  }
792  }
793  ifdebug(1){
795  pips_debug(1,"changed expression \n");
796  print_expression(tmp);
798  free_expression(tmp);
799  }
800 
802  expression lhs = binary_call_lhs(c);
803  expression rhs = binary_call_rhs(c);
804  CAR(CDR(args)).p=(gen_chunkp)MakeBinaryCall(
805  new_op,
806  copy_expression(lhs),
807  rhs);
808 
809  ifdebug(1){
811  pips_debug(1,"into expression \n");
812  print_expression(tmp);
814  free_expression(tmp);
815  }
816  }
817 }
void free_basic(basic p)
Definition: ri.c:107
union gen_chunk * gen_chunkp
#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 binary_call_rhs(c)
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MINUS_C_P(e)
#define binary_call_lhs(c)
#define ASSIGN_OPERATOR_NAME
Definition: ri-util-local.h:95
entity update_operator_to_regular_operator(entity op)
Returns the binary operator associated to a C update operator such as +=.
Definition: entity.c:2154
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Definition: type.c:1383
#define call_function(x)
Definition: ri.h:709
#define basic_pointer_p(x)
Definition: ri.h:635
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define syntax_call(x)
Definition: ri.h:2736
#define call_arguments(x)
Definition: ri.h:711
#define call_undefined
Definition: ri.h:685
#define expression_syntax(x)
Definition: ri.h:1247
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References ASSIGN_OPERATOR_NAME, basic_of_expression(), basic_pointer_p, binary_call_lhs, binary_call_rhs, call_arguments, call_function, call_to_expression(), call_undefined, CAR, CDR, copy_expression(), entity_intrinsic(), ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, entity_undefined_p, exp, EXPRESSION, expression_syntax, FOREACH, free_basic(), free_expression(), ifdebug, MakeBinaryCall(), MINUS_OPERATOR_NAME, pips_debug, PLUS_OPERATOR_NAME, print_expression(), syntax_call, and update_operator_to_regular_operator().

Referenced by check_if_conv_call(), simd_supported_stat_p(), split_update_operator(), and split_update_operator_statement_walker().

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

◆ split_update_operator()

bool split_update_operator ( const char *  module_name)

Save modified code to database

Parameters
module_nameodule_name

Definition at line 834 of file flatten_code.c.

835 {
838  debug_on("SPLIT_UPDATE_OPERATOR_DEBUG_LEVEL");
839  pips_debug(1, "begin\n");
840 
844  NULL);
845 
846  pips_debug(1, "end\n");
847  debug_off();
848 
849  /* Save modified code to database */
851 
854  return true;
855 }
static void split_update_operator_statement_walker(statement s)
Definition: flatten_code.c:820
void split_update_call(call c)
Definition: flatten_code.c:772
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58

References call_domain, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_multi_recurse(), gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), split_update_call(), split_update_operator_statement_walker(), and statement_domain.

+ Here is the call graph for this function:

◆ statement_clean_declarations()

void statement_clean_declarations ( statement  s)

cproto-generated files

util.c

cproto-generated files

Parameters
sstatement to check

Definition at line 164 of file util.c.

165 {
166  if(statement_block_p(s)) {
168  }
169 }

References statement_block_p, statement_clean_declarations_helper(), and statement_declarations.

Referenced by module_clean_declarations().

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

◆ statement_flatten_declarations()

bool statement_flatten_declarations ( entity  module,
statement  s 
)

flatten_code.c

For the time being, we handle only blocks with declarations

Can we find out what the local scope of statement s is?

FI: Shouldn't it be "0`"?

current scope for se

Parameters
moduleodule

Definition at line 509 of file flatten_code.c.

510 {
511  /* For the time being, we handle only blocks with declarations */
512  if (statement_block_p(s)) {
514  // Recursive
516  bool renaming_p = false;
517  string cs = string_undefined;
518  int csl = INT_MAX;
519 
520  /* Can we find out what the local scope of statement s is? */
521  /* FI: Shouldn't it be "0`"? */
522  const char* cmn = entity_user_name(module);
524  string sen = entity_name(se);
525  const char* seln = entity_local_name(se);
526  string cs_se = local_name_to_scope(seln); /* current scope for se */
527  const char* mn = module_name(sen);
528 
529  if(same_string_p(mn, cmn)) {
530  renaming_p = true;
531  int cs_se_l = strlen(cs_se);
532  if(cs_se_l>0 && cs_se_l<csl) {
533  csl = cs_se_l;
534  cs = cs_se;
535  }
536  else {
537  free(cs_se);
538  }
539  }
540  else {
541  free(cs_se);
542  }
543  }
544  if (renaming_p) {
545  compute_renamings(s, cs, cmn, renamings);
546  // FC: 2014-12-20 kludge to avoid a coredump
547  if (cs != string_undefined) {
548  free(cs);
549  cs = string_undefined;
550  }
551  }
552 
553  if(renaming_p) {
554  ifdebug(1)
555  hash_table_fprintf(stderr,
556  // The warning will disappear when Fabien
557  // updates Newgen
558  //(char * (*)(void *)) entity_local_name,
559  //(char * (*)(void *)) entity_local_name,
562  renamings);
563 
564  //char *(*key_to_string)(void*),
565  //char *(*value_to_string)(void*),
566 
568  statement_instruction(s), renamings,
572  NULL);
573 
574  // This look like a bad hack, partially redundant with previous
575  // replacement but... only partially ! For instance extensions was not
576  // handled previously.
577  // Probably that there's need for factoring, but it'll be another time !
578  replace_entities(s,renamings);
579 
580  gen_free_list(declarations), declarations = NIL;
581  hash_table_free(renamings), renamings = NULL;
582  }
583  else {
584  pips_debug(2,"Code flattening fails because the statement does"
585  " not contain any local declaration\n");
586  }
587  }
588  return true;
589 }
static void rename_loop_index(loop l, hash_table renamings)
gen_multi_recurse callback on exiting a loop: if loop index needs renaming, rename this occurrence.
Definition: flatten_code.c:90
static void rename_statement_declarations(statement s, hash_table renamings)
gen_multi_recurse callback on exiting a statement: recompute the declaration list for statement s and...
Definition: flatten_code.c:137
static void compute_renamings(statement s, const char *sc, const char *mn, hash_table renamings)
FI: added to wrap up the use of redeclaration context...
Definition: flatten_code.c:461
static void rename_reference(reference r, hash_table renamings)
Flatten code.
Definition: flatten_code.c:55
void replace_entities(void *s, hash_table ht)
Recursively substitute a set of entities in a statement.
Definition: replace.c:91
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
list instruction_to_declarations(instruction)
Get a list of all variables declared recursively within an instruction.
Definition: statement.c:3279
void hash_table_fprintf(FILE *f, gen_string_func_t key_to_string, gen_string_func_t value_to_string, const hash_table htp)
This function prints the content of the hash_table pointed to by htp on file descriptor f,...
Definition: hash.c:548
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
@ hash_pointer
Definition: newgen_hash.h:32
#define HASH_DEFAULT_SIZE
Definition: newgen_hash.h:26
#define same_string_p(s1, s2)
string(* gen_string_func_t)(const void *)
Definition: newgen_types.h:111
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
else
Definition: set.c:239

References compute_renamings(), ENTITY, entity_declarations, entity_local_name(), entity_name, entity_user_name(), FOREACH, free(), gen_context_multi_recurse(), gen_free_list(), gen_true(), HASH_DEFAULT_SIZE, hash_pointer, hash_table_fprintf(), hash_table_free(), hash_table_make(), ifdebug, instruction_to_declarations(), local_name_to_scope(), loop_domain, module, module_name(), NIL, pips_debug, reference_domain, rename_loop_index(), rename_reference(), rename_statement_declarations(), replace_entities(), same_string_p, statement_block_p, statement_domain, statement_instruction, and string_undefined.

Referenced by delay_communications(), delay_load_communications(), delay_store_communications(), and flatten_code().

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

◆ statement_split_initializations()

void statement_split_initializations ( statement  s)

Recurse through the statements of s and split local declarations.

For the time being, we handle only blocks with declarations.

NOTE: Statement s is modified in-place.

This function can be called from another module to apply transformation directly.

Is it still useful?

Definition at line 733 of file flatten_code.c.

734 {
736  /* Is it still useful? */
738 }
void split_initializations_in_statement(statement s)
Transform a declaration with an initialization statement into 2 parts, a declaration statement and an...
Definition: declarations.c:437

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

Referenced by process_true_stat(), promote_local_entities(), and split_initializations().

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

◆ stf()

◆ strength_reduction()

bool strength_reduction ( const  string)

strength_reduction.c

Parameters
stringodule_name

◆ strip_mine()

bool strip_mine ( const  string)

Top-level function.

Get the loop label form the user

DBR_CODE will be changed: argument "pure" should take false but this would be useless since there is only one version of code; a new version will be put back in the data base after strip_mineing

Reorder the module, because new statements have been generated.

Parameters
stringod_name

Definition at line 233 of file strip_mine.c.

234 {
235  entity module = module_name_to_entity(mod_name);
236  statement mod_stmt;
237  const char *lp_label=NULL;
238  bool return_status;
239 
240  debug_on("STRIP_MINE_DEBUG_LEVEL");
241 
242  /* Get the loop label form the user */
243  lp_label=get_string_property_or_ask("LOOP_LABEL","Which loop do you want to strip_mine?\n" "(give its label): ");
244  if (lp_label[0] == '\0') {
245  user_log("Strip mining has been cancelled.\n");
246  return_status = false;
247  }
248  else {
249  selected_label = find_label_entity(mod_name, lp_label);
251  user_error("strip_mine", "loop label `%s' does not exist\n", lp_label);
252  }
253 
255 
256  /* DBR_CODE will be changed: argument "pure" should take false but
257  this would be useless since there is only *one* version of code;
258  a new version will be put back in the data base after
259  strip_mineing */
260  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
262 
264 
265  /* Reorder the module, because new statements have been generated. */
266  module_reorder(mod_stmt);
267 
270 
271  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
272  return_status = true;
273  }
274 
275  debug(2,"strip_mine","done for %s\n", mod_name);
276  debug_off();
277 
278  return return_status;
279 }
entity selected_label
Interface with pipsmake for interactive loop transformations: loop interchange, hyperplane method,...
static statement loop_chunk_size_and_strip_mine(list lls, __attribute__((unused)) bool(*unused)(statement))
Hmmm...
Definition: strip_mine.c:165

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug(), debug_off, debug_on, entity_undefined_p, find_label_entity(), get_string_property_or_ask(), look_for_nested_loop_statements(), loop_chunk_size_and_strip_mine(), module, module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), selected_label, selected_loop_p(), set_current_module_entity(), set_current_module_statement(), user_error, and user_log().

+ Here is the call graph for this function:

◆ suppress_dead_code()

bool suppress_dead_code ( const  string)
Parameters
stringod_name

◆ suppress_trivial_test()

bool suppress_trivial_test ( const  string)

trivial_test_elimination.c

Parameters
stringod_name

◆ transformation_test()

bool transformation_test ( const  string)

transformation_test.c

Parameters
stringod_name

◆ unroll()

bool unroll ( const  string)

Top-level functions.

Get the loop label form the user

Get the unrolling factor from the user

User asked to cancel:

Sets the current module to "mod_name".

current_module(module_name_to_entity(mod_name));

DBR_CODE will be changed: argument "pure" should take false but this would be useless since there is only one version of code; a new version will be put back in the data base after unrolling

prelude

Validity of transformation should be checked

ie.: - no side effects in replicated expressions

No dependent types in C

do the job

Reorder the module, because new statements have been generated.

ostlude

Parameters
stringod_name

Definition at line 960 of file loop_unroll.c.

961 {
962  statement mod_stmt;
963  const char *lp_label = NULL;
964  entity lb_ent;
965  int rate;
966  bool return_status =true;
967 
968  debug_on("UNROLL_DEBUG_LEVEL");
969 
970  /* Get the loop label form the user */
971  lp_label=get_string_property_or_ask("LOOP_LABEL","Which loop do you want to unroll?\n(give its label):");
972  if( empty_string_p(lp_label) )
973  return_status = false;
974  else {
975  lb_ent = find_label_entity(mod_name, lp_label);
976  if (entity_undefined_p(lb_ent))
977  user_error("unroll", "loop label `%s' does not exist\n", lp_label);
978 
979  /* Get the unrolling factor from the user */
980  rate = get_int_property("UNROLL_RATE");
981  if( rate <= 1 ) {
982  string resp = user_request("How many times do you want to unroll?\n(choose integer greater or egal to 2): ");
983 
984  if (empty_string_p(resp))
985  /* User asked to cancel: */
986  return_status = false;
987  else {
988  if(sscanf(resp, "%d", &rate)!=1 || rate <= 1)
989  user_error("unroll", "unroll factor should be greater than 2\n");
990  }
991  }
992  if( return_status ) {
993 
994  pips_debug(1,"Unroll %d times loop %s in module %s\n",
995  rate, lp_label, mod_name);
996 
997  /* Sets the current module to "mod_name". */
998  /* current_module(module_name_to_entity(mod_name)); */
999 
1000  /* DBR_CODE will be changed: argument "pure" should take false
1001  but this would be useless
1002  since there is only *one* version of code; a new version
1003  will be put back in the
1004  data base after unrolling */
1005 
1006  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, mod_name, true);
1007 
1008  /* prelude */
1010  set_current_module_statement( mod_stmt);
1011 
1012  statement loop_statement = find_loop_from_label(mod_stmt,lb_ent);
1013  if( ! statement_undefined_p(loop_statement) ) {
1014  instruction i = statement_instruction(loop_statement);
1015  loop l = instruction_loop(i);
1016  /* Validity of transformation should be checked */
1017  /* ie.: - no side effects in replicated expressions */
1018  /* No dependent types in C */
1020  bool dependent_p = false;
1021  FOREACH(ENTITY, v, vl) {
1022  type t = entity_type(v);
1023  if(dependent_type_p(t)) {
1024  dependent_p = true;
1025  break;
1026  }
1027  }
1028 
1029  if(dependent_p) {
1030  pips_user_warning("Loop cannot be unrolled because it contains a dependent type.\n");
1031  return_status = false;
1032  }
1033  else {
1034  /* do the job */
1035  loop_unroll(loop_statement,rate);
1036  }
1037  }
1038  else
1039  pips_user_error("label '%s' is not linked to a loop\n", lp_label);
1040 
1041  if(return_status) {
1042  /* Reorder the module, because new statements have been generated. */
1043  module_reorder(mod_stmt);
1044 
1045  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
1046  }
1047  /*postlude*/
1050  return_status = true;
1051  }
1052  }
1053 
1054  pips_debug(2, "done for %s\n", mod_name);
1055  debug_off();
1056 
1057  if ( ! return_status )
1058  user_log("Loop unrolling has been cancelled.\n");
1059 
1060  return return_status;
1061 }
int get_int_property(const string)
void loop_unroll(statement loop_statement, int rate)
fallbacks on do_loop_unroll without statement post processing
Definition: loop_unroll.c:748
string user_request(const char *,...)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dependent_type_p(), empty_string_p(), ENTITY, entity_type, entity_undefined_p, find_label_entity(), find_loop_from_label(), FOREACH, get_int_property(), get_string_property_or_ask(), instruction_loop, loop_body, loop_unroll(), module_name_to_entity(), module_reorder(), pips_debug, pips_user_error, pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_declarations, statement_instruction, statement_undefined_p, user_error, user_log(), and user_request().

+ Here is the call graph for this function:

◆ use_def_elimination()

bool use_def_elimination ( char *  )

◆ variable_expansion()

bool variable_expansion ( const char *  )

Variable Documentation

◆ selected_label