PIPS
array_privatization.c
Go to the documentation of this file.
1 /*
2 
3  $Id: array_privatization.c 23412 2017-08-09 15:07:09Z irigoin $
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 
25 // do not compile unless required
26 #include "phases.h"
27 #if defined(BUILDER_ARRAY_PRIVATIZER) || \
28  defined(BUILDER_ARRAY_SECTION_PRIVATIZER) || \
29  defined(BUILDER_PRINT_CODE_PRIVATIZED_REGIONS) || \
30  defined(BUILDER_DECLARATIONS_PRIVATIZER)
31 
32 #ifdef HAVE_CONFIG_H
33  #include "pips_config.h"
34 #endif
35 /* regions package : Be'atrice Creusillet, october 1995
36  *
37  * array_privatization.c
38  * ~~~~~~~~~~~~~~~~~~~~~
39  *
40  * This File contains the functions computing the private regions.
41  */
42 
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <string.h>
47 
48 #include "genC.h"
49 #include "linear.h"
50 
51 #include "ri.h"
52 #include "effects.h"
53 
54 #include "ri-util.h"
55 #include "effects-util.h"
56 
57 #include "misc.h"
58 #include "properties.h"
59 
60 #include "pipsmake.h" // ??? find_rule_by_resource hack
61 
62 #include "transformer.h" // used
63 #include "semantics.h" // used
64 
65 #include "effects-generic.h"
66 #include "effects-convex.h"
67 
68 #include "pipsdbm.h"
69 
70 /********************** 1- PRIVATIZABILITY DETECTION && LOOP PRIVATISATION */
71 
72 /************************************* USEFUL VARIABLES AND ACCESS FUNCTIONS */
73 
74 /* global static variable local_regions_map, and its access functions */
77 
78 /* statement stack */
80 
81 /* what sort of privatization? */
82 static bool store_as_regions = false;
83 static bool store_as_loop_locals = true;
84 static bool privatize_sections = false;
85 static bool copy_in = false;
86 static bool copy_out = false;
87 
88 static void array_privatization_error_handler(void)
89 {
90  error_reset_current_stmt_stack();
91  store_as_regions = false;
92  store_as_loop_locals = true;
93  privatize_sections = false;
94  copy_in = false;
95  copy_out = false;
96 }
97 
98 /********************************** INTRAPROCEDURAL PRIVATE REGIONS ANALYSIS */
99 
100 
101 static void private_regions_of_module_statement(statement module_stat);
102 static void private_regions_of_module_loops(statement module_stat);
103 static bool privatizer(const string module_name);
104 
105 /* void array_privatizer(const char* module_name)
106  * input : the name of the current module
107  * output : nothing.
108  * modifies : computes the local regions of a module.
109  * comment : local regions can contain local variables.
110  */
111 bool array_privatizer(const string module_name)
112 {
113  store_as_regions = false;
114  store_as_loop_locals = true;
115  privatize_sections = false;
116  copy_in = false;
117  copy_out = false;
118  return privatizer(module_name);
119 }
120 
121 
122 /* void array_section_privatizer(const char* module_name)
123  * input : the name of the current module
124  * output : nothing.
125  * modifies : computes the local regions of a module.
126  * comment : local regions can contain local variables.
127  */
128 bool array_section_privatizer(const string module_name)
129 {
130  store_as_regions = true;
131  store_as_loop_locals = true;
132  privatize_sections = true;
133  copy_in = false;
134  copy_out = get_bool_property("ARRAY_SECTION_PRIV_COPY_OUT");
135  return privatizer(module_name);
136 }
137 
138 /* void privatizer(const char* module_name)
139  * input : the name of the current module
140  * output : nothing.
141  * modifies : computes the local regions of a module.
142  * comment : local regions can contain local variables.
143  */
144 static bool privatizer(const string module_name)
145 {
146  entity module;
147  statement module_stat;
148 
149  pips_assert("Copy-in not implemented.\n", !copy_in);
150  pips_assert("No array section privatization"
151  " if we do not store as regions.\n",
152  store_as_regions || ! privatize_sections);
153  pips_assert("No copy-in or copy-out"
154  " if we do not privatize array sections.\n",
155  privatize_sections || (!copy_in && !copy_out) );
156 
157  reset_hooks_register(array_privatization_error_handler);
158 
160  "MUST_REGIONS"))
161  pips_user_warning("\nMUST REGIONS not selected - "
162  "Do not expect wonderful results\n");
163 
164  /* set and get the current properties concerning regions */
165  set_bool_property("MUST_REGIONS", true);
166  set_bool_property("EXACT_REGIONS", true);
168 
169  /* Get the code of the module. */
171  db_get_memory_resource(DBR_CODE, module_name, true) );
172  module_stat = get_current_module_statement();
173 
174  /* Get the transformers and preconditions of the module. (Necessary ?) */
176  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true) );
178  db_get_memory_resource(DBR_PRECONDITIONS, module_name, true) );
179 
180  /* Get the READ, WRITE, IN and OUT regions of the module */
182  db_get_memory_resource(DBR_REGIONS, module_name, true));
184  db_get_memory_resource(DBR_INV_REGIONS, module_name, true));
186  db_get_memory_resource(DBR_IN_REGIONS, module_name, true));
188  db_get_memory_resource(DBR_INV_IN_REGIONS, module_name, true));
190  db_get_memory_resource(DBR_OUT_REGIONS, module_name, true));
191 
193 
194  /* predicates defining summary regions from callees have to be
195  translated into variables local to module */
198 
200  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true) );
202  db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true) );
204 
205  /* initialisation of private maps */
206  if (store_as_regions)
207  {
208  init_private_effects();
209  init_copy_out_effects();
210  }
211 
212  debug_on("ARRAY_PRIVATIZATION_DEBUG_LEVEL");
213  pips_debug(1, "begin\n");
214 
215  /* Compute the private regions of the module and of its loops. */
216  private_regions_of_module_statement(module_stat);
217  private_regions_of_module_loops(module_stat);
218 
219  pips_debug(1, "end\n");
220  debug_off();
221 
222  if (store_as_regions)
223  {
224  DB_PUT_MEMORY_RESOURCE(DBR_PRIVATIZED_REGIONS,
225  module_name, (char*) get_private_effects());
226  DB_PUT_MEMORY_RESOURCE(DBR_COPY_OUT_REGIONS,
227  module_name, (char*) get_copy_out_effects());
228  }
229 
230  /* sort locals
231  */
232  sort_all_loop_locals(module_stat);
233 
234  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
235 
236 
237  reset_hooks_unregister(array_privatization_error_handler);
250  if (store_as_regions)
251  {
252  reset_private_effects();
253  reset_copy_out_effects();
254  }
256 
257  return(true);
258 }
259 
260 
261 
262 static void private_regions_of_module_statement(statement module_stat)
263 {
264  list l_priv, l_cand, l_out_cand;
265  list l_write = regions_dup
267  list l_in = regions_dup(load_statement_in_regions(module_stat));
268  list l_out = regions_dup(load_statement_out_regions(module_stat));
269 
270 
271  pips_debug(1,"begin\n");
272 
273  pips_debug(2, "CAND = W -inf IN \n");
274  l_cand = RegionsInfDifference(l_write, l_in, w_r_combinable_p);
275 
276  pips_debug(2, "OUT_CAND = CAND inter OUT\n");
277  l_out_cand =
279 
280  pips_debug(2, "PRIV = CAND -inf OUT_CAND\n");
281  l_priv = RegionsInfDifference(l_cand, l_out_cand, w_w_combinable_p);
282 
283  if (store_as_regions)
284  {
285  store_private_effects(module_stat, make_effects(l_priv));
286  store_copy_out_effects(module_stat, make_effects(NIL));
287  }
288 
289  pips_debug(1,"end\n");
290 }
291 
292 
293 static bool stmt_filter(statement s);
294 static void private_regions_of_statement(statement s);
295 static bool private_regions_of_loop(loop l);
296 
297 
298 /* static void private_regions_of_module_loops(statement module_stat)
299  * input : the current statement.
300  * output :
301  * modifies :
302  * comment :
303  */
304 static void private_regions_of_module_loops(statement module_stat)
305 {
306 
307  make_current_stmt_stack();
308 
309  pips_debug(1,"begin\n");
310 
312  module_stat,
313  statement_domain, stmt_filter, private_regions_of_statement,
314  loop_domain, private_regions_of_loop, gen_null,
315  NULL);
316 
317 
318  pips_debug(1,"end\n");
319 
320  free_current_stmt_stack();
321 
322 }
323 
324 
325 static bool stmt_filter(s)
326 statement s;
327 {
328  pips_debug(1, "statement %03zd\n", statement_number(s));
329 
330  current_stmt_push(s);
331  pips_debug(1, "end\n");
332  return(true);
333 }
334 
335 static void private_regions_of_statement(s)
336 statement s;
337 {
338  pips_debug(1, "statement %03zd\n", statement_number(s));
339 
340  if (store_as_regions && !bound_private_effects_p(s))
341  {
342  pips_debug(6, "non-loop body statement, storing NIL regions.\n");
343  store_private_effects(s, make_effects(NIL));
344  store_copy_out_effects(s, make_effects(NIL));
345  }
346 
347  current_stmt_pop();
348 
349  pips_debug(1, "end\n");
350 
351 }
352 
353 
354 static bool private_regions_of_loop(l)
355 loop l;
356 {
357  statement b = loop_body(l);
359  list l_cand, l_loc, l_out_priv, l_out_priv_tmp, l_locals,
360  l_loc_i, l_loc_i_prime;
361  list l_write, l_in, l_out, l_tmp, l_cand_tmp;
362  entity i = loop_index(l);
364  Psysteme sc_loop_prec;
365  Pcontrainte contrainte;
366 
367  pips_debug(1, "begin, statement %03zd\n",
369 
370 
371  /* first get the write, in and out regions, invariant if available */
372  l_write =
374  l_in =
377 
379  loop_trans,
380  CONS(ENTITY, i, NIL));
381  ifdebug(2)
382  {
383  pips_debug(3, "W(i) before: \n");
384  print_regions(l_write);
385  pips_debug(3, "IN(i) before: \n");
386  print_regions(l_in);
387  pips_debug(3, "OUT(i) before: \n");
388  print_regions(l_out);
389  }
390 
391 
392  if (privatize_sections)
393  {
394  /* LOC(i) = W(i) -inf IN(i) */
395  l_tmp = regions_dup(l_in);
396  l_loc = RegionsInfDifference(l_write, l_tmp, w_w_combinable_p);
397 
398  ifdebug(3)
399  {
400  pips_debug(3, "LOC(i) = W(i) -inf IN(i)\n");
401  print_regions(l_loc);
402  }
403  }
404  else
405  {
406  /* LOC(i) = W(i) -
407  {les re'gions correspondant a` des tableaux dans IN(i)}*/
408  l_tmp = regions_dup(l_in);
409  l_loc = RegionsEntitiesInfDifference(l_write, l_tmp, w_w_combinable_p);
410 
411  ifdebug(3)
412  {
413  pips_debug(3, "LOC(i) = W(i) -entities_inf IN(i)\n");
414  print_regions(l_loc);
415  }
416  }
417 
418  if (get_bool_property("ARRAY_PRIV_FALSE_DEP_ONLY"))
419  {
420  /* Keep only arrays that induce false dependences between iterations
421  * that is to say arrays such that
422  * LOC(i) inter LOC(i', i'<i) != empty_set
423  */
424  sc_loop_prec = sc_loop_proper_precondition(l);
425 
426  /* we make and LOC(i, i'<i) and LOC(i', i'<i) */
427  l_loc_i_prime = regions_dup(l_loc);
428  l_loc_i = regions_dup(l_loc);
429  array_regions_variable_rename(l_loc_i_prime, i, i_prime);
430  contrainte = contrainte_make(vect_make(VECTEUR_NUL,
431  (Variable) i_prime, VALUE_ONE,
432  (Variable) i, VALUE_MONE,
433  TCST, VALUE_ONE));
434  sc_add_inegalite(sc_loop_prec, contrainte_dup(contrainte));
435  sc_loop_prec->base = BASE_NULLE;
436  sc_creer_base(sc_loop_prec);
437  l_loc_i_prime =
438  array_regions_sc_append(l_loc_i_prime, sc_loop_prec, false);
439  l_loc_i = array_regions_sc_append(l_loc_i, sc_loop_prec, false);
440  sc_rm(sc_loop_prec);
441 
442  /* LOC_I(i) = LOC(i, i'<i) inter LOC(i', i'<i) */
443  l_loc_i =
444  RegionsIntersection(l_loc_i, l_loc_i_prime, w_w_combinable_p);
445 
446  /* We keep in Loc(i) only the regions that correspond to arrays in
447  * l_loc_i, that is to say arrays that induce false dependences
448  */
449  l_loc = RegionsEntitiesIntersection(l_loc, l_loc_i, w_w_combinable_p);
450 
451  ifdebug(3)
452  {
453  pips_debug(3, "regions on arrays that really induce "
454  "false dependences:\n");
455  print_regions(l_loc);
456  }
457  }
458 
459  if (privatize_sections)
460  {
461  /* CAND(i) = LOC(i) -inf proj_i'[IN(i')] */
462 
463  /* first proj_i'[IN(i')] */
464  sc_loop_prec = sc_loop_proper_precondition(l);
465  array_regions_variable_rename(l_in, i, i_prime);
466  l_in = array_regions_sc_append(l_in, sc_loop_prec, false);
467  sc_rm(sc_loop_prec);
468  project_regions_along_loop_index(l_in, i_prime, loop_range(l));
469 
470  /* Then the difference */
471  l_cand = RegionsInfDifference(l_loc, l_in, w_w_combinable_p);
472 
473  ifdebug(3)
474  {
475  pips_debug(3, "CAND(i) = LOC(i) -inf proj_i'[IN(i')]\n");
476  print_regions(l_cand);
477  }
478 
479  }
480  else
481  {
482  /* CAND(i) = LOC(i), because LOC(i) inter IN(i') = empty */
483  l_cand = l_loc;
484  pips_debug(3, "CAND(i) = LOC(i)\n");
485  }
486 
487 
488  if (copy_out)
489  {
490  /* OUT_PRIV(i) = CAND(i) inter OUT(i) */
491  l_out_priv = RegionsIntersection(regions_dup(l_cand),
492  l_out, w_w_combinable_p);
493 
494  ifdebug(3)
495  {
496  pips_debug(3, "OUT_PRIV(i) = CAND(i) inter OUT(i)\n");
497  print_regions(l_out_priv);
498  }
499 
500  /* keep only good candidates (those for which the copy-out is either
501  * empty or exactly determined). */
502 
503  l_out_priv_tmp = l_out_priv;
504  while(!ENDP(l_out_priv_tmp))
505  {
506  list l_cand_tmp;
507  bool found;
508 
509  region reg = EFFECT(CAR(l_out_priv_tmp));
510  l_out_priv_tmp = CDR(l_out_priv_tmp);
511  if (!region_exact_p(reg))
512  {
513  l_cand_tmp = l_cand;
514  found = false;
515  /* remove the corresponding candidate from l_cand */
516  while(!found && !ENDP(l_cand_tmp))
517  {
518  region reg_cand = EFFECT(CAR(l_cand_tmp));
519  l_cand_tmp = CDR(l_cand_tmp);
520  if (same_entity_p(region_entity(reg_cand),
521  region_entity(reg)))
522  {
523  /* a` optimiser */
524  gen_remove(&l_cand, reg_cand);
525  region_free(reg_cand);
526  found = true;
527  }
528  }
529  gen_remove(&l_out_priv, reg);
530  region_free(reg);
531  }
532  }
533  }
534  else
535  {
536  /* OUT_PRIV(i) = NIL */
537  l_out_priv = NIL;
538  /* CAND(i) = CAND(i) -entities_inf OUT(i) */
539  l_cand = RegionsEntitiesInfDifference(l_cand, l_out, w_w_combinable_p);
540 
541  ifdebug(3)
542  {
543  pips_debug(3, "No copy-out: OUT_PRIV(i) = NIL\n");
544  pips_debug(3, "l_cand: \n");
545  print_regions(l_cand);
546  }
547  }
548 
549 
550  /* remove variables in commons not declared in current module */
551  l_cand_tmp = l_cand;
552  while(!ENDP(l_cand_tmp))
553  {
554  region reg = REGION(CAR(l_cand_tmp));
555  entity reg_ent = region_entity(reg);
556  entity ccommon;
557  list l_tmp;
558  list l_com_ent;
559  bool found= false;
560 
561  l_cand_tmp = CDR(l_cand_tmp);
562 
563  /* First, we search if the common is declared in the current module;
564  * if not, the variable cannot be privatized, and a warning is issued.
565  */
566  if(storage_ram_p(entity_storage(reg_ent)))
567  {
568  ccommon = ram_section(storage_ram(entity_storage(reg_ent)));
569  l_com_ent = area_layout(type_area(entity_type(ccommon)));
570 
571  for(l_tmp = l_com_ent; !ENDP(l_tmp) && !found; l_tmp = CDR(l_tmp))
572  {
573  entity com_ent = ENTITY(CAR(l_tmp));
574  if (strcmp(entity_module_name(com_ent),
576  {
577  found = true;
578  }
579  }
580  if (!found)
581  {
583  ("\nCOMMON %s not declared in subroutine %s:\n\t"
584  "variable %s cannot be privatized in loop "
585  "number %03d\n",
586  entity_name(ccommon),
588  entity_name(reg_ent),
590  gen_remove(&l_cand, reg);
591 
592  }
593  }
594  }
595 
596  l_out_priv = RegionsEntitiesIntersection(l_out_priv, regions_dup(l_cand),
598 
599  /* compute loop_locals from l_cand */
600  if (store_as_loop_locals)
601  {
603  loop_locals(l) = NIL;
604  l_locals = NIL;
605  MAP(EFFECT, reg,
606  {
607  entity e = region_entity(reg);
608  if (!entity_in_list_p(e, loop_locals(l)))
609  l_locals = CONS(ENTITY, e, l_locals);
610  },
611  l_cand);
612 
613  loop_locals(l) = gen_nconc(loop_locals(l), l_locals);
614 
615  /* add the loop index */
618 
619  ifdebug(2)
620  {
621  pips_debug(2, "candidate entities: ");
623  }
624  }
625 
626  ifdebug(2)
627  {
628  pips_debug(2, "candidate regions:\n");
629  print_regions(l_cand);
630  /* No copy-in for the moment */
631  /* pips_debug(2, "copy-in:\n"); */
632  /* print_regions(l_out_priv); */
633  pips_debug(2, "copy-out:\n");
634  print_regions(l_out_priv);
635  }
636 
637  if (store_as_regions)
638  {
639  store_private_effects(b, make_effects(l_cand));
640  store_copy_out_effects(b,make_effects(l_out_priv));
641  }
642 
643  pips_debug(1, "end\n");
644 
645  return(true);
646 }
647 
648 
649 /*************************** PRETTYPRINT OF PRIVATIZED AND COPY-OUT REGIONS */
650 
652 {
653  bool ok, blks_tmp, priv_tmp, scal_tmp;
654 
655  /* PUSH properties (should be done from the script??? )
656  */
657  blks_tmp = get_bool_property("PRETTYPRINT_BLOCKS");
658  priv_tmp = get_bool_property("PRETTYPRINT_ALL_PRIVATE_VARIABLES");
659  scal_tmp = get_bool_property("PRETTYPRINT_SCALAR_REGIONS");
660 
661  set_bool_property("PRETTYPRINT_BLOCKS", true);
662  set_bool_property("PRETTYPRINT_ALL_PRIVATE_VARIABLES", true);
663  set_bool_property("PRETTYPRINT_SCALAR_REGIONS", true);
664 
665  /* DO IT!
666  */
667  add_a_generic_prettyprint(DBR_COPY_OUT_REGIONS, false,
671 
672  add_a_generic_prettyprint(DBR_PRIVATIZED_REGIONS, false,
676 
678 
680 
681  /* POP properties
682  */
683  set_bool_property("PRETTYPRINT_BLOCKS", blks_tmp);
684  set_bool_property("PRETTYPRINT_ALL_PRIVATE_VARIABLES", priv_tmp);
685  set_bool_property("PRETTYPRINT_SCALAR_REGIONS", scal_tmp);
686 
687  return ok;
688 }
689 
690 
691 /************************ 2- MODULE PRIVATISATION (VARIABLE REDECLARATION) */
692 
694 
695 #define PRIVATE_VARIABLE_SUFFIX "_P"
696 static entity current_old_entity = entity_undefined;
697 static entity current_new_entity = entity_undefined;
698 
699 static void
700 set_current_entities(entity e_old, entity e_new)
701 {
702  current_old_entity = e_old;
703  current_new_entity = e_new;
704 }
705 
706 static entity
707 get_current_old_entity()
708 {
709  return current_old_entity;
710 }
711 
712 static entity
713 get_current_new_entity()
714 {
715  return current_new_entity;
716 }
717 
718 static void
719 reset_current_entities()
720 {
721  current_old_entity = entity_undefined;
722  current_new_entity = entity_undefined;
723 }
724 
725 
726 static bool
728 {
729  entity e_old = get_current_old_entity();
730  entity e_new = get_current_new_entity();
731 
732  if (reference_variable(ref) == e_old)
733  reference_variable(ref) = e_new;
734 
735  return(true);
736 }
737 
738 static void
739 privatize_entity(entity ent)
740 {
741  entity new_ent;
742  string new_ent_name;
743  storage ent_storage = entity_storage(ent);
744  storage new_ent_storage;
746 
747  /* We do not need to privatize local (dynamic) or formal variables */
748  if (storage_ram_p(ent_storage) &&
749  !dynamic_area_p(ram_section(storage_ram(ent_storage))))
750  {
751  pips_user_warning("privatizing variable: %s\n",
752  entity_local_name(ent));
753 
754  /* Make a new ram entity, similar to the previous one,
755  but with a new name */
756  new_ent_name = copy_string(concatenate(entity_name(ent),
757  PRIVATE_VARIABLE_SUFFIX, NULL));
758 
759 
760  new_ent = make_entity(new_ent_name,
761  copy_type(entity_type(ent)),
763  copy_value(entity_initial(ent)));
764 
765 
766  new_ent_storage = make_storage
769  dynamic_area,
771  new_ent),
772  NIL));
773  entity_storage(new_ent) = new_ent_storage;
774 
775  /* add this entity to the declarations of the module */
777 
778  /* replace all references to this entity by a reference to the
779  * new entity */
780  set_current_entities(ent, new_ent);
783  reset_current_entities();
784  }
785 }
786 
787 bool declarations_privatizer(const string mod_name)
788 {
789  list l_priv = NIL, l_in, l_out, l_write;
790  statement module_stat;
791  entity module;
792 
793  if (get_bool_property("ARRAY_SECTION_PRIV_COPY_OUT"))
794  {
795  pips_user_warning("property ARRAY_SECTION_PRIV_COPY_OUT set to true ;"
796  " COPY OUT not implemented.\n" );
797  }
798 
800  "MUST_REGIONS"))
801  pips_user_warning("\nMUST REGIONS not selected - "
802  "Do not expect wonderful results\n");
803 
804 
805  /* set and get the current properties concerning regions */
806  set_bool_property("MUST_REGIONS", true);
807  set_bool_property("EXACT_REGIONS", true);
809 
810  /* Get the code of the module. */
812  db_get_memory_resource(DBR_CODE, mod_name, true) );
813  module_stat = get_current_module_statement();
817  db_get_memory_resource(DBR_CUMULATED_EFFECTS, mod_name, true));
819  db_get_memory_resource(DBR_PROPER_EFFECTS, mod_name, true));
821 
822  /* sets dynamic_area */
824  {
825 
827  }
828 
829  debug_on("ARRAY_PRIVATIZATION_DEBUG_LEVEL");
830 
831  /* Privatizable array regions */
832  /* For the moment, we only want to privatize whole variables;
833  * Thus we only keep those variables which are absolutely not imported
834  * nor exported.
835  * If we want to privatize regions, we can use the ressource
836  * PRIVATE_REGIONS.
837  */
838 
839  /* Get the READ, WRITE, IN and OUT regions of the module
840  */
842  db_get_memory_resource(DBR_REGIONS, mod_name, true));
844  db_get_memory_resource(DBR_IN_REGIONS, mod_name, true));
846  db_get_memory_resource(DBR_OUT_REGIONS, mod_name, true));
848 
849  l_write = regions_dup
851  l_in = regions_dup(load_statement_in_regions(module_stat));
852  l_out = regions_dup(load_statement_out_regions(module_stat));
853 
854  ifdebug(2)
855  {
856  pips_debug(3, "WRITE regions: \n");
857  print_regions(l_write);
858  pips_debug(3, "IN regions: \n");
859  print_regions(l_in);
860  pips_debug(3, "OUT regions: \n");
861  print_regions(l_out);
862  }
863 
864 
865  l_priv = RegionsEntitiesInfDifference(l_write, l_in, w_r_combinable_p);
866  l_priv = RegionsEntitiesInfDifference(l_priv, l_out, w_w_combinable_p);
867 
868  ifdebug(2)
869  {
870  pips_debug(3, "Private regions: \n");
871  print_regions(l_priv);
872  }
873 
874  /* We effectively perform the privatization */
875  MAP(REGION, reg,
876  {
877  privatize_entity(region_entity(reg));
878  },
879  l_priv);
880 
881  /* Then we need to clean the declarations */
882  /* to be done later or in another phase */
883 
884  debug_off();
885 
886  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, module_stat);
887 
898  return( true );
899 }
900 
901 #endif // BUILDER_*
effects make_effects(list a)
Definition: effects.c:568
type copy_type(type p)
TYPE.
Definition: ri.c:2655
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
value copy_value(value p)
VALUE.
Definition: ri.c:2784
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
static bool stmt_filter(statement s)
modifies global var current_caller_stmt
Definition: alias_pairs.c:222
#define VALUE_MONE
#define VALUE_ONE
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
#define region_entity(reg)
#define REGION
#define region
simulation of the type region
#define region_exact_p(reg)
list RegionsInfDifference(list l1, list l2, bool(*difference_combinable_p)(effect, effect))
list RegionsInfDifference(list l1, l2) input : two lists of regions output : a list of region,...
list RegionsEntitiesIntersection(list l1, list l2, bool(*intersection_combinable_p)(effect, effect))
list RegionsEntitiesIntersection(list l1,l2, bool (*intersection_combinable_p)(effect,...
list RegionsEntitiesInfDifference(list l1, list l2, bool(*difference_combinable_p)(effect, effect))
list RegionsEntitiesInfDifference(list l1, l2) input : two lists of regions output : a list of region...
list RegionsIntersection(list l1, list l2, bool(*intersection_combinable_p)(effect, effect))
list RegionsIntersection(list l1,l2, bool (*intersection_combinable_p)(effect, effect)) input : outpu...
static statement current_stmt
void print_copyinout_regions(list)
list regions_write_regions(list)
Psysteme sc_loop_proper_precondition(loop)
void region_free(effect)
void print_regions(list)
text text_copyinout_array_regions(list)
void set_methods_for_convex_effects(void)
methods.c
Definition: methods.c:235
void get_regions_properties(void)
list regions_dup(list)
void print_private_regions(list)
list regions_to_write_regions(list)
void array_regions_variable_rename(list, entity, entity)
void project_regions_with_transformer_inverse(list, transformer, list)
void project_regions_along_loop_index(list, entity, range)
void project_regions_along_loop_index(list l_reg, entity index, l_range) input : a list l_reg of regi...
text text_private_array_regions(list)
list array_regions_sc_append(list, Psysteme, bool)
void(* generic_attachment_function)(text)
void set_invariant_in_effects(statement_effects)
void set_rw_effects(statement_effects)
void reset_invariant_in_effects(void)
list load_statement_inv_regions(statement)
void add_a_generic_prettyprint(string, bool, generic_text_function, generic_prettyprint_function, generic_attachment_function)
bool w_r_combinable_p(effect, effect)
void reset_out_effects(void)
bool print_source_or_code_effects_engine(const char *, string, bool)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void set_out_effects(statement_effects)
void set_in_effects(statement_effects)
void reset_in_effects(void)
bool w_w_combinable_p(effect, effect)
void reset_generic_prettyprints(void)
void reset_invariant_rw_effects(void)
list load_statement_out_regions(statement)
void generic_effects_reset_all_methods(void)
list load_statement_in_regions(statement)
void set_invariant_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
list load_statement_local_regions(statement)
void reset_rw_effects(void)
list load_statement_inv_in_regions(statement)
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
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....
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
void sort_all_loop_locals(statement s)
Definition: loop.c:381
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define list_undefined_p(c)
Return if a list is undefined.
Definition: newgen_list.h:75
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#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
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define current_stmt_head()
We want to keep track of the current statement inside the recurse.
Definition: icfg_scan.c:76
#define rule_phase(x)
Definition: makefile.h:244
#define debug_on(env)
Definition: misc-local.h:157
#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 debug_off()
Definition: misc-local.h:160
#define abort()
Definition: misc-local.h:53
void reset_hooks_unregister(reset_func_t)
remove registered cleanup hook.
Definition: reset_hooks.c:73
void reset_hooks_register(reset_func_t)
reset_hooks.c
Definition: reset_hooks.c:44
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define DEFINE_LOCAL_STACK(name, type)
#define same_string_p(s1, s2)
#define copy_string(s)
Definition: newgen_types.h:42
static entity dynamic_area
static char * module
Definition: pips.c:74
rule find_rule_by_resource(const char *rname)
This function returns the active rule to produce resource rname.
Definition: pipsmake.c:694
void set_bool_property(const char *, bool)
static bool reference_filter(reference r)
======================================================================
Definition: delay.c:114
#define make_entity(n, t, s, i)
bool dynamic_area_p(entity aire)
Definition: area.c:68
int current_offset_of_area(entity a, entity v)
Definition: area.c:174
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool entity_in_list_p(entity ent, list ent_l)
look for ent in ent_l
Definition: entity.c:2221
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void print_entities(list l)
Definition: entity.c:167
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define loop_body(x)
Definition: ri.h:1644
#define reference_variable(x)
Definition: ri.h:2326
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
@ is_storage_ram
Definition: ri.h:2492
#define entity_undefined_p(x)
Definition: ri.h:2762
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
#define loop_locals(x)
Definition: ri.h:1650
#define storage_ram(x)
Definition: ri.h:2521
#define loop_range(x)
Definition: ri.h:1642
#define entity_type(x)
Definition: ri.h:2792
#define statement_number(x)
Definition: ri.h:2452
#define loop_index(x)
Definition: ri.h:1640
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void set_transformer_map(statement_mapping)
transformer load_statement_transformer(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
void reset_transformer_map(void)
#define ifdebug(n)
Definition: sg.c:47
static bool ok
GENERIC_LOCAL_FUNCTION(directives, step_directives)
Copyright 2007, 2008, 2009 Alain Muller, Frederique Silber-Chaussumier.
Pbase base
Definition: sc-local.h:75
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
bool array_section_privatizer(const string)
bool declarations_privatizer(const string)
bool array_privatizer(const string)
array_privatization.c
bool print_code_privatized_regions(const string)
entity entity_to_intermediate_value(entity)
Definition: value.c:879
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
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_make(Pvecteur v, Variable var, Value val,...)
Pvecteur vect_make(v, [var, val,]* 0, val) Pvecteur v; // may be NULL, use assigne anyway Variable va...
Definition: alloc.c:165