PIPS
internalize_parallel_code.c
Go to the documentation of this file.
1 /*
2 
3  $Id: internalize_parallel_code.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 
25 // do not compile unless required
26 #include "phases.h"
27 #ifdef BUILDER_INTERNALIZE_PARALLEL_CODE
28 
29 #ifdef HAVE_CONFIG_H
30  #include "pips_config.h"
31 #endif
32 /*
33  For historical reasons, a parallelized program in PIPS is no longer a
34  classical PIPS program we can work on later because sequential code and
35  parallelized code do not have the same resource type. Unfortunately,
36  improving the parallelized code with some other transformations
37  (dead-code elimination, etc) is also useful. Thus we add a new
38  pseudo-transformation that coerce a parallel code into a classical
39  (sequential) one to consider parallelization as an internal
40  transformation in PIPS.
41 
42  Note this transformation may no be usable with some special
43  parallelization in PIPS such as WP65 or HPFC that generate other resource
44  types.
45 
46  Ronan.Keryell@enstb.org
47  */
48 
49 #include "genC.h"
50 #include "linear.h"
51 
52 #include "misc.h"
53 #include "pipsdbm.h"
54 
55 #include "ri.h"
56 #include "ri-util.h"
57 
58 /* I love writing so simple passes... :-)
59  Basically do only a
60  DBR_CODE(mod_name) = (DBR_CODE) DBR_PARALLELIZED_CODE(mod_name)
61 */
62 bool internalize_parallel_code(const string mod_name)
63 {
64  debug_on("INTERNALIZE_PARALLEL_CODE_DEBUG_LEVEL");
65 
66  // Get the parallelized code and tell PIPS_DBM we do not want to modify it
67  statement mod_stmt = (statement)
68  db_get_memory_resource(DBR_PARALLELIZED_CODE, mod_name, false);
69  clean_up_sequences(mod_stmt);
70  module_reorder(mod_stmt);
71  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
72  pips_debug(2, "done for %s\n", mod_name);
73  debug_off();
74  return true;
75 }
76 
77 #endif // BUILDER_INTERNALIZE_PARALLEL_CODE
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
bool internalize_parallel_code(const string)
internalize_parallel_code.c