PIPS
arguments.c File Reference
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri-util.h"
+ Include dependency graph for arguments.c:

Go to the source code of this file.

Functions

void print_homogeneous_arguments (list args, const char *variable_name(entity))
 Functions dealing with entity lists. More...
 
void dump_arguments (cons *args)
 entity_name is a macro, hence the code replication More...
 
consarguments_add_entity (cons *a, entity e)
 
consarguments_rm_entity (cons *a, entity e)
 
consarguments_union (cons *a1, cons *a2)
 cons * arguments_union(cons * a1, cons * a2): returns a = union(a1, a2) where a1 and a2 are lists of entities. More...
 
bool arguments_equal_p (list a1, list a2)
 Check the syntactic equality of lists a1 and a2. More...
 
bool entity_is_argument_p (entity e, cons *args)
 
list arguments_intersection (list a1, list a2)
 Build a new list with all entities occuring in both a1 and a2. More...
 
bool arguments_set_equal_p (list a1, list a2)
 Set equality of lists a1 and a2. More...
 
bool arguments_subset_p (list a1, list a2)
 Check if a1 is a subset of a2. More...
 
void free_arguments (cons *args)
 
consdup_arguments (cons *args)
 
consarguments_difference (cons *a1, cons *a2)
 set difference: a1 - a2 ; similar to set intersection More...
 
list base_to_entities (Pvecteur b)
 generate a Newgen list with all entities refered in vector b More...
 

Function Documentation

◆ arguments_add_entity()

cons* arguments_add_entity ( cons a,
entity  e 
)

Definition at line 85 of file arguments.c.

88 {
89  if(!entity_is_argument_p(e, a))
90  a = gen_nconc(a, CONS(ENTITY, e, NIL));
91  return a;
92 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
#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 ENTITY(x)
ENTITY.
Definition: ri.h:2755

References CONS, ENTITY, entity_is_argument_p(), gen_nconc(), and NIL.

Referenced by add_alternate_return(), add_ghost_variable_entity(), add_index_bound_conditions(), AddEffectiveFormalParameter(), AddEntryEntity(), AddEntryLabel(), args_to_transformer(), arguments_union(), comp_regions_of_implied_do(), ComputeAddresses(), effects_to_arguments(), filter_transformer(), fortran_user_call_to_transformer(), generic_transformer_intra_to_inter(), precondition_intra_to_inter(), ProcessEntry(), recompute_loop_transformer(), safe_transformer_projection(), transformer_add_identity(), transformer_add_loop_index_incrementation(), transformer_add_modified_variable(), transformer_add_modified_variable_entity(), transformer_add_value_update(), transformer_add_variable_incrementation(), transformer_add_variable_update(), transformer_combine(), transformer_list_generic_transitive_closure(), transformer_projection_with_redundancy_elimination_and_check(), translate_global_value(), update_common_sizes(), and update_cp_with_rhs_to_transformer().

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

◆ arguments_difference()

cons* arguments_difference ( cons a1,
cons a2 
)

set difference: a1 - a2 ; similar to set intersection

should gen_nconc be used ?!? Or is it only useful to chain stuff at the end of a list?

Parameters
a11
a22

Definition at line 233 of file arguments.c.

236 {
237  cons * a = NIL;
238  MAPL(ca1, {
239  entity e1 = ENTITY(CAR(ca1));
240  if(!entity_is_argument_p(e1, a2))
241  /* should gen_nconc be used ?!? Or is it only useful to
242  chain stuff at the end of a list? */
243  a = CONS(ENTITY, e1, a);
244  },
245  a1);
246  return a;
247 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#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
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, CONS, ENTITY, entity_is_argument_p(), MAPL, and NIL.

Referenced by dump_common_layout(), precondition_intra_to_inter(), print_C_common_layout(), print_common_layout(), recompute_loop_transformer(), region_exact_projection_along_parameters(), regions_transformer_apply(), statement_to_postcondition(), statement_to_total_precondition(), transformer_filter(), and transformer_list_multiple_closure_to_precondition().

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

◆ arguments_equal_p()

bool arguments_equal_p ( list  a1,
list  a2 
)

Check the syntactic equality of lists a1 and a2.

To check the equality of a1 and a2 as sets, use argument intersection and a cardinal equality, assuming no entity occurs more than once in a1 or a2.

Parameters
a11
a22

Definition at line 139 of file arguments.c.

140 {
141  list ca1;
142  list ca2;
143 
144  for( ca1 = a1, ca2 = a2; !ENDP(ca1) && !ENDP(ca2); POP(ca1), POP(ca2))
145  if(ENTITY(CAR(ca1))!=ENTITY(CAR(ca2))) break;
146 
147  return ENDP(ca1) && ENDP(ca2);
148 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59

References CAR, ENDP, ENTITY, and POP.

◆ arguments_intersection()

list arguments_intersection ( list  a1,
list  a2 
)

Build a new list with all entities occuring in both a1 and a2.

should gen_nconc be used ?!? Or is it only useful to chain stuff at the end of a list?

Parameters
a11
a22

Definition at line 158 of file arguments.c.

159 {
160  list a = NIL;
161  FOREACH(ENTITY, e1, a1) {
162  if(entity_is_argument_p(e1, a2))
163  /* should gen_nconc be used ?!? Or is it only useful to
164  chain stuff at the end of a list? */
165  a = CONS(ENTITY, e1, a);
166  }
167 
168  return a;
169 }
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179

References CONS, ENTITY, entity_is_argument_p(), FOREACH, and NIL.

Referenced by loop_fully_unrollable_p(), region_exact_projection_along_parameters(), and transformer_general_intersection().

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

◆ arguments_rm_entity()

cons* arguments_rm_entity ( cons a,
entity  e 
)

Definition at line 94 of file arguments.c.

97 {
98  if(entity_is_argument_p(e, a)) {
99  gen_remove(&a, e);
100  }
101  else {
102  pips_internal_error("entity %s is not in a",
103  entity_name(e));
104  }
105 
106  return a;
107 }
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define pips_internal_error
Definition: misc-local.h:149
#define entity_name(x)
Definition: ri.h:2790

References entity_is_argument_p(), entity_name, gen_remove(), and pips_internal_error.

Referenced by reify_ghost_variable_entity(), and rm_live_loop_index().

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

◆ arguments_set_equal_p()

bool arguments_set_equal_p ( list  a1,
list  a2 
)

Set equality of lists a1 and a2.

Check that all entities in a1 also occur in a2 and vice-versa.

Might be faster to use the intersection and its cardinal...

This algorithm is correct if an entity can appear several times in a list.

Could be implemented with two calls to arguments_subset_p()

Parameters
a11
a22

Definition at line 181 of file arguments.c.

182 {
183  bool set_equal_p = true;
184 
185  FOREACH(ENTITY, e1, a1) {
186  if(!entity_is_argument_p(e1, a2)) {
187  set_equal_p = false;
188  break;
189  }
190  }
191  if(set_equal_p) {
192  FOREACH(ENTITY, e2, a2) {
193  if(!entity_is_argument_p(e2, a1)) {
194  set_equal_p = false;
195  break;
196  }
197  }
198  }
199 
200  return set_equal_p;
201 }
bool set_equal_p(const set, const set)
returns whether s1 == s2
Definition: set.c:316

References ENTITY, entity_is_argument_p(), FOREACH, and set_equal_p().

Referenced by transformer_combine().

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

◆ arguments_subset_p()

bool arguments_subset_p ( list  a1,
list  a2 
)

Check if a1 is a subset of a2.

Parameters
a11
a22

Definition at line 204 of file arguments.c.

205 {
206  bool subset_p = true;
207 
208  FOREACH(ENTITY, e1, a1) {
209  if(!entity_is_argument_p(e1, a2)) {
210  subset_p = false;
211  break;
212  }
213  }
214 
215  return subset_p;
216 }

References ENTITY, entity_is_argument_p(), and FOREACH.

Referenced by transformer_list_multiple_closure_to_precondition().

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

◆ arguments_union()

cons* arguments_union ( cons a1,
cons a2 
)

cons * arguments_union(cons * a1, cons * a2): returns a = union(a1, a2) where a1 and a2 are lists of entities.

A new list is allocated.

Entities in a1 have the same rank wrt a1 and a. Entities in a2 are likely to have different ranks wrt a and a2. This might imply a transformer renaming.

Parameters
a11
a22

Definition at line 116 of file arguments.c.

119 {
120  cons * a;
121 
122  if(a1==a2) {
123  a = (cons *) gen_copy_seq(a1);
124  }
125  else {
126  a = (cons *) gen_copy_seq(a1);
127  MAPL(ce, {a = arguments_add_entity(a, ENTITY(CAR(ce)));}, a2);
128  }
129 
130  return a;
131 }
cons * arguments_add_entity(cons *a, entity e)
Definition: arguments.c:85
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501

References arguments_add_entity(), CAR, ENTITY, gen_copy_seq(), and MAPL.

Referenced by add_index_bound_conditions(), dump_common_layout(), fortran_user_call_to_transformer(), print_C_common_layout(), print_common_layout(), and transformer_convex_hulls().

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

◆ base_to_entities()

list base_to_entities ( Pvecteur  b)

generate a Newgen list with all entities refered in vector b

Definition at line 250 of file arguments.c.

251 {
252  list el = NIL;
253  Pvecteur ev;
254 
255  for(ev = b; ev!=NULL; ev = ev->succ) {
256  entity e = (entity) vecteur_var(ev);
257  el = CONS(ENTITY, e, el);
258  }
259 
260  gen_nreverse(el);
261 
262  return el;
263 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
#define vecteur_var(v)

References CONS, ENTITY, gen_nreverse(), NIL, Svecteur::succ, and vecteur_var.

Referenced by transformer_intersect_range_with_domain().

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

◆ dump_arguments()

void dump_arguments ( cons args)

entity_name is a macro, hence the code replication

Parameters
argsrgs

Definition at line 69 of file arguments.c.

71 {
72  if(ENDP(args))
73  (void) fprintf(stderr, "(nil)\n");
74  else {
75  MAPL(c, {entity e = ENTITY(CAR(c));
76  (void) fprintf(stderr,
77  c==args ? "%s" : ", %s",
79  "entity_undefined" : entity_name(e));},
80  args);
81  (void) putc('\n',stderr);
82  }
83 }
#define entity_undefined
Definition: ri.h:2761
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References CAR, ENDP, ENTITY, entity_name, entity_undefined, fprintf(), and MAPL.

Referenced by dump_live_loop_indices(), EndOfProcedure(), MakeEntry(), precondition_intra_to_inter(), ProcessEntry(), transformer_filter(), TranslateEntryFormals(), and variable_in_module_p2().

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

◆ dup_arguments()

cons* dup_arguments ( cons args)

should be a macro later, but keep debugging in mind!

Parameters
argsrgs

Definition at line 225 of file arguments.c.

227 {
228  /* should be a macro later, but keep debugging in mind! */
229  return gen_copy_seq(args);
230 }

References gen_copy_seq().

Referenced by recompute_loop_transformer(), transformer_equality_fix_point(), and transformer_general_intersection().

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

◆ entity_is_argument_p()

bool entity_is_argument_p ( entity  e,
cons args 
)
Parameters
argsrgs

Definition at line 150 of file arguments.c.

153 {
154  return gen_find_eq(e, args) != chunk_undefined;
155 }
#define chunk_undefined
obsolete
Definition: genC.h:79
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422

References chunk_undefined, and gen_find_eq().

Referenced by add_type_information(), any_assign_operation_to_transformer(), any_scalar_assign_to_transformer_list(), any_scalar_assign_to_transformer_without_effect(), arguments_add_entity(), arguments_difference(), arguments_intersection(), arguments_rm_entity(), arguments_set_equal_p(), arguments_subset_p(), assigned_expression_to_transformer(), assigned_expression_to_transformer_list(), call_instruction_to_communications(), ComputeAddresses(), do_kernelize(), filter_transformer(), find_field_in_field_list(), FindOrCreateCurrentEntity(), fortran_user_call_to_transformer(), generic_apply_effect_to_transformer(), ghost_variable_entity_p(), IsEffectiveFormalParameterP(), live_loop_index_p(), loop_nest_movement_generation(), loop_nest_to_local_variables(), MakeEntry(), module_to_all_declarations(), redeclaration_enter_statement(), reify_ghost_variable_entity(), safe_transformer_projection(), SafeFindOrCreateEntity(), SaveEntity(), substitute_scalar_stub_in_transformer(), substitute_stubs_in_transformer_with_translation_binding(), transformer_combine(), transformer_convex_hulls(), transformer_general_consistency_p(), transformer_list_generic_transitive_closure(), transformer_list_preserved_variables(), transformer_list_safe_variables_projection(), transformer_list_with_effect(), translate_global_value(), variable_in_module_p(), and variable_in_module_p2().

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

◆ free_arguments()

void free_arguments ( cons args)

should be a macro later, but keep debugging in mind!

Parameters
argsrgs

Definition at line 218 of file arguments.c.

220 {
221  /* should be a macro later, but keep debugging in mind! */
222  gen_free_list(args);
223 }
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327

References gen_free_list().

Referenced by add_formal_to_actual_bindings(), atom_cse_expression(), formal_and_actual_parameters_association(), fortran_user_call_to_transformer(), move_transformer(), reset_live_loop_indices(), test_to_transformer(), test_to_transformer_list(), transformer_combine(), transformer_filter(), and transformer_normalize().

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

◆ print_homogeneous_arguments()

void print_homogeneous_arguments ( list  args,
const char *  variable_nameentity 
)

Functions dealing with entity lists.

arguments.c

Called "arguments" because the package was developped within the transformer library where entity lists were used to represent transformer arguments. No specific link with transformers. Now used here and there and moved into ri-util. package "arguments"

Basic routines dealing with the arguments field of transformers (i.e. list of entities, so it should be put in ri-util like many such packages written for pips)

Hash tables were not used because the argument lists are very short

Francois Irigoin, April 1990

Parameters
argsrgs
variable_nameariable_name

Definition at line 54 of file arguments.c.

55 {
56  if(ENDP(args))
57  (void) fprintf(stderr, "(nil)\n");
58  else {
59  MAPL(c, {entity e = ENTITY(CAR(c));
60  (void) fprintf(stderr,
61  c==args ? "%s" : ", %s",
62  e==entity_undefined? "entity_undefined" : variable_name(e));},
63  args);
64  (void) putc('\n',stderr);
65  }
66 }
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73

References CAR, ENDP, ENTITY, entity_undefined, fprintf(), MAPL, and variable_name().

Referenced by fprint_transformer(), and print_arguments().

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