PIPS
tabulated.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <setjmp.h>
#include "genC.h"
#include "newgen_include.h"
+ Include dependency graph for tabulated.c:

Go to the source code of this file.

Data Structures

struct  _gtp
 

Macros

#define TABULATED_ELEMENTS_SIZE   (500)
 table of tabulated elements. More...
 
#define TABULATED_ELEMENTS_INCR   (10000)
 

Functions

static gen_tabulated_p get_tabulated_from_domain (int domain)
 
gen_tabulated_p gen_init_tabulated (int domain)
 
static void extends_tabulated (gen_tabulated_p gtp)
 
gen_chunkgen_tabulated_fake_object_hack (int domain)
 WARNING: it is not reentrant... More...
 
void gen_mapc_tabulated (void(*fp)(gen_chunk *), int domain)
 apply fp to domain... More...
 
list gen_filter_tabulated (bool(*filter)(gen_chunk *), int domain)
 returns the list of entities with this caracteristics. More...
 
static int gen_put_tabulated (int domain, gen_chunk *gc)
 add tabulated in table. More...
 
static void gen_put_tabulated_name (int domain, char *id, _int number)
 
static void gen_delete_tabulated_name (gen_chunk *obj)
 deletes obj from the tabulated names... More...
 
static _int gen_get_tabulated_name_basic (int domain, const char *id)
 
void * gen_find_tabulated (const char *key, int domain)
 
static void positive_number (gen_chunk *o)
 
int gen_read_and_check_tabulated (FILE *file, int create_p)
 
void gen_clear_tabulated_element (gen_chunk *obj)
 GEN_CLEAR_TABULATED_ELEMENT only clears the entry for object OBJ in the gen_tabulated_ and gen_tabulated_names tables. More...
 
gen_chunkgen_do_enter_tabulated (int domain, string id, gen_chunk *cp, bool is_a_ref)
 
gen_chunkgen_enter_tabulated (int domain, string id, gen_chunk *cp, bool allow_ref)
 ENTER_TABULATED_DEF enters a new definition (previous refs are allowed if ALLOW_REF) in the INDEX tabulation table of the DOMAIN, with the unique ID and value CHUNKP. More...
 

Macro Definition Documentation

◆ TABULATED_ELEMENTS_INCR

#define TABULATED_ELEMENTS_INCR   (10000)

Definition at line 48 of file tabulated.c.

◆ TABULATED_ELEMENTS_SIZE

#define TABULATED_ELEMENTS_SIZE   (500)

table of tabulated elements.

I guess it could be stored directly in the gen_binding, and the index could be dropped.

Definition at line 47 of file tabulated.c.

Function Documentation

◆ extends_tabulated()

static void extends_tabulated ( gen_tabulated_p  gtp)
static

Definition at line 88 of file tabulated.c.

89 {
90  register int nsize, i;
91  gen_chunk * t;
92 
93  nsize = gtp->size + TABULATED_ELEMENTS_INCR;
94 
95  t = (gen_chunk*) realloc(gtp->table, sizeof(gen_chunk)*nsize);
96 
97  message_assert("realloc ok", t);
98 
99  for (i=gtp->size; i<nsize; i++)
100  t[i].p = gen_chunk_undefined;
101 
102  gtp->size = nsize;
103  gtp->table = t;
104 }
#define gen_chunk_undefined
Definition: genC.h:74
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
gen_chunk * table
how many are used
Definition: tabulated.c:55
int size
domain number
Definition: tabulated.c:53
#define TABULATED_ELEMENTS_INCR
Definition: tabulated.c:48
A gen_chunk is used to store every object.
Definition: genC.h:58
union gen_chunk * p
Definition: genC.h:69

References gen_chunk_undefined, message_assert, gen_chunk::p, _gtp::size, _gtp::table, and TABULATED_ELEMENTS_INCR.

Referenced by gen_put_tabulated().

+ Here is the caller graph for this function:

◆ gen_clear_tabulated_element()

void gen_clear_tabulated_element ( gen_chunk obj)

GEN_CLEAR_TABULATED_ELEMENT only clears the entry for object OBJ in the gen_tabulated_ and gen_tabulated_names tables.

Definition at line 251 of file tabulated.c.

252 {
253  register int domain = quick_domain_index(obj);
255  int number = (obj+1)->i;
256 
257  message_assert("correct object to delete", gtp->table[number].p == obj);
258 
260  gtp->table[number].p = gen_chunk_undefined;
261  gtp->used--;
262 }
#define quick_domain_index(obj)
inlined version of domain_index.
Definition: tabulated.c:51
int used
current allocated size
Definition: tabulated.c:54
static void gen_delete_tabulated_name(gen_chunk *obj)
deletes obj from the tabulated names...
Definition: tabulated.c:198
static gen_tabulated_p get_tabulated_from_domain(int domain)
Definition: tabulated.c:59
A DOMAIN union describes the structure of a user type.

References gen_chunk_undefined, gen_delete_tabulated_name(), get_tabulated_from_domain(), message_assert, gen_chunk::p, quick_domain_index, _gtp::table, and _gtp::used.

Referenced by clean_statement_label(), do_recompile_module(), free_obj_in(), RenameFunctionEntity(), and spire_distributed_unstructured_to_structured().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_delete_tabulated_name()

static void gen_delete_tabulated_name ( gen_chunk obj)
static

deletes obj from the tabulated names...

Definition at line 198 of file tabulated.c.

199 {
200  char * key = (obj+2)->s;
201  void * okey, * val;
202  int domain = obj->i;
204 
205  val = hash_delget(gtp->names, key, &okey);
206  if (val == HASH_UNDEFINED_VALUE)
207  fatal("gen_delete_tabulated_name: clearing unexisting (%s)\n", key);
208 
209  // free(okey);
210 }
void * hash_delget(hash_table htp, const void *key, void **pkey)
deletes key from the hash table.
Definition: hash.c:398
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
void fatal(char *,...)
hash_table names
actual table
Definition: tabulated.c:56
_int i
Definition: genC.h:62

References fatal(), get_tabulated_from_domain(), hash_delget(), HASH_UNDEFINED_VALUE, gen_chunk::i, and _gtp::names.

Referenced by gen_clear_tabulated_element().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_do_enter_tabulated()

gen_chunk* gen_do_enter_tabulated ( int  domain,
string  id,
gen_chunk cp,
bool  is_a_ref 
)

stores - if ref

Definition at line 265 of file tabulated.c.

266 {
267  int number = gen_put_tabulated(domain, cp);
268  (cp+1)->i = is_a_ref? -number: number; /* stores - if ref */
269  message_assert("name pointer ok", (cp+2)->s == id);
270  gen_put_tabulated_name(domain, id, number);
271  return cp;
272 }
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Definition: sc_read.c:87
static int gen_put_tabulated(int domain, gen_chunk *gc)
add tabulated in table.
Definition: tabulated.c:162
static void gen_put_tabulated_name(int domain, char *id, _int number)
Definition: tabulated.c:188

References cp, gen_put_tabulated(), gen_put_tabulated_name(), and message_assert.

Referenced by gen_enter_tabulated(), and make_ref().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_enter_tabulated()

gen_chunk* gen_enter_tabulated ( int  domain,
string  id,
gen_chunk cp,
bool  allow_ref 
)

ENTER_TABULATED_DEF enters a new definition (previous refs are allowed if ALLOW_REF) in the INDEX tabulation table of the DOMAIN, with the unique ID and value CHUNKP.

already in, redefine

Definition at line 279 of file tabulated.c.

280 {
281  gen_chunk * gp = gen_find_tabulated(id, domain);
282 
283  if (gp==gen_chunk_undefined)
284  {
285  cp = gen_do_enter_tabulated(domain, id, cp, false);
286  }
287  else /* already in, redefine */
288  {
289  register int i, size, number = (gp+1)->i;
290 
291  if (number>0)
292  fprintf(stderr, "warning: '%s' of %d redefined\n", id, domain);
293  else
294  number = -number;
295 
296  if (!allow_ref)
297  fprintf(stderr, "unexpected reference to '%s' of %d\n", id, domain);
298 
299  size = gen_size(domain);
300 
301  message_assert("same name", same_string_p((gp+2)->s, (cp+2)->s));
302  message_assert("same domain", gp->i == cp->i);
303 
304  for (i=3; i<size; i++)
305  gp[i] = cp[i];
306 
307  free((cp+2)->s), free(cp), cp = gp;
308  (cp+1)->i = number;
309  }
310 
311  return cp;
312 }
int gen_size(int domain)
GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type.
Definition: genC.c:71
void free(void *)
#define same_string_p(s1, s2)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
gen_chunk * gen_do_enter_tabulated(int domain, string id, gen_chunk *cp, bool is_a_ref)
Definition: tabulated.c:265
void * gen_find_tabulated(const char *key, int domain)
Definition: tabulated.c:218

References cp, fprintf(), free(), gen_chunk_undefined, gen_do_enter_tabulated(), gen_find_tabulated(), gen_size(), gen_chunk::i, message_assert, and same_string_p.

Referenced by gen_alloc(), and make_def().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_filter_tabulated()

list gen_filter_tabulated ( bool(*)(gen_chunk *)  filter,
int  domain 
)

returns the list of entities with this caracteristics.

Definition at line 144 of file tabulated.c.

145 {
147  register int i, size = gtp->size;
148  list l;
149 
150  for (l=NIL, i=0; i<size; i++) {
151  gen_chunk * o = gtp->table[i].p;
152  if (o && o != gen_chunk_undefined) {
153  if (filter(o)) l = CONS(CHUNK, o, l);
154  }
155  }
156 
157  return l;
158 }
#define CHUNK(x)
Definition: genC.h:90
#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
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CHUNK, CONS, gen_chunk_undefined, get_tabulated_from_domain(), NIL, gen_chunk::p, _gtp::size, and _gtp::table.

Referenced by db_get_module_list_initial_order(), generate_starpu_pragma(), GenericCleanLocalEntities(), html_print_symbol_table(), RemoveLocalEntities(), and spire_distributed_unstructured_to_structured().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_find_tabulated()

void* gen_find_tabulated ( const char *  key,
int  domain 
)

Definition at line 218 of file tabulated.c.

219 {
221 
222  if (number == (_int) HASH_UNDEFINED_VALUE)
223  {
224  return gen_chunk_undefined;
225  }
226  else
227  {
229  message_assert("valid tabulated number", number>=0 && number<gtp->size);
230  return gtp->table[number].p;
231  }
232 }
intptr_t _int
_INT
Definition: newgen_types.h:53
static _int gen_get_tabulated_name_basic(int domain, const char *id)
Definition: tabulated.c:212

References gen_chunk_undefined, gen_get_tabulated_name_basic(), get_tabulated_from_domain(), HASH_UNDEFINED_VALUE, message_assert, gen_chunk::p, and _gtp::table.

Referenced by add_address_of_value(), add_non_declared_reference_to_declaration(), add_old_value(), add_sizeof_value(), add_symbolic_constant_to_declaration(), add_test(), alias_check(), binary_arithmetic_operator_to_post_pv(), build_new_ref(), clone_variable_with_new_name(), cmf_layout_align(), compile_mpi(), complex_bound_generation(), craft_layout_align(), create_local_index(), create_local_index2(), create_named_entity(), create_parameter_for_new_module(), create_parameter_variable_for_new_module(), create_private_integer_variable_for_new_module(), create_private_variable_for_new_module(), create_state_variable(), create_tile_basis(), creer_nom_var(), db_module_exists_p(), ecrit_une_var_neg(), entity_all_locations(), entity_empty_label(), entity_field_to_entity(), entity_from_user_name(), entity_intrinsic(), entity_nowhere_locations(), eov_add_entity_to_eliminate(), external_entity_to_old_value(), fetch_complexity_parameters(), find_entity(), find_label_entity(), find_operator(), find_or_create_coeff(), find_or_create_db_symbol(), find_or_create_emulated_shared_variable(), find_or_create_scalar_entity(), find_or_create_typed_entity(), FindEntity(), FindEntityFromLocalNameAndPrefix(), FindEntityFromLocalNameAndPrefixAndScope(), FindEntityFromUserName(), FindOrCreateEntityLikeModel(), gen_enter_tabulated(), gen_find_db_symbol(), gen_find_entity(), gen_find_opcodeClass(), generate_pseudo_formal_variable_for_formal_label(), generic_make_entity_copy_with_new_name(), get_time_ent(), get_variables_to_filter(), gfc2pips_check_entity_block_data_exists(), gfc2pips_check_entity_doesnt_exists(), gfc2pips_check_entity_exists(), gfc2pips_check_entity_module_exists(), gfc2pips_check_entity_program_exists(), gfc2pips_namespace(), global_name_to_entity(), global_new_value_to_global_old_value(), init_loop_ctrl(), init_new_df_ref(), init_new_do_loop(), local_name_to_top_level_entity(), local_name_to_variable(), loop_normalize_of_loop(), make_array_bounds(), make_array_entity(), make_bound(), make_constraint_expression(), make_derived_entity(), make_empty_module(), make_emulated_shared_variable(), make_func_op(), make_host_and_node_modules(), make_id_expression(), make_integer_constant_entity(), make_local_value_entity(), make_movements_loop_body_wp65(), make_op_exp(), make_rational_exp(), make_ref(), make_scalar_entity(), make_statement_copy_i(), make_tile_index_entity_n(), MakeAssignedOrComputedGotoInst(), MakeCurrentFunction(), MakeDiVar(), MakeDsiVar(), MakeLiVar(), MakeLoopCounter(), module_entity_to_compilation_unit_entity(), mpi_init_ctx(), my_build_new_ref(), name_to_variable(), NameToFunctionalEntity(), new_eng_loop(), new_param(), predicate_to_expression(), psystem_to_expression(), rational_op_exp(), recursive_rename_types(), replicate_declaration(), SafeFindOrCreateEntity(), sc_add_new_variable_name(), signed_integer_constant_expression_p(), simplify_minmax_contrainte(), step_function(), transformer_filter_subsumed_variables(), translate_global_value(), type_to_named_type(), undefined_pointer_value_entity(), unique_entity_name_p(), update_called_modules(), value_to_variable(), vect_gen_read(), and xml_TaskParameter().

+ Here is the call graph for this function:

◆ gen_get_tabulated_name_basic()

static _int gen_get_tabulated_name_basic ( int  domain,
const char *  id 
)
static

Definition at line 212 of file tabulated.c.

213 {
215  return (_int) hash_get(gtp->names, id);
216 }
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

References get_tabulated_from_domain(), hash_get(), and _gtp::names.

Referenced by gen_find_tabulated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_init_tabulated()

gen_tabulated_p gen_init_tabulated ( int  domain)

Definition at line 66 of file tabulated.c.

67 {
68  int i;
69  gen_chunk * t;
70  gen_tabulated_p gtp;
71 
72  gtp = (gen_tabulated_p) alloc(sizeof(struct _gtp));
73 
75  gtp->used = 0;
76  gtp->domain = domain;
78 
79  for (i=0; i<TABULATED_ELEMENTS_SIZE; i++)
80  t[i].p = gen_chunk_undefined;
81 
82  gtp->table = t;
84 
85  return gtp;
86 }
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
Definition: build.c:501
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_string
Definition: newgen_hash.h:32
struct _gtp * gen_tabulated_p
actually defined in tabulated.c
int domain
Definition: tabulated.c:52
#define TABULATED_ELEMENTS_SIZE
table of tabulated elements.
Definition: tabulated.c:47

References alloc(), _gtp::domain, gen_chunk_undefined, hash_string, hash_table_make(), _gtp::names, _gtp::size, _gtp::table, TABULATED_ELEMENTS_SIZE, and _gtp::used.

+ Here is the call graph for this function:

◆ gen_mapc_tabulated()

void gen_mapc_tabulated ( void(*)(gen_chunk *)  fp,
int  domain 
)

apply fp to domain...

Definition at line 127 of file tabulated.c.

128 {
130  register int i, size = gtp->size;
131 
132  for (i=0; i<size; i++)
133  {
134  gen_chunk e = gtp->table[i];
135  if (e.p && e.p != gen_chunk_undefined)
136  {
137  message_assert("tabulated ok", e.p->i==domain);
138  fp(e.p);
139  }
140  }
141 }

References gen_chunk_undefined, get_tabulated_from_domain(), gen_chunk::i, message_assert, gen_chunk::p, _gtp::size, and _gtp::table.

Referenced by gen_free_tabulated(), gen_read_and_check_tabulated(), gen_tabulated_consistent_p(), and gen_write_tabulated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_put_tabulated()

static int gen_put_tabulated ( int  domain,
gen_chunk gc 
)
static

add tabulated in table.

returns its index.

should not get there

Definition at line 162 of file tabulated.c.

163 {
165  register int i, size = gtp->size;
166 
167  if (gtp->used + 10 > gtp->size) {
168  extends_tabulated(gtp);
169  }
170 
171  message_assert("large enough", gtp->used+10 <= gtp->size);
172 
173  for (i = gtp->used? gtp->used: 1; i != gtp->used-1 ; i%=(size-1), i++)
174  {
175  if (gtp->table[i].p == gen_chunk_undefined)
176  {
177  gtp->table[i].p = gc;
178  gtp->used++;
179  return i;
180  }
181  }
182 
183  /* should not get there */
184  fatal("cannot put tabulated dom=%d... no space available!", domain);
185  return 0;
186 }
static void extends_tabulated(gen_tabulated_p gtp)
Definition: tabulated.c:88

References extends_tabulated(), fatal(), gen_chunk_undefined, get_tabulated_from_domain(), message_assert, gen_chunk::p, _gtp::size, _gtp::table, and _gtp::used.

Referenced by gen_do_enter_tabulated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_put_tabulated_name()

static void gen_put_tabulated_name ( int  domain,
char *  id,
_int  number 
)
static

Definition at line 188 of file tabulated.c.

189 {
191  message_assert("positive tabulated number", number>0);
192  hash_put(gtp->names, id, (void *) number);
193 }
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

References get_tabulated_from_domain(), hash_put(), message_assert, and _gtp::names.

Referenced by gen_do_enter_tabulated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gen_read_and_check_tabulated()

int gen_read_and_check_tabulated ( FILE *  file,
int  create_p 
)

Definition at line 239 of file tabulated.c.

240 {
241  int domain = gen_read_tabulated(file, create_p);
243  return domain;
244 }
int gen_read_tabulated(FILE *file, int create_p)
GEN_READ_TABULATED reads FILE to update the Gen_tabulated_ table.
Definition: genClib.c:2334
void gen_mapc_tabulated(void(*fp)(gen_chunk *), int domain)
apply fp to domain...
Definition: tabulated.c:127
static void positive_number(gen_chunk *o)
Definition: tabulated.c:234

References gen_mapc_tabulated(), gen_read_tabulated(), and positive_number().

+ Here is the call graph for this function:

◆ gen_tabulated_fake_object_hack()

gen_chunk* gen_tabulated_fake_object_hack ( int  domain)

WARNING: it is not reentrant...

max_tabulated_elements()

Definition at line 107 of file tabulated.c.

108 {
109  static gen_chunk c[2];
110  static struct intlist il;
111 
113 
114  c[0].i = Tabulated_bp-Domains;
115  c[1].p = gtp->table;
116 
117  il.val = gtp->size; /* max_tabulated_elements() */
118  il.cdr = (struct intlist *) NULL;
119 
122 
123  return c;
124 }
struct gen_binding * Tabulated_bp
pointer to tabulated domain hack
Definition: genClib.c:58
struct gen_binding Domains[MAX_DOMAIN]
in build.c
Definition: genspec_yacc.c:114
union domain * domain
struct gen_binding * element
struct intlist * dimensions
struct domain::@6 ar

References domain::ar, domain::dimensions, gen_binding::domain, Domains, domain::element, get_tabulated_from_domain(), gen_chunk::i, gen_chunk::p, and Tabulated_bp.

Referenced by gen_write_tabulated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_tabulated_from_domain()

static gen_tabulated_p get_tabulated_from_domain ( int  domain)
static

Definition at line 59 of file tabulated.c.

60 {
62  message_assert("domain is tabulated", IS_TABULATED(Domains+domain));
63  return Domains[domain].tabulated;
64 }
#define check_domain(dom)
#define IS_TABULATED(bp)
gen_tabulated_p tabulated
number of chunks to hold this data.

References check_domain, Domains, IS_TABULATED, message_assert, and gen_binding::tabulated.

Referenced by gen_clear_tabulated_element(), gen_delete_tabulated_name(), gen_filter_tabulated(), gen_find_tabulated(), gen_get_tabulated_name_basic(), gen_mapc_tabulated(), gen_put_tabulated(), gen_put_tabulated_name(), and gen_tabulated_fake_object_hack().

+ Here is the caller graph for this function:

◆ positive_number()

static void positive_number ( gen_chunk o)
static

Definition at line 234 of file tabulated.c.

235 {
236  message_assert("positive tabulated number", (o+1)->i>0);
237 }

References message_assert.

Referenced by gen_read_and_check_tabulated().

+ Here is the caller graph for this function: