PIPS
find_iteration_domain.c
Go to the documentation of this file.
1 /*
2 
3  $Id: find_iteration_domain.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  /* Code Generation for Distributed Memory Machines
28  *
29  * Build the iteration domain and the basis associated to a loop nest
30  *
31  * File: find_iteration_domain.c
32  *
33  * PUMA, ESPRIT contract 2701
34  * Corinne Ancourt
35  * 1994
36  */
37 
38 #include <stdio.h>
39 
40 #include "genC.h"
41 
42 #include "linear.h"
43 
44 #include "ri.h"
45 #include "effects.h"
46 #include "dg.h"
49 #include "graph.h"
50 
51 #include "matrice.h"
52 #include "tiling.h"
53 #include "database.h"
54 #include "text.h"
55 
56 #include "misc.h"
57 #include "text-util.h"
58 #include "ri-util.h"
59 #include "effects-util.h"
60 #include "resources.h"
61 
62 #include "constants.h"
63 #include "conversion.h"
64 #include "wp65.h"
65 
66 void find_iteration_domain(s, sc, basis, nested_level,
67  list_statement_block, inst)
68 statement s;
69 Psysteme *sc;
70 Pbase *basis;
71 int * nested_level ;
72 list *list_statement_block;
73 instruction * inst;
74 {
75  list list_loop_statement=NIL;
76 
77  debug(8, "find_iteration_domain", "begin\n");
78  iteration_domain_from_statement(&list_loop_statement,s,
79  nested_level,
80  list_statement_block,inst);
81  compute_iteration_domain(list_loop_statement,sc,basis);
82  ifdebug(8) {
83  (void) fprintf(stderr,"[find_iteration_domain] initial basis \n");
84  vect_fprint(stderr,*basis,(string(*)(void*))entity_local_name);
85  sc_fprint(stderr,*sc,(string(*)(void*))entity_local_name);
86  }
87  debug(8, "find_iteration_domain", "end\n");
88 }
89 
90 
91 
92 void compute_iteration_domain(list_loop_statement,sc,basis)
93 list list_loop_statement;
94 Psysteme *sc;
95 Pbase *basis;
96 {
97 
98  Psysteme sci;
99  Pbase base_index = BASE_NULLE;
100 
101  /* computation of the list of loop indices base_index
102  and of the iteration domain sci*/
103 
104  debug(8,"compute_iteration_domain","begin\n");
105 
106  sci = loop_iteration_domaine_to_sc(list_loop_statement, &base_index);
107  sci->base = base_reversal(sci->base);
108  ifdebug(8) { (void) fprintf(stderr,"compute_iteration_domain\n");
109  vect_fprint(stderr,base_index,(string(*)(void*))entity_local_name);
110  }
111  *sc = sci;
112  *basis = base_index;
113  debug(8,"compute_iteration_domain","end\n");
114 }
115 ␌
116 void iteration_domain_from_statement(list_loop_statement, s,nested_level, blocks,inst)
117 list *list_loop_statement;
118 statement s;
119 int * nested_level;
120 list *blocks;
121 instruction *inst;
122 {
123  instruction i;
124  cons *b;
125  loop l;
126  debug(8, "iteration_domain_from_statement", "begin\n");
127 
128  i = statement_instruction(s);
129  switch (instruction_tag(i)) {
130 
131  case is_instruction_loop:
132  l = instruction_loop(i);
133  *list_loop_statement = CONS (STATEMENT,s,*list_loop_statement);
134  iteration_domain_from_statement(list_loop_statement,loop_body(l),
135  nested_level,
136  blocks,inst);
137  break;
138 
139  case is_instruction_block: {
140  int nbl = 0;
141  bool simple_block = false;
142  b= instruction_block(i);
143  nbl = gen_length((list) b);
144  simple_block = (nbl==1
145  || (nbl ==2 && continue_statement_p(STATEMENT(CAR(CDR(b))))))
146  ? true : false;
147 
148  if (simple_block && instruction_loop_p(statement_instruction(STATEMENT(CAR(b)))))
149  iteration_domain_from_statement(list_loop_statement,
150  STATEMENT(CAR(b))
151  ,nested_level, blocks,inst);
152  else {
153  *nested_level = gen_length(*list_loop_statement);
154  *inst = i;
155  *blocks = b;
156  }
157 
158  break;
159  }
160  case is_instruction_call: {
161  /* case where there is a unique assignment in do-enddo loop nest*/
162  *nested_level = gen_length(*list_loop_statement);
164  *blocks =CONS(STATEMENT,s,NIL);
165  return;
166  }
167 
168  case is_instruction_test:
169  return;
170 
172  return;
173 
174  case is_instruction_goto:
175  pips_internal_error("unexpected goto in code");
176  default:
177  pips_internal_error("unexpected tag");
178  }
179 
180  debug(8, "search_array_from_statement", "end\n");
181 }
Pbase base_reversal(Pbase b_in)
Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in,...
Definition: base.c:221
static list blocks
lisp of loops
Psysteme loop_iteration_domaine_to_sc(list, Pbase *)
loop_iteration_domaine_to_sc.c
void compute_iteration_domain(list list_loop_statement, Psysteme *sc, Pbase *basis)
void iteration_domain_from_statement(list *list_loop_statement, statement s, int *nested_level, list *blocks, instruction *inst)
dg_vertex_label vertex_label
void find_iteration_domain(statement s, Psysteme *sc, Pbase *basis, nested_level, list *list_statement_block, instruction *inst)
dg_arc_label arc_label
Code Generation for Distributed Memory Machines.
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#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
#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
bool continue_statement_p(statement)
Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
Definition: statement.c:203
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
#define pips_internal_error
Definition: misc-local.h:149
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define true
Definition: newgen_types.h:81
#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 instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ 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 statement_instruction(x)
Definition: ri.h:2458
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
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 ...
#define ifdebug(n)
Definition: sg.c:47
Pbase base
Definition: sc-local.h:75
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
#define BASE_NULLE
MACROS SUR LES BASES.