PIPS
entity.c
Go to the documentation of this file.
1 /*
2 
3  $Id: entity.c 23495 2018-10-24 09:19:47Z 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 /* Functions closely related to the entity class, constructors, predicates,...
28  */
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <ctype.h>
33 
34 #include "linear.h"
35 
36 #include "genC.h"
37 #include "misc.h"
38 #include "ri.h"
39 #include "properties.h"
40 #include "ri-util.h"
41 
42 /********************************************************************/
43 /* Static variable to memoïze some entities for performance reasons */
44 /********************************************************************/
45 
46 
47 /* variables to store internal entities created at bootstrap
48  beware: these variables are intialized during the parser phase
49 */
51 /* effects package entities */
60 
61 /* continue statement */
63 
64 /* variables to store entities from standard includes */
65 /* As they are not created at bootstrap as the internal entities,
66  they cannot be initialized at the same time because the
67  corresponding entities may not have been already created
68 */
70 /* stdio files entities */
74 
75 #define STATIC_ENTITY_CACHE_SIZE 128
77 static size_t static_entity_size=0;
78 
79 /* beware: cannot be called on creating the database */
81 {
83  {
88  }
89 }
90 
91 /* beware: cannot be called on creating the database */
93 {
95  {
112 
114 
116  }
117 }
118 
120 {
121 
130 
132  for(size_t i =0;i< static_entity_size;i++)
136 }
137 
139 {
144 }
145 
147 {
150 }
151 
152 
153 /* add given entity to the set of entities that must reset upon workspace deletion
154  * practically, all static entities should be stored that way
155  */
158  pips_assert("static entity cache is large enough",static_entity_size<STATIC_ENTITY_CACHE_SIZE);
159 }
160 
161 
162 /********************************************************************/
163 
166 
168 {
169  FOREACH(ENTITY, e, l) {
170  fprintf(stderr, "%s ", entity_name(e));
171  }
172 }
173 
175 {
176  /* For some reason, here entity is not capitalized. */
177  SET_FOREACH(entity, e, s) {
178  fprintf(stderr, "%s ", entity_name(e));
179  }
180 }
181 
182 
183 /* The source language is not specified. Might not work with C because
184  of module_local_name. Also, the compilation unit is undefined.
185 
186 
187  It might be necessary to declare the four areas in
188  code_declarations.
189 
190  See also InitAreas() and init_c_areas(), which use global variables
191  and hence cannot be used outside of the parsers. Beware of the
192  consistency between this function and those two.
193 
194  See also MakeCurrentFunction(), which is part of the Fortran
195  parser.
196  */
198  type r, language l)
199 {
200  const char* name;
203 
204  /* FC: added to allow reintrance in HPFC */
205  if (e!=entity_undefined)
206  {
207  pips_debug(1,"module %s already exists, returning it\n", full_name);
208  return e;
209  }
210 
211  pips_assert("undefined", e == entity_undefined);
212 
213  e = make_entity
214  (strdup(full_name),
216  make_functional(NIL, r)),
220  l)));
221 
222  name = module_local_name(e);
229 
236 
243 
250 
252  entity_type(PointerArea) = make_type_area(make_area(0, NIL));
253  entity_storage(PointerArea) = make_storage_rom();
254  entity_initial(PointerArea) = make_value_unknown();
256  AddEntityToDeclarations(PointerArea, e);
257 
258  return(e);
259 }
260 
261 entity make_empty_program(const char* name,language l)
262 {
264  MODULE_SEP_STRING MAIN_PREFIX, name, NULL);
266 }
267 
269 {
271  MODULE_SEP_STRING, name, NULL);
273 }
274 
276 {
277  pips_assert("Module are only defined in Fortran95",language_fortran95_p(l));
279  MODULE_SEP_STRING, F95MODULE_PREFIX, name, NULL);
281 }
282 
283 entity make_empty_function(const char* name, type r, language l)
284 {
286  MODULE_SEP_STRING, name, NULL);
287  return make_empty_module(full_name, r,l);
288 }
289 
291 {
293  BLOCKDATA_PREFIX, name, NULL);
295 }
296 
297 ␌
298 /* this function checks that e has an initial value code. if yes returns
299 it, otherwise aborts. */
300 
302 {
303  value ve = entity_initial(e);
304  pips_assert("EntityCode", value_tag(ve) == is_value_code);
305  return(value_code(ve));
306 }
307 ␌
308 entity make_label(const char* module_name, const char* local_name)
309 {
311  if( type_undefined_p(entity_type(l)) ) {
315  }
316  return l;
317 }
318 
319 /* Maximal value set for Fortran 77 */
320 static int init = 100000;
321 
323 {
324  init = 100000;
325 }
327 {
328  string local_name;
329  const char *module_name ;
330  const char * format;
331 
332  pips_assert( "module != 0", module != 0 ) ;
333 
334  if( module == entity_undefined ) {
336  format = "%d";
337  }
338  else {
340  format = c_module_p(module)?LABEL_PREFIX "l%d":LABEL_PREFIX "%d";
341  }
342  --init;
343  for(asprintf(&local_name, format, init);
345  free(local_name);
346  --init;
347  asprintf(&local_name, format, init);
348  /* loop */
349  }
350  if(init == 0) {
351  pips_internal_error("no more available labels");
352  }
353  return local_name;
354 }
355 
356 /* This function returns a new label */
358 {
359  /* FI: do labels have to be declared?*/
360  /* FI: it's crazy; the name is usually derived from the entity
361  by the caller and here the entity is retrieved from its name! */
363  const char * module_name = entity_undefined_p(module)?
367 
368 }
369 
370 entity make_loop_label(int __attribute__ ((unused)) desired_number,
371  entity module)
372 {
374  return e;
375 }
376 ␌
377 static bool label_defined_in_statement = false;
379 
381 {
384  }
386 }
387 
389 {
392 
395 
397 }
398 
400 {
402  bool defined_p = label_defined_in_statement_p(l, s);
403 
404  return defined_p;
405 }
406 
408 {
410  pips_assert("entity defined",!entity_undefined_p(l));
412  bool defined_p = label_defined_in_statement_p(l, s);
413 
414  return defined_p;
415 }
416 
418 {
420 
421  bool defined_p = label_defined_in_statement_p(l, s);
422 
423  return defined_p;
424 }
425 ␌
426 /* predicates and functions for entities
427  */
428 
429 /* BEGIN_EOLE */ /* - please do not remove this line */
430 /* Lines between BEGIN_EOLE and END_EOLE tags are automatically included
431  in the EOLE project (JZ - 11/98) */
432 
434 {
435  string sn = string_undefined;
436 
437  if(entity_undefined_p(e))
438  sn = "undefined object, entity assumed";
439  else if(entity_domain_number(e)!= entity_domain)
440  sn = "not an entity";
441  else
442  sn = entity_name(e);
443  return sn;
444 }
445 
446 
447 /* entity_local_name modified so that it does not core when used in
448  * vect_fprint, since someone thought that it was pertinent to remove the
449  * special care of constants there. So I added something here, to deal
450  * with the "null" entity which codes the constant. FC 28/11/94.
451  * SG: should return a const pointer
452  */
453 const char* entity_local_name(entity e)
454 {
455  const char* null_name = "null";
456  pips_assert("entity is defined", !entity_undefined_p(e));
457  pips_assert("constant term or entity",
458  e==NULL || entity_domain_number(e)==entity_domain);
459  return e==NULL ? null_name : local_name(entity_name(e));
460 }
461 
462 
463 /* Used instead of the macro to pass as formal argument */
465 {
466  //string null_name = "null";
467  pips_assert("entity is defined", !entity_undefined_p(e));
468  return entity_name(e);
469 }
470 
471 /* Since entity_local_name may contain PIPS special characters such as
472  prefixes (label, common, struct, union, typedef, ...), this
473  entity_user_name function is created to return the initial
474  entity/variable name, as viewed by the user in his code.
475 
476  In addition, all possible seperators (file, module, block, member)
477  are taken into account.
478 
479  Function strstr locates the occurence of the last special character
480  which can appear just before the initial name, so the order of test
481  is important.
482 
483  01/08/2003 Nga Nguyen -
484 
485  @return pointer to the the user name (not newly allocated!)
486 */
487 const char * entity_user_name(entity e)
488 {
489  string gn = entity_name(e);
490  const char* un = global_name_to_user_name(gn);
491  return un;
492 }
493 ␌
494 /* Functions used to manage the block scoping in conjunction with
495  ContextStack and yco
496 ntext */
497 
498 string empty_scope() { return strdup("");}
499 
500 bool empty_scope_p(string s) {return strcmp(s, "")==0;}
501 
502 /* same kind of testing required for union as well */
503 bool string_struct_scope_p(string s)
504 {
505  /* Full testing would require a module_name, a block_scope and a struct name */
506  /* Just lookup the struct identifier*/
507  string ss = strchr(s, MEMBER_SEP_CHAR);
508  return ss != NULL;
509 }
510 
511 bool string_block_scope_p(string s)
512 {
513  // A block scope string is empty or made of numbers each terminated by BLOCK_SEP_STRING
514  char valid[12] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', BLOCK_SEP_CHAR, '\0'};
515  bool is_block_scope = false;
516  string cs = s;
517  bool is_number = false;
518 
519  pips_debug(10, "Potential block scope string = \"%s\"\n", s);
520 
521  if(strspn(s, valid) == strlen(s)) {
522  for(cs=s; *cs!='\0'; cs++) {
523  if(is_number && isdigit(*cs))
524  ;
525  else if(is_number && *cs==BLOCK_SEP_CHAR)
526  is_number = false;
527  else if(!is_number && isdigit(*cs))
528  is_number = true;
529  else if(!is_number && *cs==BLOCK_SEP_CHAR) {
530  is_block_scope = false;
531  break;
532  }
533  }
534  is_block_scope = !is_number;
535  }
536 
537  pips_debug(10, "String = \"%s\" is %sa block scope string\n", s, is_block_scope?"":"not ");
538 
539  return is_block_scope;
540 }
541 
542 /* allocates a new string */
544 {
545  string en = entity_name(e);
546  const char* mn = entity_module_name(e);
547  string ns = strrchr(en, BLOCK_SEP_CHAR);
548  string enws = string_undefined;
549 
550  if(ns==NULL)
551  enws = strdup(en);
552  else
553  enws = strdup(concatenate(mn, MODULE_SEP_STRING, ns+1, NULL));
554 
555  pips_debug(9, "entity name = \"%s\", without scope: \"%s\"\n",
556  en, enws);
557 
558  return enws;
559 }
560 
561 
562 /* allocates a new string */
563 string local_name_to_scope(const char* ln)
564 {
565  string ns = strrchr(ln, BLOCK_SEP_CHAR);
566  string s = string_undefined;
567 
568  if(ns==NULL)
569  s = empty_scope();
570  else
571  s = strndup(ln, ns-ln+1);
572 
573  pips_debug(8, "local name = \"%s\", scope: \"%s\"\n",
574  ln, s);
575 
576  return s;
577 }
578 
579 
580 /* Returns the module local user name
581  */
582 const char* module_local_name(entity e)
583 {
584  /* No difference between modules and other entities, except for prefixes */
585  const char* name = local_name(entity_name(e));
586 
587  return (name
589 }
590 
591 /* Returns a pointer towards the resource name. The resource name is
592  the module local name: it may include the */
594 {
595  const char* rn = entity_local_name(e);
596 
598 
599  return rn;
600 }
601 
602 /* END_EOLE */
603 
604 const char* label_local_name(entity e)
605 {
606  const char* name = local_name(entity_name(e));
607  return name+sizeof(LABEL_PREFIX) -1 ;
608 }
609 
610 bool label_name_conflict_with_labels(const char* n, list ll)
611 {
612  bool conflict_p = false;
613  if(!empty_label_p(n)) {
614  FOREACH(ENTITY, l, ll) {
615  if(strcmp(label_local_name(l), n) == 0)
616  conflict_p = true;
617  }
618  }
619  return conflict_p;
620 }
621 
622 /* Return a name valid for sorting variables in vectors and constraint
623  systems.
624 
625  @return the name or "TCST" if the entity is null.
626 */
628 {
629  if (e != NULL)
630  return entity_name(e);
631  else
632  return "TCST";
633 }
634 
635 
636 /* See next function! */
637 /*
638 string
639 entity_relative_name(e)
640 entity e;
641 {
642  entity m = get_current_module_entity();
643  string s = string_undefined;
644 
645  pips_assert("entity_relative_name", !entity_undefined_p(m));
646 
647  s = (strcmp(module_local_name(m), entity_module_name(m)) == 0) ?
648  entity_local_name(e) : entity_name(e) ;
649 
650  return s;
651 }
652 */
653 
655 {
657  string name ;
658  pips_assert("some current entity", !entity_undefined_p(m));
659 
662 
663  return name +sizeof(COMMON_PREFIX) -1;
664 }
665 
667 {
668  const char* lln = entity_local_name(e);
669  bool empty_p = empty_label_p(lln);
670  return empty_p;
671 }
672 
674 {
675  return return_label_p(entity_name(e));
676 }
677 
679 {
680  return type_statement_p(entity_type(e));
681 }
682 
684 {
685  if(typedef_entity_p(e))
686  /* Functional typedef also have value code ... */
687  return false;
688  else {
689  value v = entity_initial(e);
690  return v!=value_undefined && value_code_p(v);
691  }
692 }
693 
695 {
696  const char* name = entity_name(e);
697  return strncmp(name,F95_USE_LOCAL_NAME,strlen(F95_USE_LOCAL_NAME)) == 0;
698 }
699 
701 {
703  // && (strspn(entity_local_name(e), MAIN_PREFIX)==1
704  // || same_string_p(entity_local_name(e), "main"));
705 }
706 
708  return entity_module_p(e) &&
709  strspn(entity_local_name(e), F95MODULE_PREFIX)==1;
710 }
711 
713 {
714  return entity_module_p(e) &&
715  strspn(entity_local_name(e), BLOCKDATA_PREFIX)==1;
716 }
717 
719 {
720  return entity_module_p(e) && /* ?????? */
721  strspn(entity_local_name(e), COMMON_PREFIX)==1;
722 }
723 
725 {
726  type
727  t_ent = entity_type(e),
728  t = (type_functional_p(t_ent) ?
731 
732  return(entity_module_p(e) &&
733  !type_undefined_p(t) &&
734  !type_void_p(t));
735 }
736 
738 {
739  return entity_module_p(e) &&
740  !entity_main_module_p(e) &&
741  !entity_blockdata_p(e) && /* ??? */
742  !entity_function_p(e);
743 }
744 
746 {
749  return !basic_undefined_p(b) && basic_pointer_p(b);
750 }
751 
752 /* Is e a variable with an array type?
753  */
755 {
756  if (entity_variable_p(e)) {
758  }
759  return false;
760 }
761 
762 /* @return whether entity is a "register" variable
763  *
764  * See also entity_volatile_variable_p()
765  */
767 {
768  if (entity_variable_p(e))
769  {
771  if (qualifier_register_p(q))
772  return true;
773  }
774  return false;
775 }
776 
777 /* Assuming that v is of type variable, add a qualifier register */
779 {
780  if(!entity_register_p(v)) {
781  //type uvt = ultimate_type(entity_type(v))
782  type vt = entity_type(v);
783  if(type_variable_p(vt)) {
786  *ql = gen_nconc(*ql, CONS(QUALIFIER, q , NIL));
787  }
788  else
789  pips_internal_error("Improper argument\n");
790  }
791 }
792 
794 {
795  return entity_array_p(e);
796 }
797 
799  bool return_val = false;
800  if (entity_variable_p(e)) {
802  }
803  return return_val;
804 }
805 
806 
808 {
809  /* return true if e has an assumed-size array declarator
810  (the upper bound of the last dimension is equal to * : REAL A(*) )*/
811  if (entity_variable_p(e))
812  {
814  list l_dims = variable_dimensions(v);
815  if (l_dims != NIL)
816  {
817  int length = gen_length(l_dims);
818  dimension last_dim = find_ith_dimension(l_dims,length);
819  if (unbounded_dimension_p(last_dim))
820  return true;
821  }
822  }
823  return false;
824 }
825 
827 {
828  /* return true if e has a pointer-type array declarator
829  (the upper bound of the last dimension is equal to 1: REAL A(1) )*/
830  if (entity_variable_p(e))
831  {
833  list l_dims = variable_dimensions(v);
834  if (l_dims != NIL)
835  {
836  int length = gen_length(l_dims);
837  dimension last_dim = find_ith_dimension(l_dims,length);
838  expression exp = dimension_upper(last_dim);
840  return true;
841  }
842  }
843  return false;
844 }
845 
847 {
848  /* return true if e is an assumed-size array or a pointer-type array*/
850  return true;
851  return false;
852 }
853 
854 
855 
856 /* e is the field of a structure */
858 {
859  const char* eln = entity_local_name(e);
860  bool field_p = false;
861 
862  if(*eln!='\'' && *eln!='"') {
863  const char* pos = strrchr(eln, MEMBER_SEP_CHAR);
864 
865  field_p = pos!=NULL;
866  }
867 
868  return field_p;
869 }
870 
871 /* f is a field of a structure: what is its structure?
872  *
873  * To get the structure name, we have to drop the field part of f's
874  * name and to insert a struct prefix before the struct name. Maybe,
875  * it would have been better to keep the struct prefix in the field
876  * name.
877  */
878 static
880 {
882  const string sn = strdup(entity_name(f)); /* structure name */
883  string pos = strrchr(sn, MEMBER_SEP_CHAR);
884  string usn = string_undefined;
885  int usnl = 0;
886 
887  pips_assert("The entity is a field", pos!=NULL);
888 
889  *pos = '\0'; /* get rid of the field name */
890  usn = strdup(global_name_to_user_name(sn));
891  usnl = strlen(usn);
892  *(pos-usnl) = prefix;
893  /* can be done in place because the field name is at least one
894  character long and because we also gain the field marker */
895  (void) strcpy(pos-usnl+1, usn);
896  free(usn);
897 
898  pips_debug(8, "struct entity name is \"\%s\"\n", sn);
900  free(sn);
901 
902  return s;
903 }
904 
906 {
908 
909  /* To be able to breakpoint effectively */
910  if(entity_undefined_p(s))
911  pips_assert("entity s is defined", !entity_undefined_p(s));
912  return s;
913 }
914 
916 {
918 
919  /* To be able to breakpoint effectively */
920  if(entity_undefined_p(u))
921  pips_assert("entity s is defined", !entity_undefined_p(u));
922  return u;
923 }
924 
926 {
928 
929  if(entity_undefined_p(su))
931 
932  /* To be able to breakpoint effectively */
933  if(entity_undefined_p(su))
934  pips_assert("entity s is defined", !entity_undefined_p(su));
935 
936  return su;
937 }
938 
939 /* f is a field of a structure or of an union: what is its rank? */
941 {
942  int rank = -1;
944  type st = entity_type(su);
945  list fl = list_undefined;
946 
947  if(type_struct_p(st))
948  fl = type_struct(st);
949  else if(type_union_p(st))
950  fl = type_union(st);
951  else
952  pips_internal_error("Unexpected type tag %d", type_tag(st));
953 
954  pips_assert("st is a struct or union type",
955  type_struct_p(st) || type_union_p(st));
956 
957  /* FI: positions are counted from 1 on; do we want to subtract 1? */
958  rank = gen_position((void *) f, fl);
959 
960  if(rank==0) {
961  pips_internal_error("Field \"\%s\" is not part of its %s \"\%s\"",
962  entity_name(f), type_struct_p(st)?"structure":"union" , entity_name(su));
963  }
964 
965  return rank;
966 }
967 
969 {
970  /* Base the predicate on the entity name as for struct and union.*/
971  //return type_enum_p(entity_type(e));
972  const char* ln = entity_local_name(e);
973  string ns = strrchr(ln, BLOCK_SEP_CHAR);
974  bool struct_p = (ns==NULL && *ln==ENUM_PREFIX_CHAR)
975  || (ns!=NULL && *(ns+1)==ENUM_PREFIX_CHAR)
976  || (strstr(entity_name(e),ENUM_PREFIX DUMMY_ENUM_PREFIX)!=NULL);
977  return struct_p;
978 }
979 
981 {
982  value ev = entity_initial(e);
983  /* SG: not all entities seem to have this field defined if not
984  * defined, assume it's not an enum, although i am unsure of the
985  * validity of this:
986  *
987  * pips_assert("Value of e is defined", !value_undefined_p(ev));
988  */
989  return !value_undefined_p(ev) && value_symbolic_p(ev);
990 }
991 
996 }
997 
998 /* Is entity e the entity corresponding to a struct declaration?
999  *
1000  * Note the difference with entity_array_p()
1001  */
1003 {
1004  const char* ln = entity_local_name(e);
1005  string ns = strrchr(ln, BLOCK_SEP_CHAR);
1006  bool struct_p = (ns==NULL && *ln==STRUCT_PREFIX_CHAR)
1007  || (ns!=NULL && *(ns+1)==STRUCT_PREFIX_CHAR)
1008  || (strstr(entity_name(e),STRUCT_PREFIX DUMMY_STRUCT_PREFIX)!=NULL);
1009  return struct_p;
1010 }
1011 
1012 bool same_struct_entity_p(const entity e0, const entity e1)
1013 {
1016  return same_entity_p(s0,s1);
1017 }
1018 
1019 bool same_field_entity_p(const entity f1, const entity f2)
1020 {
1021  bool same_p = false;
1022  type t1 = entity_type(f1);
1023  type t2 = entity_type(f2);
1024  if(type_structurally_equal_p(t1,t2)) {
1025  string n1 = (string) entity_user_name(f1);
1026  string n2 = (string) entity_user_name(f2);
1027  if(same_string_p(n1, n2))
1028  same_p = true;
1029  }
1030 
1031  return same_p;
1032 }
1033 
1034 /* Is entity e an entity representing the union declaration?
1035  *
1036  * See entity_struct_p(), but different from entity_array_p()
1037  */
1039 {
1040  const char* ln = entity_local_name(e);
1041  string ns = strrchr(ln, BLOCK_SEP_CHAR);
1042  bool union_p = (ns==NULL && *ln==UNION_PREFIX_CHAR)
1043  || (ns!=NULL && *(ns+1)==UNION_PREFIX_CHAR)
1044  || (strstr(entity_name(e),UNION_PREFIX DUMMY_UNION_PREFIX)!=NULL);
1045  return union_p;
1046 }
1047 
1049 {
1050  return entity_struct_p(e) || entity_union_p(e) || entity_enum_p(e);
1051 }
1052 
1053 /* This test shows that "e" has been declared in "module".
1054  *
1055  * Well, "e" may not be declared in "module". For instance, "e" may be
1056  * a value of a variable declared in "module".
1057  *
1058  * This does not show in Fortran that e is a variable with effects local
1059  * to the module because e can be allocated in a common. Variables with
1060  * local effects are allocated either in the static or the dynamic or the
1061  * stack area.
1062  *
1063  * Variables with effects lost on return are allocated either in the
1064  * dynamic or stack areas. Effects on static variables may or not escape.
1065  *
1066  * Of course, this predicate returns false for some variables declared
1067  * in "module", extern variables for instance.
1068  */
1070 {
1071  bool
1072  result = same_string_p(entity_module_name(e),
1074 
1075  debug(6, "local_entity_of_module_p",
1076  "%s %s %s\n",
1077  entity_name(e), result ? "in" : "not in", entity_name(module));
1078 
1079  return(result);
1080 }
1081 
1083 {
1084  storage s = entity_storage(e);
1085 
1086  return(storage_ram_p(s) &&
1088 }
1089 
1090 /* See comments about module_name(). Its result is transient and must
1091  be strduped. */
1093 {
1094  return module_name(entity_name(e));
1095 }
1096 
1097 
1099 {
1100  value ve = entity_initial(e);
1101  pips_assert("entity_code",value_code_p(ve));
1102  return(value_code(ve));
1103 }
1104 
1106 {
1107  /* FI: it is difficult to memoize entity_empty_label because its value is changed
1108  * when the symbol table is written and re-read from disk; Remi's memoizing
1109  * scheme was fine as long as the entity table lasted as long as one run of
1110  * pips, i.e. is not adequate for wpips
1111  */
1112  /* static entity empty = entity_undefined; */
1113  entity empty;
1114 
1118  NULL), entity_domain);
1119  pips_assert("The empty label is defined", empty != entity_undefined );
1120 
1121  return empty;
1122 }
1123 
1124 /* Check if the scope of entity e is global.
1125 
1126  People are likely to look for global_entity_p(), entity_global_p()
1127  or, slightly different, global_variable_p(), variable_global_p(),
1128  or still slightly different, global_function_p(),...
1129  */
1131 {
1132  bool top = (strcmp(TOP_LEVEL_MODULE_NAME, entity_module_name(e)) == 0);
1133 
1134  return top;
1135 }
1136 
1137 /* Several implicit entities are declared to define the implicit
1138  effects of IO statements. */
1140 {
1142  return (same_entity_p(e, luns_ent) || same_entity_p(e, io_ptr_ent)
1144 }
1145 
1147 {
1149  return (same_entity_p(e, luns_ent));
1150 }
1151 
1153 {
1155  return (same_entity_p(e, rand_gen_ent));
1156 }
1157 
1159 {
1161  return (same_entity_p(e, malloc_effect_ent));
1162 
1163 }
1164 
1167  return (same_entity_p(e, memmove_effect_ent));
1168 }
1169 
1172  return (same_entity_p(e, time_effect_ent));
1173 }
1174 
1175 /**
1176  checks if an entity is an IO_EFFECTS_PACKAGE_NAME, a
1177  MALLOC_EFFECTS_NAME or a RAND_EFFECTS_PACKAGE_NAME entity. These
1178  entities are used to model some internal effects of standard libraries
1179  and they do not conflict with other entities.
1180  */
1182 {
1183 #ifndef NDEBUG
1184  bool result = rand_effects_entity_p(e)
1187  || time_effect_entity_p(e)
1188  || io_entity_p(e);
1189  pips_assert("entity kind is consistent", result == ((entity_kind(e) & EFFECTS_PACKAGE) == EFFECTS_PACKAGE));
1190 #endif
1191  return entity_kind(e) & EFFECTS_PACKAGE;
1192 }
1193 
1194 
1195 
1196 
1198 {
1200  return stdin_ent;
1201 }
1202 
1204 {
1205  return same_entity_p(e, get_stdin_entity());
1206 }
1207 
1208 
1210 {
1212  return stdout_ent;
1213 }
1214 
1216 {
1217  return same_entity_p(e, get_stdout_entity());
1218 }
1219 
1221 {
1223  return stderr_ent;
1224 }
1225 
1227 {
1228  return same_entity_p(e, get_stderr_entity());
1229 }
1230 
1231 
1233 {
1235  return(same_entity_p(e, stdin_ent)
1236  || same_entity_p(e, stdout_ent)
1237  || same_entity_p(e, stderr_ent));
1238 }
1239 
1240 /* Dummy standard files targets */
1241 
1242 
1244 {
1245  string std_file_name;
1246  static string std_file_target_suffix = "";
1247  if (stdin_entity_p(e)) std_file_name = "stdin";
1248  else if (stdout_entity_p(e)) std_file_name = "stdout";
1249  else std_file_name = "stderr";
1250 
1251  string target_name;
1252  asprintf(&target_name,"__%s__%s", std_file_name, std_file_target_suffix);
1253 
1255  target_name);
1256 
1257  if (type_undefined_p(entity_type(target)))
1258  {
1259  type t = entity_type(e);
1265  0, NIL));
1266  entity_kind(target) = EFFECTS_PACKAGE;
1267  }
1268 
1269  return target;
1270 }
1271 
1273 {
1275 }
1276 
1278 {
1280 }
1281 
1282 bool intrinsic_name_p(const char *local_name) {
1284  return !entity_undefined_p(e) && intrinsic_entity_p(e);
1285 }
1286 
1287 /* FI: I do not understand this function name (see next one!). It seems to me
1288  * that any common or user function or user subroutine would
1289  * be returned.
1290  * FI: assert condition made stronger (18 December 1998)
1291  */
1292 entity entity_intrinsic(const char* name)
1293 {
1296  name,
1297  NULL),
1298  entity_domain);
1299 
1300  pips_assert("entity_intrinsic", e != entity_undefined
1301  && intrinsic_entity_p(e));
1302  return(e);
1303 }
1304 
1305 
1306 
1307 /* this function does not create an intrinsic function because they must
1308  all be created beforehand by the bootstrap phase (see
1309  bootstrap/bootstrap.c). */
1310 
1312 {
1314  pips_assert("entity is defined", e!=entity_undefined );
1315  pips_assert("entity is intrinsic", intrinsic_entity_p(e));
1316  return(e);
1317 }
1318 
1319 /* predicates on entities */
1320 
1322 {
1323  return(e1 == e2);
1324 }
1325 
1326 /* Comparison function for qsort.
1327  */
1328 int compare_entities(const entity *pe1, const entity *pe2)
1329 {
1330  int
1331  null_1 = (*pe1==(entity)NULL),
1332  null_2 = (*pe2==(entity)NULL);
1333 
1334  if (null_1 || null_2)
1335  // FI: I reverse the test to place the constant term at the end of
1336  //the vector so as to regenerate expressions with trailing
1337  //constant terms; for instance, I get J+1 instead of 1+J.
1338  // Of course, this impacts PIPS code generation
1339  //return(null_2-null_1);
1340  return(null_1-null_2);
1341  else {
1342  /* FI: Which sorting do you want? */
1343 
1344  //string s1 = entity_name_without_scope(*pe1);
1345  //string s2 = entity_name_without_scope(*pe2);
1346  //int c = strcmp(s1, s2);
1347  //
1348  //free(s1);
1349  //free(s2);
1350  //
1351  //return c;
1352  return strcmp(entity_name(*pe1), entity_name(*pe2));
1353  }
1354 }
1355 
1356 /* sorted in place.
1357  */
1359 {
1361 }
1362 
1363 /* true if var1 <= var2
1364  */
1366 {
1367  /* TCST is before anything else
1368  */
1369  if ((Variable) var1==TCST) return(true);
1370  if ((Variable) var2==TCST) return(false);
1371 
1372  /* else there are two entities
1373  */
1374 
1375  return(strcmp(entity_local_name(var1), entity_local_name(var2))<=0);
1376 }
1377 
1378 /* return the basic associated to entity e if it's a function/variable/constant
1379  * basic_undefined otherwise */
1381 {
1382  if (e != entity_undefined) {
1383  type t = entity_type(e);
1384 
1385  if (type_functional_p(t))
1387  if (type_variable_p(t))
1388  return (variable_basic(type_variable(t)));
1389  }
1390  return (basic_undefined);
1391 }
1392 /* return the qualifiers associated to entity e if it's a variable
1393  * NIL otherwise */
1395 {
1396  if (e != entity_undefined) {
1397  type t = entity_type(e);
1398  if (type_variable_p(t))
1399  return (variable_qualifiers(type_variable(t)));
1400  }
1401  return NIL;
1402 }
1403 
1404 /* return true if the basic associated with entity e matchs the passed tag */
1405 bool entity_basic_p(entity e,enum basic_utype basictag)
1406 {
1407  return basic_tag(entity_basic(e)) == basictag;
1408 }
1409 
1410 /* Checks that el only contains entity*/
1412 {
1413  bool pure = true;
1414 
1415  FOREACH(ENTITY, e, el)
1416  {
1417  static entity le = entity_undefined;
1418  pips_debug(10, "Entity e in list is \"%s\"\n", safe_entity_name(e));
1420  pips_debug(8, "Last entity le in list is \"%s\"\n", safe_entity_name(le));
1421  pure = false;
1422  break;
1423  }
1424  le = e;
1425  }
1426  return pure;
1427 }
1428 
1429 /* this function maps a local name, for instance P, to the corresponding
1430  * TOP-LEVEL entity, whose name is TOP-LEVEL:P. n is the local name.
1431  */
1432 #define PREFIXES_SIZE 5
1433 static string prefixes[] = {
1434  "",
1435  MAIN_PREFIX,
1437  COMMON_PREFIX,
1439 };
1440 
1441 
1442 /**
1443  * @brief This function try to find a top-level entity from a local name
1444  *
1445  * @description Because of static C function, the entity returned is not always
1446  * a top-level entity.
1447  *
1448  * @return the entity if found, else entity_undefined
1449  */
1451 {
1453 
1454  /* Extension with C: the scope of a module can be its compilation unit if this is
1455  a static module, not only TOP-LEVEL. */
1456 
1457  if (static_module_name_p(n)) {
1458  string cun = strdup(n);
1459  string sep = strchr(cun, FILE_SEP);
1460  *(sep+1) = '\0';
1461  module = FindEntity(cun,n);
1462  free(cun);
1463  }
1464  else
1465  {
1466  for(int i=0; i<PREFIXES_SIZE && entity_undefined_p(module); i++)
1469  entity_domain);
1470  }
1471 
1472  return module;
1473 }
1474 
1475 /**
1476  * @brief This is an alias for local_name_to_top_level_entity
1477  * @return the entity if found, else entity_undefined
1478  */
1480  return local_name_to_top_level_entity(mn);
1481 }
1482 /* similar to module_name_to_entity
1483  * but generates a warning and a stub if the entity is not found
1484  */
1486 {
1487  entity e = module_name_to_entity(name);
1488  if ( entity_undefined_p( e ) )
1489  {
1490  pips_user_warning("entity %s not defined, pips is likely to crash soon\n"
1491  "Please feed pips with its definition and source\n",name);
1493  }
1494 
1495  return e;
1496 }
1497 
1498 
1499 /**
1500  * @brief Retrieve an entity from its package/module name and its local name
1501  * @return the entity if found, else entity_undefined
1502  */
1503 entity FindEntity(const char* package, const char* name ) {
1506  name,
1507  NULL ),
1508  entity_domain );
1509 }
1510 
1511 /* Find an entity, if it exists, from its global name, a.k.a. its
1512  * entity name.
1513  *
1514  * Let's avoid Newgen interface, gen_find_tabulated(), in PIPS passes.
1515  */
1516 entity global_name_to_entity(const char* name ) {
1517  return gen_find_tabulated(name, entity_domain );
1518 }
1519 
1520 entity FindEntityFromUserName( const char* package, const char* name ) {
1521  entity e = FindEntity(package, name);
1522  if ( entity_undefined_p(e) ) {
1525  name,
1526  NULL ),
1527  entity_domain );
1528  }
1529  if ( entity_undefined_p(e) ) {
1532  name,
1533  NULL ),
1534  entity_domain );
1535  }
1536  return e;
1537 }
1538 
1539 
1540 /* BEGIN_EOLE */ /* - please do not remove this line */
1541 /* Lines between BEGIN_EOLE and END_EOLE tags are automatically included
1542  in the EOLE project (JZ - 11/98) */
1543 
1544 /*
1545  * Cette fonction est appelee chaque fois qu'on rencontre un nom dans le texte
1546  * du pgm Fortran. Ce nom est celui d'une entite; si celle-ci existe deja on
1547  * renvoie son indice dans la table des entites, sinon on cree une entite vide
1548  * qu'on remplit partiellement.
1549  *
1550  * full_name est dupliqué.
1551  *
1552  * Modifications:
1553  * - partial link at parse time for global entities (Remi Triolet?)
1554  * - partial link limited to non common variables (Francois Irigoin,
1555  * 25 October 1990); see below;
1556  * - no partial link: no information is available about "name"'s type; it
1557  * can be a local variable as well as a global one; if D is a FUNCTION and
1558  * D is parsed and put in the database, any future D would be interpreted
1559  * as a FUNCTION and an assignment like D = 0. would generate a parser
1560  * error message (Francois Irigoin, 6 April 1991)
1561  * - partial link limited to intrinsic: it's necessary because there is no
1562  * real link; local variables having the same name as an intrinsic will
1563  * cause trouble; I did not find a nice way to fix the problem later,
1564  * as it should be, in update_called_modules(), MakeAtom() or MakeCallInst()
1565  * it would be necessary to rewrite the link phase; (Francois Irigoin,
1566  * 11 April 1991)
1567  * - no partial link at all: this is incompatible with the Perfect Club
1568  * benchmarks; variables DIMS conflicts with intrinsics DIMS;
1569  * (Francois Irigoin, ?? ???? 1991)
1570  */
1571 
1572 entity CreateEntity(const char *package_name, const char * local_name)
1573 {
1574  char * name;
1575  asprintf(&name,"%s"MODULE_SEP_STRING"%s",package_name, local_name);
1577  return e;
1578 }
1579 
1580 
1581 
1582 /* Problem: A functional global entity may be referenced without
1583  parenthesis or CALL keyword in a function or subroutine call.
1584  See SafeFindOrCreateEntity().
1585 */
1586 entity FindOrCreateEntity(const char* package /* package name */,
1587  const char* local_name /* entity name */)
1588 {
1589  entity e;
1592  }
1593  return e;
1594 }
1595 
1596 
1597 /* Return a top-level entity
1598 
1599  @param name of the entity to find/construct
1600 
1601  @return the entity
1602 */
1604 {
1606 }
1607 
1608 
1609 /* FIND_MODULE returns entity. Argument is module_name */
1610 /* This function should be replaced by local_name_to_top_level_entity() */
1611 /*entity FindEntity(_module(name)
1612 string name;
1613 {
1614  string full_name = concatenate(TOP_LEVEL_MODULE_NAME,
1615  MODULE_SEP_STRING, name, NULL);
1616  entity e = gen_find_tabulated(full_name, entity_domain);
1617 
1618  return(e);
1619 }
1620 */
1621 
1622 
1623 /* END_EOLE */
1624 
1625 /* returns a range expression containing e's i-th bounds */
1627 {
1628  dimension d = entity_ith_dimension(e, i);
1632  int_to_expression(1)));
1634 }
1635 
1636 
1637 /*true is a statement s is an io intrinsic*/
1638 /*bool statement_contains_io_intrinsic_call_p(statement s)
1639 {
1640  IoElementDescriptor *pid = IoElementDescriptorTable;
1641  bool found = false;
1642 
1643  while ((pid->name != NULL) && (!found)) {
1644  if (strcmp(pid->name, s) == 0)
1645  {
1646  found = true;
1647  return true;
1648  }
1649  }
1650  return false;
1651 }*/
1652 
1653 /* true if e is an io instrinsic
1654  */
1656 {
1675 
1676  /*Fortran*/
1678  //entity_intrinsic(PRINT_FUNCTION_NAME),
1688  NULL);
1689  }
1691  return true;
1692  else
1693  return false;
1694 }
1695 
1696 /* true if e is an arithmetic instrinsic
1697  *
1698  * Used to determine if a logical argument must be promoted to integer
1699  *
1700  * FI: the arithmetic operator set is not fully defined. To be completed.
1701  */
1703 {
1715  NULL);
1716  }
1718  return true;
1719  else
1720  return false;
1721 }
1722 
1723 /* true if continue. See also macro ENTITY_CONTINUE_P
1724  */
1725 
1727 {
1729  return continue_ent;
1730 }
1732 {
1733  return same_entity_p(f, get_continue_entity());
1734 }
1735 
1736 
1737 /**************************************************** CHECK COMMON INCLUSION */
1738 
1739 /* returns the list of entity to appear in the common declaration.
1740  */
1741 list /* of entity */ common_members_of_module(entity common,
1742  entity module,
1743  bool only_primary /* not the equivalenced... */)
1744 {
1745  list result = NIL;
1746  int cumulated_offset = 0;
1747  pips_assert("entity is a common", entity_area_p(common));
1748 
1749  list ld = area_layout(type_area(entity_type(common)));
1751 
1752  for(; !ENDP(ld);ld = CDR(ld))
1753  {
1754  v = ENTITY(CAR(ld));
1755  storage s = entity_storage(v);
1756  ram r;
1757  pips_assert("storage ram", storage_ram_p(s));
1758  r = storage_ram(s);
1759  if (ram_function(r)==module)
1760  {
1761  int offset = ram_offset(r);
1762  int size = 0;
1763 
1764  if(heap_area_p(ram_section(r))) {
1765  size = 0;
1766  }
1767  else if(stack_area_p(ram_section(r))) {
1768  size = 0;
1769  }
1770  else {
1771  if(!SizeOfArray(v, &size)) {
1772  pips_internal_error("Varying size array \"%s\"", entity_name(v));
1773  }
1774  }
1775 
1776  if (cumulated_offset==offset || !only_primary)
1777  result = CONS(ENTITY, v, result);
1778  else
1779  break; /* drop equivalenced that come hereafter... */
1780 
1781  cumulated_offset+=size;
1782  }
1783  }
1784 
1785  return gen_nreverse(result);
1786 }
1787 
1788 /* This function creates a common for a given name in a given module.
1789  This is an entity with the following fields :
1790  Example: SUBROUTINE SUB1
1791  COMMON /FOO/ W1,V1
1792 
1793  name = top_level:~name (TOP-LEVEL:~FOO)
1794  type = area
1795  with size = 8 [2*8], layout = NIL [SUB1:W,SUB1:V]
1796  storage = ram
1797  with function = module (TOP-LEVEL:SUB1) (first occurence ? SUB2,SUB3,..)
1798  section = TOP-LEVEL:~FOO (recursive ???)
1799  offset = undefined
1800  shared = NIL
1801  initial = unknown
1802 
1803  The area size and area layout must be updated each time when
1804  a common variable is added to this common */
1805 
1806 entity make_new_common(string name, entity mod)
1807 {
1808  string common_global_name = strdup(concatenate(TOP_LEVEL_MODULE_NAME,
1810  COMMON_PREFIX,name,NULL));
1811  type common_type = make_type(is_type_area, make_area(8, NIL));
1812  entity StaticArea =
1814  storage common_storage = make_storage(is_storage_ram,
1815  (make_ram(mod,StaticArea, 0, NIL)));
1816  value common_value =
1819  make_sequence(NIL),
1820  NIL,
1822 
1823  return make_entity(common_global_name,
1824  common_type,
1825  common_storage,
1826  common_value);
1827 }
1828 
1829 /* This function creates a common variable in a given common in a given module.
1830  This is an entity with the following fields :
1831  name = module_name:name (SUB1:W1)
1832  type = variable
1833  with basic = int, dimension = NIL
1834  storage = ram
1835  with function = module (TOP-LEVEL:SUB1)
1836  section = common (TOP-LEVEL:~FOO)
1837  offset = 0
1838  shared =
1839  initial = unknown
1840 
1841  The common must be updated with new area size and area layout */
1842 
1844 {
1845  string var_global_name = strdup(concatenate(module_local_name(mod),MODULE_SEP_STRING,
1846  name,NULL));
1848  storage var_storage = make_storage(is_storage_ram,
1849  (make_ram(mod,com,0,NIL)));
1850  value var_value = make_value_unknown();
1851  entity e = make_entity(var_global_name,var_type,var_storage,var_value);
1852  //area_layout(type_area(entity_type(com))) = CONS(ENTITY,e,NIL);
1853  return e;
1854 }
1855 
1856 
1857 #define declaration_formal_p(E) storage_formal_p(entity_storage(E))
1858 #define entity_to_offset(E) formal_offset(storage_formal(entity_storage(E)))
1859 
1860 /* This function gives back the ith formal parameter, which is found in the
1861  * declarations of a call or a subroutine.
1862  */
1864 {
1865  list ldecl = code_declarations(value_code(entity_initial(the_fnct)));
1867 
1868  while (ldecl != NULL)
1869  {
1870  current = ENTITY(CAR(ldecl));
1871  ldecl = CDR(ldecl);
1873  return current;
1874  }
1875 
1876  pips_internal_error("cannot find the %d dummy argument of %s",
1877  rank, entity_name(the_fnct));
1878 
1879  return entity_undefined;
1880 }
1881 
1882 /* @return the list of entities in module the name of which is given
1883  * warning: the entity is created if it does not exist!
1884  * @param module the name of the module for the entities
1885  * @param names a string of comma-separated of entity names
1886  */
1887 list /* of entity */ string_to_entity_list(string module, string names)
1888 {
1889  list le = NIL;
1890  string s, next_comma = (char*) 1;
1891  for (s = names; s && *s && next_comma;)
1892  {
1893  next_comma = strchr(s, ',');
1894  if (next_comma) *next_comma = '\0';
1895  le = CONS(ENTITY, FindOrCreateEntity(module, s), le);
1896  s += strlen(s)+1;
1897  if (next_comma) *next_comma = ',';
1898  }
1899  return le;
1900 }
1901 
1903 {
1904  /* Its name must contain the TYPEDEF_PREFIX just after the
1905  MODULE_SEP_STRING and the scope information */
1906  string en = entity_name(e);
1907  string ms = strrchr(en, BLOCK_SEP_CHAR);
1908  bool is_typedef = false;
1909 
1910  /* If there is no scope information, use the module separator */
1911  if(ms==NULL)
1912  ms = strchr(en, MODULE_SEP);
1913 
1914 
1915  if(ms!=NULL)
1916  is_typedef = (*(ms+1)==TYPEDEF_PREFIX_CHAR);
1917 
1918  return is_typedef;
1919 }
1920 
1922 {
1923  /* Its name must contain the MEMBER_PREFIX after the MODULE_SEP_STRING */
1924  string en = entity_name(e);
1925  string ms = strchr(en, MODULE_SEP);
1926  bool is_member = false;
1927 
1928  if(ms!=NULL)
1929  is_member = (strchr(ms, MEMBER_SEP_CHAR)!=NULL);
1930 
1931  return is_member;
1932 }
1933 
1934 /* is p a formal parameter? */
1936 {
1937  return formal_parameter_p(p);
1938 }
1939 
1940 /* is p a dummy parameter? */
1942 {
1943  string pn = entity_name(p);
1944  string dummy = strstr(pn, DUMMY_PARAMETER_PREFIX);
1945  bool is_dummy = (pn==dummy);
1946 
1947  pips_debug(9, "pn=\"%s\", dummy=\"%s\"\n", pn, dummy);
1948 
1949  return is_dummy;
1950 }
1951 
1952 ␌
1953 /* This is useful for the C language only */
1955 {
1957 
1958  pips_assert("name is a compilation unit name", compilation_unit_p(name));
1959 
1960  /* Normally, the storage must be rom but in order to store the list of entities
1961  declared with extern, we use the ram storage to put this list in ram_shared*/
1965 
1966  if(!type_undefined_p(entity_type(e)))
1967  free_type(entity_type(e));
1969 
1973 
1974  return e;
1975 }
1976 
1978 {
1979  /* There are two cases for "extern"
1980 
1981  - The current module is a compilation unit and the entity is in
1982  the ram_shared list of the ram storage of the compilation unit.
1983 
1984  - The current module is a normal function and the entity has a
1985  global scope.
1986 */
1987  // Check if e belongs to module
1988  /* bool isbelong = true;
1989  list ld = entity_declarations(m);
1990  //ifdebug(1) {
1991  pips_assert("e is visible in module",gen_in_list_p(e,ld));
1992  // pips_assert("module is a module or compilation unit",entity_module_p(m)||compilation_unit_entity_p(m));
1993  pips_assert("e is either variable or function", variable_entity_p(e),functional_entity_p(e));
1994  //}
1995  if(variable_entity_p(e))
1996  //{
1997  if (compilation_unit_entity_p(m){
1998  // return(strstr(entity_name(e),
1999  //}
2000  //else
2001  {
2002  //return(strstr(entity_name(e),TOP_LEVEL_MODULE_NAME) != NULL);
2003  //}
2004  //}
2005  //else
2006  //return(static_module_name_p(e));
2007  */
2008  /* return ((compilation_unit_entity_p(module) && gen_in_list_p(e,ram_shared(storage_ram(entity_storage(module)))))
2009  ||(!compilation_unit_entity_p(module) && (strstr(entity_name(e),TOP_LEVEL_MODULE_NAME) != NULL)));
2010  */
2012  ||(!compilation_unit_entity_p(module) && (strstr(entity_name(e),TOP_LEVEL_MODULE_NAME) != NULL)));
2013 
2014 }
2015 
2017 {
2018  /* There are two cases for "extern"
2019 
2020  - The current module is a compilation unit and the entity is in
2021  the ram_shared list of the ram storage of the compilation unit.
2022 
2023  - The current module is a normal function and the entity has a
2024  global scope: this is not an explicit extern declaration.
2025  */
2028 }
2029 
2031 {
2032  string desc = string_undefined;
2033 
2034  if(storage_undefined_p(s))
2035  desc = "storage_undefined";
2036  else if(storage_return_p(s))
2037  desc = "return";
2038  else if(storage_ram_p(s))
2039  desc = "ram";
2040  else if(storage_formal_p(s))
2041  desc = "formal";
2042  else if(storage_rom_p(s))
2043  desc = "rom";
2044  else
2045  pips_internal_error("Unknown storage tag");
2046 
2047  return desc;
2048 }
2049 
2050 /* Find the enclosing module of an entity. If an entity is a module, return e.
2051  If the entity is a top-level entity, return e.*/
2052 /* FI: I'm surprised this function does not exist already */
2054 {
2056 
2057  if(top_level_entity_p(e))
2058  m = e;
2059  else if(entity_module_p(e))
2060  m = e;
2061  else {
2062  const char* mn = entity_module_name(e);
2063  m = module_name_to_entity(mn);
2064  }
2065 
2066  pips_assert("entity m is defined", !entity_undefined_p(m));
2067  pips_assert("entity m is a module or top_level_entity", entity_module_p(m)||top_level_entity_p(e) );
2068 
2069  return m;
2070 }
2071 
2073 {
2077  }
2078  else {
2079  dummy d = parameter_dummy(p);
2080 
2081  pips_debug(8, "Dummy identifier changed from \"\%s\" to \"\%s\"\n",
2083  /* Note that free_entity(dummy_identifier(d)) should be performed... */
2084  dummy_identifier(d) = ep;
2085  }
2086 }
2087 ␌
2088 /* Returns true when f has no parameters */
2090 {
2092 
2093  /* Calls thru pointers require syntax_application */
2094  pips_assert("call to a function", type_functional_p(ft));
2095 
2096  functional ftf = type_functional(ft);
2097  bool mode_p = true;
2098 
2099 
2100  if(!ENDP(functional_parameters(ftf))) {
2101  /* It is assumed that all parameters are passed the same way,
2102  either by valule or by reference */
2104  mode_p = (((int)mode_tag(parameter_mode(p)))==tag);
2105  }
2106  else {
2107  /* We are in trouble... because we have to call a higher-level
2108  function from the preprocessor library. */
2109  if(c_module_p(f))
2110  mode_p = (tag==is_mode_value);
2111  else
2112  mode_p = (tag==is_mode_reference);
2113  }
2114  return mode_p;
2115 }
2117 {
2119 }
2120 
2122 {
2124 }
2125 
2126 /* This function concatenate a package name and a local name to
2127  produce a global entity name.
2128 
2129  Previous comment: This function creates a fortran operator parameter, i.e. a zero
2130  dimension variable with an overloaded basic type.
2131 
2132  Moved from bootstrap.c
2133  */
2134 char * AddPackageToName(p, n)
2135  string p, n;
2136 {
2137  string ps;
2138  int l;
2139 
2140  l = strlen(p);
2141  ps = gen_strndup(p, l + 1 + strlen(n) +1);
2142 
2143  *(ps+l) = MODULE_SEP;
2144  *(ps+l+1) = '\0';
2145  strcat(ps, n);
2146 
2147  return(ps);
2148 }
2149 ␌
2150 /* Returns the binary operator associated to a C update operator such as +=
2151 
2152  If the operator is unknown, an undefined entity is returned.
2153 */
2155 {
2156  entity sop = entity_undefined;
2157 
2158  if(ENTITY_PLUS_UPDATE_P(op))
2160  else if(ENTITY_MINUS_UPDATE_P(op))
2162  else if(ENTITY_MULTIPLY_UPDATE_P(op))
2164  else if(ENTITY_DIVIDE_UPDATE_P(op))
2166  else if(ENTITY_MODULO_UPDATE_P(op))
2168  else if(ENTITY_LEFT_SHIFT_UPDATE_P(op))
2170  else if(ENTITY_RIGHT_SHIFT_UPDATE_P(op))
2172  else if(ENTITY_BITWISE_AND_UPDATE_P(op))
2174  else if(ENTITY_BITWISE_XOR_UPDATE_P(op))
2176  else if(ENTITY_BITWISE_OR_UPDATE_P(op))
2178 
2179  return sop;
2180 }
2181 
2182 
2183 
2184 
2185 
2186 
2187 /**
2188  * checks if an entity is an equivalent
2189  *
2190  * @param e entity to check
2191  *
2192  * @return true if entity is an equivalent
2193  */
2195 {
2196  return storage_ram_p(entity_storage(e))
2198 }
2199 
2200 /**
2201  * compare entity names
2202  *
2203  * @param e1 first entity
2204  * @param e2 second entity
2205  *
2206  * @return true if e1 and e2 have the same name
2207  */
2209 {
2210  return same_string_p(entity_name(e1), entity_name(e2));
2211 }
2212 
2213 /**
2214  * look for @a ent in @a ent_l
2215  *
2216  * @param ent entity to find
2217  * @param ent_l list to scan
2218  *
2219  * @return true if @a ent belongs to @a ent_l
2220  */
2221 bool entity_in_list_p(entity ent, list ent_l)
2222 {
2223  return !gen_chunk_undefined_p(gen_find_eq(ent,ent_l));
2224 }
2225 
2226 /* returns l1 after elements of l2 but not of l1 have been appended to l1. */
2227 /* l2 is freed */
2228 /**
2229  * append all elements of l2 not in l1 to l1 and free l2
2230  *
2231  * @param l1 list to append entities to
2232  * @param l2 list from which the new entities come
2233  *
2234  * @return @a l1 with extra new entities appended
2235  */
2237 {
2238  list new_l2 = NIL;
2239  set s = set_make(set_pointer);
2240  set_assign_list(s, l1);
2241  FOREACH(ENTITY,e,l2) {
2242  if( ! set_belong_p(s,e) )
2243  new_l2=CONS(ENTITY,e,new_l2);
2244  }
2245  gen_free_list(l2);
2246  set_free(s);
2247  return gen_nconc(l1, gen_nreverse(new_l2));
2248 }
2249 
2250 /**
2251  * check if e is used to declare one of the entities in entity list ldecl
2252  *
2253  * @param e entity to check
2254  * @param ldecl list of entities whose declaration may use e
2255  *
2256  * @return @a true if e appears in one of the declaration in ldecl
2257  */
2259 {
2260  bool found_p = false;
2261 
2262  FOREACH(ENTITY, d, ldecl) {
2263  type dt = entity_type(d);
2264  list sel = type_supporting_entities(NIL, dt);
2265 
2266  if(gen_in_list_p(e, sel)) {
2267  pips_debug(8, "entity \"%s\" is used to declare entity \"%s\"\n",
2268  entity_name(e), entity_name(d));
2269  found_p = true;
2270  gen_free_list(sel);
2271  break;
2272  }
2273  else {
2274  gen_free_list(sel);
2275  }
2276  }
2277 
2278  return found_p;
2279 }
2280 
2281 /**
2282  * check if e is used to declare one of the entities in entity list ldecl
2283  *
2284  * @param e entity to check
2285  * @param ldecl list of entities whose declaration may use e
2286  *
2287  * @return @a true if e appears in one of the declaration in ldecl
2288  */
2290 {
2291  bool found_p = false;
2292 
2293  FOREACH(ENTITY, d, ldecl) {
2294  /* The dummy declaration may be hidden in a struct or a union
2295  declaration. Maybe it could also be hidden in a function
2296  declaration. */
2297  type dt = entity_type(d);
2298  if(entity_struct_p(d) || entity_union_p(d) || type_functional_p(dt)) {
2299  list stl = type_supporting_types(dt);
2300 
2301  if(gen_in_list_p(e, stl)) {
2302  pips_debug(8, "entity \"%s\" is used to declare entity \"%s\"\n",
2303  entity_name(e), entity_name(d));
2304  found_p = true;
2305  gen_free_list(stl);
2306  break;
2307  }
2308  else {
2309  gen_free_list(stl);
2310  }
2311  }
2312  }
2313 
2314  return found_p;
2315 }
2316 ␌
2317 
2318 /* Create a copy of an entity, with (almost) identical type, storage
2319  and initial value if move_initialization_p is false, but with a slightly
2320  different name as entities are uniquely known by their names, and a
2321  different offset if the storage is ram (still to be done).
2322 
2323  Entity e must be defined or the function core dumps.
2324 
2325  Depending on its storage, the new entity might have to be inserted
2326  in code_declarations (done) and the memory allocation recomputed (not done).
2327 
2328  Depending on the language, the new entity might have to be inserted
2329  in statement declarations. This is left up to the user of this function.
2330 
2331  For C, name collisions with the compilation unit are not checked
2332  here. They are unlikely, but should be checked by the caller.
2333 
2334  /param e entity to copy
2335  /param global_new_name new name wished
2336  /param systematically_add_suffix if true, automatically add a suffix number
2337  /param move_initialization_p if true, also copy the initial value
2338 
2339  @return the new entity.
2340 */
2342  string global_new_name,
2343  bool systematically_add_suffix,
2344  bool move_initialization_p)
2345 {
2346  entity ne = entity_undefined;
2347  char * variable_name = strdup(global_new_name);
2348  int number = 0;
2349 
2350  if (systematically_add_suffix) {
2352  asprintf(&variable_name, "%s_%d", global_new_name, number++);
2353  }
2354 
2355  /* Find the first matching non-already existent variable name: */
2357  != entity_undefined)
2358  {
2359  if (variable_name != NULL)
2360  /* Free the already allocated name in the previous iteration that
2361  was conflicting: */
2363  asprintf(&variable_name, "%s_%d", global_new_name, number++);
2364  }
2365 
2366  //extended_integer_constant_expression_p(e)
2367 
2369  copy_type(entity_type(e)),
2371  move_initialization_p? copy_value(entity_initial(e)) :
2373  );
2374 
2375  if(storage_ram_p(entity_storage(ne))) {
2376  /* We are in trouble. Up to now, we have created a static alias of
2377  * the variable e (it's a variable entity because of its
2378  * storage). Note that static aliases do not exist in C.
2379  */
2380  ram r = storage_ram(entity_storage(ne));
2381  entity m = ram_function(r);
2382 
2383  /* FI: It would be better to perform the memory allocation right
2384  away, instead of waiting for a later core dump in chains or
2385  ricedg, but I'm in a hurry. -> fixed, BC.
2386  */
2387  //ram_offset(r) = UNKNOWN_RAM_OFFSET;
2388 
2389  const char * module_name = entity_module_name(ne);
2393  int offset = 0;
2394  if (basic_undefined_p(b)) /* I don't know if this can happen, and what we should do in such case. BC. */
2396  else
2397  {
2400  (add_C_variable_to_area(a, ne)):(0);
2401  else
2403  (add_variable_to_area(a, ne)):(0);
2404  }
2405 
2406  ram_offset(r) = offset;
2407 
2408  AddEntityToDeclarations(ne, m);
2409  }
2410  return ne;
2411 }
2412 
2413 /* Create a copy of an entity, with (almost) identical type, storage
2414  and initial value if move_initialization_p is false, but with a slightly
2415  different name as entities are uniquely known by their names, and a
2416  different offset if the storage is ram (still to be done).
2417 
2418  Entity e must be defined or the function core dumps.
2419 
2420  Depending on its storage, the new entity might have to be inserted
2421  in code_declarations (done) and the memory allocation recomputed (not done).
2422 
2423  Depending on the language, the new entity might have to be inserted
2424  in statement declarations. This is left up to the user of this function.
2425 
2426  For C, name collisions with the compilation unit are not checked
2427  here. They are unlikely, but should be checked by the caller.
2428 
2429  /param e entity to copy
2430 
2431  @return the new entity.
2432 */
2434 {
2436  entity_name(e),
2437  false,
2438  true);
2439 }
2440 
2441 /* Create a copy of an entity, with (almost) identical type, storage
2442  and initial value if move_initialization_p is false, but with a slightly
2443  different name as entities are uniquely known by their names, and a
2444  different offset if the storage is ram (still to be done).
2445 
2446  Entity e must be defined or the function core dumps.
2447 
2448  Depending on its storage, the new entity might have to be inserted
2449  in code_declarations (done) and the memory allocation recomputed (not done).
2450 
2451  Depending on the language, the new entity might have to be inserted
2452  in statement declarations. This is left up to the user of this function.
2453 
2454  For C, name collisions with the compilation unit are not checked
2455  here. They are unlikely, but should be checked by the caller.
2456 
2457  /param e entity to copy
2458  /param global_new_name new name wished
2459  /param move_initialization_p if true, also copy the initial value
2460 
2461  @return the new entity.
2462 */
2464  string global_new_name,
2465  bool move_initialization_p)
2466 {
2468  global_new_name,
2469  false,
2470  move_initialization_p);
2471 }
2472 
2473 /* Create a copy of an entity, with (almost) identical type, storage
2474  and initial value if move_initialization_p is false, but with a slightly
2475  different name as entities are uniquely known by their names, and a
2476  different offset if the storage is ram (still to be done).
2477 
2478  Entity e must be defined or the function core dumps.
2479 
2480  Depending on its storage, the new entity might have to be inserted
2481  in code_declarations (done) and the memory allocation recomputed (not done).
2482 
2483  Depending on the language, the new entity might have to be inserted
2484  in statement declarations. This is left up to the user of this function.
2485 
2486  For C, name collisions with the compilation unit are not checked
2487  here. They are unlikely, but should be checked by the caller.
2488 
2489  /param e entity to copy
2490  /param global_new_name new name wished
2491  /param move_initialization_p if true, also copy the initial value
2492 
2493  @return the new entity.
2494 */
2496  string global_new_name,
2497  bool move_initialization_p)
2498 {
2500  global_new_name,
2501  true,
2502  move_initialization_p);
2503 }
2504 
2505 
2506 
2507 ␌
2508 /* FI: it is assumed that thread safe entities are invariant with
2509  respect to workspaces. Another mechanism will be needed if user
2510  variables updated within a critical section also are added to the
2511  thread safe variable set.
2512 
2513  Thread safe entities are supposed to be updated within critical
2514  sections. Hence their dependence arcs may be ignored during
2515  parallelization. There is not gaurantee that the semantics is
2516  unchanged, for isntance pointer values are likely to differ, but
2517  havoc should be avoided and the semantics of programs that are not
2518  dependent on pointer values should be preserved.
2519 
2520  For the time begin, the set is implemented as a list because very
2521  few libc hidden variables are added.
2522 */
2524 
2526 {
2528  /* This might happen when a workspace is closed and another one
2529  open or created within one session. */
2530  //pips_internal_error("Thread-safe entity \"%s\" redeclared", entity_name(v));
2531  ;
2532  }
2533  else {
2534  /* The package name of v could be checked... especially if package names are unified. */
2536  }
2537 }
2538 
2540 {
2541  bool thread_safe_p = gen_in_list_p(v, thread_safe_entities);
2542 
2543  return thread_safe_p;
2544 }
2545 
2546 /* FI: hidden variables added to take into account the side effects in
2547  the libc. Without them, dead code elimination would remove calls to
2548  rand or malloc. However, there is no useful information to be
2549  computed about them. Except perhard, the number of frees wrt the
2550  number of malloc. Hence, they are not taken into account by the
2551  semantics analysis.
2552 
2553  This set may not be a superset of the set of thread-safe variables.
2554 */
2556 
2557 
2559 {
2561  /* This might happen when a workspace is closed and another one
2562  open or created within one session. */
2563  //pips_internal_error("Thread-safe entity \"%s\" redeclared", entity_name(v));
2564  ;
2565  }
2566  else {
2567  /* The package name of v could be checked... especially if package names are unified. */
2569  }
2570 }
2571 
2573 {
2574  bool abstract_state_p = gen_in_list_p(v, abstract_state_entities);
2575 
2576  return abstract_state_p;
2577 }
2578 
2579 /* Make sure that an list is an homogeneous list of entities */
2581 {
2582  bool success_p = true;
2583 
2584  FOREACH(ENTITY, e, el) {
2585  if(!check_entity(e)) {
2586  success_p = false;
2587  break;
2588  }
2589  }
2590  return success_p;
2591 }
2592 
2594 {
2595  const char * en = entity_user_name(op);
2596 
2597  const char * one_neutral []= {
2603  NULL
2604  };
2605  for(int i=0;one_neutral[i];i++)
2606  if(same_string_p(one_neutral[i],en)) return make_integer_constant_entity(1);
2607 
2608  const char * plus_inf_neutral[] = {
2612  NULL
2613  };
2614  for(int i=0;plus_inf_neutral[i];i++)
2615  if(same_string_p(plus_inf_neutral[i],en)) {
2616  pips_user_warning("assuming reduction on integer\n");
2617  return make_integer_constant_entity(UINT_MAX);
2618  }
2619 
2620  const char * minus_inf_neutral[] = {
2622  NULL
2623  };
2624  for(int i=0;minus_inf_neutral[i];i++)
2625  if(same_string_p(minus_inf_neutral[i],en)){
2626  pips_user_warning("assuming reduction on integer\n");
2627  return make_integer_constant_entity(INT_MIN);
2628  }
2629 
2630  const char * zero_neutral [] ={
2640  NULL
2641  };
2642  for(int i=0;zero_neutral[i];i++)
2643  if(same_string_p(zero_neutral[i],en)) return make_integer_constant_entity(0);
2644 
2645  return entity_undefined;
2646 }
2647 
2648 
2649 /* Test if we are allowed to commute operations
2650 
2651  @param[in] c is the operation call
2652 
2653  @return true if we can commute operations
2654 
2655  Note that floating point operations are commutative, but since they are
2656  not associative due to rounding error , in a chain of operations, we
2657  cannot commute them. Of course, we should test whether an operation is
2658  alone or not to see if we are in this case...
2659 */
2660 bool
2662 {
2663  entity op = call_function(c);
2664  bool commut_p = false;
2665  if (ENTITY_PLUS_P(op) || ENTITY_MULTIPLY_P(op) ||
2666  ENTITY_AND_P(op) || ENTITY_OR_P(op) || ENTITY_PLUS_C_P(op))
2667  {
2668  basic b = basic_of_call(c,false,true);
2669  switch(basic_tag(b))
2670  {
2671  case is_basic_float:
2672  case is_basic_complex:
2673  if (get_bool_property("RELAX_FLOAT_ASSOCIATIVITY"))
2674  commut_p = true;
2675  break;
2676  case is_basic_logical:
2677  case is_basic_overloaded:
2678  case is_basic_int:
2679  case is_basic_pointer:
2680  commut_p = true;
2681  break;
2682  default:
2683  pips_internal_error("unhandled case");
2684  }
2685  free_basic(b);
2686  }
2687  return commut_p;
2688 }
2689 
2690 
2691 /**
2692  * @brief build a list of expressions from a list of entities
2693  * @return the list of expression
2694  * @param l_ent, the list of entities
2695  *
2696  * FI: should have been placed in expression.c
2697  *
2698  * FI: no check on arguments, robustness is doubtful; see entity_to_expression()
2699  *
2700  * FI: somebody complaining about the PIPS code structuration in files
2701  * and libraries might have added to the confusion?
2702  **/
2704  list l_exp = NIL;
2705  FOREACH(ENTITY,e,l_ent) {
2706  l_exp = CONS(EXPRESSION, entity_to_expression(e), l_exp);
2707  }
2708  l_exp = gen_nreverse(l_exp);
2709  return(l_exp);
2710 }
2711 
2712 
2714 {
2717  list sdl = list_undefined;
2718  list fdl = list_undefined;
2719 
2720  if(compilation_unit_entity_p(mod)) {
2721  /* if m was declared in the compilation unit cu and used elsewhere, cu may not be parsed yet. */
2722  sdl = NIL;
2723  }
2724  else {
2725  /* Not good in general, but should work for compilation units... */
2726  /* No, it does not... */
2727  sdl = entity_declarations(mod);
2728  }
2729  fdl = gen_nconc(gen_copy_seq(dl), gen_copy_seq(sdl));
2730 
2731  entity ee = entity_undefined;
2732 
2733  ifdebug(8) {
2734  pips_debug(8, "Declarations for enclosing module \"\%s\": \"", entity_name(mod));
2735  print_entities(dl);
2736  //print_entities(sdl);
2737  fprintf(stderr, "\"\n");
2738  }
2739 
2740  FOREACH(ENTITY, e,fdl) {
2741  if(entity_enum_p(e)) {
2742  list ml = type_enum(entity_type(e));
2743 
2744  pips_debug(8, "Checking enum \"\%s\"\n", entity_name(e));
2745 
2746  if(gen_in_list_p((void *) m, ml)) {
2747  ee = e;
2748  break;
2749  }
2750  ifdebug(8) {
2751  if(entity_undefined_p(ee)) {
2752  pips_debug(8, "Member \"\%s\" not found in enum \"\%s\"\n",
2753  entity_name(m), entity_name(e));
2754  }
2755  else {
2756  pips_debug(8, "Member \"\%s\" found in enum \"\%s\"\n",
2757  entity_name(m), entity_name(e));
2758  }
2759  }
2760  }
2761  }
2762 
2763  pips_assert("enum entity is found", !entity_undefined_p(ee));
2764  gen_free_list(fdl);
2765 
2766  return ee;
2767 }
2768 
2769 ␌
2770 /** Test if a module "m" is written in C
2771  *
2772  * value_code_p(m) is not checked: is this code robust? Why not an
2773  * if/else if/ else and a unique return statement?
2774  *
2775  * All intrinsics, including Fortran intrinsics, are considered written in C.
2776  */
2778 {
2779  bool c_p = false;
2780  value v = entity_initial(m);
2781 
2782  if(!value_undefined_p(v)) {
2783  if(value_intrinsic_p(v))
2784  return true;
2786  c_p = language_c_p(l);
2787  /* Temporary fix for the too many make_unknown_language()... */
2788  if(language_unknown_p(l))
2789  pips_internal_error("language should not be unknown");
2790  }
2791  else
2792  pips_internal_error("language should not be unknown");
2793 
2794  return c_p;
2795 }
2796 
2797 /** Test if a module is in Fortran */
2798 /* Could be better factored in with C case */
2800 {
2801  bool fortran_p = false;
2802  value v = entity_initial(m);
2803  if(!value_undefined_p(v)) {
2804  if(value_intrinsic_p(v))
2805  return true;
2806  fortran_p = language_fortran_p(code_language(value_code(v)));
2807  }
2808  else {
2809  /* If this alternative did not exist, the source code should be
2810  moved to ri-util*/
2811  pips_internal_error("Module language should not be unknown.\n");
2812  }
2813  return fortran_p;
2814 }
2815 ␌
2816 typedef struct { list le, lr; } deux_listes;
2817 
2819 {
2820  entity e = reference_variable(r);
2821  if (! (storage_rom_p(entity_storage(e)) &&
2825 
2826  /* Add reference r only once */
2827  if (l->le ==NIL || !gen_in_list_p(e, l->le)) {
2828  l->le = CONS(ENTITY,e, l->le);
2829  l->lr = CONS(REFERENCE,r,l->lr);
2830  }
2831  }
2832 }
2833 /* FI: this function has not yet been extended for C types!!! */
2835 {
2836  list arrays = NIL;
2837  deux_listes lref = { NIL, NIL };
2838 
2839  FOREACH(ENTITY,e,decls) {
2840  type t = entity_type(e);
2841 
2843  arrays = CONS(VARIABLE,type_variable(t), arrays);
2844  }
2845 
2846  FOREACH(VARIABLE,v,arrays)
2847  {
2848  list ldim = variable_dimensions(v);
2849  while (!ENDP(ldim))
2850  {
2851  dimension d = DIMENSION(CAR(ldim));
2853  ldim=CDR(ldim);
2854  }
2855  }
2856  gen_free_list(lref.le);
2857 
2858  return(lref.lr);
2859 }
2861 list l;
2862 {
2863  list l2 = gen_nreverse(gen_copy_seq(l));
2864  Pbase result = BASE_NULLE;
2865  FOREACH(ENTITY, e, l2)
2866  {
2867  Pbase new = (Pbase) vect_new((Variable) e, VALUE_ONE);
2868  new->succ = result;
2869  result = new;
2870  }
2871 
2872  gen_free_list(l2);
2873  return(result);
2874 }
2875 /**
2876  * @name declarations updater
2877  * @{ */
2878 
2879 typedef struct {
2881  bool (*chunk_filter)(void*);
2882  bool (*entity_filter)(entity);
2884 
2885 // helper storing an entity according to filter @p p->entity_filter
2888  if(p->entity_filter(e))
2890 }
2891 
2892 /**
2893  * helper looking in a reference @p r for referenced entities
2894  */
2896 {
2897  if(p->chunk_filter(r)) {
2898  entity e = reference_variable(r);
2900  }
2901 }
2902 
2903 /**
2904  * helper looking in a call for referenced entities
2905  */
2907 {
2908  if(p->chunk_filter(c)) {
2909  entity e = call_function(c);
2911  }
2912 }
2913 
2914 /**
2915  * helper looking in a loop for referenced entities
2916  */
2918 {
2919  if(p->chunk_filter(l)) {
2920  entity e = loop_index(l);
2922  }
2923 }
2924 
2925 
2926 /**
2927  * helper looking in a list for referenced entities
2928  */
2929 static
2931 {
2932  FOREACH(ENTITY,e,l)
2934 }
2935 
2936 /**
2937  * helper looking in a ram for referenced entities
2938  */
2940 {
2941  if(p->chunk_filter(r))
2943 }
2944 
2945 /**
2946  * helper looking in an area for referenced entities
2947  */
2949 {
2950  if(p->chunk_filter(a))
2952 }
2953 /**
2954  * helper looking in a statement declaration for referenced entities
2955  */
2957 {
2958  if(p->chunk_filter(s))
2960  else {
2961  /* you skip the declarations, but not the value / type inside */
2964  set_union(p->entities,p->entities,tmp);
2965  set_free(tmp);
2966  }
2969  set_union(p->entities,p->entities,tmp);
2970  set_free(tmp);
2971  }
2972  }
2973 }
2974 
2975 /* Same as get_referenced_entities,
2976  * but will only consider entities that
2977  * fulfills @p entity_filter
2978  * and will only enter consider entities **directly** involved in object
2979  * matching @p chunk_filter
2980  * \/!\ if you strip out statements, it will not consider declared entities, but it will consider their initial value
2981  */
2983  bool (*chunk_filter)(void*), bool (*entity_filter)(entity))
2984 {
2985  set referenced_entities = set_make(set_pointer);
2986  if(!gen_chunk_undefined_p(elem)) {
2988  referenced_entities,
2989  chunk_filter,
2990  entity_filter
2991  };
2992 
2993  /* if elem is an entity it self, add it */
2994  if(INSTANCE_OF(entity,(gen_chunkp)elem)) {
2995  entity e = (entity)elem;
2996  if(!entity_module_p(e)) {
2997  if(chunk_filter(entity_type(e)))
3001  NULL);
3002  if(!value_undefined_p(entity_initial(e)) && // struct fields have undefined initial
3003  chunk_filter(entity_initial(e)))
3009  NULL);
3010  }
3011  }
3012  else {
3013  /* gather entities from elem */
3014  gen_context_multi_recurse(elem,&p,
3020  NULL);
3021  }
3022 
3023  /* gather all entities referenced by referenced entities */
3024  list ltmp = set_to_list(referenced_entities);
3025  FOREACH(ENTITY,e,ltmp) {
3026  if(e!=elem) {
3027  set tmp = get_referenced_entities_filtered(e,chunk_filter,entity_filter);
3028  set_union(referenced_entities,referenced_entities,tmp);
3029  set_free(tmp);
3030  }
3031  }
3032  gen_free_list(ltmp);
3033 
3034  /* not merged with earlier test to avoid infinite recursion */
3035  if(INSTANCE_OF(entity,(gen_chunkp)elem)) {
3036  entity e = (entity)elem;
3037  set_add_element(referenced_entities,referenced_entities,e);
3038  }
3039  }
3040 
3041  return referenced_entities;
3042 }
3043 
3044 /* Default entity filter for get_referenced_entities()
3045  *
3046  * It filters out constants and intrinsics
3047  *
3048  * It should have been named entity_neither_constant_nor_intrinsic_p()...
3049  */
3051  return !entity_constant_p(e) && ! intrinsic_entity_p(e);
3052 }
3053 /**
3054  * retrieves the set of entities used in @p elem
3055  * beware that this entities may be formal parameters, functions etc
3056  * so consider filter this set depending on your need,
3057  * using get_referenced_entities_filtered
3058  *
3059  * @param elem element to check (any gen_recursifiable type is allowded)
3060  *
3061  * @return set of referenced entities
3062  */
3064 {
3065  return get_referenced_entities_filtered(elem,(bool (*)(void*))gen_true,
3067 
3068 }
3069 
3070 
3071 /* Helper for get_declared_entities()
3072  * Add all locally declared entity to the set given in argument
3073  */
3074 bool do_get_declared_entities(statement s, set declared_entities) {
3076  set_add_element(declared_entities,declared_entities,e);
3077  }
3078  return true;
3079 }
3080 
3081 /**
3082  * retrieves the set of entities declared in @p elem
3083  *
3084  * @return set of referenced entities
3085  */
3087  set the_set = set_make(set_pointer);
3089  return the_set;
3090 }
3091 
3092 
3093 /**
3094  * Check if a variable "var" is local to a module "module".
3095  *
3096  * A variable is local to a module:
3097  *
3098  * - if it has been allocated in one of the module areas such as
3099  * *STATIC*, *DYNAMIC*,...
3100  *
3101  * - if it is a formal parameter passed by value, that is a C scalar
3102  * formal parameter; note that a scalar can be a structure or a union.
3103  */
3105  bool local = false;
3106 
3107  if(storage_ram_p(entity_storage(var))) {
3108  ram r = storage_ram(entity_storage(var));
3109  if(same_entity_p(module, ram_function(r))) {
3110  entity section = ram_section(r);
3112  local=true;
3113  }
3114  }
3115  } else if( storage_formal_p(entity_storage(var))) {
3116  /* it might be better to check the parameter passing mode itself,
3117  via the module type */
3118  bool fortran_p = fortran_module_p(module);
3119  bool scalar_p = entity_scalar_p(var);
3120 
3122  if(!fortran_p && scalar_p && same_entity_p(module, formal_function(r))) {
3123  local=true;
3124  }
3125  }
3126  pips_debug(4,"Looked if variable %s is local to function %s, result is %d\n",
3127  entity_name(var), entity_name(module), local);
3128  return local;
3129 }
3130 
3131 /************************************************ SOME UTILS MOVED FROM HPFC */
3132 
3133 /* hmmm...
3134  */
3135 entity
3137  const char* package,
3138  const char* name,
3139  entity model)
3140 {
3141  string new_name = concatenate(package, MODULE_SEP_STRING, name, NULL);
3142  entity new = gen_find_tabulated(new_name, entity_domain);
3143  area tmp_area = area_undefined;
3144 
3145  pips_debug(8, "entity %s to be made after %s\n",
3146  new_name, entity_name(model));
3147 
3148  ifdebug(9)
3149  pips_assert("consistent model", entity_consistent_p(model));
3150 
3151  return(!entity_undefined_p(new) ? new :
3152  make_entity(copy_string(new_name),
3153  /*
3154  * ??? some bug in copy_type disable the possibility
3155  * of copying area for instance...
3156  *
3157  * moreover I do not wish to copy the layout list
3158  * for commons.
3159  */
3160  (!type_area_p(entity_type(model)) ?
3161  copy_type(entity_type(model)) :
3163  (tmp_area = type_area(entity_type(model)),
3164  make_area(area_size(tmp_area), NIL)))),
3165  copy_storage(entity_storage(model)),
3166  copy_value(entity_initial(model))));
3167 }
3168 
3169 /* !!! caution, it may not be a module, but a common...
3170  */
3172 {
3174  entity_local_name(e), e);
3175 
3176  pips_debug(7, "adding %s to module %s\n",
3177  entity_name(new), entity_name(module));
3178 
3179  if (entity_module_p(module))
3181 
3182  return new;
3183 }
3184 
3185 /* void fprint_entity_list(FILE *fp,list l): prints a list of entities on
3186  * file fp.
3187  */
3188 void fprint_entity_list(FILE *fp, list l)
3189 {
3190  for( ; l != NIL; l = CDR(l))
3191  fprintf(fp, "%s, ", entity_local_name(ENTITY(CAR(l))));
3192 }
3193 
3194 /* Formal parameters do not use the standard ram storage. However, a
3195  formal area is used for points-to stubs */
3197 {
3198  bool in_p = false;
3199  storage s = entity_storage(e);
3200  if(storage_ram_p(s)) {
3201  ram r = storage_ram(s);
3202  entity a = ram_section(r);
3203  in_p = formal_area_p(a);
3204  }
3205  return in_p;
3206 }
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
dummy make_dummy_identifier(entity _field_)
Definition: ri.c:620
functional make_functional(list a1, type a2)
Definition: ri.c:1109
value make_value_unknown(void)
Definition: ri.c:2847
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
value make_value_code(code _field_)
Definition: ri.c:2835
language make_language_fortran(void)
Definition: ri.c:1250
storage make_storage_rom(void)
Definition: ri.c:2285
value make_value_constant(constant _field_)
Definition: ri.c:2841
type copy_type(type p)
TYPE.
Definition: ri.c:2655
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
type make_type_functional(functional _field_)
Definition: ri.c:2718
type make_type_void(list _field_)
Definition: ri.c:2727
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
language copy_language(language p)
LANGUAGE.
Definition: ri.c:1202
entity check_entity(entity p)
Definition: ri.c:2527
type make_type_area(area _field_)
Definition: ri.c:2712
qualifier make_qualifier_register(void)
Definition: ri.c:1933
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
void free_dummy(dummy p)
Definition: ri.c:574
value copy_value(value p)
VALUE.
Definition: ri.c:2784
area make_area(intptr_t a1, list a2)
Definition: ri.c:98
code make_code(list a1, string a2, sequence a3, list a4, language a5)
Definition: ri.c:353
void free_storage(storage p)
Definition: ri.c:2231
language make_language_c(void)
Definition: ri.c:1253
type make_type_unknown(void)
Definition: ri.c:2724
storage copy_storage(storage p)
STORAGE.
Definition: ri.c:2228
void free_type(type p)
Definition: ri.c:2658
constant make_constant_litteral(void)
Definition: ri.c:418
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
void free_basic(basic p)
Definition: ri.c:107
sequence make_sequence(list a)
Definition: ri.c:2125
bool entity_consistent_p(entity p)
Definition: ri.c:2530
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
void free_value(value p)
Definition: ri.c:2787
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
void const char const char const int
#define VALUE_ONE
entity DynamicArea
These global variables are declared in ri-util/util.c.
Definition: area.c:57
entity HeapArea
Definition: area.c:59
entity StaticArea
Definition: area.c:58
entity StackArea
Definition: area.c:60
int dummy
A dummy file, to prevent empty libraries from breaking builds.
Definition: dummy.c:41
static Value offset
Definition: translation.c:283
bool static_module_name_p(const char *name)
Check if the given name is a static module name.
Definition: entity_names.c:122
bool main_module_global_name_p(const char *name)
Argument "name" is a global name.
Definition: entity_names.c:86
bool return_label_p(const char *s)
Definition: entity_names.c:272
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
Definition: entity_names.c:136
bool empty_label_p(const char *s)
Definition: entity_names.c:256
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 * local_name(const char *s)
Does not take care of block scopes and returns a pointer.
Definition: entity_names.c:221
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_chunk_undefined_p(c)
Definition: genC.h:75
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
static char * package
The package name in which functions will be defined.
Definition: genLisp.c:59
void free(void *)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
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
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
int gen_position(const void *item, const list l)
Element ranks are strictly positive as for first, second, and so on.
Definition: list.c:995
#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
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
Definition: list.c:796
#define full_name(dir, name)
Definition: compile.c:414
#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
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
static entity rank
#define COMMON_PREFIX
Definition: naming-local.h:34
#define DUMMY_STRUCT_PREFIX
Definition: naming-local.h:87
#define ENUM_PREFIX_CHAR
Definition: naming-local.h:61
#define STRUCT_PREFIX_CHAR
Definition: naming-local.h:57
#define LABEL_PREFIX
Definition: naming-local.h:31
#define BLOCK_SEP_CHAR
Definition: naming-local.h:51
#define F95MODULE_PREFIX
Definition: naming-local.h:36
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define MODULE_SEP
special characters to build entity names of various kinds
Definition: naming-local.h:27
#define DUMMY_ENUM_PREFIX
For enum and struct and union without names (see c_syntax/cyacc.y)
Definition: naming-local.h:86
#define MEMBER_SEP_CHAR
Definition: naming-local.h:54
#define MAIN_PREFIX
Definition: naming-local.h:32
#define UNION_PREFIX
Definition: naming-local.h:58
#define UNION_PREFIX_CHAR
Definition: naming-local.h:59
#define DUMMY_PARAMETER_PREFIX
For dmmmy parameters in functions declarations.
Definition: naming-local.h:93
#define EMPTY_LABEL_NAME
Its value is "@", the label prefix followed by nothing.
Definition: naming-local.h:96
#define TYPEDEF_PREFIX_CHAR
Definition: naming-local.h:63
#define ENUM_PREFIX
Definition: naming-local.h:60
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define FILE_SEP
Definition: naming-local.h:39
#define BLOCKDATA_PREFIX
Definition: naming-local.h:35
#define DUMMY_UNION_PREFIX
Definition: naming-local.h:88
#define STACK_AREA_LOCAL_NAME
Definition: naming-local.h:72
#define POINTER_DUMMY_TARGETS_AREA_LOCAL_NAME
Definition: naming-local.h:77
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define HEAP_AREA_LOCAL_NAME
Definition: naming-local.h:71
#define STRUCT_PREFIX
Definition: naming-local.h:56
#define F95_USE_LOCAL_NAME
constant names
Definition: naming-local.h:67
#define BLOCK_SEP_STRING
Scope separator.
Definition: naming-local.h:50
string gen_strndup(string, size_t)
string.c
Definition: string.c:59
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
set set_assign_list(set, const list)
assigns a list contents to a set all duplicated elements are lost
Definition: set.c:474
#define set_undefined
Definition: newgen_set.h:48
list set_to_list(const set)
create a list from a set the set is not freed
Definition: set.c:436
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
Definition: newgen_set.h:78
void set_free(set)
Definition: set.c:332
bool set_belong_p(const set, const void *)
Definition: set.c:194
set set_union(set, const set, const set)
Definition: set.c:211
@ set_pointer
Definition: newgen_set.h:44
set set_add_elements(set, const set, const void *e,...)
Definition: set.c:171
#define set_undefined_p(s)
Definition: newgen_set.h:49
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
set set_add_element(set, const set, const void *)
Definition: set.c:152
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
Definition: newgen_types.h:78
int tag
TAG.
Definition: newgen_types.h:92
#define string_undefined
Definition: newgen_types.h:40
char * string
STRING.
Definition: newgen_types.h:39
#define copy_string(s)
Definition: newgen_types.h:42
#define UU
Definition: newgen_types.h:98
int(* gen_cmp_func_t)(const void *, const void *)
Definition: newgen_types.h:114
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
static char * module
Definition: pips.c:74
static const char * prefix
#define GETS_FUNCTION_NAME
#define BITWISE_OR_OPERATOR_NAME
#define VFPRINTF_FUNCTION_NAME
#define ENTITY_OR_P(e)
#define MAX_OPERATOR_NAME
#define ENTITY_PLUS_UPDATE_P(e)
#define ENTITY_MODULO_UPDATE_P(e)
#define IO_EFFECTS_PTR_NAME
To express C IO intrinsics effects.
#define RAND_GEN_EFFECTS_NAME
variable name for random unit
#define BITWISE_XOR_OPERATOR_NAME
#define RAND_EFFECTS_PACKAGE_NAME
package name for random routines
#define SCANF_FUNCTION_NAME
#define TIME_EFFECTS_PACKAGE_NAME
package name for time routines
#define READ_FUNCTION_NAME
#define ENDFILE_FUNCTION_NAME
#define BITWISE_OR_UPDATE_OPERATOR_NAME
#define IO_EFFECTS_PACKAGE_NAME
Implicit variables to handle IO effetcs.
#define ENTITY_AND_P(e)
#define BUFFERIN_FUNCTION_NAME
#define ENTITY_BITWISE_AND_UPDATE_P(e)
#define SSCANF_FUNCTION_NAME
#define C_MODULO_OPERATOR_NAME
#define MINUS_OPERATOR_NAME
#define DIVIDE_UPDATE_OPERATOR_NAME
#define ISOC99_SSCANF_USER_FUNCTION_NAME
#define PLUS_OPERATOR_NAME
#define ENTITY_PLUS_P(e)
#define ENTITY_MULTIPLY_P(e)
#define IO_EFFECTS_ARRAY_NAME
array of Logical UNits; it is more or less handled as the current file pointer; in C,...
#define INSTANCE_OF(type, value)
polymorhism thanks to newgen !
#define make_entity(n, t, s, i)
#define FOPEN_FUNCTION_NAME
#define MEMMOVE_EFFECTS_PACKAGE_NAME
package name for memmove routines
#define BACKSPACE_FUNCTION_NAME
#define ISOC99_SSCANF_FUNCTION_NAME
#define LEFT_SHIFT_UPDATE_OPERATOR_NAME
#define ISOC99_SCANF_FUNCTION_NAME
#define VFSCANF_FUNCTION_NAME
#define UNKNOWN_RAM_OFFSET
#define REWIND_FUNCTION_NAME
#define FPRINTF_FUNCTION_NAME
#define MULTIPLY_UPDATE_OPERATOR_NAME
#define OPEN_FUNCTION_NAME
#define MALLOC_EFFECTS_NAME
variable name for heap effects
#define ENTITY_RIGHT_SHIFT_UPDATE_P(e)
#define LEFT_SHIFT_OPERATOR_NAME
#define ENTITY_BITWISE_OR_UPDATE_P(e)
#define entity_declarations(e)
MISC: newgen shorthands.
#define GENERATED_LABEL_MODULE_NAME
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define MINUS_UPDATE_OPERATOR_NAME
#define ENTITY_PLUS_C_P(e)
#define CONTINUE_FUNCTION_NAME
#define SNPRINTF_FUNCTION_NAME
#define MEMMOVE_EFFECTS_NAME
variable name for memmove unit
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
#define IO_EOF_ARRAY_NAME
array of end of file codes
#define MALLOC_EFFECTS_PACKAGE_NAME
package name for malloc routines (could be libc package)
#define module_language(e)
implemented as a macro to allow lhs
#define DIVIDE_OPERATOR_NAME
#define WRITE_FUNCTION_NAME
#define CLOSE_FUNCTION_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define ENTITY_MULTIPLY_UPDATE_P(e)
#define UNARY_PLUS_OPERATOR_NAME
#define ENTITY_DIVIDE_UPDATE_P(e)
#define RIGHT_SHIFT_UPDATE_OPERATOR_NAME
#define IO_ERROR_ARRAY_NAME
array of error codes for LUNs
#define ENTITY_BITWISE_XOR_UPDATE_P(e)
#define PLUS_UPDATE_OPERATOR_NAME
#define FORMAT_FUNCTION_NAME
#define ENTITY_MINUS_UPDATE_P(e)
#define MINUS_C_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME
#define BITWISE_AND_UPDATE_OPERATOR_NAME
#define ENTITY_LEFT_SHIFT_UPDATE_P(e)
#define BITWISE_AND_OPERATOR_NAME
#define TIME_EFFECTS_VARIABLE_NAME
variable holding time effects
#define entity_constant_p(e)
#define RIGHT_SHIFT_OPERATOR_NAME
#define INQUIRE_FUNCTION_NAME
#define PUTS_FUNCTION_NAME
#define ISOC99_SCANF_USER_FUNCTION_NAME
#define OR_OPERATOR_NAME
#define PRINTF_FUNCTION_NAME
include<stdio.h>
@ ENTITY_POINTER_DUMMY_TARGETS_AREA
@ ENTITY_STATIC_AREA
@ EFFECTS_PACKAGE
@ ABSTRACT_LOCATION
@ ENTITY_DYNAMIC_AREA
@ ENTITY_STACK_AREA
@ ENTITY_HEAP_AREA
#define PLUS_C_OPERATOR_NAME
#define FCLOSE_FUNCTION_NAME
#define MIN_OPERATOR_NAME
bool entity_area_p(entity e)
Definition: area.c:149
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86
bool formal_area_p(entity aire)
Definition: area.c:95
bool entity_special_area_p(entity e)
Definition: area.c:154
bool entity_not_constant_or_intrinsic_p(entity e)
Default entity filter for get_referenced_entities()
Definition: entity.c:3050
static entity io_error_luns_ent
Definition: entity.c:59
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
bool entity_continue_p(entity f)
Definition: entity.c:1731
bool entity_enum_member_p(entity e)
Definition: entity.c:980
bool entity_list_p(list el)
Checks that el only contains entity.
Definition: entity.c:1411
bool io_intrinsic_p(entity e)
rue is a statement s is an io intrinsic
Definition: entity.c:1655
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
static bool std_static_entities_initialized_p
variables to store entities from standard includes
Definition: entity.c:69
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool do_get_declared_entities(statement s, set declared_entities)
Helper for get_declared_entities() Add all locally declared entity to the set given in argument.
Definition: entity.c:3074
bool commutative_call_p(call c)
Test if we are allowed to commute operations.
Definition: entity.c:2661
bool entity_return_label_p(entity e)
Definition: entity.c:673
char * new_label_local_name(entity module)
Definition: entity.c:326
bool malloc_effect_entity_p(entity e)
Definition: entity.c:1158
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
static void do_get_referenced_entities_on_loop(loop l, get_referenced_entities_t *p)
helper looking in a loop for referenced entities
Definition: entity.c:2917
bool entity_in_list_p(entity ent, list ent_l)
look for ent in ent_l
Definition: entity.c:2221
entity entity_field_to_entity_struct(entity f)
Definition: entity.c:905
int compare_entities(const entity *pe1, const entity *pe2)
Comparison function for qsort.
Definition: entity.c:1328
bool entity_struct_p(entity e)
Is entity e the entity corresponding to a struct declaration?
Definition: entity.c:1002
void set_std_static_entities()
beware: cannot be called on creating the database
Definition: entity.c:80
bool dummy_parameter_entity_p(entity p)
is p a dummy parameter?
Definition: entity.c:1941
bool assumed_size_array_p(entity e)
Definition: entity.c:807
bool rand_effects_entity_p(entity e)
Definition: entity.c:1152
bool label_string_defined_in_current_module_p(string ls)
Definition: entity.c:407
void reset_static_entities()
Definition: entity.c:146
static void do_get_referenced_entities_on_statement(statement s, get_referenced_entities_t *p)
helper looking in a statement declaration for referenced entities
Definition: entity.c:2956
bool entity_register_p(entity e)
Definition: entity.c:766
bool entity_formal_p(entity p)
is p a formal parameter?
Definition: entity.c:1935
bool entity_array_p(entity e)
Is e a variable with an array type?
Definition: entity.c:754
static entity stderr_ent
Definition: entity.c:73
bool string_block_scope_p(string s)
Definition: entity.c:511
bool intrinsic_entity_p(entity e)
Definition: entity.c:1272
bool array_entity_p(entity e)
Definition: entity.c:793
entity make_entity_copy_with_new_name_and_suffix(entity e, string global_new_name, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2495
static bool label_defined_in_statement
Definition: entity.c:377
void update_dummy_parameter(parameter p, entity ep)
Definition: entity.c:2072
bool stdout_entity_p(entity e)
Definition: entity.c:1215
bool entity_f95use_p(entity e)
Definition: entity.c:694
bool explicit_extern_entity_p(entity module, entity e)
Definition: entity.c:2016
string empty_scope()
Functions used to manage the block scoping in conjunction with ContextStack and yco ntext.
Definition: entity.c:498
entity update_operator_to_regular_operator(entity op)
Returns the binary operator associated to a C update operator such as +=.
Definition: entity.c:2154
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
list string_to_entity_list(string module, string names)
of entity
Definition: entity.c:1887
void print_entity_set(set s)
Definition: entity.c:174
bool io_luns_entity_p(entity e)
Definition: entity.c:1146
string entity_global_name(entity e)
Used instead of the macro to pass as formal argument.
Definition: entity.c:464
char * AddPackageToName(string p, string n)
This function concatenate a package name and a local name to produce a global entity name.
Definition: entity.c:2134
bool entity_local_variable_p(entity var, entity module)
Check if a variable "var" is local to a module "module".
Definition: entity.c:3104
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 entity_subroutine_p(entity e)
Definition: entity.c:737
bool symbolic_entity_p(entity e)
Definition: entity.c:1277
static entity rand_gen_ent
effects package entities
Definition: entity.c:52
bool local_entity_of_module_p(entity e, entity module)
This test shows that "e" has been declared in "module".
Definition: entity.c:1069
bool label_defined_in_statement_p(entity l, statement s)
Definition: entity.c:388
bool entities_p(list el)
Make sure that an list is an homogeneous list of entities.
Definition: entity.c:2580
bool std_file_entity_p(entity e)
Definition: entity.c:1232
bool parameter_passing_mode_p(entity f, int tag)
Returns true when f has no parameters.
Definition: entity.c:2089
static entity malloc_effect_ent
Definition: entity.c:53
entity make_empty_program(const char *name, language l)
Definition: entity.c:261
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
bool pointer_type_array_p(entity e)
Definition: entity.c:826
static entity time_effect_ent
Definition: entity.c:55
static entity continue_ent
continue statement
Definition: entity.c:62
bool string_struct_scope_p(string s)
same kind of testing required for union as well
Definition: entity.c:503
code entity_code(entity e)
Definition: entity.c:1098
bool entity_label_p(entity e)
Definition: entity.c:678
bool intrinsic_name_p(const char *local_name)
Definition: entity.c:1282
bool arithmetic_intrinsic_p(entity e)
true if e is an arithmetic instrinsic
Definition: entity.c:1702
entity FindOrCreateTopLevelEntity(const char *name)
Return a top-level entity.
Definition: entity.c:1603
entity AddEntityToModule(entity e, entity module)
!!! caution, it may not be a module, but a common...
Definition: entity.c:3171
static entity io_ptr_ent
Definition: entity.c:57
set get_referenced_entities_filtered(void *elem, bool(*chunk_filter)(void *), bool(*entity_filter)(entity))
Same as get_referenced_entities, but will only consider entities that fulfills entity_filter and will...
Definition: entity.c:2982
entity make_empty_blockdata(const char *name, language l)
Definition: entity.c:290
void set_internal_static_entities()
beware: cannot be called on creating the database
Definition: entity.c:92
entity entity_to_module_entity(entity e)
Find the enclosing module of an entity.
Definition: entity.c:2053
bool same_struct_entity_p(const entity e0, const entity e1)
Definition: entity.c:1012
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
static void do_get_referenced_entities_on_reference(reference r, get_referenced_entities_t *p)
helper looking in a reference r for referenced entities
Definition: entity.c:2895
static set arithmetic_functions_set
Definition: entity.c:165
bool extern_entity_p(entity module, entity e)
Definition: entity.c:1977
static size_t static_entity_size
Definition: entity.c:77
bool entity_main_module_p(entity e)
Definition: entity.c:700
string storage_to_string(storage s)
Definition: entity.c:2030
list entities_to_expressions(list l_ent)
build a list of expressions from a list of entities
Definition: entity.c:2703
entity FindEntityFromUserName(const char *package, const char *name)
Definition: entity.c:1520
bool unnormalized_array_p(entity e)
Definition: entity.c:846
const char * entity_name_or_TCST(entity e)
Return a name valid for sorting variables in vectors and constraint systems.
Definition: entity.c:627
bool entity_function_p(entity e)
Definition: entity.c:724
string entity_name_without_scope(entity e)
allocates a new string
Definition: entity.c:543
bool entity_enum_p(entity e)
Definition: entity.c:968
static entity io_eof_ent
Definition: entity.c:58
bool typedef_entity_p(entity e)
Definition: entity.c:1902
static void do_get_referenced_entities_on_list(list l, get_referenced_entities_t *p)
helper looking in a list for referenced entities
Definition: entity.c:2930
bool effects_package_entity_p(entity e)
checks if an entity is an IO_EFFECTS_PACKAGE_NAME, a MALLOC_EFFECTS_NAME or a RAND_EFFECTS_PACKAGE_NA...
Definition: entity.c:1181
entity entity_empty_label(void)
Definition: entity.c:1105
entity make_new_common(string name, entity mod)
This function creates a common for a given name in a given module.
Definition: entity.c:1806
list concat_new_entities(list l1, list l2)
returns l1 after elements of l2 but not of l1 have been appended to l1.
Definition: entity.c:2236
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
static string prefixes[]
Definition: entity.c:1433
entity make_entity_copy(entity e)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2433
bool entity_field_p(entity e)
e is the field of a structure
Definition: entity.c:857
string local_name_to_scope(const char *ln)
allocates a new string
Definition: entity.c:563
entity make_empty_module(const char *full_name, type r, language l)
The source language is not specified.
Definition: entity.c:197
expression entity_ith_bounds(entity e, int i)
FIND_MODULE returns entity.
Definition: entity.c:1626
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320
entity make_loop_label(int __attribute__((unused)) desired_number, entity module)
Definition: entity.c:370
static entity entity_field_to_entity(entity f, char prefix)
f is a field of a structure: what is its structure?
Definition: entity.c:879
void register_static_entity(entity *e)
add given entity to the set of entities that must reset upon workspace deletion practically,...
Definition: entity.c:156
static void do_get_referenced_entities_on_area(area a, get_referenced_entities_t *p)
helper looking in an area for referenced entities
Definition: entity.c:2948
bool empty_scope_p(string s)
Definition: entity.c:500
void sort_list_of_entities(list l)
sorted in place.
Definition: entity.c:1358
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void reset_internal_static_entities()
Definition: entity.c:119
void print_entities(list l)
Definition: entity.c:167
void add_thread_safe_variable(entity v)
Definition: entity.c:2525
static entity * static_entity_cache[STATIC_ENTITY_CACHE_SIZE]
Definition: entity.c:76
bool label_name_conflict_with_labels(const char *n, list ll)
Definition: entity.c:610
list entity_qualifiers(entity e)
return the qualifiers associated to entity e if it's a variable NIL otherwise
Definition: entity.c:1394
bool label_string_defined_in_statement_p(string ls, statement s)
Definition: entity.c:417
static void do_get_referenced_entities_on_ram(ram r, get_referenced_entities_t *p)
helper looking in a ram for referenced entities
Definition: entity.c:2939
static entity stdout_ent
Definition: entity.c:72
bool entity_blockdata_p(entity e)
Definition: entity.c:712
bool entity_empty_label_p(entity e)
Definition: entity.c:666
code EntityCode(entity e)
this function checks that e has an initial value code.
Definition: entity.c:301
bool io_entity_p(entity e)
Several implicit entities are declared to define the implicit effects of IO statements.
Definition: entity.c:1139
bool entity_enum_variable_p(entity e)
Definition: entity.c:992
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
bool parameter_passing_by_reference_p(entity f)
Definition: entity.c:2121
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
set get_declared_entities(void *elem)
retrieves the set of entities declared in elem
Definition: entity.c:3086
entity operator_neutral_element(entity op)
Definition: entity.c:2593
static list abstract_state_entities
FI: hidden variables added to take into account the side effects in the libc.
Definition: entity.c:2555
bool entity_module_p(entity e)
Definition: entity.c:683
entity get_stderr_entity()
Definition: entity.c:1220
bool type_used_in_type_declarations_p(entity e, list ldecl)
check if e is used to declare one of the entities in entity list ldecl
Definition: entity.c:2289
bool entity_f95module_p(entity e)
Definition: entity.c:707
bool entity_used_in_declarations_p(entity e, list ldecl)
check if e is used to declare one of the entities in entity list ldecl
Definition: entity.c:2258
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
#define declaration_formal_p(E)
Definition: entity.c:1857
entity find_enum_of_member(entity m)
Definition: entity.c:2713
string safe_entity_name(entity e)
predicates and functions for entities
Definition: entity.c:433
bool entity_equivalence_p(entity e)
checks if an entity is an equivalent
Definition: entity.c:2194
entity CreateEntity(const char *package_name, const char *local_name)
BEGIN_EOLE.
Definition: entity.c:1572
#define PREFIXES_SIZE
this function maps a local name, for instance P, to the corresponding TOP-LEVEL entity,...
Definition: entity.c:1432
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
bool same_entity_name_p(entity e1, entity e2)
compare entity names
Definition: entity.c:2208
entity std_file_entity_to_pointed_file_entity(entity e)
Dummy standard files targets.
Definition: entity.c:1243
entity make_new_label(entity module)
This function returns a new label.
Definition: entity.c:357
entity get_continue_entity()
true if continue.
Definition: entity.c:1726
bool entity_in_formal_area_p(entity e)
Formal parameters do not use the standard ram storage.
Definition: entity.c:3196
static void make_uniq_reference_list(reference r, deux_listes *l)
Definition: entity.c:2818
bool parameter_passing_by_value_p(entity f)
Definition: entity.c:2116
void fprint_entity_list(FILE *fp, list l)
void fprint_entity_list(FILE *fp,list l): prints a list of entities on file fp.
Definition: entity.c:3188
static entity stdin_ent
stdio files entities
Definition: entity.c:71
void reset_label_counter()
Definition: entity.c:322
static entity memmove_effect_ent
Definition: entity.c:54
static entity luns_ent
Definition: entity.c:56
bool stderr_entity_p(entity e)
Definition: entity.c:1226
static entity label_searched_in_statement
Definition: entity.c:378
bool derived_entity_p(entity e)
Definition: entity.c:1048
bool abstract_state_variable_p(entity v)
Definition: entity.c:2572
entity make_new_integer_scalar_common_variable(string name, entity mod, entity com)
This function creates a common variable in a given common in a given module.
Definition: entity.c:1843
entity module_name_to_runtime_entity(const char *name)
similar to module_name_to_entity but generates a warning and a stub if the entity is not found
Definition: entity.c:1485
void add_abstract_state_variable(entity v)
Definition: entity.c:2558
entity find_ith_formal_parameter(entity the_fnct, int rank)
This function gives back the ith formal parameter, which is found in the declarations of a call or a ...
Definition: entity.c:1863
const char * module_resource_name(entity e)
Returns a pointer towards the resource name.
Definition: entity.c:593
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
bool entity_variable_length_array_p(entity e)
Definition: entity.c:798
bool entity_common_p(entity e)
Definition: entity.c:718
bool thread_safe_variable_p(entity v)
Definition: entity.c:2539
static bool internal_static_entities_initialized_p
Functions closely related to the entity class, constructors, predicates,...
Definition: entity.c:50
bool time_effect_entity_p(entity e)
Definition: entity.c:1170
entity entity_field_to_entity_union(entity f)
Definition: entity.c:915
bool entity_pointer_p(entity e)
Definition: entity.c:745
entity entity_field_to_entity_struct_or_union(entity f)
Definition: entity.c:925
static list thread_safe_entities
FI: it is assumed that thread safe entities are invariant with respect to workspaces.
Definition: entity.c:2523
bool lexicographic_order_p(entity var1, entity var2)
true if var1 <= var2
Definition: entity.c:1365
static entity generic_make_entity_copy_with_new_name(entity e, string global_new_name, bool systematically_add_suffix, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2341
const char * entity_and_common_name(entity e)
See next function!
Definition: entity.c:654
bool stdin_entity_p(entity e)
Definition: entity.c:1203
static bool check_statement_for_label(statement s)
Definition: entity.c:380
bool member_entity_p(entity e)
Definition: entity.c:1921
entity MakeCompilationUnitEntity(const char *name)
This is useful for the C language only.
Definition: entity.c:1954
Pbase entity_list_to_base(list l)
Definition: entity.c:2860
bool same_field_entity_p(const entity f1, const entity f2)
Definition: entity.c:1019
void set_register_qualifier(entity v)
Assuming that v is of type variable, add a qualifier register.
Definition: entity.c:778
#define entity_to_offset(E)
Definition: entity.c:1858
static void do_get_referenced_entities_on_entity(entity e, get_referenced_entities_t *p)
Definition: entity.c:2886
static set io_functions_set
Definition: entity.c:164
set get_referenced_entities(void *elem)
retrieves the set of entities used in elem beware that this entities may be formal parameters,...
Definition: entity.c:3063
bool memmove_effect_entity_p(entity e)
Definition: entity.c:1165
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
void reset_std_static_entities()
Definition: entity.c:138
entity make_label(const char *module_name, const char *local_name)
Definition: entity.c:308
list extract_references_from_declarations(list decls)
FI: this function has not yet been extended for C types!!!
Definition: entity.c:2834
static void do_get_referenced_entities_on_call(call c, get_referenced_entities_t *p)
helper looking in a call for referenced entities
Definition: entity.c:2906
int entity_field_rank(entity f)
f is a field of a structure or of an union: what is its rank?
Definition: entity.c:940
entity make_empty_function(const char *name, type r, language l)
Definition: entity.c:283
const char * label_local_name(entity e)
END_EOLE.
Definition: entity.c:604
entity make_empty_f95module(const char *name, language l)
Definition: entity.c:275
entity get_stdin_entity()
Definition: entity.c:1197
#define STATIC_ENTITY_CACHE_SIZE
Definition: entity.c:75
bool entity_in_common_p(entity e)
Definition: entity.c:1082
entity FindOrCreateEntityLikeModel(const char *package, const char *name, entity model)
hmmm...
Definition: entity.c:3136
entity get_stdout_entity()
Definition: entity.c:1209
bool entity_union_p(entity e)
Is entity e an entity representing the union declaration?
Definition: entity.c:1038
entity global_name_to_entity(const char *name)
Find an entity, if it exists, from its global name, a.k.a.
Definition: entity.c:1516
list common_members_of_module(entity common, entity module, bool only_primary)
returns the list of entity to appear in the common declaration.
Definition: entity.c:1741
entity make_entity_copy_with_new_name(entity e, string global_new_name, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2463
bool label_defined_in_current_module_p(entity l)
Definition: entity.c:399
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
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_equal_integer_p(expression exp, int i)
================================================================
Definition: expression.c:1977
bool compilation_unit_entity_p(entity e)
Check if the given module entity is a compilation unit.
Definition: module.c:87
dimension entity_ith_dimension(entity, int)
Another semantics would be: is this reference r to e a kill for e? In general, this cannot be answere...
Definition: variable.c:1228
type ultimate_type(type)
Definition: type.c:3466
bool array_type_p(type)
Definition: type.c:2942
dimension find_ith_dimension(list, int)
This function returns the ith dimension of a list of dimensions.
Definition: type.c:5621
bool variable_length_array_type_p(type)
Is this equivalent to dependent_type_p()?
Definition: type.c:2972
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87
list type_supporting_types(type)
Return the list of types used to define type t.
Definition: type.c:5203
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
Definition: variable.c:1113
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
int add_C_variable_to_area(entity, entity)
Definition: variable.c:1381
list type_supporting_entities(list, type)
Definition: type.c:4347
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
bool type_structurally_equal_p(type, type)
Type t1 and t2 are equal if their basic concrete components are equal.
Definition: type.c:586
type MakeTypeStatement(void)
Definition: type.c:92
bool formal_parameter_p(entity)
Definition: variable.c:1489
basic basic_of_call(call, bool, bool)
basic basic_of_call(call c): returns the basic of the result given by the call "c".
Definition: type.c:1469
entity find_label_entity(const char *, const char *)
util.c
Definition: util.c:43
int add_variable_to_area(entity, entity)
Definition: variable.c:1376
entity make_integer_constant_entity(_int)
entity make_integer_constant_entity(int c) make entity for integer constant c
Definition: variable.c:1345
#define type_functional_p(x)
Definition: ri.h:2950
#define value_tag(x)
Definition: ri.h:3064
#define value_undefined_p(x)
Definition: ri.h:3017
#define dummy_identifier(x)
Definition: ri.h:1033
#define value_undefined
Definition: ri.h:3016
basic_utype
Definition: ri.h:570
@ 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 type_struct(x)
Definition: ri.h:2964
#define value_code_p(x)
Definition: ri.h:3065
#define qualifier_register_p(x)
Definition: ri.h:2185
#define basic_pointer(x)
Definition: ri.h:637
#define normalized_undefined
Definition: ri.h:1745
#define type_struct_p(x)
Definition: ri.h:2962
#define functional_result(x)
Definition: ri.h:1444
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define language_unknown_p(x)
Definition: ri.h:1600
#define storage_formal_p(x)
Definition: ri.h:2522
#define parameter_dummy(x)
Definition: ri.h:1823
#define area_size(x)
Definition: ri.h:544
#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 loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define basic_derived(x)
Definition: ri.h:640
#define code_externs(x)
Definition: ri.h:790
#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 type_functional(x)
Definition: ri.h:2952
#define area_domain
newgen_application_domain_defined
Definition: ri.h:34
@ is_mode_reference
Definition: ri.h:1676
@ is_mode_value
Definition: ri.h:1675
#define dimension_lower(x)
Definition: ri.h:980
#define basic_tag(x)
Definition: ri.h:613
#define parameter_mode(x)
Definition: ri.h:1821
#define type_variable(x)
Definition: ri.h:2949
#define basic_pointer_p(x)
Definition: ri.h:635
#define basic_derived_p(x)
Definition: ri.h:638
#define entity_storage(x)
Definition: ri.h:2794
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define type_statement_p(x)
Definition: ri.h:2941
#define type_union_p(x)
Definition: ri.h:2965
@ is_value_code
Definition: ri.h:3031
#define code_declarations(x)
Definition: ri.h:784
#define ram_domain
newgen_qualifier_domain_defined
Definition: ri.h:322
@ is_syntax_range
Definition: ri.h:2692
#define storage_ram_p(x)
Definition: ri.h:2519
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define ram_section(x)
Definition: ri.h:2249
#define storage_formal(x)
Definition: ri.h:2524
#define language_fortran95_p(x)
Definition: ri.h:1597
#define basic_undefined_p(x)
Definition: ri.h:557
#define VARIABLE(x)
VARIABLE.
Definition: ri.h:3089
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define statement_label(x)
Definition: ri.h:2450
@ is_storage_rom
Definition: ri.h:2494
@ is_storage_ram
Definition: ri.h:2492
#define type_undefined_p(x)
Definition: ri.h:2884
#define dummy_unknown_p(x)
Definition: ri.h:1028
#define basic_undefined
Definition: ri.h:556
#define entity_undefined_p(x)
Definition: ri.h:2762
#define type_enum(x)
Definition: ri.h:2970
#define language_c_p(x)
Definition: ri.h:1594
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define entity_undefined
Definition: ri.h:2761
#define value_symbolic_p(x)
Definition: ri.h:3068
#define type_void_p(x)
Definition: ri.h:2959
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define functional_parameters(x)
Definition: ri.h:1442
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define formal_function(x)
Definition: ri.h:1406
#define dimension_upper(x)
Definition: ri.h:982
#define value_code(x)
Definition: ri.h:3067
#define variable_qualifiers(x)
Definition: ri.h:3124
#define type_area(x)
Definition: ri.h:2946
#define mode_tag(x)
Definition: ri.h:1693
#define variable_dimensions(x)
Definition: ri.h:3122
#define statement_declarations(x)
Definition: ri.h:2460
#define storage_ram(x)
Definition: ri.h:2521
#define type_undefined
Definition: ri.h:2883
#define ram_function(x)
Definition: ri.h:2247
#define type_area_p(x)
Definition: ri.h:2944
#define storage_rom_p(x)
Definition: ri.h:2525
#define entity_kind(x)
Definition: ri.h:2798
@ is_type_variable
Definition: ri.h:2900
@ is_type_area
Definition: ri.h:2899
#define entity_type(x)
Definition: ri.h:2792
#define code_language(x)
Definition: ri.h:792
#define ram_shared(x)
Definition: ri.h:2253
#define language_fortran_p(x)
Definition: ri.h:1591
#define entity_domain_number(x)
Definition: ri.h:2788
#define storage_return_p(x)
Definition: ri.h:2516
#define type_variable_p(x)
Definition: ri.h:2947
#define storage_undefined_p(x)
Definition: ri.h:2477
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define loop_index(x)
Definition: ri.h:1640
#define type_union(x)
Definition: ri.h:2967
#define variable_basic(x)
Definition: ri.h:3120
#define ram_offset(x)
Definition: ri.h:2251
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
#define area_undefined
Definition: ri.h:520
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73
s1
Definition: set.c:247
#define ifdebug(n)
Definition: sg.c:47
static size_t current
Definition: string.c:115
char * strndup(char const *s, size_t n)
A replacement function, for systems that lack strndup.
Definition: strndup.c:26
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
list lr
Definition: entity.c:2816
list le
Definition: entity.c:2816
bool(* entity_filter)(entity)
Definition: entity.c:2882
bool(* chunk_filter)(void *)
Definition: entity.c:2881
@ empty
b1 < bj -> h1/hj = empty
Definition: union-local.h:64
A gen_chunk is used to store every object.
Definition: genC.h:58
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
struct Svecteur * Pbase
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
#define BASE_NULLE
MACROS SUR LES BASES.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110