PIPS
new_atomizer.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "dg.h"
#include "graph.h"
#include "ri-util.h"
#include "effects-util.h"
#include "text-util.h"
#include "database.h"
#include "misc.h"
#include "pipsdbm.h"
#include "resources.h"
#include "control.h"
#include "arithmetique.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "atomizer.h"
+ Include dependency graph for new_atomizer.c:

Go to the source code of this file.

Data Structures

struct  atomizer_param
 

Typedefs

typedef dg_arc_label arc_label
 An atomizer that uses the one made by Fabien Coelho for HPFC, and is in fact just a hacked version of the one made by Ronan Keryell... More...
 
typedef dg_vertex_label vertex_label
 

Functions

static void atomize_call (expression, atomizer_param *)
 
static void do_atomize_call (expression parent, atomizer_param *p, list expressions)
 
static bool atomize_call_filter (expression parent, atomizer_param *p)
 
static void atomize_all (void *v, atomizer_param *p)
 
static void atomize_statement (statement stat)
 This function is called for all statements in the code. More...
 
bool new_atomizer (char *mod_name)
 Mappings for the cumulated effects of statements. More...
 

Typedef Documentation

◆ arc_label

An atomizer that uses the one made by Fabien Coelho for HPFC, and is in fact just a hacked version of the one made by Ronan Keryell...

Definition at line 44 of file new_atomizer.c.

◆ vertex_label

Definition at line 45 of file new_atomizer.c.

Function Documentation

◆ atomize_all()

static void atomize_all ( void *  v,
atomizer_param p 
)
static

Definition at line 137 of file new_atomizer.c.

138 {
141  0);
142 }
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
static bool atomize_call_filter(expression parent, atomizer_param *p)
Definition: new_atomizer.c:123
static void atomize_call(expression, atomizer_param *)
Definition: new_atomizer.c:107
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154

References atomize_call(), atomize_call_filter(), expression_domain, and gen_context_multi_recurse().

Referenced by atomize_statement().

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

◆ atomize_call()

static void atomize_call ( expression  parent,
atomizer_param p 
)
static

Definition at line 107 of file new_atomizer.c.

108 {
109  if(expression_call_p(parent))
110  {
111  call c = expression_call(parent);
112  do_atomize_call(parent,p,call_arguments(c));
113  }
114  else if(expression_reference_p(parent))
115  {
117  if(!ENDP(reference_indices(ref)))
119  }
120 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
static void do_atomize_call(expression parent, atomizer_param *p, list expressions)
Definition: new_atomizer.c:69
bool expression_call_p(expression e)
Definition: expression.c:415
call expression_call(expression e)
Definition: expression.c:445
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define reference_indices(x)
Definition: ri.h:2328
#define call_arguments(x)
Definition: ri.h:711

References call_arguments, do_atomize_call(), ENDP, expression_call(), expression_call_p(), expression_reference(), expression_reference_p(), ref, and reference_indices.

Referenced by atomize_all().

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

◆ atomize_call_filter()

static bool atomize_call_filter ( expression  parent,
atomizer_param p 
)
static

do not visit rhs of . and ->

Definition at line 123 of file new_atomizer.c.

124 {
125  pips_assert("true", p==p);
126  if(expression_call_p(parent))
127  {
128  call c= expression_call(parent);
129  entity op = call_function(c);
130  /* do not visit rhs of . and -> */
132  if(call_constant_p(c)) return false;
133  }
134  return true;
135 }
#define call_constant_p(C)
Definition: flint_check.c:51
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define binary_call_rhs(c)
#define ENTITY_POINT_TO_P(e)
#define ENTITY_FIELD_P(e)
C data structure and pointer management.
#define call_function(x)
Definition: ri.h:709

References binary_call_rhs, call_constant_p, call_function, ENTITY_FIELD_P, ENTITY_POINT_TO_P, expression_call(), expression_call_p(), gen_recurse_stop(), and pips_assert.

Referenced by atomize_all().

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

◆ atomize_statement()

static void atomize_statement ( statement  stat)
static

This function is called for all statements in the code.

SG: we could atomize condition in test, loops etc too

this may cause a useless atomization if i is an expression

Definition at line 146 of file new_atomizer.c.

147 {
149  /* SG: we could atomize condition in test, loops etc too */
151  {
152  atomizer_param p = { NIL, NIL };
154  FOREACH(EFFECT,weff,weffects)
156  /* this may cause a useless atomization if i is an expression */
157  atomize_all(i,&p);
158  if(!ENDP(p.inserted_statements))
160  }
161 
162 }
list load_cumulated_rw_effects_list(statement)
list effects_write_effects(list)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
static void atomize_all(void *v, atomizer_param *p)
Definition: new_atomizer.c:137
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define instruction_call_p(x)
Definition: ri.h:1527
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_expression_p(x)
Definition: ri.h:1539
list written_references
Definition: new_atomizer.c:64
list inserted_statements
Definition: new_atomizer.c:65
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References atomize_all(), CONS, EFFECT, effect_any_reference, effects_write_effects(), ENDP, FOREACH, gen_nreverse(), insert_statement(), atomizer_param::inserted_statements, instruction_call_p, instruction_expression_p, load_cumulated_rw_effects_list(), make_block_statement(), NIL, REFERENCE, statement_instruction, and atomizer_param::written_references.

Referenced by new_atomizer().

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

◆ do_atomize_call()

static void do_atomize_call ( expression  parent,
atomizer_param p,
list  expressions 
)
static

stop if call directly involves a written reference

go on and atomize, that is

  • create a variable to store call result
  • recurse on call arguments

Definition at line 69 of file new_atomizer.c.

70 {
71  bool safe=true;
72  /* stop if call directly involves a written reference */
73  FOREACH(EXPRESSION,arg,expressions)
74  {
75  if(expression_reference_p(arg)&&
77  {
82  { safe=false; break; }
83  if(!safe) break;
84  }
86  if(!safe) break;
87  }
88  }
89  /* go on and atomize, that is
90  * - create a variable to store call result
91  * - recurse on call arguments
92  */
93  if( safe )
94  {
95  basic bofe=basic_of_expression(parent);
99  entity_to_expression(result),
104  }
105 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
syntax make_syntax_reference(reference _field_)
Definition: ri.c:2494
list proper_effects_of_expression(expression)
void gen_full_free_list(list l)
Definition: genClib.c:1023
bool references_may_conflict_p(reference r1, reference r2)
Check if two references may conflict.
Definition: conflicts.c:426
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
statement make_assign_statement(expression, expression)
Definition: statement.c:583
bool entity_field_p(entity e)
e is the field of a structure
Definition: entity.c:857
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
void update_expression_syntax(expression e, syntax s)
frees expression syntax of e and replace it by the new syntax s
Definition: expression.c:3564
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
entity make_new_scalar_variable(entity, basic)
Definition: variable.c:741
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
#define normalized_undefined
Definition: ri.h:1745
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define syntax_undefined
Definition: ri.h:2676
#define expression_syntax(x)
Definition: ri.h:1247
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References AddEntityToCurrentModule(), basic_of_expression(), CONS, EFFECT, effect_any_reference, entity_field_p(), entity_to_expression(), EXPRESSION, expression_reference(), expression_reference_p(), expression_syntax, FOREACH, gen_full_free_list(), get_current_module_entity(), atomizer_param::inserted_statements, make_assign_statement(), make_expression(), make_new_scalar_variable(), make_reference(), make_syntax_reference(), NIL, normalized_undefined, proper_effects_of_expression(), REFERENCE, reference_variable, references_may_conflict_p(), STATEMENT, syntax_undefined, update_expression_syntax(), and atomizer_param::written_references.

Referenced by atomize_call().

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

◆ new_atomizer()

bool new_atomizer ( char *  mod_name)

Mappings for the cumulated effects of statements.

extern statement_mapping cumulated_effects_map; cproto-generated files new_atomizer.c

get the resources

Now do the job

Reorder the module, because new statements have been added

update/release resources

Parameters
mod_nameod_name

Definition at line 164 of file new_atomizer.c.

165 {
166  /* get the resources */
169  set_cumulated_rw_effects((statement_effects)db_get_memory_resource(DBR_CUMULATED_EFFECTS, mod_name, true));
170  debug_on("NEW_ATOMIZER_DEBUG_LEVEL");
171 
172 
173  /* Now do the job */
175 
176  /* Reorder the module, because new statements have been added */
180 
181  /* update/release resources */
185  debug_off();
186 
187  return true;
188 }
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
#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
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
static void atomize_statement(statement stat)
This function is called for all statements in the code.
Definition: new_atomizer.c:146
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
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

References atomize_statement(), clean_up_sequences(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), get_current_module_statement(), module_name_to_entity(), module_reorder(), 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: