PIPS
contexts.c
Go to the documentation of this file.
1 /*
2 
3  $Id: contexts.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 #include <stdio.h>
28 
29 #include "linear.h"
30 
31 #include "genC.h"
32 #include "ri.h"
33 #include "effects.h"
34 
35 #include "misc.h"
36 
37 #include "ri-util.h"
38 #include "effects-util.h"
39 
41 statement stat;
42 {
43  loop il = statement_loop(stat);
44  Psysteme cil = sc_new();
45  entity i = loop_index(il);
46  range r = loop_range(il);
47  expression lb = range_lower(r), ub = range_upper(r);
48  normalized nl, nu;
49  int inc;
50 
51 
52 
53  nl = NORMALIZE_EXPRESSION(lb);
54  nu = NORMALIZE_EXPRESSION(ub);
55 
56  if ((inc = loop_increment_value(il)) == 0) {/* it isn't constant. ignore
57  this context */
58  return(cil);
59  }
60  else {
61  if (inc < 0) {
62  normalized n = nl;
63  nl = nu;
64  nu = n;
65  }
66 
67  if (normalized_linear_p(nl)) {
68 
69  Pvecteur pv, pv1;
70  Pcontrainte pc;
71 
72  pv = (Pvecteur) normalized_linear(nl);
73  pv1 = vect_dup(pv); /* par yy */
74  vect_add_elem(&pv1, (Variable) i, -1);
75  pc = contrainte_make(pv1);
76  sc_add_ineg(cil, pc);
77  }
78 
79  if (normalized_linear_p(nu)) {
80 
81  Pvecteur pv, pv1;
82  Pcontrainte pc;
83 
84  pv = (Pvecteur) normalized_linear(nu);
85  pv1 = vect_dup(pv); /* par yy */
86  (void) vect_multiply(pv1, -1);
87  vect_add_elem(&pv1, (Variable) i, 1);
88  pc = contrainte_make(pv1);
89  sc_add_ineg(cil, pc);
90  }
91 
92  ifdebug(5) {
93  fprintf(stderr, "Execution context of loop %td is:\n",
94  statement_number(stat));
96  }
97 
98  return(cil);
99  }
100 }
101 
102 ␌
103 
104 
105 static void contexts_mapping_of_statement(m, c, s)
107 Psysteme c;
108 statement s;
109 {
111 
112  SET_STATEMENT_MAPPING(m, s, c);
113 
114  switch(instruction_tag(i)) {
115 
117  MAPL(ps, {
119  }, instruction_block(i));
120  break;
121 
122  case is_instruction_loop: {
124 
126  sc_intersection(nc, nc, c),
128  break;
129  }
130 
131  /* The next two cases are added for the dependence test
132  include IF (by Yi-Qing 12/92)*/
133  case is_instruction_test: {
136  break;
137  }
138 
141  cons *blocs = NIL ;
142 
143  CONTROL_MAP(ct, {
145  }, unstructured_control(u), blocs);
146 
147  gen_free_list( blocs );
148  break;
149  }
151  case is_instruction_call:
152  case is_instruction_goto:
153  break;
154 
155  default:
156  pips_internal_error("unexpected tag %d", instruction_tag(i));
157  }
158 }
159 
160 ␌
161 
163 statement stat;
164 {
165  statement_mapping contexts_map;
166 
167  pips_assert("contexts_mapping_of_nest", statement_loop_p(stat));
168 
169  contexts_map = MAKE_STATEMENT_MAPPING();
170 
171  contexts_mapping_of_statement(contexts_map, NULL, stat);
172 
173  ifdebug(8) {
175  statement stp = (statement) st;
176 
177  if (statement_call_p(stp)) {
178  fprintf(stderr, "Execution context of statement %td :\n",
179  statement_number(stp));
181  }
182  }, contexts_map);
183  }
184 
185  return(contexts_map);
186 }
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
statement_mapping contexts_mapping_of_nest(statement stat)
contexts.c
Definition: contexts.c:162
static Psysteme make_context_of_loop(statement stat)
Definition: contexts.c:40
static void contexts_mapping_of_statement(statement_mapping m, Psysteme c, statement s)
Definition: contexts.c:105
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
int loop_increment_value(loop l)
Definition: loop.c:714
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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 MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_call_p(statement)
Definition: statement.c:364
bool statement_loop_p(statement)
Definition: statement.c:349
#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 SET_STATEMENT_MAPPING(map, stat, val)
Definition: newgen-local.h:47
#define MAKE_STATEMENT_MAPPING()
Definition: newgen-local.h:43
#define STATEMENT_MAPPING_MAP(s, v, code, h)
Definition: newgen-local.h:53
#define NORMALIZE_EXPRESSION(e)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
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
#define loop_body(x)
Definition: ri.h:1644
#define normalized_linear_p(x)
Definition: ri.h:1779
#define range_upper(x)
Definition: ri.h:2290
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define statement_number(x)
Definition: ri.h:2452
#define normalized_linear(x)
Definition: ri.h:1781
#define instruction_unstructured(x)
Definition: ri.h:1532
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
Psysteme sc_intersection(Psysteme s1, Psysteme s2, Psysteme s3)
Psysteme sc_intersection(Psysteme s1, Psysteme s2, Psysteme s3): calcul d'un systeme de contraintes s...
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
#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
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
struct Svecteur * Pvecteur
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
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72