PIPS
compose.c
Go to the documentation of this file.
1 /*
2 
3  $Id: compose.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 /* package convex effects : Be'atrice Creusillet 6/97
28  *
29  * File: compose.c
30  * ~~~~~~~~~~~~~~~
31  *
32  * This File contains the intanciation of the generic functions necessary
33  * for the composition of convex effects with transformers or preconditions
34  *
35  */
36 
37 #include <stdio.h>
38 #include <string.h>
39 
40 #include "genC.h"
41 #include "linear.h"
42 #include "ri.h"
43 #include "effects.h"
44 #include "ri-util.h"
45 #include "prettyprint.h" // for sc_syst_debug()
46 #include "effects-util.h"
47 #include "misc.h"
48 
49 #include "transformer.h"
50 #include "effects-generic.h"
51 #include "effects-convex.h"
52 
53 list
55 {
57  return l_reg;
58 }
59 
60 list
62 {
64  return l_reg;
65 }
66 
68 {
69  list l_res = NIL;
71 
72  pips_assert("sc is weakly consistent", sc_weak_consistent_p(sc_context));
73  ifdebug(8) {
74  pips_debug(8, "context: \n");
75  sc_syst_debug(sc_context);
76  }
77 
78  FOREACH(EFFECT, reg, l_reg) {
79  /* Only the store effects require preconditions */
80  if(store_effect_p(reg)) {
81  /* FI: this leads to problems when the context might become
82  * later empty: there won't be any way to find out; in one
83  * case I do not remember, the IN regions end up wrong;
84  * however, adding descriptors for all scalar references may
85  * slow down the region computation a lot. */
86  /* NL: To have good (IN/) OUT-Regions for (loop/) loop body in presence of scalar,
87  * We have to add the the context (loop bounds) for the regions too.
88  * To make a compromise between performance and requirement,
89  * add variable on_scalar_p
90  */
91  if (on_scalar_p || !effect_scalar_p(reg) )
92  {
93  descriptor reg_d = effect_descriptor(reg);
94  Psysteme reg_sc = descriptor_convex_p(reg_d)? descriptor_convex(reg_d) : NULL;
95 
96  pips_assert("sc_context is weakly consistent", sc_weak_consistent_p(sc_context));
97  pips_assert("reg_sc is weakly consistent (1)", sc_weak_consistent_p(reg_sc));
98  region_sc_append(reg, sc_context, false);
99 
100  /* remove potential old values that may be found in precondition */
101  list l_old_values = NIL;
102  reg_sc = region_system(reg);
103  for(Pbase b = sc_base(reg_sc); !BASE_NULLE_P(b); b = vecteur_succ(b)) {
104  entity e = (entity) vecteur_var(b);
105  if(global_old_value_p(e)) {
106  l_old_values = CONS(ENTITY, e, l_old_values);
107  }
108  }
109  region_exact_projection_along_parameters(reg, l_old_values);
110  reg_sc = region_system(reg);
111  gen_free_list(l_old_values);
113  pips_debug_effect(8, "region after transformation: \n", reg );
114 
115  pips_assert("sc_context is weakly consistent", sc_weak_consistent_p(sc_context));
116  pips_assert("reg_sc is weakly consistent (2)", sc_weak_consistent_p(reg_sc));
117  }
118 
119  if (!region_empty_p(reg))
120  l_res = CONS(EFFECT, reg, l_res);
121  }
122  }
123 
124  return l_res;
125 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
void sc_syst_debug(Psysteme s)
constraint_to_text.c
#define debug_region_consistency(reg)
#define region_system(reg)
#define region_empty_p(reg)
void project_regions_with_transformer(list, transformer, list)
void region_sc_append(effect, Psysteme, bool)
void project_regions_with_transformer_inverse(list, transformer, list)
void region_exact_projection_along_parameters(effect, list)
list convex_regions_precondition_compose(list, transformer, bool)
list convex_regions_transformer_compose(list, transformer)
compose.c
list convex_regions_inverse_transformer_compose(list, transformer)
#define pips_debug_effect(level, message, eff)
for debug
bool store_effect_p(effect)
Definition: effects.c:1062
bool effect_scalar_p(effect)
Definition: effects.c:567
#define descriptor_convex_p(x)
Definition: effects.h:599
#define effect_descriptor(x)
Definition: effects.h:646
#define descriptor_convex(x)
Definition: effects.h:601
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#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
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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define transformer_relation(x)
Definition: ri.h:2873
#define predicate_system(x)
Definition: ri.h:2069
bool sc_weak_consistent_p(Psysteme sc)
check that sc is well defined, that the numbers of equalities and inequalities are consistent with th...
Definition: sc.c:362
#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: delay.c:253
bool global_old_value_p(entity)
Return true if an entity is a global old value (such as "i#init"...).
Definition: value.c:690
#define vecteur_var(v)
#define vecteur_succ(v)
#define BASE_NULLE_P(b)