PIPS
overlap.c
Go to the documentation of this file.
1 /*
2 
3  $Id: overlap.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 /* Overlap Management Module for HPFC
28  * Fabien Coelho, August 1993
29  */
30 
31 #include "defines-local.h"
32 bool expression_constant_p(expression); /* in static_controlize */
33 
34 GENERIC_GLOBAL_FUNCTION(overlap_status, overlapsmap)
35 
36 static void create_overlaps(e)
37 entity e;
38 {
39  type t = entity_type(e);
40  list o=NIL;
41  int n;
42 
44 
46  for(; n>=1; n--) o = CONS(OVERLAP, make_overlap(0, 0), o);
47 
49 
51 }
52 
53 /* set_overlap(ent, dim, side, width)
54  *
55  * set the overlap value for entity ent, on dimension dim,
56  * dans side side to width, which must be a positive integer.
57  * if necessary, the overlap is updates with the value width.
58  */
59 void set_overlap(ent, dim, side, width)
60 entity ent;
61 int dim, side, width;
62 {
63  overlap o;
64  int current;
65 
66  assert(dim>0);
67 
69  o = OVERLAP(gen_nth(dim-1, load_overlap_status(ent)));
70 
71  if (side) /* upper */
72  {
74  if (current<width) overlap_upper(o)=width;
75  }
76  else /* lower */
77  {
79  if (current<width) overlap_lower(o)=width;
80  }
81 }
82 
83 /* int get_overlap(ent, dim, side)
84  *
85  * returns the overlap for a given entity, dimension and side,
86  * to be used in the declaration modifications
87  */
88 int get_overlap(ent, dim, side)
89 entity ent;
90 int dim, side;
91 {
92  overlap o;
93 
94  assert(dim>0);
95 
98 
99  o = OVERLAP(gen_nth(dim-1, load_overlap_status(ent)));
100  return(side ? overlap_upper(o) : overlap_lower(o));
101 }
102 
103 /* static void overlap_redefine_expression(pexpr, ov)
104  *
105  * redefine the bound given the overlap which is to be included
106  */
107 static void overlap_redefine_expression(pexpr, ov)
108 expression *pexpr;
109 int ov;
110 {
111  expression
112  copy = *pexpr;
113 
114  if (expression_constant_p(*pexpr))
115  {
116  *pexpr = int_to_expression(HpfcExpressionToInt(*pexpr)+ov);
117  free_expression(copy); /* this avoid a memory leak */
118  }
119  else
122  *pexpr,
123  int_to_expression(ov));
124 }
125 
127 list l;
128 {
129  entity ent;
130  int ndim, i, lower_overlap, upper_overlap;
131  dimension the_dim;
132 
133  MAP(ENTITY, oldent,
134  {
135  ent = load_new_node(oldent);
136  ndim = variable_entity_dimension(ent);
137 
139 
140  for (i=1 ; i<=ndim ; i++)
141  {
142  the_dim = entity_ith_dimension(ent, i);
143  lower_overlap = get_overlap(oldent, i, 0);
144  upper_overlap = get_overlap(oldent, i, 1);
145 
146  debug(8, "declaration_with_overlaps",
147  "%s(DIM=%d): -%d, +%d\n",
148  entity_name(ent), i, lower_overlap, upper_overlap);
149 
150  if (lower_overlap!=0)
152  -lower_overlap);
153 
154  if (upper_overlap!=0)
156  upper_overlap);
157  }
158  },
159  l);
160 }
161 
162 /* updates overlaps for similar arrays that are going to be merged
163  */
164 static void deal_with_similars(list le)
165 {
166  FOREACH(ENTITY, array, le)
167  {
168  //if (entity_dynamic_p(array) && load_similar_mapping(array)!=array)
170  {
172  int dim;
173 
174  pips_debug(8, "translating overlaps from %s to %s\n",
175  entity_name(array), entity_name(sim));
176 
177  for (dim=variable_entity_dimension(array); dim>0; dim--)
178  {
179  int o;
180 
181  o = get_overlap(array, dim, 0);
182  set_overlap(sim, dim, 0, o);
183  o = get_overlap(array, dim, 1);
184  set_overlap(sim, dim, 1, o);
185  }
186  }
187  }
188 }
189 
191 entity module;
192 {
194 
197  gen_free_list(l);
198 }
199 
200 /* That is all
201  */
overlap make_overlap(intptr_t a1, intptr_t a2)
Definition: hpf_private.c:740
void free_expression(expression p)
Definition: ri.c:853
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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
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
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#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
#define OVERLAP(x)
OVERLAP.
Definition: hpf_private.h:826
#define overlap_lower(x)
Definition: hpf_private.h:856
#define overlap_upper(x)
Definition: hpf_private.h:858
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569
list list_of_distributed_arrays_for_module(entity module)
returns the list of entities that are 'local' to module
Definition: declarations.c:72
entity load_similar_mapping(entity)
entity load_new_node(entity)
list load_overlap_status(entity)
void store_overlap_status(entity, list)
bool bound_overlap_status_p(entity)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define assert(ex)
Definition: newgen_assert.h:41
#define GENERIC_GLOBAL_FUNCTION(name, type)
bool expression_constant_p(expression)
Overlap Management Module for HPFC Fabien Coelho, August 1993.
Definition: expression.c:2453
static void declaration_with_overlaps(list l)
Definition: overlap.c:126
int get_overlap(entity ent, int dim, int side)
int get_overlap(ent, dim, side)
Definition: overlap.c:88
static void deal_with_similars(list le)
updates overlaps for similar arrays that are going to be merged
Definition: overlap.c:164
static void overlap_redefine_expression(expression *pexpr, int ov)
static void overlap_redefine_expression(pexpr, ov)
Definition: overlap.c:107
static void create_overlaps(entity e)
in static_controlize
Definition: overlap.c:36
void declaration_with_overlaps_for_module(entity module)
Definition: overlap.c:190
void set_overlap(entity ent, int dim, int side, int width)
set_overlap(ent, dim, side, width)
Definition: overlap.c:59
static char * module
Definition: pips.c:74
#define PLUS_OPERATOR_NAME
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
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
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
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
bool variable_dynamic_p(entity)
Definition: variable.c:1586
int variable_entity_dimension(entity)
variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.
Definition: variable.c:1293
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define entity_name(x)
Definition: ri.h:2790
#define dimension_upper(x)
Definition: ri.h:982
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947
static entity array
static size_t current
Definition: string.c:115
The structure used to build lists in NewGen.
Definition: newgen_list.h:41