PIPS
misc_paf_utils.c File Reference
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri-util.h"
#include "text-util.h"
+ Include dependency graph for misc_paf_utils.c:

Go to the source code of this file.

Macros

#define STATIC_CONTROLIZE_MODULE_NAME   "STATCON"
 
#define NLC_PREFIX   "NLC"
 
#define NSP_PREFIX   "NSP"
 
#define NUB_PREFIX   "NUB"
 
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)    (_list = gen_nconc( _list, CONS( _type, _element, NIL)))
 

Functions

list base_to_list (Pbase b)
 list base_to_list(Pbase v): translates a Pbase into a list of entities, in the same order. More...
 
Pbase list_to_base (list l)
 Pbase list_to_base(list l): returns the Pbase that contains the variables of list "l", of entities, in the same order. More...
 
expression make_max_exp (entity ent, expression exp1, expression exp2)
 ================================================================ More...
 
entity make_nlc_entity (int *Gcount_nlc)
 ================================================================ More...
 
entity make_nsp_entity ()
 entity make_nsp_entity() Makes a new NSP (for New Structural Parameter) . More...
 
entity make_nub_entity ()
 ================================================================ More...
 
entity current_module (entity mod)
 ================================================================ More...
 
bool undefined_statement_list_p (list l)
 ================================================================= More...
 
entity expression_int_scalar (expression exp)
 ================================================================ More...
 
entity scalar_assign_call (call c)
 entity scalar_assign_call((call) c) Detects if the call is an assignement and if the value assigned is a scalar. More...
 
void scalar_written_in_call (call the_call, list *ell, list *etl, list *swfl)
 scalar_written_in_call((call) the_call) Detects and puts a scalar written in an assignement call, in the global list Gscalar_written_forward if Genclosing_loops or Genclosing_tests are not empty. More...
 

Variables

int Gcount_nsp
 ================================================================ More...
 
int Gcount_nub
 

Macro Definition Documentation

◆ ADD_ELEMENT_TO_LIST

#define ADD_ELEMENT_TO_LIST (   _list,
  _type,
  _element 
)     (_list = gen_nconc( _list, CONS( _type, _element, NIL)))

Definition at line 263 of file misc_paf_utils.c.

◆ NLC_PREFIX

#define NLC_PREFIX   "NLC"

Definition at line 40 of file misc_paf_utils.c.

◆ NSP_PREFIX

#define NSP_PREFIX   "NSP"

Definition at line 41 of file misc_paf_utils.c.

◆ NUB_PREFIX

#define NUB_PREFIX   "NUB"

Definition at line 42 of file misc_paf_utils.c.

◆ STATIC_CONTROLIZE_MODULE_NAME

#define STATIC_CONTROLIZE_MODULE_NAME   "STATCON"

Definition at line 39 of file misc_paf_utils.c.

Function Documentation

◆ base_to_list()

list base_to_list ( Pbase  b)

list base_to_list(Pbase v): translates a Pbase into a list of entities, in the same order.

misc_paf_utils.c

Most includes are centralized here.

Definition at line 47 of file misc_paf_utils.c.

48 {
49  list l = NIL;
50 
51  for( ; b != NULL; b = b->succ)
52  l = gen_nconc(l, CONS(ENTITY, (entity) b->var, NIL));
53 
54  return(l);
55 }
#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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, ENTITY, gen_nconc(), NIL, Svecteur::succ, and Svecteur::var.

Referenced by apply_farkas(), array_must_fully_written_by_regions_p(), build_first_comb(), build_third_comb(), clean_distributed_io_system(), clean_list_of_unk(), clean_shared_io_system(), copy_write_statement_with_cumulated_regions(), include_time_in_base(), include_trans_on_LC_in_ref(), include_trans_on_LC_in_sc(), include_trans_on_LC_in_sc2(), is_mu_stat_in_sc(), make_causal_external(), make_causal_internal(), make_dual(), make_list_of_unk(), make_primal(), matrix_to_system(), my_matrices_to_constraints_with_sym_cst(), pip_solve_min_with_big(), plc_make_distance(), put_variables_in_ordered_lists(), region_to_com_nest(), region_to_loop_nest(), remapping_variables(), replace_indices_region(), replace_indices_region_com(), valuer(), and vvs_on_polynome().

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

◆ current_module()

entity current_module ( entity  mod)

================================================================

entity current_module(entity mod): returns the current module entity, that is the entity of the module in which we are working currently. If the entity "mod" is undefined, it returns the static entity already known; Else, the static entity is updated to the entity "mod".

Parameters
modod

Definition at line 250 of file misc_paf_utils.c.

252 {
253  static entity current_mod;
254 
255  debug( 7, "current_module", "doing\n");
256  if (mod != entity_undefined) {
257  pips_assert("current_module_entity", entity_module_p(mod));
258  current_mod = mod;
259  }
260  return(current_mod);
261 }
static entity current_mod
Definition: alias_check.c:120
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
bool entity_module_p(entity e)
Definition: entity.c:683
#define entity_undefined
Definition: ri.h:2761

References current_mod, debug(), entity_module_p(), entity_undefined, and pips_assert.

+ Here is the call graph for this function:

◆ expression_int_scalar()

entity expression_int_scalar ( expression  exp)

================================================================

entity expression_int_scalar((expression) exp) Returns the scalar entity if this expression is a scalar.

Parameters
expxp

Definition at line 299 of file misc_paf_utils.c.

301 {
303  tag t = syntax_tag( s );
304  entity ent = entity_undefined;
305 
306  debug( 7, "expression_int_scalar", "doing \n");
307  switch( t ) {
308  case is_syntax_reference: {
309  entity local;
311  if (entity_integer_scalar_p(local)) ent = local;
312  break;
313  }
314  default: break;
315  }
316  debug( 7, "expression_int_scalar",
317  "returning : %s\n",
318  ((ent == entity_undefined)?"entity_undefined":
319  entity_local_name( ent )) );
320  return( ent );
321 }
int tag
TAG.
Definition: newgen_types.h:92
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_integer_scalar_p(entity)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
Definition: variable.c:1130
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define reference_variable(x)
Definition: ri.h:2326
@ is_syntax_reference
Definition: ri.h:2691
#define expression_syntax(x)
Definition: ri.h:1247
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References debug(), entity_integer_scalar_p(), entity_local_name(), entity_undefined, exp, expression_syntax, is_syntax_reference, reference_variable, syntax_reference, and syntax_tag.

Referenced by get_sp_of_call_p(), scalar_assign_call(), and terapix_optimize_accumulator().

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

◆ list_to_base()

Pbase list_to_base ( list  l)

Pbase list_to_base(list l): returns the Pbase that contains the variables of list "l", of entities, in the same order.

Definition at line 60 of file misc_paf_utils.c.

62 {
63  Pbase new_b = NULL;
64  list el_l;
65 
66  for(el_l = l ; el_l != NIL; el_l = CDR(el_l))
67  vect_add_elem((Pvecteur *) &new_b, (char *) ENTITY(CAR(el_l)), VALUE_ONE);
68 
69  new_b = base_reversal(new_b);
70  return(new_b);
71 }
#define VALUE_ONE
Pbase base_reversal(Pbase b_in)
Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in,...
Definition: base.c:221
#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
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References base_reversal(), CAR, CDR, ENTITY, NIL, VALUE_ONE, and vect_add_elem().

Referenced by adg_dataflowgraph(), analyze_quast(), base_complete(), broadcast_conditions(), broadcast_of_dataflow(), clean_list_of_unk(), completer_base(), completer_n_base(), do_array_expansion(), do_solve_hardware_constraints_on_nb_proc(), extract_lattice(), include_time_in_base(), make_dual(), make_list_of_unk(), make_primal(), mapping_on_broadcast(), partial_broadcast_coefficients(), prepare_reindexing(), rectangularization_region(), search_scc_bdt(), stmt_bdt_directions(), system_inversion_restrict(), and valuer().

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

◆ make_max_exp()

expression make_max_exp ( entity  ent,
expression  exp1,
expression  exp2 
)

================================================================

expression make_max_exp(entity ent, expression exp1, expression exp2) computes MAX( exp1, exp2 ) if exp1 and exp2 are constant expressions. If it is not the case, it returns MAX( exp1, exp2 )

pips_debug(7, "doing MAX( %s, %s ) \n",

expression_to_string(exp1),

expression_to_string(exp2) );

Parameters
entnt
exp1xp1
exp2xp2

Definition at line 78 of file misc_paf_utils.c.

81 {
82  expression rexp;
83 
84  /* pips_debug(7, "doing MAX( %s, %s ) \n", */
85  /* expression_to_string(exp1), */
86  /* expression_to_string(exp2) ); */
87  if (expression_constant_p( exp1 ) && expression_constant_p( exp2 )) {
88  int val1 = expression_to_int( exp1 );
89  int val2 = expression_to_int( exp2 );
90  if (val1 > val2) rexp = int_to_expression(val1);
91  else rexp = int_to_expression( val2 );
92  }
93  else rexp = MakeBinaryCall( ent, exp1, exp2 );
94 
95  return rexp ;
96 }
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188

References expression_constant_p(), expression_to_int(), int_to_expression(), and MakeBinaryCall().

Referenced by loop_normalize_of_loop().

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

◆ make_nlc_entity()

entity make_nlc_entity ( int Gcount_nlc)

================================================================

entity make_nlc_entity(int *Gcount_nlc):

Returns a new entity. Its local name is "NLC#", where '#' represents the value of "Gcount_nlc". This variable counts the number of NLCs variables.

These entities have a special full name. The first part of it is the concatenation of the define constant STATIC_CONTROLIZE_MODULE_NAME and the local name of the current module.

The type ("basic") of these variables is INTEGER.

These variables are local to the current module, so they have a "storage_ram" with DYNAMIC "area".

NLC means Normalized Loop Counter.

Parameters
Gcount_nlccount_nlc

Definition at line 117 of file misc_paf_utils.c.

119 {
120  entity new_ent, mod_ent;
121  char *name, *num;
123  ram new_dynamic_ram;
124 
125 
126  debug( 7, "make_nlc_entity", "doing\n");
127  (*Gcount_nlc)++;
128  (void) asprintf(&num, "%d", *Gcount_nlc);
129 
131 
134  MODULE_SEP_STRING, NLC_PREFIX, num, (char *) NULL));
135 
136  new_ent = make_entity(name,
139  NIL,NIL)),
142 
145 
146  new_dynamic_ram = make_ram(mod_ent,
147  dynamic_area,
149  NIL);
150 
151  storage_ram(entity_storage(new_ent)) = new_dynamic_ram;
152 
153  return(new_ent);
154 }
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
static entity mod_ent
static int num
Definition: bourdoncle.c:137
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define asprintf
Definition: misc-local.h:225
#define STATIC_CONTROLIZE_MODULE_NAME
#define NLC_PREFIX
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define UUINT(i)
Definition: newgen_types.h:99
#define UU
Definition: newgen_types.h:98
static entity dynamic_area
#define make_entity(n, t, s, i)
int current_offset_of_area(entity a, entity v)
Definition: area.c:174
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
@ is_basic_int
Definition: ri.h:571
#define ram_undefined
Definition: ri.h:2221
#define entity_storage(x)
Definition: ri.h:2794
@ is_value_unknown
Definition: ri.h:3035
@ is_storage_ram
Definition: ri.h:2492
#define storage_ram(x)
Definition: ri.h:2521
@ is_type_variable
Definition: ri.h:2900
char * strdup()
int Gcount_nlc

References asprintf, concatenate(), current_offset_of_area(), debug(), dynamic_area, DYNAMIC_AREA_LOCAL_NAME, entity_local_name(), entity_storage, FindOrCreateEntity(), Gcount_nlc, get_current_module_entity(), is_basic_int, is_storage_ram, is_type_variable, is_value_unknown, make_basic(), make_entity, make_ram(), make_storage(), make_type(), make_value(), make_variable(), mod_ent, module_local_name(), MODULE_SEP_STRING, NIL, NLC_PREFIX, num, ram_undefined, STATIC_CONTROLIZE_MODULE_NAME, storage_ram, strdup(), UU, and UUINT.

Referenced by loop_normalize_of_loop().

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

◆ make_nsp_entity()

entity make_nsp_entity ( void  )

entity make_nsp_entity() Makes a new NSP (for New Structural Parameter) .

Definition at line 165 of file misc_paf_utils.c.

166 {
167  entity new_ent, mod_ent;
168  char *name, *num;
170  ram new_dynamic_ram;
171 
172  debug( 7, "make_nsp_entity", "doing\n");
173  Gcount_nsp++;
174  (void) asprintf(&num, "%d", Gcount_nsp);
175 
177 
180  MODULE_SEP_STRING, NSP_PREFIX, num, (char *) NULL));
181 
182  new_ent = make_entity(name,
185  NIL,NIL)),
188 
191 
192  new_dynamic_ram = make_ram(mod_ent,
193  dynamic_area,
195  NIL);
196 
197  storage_ram(entity_storage(new_ent)) = new_dynamic_ram;
198 
199  return new_ent;
200 }
int Gcount_nsp
================================================================
#define NSP_PREFIX

References asprintf, concatenate(), current_offset_of_area(), debug(), dynamic_area, DYNAMIC_AREA_LOCAL_NAME, entity_local_name(), entity_storage, FindOrCreateEntity(), Gcount_nsp, get_current_module_entity(), is_basic_int, is_storage_ram, is_type_variable, is_value_unknown, make_basic(), make_entity, make_ram(), make_storage(), make_type(), make_value(), make_variable(), mod_ent, module_local_name(), MODULE_SEP_STRING, NIL, NSP_PREFIX, num, ram_undefined, STATIC_CONTROLIZE_MODULE_NAME, storage_ram, strdup(), UU, and UUINT.

Referenced by get_sp_of_call_p().

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

◆ make_nub_entity()

entity make_nub_entity ( void  )

================================================================

entity make_nub_entity() Makes a new NUB (for New Upper Bound) .

Definition at line 206 of file misc_paf_utils.c.

207 {
208  entity new_ent, mod_ent;
209  char *name, *num;
211  ram new_dynamic_ram;
212 
213 
214  debug( 7, "make_nub_entity", "doing\n");
215  Gcount_nub++;
216  (void) asprintf(&num, "%d", Gcount_nub);
217 
219 
222  MODULE_SEP_STRING, NUB_PREFIX, num, (char *) NULL));
223 
224  new_ent = make_entity(name,
227  NIL,NIL)),
230 
233 
234  new_dynamic_ram = make_ram(mod_ent,
235  dynamic_area,
237  NIL);
238 
239  storage_ram(entity_storage(new_ent)) = new_dynamic_ram;
240 
241  return new_ent;
242 }
#define NUB_PREFIX
int Gcount_nub

References asprintf, concatenate(), current_offset_of_area(), debug(), dynamic_area, DYNAMIC_AREA_LOCAL_NAME, entity_local_name(), entity_storage, FindOrCreateEntity(), Gcount_nub, get_current_module_entity(), is_basic_int, is_storage_ram, is_type_variable, is_value_unknown, make_basic(), make_entity, make_ram(), make_storage(), make_type(), make_value(), make_variable(), mod_ent, module_local_name(), MODULE_SEP_STRING, NIL, NUB_PREFIX, num, ram_undefined, STATIC_CONTROLIZE_MODULE_NAME, storage_ram, strdup(), UU, and UUINT.

+ Here is the call graph for this function:

◆ scalar_assign_call()

entity scalar_assign_call ( call  c)

entity scalar_assign_call((call) c) Detects if the call is an assignement and if the value assigned is a scalar.

If it is so, it returns this scalar.

Definition at line 328 of file misc_paf_utils.c.

330 {
331  entity ent = entity_undefined;
332 
333  debug( 7, "scalar_assign_call", "doing \n");
335  {
336  expression lhs;
337 
338  lhs = binary_call_lhs(c);
339  ent = expression_int_scalar( lhs );
340  }
341  debug( 7, "scalar_assign_call", "returning : %s \n",
342  ((ent == entity_undefined)?"entity_undefined":
343  entity_name(ent)) );
344  return( ent );
345 }
entity expression_int_scalar(expression exp)
================================================================
#define ENTITY_ASSIGN_P(e)
#define binary_call_lhs(c)
#define call_function(x)
Definition: ri.h:709
#define entity_name(x)
Definition: ri.h:2790

References binary_call_lhs, call_function, debug(), ENTITY_ASSIGN_P, entity_name, entity_undefined, and expression_int_scalar().

Referenced by scalar_written_in_call(), and sp_feautrier_scalar_assign_call().

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

◆ scalar_written_in_call()

void scalar_written_in_call ( call  the_call,
list ell,
list etl,
list swfl 
)

scalar_written_in_call((call) the_call) Detects and puts a scalar written in an assignement call, in the global list Gscalar_written_forward if Genclosing_loops or Genclosing_tests are not empty.

Parameters
the_callhe_call
ellll
etltl
swflwfl

Definition at line 352 of file misc_paf_utils.c.

355 {
356  entity ent;
357 
358  debug( 7, "scalar_written_in_call", "doing\n");
359  if ( ((ent = scalar_assign_call(the_call)) != entity_undefined)
360  && ( (*ell != NIL) || (*etl != NIL) )
361  && entity_integer_scalar_p( ent ) )
362 
363  ADD_ELEMENT_TO_LIST(*swfl, ENTITY, ent);
364 }
entity scalar_assign_call(call c)
entity scalar_assign_call((call) c) Detects if the call is an assignement and if the value assigned i...
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)

References ADD_ELEMENT_TO_LIST, debug(), ENTITY, entity_integer_scalar_p(), entity_undefined, NIL, and scalar_assign_call().

Referenced by loop_normalize_of_statement().

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

◆ undefined_statement_list_p()

bool undefined_statement_list_p ( list  l)

=================================================================

bool undefined_statement_list_p( (list) l ) AL 04/93 Returns true if l is made of 2 undefined or continue statement.

Newgen does not support list of undefined objects

Definition at line 272 of file misc_paf_utils.c.

274 {
275  bool local_bool;
276  statement first, second;
277 
278  debug(7, "undefined_statement_list_p","doing\n");
279  if ( (l == NIL) || (gen_length(l) != 2) )
280  return( false );
281 
282  first = STATEMENT(CAR( l ));
283  second = STATEMENT(CAR(CDR( l )));
284  local_bool = ( first == statement_undefined )
285  && ( second == statement_undefined );
286 
287  /* Newgen does not support list of undefined objects */
288  if(!local_bool) {
289  local_bool = continue_statement_p(first) && continue_statement_p(second);
290  }
291 
292  return( local_bool );
293 }
size_t gen_length(const list l)
Definition: list.c:150
bool continue_statement_p(statement)
Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
Definition: statement.c:203
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CAR, CDR, continue_statement_p(), debug(), gen_length(), NIL, STATEMENT, and statement_undefined.

Referenced by loop_normalize_of_unstructured().

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

Variable Documentation

◆ Gcount_nsp

int Gcount_nsp

================================================================

Definition at line 158 of file misc_paf_utils.c.

Referenced by make_nsp_entity(), and static_controlize().

◆ Gcount_nub

int Gcount_nub

Definition at line 160 of file misc_paf_utils.c.

Referenced by make_nub_entity(), and static_controlize().