PIPS
ordering.c
Go to the documentation of this file.
1 /*
2 
3  $Id: ordering.c 23495 2018-10-24 09:19:47Z 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 /** @file ordering.c
29 
30  Defines a static mapping from orderings to statements.
31  must be initialize_ordering_to_statement, and afterwards
32  reset_ordering_to_statement.
33 
34  For information on ordering, see control/reorder.c
35  */
36 
37 #include <stdio.h>
38 
39 #include "linear.h"
40 
41 #include "genC.h"
42 #include "ri.h"
43 
44 #include "misc.h"
45 #include "ri-util.h"
46 
47 /* a hash table to map orderings (integer) to statements (pointers)
48  * assumed to be valid for the current module returned by
49  * get_current_module_entity(). This is assumed to hold when
50  * pipsmake issues a request to lower level libraries.
51  *
52  * db_get_current_module() returns the module used in the request
53  * to pipsmake and is usually different.
54  *
55  * It would be possible to expose a lower level interface to manage
56  * several ordering_to_statement hash tables
57  */
59 
60 
61 /* Test if the ordering to statement is initialized */
62 bool
64 {
66 }
67 
68 
69 /* Dump the ordering with the corresponding statement address */
70 void
72 {
73  HASH_MAP(ko, vs, {
74  _int o = (_int) ko;
75  statement s = (statement) vs;
76 
77  fprintf(stderr,"%td (%td,%td)->%s\n",
81 }
82 
83 
84 /* Get the statement from an ordering in a given ordering to statement
85  table */
86 static statement
88 {
89  statement s;
90  pips_assert("defined hash table...",
91  ots != NULL && ots != hash_table_undefined);
92 
94  pips_internal_error("Illegal ordering %td", o);
95 
96  s = (statement) hash_get(ots, (char *) o);
97 
98  if(s == statement_undefined)
99  pips_internal_error("no statement for order %td=(%td,%td)",
101 
102  return s;
103 }
104 
105 
106 /* Get the statement associated to a given ordering.
107 
108  It is useful for retrieve the statements associated with the arcs in
109  the dependence graphs for example. */
110 statement
112 {
113  statement s;
115  return s;
116 }
117 
118 
119 /* Add the statement for its ordering, if any, in the hash-map. */
121 {
122  pips_assert("ordering is defined",
124  hash_put(ots, (void *) statement_ordering(stat), (void *) stat);
125  return true;
126 }
127 
128 
129 /* Add the statement for its ordering, if any, in the hash-map. */
131 {
132  pips_assert("ordering is defined",
134  hash_put(OrderingToStatement, (void *) statement_ordering(stat), (void *) stat);
135  return true;
136 }
137 
138 /* Overwrite the statement for its ordering, if any, in the hash-map.
139  * The difference with add_ordering_of_the_statement_to_current_mapping() is
140  * that this version won't trigger a warning if the mapping already exist
141  */
143 {
144  pips_assert("ordering is defined",
146  hash_overwrite(OrderingToStatement, (void *) statement_ordering(stat), (void *) stat);
147  return true;
148 }
149 
150 
151 /* Initialize the ordering to statement mapping by iterating from a given
152  statement
153 
154  @param ots is ordering to statement hash-table to fill
155 
156  @param s is the statement to start with. Typically the module
157  statement.
158 */
160 {
161  /* Simplify this with a gen_recurse to avoid dealing with all the new
162  cases by hand (for-loops...).
163 
164  Apply a prefix hash-map add to be compatible with previous
165  implementation and avoid different hash-map iteration later. */
167 }
168 
169 
170 /* To be used instead of initialize_ordering_to_statement() to make
171  sure that the hash table ots is in sync with the current module. */
173 {
174  pips_assert("hash table \"OrderingToStatement\" is undefined",
178  OrderingToStatement = ots;
179  return ots;
180 }
181 
182 
183 /* Reset the mapping from ordering to statement. */
184 void
186 {
187  pips_assert("hash table is defined",
189 
192 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
string statement_identification(statement)
Like external_statement_identification(), but with internal information, the hexadecimal address of t...
Definition: statement.c:1700
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
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
void hash_overwrite(hash_table htp, const void *key, const void *val)
hash_put which allows silent overwrite...
Definition: hash.c:344
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
@ hash_int
Definition: newgen_hash.h:32
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
intptr_t _int
_INT
Definition: newgen_types.h:53
void print_ordering_to_statement(void)
Dump the ordering with the corresponding statement address.
Definition: ordering.c:71
static bool add_ordering_of_the_statement(statement stat, hash_table ots)
Add the statement for its ordering, if any, in the hash-map.
Definition: ordering.c:120
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
bool add_ordering_of_the_statement_to_current_mapping(statement stat)
Add the statement for its ordering, if any, in the hash-map.
Definition: ordering.c:130
static hash_table OrderingToStatement
a hash table to map orderings (integer) to statements (pointers) assumed to be valid for the current ...
Definition: ordering.c:58
statement ordering_to_statement(int o)
Get the statement associated to a given ordering.
Definition: ordering.c:111
static statement apply_ordering_to_statement(hash_table ots, _int o)
Get the statement from an ordering in a given ordering to statement table.
Definition: ordering.c:87
static void rinitialize_ordering_to_statement(hash_table ots, statement s)
Initialize the ordering to statement mapping by iterating from a given statement.
Definition: ordering.c:159
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
bool overwrite_ordering_of_the_statement_to_current_mapping(statement stat)
Overwrite the statement for its ordering, if any, in the hash-map.
Definition: ordering.c:142
bool ordering_to_statement_initialized_p()
Test if the ordering to statement is initialized.
Definition: ordering.c:63
#define ORDERING_NUMBER(o)
#define ORDERING_STATEMENT(o)
#define statement_ordering(x)
Definition: ri.h:2454
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define statement_undefined
Definition: ri.h:2419
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...