PIPS
variable.c
Go to the documentation of this file.
1 /*
2 
3  $Id: variable.c 23468 2018-06-02 13:22:34Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* Handling of entity as program variables
28  * (see also entity.c for generic entities)
29  */
30 
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <string.h>
34 
35 #include "linear.h"
36 #include "genC.h"
37 
38 #include "misc.h"
39 #include "properties.h"
40 #include "ri-util.h"
41 
42 /* Check that "name" can be used as a new variable name in module
43  "in_module". Should work for C and for Fortran. Apparently, should
44  work whether name is already a global name or not, hence the
45  derivation of user_name
46 
47  Of course, not really debugged for Fortran:-(.
48 .*/
49 static bool unique_entity_name_p(const char * name, entity in_module)
50 {
51  /* first recover a user_name from global_name */
52  const char *user_name=
53  strchr(name,BLOCK_SEP_CHAR)?global_name_to_user_name(name):name;
54  /* first check in entity declaration, where all entities are added
55  * At least AddEntityToDeclarations keep this information up to date
56  */
57  FOREACH(ENTITY,e,entity_declarations(in_module))
58  {
59  if(same_string_p(entity_user_name(e),user_name))
60  return false;
61  }
62  /* everything seems ok, do a last check with gen_fin_tabulated */
63  if(strstr(name,MODULE_SEP_STRING))
65  else
67 }
68 
69 /* See also macro entity_variable_p()... */
71 {
72  bool variable =
75 
76  return variable;
77 }
78 
79 /* BEGIN_EOLE */ /* - please do not remove this line */
80 /* Lines between BEGIN_EOLE and END_EOLE tags are automatically included
81  in the EOLE project (JZ - 11/98) */
82 bool
84 {
89 
90  return symbolic_constant;
91 }
92 
93 /* END_EOLE */
94 
95 
96 /* Add a global variable e to the variable declarations of a module.
97 
98  It does nothing if e is already in the list.
99 
100  In the general case you should use AddLocalEntityToDeclarations() or
101  AddEntityToCurrentModule() instead.
102 
103  Since in C, variables should be added to the statement declarations
104  too, only use this function for special stuff like compilation unit and
105  special area delarations in the module bootstrapping.
106 */
107 void
109  pips_assert("module is fine",entity_consistent_p(module));
110  pips_assert("entity is fine",entity_consistent_p(e));
111  /* Add the variable to the module declarations */
112  list l =
114  /* Add the declaration only if not already here: */
117 }
118 
119 void
121 {
124  if(!statement_undefined_p(s))
125  {
128  if(statement_block_p(s))
129  {
130  // iterate over a copy because FOREACH does not
131  // support inplace modification
132  list theblock = gen_copy_seq(statement_block(s));
133  FOREACH(STATEMENT,stat,theblock)
134  {
135  bool decl_stat = declaration_statement_p(stat);
137  /* this take care of removing useless declaration statements*/
138  if(ENDP(statement_declarations(stat)) && decl_stat)
139  {
141  free_statement(stat);
142  }
143  }
144  gen_free_list(theblock);
145  }
146  }
147 
148 }
149 
150 /* See the two user interfaces below */
151 static void
153  bool add_declaration_statement_p) {
154  /* SG: fix the entity storage if undefined
155  * it basically recompute the offset of a scalar variable
156  * I have not found how to do it for a variable size array, so I
157  * just dropped the case -> a variable size array must be allocated
158  * in a different area, STACK_AREA, where offsets are not computed
159  */
161  {
164  int tmp;
165  /* current_offset_of_area fails if SizeOfArray is not computable
166  * because e is a varying length array
167  */
168  if(SizeOfArray(e,&tmp)) {
171  dynamic_area,
173  NIL)
174  );
175  }
176  else {
177  /* The variable e should be allocated in the Stack area */
178  pips_user_warning("Varying size for array \"%s\"\n", entity_name(e));
179  pips_user_warning("Not yet supported properly by PIPS\n");
180  }
181  }
182 
183  /* Both in C and Fortran, all variables and useful entities are
184  stored in code_declarations, in the symbol table. */
186 
187  /* In C, the variables, but the formal parameters, are local to a
188  statement */
189  if (c_module_p(module)) {
190  /* If undeclared in s, variable e is added in the
191  statement_declarations field. */
192  if(!statement_block_p(s))
194  pips_assert("add declarations to statement block",statement_block_p(s));
195 
197  pips_assert("Calling AddLocalEntityToDeclarations from c_module "
198  "with valid statement", !statement_undefined_p(s) );
199 
200  /* The entity may have already been declared... This could be an
201  assert but Serge seems to redeclare several times the same
202  variables when performing inlining */
205 
206  /* The C prettyprinter is not based on code_declarations or
207  statement_declarations but on declaration statements, which
208  happen to be continue statement for the time being. */
209  if(!declaration_statement_p(s) && add_declaration_statement_p) {
210  /* To preserve the source layout, declarations are
211  statements */
213  }
214  }
215  }
216 }
217 
218 /**
219  Add the variable entity e to the list of variables of the function
220  module.
221 
222  For a C module, the variable is also added as local to the given
223  statement s. A global variable to a module should be added to the global
224  statement module (given by get_current_module_statement() for
225  example. The consistency of the internal representation is maintained.
226 
227  @param e variable entity to add
228  @param module entity
229  @param s statement where entity must be added. A new declaraton
230  statement for e is added. It can be
231  statement_undefined in the case of a Fortran module
232  */
235 }
236 
237 /**
238  Add the variable entity e to the list of variables of the function
239  module.
240 
241  For a C module, the variable is also added as local to the given
242  statement s. A global variable to a module should be added to the global
243  statement module (given by get_current_module_statement() for
244  example. The consistency of the internal representation is not
245  maintained, but this is useful for the controlizer.
246 
247  @param e variable entity to add
248  @param module entity
249  @param s statement where entity must be added. No new declaration
250  ststement is added. It can be
251  statement_undefined in the case of a Fortran module
252  */
255 }
256 
257 
258 /* Add a variable entity to the current module declarations. */
259 void
261  entity module_e = get_current_module_entity();
262  /* There is no declaration local to a statement in Fortran: */
263  statement module_s = c_module_p(module_e) ? get_current_module_statement()
265 
266  AddLocalEntityToDeclarations(e, module_e, module_s);
267 }
268 
269 /* Add a variable entity to the current module declarations. */
270 void
272  entity module_e = get_current_module_entity();
273  /* There is no declaration local to a statement in Fortran: */
274  statement module_s = c_module_p(module_e) ? get_current_module_statement()
276 
277  AddLocalEntityToDeclarationsOnly(e, module_e, module_s);
278 }
279 
280 
282  const char* seed = entity_local_name(local);
283  int counter=0;
284  entity new = entity_undefined;
285  string eln= strdup(seed);
287  asprintf(&eln,"%s%d",seed,counter++);
288  }
290  free(eln);
291  entity_type(new)=copy_type(entity_type(local));
296  return new;
297 }
298 
299 /* If the parser has not (yet) encountered "stderr", a PIPS
300  transformation or instrumentation phase may need "stderr" to
301  generate AST code. This happens with array_bound_check at least. */
303 {
304  /* It's a global variable */
306  STDERR_NAME);
307  /* Unfortunately, I do not have an unknown basic to use... It
308  should be a FILE * pointer... */
314 
315  pips_assert("f & a are defined", !entity_undefined_p(f)
316  && !entity_undefined_p(a));
317 
318  /* Its type is variable, scalar, */
320 
321  /* its storage must be the static area of top-level */
323 
324  /* Its initial value is unknown */
326  return v;
327 }
328 
329 /* entity make_scalar_entity(name, module_name, base)
330  */
331 entity make_scalar_entity(const char * name,
332  const char * module_name,
333  basic base)
334 {
335  string full_name;
336  entity e, f, a;
337  basic b = base;
338 
339  full_name =
341 
342  pips_debug(8, "name %s\n", full_name);
343 
344  message_assert("not already defined",
346 
349 
353 
354  int offset = 0;
355  /* FI: this creates an inconsistency between the module declarations
356  * and the content of the *DYNAMIC* area.
357  */
358  if(!place_holder_variable_p(e)) {
361  (add_C_variable_to_area(a, e)):(0);
362  else
364  (add_variable_to_area(a, e)):(0);
365  }
366 
367  entity_storage(e) =
369  make_ram(f, a,
370  offset,
371  NIL));
372 
373  /* FI: I would have expected is_value_unknown, especially with a RAM storage! */
375 
376  return(e);
377 }
378 entity make_derived_entity(const char * name,
379  const char * module_name,
380  type t)
381 {
382  string full_name;
383  entity e;
384 
385  full_name =
387 
388  pips_debug(8, "name %s\n", full_name);
389 
390  message_assert("not already defined",
392 
395 
396  entity_type(e) = copy_type(t);
397 
399 
401 
402  return(e);
403 }
404 
405 
406 ␌
407 /* -------------------------------------------------------------
408  *
409  * New Temporary Variables MANAGEMENT
410  *
411  */
412 
413 static int
419 
420 void
422 {
427 }
428 
429 /* Default prefixes */
430 #define DEFAULT_INT_PREFIX "I_"
431 #define DEFAULT_FLOAT_PREFIX "F_"
432 #define DEFAULT_LOGICAL_PREFIX "L_"
433 #define DEFAULT_COMPLEX_PREFIX "C_"
434 #define DEFAULT_STRING_PREFIX "S_"
435 #define DEFAULT_POINTER_PREFIX "P_"
436 #define DEFAULT_STRUCT_PREFIX "ST_"
437 #define DEFAULT_UNION_PREFIX "U_"
438 #define DEFAULT_ENUM_PREFIX "E_"
439 #define DEFAULT_DERIVED_STRUCT_PREFIX "DS_"
440 #define DEFAULT_DERIVED_UNION_PREFIX "DU_"
441 #define DEFAULT_DERIVED_ENUM_PREFIX "DE_"
442 
443 /* Generate a new variable name from a seed name to a module
444 
445  @param seed_name is the main name of the variable name to generate
446 
447  @param prefix is the prefix to prepend to the variable name
448 
449  @param suffix is the suffix to append to the variable name
450 
451  @param module is the entity of the module the variable will belong to
452 
453  Is there is already a variable with this name, a new one is tried with
454  some numerical suffixes.
455 
456  @return the entity of the new variable. Its fields are to be filled
457  later before use.
458 */
459 entity
461  const char * prefix,
462  const char * suffix,
463  entity module) {
464  const char* format = fortran_module_p(module) ?
465  "%s "MODULE_SEP_STRING "%s%s%s":
466  "%s "MODULE_SEP_STRING "0" BLOCK_SEP_STRING "%s%s%s";
467 
468  const char* format_num = fortran_module_p(module) ?
469  "%s "MODULE_SEP_STRING "%s%s%s%d":
470  "%s "MODULE_SEP_STRING "0" BLOCK_SEP_STRING "%s%s%s%d";
471 
472  const char* module_name = module_local_name(module);
473  string variable_name;
474  int number = 0;
475 
476  /* First try a basic name without numeric suffix: */
477  asprintf(&variable_name, format, module_name, prefix, seed_name, suffix);
479  {
480  /* Free the old name since it was already used: */
482  /* And try a new one with a number suffix: */
483  asprintf(&variable_name, format_num, module_name, prefix, seed_name, suffix, number++);
484  };
485 
490  return e;
491 }
492 
493 
494 /* clone a variable with a new name.
495 
496  The new variable is added in the different declaration lists.
497 
498  @param insert_p If true, for C code, a new declaration statement is
499  inserted in "declaration_statement" to maintain the internal
500  representation consistency. Else, no new declaration statement is
501  inserted and the internal representation is no longer consistent
502  for C code.
503 
504  @return the new cloned entity
505 
506  See useful interface below
507 
508 */
510  statement declaration_statement,
511  string prefix,
512  string suffix,
513  entity module,
514  bool insert_p) {
515  const char * seed_name = entity_user_name(old_variable);
517  prefix,
518  suffix,
519  module);
520 
521  /* Clone the attributes of the old variable into the new one: */
525 
526  if(insert_p)
527  AddLocalEntityToDeclarations(new_variable, module, declaration_statement);
528  else
529  AddLocalEntityToDeclarationsOnly(new_variable, module, declaration_statement);
530 
531  return new_variable;
532 }
533 
534 /* Clone a variable with a new user name.
535 
536  @param old_variable is the variable to clone
537 
538  @param declaration_statement is the enclosing sequence (block)
539  defining the scope where the new variable is visible. It must be a
540  statement of kind sequence.
541 
542  @param prefix is the prefix to prepend to the variable name
543 
544  @param suffix is the suffix to append to the variable name
545 
546  @param module is the entity of the module the variable will belong to
547 
548  Is there is already a variable with this name, new names are tried with
549  numerical suffixes.
550 
551  @return the entity of the new variable. Its fields are copies from the
552  old one. That means that there may be some aliasing since the old one
553  and the new one have the same offset (in the sense of IR RAM) and
554  that use-def chains and dependence graphs are going to be wrong.
555 
556  The clone variable is added to the declaration list of
557  "statement_declaration" and to the code declarations of module
558  "module". A new declaration statement is inserted in the sequence
559  of "declaration_statement". This maintains the consistency of PIPS
560  internal representation for C and Fortran code.
561  */
563  statement declaration_statement,
564  string prefix,
565  string suffix,
566  entity module) {
568  declaration_statement,
569  prefix,
570  suffix,
571  module,
572  true);
573 }
574 
575 /* Create a new scalar variable of type b in the given module.
576 
577  The variable name is constructed with "<prefix><number>" If the given
578  prefix is the empty string, some standard prefixes are used, based on
579  the type.
580 
581  In Fortran, the prefix is forced to upper case to be consistent
582  with PIPS Fortran internal representation. All the default prefixes
583  are assumed to be uppercase strings.
584 
585  In C this function is added to current module only.
586 
587  @return the variable entity.
588 
589  It is not clear why the default prefix is (re)computed in the repeat
590  until loop rather than before entering it.
591 */
593  entity module,
594  basic b)
595 {
596  const char* module_name = module_local_name(module);
597  string ep = strdup(prefix);
598  entity e;
599  char * variable_name = NULL;
600  int number = 0;
601  bool empty_prefix = (strlen(prefix) == 0);
602  const string format = fortran_module_p(module)?"%s%d":"0" BLOCK_SEP_STRING "%s%d";
603  ep = fortran_module_p(module)? strupper(ep,ep) : ep;
604 
605  /* Find the first matching non-already existent variable name: */
606  do {
607  if (variable_name != NULL)
608  /* Free the already allocated name in the previous iteration that
609  was conflicting: */
611 
612  if (empty_prefix) {
613  /* Use a default type-dependent variable name since the programmer
614  gave none: */
615  basic ub = basic_ultimate(b);
616  switch(basic_tag(ub)) {
617  case is_basic_int:
620  break;
621  case is_basic_float:
624  break;
625  case is_basic_logical:
628  break;
629  case is_basic_complex:
632  break;
633  case is_basic_string:
636  break;
637  case is_basic_pointer:
640  break;
641  case is_basic_derived: {
642  entity de = basic_derived(ub);
643  type dt = ultimate_type(entity_type(de));
644 
645  if(type_struct_p(dt)) {
648  }
649  else if(type_union_p(dt)) {
652  }
653  else if(type_enum_p(dt)) {
656  }
657  else {
658  pips_internal_error("Not implemented for type tag: %d",
659  type_tag(dt));
660  }
661  break;
662  }
663  default:
664  pips_internal_error("unknown basic tag: %d",
665  basic_tag(ub));
666  break;
667  }
668  }
669  else
670  asprintf(&variable_name, format, ep, number++);
671  }
673 
674  pips_debug(9, "var %s, tag %d\n", variable_name, basic_tag(b));
675 
678  free(ep);
679 
680  return e;
681 }
682 
683 /* derived from make_new_scalar_variable_with_prefix
684  */
686  entity module,
687  type t)
688 {
689  const char* module_name = module_local_name(module);
690  string ep = strdup(prefix);
691  entity e;
692  char * variable_name = NULL;
693  int number = 0;
694  bool empty_prefix = (strlen(prefix) == 0);
695  /* declare the entity at the highest scope */
696  const string format = "0" BLOCK_SEP_STRING "%s%d";
697 
698  /* Find the first matching non-already existent variable name: */
699  do {
700  if (variable_name != NULL)
701  /* Free the already allocated name in the previous iteration that
702  was conflicting: */
704 
705  if (empty_prefix) {
706  /* Use a default type-dependent variable name since the programmer
707  gave none: */
708  switch(type_tag(t)) {
709  case is_type_struct:
712  break;
713  case is_type_union:
716  break;
717  case is_type_enum:
720  break;
721  default:
722  pips_internal_error("unexpected type kind: %d",
723  type_tag(t));
724  break;
725  }
726  }
727  else
728  asprintf(&variable_name, format, ep, number++);
729  }
731 
732  pips_debug(9, "var %s, tag %d\n", variable_name, type_tag(t));
733 
736  free(ep);
737 
738  return e;
739 }
740 
742 {
744 }
745 
746 /** Create an array entity
747  * @param module_name is the name of the module part of the entity name
748  * @param name is the user name of the entity
749  * @param base is the basic type for the array
750  * @param dimensions is the list of dimensions for the array
751  */
752 static entity make_array_entity(const char* name,
753  const char* module_name,
754  basic base,
755  list dimensions) {
756  string full_name;
757  entity e, f, a;
758  basic b = base;
760  pips_debug(8, "name %s\n", full_name);
761  int n =0;
763  free(full_name);
764  asprintf(&full_name,"%s"MODULE_SEP_STRING"%s%d",module_name,name,n++);
765  }
767 
768  entity_type(e) = (type) MakeTypeVariable(b, dimensions);
771  entity_storage(e) =
773  make_ram(f, a,
775  (add_variable_to_area(a, e)):(0),
776  NIL));
778  return(e);
779 }
780 
781 
782 /* J'ai ameliore la fonction make_new_scalar_variable_with_prefix */
783 /* afin de l'etendre a des tableau */
784 
786 {
787  const char* module_name = module_local_name(module);
788  entity e;
789  e = make_array_entity(prefix, module_name, b, dimensions);
790  return e;
791 }
792 
794  return make_new_array_variable_with_prefix("", module,b,dimensions);
795 }
796 
797 /*
798  Create an pointer to an array simlar to `efrom' initialized with
799  expression `from'
800  */
802  expression from) {
805 
806  /* Make the pointer type */
808  dims,
809  NIL)));
810  /* Create the variable as a pointer */
812  module, pointer);
813  /* Set its initial */
816  return new;
817 }
818 
821 }
822 
823 
824 
825 
826 
827 /* Make a new module integer variable of name X<d>.
828  */
829 entity
831 {
832 
833  string name;
835  static int num = 1;
836  if (d != 0) {
837  (void)asprintf(&name,"X%d",d);
838  num = d;
839  }
840  else { (void) asprintf(&name,"X%d",num);
841  num++;}
842 
843  while(!unique_entity_name_p(name,module))
844  {
845  string tmp = name;
846  (void)asprintf(&name,"X%d",num);
847  num++;
848  free(tmp);
849  }
850  ent1 = make_scalar_integer_entity(name,
852  return ent1;
853 }
854 
855 ␌
856 /* These globals variables count the number of temporary and auxiliary
857  * entities. Each time such a variable is created, the corresponding
858  * counter is incremented.
859  *
860  * FI: this must be wrong. A function to reset count_tmp and count_aux
861  * is needed if tpips or wpips are to work in a consistent way!
862  */
863 /* gcc complains that they are not used... but they are defined! */
864 static int count_tmp = 0;
865 static int count_aux = 0;
866 
867 
868 /* Make a new variable entity which name is one letter prefix + one
869  incrementing number.
870 
871  The function name should be changed. Useless function according to
872  previous ones ?
873 
874  * This entity is either a new temporary or a new auxiliary variable.
875  * The parameter "kind" gives the kind of entity to produce.
876  * "ba" gives the basic (ie the type) of the entity to create.
877  *
878  * The number of the temporaries is given by a global variable named
879  * "count_tmp".
880  * The number of the auxiliary variables is given by a global variable named
881  * "count_aux".
882  */
883 
884 // moved from atomizer to cut a ri-util -> atomizer dependency
885 
886 /* These lists memorize all the new created entities of each type. They
887  * are used for the declarations of these new variables : temporaries
888  * and auxiliaries.
889  */
890 list
897 
899 {
900  entity new_ent, mod_ent;
901  // prefix+1 (line#820) must hold 3 characters
902  char prefix[5], *name;
903  int number = 0;
905 
906  /* The first letter of the local name depends on the basic:
907  * int --> I
908  * real --> F (float single precision)
909  * others --> O
910  */
911  switch(basic_tag(ba))
912  {
913  case is_basic_int: { (void) sprintf(prefix, "I"); break;}
914  case is_basic_float:
915  {
917  (void) sprintf(prefix, "O");
918  else
919  (void) sprintf(prefix, "F");
920  break;
921  }
922  default: (void) sprintf(prefix, "O");
923  }
924 
925  /* The three following letters are whether "TMP", for temporaries
926  * or "AUX" for auxiliary variables.
927  */
928  switch(kind)
929  {
930  case TMP_ENT:
931  {
932  number = (++count_tmp);
933  (void) sprintf(prefix+1, "TMP");
934  break;
935  }
936  case AUX_ENT:
937  {
938  number = (++count_aux);
939  (void) sprintf(prefix+1, "AUX");
940  break;
941  }
942  default: user_error("make_new_entity", "Bad kind of entity: %d", kind);
943  }
944 
946 
947  /* The first part of the full name is the concatenation of the define
948  * constant ATOMIZER_MODULE_NAME and the local name of the module
949  * entity.
950  */
951  /* ATOMIZER_MODULE_NAME discarded : it is a bug ! RK, 31/05/1994.
952  name = strdup(concatenate(ATOMIZER_MODULE_NAME, entity_local_name(mod_ent),
953  MODULE_SEP_STRING, prefix, num, (char *) NULL));
954  */
955  asprintf(&name,"%s" MODULE_SEP_STRING "%s%d",entity_local_name(mod_ent),prefix,number);
956  /*
957  new_ent = make_entity(name,
958  make_type(is_type_variable,
959  make_variable(ba,
960  NIL,NIL)),
961  make_storage(is_storage_rom, UU),
962  make_value(is_value_unknown, UU));
963  */
964  /* Create a true dynamic variable. RK, 31/05/1994 : */
965  new_ent = make_entity(name,
967  make_variable(ba,
968  NIL,NIL)),
975  dynamic_area,
977  NIL));
978  AddEntityToCurrentModule(new_ent);
979 
980  /* Is the following useless : */
981 
982  /* The new entity is stored in the list of entities of the same type. */
983  switch(basic_tag(ba))
984  {
985  case is_basic_int:
986  {
988  break;
989  }
990  case is_basic_float:
991  {
994  else
995  real_entities = CONS(ENTITY, new_ent, real_entities);
996  break;
997  }
998  case is_basic_logical:
999  {
1001  break;
1002  }
1003  case is_basic_complex:
1004  {
1006  break;
1007  }
1008  case is_basic_string:
1009  {
1010  char_entities = CONS(ENTITY, new_ent, char_entities);
1011  break;
1012  }
1013  default:break;
1014  }
1015 
1016  return new_ent;
1017 }
1018 
1019 
1020 /* Looks for an entity which should be a scalar of the specified
1021  basic. If found, returns it, else one is created.
1022 
1023  If the entity is not a scalar, it aborts.
1024  */
1025 entity find_or_create_scalar_entity(const char* name, const char* module_name, tag base)
1026 {
1028  string nom = concatenate(module_name, MODULE_SEP_STRING, name, NULL);
1029 
1031  {
1032  pips_assert("find_or_create_scalar_entity",
1033  (entity_scalar_p(e) && entity_basic_p(e, base)));
1034 
1035  return(e);
1036  }
1037 
1038  return(make_scalar_entity(name, module_name, MakeBasic(base)));
1039 }
1040 
1041 
1042 /* Looks for an entity of the specified
1043  basic. If found, returns it, else one is created.
1044  */
1045 entity
1047  string name,
1048  const char* module_name,
1049  tag base)
1050 {
1052  string nom = concatenate(module_name, MODULE_SEP_STRING, name, NULL);
1053 
1055  {
1056  pips_assert("type is okay", entity_basic_p(e, base));
1057 
1058  return(e);
1059  }
1060 
1061  return(make_scalar_entity(name, module_name, MakeBasic(base)));
1062 }
1063 
1064 
1065 /* Create an integer variable of name "name" in module of name
1066  "module_name" */
1067 entity
1068 make_scalar_integer_entity(const char *name, const char *module_name)
1069 {
1070  string full_name;
1071  entity e, f, a ;
1072  basic b ;
1073 
1074  pips_debug(8, "begin name=%s, module_name=%s\n", name, module_name);
1075 
1081  value_undefined);
1082 
1083  b = make_basic(is_basic_int, (void*) 4);
1084 
1085  entity_type(e) = (type) MakeTypeVariable(b, NIL);
1086 
1089  pips_assert("make_scalar_integer_entity",
1091 
1092  entity_storage(e)
1094  (make_ram(f, a,
1096  NIL)));
1097 
1100 
1101  pips_debug(8, "end\n");
1102 
1103  return(e);
1104 }
1105 
1106 
1107 /* The concrete type of e is a scalar type. The programmer cannot index
1108  this variable.
1109 
1110  Note: variable e may appear indexed somewhere in the PIPS internal
1111  representation if this is linked to some semantics.
1112 */
1114 {
1115  bool return_value = false;
1116 
1117  type t = ultimate_type(entity_type(e));
1118  if(type_variable_p(t)) {
1119  return_value = ENDP(variable_dimensions(type_variable(t)))
1120  && ! pointer_type_p(t);
1121  }
1122  return return_value;
1123 }
1124 
1125 /* for variables (like I), not constants (like 1)!
1126  * use integer_constant_p() for constants
1127  *
1128  * The integer type may be signed or unsigned.
1129  */
1131 {
1132  return(entity_scalar_p(e) &&
1134 }
1135 
1136 /* integer_scalar_entity_p() is obsolete; use entity_integer_scalar_p() */
1138 {
1139  type ct = ultimate_type(entity_type(e));
1140  return type_variable_p(entity_type(e)) &&
1143 }
1144 
1145 /* return true if the entity is declared with the keyword static */
1147  storage s = entity_storage(e);
1149 }
1150 
1151 /* Any reference r such that reference_variable(r)==e accesses all
1152  bytes (or bits) allocated to variable e. In other words, any write
1153  of e is a kill. At least, if the reference indices are NIL in the
1154  case of pointers.
1155 
1156  The Newgen type of e must be "variable".
1157 
1158  FI: This function is much too naive because array dimensions may be
1159  hidden anywhere in a chain of typdef types. It might be much better
1160  to use type_depth() or to write a more specific function. Well, for
1161  some unknown reason, type_depth is not the answer.
1162  */
1164 {
1165  type t = entity_type(e);
1166  //variable vt = type_variable(t);
1167  type ut = ultimate_type(entity_type(e));
1168  variable uvt = type_variable(ut);
1169  bool atomic_p = false;
1170 
1171  pips_assert("entity e is a variable", type_variable_p(ut));
1172 
1173  /* Kludge to work in case the dimension is part of the typedef or
1174  part of the type. */
1175  /* if(ENDP(variable_dimensions(uvt)) &&
1176  ENDP(variable_dimensions(vt))) {*/
1177  if(type_depth(t)==0) {
1178  /* The property is not true for overloaded, string, derived
1179  (typedef is impossible here) */
1180  basic ubt = variable_basic(uvt);
1181  atomic_p = basic_int_p(ubt) || basic_float_p(ubt) || basic_logical_p(ubt)
1182  || basic_complex_p(ubt) || basic_bit_p(ubt) || basic_pointer_p(ubt);
1183  }
1184 
1185  return atomic_p;
1186 }
1187 
1188 /**
1189 
1190  @return true if the entity is a scalar but not a pointer, false otherwise.
1191  (takes care of typedefs).
1192  */
1194 {
1195  bool atomic_p = false;
1197  if(type_variable_p(ct)) {
1198  variable vt = type_variable(ct);
1199 
1200  //pips_assert("entity e is a variable", type_variable_p(ct));
1201  //entity can be a functional in C too
1202 
1203  if(ENDP(variable_dimensions(vt)))
1204  {
1205  /* The property is not true for overloaded, string, derived
1206  */
1207  basic bt = variable_basic(vt);
1208  atomic_p = basic_int_p(bt) || basic_float_p(bt) || basic_logical_p(bt)
1209  || basic_complex_p(bt) || basic_bit_p(bt);
1210  }
1211 
1212  }
1213  return atomic_p;
1214 }
1215 
1216 
1217 
1218 
1219  /* Another semantics would be: is this reference r to e a kill for
1220  e? In general, this cannot be answered at the entity level only
1221  (see previous function) and the reference itself must be passed
1222  as an argument.
1223 
1224  FI: I'm not sure of the best location for this function in
1225  ri-util (no file reference.c).
1226  */
1227 ␌
1229 {
1230  cons *pd;
1231  type t = entity_type(e);
1232 
1233  pips_assert("entity_ith_dimension", type_variable_p(t));
1234 
1236 
1237  while (pd != NIL && --i > 0)
1238  pd = CDR(pd);
1239 
1240  pips_assert("entity_ith_dimension", pd != NIL);
1241 
1242  return(DIMENSION(CAR(pd)));
1243 }
1244 
1245 /* bool entity_unbounded_p(entity e)
1246  * input : an array entity
1247  * output : true if the last dimension of the array is unbounded (*),
1248  * false otherwise.
1249  * modifies : nothing
1250  * comment :
1251  */
1253 {
1254  int nb_dim = NumberOfDimension(e);
1255 
1256  return(unbounded_dimension_p(entity_ith_dimension(e, nb_dim)));
1257 }
1258 
1259 /* bool array_with_numerical_bounds_p(entity a)
1260  * input : an array entity
1261  * output : true if all bounds of all dimensions are numerical
1262  * false otherwise (adjustable arrays, formal parameters).
1263  * modifies : nothing
1264  * comment :
1265  */
1267 {
1268  int nb_dim = NumberOfDimension(a);
1269  int d;
1270  bool numerical_bounds_p = true;
1271 
1272  for(d=1; d <= nb_dim && numerical_bounds_p; d++) {
1273  dimension dd = entity_ith_dimension(a, nb_dim);
1274  expression l = dimension_lower(dd);
1275  expression u = dimension_upper(dd);
1276 
1277  numerical_bounds_p = expression_with_constant_signed_integer_value_p(l)
1279  }
1280 
1281  return numerical_bounds_p;
1282 }
1283 
1284 
1285 
1286 /* variable_entity_dimension(entity v): returns the dimension of variable v;
1287  * scalar have dimension 0.
1288  *
1289  * This is not necessarily the dimensions because of typedefs. Another
1290  * function is able to collect dimensions hidden in typedefs, but also
1291  * via fields: see type_depth().
1292  */
1294 {
1295  int d = 0;
1296 
1297  pips_assert("variable_entity_dimension", type_variable_p(entity_type(v)));
1298 
1300  d++;
1301 
1302  return d;
1303 }
1304 
1305 
1307 {
1308  /* FI: this is pretty dangerous as it may leave tons of dangling pointers;
1309  * I use it to correct early declarations of types functions as variables;
1310  * I assume that no pointers to v exist in statements because we are still
1311  * in the declaration phasis.
1312  *
1313  * Memory leaks: I do not know if NewGen free_entity() is recursive.
1314  */
1315  storage s = entity_storage(v);
1317  code c = code_undefined;
1318 
1319  if(storage_undefined_p(s)) {
1320  const char* fn = entity_module_name(v);
1322  }
1323  else if(storage_ram_p(s)) {
1324  f = ram_function(storage_ram(s));
1325  }
1326  else if(storage_rom_p(s)) {
1327  f = entity_undefined;
1328  }
1329  else {
1330  pips_internal_error("unexpected storage %d", storage_tag(s));
1331  }
1332 
1333  if(!entity_undefined_p(f)) {
1334  pips_assert("remove_variable_entity", entity_module_p(f));
1335  c = value_code(entity_initial(f));
1336  gen_remove(&code_declarations(c), v);
1337  }
1338  free_entity(v);
1339 }
1340 
1341 /* entity make_integer_constant_entity(int c)
1342  * make entity for integer constant c
1343 
1344  WARNING : the basic integer size is fixed to sizeof(_int) */
1346  entity ce;
1347  /* 64 bits numbers are printed in decimal in 20 digits, so with - and \0
1348  32 is enough. */
1349  char num[32];
1350  string cn;
1351 
1352  sprintf(num, "%td", c);
1355  if (ce==entity_undefined) { /* make entity for the constant c */
1356  functional cf =
1359  make_variable(make_basic(is_basic_int, (void*)sizeof(int)),
1360  NIL,NIL)));
1361  type ct = make_type(is_type_functional, cf);
1362  ce = make_entity(strdup(cn), ct, make_storage_rom(),
1364  make_constant(is_constant_int, (void*)c)));
1365  }
1366  return(ce);
1367 }
1368 ␌
1369 /*
1370  * These functions compute the current offset of the area a passed as
1371  * argument. The length of the variable v is also computed and then added
1372  * to a's offset. The initial offset is returned to the calling function.
1373  * v is added to a's layout if not already present. C and Fortran behaviours differ slightly.
1374  */
1375 
1377 {
1378  return(add_any_variable_to_area(a, v, true));
1379 }
1380 
1382 {
1383  return(add_any_variable_to_area(a, v, false));
1384 }
1385 
1386 int add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
1387 {
1388  int OldOffset=-1;
1389  type ta = entity_type(a);
1390  area aa = type_area(ta);
1391 
1392  if(top_level_entity_p(a) && is_fortran_p ) {
1393  /* COMMONs are supposed to have the same layout in each routine */
1394  pips_internal_error("COMMONs should not be modified");
1395  }
1396  else {
1397  /* the local areas are StaticArea and DynamicArea in fortran */
1398  /* the areas are localStaticArea, localDynamicArea,
1399  moduleStaticArea, globalStaticArea in C; but we also mange the
1400  stack for variable of dependent types, the heap area to model
1401  dynamic allocation and the formal area to model the formal
1402  context in C. */
1403  int s = 0;
1404  OldOffset = area_size(aa);
1405  /* FI: I have a (temporary?) problem with some stub functional
1406  variables generated by the points-to analysis. In fact, the
1407  should be declared as pointers to functions, not as
1408  functions. I also have problem with overloaded stubs... */
1409  type uet = ultimate_type(entity_type(v));
1410  if(!type_variable_p(uet)
1411  || overloaded_type_p(uet)
1412  || !SizeOfArray(v, &s)) {
1413  if(is_fortran_p)
1414  return DYNAMIC_RAM_OFFSET;
1415  else {
1416  if(!gen_in_list_p(v, area_layout(aa)))
1417  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1418  }
1419  }
1420 
1421  if(is_fortran_p)
1422  {
1423  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1424  area_size(aa) = OldOffset+s;
1425  }
1426  else
1427  {
1428  if(!gen_in_list_p(v, area_layout(aa)))
1429  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1430  area_size(aa) = OldOffset+s;
1431  }
1432  }
1433  return(OldOffset);
1434 }
1435 
1436 int new_add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
1437 {
1438  int OldOffset=-1;
1439  type ta = entity_type(a);
1440  area aa = type_area(ta);
1441 
1442  if(top_level_entity_p(a) && is_fortran_p ) {
1443  /* COMMONs are supposed to havethe same layout in each routine */
1444  pips_internal_error("COMMONs should not be modified.");
1445  }
1446  else if(static_area_p(a) || dynamic_area_p(a)) {
1447  /* the local areas are StaticArea and DynamicArea in fortran */
1448  /* the areas are localStaticArea, localDynamicArea,
1449  moduleStaticArea, globalStaticArea in C*/
1450  int s = 0;
1451  OldOffset = area_size(aa);
1452  if(!SizeOfArray(v, &s)) {
1453  /* FI: should only happens with stack_area_p(a)... */
1454  return DYNAMIC_RAM_OFFSET;
1455  }
1456 
1457  if(is_fortran_p) {
1458  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1459  area_size(aa) = OldOffset+s;
1460  }
1461  else { /* C language */
1462  if(!gen_in_list_p(v, area_layout(aa)))
1463  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1464  area_size(aa) = OldOffset+s;
1465  }
1466  }
1467  else if(stack_area_p(a)) {
1468  /* By definition of the stack area, the offset is unknown because
1469  the size of the cariables is unknown statically. E.g. dependent
1470  types. This may happen in C99 or in Fortran 77 extensions. */
1471  if(!gen_in_list_p(v, area_layout(aa)))
1472  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1473  }
1474  else if(heap_area_p(a)) {
1475  /* FI: the points-to analysis is going to modify the symbol table
1476  under some properties... Maybe it would be better not to track
1477  buckets and abstract buckets declared in the heap? */
1478  pips_assert("Not possible for Fortran code", !is_fortran_p);
1479  if(!gen_in_list_p(v, area_layout(aa)))
1480  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1481  }
1482  else {
1483  pips_internal_error("Unexpected area kind: \"%s\".",
1484  entity_name(a));
1485  }
1486  return(OldOffset);
1487 }
1488 ␌
1490 {
1491  storage s = entity_storage(v);
1492  bool formal_p = storage_formal_p(s);
1493 
1494  return formal_p;
1495 }
1496 
1497 /* Is v a global variable declared local to a C file such "static int i;" */
1499 {
1500  // static global variables are decared in a compilation unit
1502 
1503  return static_global_variable_p;
1504 }
1505 
1506 /* Is v a global variable such as "int i;"
1507  *
1508  * This is OK for C, but Fortran deals with commons.
1509  */
1511 {
1512  // static global variables are decared in a compilation unit
1513  bool global_variable_p =
1514  (strcmp(entity_module_name(v), TOP_LEVEL_MODULE_NAME)==0);
1515 
1516  return global_variable_p;
1517 }
1518 
1519 
1520 /* True if a variable is the pseudo-variable used to store value
1521  returned by a function: */
1523 {
1524  storage s = entity_storage(v);
1525  bool return_p = storage_return_p(s);
1526 
1527  return return_p;
1528 }
1529 
1530 
1531 /* Such pseudo-variables are generated by the points-to analysis
1532  *
1533  * See also entity_in_formal_area_p()
1534  */
1536 {
1537  bool formal_p = false;
1538  storage s = entity_storage(v);
1539  if(storage_ram_p(s)) {
1540  ram r = storage_ram(s);
1541  entity s = ram_section(r);
1542  formal_p = formal_area_p(s);
1543  }
1544  return formal_p;
1545 }
1546 
1548  entity a_module)
1549 {
1551  {
1552  storage s = entity_storage(e);
1553  if (e == a_variable) {
1554  if (storage_formal_p(s))
1555  /* Well, the variable is a formal parameter of the
1556  module: */
1557  return true;
1558  else
1559  /* The variable is in the declaration of the module
1560  but is not a formal parameter: */
1561  return false;
1562  }
1563  }
1564 
1565  /* The variable is not in the declaration of the module: */
1566  return false;
1567 }
1568 
1569 /* true if v is in a common. */
1571 {
1572  return type_variable_p(entity_type(v)) &&
1575 }
1576 
1577 /* true if v appears in a SAVE statement, or in a DATA statement, or
1578  is declared static i C. The size of v in bytes can */
1580 {
1581  return(type_variable_p(entity_type(v)) &&
1584 }
1585 
1587 {
1588  return(type_variable_p(entity_type(v)) &&
1591 }
1592 
1594 {
1595  return(type_variable_p(entity_type(v)) &&
1598 }
1599 
1601 {
1602  return(type_variable_p(entity_type(v)) &&
1605 }
1606 
1607 /* This test can only be applied to variables, not to functions, subroutines or
1608  * commons visible from a module.
1609  */
1611  entity m)
1612 {
1613  bool in_module_1 =
1614  strcmp(module_local_name(m), entity_module_name(v)) == 0;
1615  bool in_module_2 =
1617 
1618  pips_assert ("Module declaration consistency", in_module_1==in_module_2);
1619 
1620  return in_module_1;
1621 }
1622 
1624 {
1625  // FI: should be a call to gen_in_list_p()
1626  bool is_in_list = false;
1627  for( ; (l != NIL) && (! is_in_list); l = CDR(l))
1628  if(same_entity_p(e, ENTITY(CAR(l))))
1629  is_in_list = true;
1630  return(is_in_list);
1631 }
1632 
1633 /* @return whether entity is a "volatile" variable
1634  *
1635  * See also entity_register_p()
1636  */
1638 {
1639  type t = entity_type(v);
1640  pips_assert("the entity must have type variable", type_variable_p(t));
1641 
1643 }
1644 
1645 /* @return whether variable is a "volatile" variable
1646  *
1647  * See also entity_register_p()
1648  */
1650 {
1651  bool volatile_p = false;
1652 
1653  // FI: no idea if volatile can he hidden in a typedef...
1654  list ql = variable_qualifiers(v);
1655 
1656  FOREACH(QUALIFIER, q, ql) {
1657  if(qualifier_volatile_p(q)) {
1658  volatile_p = true;
1659  break;
1660  }
1661  }
1662  return volatile_p;
1663 }
1664 
1665 /* The variable may turn out to be a function */
1666 bool qualified_variable_p(entity v, unsigned int is_qualified)
1667 {
1668  bool qualified_p = false;
1669  type t = entity_type(v);
1670  if(type_variable_p(t)) {
1671  // ifdebug(1) pips_assert("the entity must have type variable",
1672  // type_variable_p(t));
1673  // FI: no idea if volatile can he hidden in a typedef...
1674  variable vt = type_variable(t);
1675  list ql = variable_qualifiers(vt);
1676 
1677  FOREACH(QUALIFIER, q, ql) {
1678  if(qualifier_tag(q)==is_qualified) {
1679  qualified_p = true;
1680  break;
1681  }
1682  }
1683  }
1684  return qualified_p;
1685 }
1686 
1688 {
1690 }
1691 ␌
1692 /* Discard the decls_text string of the module code to make the
1693  prettyprinter ignoring the textual declaration and remake all from
1694  the declarations without touching the corresponding property
1695  (PRETTYPRINT_ALL_DECLARATIONS). RK, 31/05/1994. */
1697 {
1698  code c = entity_code(a_module);
1699  string s = code_decls_text(c);
1700 
1701  free(s);
1702  code_decls_text(c) = strdup("");
1703 }
1704 
1705 /* Returns a numbered entity the name of which is suffix + number,
1706  * the module of which is prefix. Used by some macros to return
1707  * dummy and primed variables for system of constraints.
1708  *
1709  * moved to ri-util from hpfc on BC's request. FC 08/09/95
1710  */
1711 entity get_ith_dummy(string prefix, string suffix, int i)
1712 {
1713  char buffer[100];
1714  assert(i>=1 && i<=7);
1715  (void) sprintf(buffer, "%s%d", suffix, i);
1716 
1718 }
1719 
1720 
1722 {
1724  char buffer[9];
1725 
1726  pips_assert("A label cannot be more than 5 character long", strlen(i)<=5);
1727  buffer[0]='"';
1728  buffer[1]='*';
1729  buffer[2]=0;
1730 
1731  strcat(&buffer[0], i);
1732 
1733  buffer[strlen(i)+2]='"';
1734  buffer[strlen(i)+3]=0;
1735 
1737 
1738  return e;
1739 }
1740 
1741 /* * (star) used as formal label parameter is replaced by a string
1742  variable as suggested by Fabien Coelho. Its storage and initial value
1743  are lated initialized by MakeFormalParameter(). */
1745 {
1746  entity fs = entity_undefined;
1747  const char* lsp = get_string_property("PARSER_FORMAL_LABEL_SUBSTITUTE_PREFIX");
1748  /* string lsp = "FORMAL_RETURN_LABEL_"; */
1749  /* let's assume that there are fewer than 999 formal label arguments */
1750  char buffer[4];
1751  string sn = &buffer[0];
1752  string full_name = string_undefined;
1753 
1754  pips_assert("No more than 999 alternate returns", 0 <= l && l < 999);
1755 
1756  sprintf(buffer, "%d", l);
1757 
1758  /* Generate a variable of type CHARACTER*(*). See gram.y,
1759  "lg_fortran_type:". It is postponed to MakeFormalParameter */
1760  full_name = strdup(concatenate(p, MODULE_SEP_STRING, lsp, sn, NULL));
1762  fs = make_entity(full_name,
1765  value_undefined);
1766  }
1767  else {
1768  /* fs may already exists if a ParserError occured or if an edit of the
1769  source file occured */
1770  free(full_name);
1772 
1773  /* Not so sure because CleanUpEntities() is called later, not
1774  before. This function is cvalled by the parser before the module
1775  declaration rule is reduced. */
1776  /*
1777  pips_assert("The type, storage and value are undefined\n",
1778  type_undefined_p(entity_type(fs))
1779  && storage_undefined_p(entity_storage(fs))
1780  && value_undefined_p(entity_initial(fs)));
1781  */
1782  /* Too bad for the memory leaks: they should not occur frequently */
1786  }
1787 
1788  /* Too early because the current_module_entity is not yet fully defined. */
1789  /* AddEntityToDeclarations(fs, get_current_module_entity()); */
1790 
1791  pips_debug(8, "Generated replacement for formal return label: %s\n",
1792  entity_name(fs));
1793 
1794  return fs;
1795 }
1796 
1798 {
1799  bool replacement_p = false;
1800 
1801  const char* fpn = entity_local_name(fp);
1802  const char* lsp = get_string_property("PARSER_FORMAL_LABEL_SUBSTITUTE_PREFIX");
1803  /* string lsp = "FORMAL_RETURN_LABEL_"; */
1804 
1805  replacement_p = (strstr(fpn, lsp)==fpn);
1806 
1807  return replacement_p;
1808 }
1809 
1810 /* Assumes that eap is a call */
1812 {
1813  bool replacement_p = false;
1814  if (expression_call_p(eap))
1815  {
1816  const char * ls = entity_user_name(call_function(syntax_call(expression_syntax(eap))));
1817  const char * p = ls+1;
1818 
1819  replacement_p = (strlen(ls) >= 4
1820  && *ls=='"' && *(ls+1)=='*' && *(ls+strlen(ls)-1)=='"');
1821 
1822  if(replacement_p) {
1823  for(p=ls+2; p<ls+strlen(ls)-1; p++) {
1824  if(*p<'0'||*p>'9') {
1825  replacement_p =false;
1826  break;
1827  }
1828  }
1829  }
1830  }
1831 
1832  return replacement_p;
1833 }
1834 
1836 {
1837  bool contains_p = false;
1838 
1840  if((contains_p = actual_label_replacement_p(arg)))
1841  break;
1842 
1843  return contains_p;
1844 }
1845 ␌
1846 /*
1847  * create a new entity for a new index variable with a name similar to
1848  * the old index name, and with the same type, declare it in the
1849  * current module and allocate it.
1850  */
1851 entity make_new_index_entity(entity old_index, string suffix)
1852 {
1853  entity new_index;
1854  string old_name;
1855  char *new_name=NULL;
1857 
1858  old_name = entity_name(old_index);
1859 
1860  /* add a terminal suffix till a new name is found. */
1861  for (asprintf(&new_name, "%s%s", old_name, suffix); !unique_entity_name_p(global_name_to_user_name(new_name),module); old_name = new_name) {
1862  char *tmp = new_name;
1863  asprintf(&new_name, "%s%s", old_name, suffix);
1864  free(tmp);
1865  }
1866 
1867  // FI: copy_storage() cree de l'aliasing entre new_index et old_index
1868  // Is this the right place to fix the problem?
1869  new_index = make_entity(new_name,
1870  copy_type(entity_type(old_index)),
1872  copy_value(entity_initial(old_index)));
1873  AddEntityToCurrentModule(new_index);
1874  return(new_index);
1875 }
1876 
1878 {
1879  const char * vn = entity_user_name(v);
1880 
1881 
1882  // return string_equal_p(vn, IMPLICIT_VARIABLE_NAME_1)
1883  //|| string_equal_p(vn, IMPLICIT_VARIABLE_NAME_2);
1884 
1885  return strcmp(vn, IMPLICIT_VARIABLE_NAME_1) == 0
1886  || strcmp(vn, IMPLICIT_VARIABLE_NAME_2) == 0;
1887 
1888 }
1889 
1890 ␌
1891 /* Returns a copy of the initial (i.e. initialization) expression of
1892  variable v. If v's inital value is a constants or a code block, it
1893  is converted to the corresponding expression.
1894 
1895  Could have been called entity_to_initialization_expression(), or
1896  entity_to_initial_expression(), but it only makes sense for
1897  variables.
1898 */
1900 {
1901  value val = entity_initial(v);
1903 
1904  if (value_undefined_p(val))
1905  {
1906  // FC: this seems to occur on from initial preconditions on a field
1907  // within a struct. The actual initial value should be "0" in that case.
1908  // see Semantics/struct04.c
1909  pips_user_warning("undefined initial value on %s... ignoring",
1910  entity_name(v));
1911  return expression_undefined;
1912  }
1913 
1914  if (value_expression_p(val)) {
1916  }
1917  else if(value_constant_p(val)) {
1918  constant c = value_constant(val);
1919  if (constant_int_p(c)) {
1921  }
1922  else {
1923  pips_internal_error("Not Yet Implemented.");
1924  }
1925  }
1926  else if(value_code_p(val)) {
1929 
1930  if(!ENDP(il)) {
1931  statement is = STATEMENT(CAR(il));
1933 
1934  pips_assert("A pointer initialization is made of one instruction expression",
1935  gen_length(il)==1 && instruction_expression(ii));
1936 
1938  }
1939  }
1940  }
1941  else if(value_unknown_p(val)) {
1943  }
1944  else if(value_intrinsic_p(val)) {
1946  }
1947  else if(value_reference_p(val)) {
1948  // FI: the initial value of a location entity is a reference to itself
1950  }
1951  else if(value_symbolic_p(val)) {
1952  symbolic s = value_symbolic(val);
1953  /* FI: not sure this is used in C; also, the constant field could be
1954  used as well. */
1956  }
1957  else {
1958  pips_internal_error("Unexpected value tag %d.", value_tag(val));
1959  }
1960 
1961  return exp;
1962 }
1963 
1964 /* Check if a variable is initialized by itself as "int a = a;" is
1965  legal C code according to gcc. */
1967 {
1968  bool self_p = false;
1969 
1971 
1972  if(expression_undefined_p(e))
1973  self_p = false;
1974  else {
1975  /* sd v referenced in e? */
1977 
1978  FOREACH(REFERENCE, r, lr) {
1979  entity rv = reference_variable(r);
1980  if(v==rv) {
1981  self_p = true;
1982  break;
1983  }
1984  }
1985  gen_free_list(lr);
1986  }
1987  return self_p;
1988 }
1989 ␌
1990 /* FI: transferred from semantics (should be used for effect translation
1991  as well) */
1993 {
1994  storage st1 = entity_storage(e1);
1995  storage st2 = entity_storage(e2);
1997  entity s2 = entity_undefined;
1998  ram r1 = ram_undefined;
1999  ram r2 = ram_undefined;
2000  bool same = false;
2001 
2002  /* e1 or e2 may be a formal parameter as shown by the benchmark m from CEA
2003  * and the call to SOURCE by the MAIN, parameter NPBF (FI, 13/1/93)
2004  *
2005  * I do not understand why I should return false since they actually have
2006  * the same location for this call site. However, there is no need for
2007  * a translate_global_value() since the usual formal/actual binding
2008  * must be enough.
2009  */
2010  /*
2011  * pips_assert("same_scalar_location_p", storage_ram_p(st1) && storage_ram_p(st2));
2012  */
2013  if(!(storage_ram_p(st1) && storage_ram_p(st2)))
2014  return false;
2015 
2016  r1 = storage_ram(entity_storage(e1));
2017  s1 = ram_section(r1);
2018  r2 = storage_ram(entity_storage(e2));
2019  s2 = ram_section(r2);
2020 
2021  if(s1 == s2) {
2022  if(ram_offset(r1) == ram_offset(r2))
2023  same = true;
2024  else {
2025  pips_debug(7,
2026  "Different offsets %td for %s in section %s and %td for %s in section %s\n",
2027  ram_offset(r1), entity_name(e1), entity_name(s1),
2028  ram_offset(r2), entity_name(e2), entity_name(s2));
2029  }
2030  }
2031  else {
2032  pips_debug(7,
2033  "Disjoint entitites %s in section %s and %s in section %s\n",
2034  entity_name(e1), entity_name(s1),
2035  entity_name(e2), entity_name(s2));
2036  }
2037 
2038  return same;
2039 }
2040 
2041 /* Assume that v is declared as a struct. Return the list of its fields.
2042  *
2043  * Apart from a possible assert, the same function should work for a union.
2044 */
2046 {
2048  list fl = derived_type_to_fields(c_t);
2049  return fl;
2050 }
2051 ␌
2052 /* Generate special variables to represent declarations such as "struct s;" */
2053 
2054 /* This special character string does not have to be exported, except
2055  * to make sure it is unique
2056  */
2057 #define PLACE_HOLDER_PREFIX_STRING "PLACE__HOLDER_"
2058 
2060 {
2062  basic b = make_basic_derived(de);
2063  entity ph = entity_undefined;
2064  if(!entity_undefined_p(m))
2066  return ph;
2067 }
2068 
2070 {
2071  const char * n = entity_local_name(ph);
2072  string f = strstr(n, PLACE_HOLDER_PREFIX_STRING);
2073  return f!=NULL;
2074 }
functional make_functional(list a1, type a2)
Definition: ri.c:1109
cast make_cast(type a1, expression a2)
Definition: ri.c:311
constant make_constant(enum constant_utype tag, void *val)
Definition: ri.c:406
value make_value_unknown(void)
Definition: ri.c:2847
basic make_basic_derived(entity _field_)
Definition: ri.c:182
value make_value_expression(expression _field_)
Definition: ri.c:2850
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage_rom(void)
Definition: ri.c:2285
void free_entity(entity p)
Definition: ri.c:2524
type copy_type(type p)
TYPE.
Definition: ri.c:2655
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
basic make_basic_pointer(type _field_)
Definition: ri.c:179
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
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
value copy_value(value p)
VALUE.
Definition: ri.c:2784
storage copy_storage(storage p)
STORAGE.
Definition: ri.c:2228
syntax make_syntax_cast(cast _field_)
Definition: ri.c:2503
constant make_constant_litteral(void)
Definition: ri.c:418
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
void free_statement(statement p)
Definition: ri.c:2189
bool entity_consistent_p(entity p)
Definition: ri.c:2530
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
static entity mod_ent
#define DOUBLE_PRECISION_SIZE
#define AUX_ENT
#define TMP_ENT
bdt base
Current expression.
Definition: bdt_read_paf.c:100
static int num
Definition: bourdoncle.c:137
struct _newgen_struct_type_ * type
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860
static entity old_variable
void propagate_synonym(s, old, new) statement s; entity old, new;
Definition: dynamic.c:859
static Value offset
Definition: translation.c:283
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
Definition: entity_names.c:136
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
char * get_string_property(const char *)
static entity a_variable
#define gen_chunk_undefined_p(c)
Definition: genC.h:75
void free(void *)
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
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
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
size_t gen_length(const list l)
Definition: list.c:150
#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 CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
statement make_continue_statement(entity)
Definition: statement.c:953
statement add_declaration_statement(statement, entity)
Definition: statement.c:2790
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
Definition: hash.c:183
#define full_name(dir, name)
Definition: compile.c:414
static const char * old_name(entity module, entity obj)
old name of obj while in module now.
Definition: compile.c:354
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
#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 pips_internal_error
Definition: misc-local.h:149
#define user_error(fn,...)
Definition: misc-local.h:265
#define BLOCK_SEP_CHAR
Definition: naming-local.h:51
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define BLOCK_SEP_STRING
Scope separator.
Definition: naming-local.h:50
#define assert(ex)
Definition: newgen_assert.h:41
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
string strupper(string, const char *)
Definition: string.c:213
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
int tag
TAG.
Definition: newgen_types.h:92
#define string_undefined
Definition: newgen_types.h:40
intptr_t _int
_INT
Definition: newgen_types.h:53
#define UU
Definition: newgen_types.h:98
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static entity dynamic_area
int add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
Definition: variable.c:1386
entity make_scalar_entity(const char *name, const char *module_name, basic base)
entity make_scalar_entity(name, module_name, base)
Definition: variable.c:331
entity make_place_holder_variable(entity de)
Definition: variable.c:2059
entity make_integer_constant_entity(_int c)
entity make_integer_constant_entity(int c) make entity for integer constant c
Definition: variable.c:1345
entity get_ith_dummy(string prefix, string suffix, int i)
Returns a numbered entity the name of which is suffix + number, the module of which is prefix.
Definition: variable.c:1711
void AddEntityToDeclarations(entity e, entity module)
END_EOLE.
Definition: variable.c:108
list double_entities
Definition: variable.c:895
dimension entity_ith_dimension(entity e, int i)
Another semantics would be: is this reference r to e a kill for e? In general, this cannot be answere...
Definition: variable.c:1228
bool variable_static_p(entity v)
true if v appears in a SAVE statement, or in a DATA statement, or is declared static i C.
Definition: variable.c:1579
static int unique_string_number
Definition: variable.c:418
#define DEFAULT_DERIVED_ENUM_PREFIX
Definition: variable.c:441
entity generate_pseudo_formal_variable_for_formal_label(const char *p, int l)
Definition: variable.c:1744
list real_entities
Definition: variable.c:892
entity make_new_scalar_variable_with_prefix(const char *prefix, entity module, basic b)
Create a new scalar variable of type b in the given module.
Definition: variable.c:592
bool integer_scalar_entity_p(entity e)
integer_scalar_entity_p() is obsolete; use entity_integer_scalar_p()
Definition: variable.c:1137
bool const_variable_p(entity v)
Definition: variable.c:1687
static void GenericAddLocalEntityToDeclarations(entity e, entity module, statement s, bool add_declaration_statement_p)
See the two user interfaces below.
Definition: variable.c:152
entity make_new_entity(basic ba, int kind)
Definition: variable.c:898
bool variable_in_common_p(entity v)
true if v is in a common.
Definition: variable.c:1570
bool variable_return_p(entity v)
True if a variable is the pseudo-variable used to store value returned by a function:
Definition: variable.c:1522
entity make_new_index_entity(entity old_index, string suffix)
Definition: variable.c:1851
static int count_tmp
These globals variables count the number of temporary and auxiliary entities.
Definition: variable.c:864
list complex_entities
Definition: variable.c:894
void reset_unique_variable_numbers()
Definition: variable.c:421
int add_variable_to_area(entity a, entity v)
Definition: variable.c:1376
#define DEFAULT_POINTER_PREFIX
Definition: variable.c:435
entity find_or_create_typed_entity(string name, const char *module_name, tag base)
Looks for an entity of the specified basic.
Definition: variable.c:1046
bool entity_atomic_reference_p(entity e)
Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable...
Definition: variable.c:1163
bool variable_dynamic_p(entity v)
Definition: variable.c:1586
static int unique_float_number
Definition: variable.c:415
bool array_with_numerical_bounds_p(entity a)
bool array_with_numerical_bounds_p(entity a) input : an array entity output : true if all bounds of a...
Definition: variable.c:1266
entity find_or_create_scalar_entity(const char *name, const char *module_name, tag base)
Looks for an entity which should be a scalar of the specified basic.
Definition: variable.c:1025
expression generate_string_for_alternate_return_argument(string i)
Definition: variable.c:1721
bool entity_scalar_p(entity e)
The concrete type of e is a scalar type.
Definition: variable.c:1113
bool place_holder_variable_p(entity ph)
Definition: variable.c:2069
static int count_aux
Definition: variable.c:865
bool variable_stack_p(entity v)
Definition: variable.c:1593
#define DEFAULT_COMPLEX_PREFIX
Definition: variable.c:433
bool global_variable_p(entity v)
Is v a global variable such as "int i;".
Definition: variable.c:1510
void AddEntityToCurrentModuleWithoutDeclaration(entity e)
Add a variable entity to the current module declarations.
Definition: variable.c:271
bool variable_in_list_p(entity e, list l)
Definition: variable.c:1623
list logical_entities
Definition: variable.c:893
list char_entities
Definition: variable.c:896
bool implicit_c_variable_p(entity v)
Definition: variable.c:1877
bool same_scalar_location_p(entity e1, entity e2)
FI: transferred from semantics (should be used for effect translation as well)
Definition: variable.c:1992
int add_C_variable_to_area(entity a, entity v)
Definition: variable.c:1381
entity generate_variable_with_unique_name_to_module(const char *seed_name, const char *prefix, const char *suffix, entity module)
Generate a new variable name from a seed name to a module.
Definition: variable.c:460
bool entity_static_variable_p(entity e)
return true if the entity is declared with the keyword static
Definition: variable.c:1146
void RemoveLocalEntityFromDeclarations(entity e, entity module, statement s)
Definition: variable.c:120
static int unique_integer_number
Definition: variable.c:414
bool formal_label_replacement_p(entity fp)
Definition: variable.c:1797
static entity make_array_entity(const char *name, const char *module_name, basic base, list dimensions)
Create an array entity.
Definition: variable.c:752
entity make_global_entity_from_local(entity local)
Definition: variable.c:281
entity make_new_module_variable(entity module, int d)
Make a new module integer variable of name X<d>.
Definition: variable.c:830
entity make_scalar_integer_entity(const char *name, const char *module_name)
Create an integer variable of name "name" in module of name "module_name".
Definition: variable.c:1068
entity make_derived_entity(const char *name, const char *module_name, type t)
Definition: variable.c:378
bool symbolic_constant_entity_p(entity e)
BEGIN_EOLE.
Definition: variable.c:83
bool volatile_variable_p(variable v)
Definition: variable.c:1649
bool self_initialization_p(entity v)
Check if a variable is initialized by itself as "int a = a;" is legal C code according to gcc.
Definition: variable.c:1966
bool entity_unbounded_p(entity e)
bool entity_unbounded_p(entity e) input : an array entity output : true if the last dimension of the ...
Definition: variable.c:1252
int new_add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
Definition: variable.c:1436
#define DEFAULT_FLOAT_PREFIX
Definition: variable.c:431
entity make_new_array_variable_with_prefix(const char *prefix, entity module, basic b, list dimensions)
J'ai ameliore la fonction make_new_scalar_variable_with_prefix
Definition: variable.c:785
entity make_new_array_variable(entity module, basic b, list dimensions)
Definition: variable.c:793
bool static_global_variable_p(entity v)
Is v a global variable declared local to a C file such "static int i;".
Definition: variable.c:1498
bool qualified_variable_p(entity v, unsigned int is_qualified)
The variable may turn out to be a function.
Definition: variable.c:1666
bool formal_parameter_p(entity v)
Definition: variable.c:1489
void AddEntityToCurrentModule(entity e)
Add a variable entity to the current module declarations.
Definition: variable.c:260
bool actual_label_replacement_p(expression eap)
Assumes that eap is a call.
Definition: variable.c:1811
static int unique_logical_number
Definition: variable.c:416
#define DEFAULT_DERIVED_UNION_PREFIX
Definition: variable.c:440
#define DEFAULT_STRUCT_PREFIX
Definition: variable.c:436
#define DEFAULT_LOGICAL_PREFIX
Definition: variable.c:432
entity clone_variable_with_unique_name(entity old_variable, statement declaration_statement, string prefix, string suffix, entity module)
Clone a variable with a new user name.
Definition: variable.c:562
static bool unique_entity_name_p(const char *name, entity in_module)
Handling of entity as program variables (see also entity.c for generic entities)
Definition: variable.c:49
bool entity_volatile_variable_p(entity v)
Definition: variable.c:1637
bool entity_non_pointer_scalar_p(entity e)
Definition: variable.c:1193
entity make_new_scalar_variable(entity module, basic b)
Definition: variable.c:741
void AddLocalEntityToDeclarations(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:233
bool call_contains_alternate_returns_p(call c)
Definition: variable.c:1835
list integer_entities
Make a new variable entity which name is one letter prefix + one incrementing number.
Definition: variable.c:891
#define PLACE_HOLDER_PREFIX_STRING
Generate special variables to represent declarations such as "struct s;".
Definition: variable.c:2057
bool entity_integer_scalar_p(entity e)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
Definition: variable.c:1130
bool variable_is_a_module_formal_parameter_p(entity a_variable, entity a_module)
Definition: variable.c:1547
#define DEFAULT_STRING_PREFIX
Definition: variable.c:434
entity make_stderr_variable()
If the parser has not (yet) encountered "stderr", a PIPS transformation or instrumentation phase may ...
Definition: variable.c:302
bool formal_context_variable_p(entity v)
Such pseudo-variables are generated by the points-to analysis.
Definition: variable.c:1535
#define DEFAULT_DERIVED_STRUCT_PREFIX
Definition: variable.c:439
entity make_temporary_pointer_to_array_entity(entity efrom, expression from, entity module)
Definition: variable.c:819
entity make_new_derived_entity_with_prefix(const char *prefix, entity module, type t)
derived from make_new_scalar_variable_with_prefix
Definition: variable.c:685
void remove_variable_entity(entity v)
Definition: variable.c:1306
#define DEFAULT_INT_PREFIX
Default prefixes.
Definition: variable.c:430
static int unique_complex_number
Definition: variable.c:417
bool variable_in_module_p(entity v, entity m)
This test can only be applied to variables, not to functions, subroutines or commons visible from a m...
Definition: variable.c:1610
#define DEFAULT_ENUM_PREFIX
Definition: variable.c:438
entity make_temporary_pointer_to_array_entity_with_prefix(char *prefix, entity efrom, entity module, expression from)
Definition: variable.c:801
list struct_variable_to_fields(entity v)
Assume that v is declared as a struct.
Definition: variable.c:2045
int variable_entity_dimension(entity v)
variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.
Definition: variable.c:1293
bool variable_entity_p(entity e)
See also macro entity_variable_p()...
Definition: variable.c:70
expression variable_initial_expression(entity v)
Returns a copy of the initial (i.e.
Definition: variable.c:1899
#define DEFAULT_UNION_PREFIX
Definition: variable.c:437
void AddLocalEntityToDeclarationsOnly(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:253
bool variable_heap_p(entity v)
Definition: variable.c:1600
void discard_module_declaration_text(entity a_module)
Discard the decls_text string of the module code to make the prettyprinter ignoring the textual decla...
Definition: variable.c:1696
entity generic_clone_variable_with_unique_name(entity old_variable, statement declaration_statement, string prefix, string suffix, entity module, bool insert_p)
clone a variable with a new name.
Definition: variable.c:509
static char * module
Definition: pips.c:74
static const char * prefix
#define STDERR_NAME
#define DEFAULT_INTEGER_TYPE_SIZE
#define statement_block_p(stat)
#define make_entity(n, t, s, i)
#define DYNAMIC_RAM_OFFSET
FI: I would have assumed that it is used for the stack area, but I must be wrong.....
#define IMPLICIT_VARIABLE_NAME_1
Implicit variable names for C.
#define UNKNOWN_RAM_OFFSET
#define entity_declarations(e)
MISC: newgen shorthands.
#define IMPLICIT_VARIABLE_NAME_2
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
#define instruction_block(i)
bool dynamic_area_p(entity aire)
Definition: area.c:68
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86
int current_offset_of_area(entity a, entity v)
Definition: area.c:174
bool formal_area_p(entity aire)
Definition: area.c:95
bool static_area_p(entity aire)
Definition: area.c:77
bool entity_special_area_p(entity e)
Definition: area.c:154
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
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
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
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
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 c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
code entity_code(entity e)
Definition: entity.c:1098
entity entity_to_module_entity(entity e)
Find the enclosing module of an entity.
Definition: entity.c:2053
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
entity entity_empty_label(void)
Definition: entity.c:1105
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
code EntityCode(entity e)
this function checks that e has an initial value code.
Definition: entity.c:301
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
bool entity_basic_p(entity e, enum basic_utype basictag)
return true if the basic associated with entity e matchs the passed tag
Definition: entity.c:1405
bool entity_module_p(entity e)
Definition: entity.c:683
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
bool expression_call_p(expression e)
Definition: expression.c:415
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
bool unbounded_dimension_p(dimension dim)
bool unbounded_dimension_p(dim) input : a dimension of an array entity.
Definition: expression.c:1130
bool expression_with_constant_signed_integer_value_p(expression e)
The expression may be complicated but all its leaves are constants or parameters.
Definition: expression.c:960
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
Definition: expression.c:1263
type ultimate_type(type)
Definition: type.c:3466
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993
list derived_type_to_fields(type)
Definition: type.c:5381
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
Definition: type.c:4880
int NumberOfDimension(entity)
Definition: size.c:588
bool overloaded_type_p(type)
Returns true if t is a variable type with a basic overloaded.
Definition: type.c:2666
basic basic_ultimate(basic)
get the ultimate basic from a basic typedef
Definition: type.c:1806
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
#define value_tag(x)
Definition: ri.h:3064
#define type_enum_p(x)
Definition: ri.h:2968
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_undefined
Definition: ri.h:3016
@ is_basic_derived
Definition: ri.h:579
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_pointer
Definition: ri.h:578
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
@ is_basic_logical
Definition: ri.h:573
@ is_basic_complex
Definition: ri.h:575
#define value_code_p(x)
Definition: ri.h:3065
#define qualifier_tag(x)
Definition: ri.h:2175
#define normalized_undefined
Definition: ri.h:1745
#define type_struct_p(x)
Definition: ri.h:2962
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define code_undefined
Definition: ri.h:757
#define storage_formal_p(x)
Definition: ri.h:2522
#define basic_complex_p(x)
Definition: ri.h:626
#define area_size(x)
Definition: ri.h:544
#define value_constant(x)
Definition: ri.h:3073
#define basic_int_p(x)
Definition: ri.h:614
#define call_function(x)
Definition: ri.h:709
#define QUALIFIER(x)
QUALIFIER.
Definition: ri.h:2106
#define reference_variable(x)
Definition: ri.h:2326
#define basic_derived(x)
Definition: ri.h:640
#define storage_tag(x)
Definition: ri.h:2515
#define value_intrinsic_p(x)
Definition: ri.h:3074
#define type_tag(x)
Definition: ri.h:2940
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define symbolic_constant(x)
Definition: ri.h:2599
#define constant_int(x)
Definition: ri.h:850
#define ram_undefined
Definition: ri.h:2221
#define value_unknown_p(x)
Definition: ri.h:3077
#define qualifier_volatile_p(x)
Definition: ri.h:2182
#define dimension_lower(x)
Definition: ri.h:980
#define basic_tag(x)
Definition: ri.h:613
@ is_constant_int
Definition: ri.h:817
#define type_variable(x)
Definition: ri.h:2949
#define basic_pointer_p(x)
Definition: ri.h:635
#define entity_storage(x)
Definition: ri.h:2794
#define type_union_p(x)
Definition: ri.h:2965
@ is_value_unknown
Definition: ri.h:3035
@ is_value_constant
Definition: ri.h:3033
#define code_declarations(x)
Definition: ri.h:784
#define storage_ram_p(x)
Definition: ri.h:2519
#define value_constant_p(x)
Definition: ri.h:3071
#define ram_section(x)
Definition: ri.h:2249
#define value_symbolic(x)
Definition: ri.h:3070
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_storage_ram
Definition: ri.h:2492
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define constant_int_p(x)
Definition: ri.h:848
#define expression_undefined
Definition: ri.h:1223
#define value_symbolic_p(x)
Definition: ri.h:3068
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define dimension_upper(x)
Definition: ri.h:982
#define value_code(x)
Definition: ri.h:3067
#define syntax_call(x)
Definition: ri.h:2736
#define variable_qualifiers(x)
Definition: ri.h:3124
#define type_area(x)
Definition: ri.h:2946
#define basic_float(x)
Definition: ri.h:619
#define instruction_expression(x)
Definition: ri.h:1541
#define expression_undefined_p(x)
Definition: ri.h:1224
#define value_reference_p(x)
Definition: ri.h:3083
#define variable_dimensions(x)
Definition: ri.h:3122
#define code_decls_text(x)
Definition: ri.h:786
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_instruction(x)
Definition: ri.h:2458
#define storage_ram(x)
Definition: ri.h:2521
#define type_undefined
Definition: ri.h:2883
#define ram_function(x)
Definition: ri.h:2247
#define storage_rom_p(x)
Definition: ri.h:2525
#define call_arguments(x)
Definition: ri.h:711
@ is_qualifier_const
Definition: ri.h:2127
#define statement_undefined_p(x)
Definition: ri.h:2420
@ is_type_enum
Definition: ri.h:2907
@ is_type_functional
Definition: ri.h:2901
@ is_type_variable
Definition: ri.h:2900
@ is_type_union
Definition: ri.h:2906
@ is_type_struct
Definition: ri.h:2905
#define entity_type(x)
Definition: ri.h:2792
#define value_expression_p(x)
Definition: ri.h:3080
#define expression_syntax(x)
Definition: ri.h:1247
#define storage_return_p(x)
Definition: ri.h:2516
#define type_variable_p(x)
Definition: ri.h:2947
#define basic_bit_p(x)
Definition: ri.h:632
#define symbolic_expression(x)
Definition: ri.h:2597
#define value_expression(x)
Definition: ri.h:3082
#define storage_undefined_p(x)
Definition: ri.h:2477
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define variable_basic(x)
Definition: ri.h:3120
#define statement_undefined
Definition: ri.h:2419
#define basic_logical_p(x)
Definition: ri.h:620
#define ram_offset(x)
Definition: ri.h:2251
struct _newgen_struct_variable_ * variable
Definition: ri.h:463
#define basic_float_p(x)
Definition: ri.h:617
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
char * strdup()
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73
s1
Definition: set.c:247
static string buffer
Definition: string.c:113
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207