PIPS
workspace-util.h File Reference
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "text.h"
#include "cloning.h"
#include "newgen.h"
#include "naming.h"
#include "ri-util.h"
#include "pipsdbm.h"
+ Include dependency graph for workspace-util.h:

Go to the source code of this file.

Functions

const char * entity_module_unambiguous_user_name (entity, entity)
 Warning! Do not modify this file that is automatically generated! More...
 
const char * entity_unambiguous_user_name (entity)
 
const char * entity_minimal_name (entity)
 Do preserve scope informations. More...
 
const char * entity_minimal_user_name (entity)
 Do not preserve scope information. More...
 
void print_arguments (list)
 
entity string_to_entity (const char *, entity)
 very simple conversion from string to expression only handles entities and numeric values at the time being More...
 
list string_to_entities (const char *, const char *, entity)
 split a string using seed as separator and call string_to_entity on each chunk More...
 
expression string_to_expression (const char *, entity)
 expressions.c More...
 
list string_to_expressions (const char *, const char *, entity)
 split a string using seed as separator and call string_to_expression on each chunk More...
 
list base_to_list (Pbase)
 misc_paf_utils.c More...
 
Pbase list_to_base (list)
 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, expression, expression)
 ================================================================ More...
 
entity make_nlc_entity (int *)
 ================================================================ More...
 
entity make_nsp_entity (void)
 entity make_nsp_entity() Makes a new NSP (for New Structural Parameter) . More...
 
entity make_nub_entity (void)
 ================================================================ More...
 
entity current_module (entity)
 ================================================================ More...
 
bool undefined_statement_list_p (list)
 ================================================================= More...
 
entity expression_int_scalar (expression)
 ================================================================ More...
 
entity scalar_assign_call (call)
 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, list *, list *, list *)
 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...
 
list module_declarations (entity)
 module.c More...
 
list current_module_declarations (void)
 
list module_entities (entity)
 Return a list of all variables and functions accessible somewhere in a module. More...
 
entity module_entity_to_compilation_unit_entity (entity)
 Retrieve the compilation unit containing a module definition. More...
 
bool language_module_p (entity, string)
 
void AddEntityToCompilationUnit (entity, entity)
 Add an entity to the current's module compilation unit declarations we have to generate its statement if none created before due to limitation of pipsmake, it is not always possible to make sure from pipsmake that this ressource is created. More...
 
void RemoveEntityFromCompilationUnit (entity, entity)
 Remove an entity from the current's module compilation unit declarations. More...
 
void AddEntityToModuleCompilationUnit (entity, entity)
 
list module_to_all_declarations (entity)
 
string compilation_unit_of_module (const char *)
 The output is undefined if the module is referenced but not defined in the workspace, for instance because its code should be synthesized. More...
 
string module_name_to_input_file_name (const char *)
 To be checked for static functions... More...
 

Variables

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

Function Documentation

◆ AddEntityToCompilationUnit()

void AddEntityToCompilationUnit ( entity  e,
entity  cu 
)

Add an entity to the current's module compilation unit declarations we have to generate its statement if none created before due to limitation of pipsmake, it is not always possible to make sure from pipsmake that this ressource is created.

For example in INLINING (!) we would like to tell pipsmake we need the CODE resource from all module callers.

Parameters
[in]eis the entity to add
[in]cuis the compilation unit

SG: when adding a new entity to compilation unit, one should check the entity is not already present but an entity with the same name may already be defined there so check this with a very costly test

Parameters
cuu

Definition at line 198 of file module.c.

198  {
200  const char* cum = module_local_name(cu);
201  if( c_module_p(cu) ) {
202  if(!db_resource_required_or_available_p(DBR_PARSED_CODE,cum))
203  {
204  bool compilation_unit_parser(const char*);
210  if(!entity_undefined_p(tmp))
214  }
215  if(!db_resource_required_or_available_p(DBR_CODE,cum))
216  {
217  bool controlizer(const char*);
222  controlizer(cum);
223  if(!entity_undefined_p(tmp))
227  }
228  s=(statement)db_get_memory_resource(DBR_CODE,cum,true);
229  }
230  /* SG: when adding a new entity to compilation unit,
231  * one should check the entity is not already present
232  * but an entity with the same name may already be defined there
233  * so check this with a very costly test*/
234  list cu_entities = entity_declarations(cu);
235  FOREACH(ENTITY,cue,cu_entities)
237  return;
239  if( c_module_p(cu) ) {
240  module_reorder(s);
241  db_put_or_update_memory_resource(DBR_CODE,cum,s,true);
242  db_touch_resource(DBR_CODE,cum);
243  if( typedef_entity_p(e) ) {
244  //keyword_typedef_table = (hash_table)db_get_memory_resource(DBR_DECLARATIONS, cum, true);
245  //put_new_typedef(entity_user_name(e));
246  // FI: I do not see why the global variable of the parsers should be reused here
247  // hash_table keyword_typedef_table = (hash_table)db_get_memory_resource(DBR_DECLARATIONS, cum, true);
248  set_keyword_typedef_table((hash_table) db_get_memory_resource(DBR_DECLARATIONS, cum, true));
249  //hash_put(keyword_typedef_table,strdup(cum),(void *) TK_NAMED_TYPE);
250  // FI; temporary
251  //hash_put(keyword_typedef_table,strdup(cum),(void *) 262);
253  //SG: we have to do this behind the back of pipsmake. Not Good for serialization, but otherwise it forces the recompilation of the parsed_code of the associated modules, not good :(
254  //DB_PUT_MEMORY_RESOURCE(DBR_DECLARATIONS, cum, keyword_typedef_table);
255  }
256 
257  }
258 }
bool db_resource_required_or_available_p(const char *rname, const char *oname)
from now on we must not know about the database internals?
Definition: database.c:505
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
Definition: database.c:538
bool compilation_unit_parser(const char *module_name)
Definition: c_parser.c:746
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
bool controlizer(const char *module_name)
The old controlizer user interface.
Definition: module.c:224
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
#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
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
void db_put_or_update_memory_resource(const char *rname, const char *oname, void *p, bool update_is_ok)
Put a resource into the current workspace database.
Definition: database.c:854
#define same_string_p(s1, s2)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
#define entity_declarations(e)
MISC: newgen shorthands.
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
bool typedef_entity_p(entity e)
Definition: entity.c:1902
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void set_keyword_typedef_table(hash_table)
Definition: static.c:263
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:233
void declare_new_typedef(const string)
Definition: static.c:283
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_undefined_p(x)
Definition: ri.h:2762
#define statement_undefined_p(x)
Definition: ri.h:2420
#define statement_undefined
Definition: ri.h:2419
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54

References AddLocalEntityToDeclarations(), c_module_p(), compilation_unit_parser(), controlizer(), db_get_memory_resource(), db_put_or_update_memory_resource(), db_resource_required_or_available_p(), db_touch_resource(), declare_new_typedef(), ENTITY, entity_declarations, entity_undefined_p, entity_user_name(), FOREACH, get_current_module_entity(), get_current_module_statement(), module_local_name(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), same_string_p, set_current_module_entity(), set_current_module_statement(), set_keyword_typedef_table(), statement_undefined, statement_undefined_p, and typedef_entity_p().

Referenced by AddEntityToModuleCompilationUnit(), outliner_independent_recursively(), and type_to_named_type().

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

◆ AddEntityToModuleCompilationUnit()

void AddEntityToModuleCompilationUnit ( entity  e,
entity  module 
)
Parameters
moduleodule

Definition at line 301 of file module.c.

302 {
305  FOREACH(ENTITY,se,tse) {
306  const char * eln = entity_local_name(se);
307  if(strstr(eln, DUMMY_STRUCT_PREFIX) || strstr(eln, DUMMY_UNION_PREFIX) ) {
308  continue;
309  }
311  }
312  gen_free_list(tse);
314 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define DUMMY_STRUCT_PREFIX
Definition: naming-local.h:87
#define DUMMY_UNION_PREFIX
Definition: naming-local.h:88
static char * module
Definition: pips.c:74
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
list type_supporting_entities(list, type)
Definition: type.c:4347
#define entity_type(x)
Definition: ri.h:2792
void AddEntityToCompilationUnit(entity e, entity cu)
Add an entity to the current's module compilation unit declarations we have to generate its statement...
Definition: module.c:198
entity module_entity_to_compilation_unit_entity(entity m)
Retrieve the compilation unit containing a module definition.
Definition: module.c:116

References AddEntityToCompilationUnit(), DUMMY_STRUCT_PREFIX, DUMMY_UNION_PREFIX, ENTITY, entity_local_name(), entity_type, FOREACH, gen_free_list(), module, module_entity_to_compilation_unit_entity(), NIL, and type_supporting_entities().

Referenced by dimensions_to_dma(), initialization_list_to_statements(), inline_expression_call(), make_dma_transfert(), outliner_file(), outliner_independent_recursively(), promote_local_entities(), step_parameter(), and wrap_argument().

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

◆ base_to_list()

list base_to_list ( Pbase  b)

misc_paf_utils.c

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 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
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92

◆ compilation_unit_of_module()

string compilation_unit_of_module ( const char *  module_name)

The output is undefined if the module is referenced but not defined in the workspace, for instance because its code should be synthesized.

Fabien Coelho suggests to build a default compilation unit where all synthesized module codes would be located.

Parameters
module_nameodule_name

Definition at line 350 of file module.c.

351 {
353  pips_assert("only for C modules\n", entity_undefined_p(e) || c_module_p(e));
354 
355  // Should only be called for C modules.
357 
358  // The guard may not be sufficient...
359  // and this may crash in db_get_memory_resource()
360  if(db_resource_p(DBR_USER_FILE, module_name)) {
361  string source_file_name =
362  db_get_memory_resource(DBR_USER_FILE, module_name, true);
363  string simpler_file_name = pips_basename(source_file_name, PP_C_ED);
364 
365  // It is not clear how robust it is going to be
366  // when file name conflicts occur.
368  simpler_file_name);
369  free(simpler_file_name);
370  }
371 
372  return compilation_unit_name;
373 }
bool db_resource_p(const char *rname, const char *oname)
true if exists and in loaded or stored state.
Definition: database.c:524
string compilation_unit_name
cproto-generated files
Definition: c_parser.c:49
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
char * pips_basename(char *fullpath, char *suffix)
Definition: file.c:822
void free(void *)
#define asprintf
Definition: misc-local.h:225
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define FILE_SEP_STRING
Definition: naming-local.h:41
#define string_undefined
Definition: newgen_types.h:40
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

◆ 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
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:

◆ current_module_declarations()

list current_module_declarations ( void  )

Definition at line 78 of file module.c.

79 {
81  return module_declarations(m);
82 }
list module_declarations(entity m)
High-level functions about modules, using pipsdbm and ri-util and some global variables assumed prope...
Definition: module.c:58

References get_current_module_entity(), and module_declarations().

Referenced by add_declaration_information(), and module_to_value_mappings().

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

◆ entity_minimal_name()

const char* entity_minimal_name ( entity  e)

Do preserve scope informations.

This function does not allocate a new string, which implies to keep the scope information in the name of extraprocedural variables and functions.

Definition at line 214 of file naming.c.

215 {
216  return entity_more_or_less_minimal_name(e, true);
217 }
static const char * entity_more_or_less_minimal_name(entity e, bool strict_p)
In interprocedural context, returns the shortest non-ambiguous name for a variable.
Definition: naming.c:107

References entity_more_or_less_minimal_name().

Referenced by DisplayDad(), effect_words_reference(), flint_check_uninitialized_variables_in_statement(), flint_initialize_statement_def_use_variables(), generic_value_name(), pips_region_user_name(), pips_user_value_name(), print_arguments(), print_value_mappings(), region_translation(), text_transformer(), and variable_local_name().

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

◆ entity_minimal_user_name()

const char* entity_minimal_user_name ( entity  e)

Do not preserve scope information.

A new string is allocated.

Definition at line 223 of file naming.c.

224 {
225  return entity_more_or_less_minimal_name(e, false);
226 }

References entity_more_or_less_minimal_name().

Referenced by equal_must_vreference(), is_entity_in_list(), opkill_may_vreference(), opkill_must_vreference(), points_to_compare_cell(), points_to_compare_cells(), points_to_compare_location(), points_to_compare_ptr_cell(), points_to_words_reference(), remove_from_effective_parameters(), and remove_from_formal_parameters().

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

◆ entity_module_unambiguous_user_name()

const char* entity_module_unambiguous_user_name ( entity  e,
entity  m 
)

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

Modify src/Libs/workspace-util/workspace-util-local.h instead, to add your own modifications. header file built by cproto workspace_util-local.h WORKSPACE-UTIL Library: Functions dealing with the internal representation at the workspace level, mixing calls to pipsdbm, naming-util and ri-util. cproto-generated files naming.c

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

Based on entity_user_name, but preserves scoping information when needed to avoid ambiguity between two or more variables with the same name.

A variable or function name can be used for an external or static entity in the compilation unit, it can be used as function parameter, and then declared within the function at any scope level.

This function cannot directly be used in an interprocedural setting as it is only related to one module.

It is assumed that no new string is allocated, but a pointer to an existing string is returned.

The current implementation is extremely ineffective, especially for a very unlikely, although mystifying, problem.

FI: this function does not seem to be used in Libs or Passes. Its implementation is based on module_entities(), which is not in ri-util...

No problem in Fortran

Definition at line 68 of file naming.c.

69 {
70  const char* uan = entity_user_name(e);
71 
72  /* No problem in Fortran */
73  if(c_module_p(m)) {
74  list conflicts = module_entities(m);
75 
76  FOREACH(ENTITY, v, conflicts){
77  if(v!=e) {
78  const char* vn = entity_user_name(v);
79  if(same_string_p(uan,vn)) {
80  uan = entity_local_name(e);
81  break;
82  }
83  }
84  }
85  gen_free_list(conflicts);
86  }
87 
88  return (uan);
89 }
list module_entities(entity m)
Return a list of all variables and functions accessible somewhere in a module.
Definition: module.c:85

References c_module_p(), ENTITY, entity_local_name(), entity_user_name(), FOREACH, gen_free_list(), module_entities(), and same_string_p.

Referenced by entity_unambiguous_user_name().

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

◆ entity_unambiguous_user_name()

const char* entity_unambiguous_user_name ( entity  e)

Definition at line 91 of file naming.c.

92 {
94 
96 }
const char * entity_module_unambiguous_user_name(entity e, entity m)
Functions using simultaneously pipsdbm, which is based on strings, and ri-util, which contains basic ...
Definition: naming.c:68

References entity_module_unambiguous_user_name(), and get_current_module_entity().

Referenced by entity_more_or_less_minimal_name().

+ Here is the call graph for this function:
+ Here is the caller 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
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:

◆ language_module_p()

bool language_module_p ( entity  m,
string  lid 
)

FI: does not work with static functions

SG: must check if the ressource exist (not always the case)

SG: be positive ! (needed for Hpfc)

Parameters
lidid

Definition at line 166 of file module.c.

167 {
168  bool c_p = false;
169 
170  if(entity_module_p(m)) {
171  /* FI: does not work with static functions */
172  //string aufn = db_get_memory_resource(DBR_USER_FILE, entity_user_name(m), true);
173  /* SG: must check if the ressource exist (not always the case) */
174  const char* lname= module_local_name(m);
175  if( db_resource_p(DBR_USER_FILE,lname) )
176  {
177  string aufn = db_get_memory_resource(DBR_USER_FILE, module_local_name(m), true);
178  string n = strstr(aufn, lid);
179 
180  c_p = (n!=NULL);
181  }
182  else
183  c_p = true; /* SG: be positive ! (needed for Hpfc)*/
184  }
185  return c_p;
186 }
static int lname(char *s, int look_for_entry)
check for keywords for subprograms return 0 if comment card, 1 if found name and put in arg string.
Definition: split_file.c:283

References db_get_memory_resource(), db_resource_p(), entity_module_p(), lname(), and module_local_name().

+ Here is the call 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
#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
@ 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:

◆ module_declarations()

list module_declarations ( entity  m)

module.c

module.c

Retrieve all declarations linked to a module, but the local variables private to loops. Allocate and build a new list which will have to be freed by the caller.

This function has been implemented twice.

It may be useless because code_declarations() is supposed to contain all module declarations, regardless of where the declarations happens.

FI: maybe we should also look up the declarations in the compilation unit...

Definition at line 58 of file module.c.

59 {
61  if (list_undefined_p(dl))
62  {
65  }
66 
67  /* FI: maybe we should also look up the declarations in the compilation unit... */
68 
69  ifdebug(9) {
70  pips_debug(8, "Current module declarations:\n");
71  print_entities(dl);
72  fprintf(stderr, "\n");
73  }
74 
75  return gen_copy_seq(dl);
76 }
void set_current_module_declarations(list)
Definition: static.c:131
list get_current_module_declarations(void)
Definition: static.c:141
#define list_undefined_p(c)
Return if a list is undefined.
Definition: newgen_list.h:75
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void print_entities(list l)
Definition: entity.c:167
#define code_declarations(x)
Definition: ri.h:784
#define value_code(x)
Definition: ri.h:3067
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

References code_declarations, entity_initial, fprintf(), gen_copy_seq(), get_current_module_declarations(), ifdebug, list_undefined_p, pips_debug, print_entities(), set_current_module_declarations(), and value_code.

Referenced by add_parameter_variable_to_module(), add_private_variable_to_module(), create_parameter_for_new_module(), current_module_declarations(), and module_entities().

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

◆ module_entities()

list module_entities ( entity  m)

Return a list of all variables and functions accessible somewhere in a module.

Make sure you only have entities in list cudl

Definition at line 85 of file module.c.

86 {
89  list mdl = module_declarations(m);
90 
91  pips_assert("compilation unit is an entity list.",
93  pips_assert("initial cudl is an entity list.", entity_list_p(cudl));
94  pips_assert("mdl is an entity list.", entity_list_p(mdl));
95 
96  cudl = gen_nconc(cudl, mdl);
97 
98  /* Make sure you only have entities in list cudl */
99  pips_assert("Final cudl is an entity list.", entity_list_p(cudl));
100 
101  return cudl;
102 }
bool entity_list_p(list el)
Checks that el only contains entity.
Definition: entity.c:1411

References code_declarations, entity_initial, entity_list_p(), gen_copy_seq(), gen_nconc(), module_declarations(), module_entity_to_compilation_unit_entity(), pips_assert, and value_code.

Referenced by entity_module_unambiguous_user_name().

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

◆ module_entity_to_compilation_unit_entity()

entity module_entity_to_compilation_unit_entity ( entity  m)

Retrieve the compilation unit containing a module definition.

The implementation is clumsy.

It would be nice to memoize the information as with get_current_module_entity().

It would be much nicer to keep a resource like INPUT_FILE_NAME, say COMPILATION_UNIT_NAME.

The entity returned may be undefined.

The resource does not always exist.

For Fortran code to start with.

For synthesized code too: initializer, outliner... (although pass outline might build a compilation unit...

Let's assume that synthesized module "foo" has "foo!" a compilation unit name and it never is a static function.

Definition at line 116 of file module.c.

117 {
119 
121  cu = m;
122  else if(!db_resource_p(DBR_USER_FILE, module_local_name(m))) {
123  /* The resource does not always exist.
124  *
125  * For Fortran code to start with.
126  *
127  * For synthesized code too: initializer, outliner... (although
128  * pass outline might build a compilation unit...
129  *
130  * Let's assume that synthesized module "foo" has "foo!" a
131  * compilation unit name and it never is a static function.
132  */
133  string name = strdup(concatenate(entity_name(m), FILE_SEP_STRING, NULL));
134  cu = gen_find_tabulated(name, entity_domain);
135  }
136  else {
137  // string aufn = db_get_memory_resource(DBR_USER_FILE, entity_user_name(m), true);
138  string aufn = db_get_memory_resource(DBR_USER_FILE, module_local_name(m), true);
139  string lufn = strrchr(aufn, '/')+1;
140 
141  if(lufn!=NULL) {
142  string n = strstr(lufn, PP_C_ED);
143  int l = n-lufn;
144  string cun = strndup(lufn, l);
145 
146  if(static_module_name_p(cun)) {
147  string end = strrchr(cun, FILE_SEP_CHAR);
148  *(end+1) = '\0';
150  }
151  else {
152  string ncun = strdup(concatenate(cun, FILE_SEP_STRING, NULL));
154  free(ncun);
155  }
156  free(cun);
157  }
158  else
159  pips_internal_error("Not implemented yet");
160  }
161  pips_assert("If defined, cu is a compilation unit",
163  return cu;
164 }
bool static_module_name_p(const char *name)
Check if the given name is a static module name.
Definition: entity_names.c:122
char end
Definition: gtk_status.c:82
#define pips_internal_error
Definition: misc-local.h:149
#define FILE_SEP_CHAR
Definition: naming-local.h:38
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
bool compilation_unit_entity_p(entity e)
Check if the given module entity is a compilation unit.
Definition: module.c:87
#define entity_name(x)
Definition: ri.h:2790
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26

References compilation_unit_entity_p(), concatenate(), db_get_memory_resource(), db_resource_p(), end, entity_domain, entity_name, entity_undefined, entity_undefined_p, FILE_SEP_CHAR, FILE_SEP_STRING, free(), gen_find_tabulated(), local_name_to_top_level_entity(), module_local_name(), pips_assert, pips_internal_error, static_module_name_p(), strdup(), and strndup().

Referenced by AddEntityToModuleCompilationUnit(), ensure_comment_consistency(), module_entities(), outliner_parameters(), promote_local_entities(), and update_unstructured_declarations().

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

◆ module_name_to_input_file_name()

string module_name_to_input_file_name ( const char *  module_name)

To be checked for static functions...

Parameters
module_nameodule_name

Definition at line 376 of file module.c.

377 {
379  pips_assert("only for C modules\n", entity_undefined_p(e) || c_module_p(e));
380 
381  // Should only be called for C modules.
382  string input_file_name = string_undefined;
383 
384  // The guard may not be sufficient...
385  // and this may crash in db_get_memory_resource()
386  if(db_resource_p(DBR_USER_FILE, module_name)) {
387  string source_file_name =
388  db_get_memory_resource(DBR_USER_FILE, module_name, true);
389  string simpler_file_name = pips_basename(source_file_name, PP_C_ED);
390 
391  // It is not clear how robust it is going to be
392  // when file name conflicts occur.
393  (void) asprintf(&input_file_name, "%s/" WORKSPACE_SRC_SPACE "/%s.c",
394  db_get_current_workspace_directory(), simpler_file_name);
395  free(simpler_file_name);
396  }
397 
398  return input_file_name;
399 }
#define WORKSPACE_SRC_SPACE
Definition: pipsdbm-local.h:32
string db_get_current_workspace_directory(void)
Definition: workspace.c:96

References asprintf, c_module_p(), db_get_current_workspace_directory(), db_get_memory_resource(), db_resource_p(), entity_undefined_p, free(), module_name(), module_name_to_entity(), pips_assert, pips_basename(), string_undefined, and WORKSPACE_SRC_SPACE.

+ Here is the call graph for this function:

◆ module_to_all_declarations()

list module_to_all_declarations ( entity  m)

Definition at line 323 of file module.c.

324 {
326  bool c_module_p(entity);
327 
328  if(c_module_p(m)) {
329  //const char* module_name = entity_user_name(m);
330  const char* module_name = entity_local_name(m);
331  statement s = (statement) db_get_memory_resource(DBR_PARSED_CODE, module_name, true);
333 
334  FOREACH(ENTITY, e, sdl) {
335  if(!entity_is_argument_p(e, dl))
336  dl = gen_nconc(dl, CONS(ENTITY, e, NIL));
337  }
338  gen_free_list(sdl);
339  }
340 
341  return dl;
342 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
list statement_to_declarations(void *)
Get a list of all variables declared recursively within a statement.
Definition: statement.c:3253

References c_module_p(), code_declarations, CONS, db_get_memory_resource(), ENTITY, entity_initial, entity_is_argument_p(), entity_local_name(), FOREACH, gen_copy_seq(), gen_free_list(), gen_nconc(), module_name(), NIL, statement_to_declarations(), and value_code.

Referenced by all_data_to_precondition(), and generic_module_initial_pointer_values().

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

◆ print_arguments()

void print_arguments ( list  args)
Parameters
argsrgs

Definition at line 228 of file naming.c.

229 {
231 }
void print_homogeneous_arguments(list args, const char *variable_name(entity))
Functions dealing with entity lists.
Definition: arguments.c:54
const char * entity_minimal_name(entity e)
Do preserve scope informations.
Definition: naming.c:214

References entity_minimal_name(), and print_homogeneous_arguments().

Referenced by ComputeAddresses(), fuse_sequences_in_unstructured(), MakeEntryCommon(), recompute_loop_transformer(), TestDependence(), and update_common_layout().

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

◆ RemoveEntityFromCompilationUnit()

void RemoveEntityFromCompilationUnit ( entity  e,
entity  cu 
)

Remove an entity from the current's module compilation unit declarations.

Parameters
[in]eis the entity to remove
[in]cuis the compilation unit
Parameters
cuu

Definition at line 265 of file module.c.

265  {
267  const char* cum = module_local_name(cu);
268  if( c_module_p(cu) ) {
269  if(!db_resource_required_or_available_p(DBR_CODE,cum))
270  {
271  bool controlizer(const char*);
276  controlizer(cum);
277  if(!entity_undefined_p(tmp))
281  }
282  s=(statement)db_get_memory_resource(DBR_CODE,cum,true);
283  }
284 
285  // Remove entity from global declaration lists
287  // FIXME : s is only defined for c_module !!
289 
291  if( c_module_p(cu) ) {
292  module_reorder(s);
293  db_put_or_update_memory_resource(DBR_CODE,cum,s,true);
294  db_touch_resource(DBR_CODE,cum);
295  }
296 }
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
statement remove_declaration_statement(statement, entity)
Declarations are not only lists of entities, but also statement to carry the line number,...
Definition: statement.c:2966
#define statement_declarations(x)
Definition: ri.h:2460

References c_module_p(), controlizer(), db_get_memory_resource(), db_put_or_update_memory_resource(), db_resource_required_or_available_p(), db_touch_resource(), entity_declarations, entity_undefined_p, gen_remove(), get_current_module_entity(), get_current_module_statement(), module_local_name(), module_reorder(), remove_declaration_statement(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_declarations, statement_undefined, and statement_undefined_p.

+ 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

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:

◆ string_to_entities()

list string_to_entities ( const char *  str,
const char *  seed,
entity  module 
)

split a string using seed as separator and call string_to_entity on each chunk

Parameters
strtr
seedeed
moduleodule

Definition at line 276 of file naming.c.

276  {
277  list strings = strsplit(str,seed);
278  list entities = NIL;
279  FOREACH(STRING,s,strings) {
281  if(!entity_undefined_p(e)) {
282  entities = CONS(ENTITY,
283  e,
284  entities);
285  }
286  }
287  gen_map(free,strings);
288  gen_free_list(strings);
289  return gen_nreverse(entities);
290 
291 }
#define STRING(x)
Definition: genC.h:87
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
entity string_to_entity(const char *s, entity module)
very simple conversion from string to expression only handles entities and numeric values at the time...
Definition: naming.c:237
list strsplit(const char *, const char *)
Definition: string.c:318

References CONS, ENTITY, entity_undefined_p, FOREACH, free(), gen_free_list(), gen_map(), gen_nreverse(), module, NIL, STRING, string_to_entity(), and strsplit().

+ Here is the call graph for this function:

◆ string_to_entity()

entity string_to_entity ( const char *  s,
entity  module 
)

very simple conversion from string to expression only handles entities and numeric values at the time being

try float conversion

no negative integer entity in pips

first find all relevant entities

this an heuristic to find the one with a suiting scope error prone

try at the compilation unit level

try at top level

Parameters
moduleodule

Definition at line 237 of file naming.c.

238 {
239  if(empty_string_p(s)) return entity_undefined;
240 
241  /* try float conversion */
242  string endptr;
243  const char *module_name=module_local_name(module);
244  long int l = strtol(s,&endptr,10);
245  if(!*endptr) {
246  if(l>=0)
247  return int_to_entity(l);
248  else /* no negative integer entity in pips */
249  return entity_undefined;
250  }
251  float f = strtof(s,&endptr);
252  if(!*endptr) return float_to_entity(f);
253 
254  entity candidate = entity_undefined;
255  /* first find all relevant entities */
257  {
258  /* this an heuristic to find the one with a suiting scope
259  * error prone*/
261  if(entity_undefined_p(candidate) ||
262  strlen(entity_name(candidate)) > strlen(entity_name(e)))
263  candidate=e;
264  }
265  /* try at the compilation unit level */
266  if(entity_undefined_p(candidate))
268  /* try at top level */
269  if(entity_undefined_p(candidate))
270  candidate=FindEntity(TOP_LEVEL_MODULE_NAME,s);
271  return candidate;
272 }
entity float_to_entity(float c)
Definition: constant.c:430
entity int_to_entity(_int c)
Definition: constant.c:453
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350
bool empty_string_p(const char *s)
Definition: entity_names.c:239
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503

References compilation_unit_of_module(), empty_string_p(), ENTITY, entity_declarations, entity_name, entity_undefined, entity_undefined_p, entity_user_name(), f(), FindEntity(), float_to_entity(), FOREACH, int_to_entity(), module, module_local_name(), module_name(), same_string_p, and TOP_LEVEL_MODULE_NAME.

Referenced by do_solve_hardware_constraints(), string_to_entities(), and string_to_expression().

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

◆ string_to_expression()

expression string_to_expression ( const char *  s,
entity  module 
)

expressions.c

expressions.c

try to parse s in the context of module module only simple expressions are found

try to find simple expression

unary operators

inary operators

Parameters
moduleodule

Definition at line 50 of file expressions.c.

51 {
53  if(entity_undefined_p(e)) {
54  /* try to find simple expression */
55  /* unary operators */
56  for(const char *iter = s ; *iter ; iter++) {
57  if(isspace(*iter)) continue;
58  if(*iter=='-') {
59  expression etmp = string_to_expression(iter+1, module);
60  if(!expression_undefined_p(etmp)) {
62  etmp);
63  }
64  }
65  }
66 
67  /*binary operators*/
69  for(int i=0; i < (int) (sizeof(seeds)/sizeof(seeds[0])); i++) {
70  char *where = strchr(s,seeds[i][0]);
71  if(where) {
72  char * head = strdup(s);
73  char * tail = head + (where -s) +1 ;
74  head[where-s]='\0';
77  free(head);
79  return MakeBinaryCall(
80  entity_intrinsic(seeds[i]),
81  e0,
82  e1
83  );
84  }
85  else {
86  free_expression(e0);
87  free_expression(e1);
88  }
89  }
90  }
91  return expression_undefined;
92  }
93  else
94  return entity_to_expression(e);
95 }
void free_expression(expression p)
Definition: ri.c:853
void const char const char const int
expression string_to_expression(const char *s, entity module)
Functions using simultaneously pipsdbm, which is based on strings, and ri-util, which contains basic ...
Definition: expressions.c:50
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define DIVIDE_OPERATOR_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342
#define expression_undefined
Definition: ri.h:1223
#define expression_undefined_p(x)
Definition: ri.h:1224

References DIVIDE_OPERATOR_NAME, entity_intrinsic(), entity_to_expression(), entity_undefined_p, expression_undefined, expression_undefined_p, free(), free_expression(), int, MakeBinaryCall(), MakeUnaryCall(), MINUS_OPERATOR_NAME, module, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, strdup(), string_to_entity(), and UNARY_MINUS_OPERATOR_NAME.

Referenced by loop_expansion(), loop_expansion_init(), maxima_simplify(), and string_to_expressions().

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

◆ string_to_expressions()

list string_to_expressions ( const char *  str,
const char *  seed,
entity  module 
)

split a string using seed as separator and call string_to_expression on each chunk

Parameters
strtr
seedeed
moduleodule

Definition at line 98 of file expressions.c.

98  {
99  list strings = strsplit(str,seed);
100  list expressions = NIL;
101  FOREACH(STRING,s,strings) {
103  if(!expression_undefined_p(expr)) {
104  expressions = CONS(EXPRESSION,
105  expr,
106  expressions);
107  }
108  }
109  gen_map(free,strings);
110  gen_free_list(strings);
111  return gen_nreverse(expressions);
112 }
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References CONS, EXPRESSION, expression_undefined_p, FOREACH, free(), gen_free_list(), gen_map(), gen_nreverse(), module, NIL, STRING, string_to_expression(), and strsplit().

Referenced by symbolic_tiling().

+ 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(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
extern

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

Definition at line 158 of file misc_paf_utils.c.

Referenced by make_nsp_entity().

◆ Gcount_nub

int Gcount_nub
extern

Definition at line 160 of file misc_paf_utils.c.

Referenced by make_nub_entity().