PIPS
declarations2.c
Go to the documentation of this file.
1 /*
2 
3  $Id: declarations2.c 23065 2016-03-02 09:05:50Z 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 
28 // strndup are GNU extensions...
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include "genC.h"
33 #include "text.h"
34 #include "constants.h"
35 
36 #include "text-util.h"
37 #include "properties.h"
38 #include "misc.h"
39 #include "linear.h"
40 #include "text-util.h"
41 #include "ri.h"
42 #include "ri-util.h"
43 #include "pipsdbm.h"
44 #include "workspace-util.h"
45 #include "prettyprint.h"
46 
47 /* debugging for equivalences */
48 #define EQUIV_DEBUG 8
49 
50 /* To deal with declarations above ri-util and pipsdbm and text-util */
51 
52 /********************************************************************* TEXT */
53 
54 #define ADD_WORD_LIST_TO_TEXT(t, l) ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, 0)
55 #define ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, m)\
56  if (!ENDP(l)) ADD_SENTENCE_TO_TEXT(t,\
57  make_sentence(is_sentence_unformatted, \
58  make_unformatted(NULL, 0, m, l)));
59 
60 /********************************************************** ALL DECLARATIONS */
61 /**
62  * @brief This handle the fact that a Fortran95 declaration use "::" as a
63  * separator between type and variable name. It also adds an "allocatable"
64  * modifier if requested. Finally it add a "," between each variable if there
65  * more than one to declare.
66  **/
68  string str,
69  bool allocatable_pass_p,
70  bool space_p) {
71  list result = prev;
72  if (prev == NIL) {
73  result = CHAIN_SWORD(result, str);
74  if(allocatable_pass_p) {
75  result = CHAIN_SWORD(result, ", ALLOCATABLE ");
76  }
78  result = CHAIN_SWORD(result, ":: ");
79  }
80  }
81  else {
82  result = CHAIN_SWORD(result, space_p? ", " : ",");
83  }
84  return result;
85 }
86 
87 /* if the common is declared similarly in all routines, generate
88  * "include 'COMMON.h'", and the file is put in Src. otherwise
89  * the full local declarations are generated. That's fun.
90  */
91 
92 static text include(const char* file)
93 {
94  return make_text
95  (CONS(SENTENCE,
97  strdup(concatenate(" include '", file, "'\n", NULL))),
98  NIL));
99 }
100 
101 static void equiv_class_debug(list l_equiv)
102 {
103  if (ENDP(l_equiv))
104  fprintf(stderr, "<none>");
105  MAP(ENTITY, equiv_ent,
106  {
107  fprintf(stderr, " %s", entity_local_name(equiv_ent));
108  }, l_equiv);
109  fprintf(stderr, "\n");
110 }
111 
112 /* static int equivalent_entity_compare(entity *ent1, entity *ent2)
113  * input : two pointers on entities.
114  * output : an integer for qsort.
115  * modifies : nothing.
116  * comment : this is a comparison function for qsort; the purpose
117  * being to order a list of equivalent variables.
118  * algorithm: If two variables have the same offset, the longest
119  * one comes first; if they have the same length, use a lexicographic
120  * ordering.
121  * author: bc.
122  */
123 static int equivalent_entity_compare(entity *ent1, entity *ent2)
124 {
125  int result;
126  int offset1 = ram_offset(storage_ram(entity_storage(*ent1)));
127  int offset2 = ram_offset(storage_ram(entity_storage(*ent2)));
128  Value size1, size2;
129 
130  result = offset1 - offset2;
131 
132  /* pips_debug(1, "entities: %s %s\n", entity_local_name(*ent1),
133  entity_local_name(*ent2)); */
134 
135  if (result == 0)
136  {
137  /* pips_debug(1, "same offset\n"); */
138  size1 = ValueSizeOfArray(*ent1);
139  size2 = ValueSizeOfArray(*ent2);
140  result = value_compare(size2,size1);
141 
142  if (result == 0)
143  {
144  /* pips_debug(1, "same size\n"); */
145  result = strcmp(entity_local_name(*ent1), entity_local_name(*ent2));
146  }
147  }
148 
149  return(result);
150 }
151 
152 /* static text text_equivalence_class(list l_equiv)
153  * input : a list of entities representing an equivalence class.
154  * output : a text, which is the prettyprint of this class.
155  * modifies : sorts l_equiv according to equivalent_entity_compare.
156  * comment : partially associated entities are not handled.
157  * author : bc.
158  */
159 static text text_equivalence_class(list /* of entities */ l_equiv)
160 {
161  text t_equiv = make_text(NIL);
162  list lw = NIL;
163  list l1, l2;
164  entity ent1, ent2;
165  int offset1, offset2;
166  Value size1, offset_end1;
167  bool first;
168  bool space_p = get_bool_property("PRETTYPRINT_LISTS_WITH_SPACES");
169 
170  if (gen_length(l_equiv)<=1) return t_equiv;
171 
172  /* FIRST, sort the list by increasing offset from the beginning of
173  the memory suite. If two variables have the same offset, the longest
174  one comes first; if they have the same lenght, use a lexicographic
175  ordering */
177  {
178  pips_debug(1, "equivalence class before sorting:\n");
179  equiv_class_debug(l_equiv);
180  }
181 
182  gen_sort_list(l_equiv,
183  (int (*)(const void *,const void *)) equivalent_entity_compare);
184 
186  {
187  pips_debug(1, "equivalence class after sorting:\n");
188  equiv_class_debug(l_equiv);
189  }
190 
191  /* THEN, prettyprint the sorted list*/
192  pips_debug(EQUIV_DEBUG,"prettyprint of the sorted list\n");
193 
194  /* At each step of the next loop, we consider two entities
195  * from the equivalence class. l1 points on the first entity list,
196  * and l2 on the second one. If l2 is associated with l1, we compute
197  * the output string, and l2 becomes the next entity. If l2 is not
198  * associated with l1, l1 becomes the next entity, until it is
199  * associated with l1. In the l_equiv list, l1 is always before l2.
200  */
201 
202  /* loop initialization */
203  l1 = l_equiv;
204  ent1 = ENTITY(CAR(l1));
205  offset1 = ram_offset(storage_ram(entity_storage(ent1)));
206  size1 = ValueSizeOfArray(ent1);
207  l2 = CDR(l_equiv);
208  first = true;
209 
210  while(!ENDP(l2))
211  {
212  ent2 = ENTITY(CAR(l2));
213  offset2 = ram_offset(storage_ram(entity_storage(ent2)));
214 
215  pips_debug(EQUIV_DEBUG, "dealing with: %s %s\n",
216  entity_local_name(ent1),
217  entity_local_name(ent2));
218 
219  /* If the two variables have the same offset, their
220  * first elements are equivalenced.
221  */
222  if (offset1 == offset2)
223  {
224  pips_debug(EQUIV_DEBUG, "easiest case: offsets are the same\n");
225 
226  if (first) lw = CHAIN_SWORD(lw, "EQUIVALENCE"), first = false;
227  else lw = CHAIN_SWORD(lw, space_p? ", " : ",");
228 
229  lw = CHAIN_SWORD(lw, " (");
230  lw = CHAIN_SWORD(lw, entity_local_name(ent1));
231  lw = CHAIN_SWORD(lw, space_p? ", " : ",");
232  lw = CHAIN_SWORD(lw, entity_local_name(ent2));
233  lw = CHAIN_SWORD(lw, ")");
234  POP(l2);
235  }
236  /* Else, we first check that there is an overlap */
237  else
238  {
239  pips_assert("the equivalence class has been sorted\n",
240  offset1 < offset2);
241 
242  offset_end1 = value_plus(offset1, size1);
243 
244  /* If there is no overlap, we change the reference variable */
245  if (value_le(offset_end1,offset2))
246  {
247  pips_debug(1, "second case: there is no overlap\n");
248  POP(l1);
249  ent1 = ENTITY(CAR(l1));
250  offset1 = ram_offset(storage_ram(entity_storage(ent1)));
251  size1 = ValueSizeOfArray(ent1);
252  if (l1 == l2) POP(l2);
253  }
254 
255  /* Else, we must compute the coordinates of the element of ent1
256  * which corresponds to the first element of ent2
257  */
258  else
259  {
260  /* ATTENTION: Je n'ai pas considere le cas
261  * ou il y a association partielle. De ce fait, offset
262  * est divisiable par size_elt_1. */
263  int offset = offset2 - offset1;
264  int rest;
265  int current_dim;
266  int dim_max = NumberOfDimension(ent1);
269  list l_tmp = variable_dimensions
270  (type_variable(entity_type(ent1)));
271  normalized nlo;
272  Pvecteur pvlo;
273 
274  pips_debug(EQUIV_DEBUG, "third case\n");
276  "offset=%d, dim_max=%d, size_elt_1=%d\n",
277  offset, dim_max,size_elt_1);
278 
279  if (first) lw = CHAIN_SWORD(lw, "EQUIVALENCE"), first = false;
280  else lw = CHAIN_SWORD(lw, space_p? ", " : ",");
281 
282  lw = CHAIN_SWORD(lw, " (");
283  lw = CHAIN_SWORD(lw, entity_local_name(ent1));
284  lw = CHAIN_SWORD(lw, "(");
285 
286  pips_assert("partial association case not implemented:\n"
287  "offset % size_elt_1 == 0",
288  (offset % size_elt_1) == 0);
289 
291  current_dim = 1;
292 
293  while (current_dim <= dim_max)
294  {
295  dimension dim = DIMENSION(CAR(l_tmp));
296  int new_decl;
297  int size;
298 
299  pips_debug(EQUIV_DEBUG, "prettyprinting dimension %d\n",
300  current_dim);
301  size = SizeOfIthDimension(ent1, current_dim);
302  rest = (offset % size);
303  offset = offset / size;
305  pvlo = normalized_linear(nlo);
306 
307  pips_assert("sg", vect_constant_p(pvlo));
309  "size=%d, rest=%d, offset=%d, lower_bound=%d\n",
310  size, rest, offset, (int)VALUE_TO_INT(val_of(pvlo)));
311 
312  new_decl = VALUE_TO_INT(val_of(pvlo)) + rest;
313  lw = CHAIN_SWORD(lw,int2a(new_decl));
314  if (current_dim < dim_max)
315  lw = CHAIN_SWORD(lw, space_p? ", " : ",");
316 
317  POP(l_tmp);
318  current_dim++;
319 
320  } /* while */
321 
322  lw = CHAIN_SWORD(lw, ")");
323  lw = CHAIN_SWORD(lw, space_p? ", " : ",");
324  lw = CHAIN_SWORD(lw, entity_local_name(ent2));
325  lw = CHAIN_SWORD(lw, ")");
326  POP(l2);
327  } /* if-else: there is an overlap */
328  } /* if-else: not same offset */
329  } /* while */
330  ADD_WORD_LIST_TO_TEXT(t_equiv, lw);
331 
332  pips_debug(EQUIV_DEBUG, "end\n");
333  return t_equiv;
334 }
335 
336 
337 /* input : the current module, and the list of declarations.
338  * output : a text for all the equivalences.
339  * modifies : nothing
340  * comment :
341  */
343  entity __attribute__ ((unused)) module /* the module dealt with */,
344  list ldecl /* the list of declarations to consider */,
345  bool no_commons /* whether to print common equivivalences */)
346 {
347  list equiv_classes = NIL, l_tmp;
348  text t_equiv_class;
349 
350  pips_debug(1,"begin\n");
351 
352  /* FIRST BUILD EQUIVALENCE CLASSES */
353 
354  pips_debug(EQUIV_DEBUG, "loop on declarations\n");
355  /* consider each entity in the declaration */
356  MAP(ENTITY, e,
357  {
358  storage s = entity_storage(e);
359  /* but only variables which have a ram storage must be considered
360  */
362  {
363  ram r = storage_ram(s);
364  entity common = ram_section(r);
365  list l_shared = ram_shared(r);
366 
367  if (no_commons && !entity_special_area_p(common))
368  break;
369 
371  {
372  pips_debug(1, "considering entity: %s\n",entity_local_name(e));
373  pips_debug(1, "shared variables:\n");
374  equiv_class_debug(l_shared);
375  }
376 
377  /* If this variable is statically aliased */
378  if (!ENDP(l_shared))
379  {
380  bool found = false;
381  list found_equiv_class = NIL;
382 
383  /* We first look in already found equivalence classes
384  * if there is already a class in which one of the
385  * aliased variables appears
386  */
387  MAP(LIST, equiv_class,
388  {
390  {
391  pips_debug(1, "considering equivalence class:\n");
392  equiv_class_debug(equiv_class);
393  }
394 
395  MAP(ENTITY, ent,
396  {
397  if (variable_in_list_p(ent, equiv_class))
398  {
399  found = true;
400  found_equiv_class = equiv_class;
401  break;
402  }
403  }, l_shared);
404 
405  if (found) break;
406  },
407  equiv_classes);
408 
409  if (found)
410  {
411  pips_debug(EQUIV_DEBUG, "already there\n");
412  /* add the entities of shared which are not already in
413  * the existing equivalence class. Useful ??
414  */
415  MAP(ENTITY, ent,
416  {
417  if(!variable_in_list_p(ent, found_equiv_class) &&
418  variable_in_list_p(ent, ldecl)) /* !!! */
419  found_equiv_class =
420  CONS(ENTITY, ent, found_equiv_class);
421  }, l_shared)
422  }
423  else
424  {
425  list l_tmp = NIL;
426  pips_debug(EQUIV_DEBUG, "not found\n");
427  /* add the list of variables in l_shared; necessary
428  * because variables may appear several times in
429  * l_shared. */
430  MAP(ENTITY, shared_ent,
431  {
432  if (!variable_in_list_p(shared_ent, l_tmp) &&
433  variable_in_list_p(shared_ent, ldecl))
434  /* !!! restricted to declared... */
435  l_tmp = CONS(ENTITY, shared_ent, l_tmp);
436  },
437  l_shared);
438  equiv_classes = CONS(LIST, l_tmp, equiv_classes);
439  }
440  }
441  }
442  },
443  ldecl);
444 
446  {
447  pips_debug(1, "final equivalence classes:\n");
448  MAP(LIST, equiv_class, equiv_class_debug(equiv_class), equiv_classes);
449  }
450 
451  /* SECOND, PRETTYPRINT THEM */
452  t_equiv_class = make_text(NIL);
453  MAP(LIST, equiv_class,
454  {
455  MERGE_TEXTS(t_equiv_class, text_equivalence_class(equiv_class));
456  }, equiv_classes);
457 
458  /* AND FREE THEM */
459  for(l_tmp = equiv_classes; !ENDP(l_tmp); POP(l_tmp))
460  {
461  list equiv_class = LIST(CAR(l_tmp));
462  gen_free_list(equiv_class);
463  LIST(CAR(l_tmp)) = NIL;
464  }
465  gen_free_list(equiv_classes);
466 
467  /* THE END */
468  pips_debug(EQUIV_DEBUG, "end\n");
469  return(t_equiv_class);
470 }
471 
472 /**
473  * @brief Create a sentence for a USE directive
474  *
475  * @description Use directive is handled by copying the string directly in the
476  * name of the entity during the parsing. So we juste get the local name and put
477  * it in a sentence.
478  *
479  * @return a sentence with correct indentation containing the whole use
480  * directive in one word.
481  */
483  list decl = NIL;
484 
485  decl = CHAIN_SWORD(decl, entity_local_name(e));
486 
488  0,
489  INDENTATION,
490  decl)));
491 }
492 
494 {
495  list pc = NIL;
496 
497  pc = CHAIN_SWORD(pc, "EXTERNAL ");
498  pc = CHAIN_SWORD(pc, entity_local_name(f));
499 
502 }
503 
505 {
506  list pc = NIL;
507  value vf = entity_initial(f);
509 
510  pc = CHAIN_SWORD(pc, "PARAMETER (");
511  pc = CHAIN_SWORD(pc, entity_local_name(f));
512  pc = CHAIN_SWORD(pc, " = ");
513  pc = gen_nconc(pc, words_expression(e, ppdl));
514  pc = CHAIN_SWORD(pc, ")");
515 
518 }
519 
520 /* why is it assumed that the constant is an int ???
521  */
523 {
524  list pc = NIL;
525  constant c;
526 
528  return(sentence_undefined);
529 
531 
532  if (! constant_int_p(c))
533  return(sentence_undefined);
534 
535  pc = CHAIN_SWORD(pc, "DATA ");
536  pc = CHAIN_SWORD(pc, entity_local_name(e));
537  pc = CHAIN_SWORD(pc, " /");
538  pc = CHAIN_IWORD(pc, constant_int(c));
539  pc = CHAIN_SWORD(pc, "/");
540 
543 }
544 
545 
546 /* special management of empty commons added.
547  * this may happen in the hpfc generated code.
548  */
549 static sentence sentence_area(entity e, entity module, bool pp_dimensions, list * ppdl)
550 {
551  const char* area_name = module_local_name(e);
552  type te = entity_type(e);
553  list pc = NIL, entities = NIL;
554  bool space_p = get_bool_property("PRETTYPRINT_LISTS_WITH_SPACES");
555 
556  /* FI: POINTER declarations should be generated for the heap area */
557  if (dynamic_area_p(e) || heap_area_p(e) || stack_area_p(e) || pointer_dummy_targets_area_p(e)) /* shouldn't get in? */
558  return sentence_undefined;
559 
560  assert(type_area_p(te));
561 
562  if (!ENDP(area_layout(type_area(te))))
563  {
564  bool pp_hpfc = get_bool_property("PRETTYPRINT_HPFC");
565 
566  if (pp_hpfc)
568  else
570 
571  /* the common is not output if it is empty
572  */
573  if (!ENDP(entities))
574  {
575  bool comma = false, is_save = static_area_p(e);
576 
577  if (is_save)
578  {
579  pc = CHAIN_SWORD(pc, "SAVE ");
580  }
581  else
582  {
583  pc = CHAIN_SWORD(pc, "COMMON ");
584  if (strcmp(area_name, BLANK_COMMON_LOCAL_NAME) != 0)
585  {
586  pc = CHAIN_SWORD(pc, "/");
587  pc = CHAIN_SWORD(pc, area_name);
588  pc = CHAIN_SWORD(pc, "/ ");
589  }
590  }
591 
592  MAP(ENTITY, ee,
593  {
594  if (comma) pc = CHAIN_SWORD(pc, space_p? ", " : ",");
595  else comma = true;
596  pc = gen_nconc(pc,
597  words_declaration(ee, !is_save && pp_dimensions, ppdl));
598  },
599  entities);
600 
602  }
603  else
604  {
605  pips_user_warning("empty common %s for module %s encountered...\n",
608  strdup(concatenate("!! empty common ", entity_local_name(e),
609  " in module ", entity_local_name(module),
610  "\n", NULL)));
611  }
612  }
613 
616 }
617 
619 {
620  list decl = NIL;
621  basic b = entity_basic(e);
622 
623  pips_assert("b is defined", !basic_undefined_p(b));
624 
625  decl = CHAIN_SWORD(decl, basic_to_string(b));
626  decl = CHAIN_SWORD(decl, " ");
627  decl = CHAIN_SWORD(decl, entity_local_name(e));
628 
630  make_unformatted(NULL, 0, get_prettyprint_indentation(), decl)));
631 }
632 
633 ␌
634 /* Prettyprint the initializations field of code */
636 {
637  unformatted u =
639  (NULL,
641  CONS(STRING, strdup("DATA "), NIL));
643  list wl = unformatted_words(u);
645  call ic = instruction_call(ii);
646  entity ife = entity_undefined;
647  list al = list_undefined; /* Argument List */
648  list rl = list_undefined; /* Reference List */
649  expression rle = expression_undefined; /* reference list expression, i.e. call to DATA LIST */
650  entity rlf = entity_undefined; /* DATA LIST entity function */
651  bool space_p = get_bool_property("PRETTYPRINT_LISTS_WITH_SPACES");
652 
653  pips_assert("An initialization instruction is a call", instruction_call_p(ii));
654  ife = call_function(ic);
655  pips_assert("The static initialization function is called",
657  al = call_arguments(ic);
658 
659  /* Find all initialized variables pending from DATA LIST */
660  rle = EXPRESSION(CAR(al));
661  POP(al); /* Move al to the first value */
662  pips_assert("The first argument is a call", expression_call_p(rle));
664  pips_assert("This is the DATA LIST function", ENTITY_DATA_LIST_P(rlf));
666 
667  for(; !ENDP(rl); POP(rl)){
669  list ivwl = list_undefined;
670 
672  wl = CHAIN_SWORD(wl, strdup(space_p? ", " : ","));
673  }
674 
675  ive = EXPRESSION(CAR(rl));
676  ivwl = words_expression(ive, ppdl);
677  wl = gen_nconc(wl, ivwl);
678  }
679 
680  pips_assert("The value list is not empty", !ENDP(al));
681 
682  /* Print all values */
683 
684  wl = CHAIN_SWORD(wl, " /");
685 
686  for(; !ENDP(al); POP(al)){
687  expression ve = EXPRESSION(CAR(al));
689  list iwl = list_undefined;
690 
691  pips_assert("Values are encoded as calls", expression_call_p(ve));
692 
693  if(strcmp(module_local_name(call_function(vc)), REPEAT_VALUE_NAME)==0) {
696  list rwl = list_undefined;
697 
698  pips_assert("Pseudo-intrinsic REPEAT-VALUE must have two arguments",
699  gen_length(call_arguments(vc))==2);
700 
701  rfe = binary_call_lhs(vc);
702  rve = binary_call_rhs(vc);
703 
704  if(!(integer_constant_expression_p(rfe) && expression_to_int(rfe)==1)) {
705  /* print out the repeat factor if it is not one */
706  rwl = words_expression(rfe, ppdl);
707  wl = gen_nconc(wl, rwl);
708  wl = gen_nconc(wl, CONS(STRING, strdup("*"), NIL));
709  }
710  iwl = words_expression(rve, ppdl);
711  wl = gen_nconc(wl, iwl);
712  }
713  else {
714  iwl = words_expression(ve, ppdl);
715  wl = gen_nconc(wl, iwl);
716  }
717  if(!ENDP(CDR(al))) {
718  wl = gen_nconc(wl, CONS(STRING, strdup(space_p? ", " : ","), NIL));
719  }
720  }
721 
722  wl = CHAIN_SWORD(wl, "/");
723 
724  return s;
725 }
726 
727 /*************************************************************** PARAMETERS */
728 
729 static text text_of_parameters(list /* of entity that are parameters */ lp)
730 {
731  list /* of sentence */ ls = NIL;
732 
733  /* generate the sentences
734  */
735  FOREACH(ENTITY, e, lp) {
736  list pdl = NIL; // Assumed to be Fortran only
738  CONS(SENTENCE, sentence_symbolic(e, &pdl), ls));
739  }
740 
741  return make_text(ls);
742 }
743 
744 /* We add this function to cope with the declaration
745  * When the user declare sth. there's no need to declare sth. for the user.
746  * When nothing is declared ( especially there is no way to know whether it's
747  * a SUBROUTINE or PROGRAM). We will go over the entire module to find all the
748  * variables and declare them properly.
749  * Lei ZHOU 18/10/91
750  *
751  * the float length is now tested to generate REAL*4 or REAL*8.
752  * ??? something better could be done, printing "TYPE*%d".
753  * the problem is that you cannot mix REAL*4 and REAL*8 in the same program
754  * Fabien Coelho 12/08/93 and 15/09/93
755  *
756  * pf4 and pf8 distinction added, FC 26/10/93
757  *
758  * Is it really a good idea to print overloaded type variables~? FC 15/09/93
759  * PARAMETERS added. FC 15/09/93
760  *
761  * typed PARAMETERs FC 13/05/94
762  * EXTERNALS are missing: added FC 13/05/94
763  *
764  * Bug: parameters and their type should be put *before* other declarations
765  * since they may use them. Changed FC 08/06/94
766  *
767  * COMMONS are also missing:-) added, FC 19/08/94
768  *
769  * updated to fully control the list to be used.
770  */
771 /* hook for commons, when not generated...
772  */
774  entity common)
775 {
776  return strdup(concatenate
777  ("common to include: ", entity_local_name(common), "\n", NULL));
778 }
779 
781 
783 {
784  common_hook=f;
785 }
786 
788 {
790 }
791 
793  entity common /* the common the declaration of which are of interest */,
794  entity module /* the module dealt with */)
795 {
796  string dir, file, local;
797  const char* name;
798  text t;
799 
801  name = module_local_name(common);
803  name = "blank";
804  local = strdup(concatenate(name, ".h", NULL));
805  file = strdup(concatenate(dir, "/", local, NULL));
806  free(dir);
807 
808  if (file_exists_p(file))
809  {
810  /* the include was generated once before... */
811  t = include(local);
812  }
813  else
814  {
815  string nofile =
816  strdup(concatenate(file, ".sorry_common_not_homogeneous", NULL));
817  t = text_common_declaration(common, module);
818  if (!file_exists_p(nofile))
819  {
820  if (check_common_inclusion(common))
821  {
822  /* same declaration, generate the file! */
823  FILE * f = safe_fopen(file, "w");
824  fprintf(f, "!!\n!! pips: include file for common %s\n!!\n",
825  name);
826  print_text(f, t);
827  safe_fclose(f, file);
828  t = include(local);
829  }
830  else
831  {
832  /* touch the nofile to avoid the inclusion check latter on. */
833  FILE * f = safe_fopen(nofile, "w");
834  fprintf(f,
835  "!!\n!! pips: sorry, cannot include common %s\n!!\n",
836  name);
837  safe_fclose(f, nofile);
838  }
839  free(nofile);
840  }
841  }
842 
843  free(local); free(file);
844  return t;
845 }
846 
847 /* @brief This function compute the list of declaration at the begining of
848  * a module. It's intended to be used with Fortran or Fortran95 only
849  *
850  * @param ldecl is the list of entity to be prettyprinted
851  * @param force_common will force the prettyprint of common in include
852  * @param
853  * @param pdl is the list of previously declared derived entities
854  * @return the text of module declarations
855  */
857  list /* of entity */ ldecl,
858  bool force_common,
859  list * ppdl)
860 {
861  /*
862  * allocatable_pass indicate if we want to prettyprint allocatable or non
863  * allocatable entity, this is set to true during a second recursive pass.
864  */
865  static bool allocatable_pass_p = false;
866  list allocatable_list = NULL;
867 
868  const char* how_common = get_string_property("PRETTYPRINT_COMMONS");
869  bool print_commons = !same_string_p(how_common, "none");
870  /* prettyprint common in include if possible... */
871  bool pp_cinc = same_string_p(how_common, "include") && !force_common;
872  list before = NIL, area_decl = NIL, pi1 = NIL, pi2 = NIL, pi4 = NIL, pi8 =
873  NIL, ph1 = NIL, ph2 = NIL, ph4 = NIL, ph8 = NIL, pf4 = NIL, pf8 = NIL,
874  pl = NIL, pc8 = NIL, pc16 = NIL, ps = NIL, lparam = NIL, uses = NIL;
875  list * ppi = NULL;
876  list * pph = NULL;
877  text r, t_chars = make_text(NIL), t_area = make_text(NIL);
878  const char* pp_var_dim = get_string_property("PRETTYPRINT_VARIABLE_DIMENSIONS");
879  bool pp_in_type = false, pp_in_common = false;
880  bool space_p = get_bool_property("PRETTYPRINT_LISTS_WITH_SPACES");
881  /* Declarations cannot be sorted out because Fortran standard impose
882  at least an order on parameters. Fortunately here, PARAMETER are
883  mostly integers, defined from other integer parameters... I assume
884  that PIPS would fail with an ENTRY referencing an integer array
885  dimensionned with a real parameter. But real parameters are not
886  really well processed by PIPS anyway... Also we are in trouble if
887  arrays or functions are used dimension other arrays
888 
889  list sorted_ldecl = gen_copy_seq(ldecl);
890 
891  gen_sort_list(sorted_ldecl, compare_entities); */
892 
894 
895 
896  /*
897  * Deals with indentation
898  */
899  list indentation_words = NIL;
901  for(int i=0; i<INDENTATION; i++) {
902  indentation_words = CHAIN_SWORD(indentation_words, " ");
903  }
904  }
905 
906  /* where to put the dimension information.
907  */
908  if (same_string_p(pp_var_dim, "type")) {
909  pp_in_type = true, pp_in_common = false;
910  } else if (same_string_p(pp_var_dim, "common")) {
911  pp_in_type = false, pp_in_common = true;
912  } else {
913  pips_internal_error("PRETTYPRINT_VARIABLE_DIMENSIONS=\"%s\""
914  " unexpected value\n", pp_var_dim);
915  }
916 
917 
918 
919  FOREACH(ENTITY, e,ldecl) {
920  type te = entity_type(e);
921  bool func = type_functional_p(te) && storage_rom_p(entity_storage(e));
922  value v = entity_initial(e);
923  bool param = func && value_symbolic_p(v);
924  bool external = /* subroutines won't be declared */
925  (func
926  && (value_code_p(v) || value_unknown_p(v) /* not parsed callee */)
931  bool area_p = type_area_p(te);
932  bool var = type_variable_p(te);
933  bool in_ram = storage_ram_p(entity_storage(e));
934  bool in_common = in_ram
936  bool skip_it = same_string_p(entity_local_name(e),
938 
939  pips_debug(3, "entity name is %s\n", entity_name(e));
940 
941  /* Do not declare variables used to replace formal labels */
943  && get_bool_property("PRETTYPRINT_REGENERATE_ALTERNATE_RETURNS")
945  continue;
946 
947  if (!print_commons && area_p && !entity_special_area_p(e) && !pp_cinc) {
948  area_decl = CONS(SENTENCE,
950  common_hook(module, e)),
951  area_decl);
952  }
953 
954  if (skip_it) {
955  pips_debug(5, "skipping function %s\n", entity_name(e));
956  } else if (entity_f95use_p(e)) {
957  uses = CONS(SENTENCE, sentence_f95use_declaration(e), uses);
958  } else if (!print_commons && (area_p || (var && in_common && pp_cinc))) {
959  pips_debug(5, "skipping entity %s\n", entity_name(e));
960  } else if (param) {
961  /* PARAMETER
962  */
963  pips_debug(7, "considered as a parameter\n");
964  lparam = CONS(ENTITY, e, lparam);
965  } else if (external) {
966  /* EXTERNAL
967  */
968  pips_debug(7, "considered as an external\n");
969  before = CONS(SENTENCE, sentence_basic_declaration(e), before);
970  before = CONS(SENTENCE, sentence_external(e), before);
971  } else if (area_p && !dynamic_area_p(e) && !heap_area_p(e)
973  /* AREAS: COMMONS and SAVEs
974  */
975  pips_debug(7, "considered as a regular common\n");
976  if (pp_cinc && !entity_special_area_p(e)) {
978  MERGE_TEXTS(t_area, t);
979  } else
980  area_decl = CONS(SENTENCE,
981  sentence_area(e, module, pp_in_common, ppdl),
982  area_decl);
983  } else if (var && !(in_common && pp_cinc)) {
985  bool pp_dim = pp_in_type || variable_static_p(e);
986 
987  pips_debug(7, "is a variable...\n");
988 
989  switch(basic_tag(b)) {
990  case is_basic_int:
991  /* simple integers are moved ahead... */
992 
993  pips_debug(7, "is an integer\n");
995  string s = string_undefined;
996  switch(basic_int(b)) {
997  case 4:
998  ppi = &pi4;
999  s = "INTEGER ";
1000  break;
1001  case 2:
1002  ppi = &pi2;
1003  s = "INTEGER*2 ";
1004  break;
1005  case 8:
1006  ppi = &pi8;
1007  s = "INTEGER*8 ";
1008  break;
1009  case 1:
1010  ppi = &pi1;
1011  s = "INTEGER*1 ";
1012  break;
1013 
1014  default:
1015  pips_internal_error("Unexpected integer size");
1016  }
1017 
1018  *ppi = f77_f95_style_management (*ppi, s, allocatable_pass_p, space_p);
1019  *ppi = gen_nconc(*ppi, words_declaration(e, pp_dim, ppdl));
1020  } else {
1021  string s = string_undefined;
1022 
1023  switch(basic_int(b)) {
1024  case 4:
1025  pph = &ph4;
1026  s = "INTEGER ";
1027  break;
1028  case 2:
1029  pph = &ph2;
1030  s = "INTEGER*2 ";
1031  break;
1032  case 8:
1033  pph = &ph8;
1034  s = "INTEGER*8 ";
1035  break;
1036  case 1:
1037  pph = &ph1;
1038  s = "INTEGER*1 ";
1039  break;
1040  default:
1041  pips_internal_error("Unexpected integer size");
1042  }
1043  *pph = f77_f95_style_management (*pph, s, allocatable_pass_p, space_p);
1044  *pph = gen_nconc(*pph, words_declaration(e, pp_dim, ppdl));
1045  }
1046  break;
1047  case is_basic_float:
1048  pips_debug(7, "is a float\n");
1049  switch(basic_float(b)) {
1050  case 4:
1051  pf4 = f77_f95_style_management(pf4, "REAL*4 ", allocatable_pass_p, space_p);
1052  pf4 = gen_nconc(pf4, words_declaration(e, pp_dim, ppdl));
1053  break;
1054  case 8:
1055  default:
1056  pf8 = f77_f95_style_management(pf8, "REAL*8 ", allocatable_pass_p, space_p);
1057  pf8 = gen_nconc(pf8, words_declaration(e, pp_dim, ppdl));
1058  break;
1059  }
1060  break;
1061  case is_basic_complex:
1062  pips_debug(7, "is a complex\n");
1063  switch(basic_complex(b)) {
1064  case 8:
1065  pc8 = f77_f95_style_management(pc8, "COMPLEX*8 ", allocatable_pass_p, space_p);
1066  pc8 = gen_nconc(pc8, words_declaration(e, pp_dim, ppdl));
1067  break;
1068  case 16:
1069  default:
1070  pc16 = f77_f95_style_management(pc16, "COMPLEX*16 ", allocatable_pass_p, space_p);
1071  pc16 = gen_nconc(pc16, words_declaration(e, pp_dim, ppdl));
1072  break;
1073  }
1074  break;
1075  case is_basic_logical:
1076  pips_debug(7, "is a logical\n");
1077  pl = CHAIN_SWORD(pl, pl==NIL ? "LOGICAL " : (space_p? ", " : ","));
1078  pl = gen_nconc(pl, words_declaration(e, pp_dim, ppdl));
1079  break;
1080  case is_basic_overloaded:
1081  /* nothing! some in hpfc I guess...
1082  */
1083  break;
1084  case is_basic_string: {
1085  value v = basic_string(b);
1086  pips_debug(7, "is a string\n");
1087 
1089  int i = constant_int(value_constant(v));
1090 
1091  if (i == 1) {
1092  ps = f77_f95_style_management(ps, "CHARACTER ", allocatable_pass_p, space_p);
1093  ps = gen_nconc(ps, words_declaration(e, pp_dim, ppdl));
1094  } else {
1095  list chars = NIL;
1096  chars = CHAIN_SWORD(chars, "CHARACTER*");
1097  chars = CHAIN_IWORD(chars, i);
1098  chars = CHAIN_SWORD(chars, " ");
1099  chars = gen_nconc(chars, words_declaration(e, pp_dim, ppdl));
1100  attach_declaration_size_type_to_words(chars, "CHARACTER", i);
1101  ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t_chars, chars,
1103  }
1104  } else if (value_unknown_p(v)) {
1105  list chars = NIL;
1106  chars = CHAIN_SWORD(chars, "CHARACTER*(*) ");
1107  chars = gen_nconc(chars, words_declaration(e, pp_dim, ppdl));
1108  attach_declaration_type_to_words(chars, "CHARACTER*(*)");
1109  ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t_chars, chars,
1111  } else if (value_symbolic_p(v)) {
1112  list chars = NIL;
1113  symbolic s = value_symbolic(v);
1114  chars = CHAIN_SWORD(chars, "CHARACTER*(");
1116  ppdl));
1117  chars = CHAIN_SWORD(chars, ") ");
1118  chars = gen_nconc(chars, words_declaration(e, pp_dim, ppdl));
1119 
1120  attach_declaration_type_to_words(chars, "CHARACTER*(*)");
1121  ADD_WORD_LIST_TO_TEXT(t_chars, chars);
1122  } else
1123  pips_internal_error("unexpected value");
1124  break;
1125  }
1126  case is_basic_derived: {
1127  if(allocatable_pass_p) {
1128  pips_internal_error("We got an allocatable but we are inside"
1129  "allocatable pass !! This should be impossible...\n");
1130  }
1131  // Chains the entity to be declared, aka the array inside allocatable
1132  allocatable_list = CONS(entity,get_allocatable_data_entity(e),allocatable_list);
1133  break;
1134  }
1135  default:
1136  pips_internal_error("unexpected basic tag (%d)",
1137  basic_tag(b));
1138  }
1139  }
1140  }
1141 
1142 
1143  /* usually they are sorted in order, and appended backwards,
1144  * hence the reversion.
1145  */
1146  r = make_text(uses);
1147  MERGE_TEXTS(r, make_text(gen_nreverse(before)));
1148 
1149  MERGE_TEXTS(r, text_of_parameters(lparam));
1150  gen_free_list(lparam), lparam = NIL;
1151 
1153  attach_declaration_type_to_words(ph1, "INTEGER*1");
1155  attach_declaration_type_to_words(ph2, "INTEGER*2");
1157  attach_declaration_type_to_words(ph4, "INTEGER");
1159  attach_declaration_type_to_words(ph8, "INTEGER*8");
1161  attach_declaration_type_to_words(pi1, "INTEGER*1");
1163  attach_declaration_type_to_words(pi2, "INTEGER*2");
1165  attach_declaration_type_to_words(pi4, "INTEGER");
1167  attach_declaration_type_to_words(pi8, "INTEGER*8");
1169  attach_declaration_type_to_words(pf4, "REAL*4");
1171  attach_declaration_type_to_words(pf8, "REAL*8");
1175  attach_declaration_type_to_words(pc8, "COMPLEX*8");
1177  attach_declaration_type_to_words(pc16, "COMPLEX*16");
1179  attach_declaration_type_to_words(ps, "CHARACTER");
1180  MERGE_TEXTS(r, t_chars);
1181 
1182  /* all about COMMON and SAVE declarations
1183  */
1184  MERGE_TEXTS(r, make_text(area_decl));
1185  MERGE_TEXTS(r, t_area);
1186 
1187  /* and EQUIVALENCE statements... - BC
1188  */
1189  MERGE_TEXTS(r, text_equivalences(module, /* sorted_ */ldecl,
1190  pp_cinc || !print_commons));
1191 
1192  /* what about DATA statements! FC
1193  */
1194  /* More general way with with call to text_initializations(module) in
1195  text_named_module() */
1196  /*
1197  if(get_bool_property("PRETTYPRINT_DATA_STATEMENTS")) {
1198  MERGE_TEXTS(r, text_data(module, ldecl));
1199  }
1200  */
1201 
1202  /* gen_free_list(sorted_ldecl); */
1203 
1204  if(!allocatable_pass_p && !ENDP(allocatable_list)) {
1205  /* We have to do a recursive call to get the allocatable declarations */
1206  allocatable_pass_p = true;
1207  MERGE_TEXTS(r,text_entity_declaration(module,allocatable_list,force_common,ppdl));
1208  allocatable_pass_p = false;
1209  }
1210 
1211  return r;
1212 }
1213 
1214 /* exported for hpfc.
1215  */
1217 {
1218  /* Assume Fortran only! */
1219  list pdl = NIL;
1221  (module, code_declarations(entity_code(module)), false, &pdl);
1222  gen_free_list(pdl);
1223  return t;
1224 }
1225 
1226 /* needed for hpfc
1227  */
1229  entity common,
1230  entity module)
1231 {
1232  type t = entity_type(common);
1233  list l;
1234  text result;
1235  list pdl = NIL; // Assumed Fortran only
1236  pips_assert("indeed a common", type_area_p(t));
1237  l = CONS(ENTITY, common, common_members_of_module(common, module, false));
1238  result = text_entity_declaration(module, l, true, &pdl);
1239  gen_free_list(l);
1240  gen_free_list(pdl);
1241  return result;
1242 }
1243 
1245 {
1246  text t = make_text(NIL);
1247  list il = list_undefined;
1248 
1249  pips_assert("m is a module", entity_module_p(m));
1250 
1252 
1253  FOREACH(STATEMENT, is, il) {
1254  /* The previous declaration list is useless in Fortran, but the
1255  signature of functions designed for C or Fortran must be
1256  respected. */
1257  list pdl = NIL;
1260  strdup(statement_comments(is))));
1261  }
1263  gen_free_list(pdl);
1264  }
1265 
1266  return t;
1267 }
1268 ␌
1269 /* returns the DATA initializations.
1270  * limited to integers, because I do not know where is the value
1271  * for other types...
1272  */
1273 static text __attribute__ ((unused))
1274 text_data(entity __attribute__ ((unused)) module, list /* of entity */ ldecl)
1275 {
1276  list /* of sentence */ ls = NIL;
1277 
1278  FOREACH(ENTITY, e, ldecl)
1279  {
1280  value v = entity_initial(e);
1281  if(!value_undefined_p(v) &&
1283  ls = CONS(SENTENCE, sentence_data(e), ls);
1284  }
1285 
1286  return make_text(ls);
1287 }
unformatted make_unformatted(string a1, intptr_t a2, intptr_t a3, list a4)
Definition: text.c:149
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
text make_text(list a)
Definition: text.c:107
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define VALUE_TO_INT(val)
#define value_le(v1, v2)
#define value_compare(v1, v2)
int Value
#define value_plus(v1, v2)
binary operators on values
void attach_declaration_type_to_words(list l, string declaration_type)
Attach a declaration type to all the words of the given list.
void attach_declaration_size_type_to_words(list l, string declaration_type, int size)
Attach a declaration type with its size to all the words of the given list.
bool vect_constant_p(Pvecteur)
bool vect_constant_p(Pvecteur v): v contains only a constant term, may be zero
Definition: predicats.c:211
static sentence sentence_f95use_declaration(entity e)
Create a sentence for a USE directive.
static sentence sentence_area(entity e, entity module, bool pp_dimensions, list *ppdl)
special management of empty commons added.
static string(* common_hook)(entity, entity)
static string default_common_hook(entity __attribute__((unused)) module, entity common)
We add this function to cope with the declaration When the user declare sth.
static int equivalent_entity_compare(entity *ent1, entity *ent2)
static int equivalent_entity_compare(entity *ent1, entity *ent2) input : two pointers on entities.
static text text_equivalences(entity __attribute__((unused)) module, list ldecl, bool no_commons)
input : the current module, and the list of declarations.
static void equiv_class_debug(list l_equiv)
static list f77_f95_style_management(list prev, string str, bool allocatable_pass_p, bool space_p)
This handle the fact that a Fortran95 declaration use "::" as a separator between type and variable n...
Definition: declarations2.c:67
static text __attribute__((unused))
returns the DATA initializations.
#define EQUIV_DEBUG
debugging for equivalences
Definition: declarations2.c:48
static text text_entity_declaration(entity module, list ldecl, bool force_common, list *ppdl)
This function compute the list of declaration at the begining of a module.
#define ADD_WORD_LIST_TO_TEXT(t, l)
To deal with declarations above ri-util and pipsdbm and text-util.
Definition: declarations2.c:54
text text_initializations(entity m)
static sentence sentence_data_statement(statement is, list *ppdl)
Prettyprint the initializations field of code.
static sentence sentence_data(entity e)
why is it assumed that the constant is an int ???
static text text_equivalence_class(list l_equiv)
static text text_equivalence_class(list l_equiv) input : a list of entities representing an equivale...
void reset_prettyprinter_common_hook(void)
text text_common_declaration(entity common, entity module)
needed for hpfc
static text include(const char *file)
if the common is declared similarly in all routines, generate "include 'COMMON.h'",...
Definition: declarations2.c:92
static sentence sentence_external(entity f)
static sentence sentence_symbolic(entity f, list *ppdl)
text text_declaration(entity module)
exported for hpfc.
static text text_area_included(entity common, entity module)
#define ADD_WORD_LIST_TO_TEXT_WITH_MARGIN(t, l, m)
Definition: declarations2.c:55
static text text_of_parameters(list lp)
static sentence sentence_basic_declaration(entity e)
static Value size_elt_1
Definition: translation.c:285
static Value offset
Definition: translation.c:283
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
bool file_exists_p(const char *name)
Definition: file.c:321
char * get_string_property(const char *)
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define LIST(x)
Definition: genC.h:93
#define STRING(x)
Definition: genC.h:87
void free(void *)
#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
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#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
#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
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
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
bool empty_comments_p(const char *)
Definition: statement.c:107
struct _newgen_struct_entities_ * entities
Definition: hpf_private.h:89
bool prettyprint_language_is_fortran95_p()
Definition: language.c:83
string db_get_directory_name_for_module(const char *name)
returns the allocated and mkdir'ed directory for module name
Definition: lowlevel.c:150
#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 pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define BLANK_COMMON_LOCAL_NAME
Definition: naming-local.h:68
#define assert(ex)
Definition: newgen_assert.h:41
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define same_string_p(s1, s2)
#define string_undefined
Definition: newgen_types.h:40
char * string
STRING.
Definition: newgen_types.h:39
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static char * module
Definition: pips.c:74
#define WORKSPACE_SRC_SPACE
Definition: pipsdbm-local.h:32
bool check_common_inclusion(entity common)
check whether a common declaration can be simply included, that is it is declared with the same names...
Definition: area.c:107
list words_declaration(entity e, bool prettyprint_common_variable_dimensions_p, list *ppdl)
some compilers don't like dimensions that are declared twice.
Definition: declarations.c:277
unsigned int get_prettyprint_indentation()
Definition: misc.c:177
list words_expression(expression obj, list *ppdl)
This one is exported.
Definition: misc.c:2611
void set_prettyprinter_common_hook(string(*)(entity, entity))
declarations2.c
string basic_to_string(basic)
Definition: type.c:87
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
#define REPEAT_VALUE_NAME
Definition: ri-util-local.h:77
#define binary_call_rhs(c)
#define NORMALIZE_EXPRESSION(e)
#define STATEMENT_NUMBER_UNDEFINED
default values
#define ENTITY_STATIC_INITIALIZATION_P(e)
Fortran DATA management.
#define binary_call_lhs(c)
#define INDENTATION
#define ENTITY_DATA_LIST_P(e)
entity get_allocatable_data_entity(entity e)
Get the entity inside the struct corresponding to the array, mostly for correct prettyprint.
Definition: allocatable.c:157
bool dynamic_area_p(entity aire)
Definition: area.c:68
bool pointer_dummy_targets_area_p(entity aire)
Definition: area.c:113
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86
bool empty_static_area_p(entity e)
Definition: area.c:201
bool static_area_p(entity aire)
Definition: area.c:77
bool entity_special_area_p(entity e)
Definition: area.c:154
void check_fortran_declaration_dependencies(list ldecl)
Regeneration of declarations from the symbol table.
Definition: declarations.c:47
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool entity_f95use_p(entity e)
Definition: entity.c:694
code entity_code(entity e)
Definition: entity.c:1098
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
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool entity_module_p(entity e)
Definition: entity.c:683
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
bool expression_call_p(expression e)
Definition: expression.c:415
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
bool integer_constant_expression_p(expression e)
positive integer constant expression: call to a positive constant or to a sum of positive integer con...
Definition: expression.c:903
bool formal_label_replacement_p(entity)
Definition: variable.c:1797
int SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
Value ValueSizeOfArray(entity)
Definition: size.c:206
bool variable_in_list_p(entity, list)
Definition: variable.c:1623
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
Definition: size.c:297
int NumberOfDimension(entity)
Definition: size.c:588
bool variable_static_p(entity)
true if v appears in a SAVE statement, or in a DATA statement, or is declared static i C.
Definition: variable.c:1579
#define type_functional_p(x)
Definition: ri.h:2950
#define value_undefined_p(x)
Definition: ri.h:3017
@ is_basic_derived
Definition: ri.h:579
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
@ is_basic_logical
Definition: ri.h:573
@ is_basic_complex
Definition: ri.h:575
#define value_code_p(x)
Definition: ri.h:3065
#define functional_result(x)
Definition: ri.h:1444
#define storage_formal_p(x)
Definition: ri.h:2522
#define value_constant(x)
Definition: ri.h:3073
#define call_function(x)
Definition: ri.h:709
#define basic_int(x)
Definition: ri.h:616
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define constant_int(x)
Definition: ri.h:850
#define type_functional(x)
Definition: ri.h:2952
#define value_unknown_p(x)
Definition: ri.h:3077
#define dimension_lower(x)
Definition: ri.h:980
#define basic_tag(x)
Definition: ri.h:613
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
#define code_declarations(x)
Definition: ri.h:784
#define storage_ram_p(x)
Definition: ri.h:2519
#define value_constant_p(x)
Definition: ri.h:3071
#define ram_section(x)
Definition: ri.h:2249
#define basic_overloaded_p(x)
Definition: ri.h:623
#define value_symbolic(x)
Definition: ri.h:3070
#define basic_undefined_p(x)
Definition: ri.h:557
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined
Definition: ri.h:2761
#define constant_int_p(x)
Definition: ri.h:848
#define expression_undefined
Definition: ri.h:1223
#define value_symbolic_p(x)
Definition: ri.h:3068
#define 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 code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define value_code(x)
Definition: ri.h:3067
#define syntax_call(x)
Definition: ri.h:2736
#define type_area(x)
Definition: ri.h:2946
#define basic_float(x)
Definition: ri.h:619
#define instruction_call_p(x)
Definition: ri.h:1527
#define variable_dimensions(x)
Definition: ri.h:3122
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define storage_ram(x)
Definition: ri.h:2521
#define instruction_call(x)
Definition: ri.h:1529
#define basic_complex(x)
Definition: ri.h:628
#define type_area_p(x)
Definition: ri.h:2944
#define storage_rom_p(x)
Definition: ri.h:2525
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define ram_shared(x)
Definition: ri.h:2253
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define type_variable_p(x)
Definition: ri.h:2947
#define symbolic_expression(x)
Definition: ri.h:2597
#define variable_basic(x)
Definition: ri.h:3120
#define basic_string(x)
Definition: ri.h:631
#define ram_offset(x)
Definition: ri.h:2251
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
#define ifdebug(n)
Definition: sg.c:47
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: replace.c:135
#define CHAIN_SWORD(l, s)
#define MERGE_TEXTS(r, t)
#define CHAIN_IWORD(l, i)
#define ADD_SENTENCE_TO_TEXT(t, p)
void print_text(FILE *fd, text t)
Definition: print.c:195
char * int2a(int)
util.c
Definition: util.c:42
#define sentence_undefined
Definition: text.h:42
#define SENTENCE(x)
newgen_unformatted_domain_defined
Definition: text.h:36
#define unformatted_words(x)
Definition: text.h:155
@ is_sentence_formatted
Definition: text.h:57
@ is_sentence_unformatted
Definition: text.h:58
#define val_of(varval)