PIPS
delay.c
Go to the documentation of this file.
1 /*
2 
3  $Id: delay.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 /* Name : delay.c
29  * Package : reindexing
30  * Author : Alexis Platonoff
31  * Date : March 1995
32  * Historic :
33  *
34  * Documents: SOON
35  * Comments : This file contains the functions dealing with the dealy.
36  */
37 
38 /* Ansi includes */
39 #include <stdio.h>
40 
41 /* Newgen includes */
42 #include "genC.h"
43 
44 /* C3 includes */
45 #include "boolean.h"
46 #include "arithmetique.h"
47 #include "vecteur.h"
48 #include "contrainte.h"
49 #include "ray_dte.h"
50 #include "sommet.h"
51 #include "sg.h"
52 #include "sc.h"
53 #include "polyedre.h"
54 #include "union.h"
55 #include "matrice.h"
56 #include "matrix.h"
57 #include "sparse_sc.h"
58 
59 /* Pips includes */
60 #include "boolean.h"
61 #include "ri.h"
62 #include "constants.h"
63 #include "ri-util.h"
64 #include "misc.h"
65 #include "complexity_ri.h"
66 #include "database.h"
67 #include "graph.h"
68 #include "dg.h"
69 #include "paf_ri.h"
70 #include "parser_private.h"
71 #include "property.h"
72 #include "reduction.h"
73 #include "text.h"
74 #include "text-util.h"
75 #include "tiling.h"
76 #include "text-util.h"
77 #include "pipsdbm.h"
78 #include "resources.h"
79 #include "static_controlize.h"
80 #include "paf-util.h"
81 #include "pip.h"
82 #include "array_dfg.h"
83 #include "prgm_mapping.h"
84 #include "conversion.h"
85 #include "scheduling.h"
86 #include "reindexing.h"
87 
88 /* External variables */
89 extern hash_table delay_table;
90 
91 /* Local defines */
94 
95 
96 /*=======================================================================*/
97 /* void rewrite_nothing(chunk *) {return;}: rewrite nothing,
98  * incredible,no?
99  *
100  * AC 94/07/25
101  * could use gen_null instead. FC.
102  */
103 
104 static void rewrite_nothing_call(call c) {return;}
105 static void rewrite_nothing_ref(reference r) {return;}
106 
107 
108 /*=======================================================================*/
109 /* bool reference_filter(r): filter on the reference r.
110  *
111  * AC 94/07/28
112  */
113 
114 static bool reference_filter(r)
115 reference r;
116 {
117  entity e = reference_variable(r);
118  list lexp = NIL, lexp2 = NIL;
119  int n, d;
120  expression exp, exp2;
121  call ca;
122 
123  /* first we get the number of the instruction */
124  n = get_number_of_ins(e);
125 
126  /* get the delay in the hash table */
127  d = (int)hash_get(delay_table, (char *)n);
128 
129  if (get_debug_level() > 6) {
130  fprintf(stderr,"\nOld ref : ");
131  print_reference(r);
132  fprintf(stderr, "\n n = %d", n);
133  fprintf(stderr, "\n d = %d", d);
134  }
135 
136  /* process the instruction only if the reference is an array. */
137  if(reference_indices(r) != NIL) {
138  if ((d > 0) && (d != INFINITY)) {
140  lexp = CDR(reference_indices(r));
141  /* build the modulo expression */
142  lexp2 = CONS(EXPRESSION, int_to_expression(d+1), NIL);
143  lexp2 = CONS(EXPRESSION, exp, lexp2);
147  reference_indices(r) = CONS(EXPRESSION, exp2, lexp);
148  }
149  else if (d == 0) {
150  lexp = CDR(reference_indices(r));
151  exp = int_to_expression(0);
153  }
154  }
155  if (get_debug_level() > 6) {
156  fprintf(stderr,"\nNew ref : ");
157  print_reference(r);}
158 
159  return(false);
160 }
161 
162 /*=======================================================================*/
163 /* bool assignation_filter(c): tests if the call is an assignation. This
164  * is the filter of the function gen_recurse(). In case of a call we do not
165  * want to go down so the bool is always set to false. We test too if
166  * the assignation is an instruction and in that case, we treat each
167  * reference by calling the function gen_recurse again.
168  *
169  * AC 94/07/25
170  */
171 
172 static bool assignation_filter(c)
173 call c;
174 {
175  list lexp;
176  expression exp;
177 
179  {
180  lexp = call_arguments(c);
181  exp = EXPRESSION(CAR(lexp));
182 
183  /* first, test if the expression is an array that is an instruction */
184  if (array_ref_exp_p(exp))
187  }
188 
189  return(false);
190 }
191 
192 /*=======================================================================*/
193 /* list add_delay_information(t, sl): go through the list of new statement
194  * and replace each first time dimension by its expression modulo the value
195  * of the delay.
196  *
197  * AC 94/07/06
198  */
199 
201 
202  hash_table t;
203  list sl;
204 {
205  instruction ins;
206 
207  ins = make_instruction_block(sl);
208 
210 
211  return(instruction_block(ins));
212 }
213 
214 
215 /*=======================================================================*/
216 /* void fprint_delay(fp, t): print the hash_table t
217  *
218  * AC 94/07/01
219  */
220 
221 void fprint_delay(fp, g, t)
222 FILE *fp;
223 graph g;
224 hash_table t;
225 {
226  list vl;
227 
228  for (vl = graph_vertices(g); !ENDP(vl); POP(vl)) {
229  int cn, del;
230  vertex cv;
231 
232  cv = VERTEX(CAR(vl));
234  del = (int)hash_get(delay_table, (char *)cn);
235  fprintf(fp,"\nInstruction n. %d \t=> delai = %d", cn, del);
236  }
237 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
dg_vertex_label vertex_label
Definition: delay.c:64
dg_arc_label arc_label
Definition: delay.c:63
void const char const char const int
static list lexp
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
#define vertex_vertex_label(x)
Definition: graph.h:152
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#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
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
#define dfg_vertex_label_statement(x)
Definition: paf_ri.h:413
void print_reference(reference r)
Definition: expression.c:142
#define INFINITY
define INFINITY 2147483647
static bool assignation_filter(call c)
======================================================================
Definition: delay.c:172
static void rewrite_nothing_ref(reference r)
Definition: delay.c:105
static void rewrite_nothing_call(call c)
======================================================================
Definition: delay.c:104
static bool reference_filter(reference r)
======================================================================
Definition: delay.c:114
hash_table delay_table
Name : delay.c Package : reindexing Author : Alexis Platonoff Date : March 1995 Historic :
Definition: reindexing.c:109
void fprint_delay(FILE *fp, graph g, hash_table t)
======================================================================
Definition: delay.c:221
list add_delay_information(hash_table t, list sl)
======================================================================
Definition: delay.c:200
int get_number_of_ins(entity e)
======================================================================
Definition: reindexing.c:638
bool array_ref_exp_p(expression e)
======================================================================
#define ENTITY_ASSIGN_P(e)
#define instruction_block(i)
#define MODULO_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
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
#define normalized_undefined
Definition: ri.h:1745
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
@ is_syntax_call
Definition: ri.h:2693
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define reference_indices(x)
Definition: ri.h:2328
#define call_arguments(x)
Definition: ri.h:711
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207