PIPS
freia_aipo.c
Go to the documentation of this file.
1 /*
2 
3  $Id: freia_aipo.c 23288 2016-11-08 10:09:39Z 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 
25 #ifdef HAVE_CONFIG_H
26 #include "pips_config.h"
27 #endif
28 
29 #include <stdint.h>
30 #include <stdlib.h>
31 
32 #include "genC.h"
33 #include "misc.h"
34 #include "linear.h"
35 
36 #include "ri.h"
37 
38 #include "freia.h"
39 #include "hwac.h"
40 
41 /*
42  @brief compile one dag with AIPO optimizations
43  @param ls statements underlying the full dag
44  @param occs image occurences
45  @param exchanges statements to exchange because of dependences
46  @return the list of allocated intermediate images
47 */
49 (string module,
50  dag fulld,
51  list /* of statements */ ls,
52  const hash_table occs,
53  hash_table exchanges,
54  int number)
55 {
56  pips_debug(3, "considering %d statements\n", (int) gen_length(ls));
57  pips_assert("some statements", ls);
58 
59  // about aipo statistics: no helper file to put them...
60 
61  // handle intermediate images
63  list new_images = dag_fix_image_reuse(fulld, init, occs);
64 
65  // optimize dag
66  list added_before = NIL, added_after = NIL;
67  freia_dag_optimize(fulld, exchanges, &added_before, &added_after);
68 
69  // dump final optimised dag
70  dag_dot_dump_prefix(module, "dag_cleaned_", number, fulld,
71  added_before, added_after);
72 
73  // now may put actual allocations, which messes up statement numbers
74  list reals =
75  freia_allocate_new_images_if_needed(ls, new_images, occs, init, NULL);
76 
77  // ??? should it be NIL because it is not useful in AIPO->AIPO?
78  freia_insert_added_stats(ls, added_before, true);
79  added_before = NIL;
80  freia_insert_added_stats(ls, added_after, false);
81  added_after = NIL;
82 
83  // cleanup
84  gen_free_list(new_images);
86 
87  return reals;
88 }
list dag_fix_image_reuse(dag d, hash_table init, const hash_table occs)
fix intermediate image reuse in dag
Definition: dag-utils.c:2779
void freia_dag_optimize(dag d, hash_table exchanges, list *lbefore, list *lafter)
remove dead image operations.
Definition: dag-utils.c:1416
void dag_dot_dump_prefix(const string module, const string prefix, int number, const dag d, const list lb, const list la)
Definition: dag-utils.c:504
list freia_allocate_new_images_if_needed(list ls, list images, const hash_table occs, const hash_table init, const hash_table signatures)
insert image allocation if needed, for intermediate image inserted before if an image is used only tw...
Definition: freia-utils.c:1650
void freia_insert_added_stats(list ls, list stats, bool before)
insert statements to actual code sequence in "ls" BEWARE that ls is assumed to be in reverse order....
Definition: freia-utils.c:1185
list freia_aipo_compile_calls(string module, dag fulld, list ls, const hash_table occs, hash_table exchanges, int number)
freia_aipo.c
Definition: freia_aipo.c:49
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
@ hash_pointer
Definition: newgen_hash.h:32
static char * module
Definition: pips.c:74
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320
The structure used to build lists in NewGen.
Definition: newgen_list.h:41