PIPS
adg_read_paf.c
Go to the documentation of this file.
1 /*
2 
3  $Id: adg_read_paf.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 : adg_read_paf.c
29  * Package : paf-util
30  * Author : Alexis Platonoff
31  * Date : april 1993
32  * Historic : 16 july 93, changes in paf_ri, AP
33  * 2 august 93, moved from (package) array_dfg to paf-util, AP
34  * Documents:
35  *
36  * Comments :
37  * This functions are used to store a data flow graph in a NEWGEN structure
38  * from the reading of three files generate by the PAF parallelizer:
39  *
40  * _ the ".src" file, which contains the DFG nodes
41  * _ the ".do" file, which contains the LOOP list
42  * _ the ".gd" file, which contains the DG nodes
43  *
44  * The DFG nodes include the source and sink instructions, the reference, the
45  * transformation and the governing predicate. The LOOP list gives the
46  * description of each loop of the program, i.e. the index parameter, the lower
47  * and upper bounds expressions and the step expression. The DG nodes give for
48  * each instruction, the list of the englobing loops. From the loop description
49  * and the list of the englobing loops, we can compute for each instruction the
50  * execution domain.
51  *
52  * This program uses two new NEWGEN data structures: "dfg" (which uses the
53  * generic graph structure) and "lisp_expression". They are defined in the
54  * file paf_ri.f.tex (see comments on them in this file). It also uses the
55  * library of PIPS and its RI data structure.
56  *
57  * The PAF files are read with YACC and LEX programs. We made one grammar for
58  * the three types of files (parse.y) and one characters analyser (scan.l).
59  * The "yy" and "YY" prefixes are modified into "adgyy" and "ADGYY".
60  *
61  * In order two simplify the parser, this parsing requires the concatenation of
62  * the three files in one with the extension ".paf". This concatenation must
63  * be like this (see the file parse.y for the grammar):
64  * ( .src ) ( .do ) ( .gd )
65  *
66  * Thus, the parsing has three steps:
67  *
68  * First, the ".src" file is parsed. During this reading we collect the
69  * informations for the DFG. All these informations are stored in the global
70  * variables "dfg".
71  *
72  * Second, we read the ".do" file. All the loops and their description are
73  * stored in the global variables "loop_list". This variable is a list of
74  * "loop" (from the NEWGEN type defined in the RI of PIPS).
75  *
76  * Third, we parse the ".gd" file. In this reading, we only keep the englobing
77  * loops of each instruction. The update of the DFG execution domain is done
78  * during the parsing (each time all the englobing loops for a given
79  * instruction are known).
80  */
81 
82 /* Ansi includes */
83 #include <stdio.h>
84 #include <string.h>
85 #include <limits.h>
86 #include <stdlib.h>
87 
88 /* Newgen includes */
89 #include "genC.h"
90 
91 /* C3 includes */
92 #include "boolean.h"
93 #include "arithmetique.h"
94 #include "vecteur.h"
95 #include "contrainte.h"
96 #include "ray_dte.h"
97 #include "sommet.h"
98 #include "sg.h"
99 #include "sc.h"
100 #include "polyedre.h"
101 #include "matrice.h"
102 #include "matrix.h"
103 
104 /* Pips includes */
105 #include "boolean.h"
106 #include "linear.h"
107 #include "ri.h"
108 #include "constants.h"
109 #include "ri-util.h"
110 #include "misc.h"
111 /* Types arc_label and vertex_label must be defined although they are
112  not used */
113 /*
114 typedef void * arc_label;
115 typedef void * vertex_label;
116 */
117 /* Local typedef, probably to be found in paf_ri */
118 #include "paf_ri.h"
121 #include "graph.h"
122 #include "dg.h"
123 #include "misc.h"
124 /*#include "paf_ri.h"*/
125 #include "paf-util.h"
126 
127 /* Macro functions */
128 #define DOT "."
129 #define PAF_STRING "paf"
130 #define INS_NAME_LENGTH 4
131 #define STMT_TO_STCT_SIZE 100 /* hash table max size */
132 
133 
134 /* Global variables */
135 /* The "dfg" global variable is the current DFG being computed. Its type is
136  * defined in graph.h and paf_ri.h.
137  */
139 
140 /* The "stmt_list" global variable is the list the assign statement of the
141  * program (with all fields empty but two: ordering (the number of the
142  * statement) and comments (the string name of the statement)).
143  */
145 
146 /* The "loop_list" global variable is the list the loops of the program
147  * (with all their characteristics: index, bounds, step). The loop type is
148  * "loop" defined in ri.h.
149  */
151 
152 /* The "STS" global variable is the hash table that maps the
153  * static_control on the statements.
154  */
156 
157 
158 /* Internal variables */
159 static vertex crt_node; /* Current source node */
160 static int sink_stmt, /* Current sink statement */
161  source_stmt, /* Current source statement */
162  crt_stmt; /* Current stmt (an integer) */
163 static reference ref; /* Current reference */
164 static expression crt_exp; /* Current expression */
165 static predicate gov_pred, /* Current governing predicate */
166  exec_dom; /* Current execution domain */
167 static list crt_node_l, /* Current list of nodes */
168  trans_l, /* Current list of transformations */
169  ref_inds, /* Current list of reference indices */
170  lin_exp_l, /* Current list of linear expressions */
171  pred_l, /* Current list of predicates */
172  crt_el, /* Current list of englobing loops */
173  param_l; /* Current list of structure parameters */
174 static string crt_op_name; /* Current operator name */
175 static loop crt_loop; /* Current loop instruction */
176 
177 /* Local typedef */
178 /*
179 typedef dfg_arc_label arc_label;
180 typedef dfg_vertex_label vertex_label;
181 */
182 
183 /*============================================================================*/
184 /* void adg_read_paf(char * s) :
185  *
186  * computes the DFG of the PAF program name given in argument and returns
187  * it.
188  *
189  * The global variables "loop_list" and "stmt_list" are initialized to NIL.
190  *
191  * The DFG is put in the variable "dfg", which is the value returned.
192  *
193  * Note : This function creates a statement_mapping (i.e. a hash_table)
194  * which is initialized in this function. This is done by
195  * set_current_stco_map(), see paf-util/utils.c. To use this hash_table,
196  * you do not have to know its name, only call get_current_stco_map()
197  * which returns it. */
199 char * s;
200 {
201  extern list loop_list, stmt_list;
202 
203  FILE *paf_file;
204  char *paf_file_name;
205 
206  loop_list = NIL;
207  stmt_list = NIL;
208 
210 
211  paf_file_name = strdup(concatenate(s, DOT, PAF_STRING, (char *) NULL));
212 
213  if( (paf_file = fopen(paf_file_name, "r")) == NULL)
214  {
215  fprintf(stderr, "Cannot open file %s\n", paf_file_name);
216  exit(1);
217  }
218 
219 #if defined(HAS_ADGYY)
220 
221  adgyyin = paf_file;
222  (void) adgyyparse();
223 
224 #else
225 
226  pips_internal_error("not adgyy{in,parse} compiled in (HAS_ADGYY undef)");
227 
228 #endif
229 
230  fclose(paf_file);
231 
233 
234  return(dfg);
235 }
236 
237 
238 #define INIT_STATEMENT_SIZE 20
239 
240 /*============================================================================*/
241 /* void init_new_dfg() : initializes the computation of the DFG, i.e. the
242  * creation of the DFG in the "dfg" variable and the initialization of the
243  * global variables "exec_dom" and "gov_pred".
244  */
246 {
247  extern predicate exec_dom, gov_pred;
248  extern list param_l;
249 
250  dfg = make_graph(NIL); /* The list of vertices is empty at the beginning */
251 
252  param_l = NIL;
255 }
256 
257 
258 /*============================================================================*/
259 /* void new_param(s) : adds a new structure parameters to the global list
260  * "param_l".
261  */
262 void new_param(s)
263 string s;
264 {
265  extern list param_l;
266 
267  entity new_ent;
268  string param_full_name;
269 
271  s, (char *) NULL));
272 
273  new_ent = gen_find_tabulated(param_full_name, entity_domain);
274 
275  if(new_ent == entity_undefined)
276  /* Fi: UU is not a proper argument for make_basic_int() */
277  new_ent = make_entity(param_full_name,
279  make_variable(make_basic_int(4 /* UU */),
280  NIL, NIL)),
283 
284  param_l = CONS(ENTITY, new_ent, param_l);
285 }
286 
287 
288 /*============================================================================*/
289 /* void init_new_df_sink_ins(): initializes the computation of the sink
290  * statement of a datadflow. The structure of the file is such that all
291  * dependences with the same sink statement are grouped together. As our graph
292  * structure groups the dependences on the same source statement, we have to
293  * create a node for each dependence found for this sink statement. All these
294  * nodes are kept in "crt_node_l". The sink statement will be known when all
295  * these nodes will be computed, that's why they are kept in a special list.
296  */
298 {
299  crt_node_l = NIL;
300 
301  sink_stmt = -1;
304 }
305 
306 
307 /*============================================================================*/
308 /* static statement find_stmt_with_num(int n): returns the statement that has
309  * its ordering equal to "n".
310  *
311  * This computation is done using the global variable "stmt_list" that contains
312  * the list of all the statements.
313  */
315 int n;
316 {
317  extern list stmt_list;
318 
319  list aux_l = stmt_list;
320 
321  for(; aux_l != NIL; aux_l = CDR(aux_l))
322  {
323  statement aux_stmt = STATEMENT(CAR(aux_l));
324  int stmt_order = statement_ordering(aux_stmt);
325  if(stmt_order == n)
326  return(aux_stmt);
327  }
328  return(statement_undefined);
329 }
330 
331 
332 /*============================================================================*/
333 /* void init_new_df_source(char *s_ins): initializes the computation of
334  * the source statement of a datadflow. This statement is represented by its
335  * ordering contained in its name "s_ins". We initialize the list of
336  * transformations that will be associated with source statement ("trans_l").
337  * Also, we initialize "lin_exp_l" which is used for the parsing of the lisp
338  * expressions.
339  *
340  * Note: We don't forget to update the list of statements "stmt_list".
341  */
343 char * s_ins;
344 {
345  extern list trans_l, stmt_list;
346 
347  trans_l = NIL;
348 
349  /* In PAF, an statement name is a string "ins_#", where "#" is the number
350  * associated with the statement. We get this number.
351  */
352  source_stmt = atoi(strdup(s_ins + INS_NAME_LENGTH));
353 
354  /* We update the global list of statements */
359  NIL, // No local declarations
360  NULL, // null or empty string...
362  stmt_list);
363 
364 /* Initialization of global variables */
365  lin_exp_l = NIL;
366 }
367 
368 
369 /*============================================================================*/
370 /* void new_df_trans_exp(): The parser has now completed the reading of
371  * one transformation expression. We update "trans_l" and reinitialize
372  * "lin_exp_l" for the next expression.
373  */
375 {
377  pips_internal_error("current expression is undefined");
378 
381 
382 /* Initialization of global variables */
383  lin_exp_l = NIL;
384 }
385 
386 
387 /*============================================================================*/
388 /* void finish_new_df_source(): The reading of source of the current
389  * dataflow is completed. We create this dataflow, the successor to which it is
390  * attached and the node from which the dataflow comes. This node is put in the
391  * global list "crt_node_l" that contains all the computed edges that have
392  * the same sink statement (which is still not known).
393  *
394  * At this time of the computation, only the source statement and the list of
395  * transformations are known. The governing predicate will be added on all
396  * the node of "crt_node_l", as well as the reference and the execution
397  * domain will be computed afterwards, when all the graph will be made.
398  */
400 {
401  extern predicate exec_dom;
402 
403  successor source_succ;
404  list crt_df;
405 
408  source_succ = make_successor(make_dfg_arc_label(crt_df),
410 
413  CONS(SUCCESSOR, source_succ, NIL));
414 
416 }
417 
418 
419 /*============================================================================*/
420 /* void init_new_df_gov_pred(): Initializes the computation of the
421  * governing predicate.
422  *
423  * For this, we initialize "pred_l" (expressions that will be contained in the
424  * predicate) and "lin_exp_l" (for the parsing of each expression).
425  */
427 {
429  pred_l = NIL;
430  lin_exp_l = NIL;
431 }
432 
433 
434 /*============================================================================*/
435 /* void save_pred(int option): computes one expression of the predicate.
436  * Each expression is used twice ; indeed, an expression may be greater or
437  * equal than zero (>=) and smaller than zero (<). "option" says in which case
438  * we are: POSITIVE indicates that the predicate is >=, with NEGATIVE it is <.
439  * However, the C3 library always represents its inequalities with <=. So, the
440  * inequality "A >= 0" becomes "-A <= 0" and "A < 0" becomes "A + 1 <= 0".
441  *
442  * This function updates the global list "pred_l" that contains the current
443  * list of predicates. When a new predicate expression is parsed, the POSITIVE
444  * is always considered first (that is why only in that case we use "crt_exp").
445  * When the NEGATICE case is considered, the corresponding expression (used in
446  * the POSITIVE case) is the first expression of the list "pred_l". So, we only
447  * have to replace this expression by it equivalent for the NEGATIVE case (that
448  * is why the expression is multiplied by -1).
449  */
450 void save_pred(option)
451 int option;
452 {
453  expression aux_pred;
454 
455  if(option == POSITIVE)
456  {
458  pips_internal_error("current expression is undefined");
459 
460  /* "A >= 0" becomes "-A <= 0"*/
463  }
464  else
465  /* option == NEGATIVE */
466  {
467  /* "A < 0" becomes "A + 1 <= 0"*/
468  aux_pred = make_op_exp(PLUS_OPERATOR_NAME,
470  int_to_expression(1));
471 
472  pred_l = CONS(EXPRESSION, aux_pred, CDR(pred_l));
473  }
474 
475 /* Initialization of global variables */
476  lin_exp_l = NIL;
477 }
478 
479 
480 /*============================================================================*/
481 /* void elim_last_pred(): When POSITIVE and NEGATIVE cases of one predicate
482  * have been completed, we eliminate the corresponding expression which is the
483  * first one of the list "pred_l".
484  */
486 {
487  pred_l = CDR(pred_l);
488 }
489 
490 
491 /*============================================================================*/
492 /* void new_df_gov_pred(): the parser has found the all predicate of the
493  * dataflow of the current node, we have to compute it. This predicate is
494  * formed with the list of expressions of "pred_l". The function
495  * expressions_to_predicate() translates a list of expressions into a
496  * predicate.
497  */
499 {
500  dataflow df;
501 
503 
506 }
507 
508 
509 /*============================================================================*/
510 /* void init_new_df_ref(ichar *s_ref): the parser has gotten the name of
511  * the reference on which the current dataflow depends. We compute it and
512  * update the global variable "ref".
513  */
514 void init_new_df_ref(s_ref)
515 char * s_ref;
516 {
517  entity ent_ref;
518  string ref_full_name;
519 
520  ref_inds = NIL;
521 
523  s_ref, (char *) NULL));
524 
525  ent_ref = gen_find_tabulated(ref_full_name, entity_domain);
526 
527  if(ent_ref == entity_undefined)
528  ent_ref = make_entity(ref_full_name,
530  make_variable(make_basic_int(4 /* UU */),
531  NIL, NIL)),
534 
535  ref = make_reference(ent_ref, NIL);
536 
537 /* Initialization of global variables */
538  lin_exp_l = NIL;
539 }
540 
541 
542 /*============================================================================*/
543 /* void save_int(int i): The parser has found an integer as a part of a
544  * lisp expression. We save it in our global variable "lin_exp_l".
545  *
546  * If "lin_exp_l" is empty, then this integer becomes the current expression.
547  * If not, it becomes an argument of the first lisp expression of "lin_exp_l".
548  */
549 void save_int(i)
550 int i;
551 {
552  extern list lin_exp_l;
553  extern expression crt_exp;
554  expression aux_exp;
555 
556  aux_exp = int_to_expression(i);
557 
558  if(lin_exp_l == NIL)
559  crt_exp = aux_exp;
560  else
561  {
564  CONS(EXPRESSION, aux_exp, NIL));
565  }
566 }
567 
568 
569 /*============================================================================*/
570 /* void save_id(string s): The parser has found a variable as a part of a
571  * lisp expression. We save it in our global variable "lin_exp_l".
572  *
573  * If "lin_exp_l" is empty, then this variable becomes the current expression.
574  * If not, it becomes an argument of the first lisp expression of "lin_exp_l".
575  */
576 void save_id(s)
577 string s;
578 {
579  extern list lin_exp_l;
580  extern expression crt_exp;
581  expression aux_exp;
582 
583  aux_exp = make_id_expression(s);
584 
585  if(lin_exp_l == NIL)
586  crt_exp = aux_exp;
587  else
588  {
591  CONS(EXPRESSION, aux_exp, NIL));
592  }
593 }
594 
595 
596 /*============================================================================*/
597 /* void init_op_name(string op_name): this function initializes the global
598  * variable "crt_op_name". It gives the current operation that the parser is
599  * dealing with.
600  */
601 void init_op_name(op_name)
602 string op_name;
603 {
604  extern string crt_op_name;
605 
606  crt_op_name = op_name;
607 }
608 
609 
610 /*============================================================================*/
611 /* void init_op_exp(string op_name): initializes a new lisp expression with
612  * the operation "op_name". This expression is put at the beginning of
613  * "lin_exp_l", it is the expression the parser is currently reading.
614  *
615  * If "op_name" is the string "0" then the operator used is "crt_op_name", else
616  * the operator name is contained in "op_name".
617  */
618 void init_op_exp(op_name)
619 string op_name;
620 {
621  extern list lin_exp_l;
622 
623  lisp_expression new_le;
624 
625  if(strncmp(op_name, "0", 1) == 0)
627  else
628  new_le = make_lisp_expression(op_name, NIL);
629 
631 }
632 
633 
634 /*============================================================================*/
635 /* void save_exp(): the parser has completed the reading of one lisp
636  * expression, this is the first lisp expression of "lin_exp_l". We extract it
637  * from this list and translate it into a Pips expression. If there is no other
638  * lisp expression in "lin_exp_l", then this expression becomes the current
639  * expression, else it becomes an argument of the next lisp expression which is
640  * now the first object of "lin_exp_l".
641  */
642 void save_exp()
643 {
644  expression aux_exp;
645  lisp_expression aux_le;
646 
647  aux_le = LISP_EXPRESSION(CAR(lin_exp_l));
648  aux_exp = lisp_exp_to_ri_exp(aux_le);
649 
651 
652  if(lin_exp_l == NIL)
653  crt_exp = aux_exp;
654  else
655  {
658  CONS(EXPRESSION, aux_exp, NIL));
659  }
660 }
661 
662 
663 /*============================================================================*/
664 /* void new_df_ref_ind(char *s_ind): the parser has read a new indice of
665  * the current reference. We put it in the list of indices "ref_inds".
666  */
667 void new_df_ref_ind(string s_ind __attribute__ ((unused)))
668 {
670 
671  /* Initialisation of the global variables used for the reference indices
672  * parsing.
673  */
674  lin_exp_l = NIL;
675 }
676 
677 
678 /*============================================================================*/
679 /* void finish_new_df_ref(): the parser has completed the reading of the
680  * current reference with all its indices. We update our current reference and
681  * update all nodes contained in "crt_node_l".
682  */
684 {
685  list aux_l;
686 
688 
689  for(aux_l = crt_node_l; aux_l != NIL; aux_l = CDR(aux_l))
690  {
691  dataflow df;
692 
694  dataflow_reference(df) = ref;
695  }
696 }
697 
698 
699 /*============================================================================*/
700 /* void new_df_sink_ins(char *s_ins): the parser has read the name of the
701  * sink statement. With this name we get its number. We update the global
702  * list of statements and the list "crt_node_l". At this time, all the
703  * informations needed for the nodes of "crt_node_l" are present, we then
704  * concatenate these nodes into the list of vertices of the graph.
705  */
706 void new_df_sink_ins(s_ins)
707 char * s_ins;
708 {
709  extern list stmt_list;
710  extern predicate exec_dom;
711 
712  list aux_l;
713 
714  /* In PAF, an instruction name is a string "ins_#", where "#" is the number
715  * associated with the instruction. We get this number.
716  */
717  sink_stmt = atoi(strdup(s_ins + INS_NAME_LENGTH));
718 
723  NIL, // No local declarations
724  NULL, // null or empty string...
726  stmt_list);
727 
728  for(aux_l = crt_node_l; aux_l != NIL; aux_l = CDR(aux_l))
729  {
730  successor succ = first_succ_of_vertex(VERTEX(CAR(aux_l)));
731  /* FI: removed because of problems. paf_ri.h and/or paf_util.h or something else
732  should be included and might cause conflict between newgen
733  data structures */
736  exec_dom,
738  NIL);
739  }
740 
742 }
743 
744 
745 /*============================================================================*/
746 /* void init_new_do_loop(char *s_loop): initializes the parsing of the paf
747  * file ".do". The parser has read the name of a loop. With this name we create
748  * a new loop which becomes the current loop. The name of the loop is put in
749  * the loop label.
750  */
751 void init_new_do_loop(s_loop)
752 char * s_loop;
753 {
754  extern loop crt_loop;
755  entity loop_ent;
756  string loop_full_name;
757 
758  loop_full_name = strdup(concatenate(DFG_MODULE_NAME,
760  s_loop, (char *) NULL));
761 
762  loop_ent = gen_find_tabulated(loop_full_name, entity_domain);
763 
764  if(loop_ent == entity_undefined)
765  loop_ent = make_entity(loop_full_name,
769 
775  loop_ent, execution_undefined, NIL);
776 }
777 
778 
779 /*============================================================================*/
780 /* void init_loop_ctrl(char *s_ind): initializes the parsing of the control
781  * of a loop. The name that was parsed is the name of the loop index. Then we
782  * create the corresponding entity and update our current loop.
783  */
784 void init_loop_ctrl(s_ind)
785 char * s_ind;
786 {
787  string index_full_name;
788  entity var_ind;
789 
791  s_ind, (char *) NULL));
792 
793  var_ind = gen_find_tabulated(index_full_name, entity_domain);
794 
795  if(var_ind == entity_undefined)
796  var_ind = make_entity(index_full_name,
798  make_variable(make_basic_int(4/*UU*/),
799  NIL, NIL)),
802 
803  loop_index(crt_loop) = var_ind;
804 
805  lin_exp_l = NIL;
806 }
807 
808 
809 /*============================================================================*/
810 /* void lbound_exp(): The parser has read the lower bound expression of the
811  * current loop. This expression is contained in "crt_exp". We update our
812  * current loop.
813  */
815 {
817 
818  lin_exp_l = NIL;
819 }
820 
821 
822 /*============================================================================*/
823 /* void step_exp(): The parser has read the step expression of the current
824  * loop. This expression is contained in "crt_exp". We update our current loop.
825  */
826 void step_exp()
827 {
829 
830  lin_exp_l = NIL;
831 }
832 
833 
834 /*============================================================================*/
835 /* void ubound_exp(): The parser has read the upper bound expression of the
836  * current loop. This expression is contained in "crt_exp". We update our
837  * current loop.
838  */
840 {
842 
843  lin_exp_l = NIL;
844 }
845 
846 
847 /*============================================================================*/
848 /* void finish_new_do_loop(): This function update the global list of loops
849  * with the current loop.
850  */
852 {
853  extern list loop_list;
854 
856 }
857 
858 
859 /*============================================================================*/
860 /* void init_new_gd_ins(char *s_ins): initializes the parsing of the paf
861  * file ".gd". The parser has read the name of a statement. We get the number
862  * contained in this name and put in our current statement "crt_stmt".
863  *
864  * "crt_el" is the list of the current englobing loops, i.e. the englobing
865  * loops of the current statement. It is initializes to NIL.
866  */
867 void init_new_gd_ins(s_ins)
868 char * s_ins;
869 {
870  extern list crt_el;
871  extern int crt_stmt;
872 
873  crt_stmt = atoi(strdup(s_ins + INS_NAME_LENGTH));
874  crt_el = NIL;
875 }
876 
877 
878 /*============================================================================*/
879 /* static loop find_loop_with_name(string s): returns the loop that has a label
880  * name equal to the name given in argument ("s"). This function uses the
881  * global list of loops "loop_list".
882  */
884 string s;
885 {
886  extern list loop_list;
887 
888  list aux_l = loop_list;
889 
890  for(; aux_l != NIL; aux_l = CDR(aux_l))
891  {
892  loop aux_loop = LOOP(CAR(aux_l));
893  const char* loop_name = entity_local_name(loop_label(aux_loop));
894  if(strcmp(loop_name, s) == 0)
895  return(aux_loop);
896  }
897  return(loop_undefined);
898 }
899 
900 
901 /*============================================================================*/
902 /* void new_eng_loop(char *s_loop): the parser has found a new englobing
903  * loop. If it does not exist yet (we call find_loop_with_name()) we create it.
904  * We update "crt_el" with this loop (at the end): we want to construct an
905  * ordered list from the most external list to the innermost loop, and the
906  * parsing gets the loops in this order.
907  *
908  */
909 void new_eng_loop(s_loop)
910 char * s_loop;
911 {
912  extern list crt_el;
913 
914  loop aux_loop;
915 
916  aux_loop = find_loop_with_name(s_loop);
917  if(aux_loop == loop_undefined)
918  {
919  entity loop_ent;
920  string loop_full_name;
921 
922  loop_full_name = strdup(concatenate(DFG_MODULE_NAME,
924  s_loop, (char *) NULL));
925 
926  loop_ent = gen_find_tabulated(loop_full_name, entity_domain);
927 
928  if(loop_ent == entity_undefined)
929  loop_ent = make_entity(loop_full_name,
933 
934  aux_loop = make_loop(entity_undefined,
939  loop_ent, execution_undefined, NIL);
940  }
941  crt_el = gen_nconc(crt_el, CONS(LOOP, aux_loop, NIL));
942 }
943 
944 
945 /*============================================================================*/
946 /* void finish_new_gd_ins(): completes the parsing of the DFG. We copy the
947  * list of englobing loops in order to store it in the global static
948  * control map (it contains the static_controls associated to
949  * the statements). */
951 {
952  extern list crt_el, param_l;
953  extern int crt_stmt;
954 
955  list new_el;
956 
957  /* We compute the execution domain (for the dfg) for all sink instructions
958  * named "crt_stmt".
959  comp_exec_domain(dfg, crt_stmt, crt_el);
960  */
961 
962  /* Make a copy to store in the hash table "STS" */
963  new_el = NIL;
964  MAPL(cl, {
965  /* loop l = EFFECT(CAR(cl)); */
966  loop l = LOOP(CAR(cl));
967  loop nl = loop_dup(l);
968  new_el = gen_nconc(new_el, CONS(LOOP, nl, NIL));
969  }, crt_el);
970 
971  /* should be a long int for crt_stmt */
972  hash_put(STS, (void *) ((long)crt_stmt),
973  (void *) make_static_control(true, param_l, new_el, NIL));
974 }
975 
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
graph make_graph(list a)
Definition: graph.c:56
successor make_successor(arc_label a1, vertex a2)
Definition: graph.c:98
vertex make_vertex(vertex_label a1, list a2)
Definition: graph.c:140
static_control make_static_control(bool a1, list a2, list a3, list a4)
Definition: paf_ri.c:655
dataflow make_dataflow(reference a1, list a2, predicate a3, communication a4)
Definition: paf_ri.c:180
lisp_expression make_lisp_expression(string a1, list a2)
Definition: paf_ri.c:348
dfg_arc_label make_dfg_arc_label(list a)
Definition: paf_ri.c:222
dfg_vertex_label make_dfg_vertex_label(intptr_t a1, predicate a2, sccflags a3)
Definition: paf_ri.c:264
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
type make_type_variable(variable _field_)
Definition: ri.c:2715
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
synchronization make_synchronization_none(void)
Definition: ri.c:2424
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
static vertex crt_node
Internal variables
Definition: adg_read_paf.c:159
void new_df_trans_exp()
===========================================================================
Definition: adg_read_paf.c:374
void init_op_name(string op_name)
===========================================================================
Definition: adg_read_paf.c:601
void init_new_do_loop(char *s_loop)
===========================================================================
Definition: adg_read_paf.c:751
void elim_last_pred()
===========================================================================
Definition: adg_read_paf.c:485
static int sink_stmt
Current source node.
Definition: adg_read_paf.c:160
void init_new_gd_ins(char *s_ins)
===========================================================================
Definition: adg_read_paf.c:867
dfg_arc_label arc_label
Name : adg_read_paf.c Package : paf-util Author : Alexis Platonoff Date : april 1993 Historic : 16 ju...
Definition: adg_read_paf.c:119
void init_new_dfg()
===========================================================================
Definition: adg_read_paf.c:245
void new_df_ref_ind(string s_ind __attribute__((unused)))
===========================================================================
Definition: adg_read_paf.c:667
static list trans_l
Current list of nodes.
Definition: adg_read_paf.c:168
list stmt_list
The "stmt_list" global variable is the list the assign statement of the program (with all fields empt...
Definition: adg_read_paf.c:144
static loop crt_loop
Current operator name.
Definition: adg_read_paf.c:175
static int source_stmt
Current sink statement.
Definition: adg_read_paf.c:161
void save_int(int i)
===========================================================================
Definition: adg_read_paf.c:549
void init_new_df_gov_pred()
===========================================================================
Definition: adg_read_paf.c:426
static list crt_node_l
Current execution domain.
Definition: adg_read_paf.c:167
void new_param(string s)
===========================================================================
Definition: adg_read_paf.c:262
static predicate exec_dom
Current governing predicate.
Definition: adg_read_paf.c:166
void init_new_df_source(char *s_ins)
===========================================================================
Definition: adg_read_paf.c:342
static loop find_loop_with_name(string s)
===========================================================================
Definition: adg_read_paf.c:883
void finish_new_do_loop()
===========================================================================
Definition: adg_read_paf.c:851
#define PAF_STRING
Definition: adg_read_paf.c:129
dfg_vertex_label vertex_label
Definition: adg_read_paf.c:120
static list ref_inds
Current list of transformations.
Definition: adg_read_paf.c:169
list loop_list
The "loop_list" global variable is the list the loops of the program (with all their characteristics:...
Definition: adg_read_paf.c:150
#define STMT_TO_STCT_SIZE
Definition: adg_read_paf.c:131
void lbound_exp()
===========================================================================
Definition: adg_read_paf.c:814
static list pred_l
Current list of linear expressions.
Definition: adg_read_paf.c:171
void finish_new_gd_ins()
===========================================================================
Definition: adg_read_paf.c:950
static int crt_stmt
Current source statement.
Definition: adg_read_paf.c:162
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
void init_new_df_sink_ins()
===========================================================================
Definition: adg_read_paf.c:297
#define DOT
include "paf_ri.h"
Definition: adg_read_paf.c:128
static list param_l
Current list of englobing loops.
Definition: adg_read_paf.c:173
void new_df_sink_ins(char *s_ins)
===========================================================================
Definition: adg_read_paf.c:706
void new_df_gov_pred()
===========================================================================
Definition: adg_read_paf.c:498
static expression crt_exp
Current reference.
Definition: adg_read_paf.c:164
void step_exp()
===========================================================================
Definition: adg_read_paf.c:826
static string crt_op_name
Current list of structure parameters.
Definition: adg_read_paf.c:174
void ubound_exp()
===========================================================================
Definition: adg_read_paf.c:839
void init_new_df_ref(char *s_ref)
===========================================================================
Definition: adg_read_paf.c:514
#define INS_NAME_LENGTH
Definition: adg_read_paf.c:130
void save_exp()
===========================================================================
Definition: adg_read_paf.c:642
void save_id(string s)
===========================================================================
Definition: adg_read_paf.c:576
void init_loop_ctrl(char *s_ind)
===========================================================================
Definition: adg_read_paf.c:784
static hash_table STS
The "STS" global variable is the hash table that maps the static_control on the statements.
Definition: adg_read_paf.c:155
graph dfg
Global variables
Definition: adg_read_paf.c:138
void save_pred(int option)
===========================================================================
Definition: adg_read_paf.c:450
static list crt_el
Current list of predicates.
Definition: adg_read_paf.c:172
static statement find_stmt_with_num(int n)
===========================================================================
Definition: adg_read_paf.c:314
void new_eng_loop(char *s_loop)
===========================================================================
Definition: adg_read_paf.c:909
void finish_new_df_source()
===========================================================================
Definition: adg_read_paf.c:399
graph adg_read_paf(char *s)
Current loop instruction.
Definition: adg_read_paf.c:198
static list lin_exp_l
Current list of reference indices.
Definition: adg_read_paf.c:170
static predicate gov_pred
Current expression.
Definition: adg_read_paf.c:165
void init_op_exp(string op_name)
===========================================================================
Definition: adg_read_paf.c:618
void finish_new_df_ref()
===========================================================================
Definition: adg_read_paf.c:683
#define POSITIVE
Definition: bdt_read_paf.c:81
#define sccflags_undefined
Definition: dg.h:247
#define successor_vertex(x)
Definition: graph.h:118
#define vertex_undefined
Definition: graph.h:128
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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
#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
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define pips_internal_error
Definition: misc-local.h:149
#define exit(code)
Definition: misc-local.h:54
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
@ hash_int
Definition: newgen_hash.h:32
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define UU
Definition: newgen_types.h:98
#define DFG_MODULE_NAME
expression negate_expression(expression)
===========================================================================
Definition: utils.c:792
loop loop_dup(loop)
===========================================================================
Definition: utils.c:1014
expression lisp_exp_to_ri_exp(lisp_expression)
===========================================================================
Definition: utils.c:755
successor first_succ_of_vertex(vertex)
===========================================================================
Definition: utils.c:994
expression make_id_expression(string)
===========================================================================
Definition: utils.c:672
void set_current_stco_map(statement_mapping)
========================================================================
Definition: utils.c:2408
dataflow first_df_of_succ(successor)
===========================================================================
Definition: utils.c:1004
predicate expressions_to_predicate(list)
===========================================================================
Definition: utils.c:826
#define DATAFLOW(x)
DATAFLOW.
Definition: paf_ri.h:308
#define LISP_EXPRESSION(x)
LISP_EXPRESSION.
Definition: paf_ri.h:457
#define communication_undefined
Definition: paf_ri.h:236
#define dataflow_governing_pred(x)
Definition: paf_ri.h:344
#define dataflow_reference(x)
Definition: paf_ri.h:340
#define lisp_expression_args(x)
Definition: paf_ri.h:489
#define PLUS_OPERATOR_NAME
#define make_entity(n, t, s, 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
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
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define LOOP(x)
LOOP.
Definition: ri.h:1606
#define loop_undefined
Definition: ri.h:1612
#define reference_undefined
Definition: ri.h:2302
#define range_upper(x)
Definition: ri.h:2290
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define ram_undefined
Definition: ri.h:2221
#define statement_ordering(x)
Definition: ri.h:2454
#define execution_undefined
Definition: ri.h:1174
@ is_value_unknown
Definition: ri.h:3035
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define instruction_undefined
Definition: ri.h:1454
@ is_storage_ram
Definition: ri.h:2492
#define entity_undefined
Definition: ri.h:2761
#define expression_undefined
Definition: ri.h:1223
#define predicate_undefined
Definition: ri.h:2046
#define reference_indices(x)
Definition: ri.h:2328
#define loop_label(x)
Definition: ri.h:1646
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
@ is_type_statement
Definition: ri.h:2898
@ is_type_variable
Definition: ri.h:2900
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define loop_index(x)
Definition: ri.h:1640
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
The structure used to build lists in NewGen.
Definition: newgen_list.h:41