PIPS
code_generation.c
Go to the documentation of this file.
1 /*
2 
3  $Id: code_generation.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 hyperplane
28  */
29 
30 #include <stdio.h>
31 /* #include <sys/stdtypes.h> */ /* for debug with dbmalloc */
32 /* #include "stdlib.h" */
33 
34 #include "genC.h"
35 #include "linear.h"
36 #include "ri.h"
37 
38 #include "ri-util.h"
39 #include "conversion.h"
40 
41 #include "hyperplane.h"
42 
43 /* statement code_generation(cons *lls,Pvecteur pvg[], Pbase base_oldindex,
44  * Pbase base_newindex)
45  * generation of hyperplane code for the nested loops (cons *lls).
46  * the new nested loops will be ;
47  * DOSEQ Ip = ...
48  * DOALL Jp = ...
49  * DOALL Kp = ...
50  * ...
51  * ENDDO
52  *
53  * modification : Keep the code in the sequential version. Let the
54  * parallelisation to generate the parallel code. suggested by BB,
55  * modified by Yi-Qing. 17/05/92
56  *
57  */
59  Pvecteur pvg[],
60  Pbase base_oldindex,
61  Pbase base_newindex,
63  bool preserve_entry_label_p)
64 {
65  statement state_lhyp = statement_undefined;
67  loop l_hyp = loop_undefined;
73  Pbase pb = BASE_UNDEFINED;
74 
76  statement_newbase(bl,pvg,base_oldindex);
77  /* make the parallel loops from inner loop to outermost loop*/
78 
79  for(pb=base_reversal(base_newindex);lls!=NIL; lls=CDR(lls), pb = pb->succ) {
80  /* handling of current loop */
81  s_loop = STATEMENT(CAR(lls));
82 
83  /* new bounds for new index related to the old index of the old loop*/
84  make_bound_expression(pb->var, base_newindex,sc_newbase, &lower, &upper);
85  rl = make_range(lower, upper, int_to_expression(1));
86 
87  /*
88  loop l_old = loop_undefined;
89  l_old = instruction_loop(statement_instruction(s_loop));
90  l_hyp = make_loop((entity) pb->var,
91  rl,
92  bl,
93  loop_label(l_old),
94  make_execution(is_execution_sequential,UU),
95  loop_locals(l_old));
96  */
97 
98  /* FI: I do not understand how you could keep a go to target (!)
99  * or a list of local variables
100  */
101  l_hyp = make_loop((entity) pb->var,
102  rl,
103  bl,
106  NIL);
107 
108  bl = makeloopbody(l_hyp, s_loop, true);
109  }
110 
111  instr_lhyp = make_instruction(is_instruction_loop,l_hyp);
112  state_lhyp = copy_statement(s_loop);
113  if(!preserve_entry_label_p)
114  clear_label(state_lhyp);
116  statement_instruction(state_lhyp) = instr_lhyp;
117  return(state_lhyp);
118 }
119 
120 
121 
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void free_instruction(instruction p)
Definition: ri.c:1118
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
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
void statement_newbase(statement s, pvg, Pbase base_oldindex)
statement_newbase(statement s, Pvecteur pvg[], Pbase base_oldindex) compute the new statement by perf...
statement code_generation(list lls, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex, Psysteme sc_newbase, bool preserve_entry_label_p)
package hyperplane
#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
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
statement makeloopbody(loop, statement, bool)
statement makeloopbody(l, s_old) make a statement for a loop body, using the fields of a previously e...
Definition: statement.c:1641
void clear_label(statement)
Definition: statement.c:1568
Psysteme sc_newbase
include <sys/ddi.h>
#define UU
Definition: newgen_types.h:98
void make_bound_expression(Variable index, Pbase base, Psysteme sc, expression *lower, expression *upper)
void make_bound_expression(variable index, Pbase base, Psysteme sc, expression *lower,...
entity entity_empty_label(void)
Definition: entity.c:1105
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 loop_body(x)
Definition: ri.h:1644
#define loop_undefined
Definition: ri.h:1612
#define instruction_loop(x)
Definition: ri.h:1520
#define range_undefined
Definition: ri.h:2263
#define instruction_undefined
Definition: ri.h:1454
#define expression_undefined
Definition: ri.h:1223
@ is_instruction_loop
Definition: ri.h:1471
#define statement_instruction(x)
Definition: ri.h:2458
@ is_execution_sequential
Definition: ri.h:1189
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define BASE_UNDEFINED