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

Go to the source code of this file.

Functions

string build_new_top_level_module_name (const char *prefix, bool prevent_suffix)
 Get a new name for a module built from a prefix. More...
 
bool static_module_p (entity e)
 Check if the given module entity is a static module. More...
 
bool compilation_unit_entity_p (entity e)
 Check if the given module entity is a compilation unit. More...
 
bool variable_in_module_p2 (entity v, entity m)
 
void variable_declaration_verify (reference ref)
 
void symbolic_constant_declaration_verify (call c)
 
void add_non_declared_reference_to_declaration (reference ref)
 
void add_symbolic_constant_to_declaration (call c)
 
bool variable_declaration_coherency_p (entity module, statement st)
 
static string get_end_of_header_comments (string the_comments)
 Look for the end of header comments: More...
 
sentence get_header_comments (entity module)
 Get the header comments (before PROGRAM, FUNCTION,...) from the text declaration: More...
 
sentence get_declaration_comments (entity module)
 Get all the declaration comments, that are comments from the PROGRAM, FUNCTION,... More...
 
list module_formal_parameters (entity func)
 list module_formal_parameters(entity func) input : an entity representing a function. More...
 
int module_to_declaration_length (entity func)
 Number of user declaration lines for a module. More...
 
list declaration_supporting_references (list dl)
 Find all references in the declaration list. More...
 
list module_all_declarations (entity m)
 The function itself is not in its declarations. More...
 
static bool x_language_module_p (entity m, unsigned int x)
 Simplified versions of c_module_p() and fortran_module_p(). More...
 
bool c_language_module_p (entity m)
 
bool fortran_language_module_p (entity m)
 
bool fortran95_language_module_p (entity m)
 
entity generic_function_to_return_value (entity m, bool safe_p)
 Returns the entity rv that carries the value returned by module m, when m is not a C void function or a Fortran subroutine. More...
 
entity function_to_return_value (entity m)
 Returns the entity rv that carries the value returned by module m, when m is not a C void function or a Fortran subroutine. More...
 
entity any_function_to_return_value (entity m)
 Same as function_to_return_value(), but returns value_undefined when m is a C void function or a Fortran subroutine. More...
 
bool return_value_p (entity v)
 Is entity v the return value of some function? More...
 
bool function_return_value_p (entity v, entity f)
 Is entity v the return value of function f? More...
 
bool void_function_p (entity m)
 Check if m is a C void function or a Fortran subroutine. More...
 
list string_to_user_modules (const char *s)
 Build a list of functions from a string s containing SPACE separated function names. More...
 

Variables

static bool module_coherent_p =true
 To have asprintf(): More...
 
static entity checked_module = entity_undefined
 

Function Documentation

◆ add_non_declared_reference_to_declaration()

void add_non_declared_reference_to_declaration ( reference  ref)

type t = entity_type(var);

Parameters
refef

Definition at line 142 of file module.c.

143 {
145  /* type t = entity_type(var); */
146 
148  {
150  code ce = value_code(val);
151  list decl = code_declarations (ce);
153  string name=strdup(concatenate(
156  entity_local_name(var),
157  NULL));
159  {
160  pips_debug(8, "ajout de la variable symbolique %s au module %s\n",
162 
163  ent = make_entity(name,
164  copy_type(entity_type(var)),
166  copy_value(entity_initial(var)));
167 
168  code_declarations(ce) = gen_nconc(decl,
169  CONS(ENTITY, ent, NIL));
170  }
171  }
172 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
value copy_value(value p)
VALUE.
Definition: ri.c:2784
storage copy_storage(storage p)
STORAGE.
Definition: ri.c:2228
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define make_entity(n, t, s, i)
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
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool variable_in_module_p2(entity v, entity m)
Definition: module.c:94
static entity checked_module
Definition: module.c:41
#define reference_variable(x)
Definition: ri.h:2326
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794
#define code_declarations(x)
Definition: ri.h:784
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define value_code(x)
Definition: ri.h:3067
#define entity_type(x)
Definition: ri.h:2792
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define entity_initial(x)
Definition: ri.h:2796
char * strdup()
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References checked_module, code_declarations, concatenate(), CONS, copy_storage(), copy_type(), copy_value(), ENTITY, entity_domain, entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, gen_find_tabulated(), gen_nconc(), make_entity, module_local_name(), MODULE_SEP_STRING, NIL, pips_debug, ref, reference_variable, strdup(), value_code, and variable_in_module_p2().

Referenced by variable_declaration_coherency_p().

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

◆ add_symbolic_constant_to_declaration()

void add_symbolic_constant_to_declaration ( call  c)

Definition at line 175 of file module.c.

176 {
179  code ce = value_code(val);
180  list decl = code_declarations (ce);
184  entity_local_name(call_function(c)), NULL));
185  if ((ent = gen_find_tabulated(name,entity_domain)) == entity_undefined) {
186  ifdebug(8)
187  (void) fprintf(stderr,"ajout de la variable symbolique %s au module %s\n",
190 
191  ent = make_entity( name,
195 
196  code_declarations(ce) = gen_nconc(decl,
197  CONS(ENTITY, ent, NIL));
198  }
199  }
200 }
#define call_function(x)
Definition: ri.h:709
#define value_symbolic_p(x)
Definition: ri.h:3068
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

References call_function, checked_module, code_declarations, concatenate(), CONS, copy_storage(), copy_type(), copy_value(), ENTITY, entity_domain, entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, fprintf(), gen_find_tabulated(), gen_nconc(), ifdebug, make_entity, module_local_name(), MODULE_SEP_STRING, NIL, strdup(), value_code, and value_symbolic_p.

Referenced by variable_declaration_coherency_p().

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

◆ any_function_to_return_value()

entity any_function_to_return_value ( entity  m)

Same as function_to_return_value(), but returns value_undefined when m is a C void function or a Fortran subroutine.

Definition at line 516 of file module.c.

517 {
518  return generic_function_to_return_value(m, false);
519 }
entity generic_function_to_return_value(entity m, bool safe_p)
Returns the entity rv that carries the value returned by module m, when m is not a C void function or...
Definition: module.c:469

References generic_function_to_return_value().

Referenced by filter_formal_out_context_according_to_formal_in_context(), points_to_cell_translation(), and points_to_set_block_projection().

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

◆ build_new_top_level_module_name()

string build_new_top_level_module_name ( const char *  prefix,
bool  prevent_suffix 
)

Get a new name for a module built from a prefix.

module.c

Parameters
prefixis the prefix string
prevent_suffixis a flag that prevent from adding a "_0" suffix if possible
Returns
the first module name (malloc'd string) of the form "<prefix>_<integer>" that do not correspond to an existing module with integer starting at 0
Parameters
prefixrefix
prevent_suffixrevent_suffix

Definition at line 55 of file module.c.

55  {
56  string name;
57  int version = 0;
58 
59  if(prevent_suffix) {
60  name = strdup(prefix);
61  }
62 
63  for(;;) {
64  if(!prevent_suffix || version!=0)
65  asprintf(&name, "%s_%d", prefix, version);
66 
68  break;
69 
70  free(name);
71  version++;
72  }
73 
74  return name;
75 }
void free(void *)
#define asprintf
Definition: misc-local.h:225
static const char * prefix
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

References asprintf, entity_undefined, free(), module_name_to_entity(), prefix, and strdup().

Referenced by build_outline_name(), create_new_module_entity(), gpu_ify_statement(), gpu_memory_apply(), outline_stmts_between_pragmas_in_sequence(), and scalopragma().

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

◆ c_language_module_p()

bool c_language_module_p ( entity  m)

Definition at line 447 of file module.c.

448 {
450 }
static bool x_language_module_p(entity m, unsigned int x)
Simplified versions of c_module_p() and fortran_module_p().
Definition: module.c:432
@ is_language_c
Definition: ri.h:1567

References is_language_c, and x_language_module_p().

Referenced by constraints_to_loop_bound(), data_to_prec_for_variables(), generic_reference_to_transformer(), make_bound_expression(), make_constraint_expression(), partial_eval_call(), and precondition_intra_to_inter().

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

◆ compilation_unit_entity_p()

bool compilation_unit_entity_p ( entity  e)

Check if the given module entity is a compilation unit.

Definition at line 87 of file module.c.

87  {
88  if (e == entity_undefined) return false;
90 }
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56

References compilation_unit_p(), entity_name, and entity_undefined.

Referenced by c_text_related_entities(), declaration_to_post_pv(), explicit_extern_entity_p(), extern_entity_p(), filtered_declaration_list(), find_enum_of_member(), FindOrCreateCurrentEntity(), generic_function_to_return_value(), linearize_array_generic(), module_entity_to_compilation_unit_entity(), and UpdateEntity().

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

◆ declaration_supporting_references()

list declaration_supporting_references ( list  dl)

Find all references in the declaration list.

FI: for efficiency, the type cache used in type_supporting_references() should be moved up here

FI: we should also look up the initial values

Parameters
dll

Definition at line 392 of file module.c.

393 {
394  list srl = NIL;
395 
396  /* FI: for efficiency, the type cache used in
397  type_supporting_references() should be moved up here */
398  FOREACH(ENTITY, v,dl)
399  {
400  if( ! entity_special_area_p(v))
401  {
402  type t = entity_type(v);
403  /* FI: we should also look up the initial values */
404  srl = type_supporting_references(srl, t);
405  }
406  }
407 
408  return srl;
409 }
#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
bool entity_special_area_p(entity e)
Definition: area.c:154
list type_supporting_references(list, type)
Definition: type.c:4700

References ENTITY, entity_special_area_p(), entity_type, FOREACH, NIL, and type_supporting_references().

Referenced by UseFormalArguments().

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

◆ fortran95_language_module_p()

bool fortran95_language_module_p ( entity  m)

Definition at line 457 of file module.c.

458 {
460 }
@ is_language_fortran95
Definition: ri.h:1568

References is_language_fortran95, and x_language_module_p().

Referenced by data_to_prec_for_variables().

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

◆ fortran_language_module_p()

bool fortran_language_module_p ( entity  m)

Definition at line 452 of file module.c.

453 {
455 }
@ is_language_fortran
Definition: ri.h:1566

References is_language_fortran, and x_language_module_p().

Referenced by arguments_are_something(), data_to_prec_for_variables(), partial_eval_call(), and precondition_intra_to_inter().

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

◆ function_return_value_p()

bool function_return_value_p ( entity  v,
entity  f 
)

Is entity v the return value of function f?

Definition at line 529 of file module.c.

530 {
531  bool return_p = strcmp(entity_module_name(v), entity_user_name(v))==0
532  && strcmp(entity_module_name(v), entity_user_name(f))==0;
533  return return_p;
534 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092

References entity_module_name(), entity_user_name(), and f().

+ Here is the call graph for this function:

◆ function_to_return_value()

entity function_to_return_value ( entity  m)

Returns the entity rv that carries the value returned by module m, when m is not a C void function or a Fortran subroutine.

rv is supposed to be allocated early by the parser.

Definition at line 509 of file module.c.

510 {
511  return generic_function_to_return_value(m, true);
512 }

References generic_function_to_return_value().

Referenced by C_MakeReturnStatement(), Generate_C_ReturnStatement(), intrinsic_call_to_points_to(), module_to_value_mappings(), points_to_function_projection(), user_call_to_points_to_sinks(), and words_goto_label().

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

◆ generic_function_to_return_value()

entity generic_function_to_return_value ( entity  m,
bool  safe_p 
)

Returns the entity rv that carries the value returned by module m, when m is not a C void function or a Fortran subroutine.

If safe_p, abort if the function is void. Otherwise, return an undefined_entity.

rv is supposed to be allocated early by the parser.

Parameters
safe_pafe_p

Definition at line 469 of file module.c.

470 {
474  if(safe_p)
475  pips_user_error("A return value is requested for compilation unit"
476  " \"%s\".\n", entity_user_name(m));
477  else
478  rv = entity_undefined;
479  }
480  else if(type_functional_p(ft)) {
483  if(type_void_p(r)) {
484  if(safe_p)
485  pips_user_error("A return value is used for void function \"%s\".\n",
486  entity_user_name(m));
487  else
488  rv = entity_undefined;
489  }
490  else {
491  const char* mn = entity_local_name(m);
492  rv = FindEntity(mn, mn);
493 
494  pips_assert("rv is defined", entity_defined_p(rv));
495  }
496  }
497  else
498  pips_internal_error("Return value requested for non-functional object"
499  " \"%s\".\n", entity_user_name(m));
500 
501  return rv;
502 }
bool entity_defined_p(entity p)
Definition: ri.c:2534
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define pips_user_error
Definition: misc-local.h:147
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
bool compilation_unit_entity_p(entity e)
Check if the given module entity is a compilation unit.
Definition: module.c:87
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
type compute_basic_concrete_type(type)
computes a new type which is the basic concrete type of the input type (this new type is not stored i...
Definition: type.c:3556
#define type_functional_p(x)
Definition: ri.h:2950
#define functional_result(x)
Definition: ri.h:1444
#define type_functional(x)
Definition: ri.h:2952
#define type_void_p(x)
Definition: ri.h:2959

References compilation_unit_entity_p(), compute_basic_concrete_type(), entity_basic_concrete_type(), entity_defined_p(), entity_local_name(), entity_undefined, entity_user_name(), f(), FindEntity(), functional_result, pips_assert, pips_internal_error, pips_user_error, type_functional, type_functional_p, and type_void_p.

Referenced by any_function_to_return_value(), and function_to_return_value().

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

◆ get_declaration_comments()

sentence get_declaration_comments ( entity  module)

Get all the declaration comments, that are comments from the PROGRAM, FUNCTION,...

stuff up to the end of the declarations:

Get the textual header:

Now, gather all the comments:

Add it to the extracted_comments:

There is no newline, so this is the last comment line:

Build a string that holds the comment:

Have a look to next line if any...

Parameters
moduleodule

Definition at line 275 of file module.c.

276 {
277  string comment;
278  string old_extracted_comments;
279  string extracted_comments = strdup("");
280  /* Get the textual header: */
281  string the_comments = code_decls_text(entity_code(module));
282 
283  comment = get_end_of_header_comments(the_comments);
284  /* Now, gather all the comments: */
285  for(;;) {
286  string next_line;
287  if (*comment == '\0')
288  break;
289  next_line = strchr(comment, '\n');
290  if (comment_string_p(comment)) {
291  string the_comment;
292  /* Add it to the extracted_comments: */
293  if (next_line == NULL)
294  /* There is no newline, so this is the last
295  comment line: */
296  the_comment = strdup(comment);
297  else {
298  /* Build a string that holds the comment: */
299  the_comment = (string) malloc(next_line - comment + 2);
300  (void) strncpy(the_comment, comment, next_line - comment + 1);
301  the_comment[next_line - comment + 1] = '\0';
302  }
303  old_extracted_comments = extracted_comments;
304  extracted_comments = strdup(concatenate(old_extracted_comments,
305  the_comment,
306  NULL));
307  free(old_extracted_comments);
308  free(the_comment);
309  }
310  /* Have a look to next line if any... */
311  if (next_line == NULL)
312  break;
313  comment = next_line + 1;
314  }
315 
316  return make_sentence(is_sentence_formatted, extracted_comments);
317 }
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
Definition: freia_spoc.c:52
void * malloc(YYSIZE_T)
char * string
STRING.
Definition: newgen_types.h:39
static char * module
Definition: pips.c:74
code entity_code(entity e)
Definition: entity.c:1098
static string get_end_of_header_comments(string the_comments)
Look for the end of header comments:
Definition: module.c:224
bool comment_string_p(const string)
Test if a string can be a Fortran 77 comment:
Definition: util.c:159
#define code_decls_text(x)
Definition: ri.h:786
@ is_sentence_formatted
Definition: text.h:57

References code_decls_text, comment(), comment_string_p(), concatenate(), entity_code(), free(), get_end_of_header_comments(), is_sentence_formatted, make_sentence(), malloc(), module, and strdup().

Referenced by ensure_comment_consistency().

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

◆ get_end_of_header_comments()

static string get_end_of_header_comments ( string  the_comments)
static

Look for the end of header comments:

If we are at the end of string or the line is not a comment (it must be a PROGRAM, FUNCTION,... line), it is the end of the header comment:

Look for next line

No return char: it is the last line and it is a comment... Should never happend in a real program without any useful header!

Definition at line 224 of file module.c.

225 {
226  string end_of_comment = the_comments;
227 
228  for(;;) {
229  string next_line;
230  /* If we are at the end of string or the line is not a comment
231  (it must be a PROGRAM, FUNCTION,... line), it is the end of
232  the header comment: */
233  if (!comment_string_p(end_of_comment))
234  break;
235 
236  if ((next_line = strchr(end_of_comment, '\n')) != NULL
237  || *end_of_comment != '\0')
238  /* Look for next line */
239  end_of_comment = next_line + 1;
240  else
241  /* No return char: it is the last line and it is a
242  comment... Should never happend in a real program
243  without any useful header! */
244  pips_assert("get_end_of_header_comments found only comments!",
245  false);
246  }
247  return end_of_comment;
248 }

References comment_string_p(), and pips_assert.

Referenced by get_declaration_comments(), and get_header_comments().

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

◆ get_header_comments()

sentence get_header_comments ( entity  module)

Get the header comments (before PROGRAM, FUNCTION,...) from the text declaration:

Get the textual header:

Keep room for the trailing '\0':

Parameters
moduleodule

Definition at line 254 of file module.c.

255 {
256  int length;
257  string end_of_comment;
258  string extracted_comment;
259  /* Get the textual header: */
260  string the_comments = code_decls_text(entity_code(module));
261 
262  end_of_comment = get_end_of_header_comments(the_comments);
263  /* Keep room for the trailing '\0': */
264  length = end_of_comment - the_comments;
265  extracted_comment = (string) malloc(length + 1);
266  (void) strncpy(extracted_comment, the_comments, length);
267  extracted_comment[length] = '\0';
268  return make_sentence(is_sentence_formatted, extracted_comment);
269 }

References code_decls_text, entity_code(), get_end_of_header_comments(), is_sentence_formatted, make_sentence(), malloc(), and module.

Referenced by ensure_comment_consistency().

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

◆ module_all_declarations()

list module_all_declarations ( entity  m)

The function itself is not in its declarations.

Maybe, it should be changed in the parser?

A new list is allocated to avoid sharing with code_declarations.

Definition at line 419 of file module.c.

420 {
422  return dl;
423 }
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define entity_declarations(e)
MISC: newgen shorthands.

References CONS, ENTITY, entity_declarations, and gen_copy_seq().

Referenced by UseFormalArguments().

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

◆ module_formal_parameters()

list module_formal_parameters ( entity  func)

list module_formal_parameters(entity func) input : an entity representing a function.

output : the ordered list (of entities) of parameters of the function "func". modifies : nothing. comment : Made from "entity_to_formal_integer_parameters()" that considers only integer variables.

Dummy parameters should have been filtered out of the declarations by the parser, but let's be careful here. As a consequence, dummy parameters cannot be retrieved, except thru the type.

Parameters
funcunc

Definition at line 327 of file module.c.

328 {
329  list formals = NIL;
330  list decl = list_undefined;
331 
332  pips_assert("func must be a module",entity_module_p(func));
333 
334  decl = code_declarations(entity_code(func));
335  FOREACH(ENTITY, e, decl)
336  {
337  /* Dummy parameters should have been filtered out of the
338  declarations by the parser, but let's be careful here. As a
339  consequence, dummy parameters cannot be retrieved, except
340  thru the type. */
344  formals = CONS(ENTITY, e, formals);
345  }
346 
347  return gen_nreverse(formals);
348 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
bool dummy_parameter_entity_p(entity p)
is p a dummy parameter?
Definition: entity.c:1941
bool entity_module_p(entity e)
Definition: entity.c:683
#define storage_formal_p(x)
Definition: ri.h:2522
#define value_reference_p(x)
Definition: ri.h:3083

References code_declarations, CONS, dummy_parameter_entity_p(), ENTITY, entity_code(), entity_initial, entity_module_p(), entity_storage, FOREACH, gen_nreverse(), list_undefined, NIL, pips_assert, storage_formal_p, and value_reference_p.

Referenced by inline_expression_call(), interprocedural_mapping(), module_initial_parameter_pv(), normalize_microcode_anotate(), sort_parameters(), translate_arguments(), xml_FormalVariables(), xml_ParameterUseToArrayBound(), and xml_TaskParameters().

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

◆ module_to_declaration_length()

int module_to_declaration_length ( entity  func)

Number of user declaration lines for a module.

Is it allowed? The declaration text may be destroyed or may not exist when a module is synthesized or heavily transformed.

Entity func has not been parsed yet

Parameters
funcunc

Definition at line 352 of file module.c.

353 {
354  value v = entity_initial(func);
355  code c = code_undefined;
356  int length = 0;
357 
358  if(!value_undefined_p(v)) {
359  if(value_code_p(v)) {
360  string s = string_undefined;
361 
362  c = value_code(v);
363  s = code_decls_text(c);
364  if(string_undefined_p(s)) {
365  /* Is it allowed? The declaration text may be destroyed or
366  * may not exist when a module is synthesized or heavily
367  * transformed.
368  */
369  length = 0;
370  }
371  else {
372  char l;
373  while((l=*s++)!= '\0')
374  if(l=='\n')
375  length++;
376  }
377  }
378  else {
379  pips_internal_error("Entity %s is not a module",
380  entity_name(func));
381  }
382  }
383  else {
384  /* Entity func has not been parsed yet */
385  length = -1;
386  }
387 
388  return length;
389 }
#define string_undefined
Definition: newgen_types.h:40
#define string_undefined_p(s)
Definition: newgen_types.h:41
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_code_p(x)
Definition: ri.h:3065
#define code_undefined
Definition: ri.h:757

References code_decls_text, code_undefined, entity_initial, entity_name, pips_internal_error, string_undefined, string_undefined_p, value_code, value_code_p, and value_undefined_p.

Referenced by make_filtered_dg_or_dvdg(), and prettyprint_dependence_graph().

+ Here is the caller graph for this function:

◆ return_value_p()

bool return_value_p ( entity  v)

Is entity v the return value of some function?

Definition at line 522 of file module.c.

523 {
524  bool return_p = strcmp(entity_module_name(v), entity_user_name(v))==0;
525  return return_p;
526 }

References entity_module_name(), and entity_user_name().

+ Here is the call graph for this function:

◆ static_module_p()

bool static_module_p ( entity  e)

Check if the given module entity is a static module.

Definition at line 80 of file module.c.

80  {
82 }
bool static_module_name_p(const char *name)
Check if the given name is a static module name.
Definition: entity_names.c:122

References entity_name, and static_module_name_p().

Referenced by c_text_related_entities(), CreateEntityFromLocalNameAndPrefix(), CreateMemberScope(), FindEntityFromLocalNameAndPrefixAndScope(), FindOrCreateCurrentEntity(), sentence_head(), and sentence_tail().

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

◆ string_to_user_modules()

list string_to_user_modules ( const char *  s)

Build a list of functions from a string s containing SPACE separated function names.

Beware of ambiguities that static function names may cause.

See also string_to_entities() and a similar piece of code in inlining.c that was used to code this function.

FI: warning at a very low level, with no information about the context. Might be better to return list_undefined on a conversion failure?

Definition at line 562 of file module.c.

563 {
564  list ml = NIL; // module list
565  string ds = strdup(s);
566 
567  string c_name= NULL;
568  for(c_name = strtok(ds," ") ;
569  c_name ;
570  c_name=strtok(NULL," ") ) {
572  if(entity_undefined_p(m))
573  /* FI: warning at a very low level, with no information about
574  the context. Might be better to return list_undefined on a
575  conversion failure? */
576  pips_user_warning("No function found for \"%s\".\n", c_name);
577  else
578  ml = CONS(ENTITY, m, ml);
579  }
580  free(ds);
581  return ml;
582 }
#define pips_user_warning
Definition: misc-local.h:146
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
#define entity_undefined_p(x)
Definition: ri.h:2762

References CONS, ENTITY, entity_undefined_p, free(), local_name_to_top_level_entity(), NIL, pips_user_warning, and strdup().

Referenced by loop_fully_unrollable_p().

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

◆ symbolic_constant_declaration_verify()

void symbolic_constant_declaration_verify ( call  c)

Definition at line 128 of file module.c.

129 {
130 
133  { module_coherent_p = false;
134  ifdebug(4) fprintf(stderr,
135  "variable non declaree %s\n",
137  }
138  }
139 }
static bool module_coherent_p
To have asprintf():
Definition: module.c:40

References call_function, checked_module, entity_initial, entity_name, fprintf(), ifdebug, module_coherent_p, value_symbolic_p, and variable_in_module_p2().

+ Here is the call graph for this function:

◆ variable_declaration_coherency_p()

bool variable_declaration_coherency_p ( entity  module,
statement  st 
)
Parameters
moduleodule
stt

Definition at line 203 of file module.c.

204 {
205  module_coherent_p = true;
209  gen_true,
211  module_coherent_p = true;
213  call_domain,
214  gen_true,
217  return module_coherent_p;
218 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
void add_non_declared_reference_to_declaration(reference ref)
Definition: module.c:142
void add_symbolic_constant_to_declaration(call c)
Definition: module.c:175
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References add_non_declared_reference_to_declaration(), add_symbolic_constant_to_declaration(), call_domain, checked_module, entity_undefined, gen_multi_recurse(), gen_true(), module, module_coherent_p, and reference_domain.

Referenced by wp65().

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

◆ variable_declaration_verify()

void variable_declaration_verify ( reference  ref)
Parameters
refef

Definition at line 116 of file module.c.

117 {
118 
120  { module_coherent_p = false;
121  fprintf(stderr,
122  "variable non declaree %s\n",
124  }
125 }

References checked_module, entity_name, fprintf(), module_coherent_p, ref, reference_variable, and variable_in_module_p2().

+ Here is the call graph for this function:

◆ variable_in_module_p2()

bool variable_in_module_p2 ( entity  v,
entity  m 
)

Definition at line 94 of file module.c.

97 {
98  bool in_module_1 =
101 
102  bool in_module_2 = entity_is_argument_p(v,decl);
103 
104  ifdebug(8) {
105  if (!in_module_1 || !in_module_2) {
106  pips_debug(8, "variable %s not in declarations of %s\n",
107  entity_name(v),entity_name(m));
108  dump_arguments(decl);
109  }
110  }
111  return (in_module_1 && in_module_2);
112 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
void dump_arguments(cons *args)
entity_name is a macro, hence the code replication
Definition: arguments.c:69
#define same_string_p(s1, s2)

References code_declarations, dump_arguments(), entity_initial, entity_is_argument_p(), entity_module_name(), entity_name, ifdebug, module_local_name(), pips_debug, same_string_p, and value_code.

Referenced by add_non_declared_reference_to_declaration(), symbolic_constant_declaration_verify(), and variable_declaration_verify().

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

◆ void_function_p()

bool void_function_p ( entity  m)

Check if m is a C void function or a Fortran subroutine.

No information about m is available when false is returned.

Definition at line 538 of file module.c.

539 {
540  type ft = ultimate_type(entity_type(m));
541  bool void_p = false;
542 
543  if(type_functional_p(ft)) {
545  type r = functional_result(f);
546  if(type_void_p(r)) {
547  void_p = true;
548  }
549  }
550 
551  return void_p;
552 }
type ultimate_type(type)
Definition: type.c:3466

References entity_type, f(), functional_result, type_functional, type_functional_p, type_void_p, and ultimate_type().

Referenced by words_goto_label().

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

◆ x_language_module_p()

static bool x_language_module_p ( entity  m,
unsigned int  x 
)
static

Simplified versions of c_module_p() and fortran_module_p().

They cannot be used before the parsing is advanced unlike the other above two functions located in preprocessor, but they only require stuff from ri-util.

Definition at line 432 of file module.c.

433 {
434  bool is_x = true;
435  value mv = entity_initial(m);
436 
437  if(value_code_p(mv)) {
438  code c = value_code(mv);
439  is_x = language_tag(code_language(c))==x;
440  }
441  else
442  is_x = false;
443 
444  return is_x;
445 }
#define code_language(x)
Definition: ri.h:792
#define language_tag(x)
Definition: ri.h:1590
static char * x
Definition: split_file.c:159

References code_language, entity_initial, language_tag, value_code, value_code_p, and x.

Referenced by c_language_module_p(), fortran95_language_module_p(), and fortran_language_module_p().

+ Here is the caller graph for this function:

Variable Documentation

◆ checked_module

◆ module_coherent_p

bool module_coherent_p =true
static