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

Go to the source code of this file.

Functions

list cell_relations_generic_binary_op (list l1, list l2, bool(*cr1_cr2_combinable_p)(cell_relation, cell_relation), list(*cr1_cr2_binary_op)(cell_relation, cell_relation), list(*cr1_unary_op)(cell_relation), list(*cr2_unary_op)(cell_relation), list(*union_op)(list, list))
 functions specific to cell_relations More...
 

Function Documentation

◆ cell_relations_generic_binary_op()

list cell_relations_generic_binary_op ( list  l1,
list  l2,
bool(*)(cell_relation, cell_relation cr1_cr2_combinable_p,
list(*)(cell_relation, cell_relation cr1_cr2_binary_op,
list(*)(cell_relation cr1_unary_op,
list(*)(cell_relation cr2_unary_op,
list(*)(list, list union_op 
)

functions specific to cell_relations

cell_relations.c

beware : modifies l1, l2 and their effects

Parameters
l1and l2 are two lists of cell_relations.
cr1_cr2_combinable_pis a bool function that takes two individual cell_relations as arguments and renders true when they are considered as combinable ;
cr1_cr2_binary_opis a binary operator that combines two individual cell_relations;
cr1_unary_opis a unary operators that deal with the remnants of l1, that is those cell_relations that are not combinable with any effect of l2;
cr2_unary_opis a unary operators that deal with the remnants of l2, that is those cell_relations that are not combinable with any effect of l1;
Returns
a list of cell_relations, combination of l1 and l2.

we first deal with the elements of l1 : those that are combinable with the elements of l2, and the others, which we call the remnants of l1

gen_remove(&l2, EFFECT(CAR(l_cr2)));

cr1 belongs to the remnants of l1 : it is combinable with no effects of l2

we must then deal with the remnants of l2

no memory leaks: l1 and l2 won't be used anymore

Parameters
l11
l22

Definition at line 59 of file cell_relations.c.

67 {
68  list l_res = NIL;
69  list l_cr1 = list_undefined;
70  list l_cr2 = list_undefined;
71 
72  debug_on("CELL_RELATIONS_OPERATORS_DEBUG_LEVEL");
73 
74  pips_debug_pvs(1, "l1:\n", l1);
75  pips_debug_pvs(1, "l2:\n", l2);
76 
77  /* we first deal with the elements of l1 : those that are combinable with
78  * the elements of l2, and the others, which we call the remnants of l1 */
79  for(l_cr1 = l1; !ENDP(l_cr1); POP(l_cr1))
80  {
81  cell_relation cr1 = CELL_RELATION(CAR(l_cr1));
82  list prec_l_cr2 = NIL;
83  bool combinable = false;
84 
85  pips_debug_pv(2, "dealing with cr1:\n", cr1);
86 
87  l_cr2 = l2;
88  while(!ENDP(l_cr2))
89  {
90  cell_relation cr2 = CELL_RELATION(CAR(l_cr2));
91 
92  pips_debug_pv(2, "considering cr2:\n", cr2);
93 
94  if ( (*cr1_cr2_combinable_p)(cr1,cr2) )
95  {
96  pips_debug(2, "combinable\n");
97  combinable = true;
98  list l_res_tmp = (*cr1_cr2_binary_op)(cr1,cr2);
99  l_res = (*union_op)(l_res, l_res_tmp);
100 
101  /* gen_remove(&l2, EFFECT(CAR(l_cr2))); */
102  if (prec_l_cr2 != NIL)
103  CDR(prec_l_cr2) = CDR(l_cr2);
104  else
105  l2 = CDR(l_cr2);
106 
107  free(l_cr2); l_cr2 = NIL;
108  /* */
109  //free_cell_relation(cr1); cr1=cell_relation_undefined;
111  }
112  else
113  {
114  pips_debug(2, "not combinable\n");
115  prec_l_cr2 = l_cr2;
116  l_cr2 = CDR(l_cr2);
117  }
118  }
119 
120  pips_debug_pvs(2, "intermediate l_res 1:\n", l_res);
121 
122  if(!combinable)
123  {
124  /* cr1 belongs to the remnants of l1 : it is combinable
125  * with no effects of l2 */
126  if ( (*cr1_cr2_combinable_p)(cr1,cell_relation_undefined) )
127  l_res = gen_nconc(l_res, (*cr1_unary_op)(cr1));
128  }
129  else
130  {
132  }
133  }
134 
135  pips_debug_pvs(2, "intermediate l_res 2:\n", l_res);
136 
137  /* we must then deal with the remnants of l2 */
138  for(l_cr2 = l2; !ENDP(l_cr2); POP(l_cr2))
139  {
140  cell_relation cr2 = CELL_RELATION(CAR(l_cr2));
141 
142  if ( (*cr1_cr2_combinable_p)(cell_relation_undefined,cr2) )
143  l_res = gen_nconc(l_res, (*cr2_unary_op)(cr2));
144  }
145 
146  pips_debug_pvs(1, "final pvs:\n", l_res);
147 
148  /* no memory leaks: l1 and l2 won't be used anymore */
149  gen_free_list(l1);
150  gen_free_list(l2);
151 
152  debug_off();
153 
154  return l_res;
155 }
void free_cell_relation(cell_relation p)
Definition: effects.c:308
#define pips_debug_pv(level, message, pv)
#define pips_debug_pvs(level, message, l_pv)
#define CELL_RELATION(x)
CELL_RELATION.
Definition: effects.h:479
#define cell_relation_undefined
Definition: effects.h:485
void free(void *)
#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
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#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
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, CDR, CELL_RELATION, cell_relation_undefined, debug_off, debug_on, ENDP, free(), free_cell_relation(), gen_free_list(), gen_nconc(), list_undefined, NIL, pips_debug, pips_debug_pv, pips_debug_pvs, and POP.

Referenced by simple_pvs_may_union(), and simple_pvs_must_union().

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