PIPS
Psc.c File Reference
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "misc.h"
#include "newgen.h"
+ Include dependency graph for Psc.c:

Go to the source code of this file.

Macros

#define error(fun, msg)
 NewGen interface with C3 type Psysteme for PIPS project. More...
 

Functions

void sc_gen_write (FILE *fd, Psysteme s)
 Psc.c. More...
 
Psysteme sc_gen_read (FILE *fd, int(*f)())
 
void sc_gen_free (Psysteme s)
 
Psysteme sc_gen_copy_tree (Psysteme s)
 
int sc_gen_allocated_memory (Psysteme s)
 

Macro Definition Documentation

◆ error

#define error (   fun,
  msg 
)
Value:
{ \
fprintf(stderr, "pips internal error in %s: %s\n", fun, msg); exit(2); \
}
#define exit(code)
Definition: misc-local.h:54

NewGen interface with C3 type Psysteme for PIPS project.

Systems of linear equalities and inequalities are stored as a triplet, a base followed by two vector lists, the sets of equalities and inequalities: (b leq lineq).

Each vector list is also parenthesized: (v1 v2 v3). Each vector itself (see Pvecteur.c) is a parenthesized list of couples value/variable.

For instance, the empty system (the whole space as defined by basis b) is: (b()()) where basis vector b is stored as a regular vector (see Pvecteur.c).

To cope with the absence of unget() for f(), each vectors in the list is separated by a space.

Redundant information, the number of equalities and the number of inequalities and the system dimension, is discarded.

Francois Irigoin, November 1990 Sigh, sigh, sigh:

  • either ri-util.h must be included, as well as all underlaying libraries
  • or vect_gen_read() and vect_gen_write() must be locally declared, at the risk of a future inconsistency sigh no more, lady, sigh no more, man, who decieves ever, one foot in sea, and one on shore, to one thing, constant never. so sigh not so, but let them go, and be your blith ...
  • I forgot some part of it I guess. FC

Definition at line 78 of file Psc.c.

Function Documentation

◆ sc_gen_allocated_memory()

int sc_gen_allocated_memory ( Psysteme  s)

Definition at line 208 of file Psc.c.

209 {
210  return contrainte_gen_allocated_memory(sc_egalites(s))
211  + contrainte_gen_allocated_memory(sc_inegalites(s))
212  + vect_gen_allocated_memory(sc_base(s))
213  + sizeof(Ssysteme) ;
214 }
int contrainte_gen_allocated_memory(Pcontrainte)
Definition: Pvecteur.c:176
int vect_gen_allocated_memory(Pvecteur)
Definition: Pvecteur.c:168
struct Ssysteme Ssysteme

References contrainte_gen_allocated_memory(), and vect_gen_allocated_memory().

Referenced by initialize_newgen().

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

◆ sc_gen_copy_tree()

Psysteme sc_gen_copy_tree ( Psysteme  s)

Definition at line 203 of file Psc.c.

204 {
205  return sc_copy(s);
206 }
Psysteme sc_copy(Psysteme ps)
Psysteme sc_copy(Psysteme ps): duplication d'un systeme (allocation et copie complete des champs sans...
Definition: sc_alloc.c:230

References sc_copy().

Referenced by initialize_newgen(), and main().

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

◆ sc_gen_free()

void sc_gen_free ( Psysteme  s)

Definition at line 198 of file Psc.c.

199 {
200  sc_rm(s);
201 }
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277

References sc_rm().

Referenced by initialize_newgen(), and main().

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

◆ sc_gen_read()

Psysteme sc_gen_read ( FILE *  fd,
int(*)()  f 
)

It might be a good idea to check that the basis is consistent with the equalities and inequalities that were read, later...

FI: doesn't work because it's just the definition of transformer_identity

Parameters
fdignored

Definition at line 139 of file Psc.c.

140 {
141  Psysteme s = sc_new();
142  int c;
143 
144  if ((c = f()) != '(') {
145  error("sc_gen_read","initial '(' missing\n");
146  }
147 
148  s->base = vect_gen_read(fd, f);
149 
150  if ((c = f()) != '(') {
151  error("sc_gen_read","equalities '(' missing\n");
152  }
153 
154  while ((c = f()) != ')') {
155  Pvecteur v = vect_gen_read(fd, f);
157 
158  pips_assert("sc_gen_read", c==' ');
159 
160  sc_add_egalite(s, e);
161  }
162 
163  if ((c = f()) != '(') {
164  error("sc_gen_read","inequalities '(' missing\n");
165  }
166 
167  while ((c = f()) != ')') {
168  Pvecteur v = vect_gen_read(fd, f);
170 
171  pips_assert("sc_gen_read", c==' ');
172 
173  sc_add_inegalite(s, i);
174  }
175 
176  if ((c = f()) != ')') {
177  error("sc_gen_read","closing ')' missing\n");
178  }
179 
180  /* It might be a good idea to check that the basis is consistent
181  with the equalities and inequalities that were read, later... */
182 
183  s->dimension = vect_size(s->base);
184 
185  /* FI: doesn't work because it's just the definition of
186  transformer_identity */
187  /*
188  if(s->dimension == 0) {
189  pips_assert("sc_gen_read", s->nb_eq == 0 && s->nb_ineq == 0);
190  sc_rm(s);
191  s = SC_UNDEFINED;
192  }
193  */
194 
195  return s;
196 }
#define error(fun, msg)
NewGen interface with C3 type Psysteme for PIPS project.
Definition: Psc.c:78
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
Pvecteur vect_gen_read(FILE *, int(*)(void))
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89

References Ssysteme::base, contrainte_make(), Ssysteme::dimension, error, f(), pips_assert, sc_add_egalite(), sc_add_inegalite(), sc_new(), vect_gen_read(), and vect_size().

+ Here is the call graph for this function:

◆ sc_gen_write()

void sc_gen_write ( FILE *  fd,
Psysteme  s 
)

Psc.c.

FI: we cannot not store SC_UNDEFINED as it is used in regions; we cannot store it like a system with an empty basis, no inequalities and no equalities because it is used to define transformer identity; conclusion: region library has to be changed and to use transformer_undefined as context

Current kludge: SC_UNDEFINED is stored but retrieved as a system with 0 equalities and 0 inequalities over a space of dimension 0

Parameters
fdd

Definition at line 82 of file Psc.c.

83 {
84  Pcontrainte c;
85  Psysteme stored_s;
86  static Psysteme undefined_s = SC_UNDEFINED;
87 
88  /* FI: we cannot not store SC_UNDEFINED as it is used in regions;
89  we cannot store it like a system with an empty basis, no inequalities
90  and no equalities because it is used to define transformer identity;
91  conclusion: region library has to be changed and to use
92  transformer_undefined as context
93 
94  Current kludge: SC_UNDEFINED is stored but retrieved as a system
95  with 0 equalities and 0 inequalities over a space of dimension 0
96  */
97  if(SC_UNDEFINED_P(s)) {
98  if(SC_UNDEFINED_P(undefined_s))
100  stored_s = undefined_s;
101  }
102  else
103  stored_s = s;
104 
105  pips_assert("sc_gen_write",!SC_UNDEFINED_P(stored_s));
106 
107  /*
108  ifdebug(10){
109  fprintf(stderr, "[sc_gen_write] sys 0x%x\n", (unsigned int) s);
110  syst_debug(s); }
111  */
112 
113  (void) fputc('(',fd);
114 
115  vect_gen_write(fd,stored_s->base);
116 
117  (void) fputc('(',fd);
118 
119  for (c = stored_s->egalites; c != NULL; c = c->succ) {
120  (void) fputc(' ', fd);
121  vect_gen_write(fd,c->vecteur);
122  }
123 
124  (void) fputc(')',fd);
125 
126  (void) fputc('(',fd);
127 
128  for (c = stored_s->inegalites; c != NULL; c = c->succ) {
129  (void) fputc(' ', fd);
130  vect_gen_write(fd, c->vecteur);
131  }
132 
133  (void) fputc(')',fd);
134 
135  (void) fputc(')',fd);
136 
137 }
#define CONTRAINTE_UNDEFINED
void vect_gen_write(FILE *, Pvecteur)
Pvecteur.c.
Definition: Pvecteur.c:108
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70

References Ssysteme::base, CONTRAINTE_UNDEFINED, Ssysteme::egalites, Ssysteme::inegalites, pips_assert, sc_make(), Scontrainte::succ, vect_gen_write(), and Scontrainte::vecteur.

Referenced by initialize_newgen(), and main().

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