PIPS
utils.c File Reference
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrix.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "constants.h"
#include "paf_ri.h"
#include "graph.h"
#include "dg.h"
#include "text.h"
#include "text-util.h"
#include "misc.h"
#include "paf-util.h"
#include "static_controlize.h"
+ Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define STRING_FOUR_OPERATION_P(s)
 Macro functions. More...
 
#define ENTITY_FOUR_OPERATION_P(s)   (ENTITY_PLUS_P(s) || ENTITY_MINUS_P(s) || ENTITY_MULTIPLY_P(s) || ENTITY_DIVIDE_P(s))
 
#define MINMAX_REF_NAME   "MMREF"
 

Typedefs

typedef dfg_arc_label arc_label
 Name : utils.c Package : paf-util Author : Alexis Platonoff Date : july 1993. More...
 
typedef dfg_vertex_label vertex_label
 

Functions

statement_mapping get_current_stco_map (void)
 ======================================================================== More...
 
void pu_matrices_to_contraintes (Pcontrainte *pc, Pbase b, matrice A, matrice B, int n, int m)
 Global variables
More...
 
void pu_contraintes_to_matrices (Pcontrainte pc, Pbase b, matrice A, matrice B, int n, int m)
 =========================================================================== More...
 
void contraintes_with_sym_cst_to_matrices (Pcontrainte pc, Pbase index_base, Pbase const_base, matrice A, matrice B, int n, int m1, int m2)
 Creation de la matrice A correspondant au systeme lineaire et de la matrice correspondant a la partie constante B Le systeme peut contenir des constantes symboliques. More...
 
void matrices_to_contraintes_with_sym_cst (Pcontrainte *pc, Pbase index_base, Pbase const_base, matrice A, matrice B, int n, int m1, int m2)
 
vertex in_dfg_vertex_list (list l, vertex v)
 =========================================================================== More...
 
vertex in_dg_vertex_list (list l, vertex v)
 ====================================================================== More...
 
expression make_id_expression (string s)
 =========================================================================== More...
 
expression make_array_ref (list l)
 =========================================================================== More...
 
expression make_func_op (string func_name, list args)
 =========================================================================== More...
 
expression lisp_exp_to_ri_exp (lisp_expression le)
 =========================================================================== More...
 
expression negate_expression (expression exp)
 =========================================================================== More...
 
predicate expressions_to_predicate (list exp_l)
 =========================================================================== More...
 
int vertex_int_stmt (vertex v)
 =========================================================================== More...
 
void comp_exec_domain (graph g, hash_table STS)
 =========================================================================== More...
 
Psysteme make_expression_equalities (list le)
 =========================================================================== More...
 
static list find_el_with_num (int stmt)
 =========================================================================== More...
 
Pbase make_base_of_nest (int stmt)
 =========================================================================== More...
 
successor first_succ_of_vertex (vertex v)
 =========================================================================== More...
 
dataflow first_df_of_succ (successor s)
 =========================================================================== More...
 
loop loop_dup (loop l)
 =========================================================================== More...
 
list static_control_to_indices (static_control stct)
 package mapping : Alexis Platonoff, july 1993 More...
 
Pvecteur polynome_to_vecteur (Ppolynome pp)
 ======================================================================== More...
 
Pcontrainte polynome_to_contrainte (Ppolynome pp)
 ======================================================================== More...
 
Psysteme old_polynome_to_sc (Ppolynome pp, list l)
 =========================================================================== More...
 
Psysteme polynome_to_sc (Ppolynome pp, list l)
 =========================================================================== More...
 
void substitute_var_with_vec (Psysteme ps, entity var, Value val, Pvecteur vec)
 =========================================================================== More...
 
bool is_entity_in_list_p (entity e, list l)
 =========================================================================== More...
 
Psysteme elim_var_with_eg (Psysteme ps, list *init_l, list *elim_l)
 =========================================================================== More...
 
Psysteme better_elim_var_with_eg (Psysteme ps, list *init_l, list *elim_l)
 =========================================================================== More...
 
bool single_var_vecteur_p (Pvecteur pv)
 =========================================================================== More...
 
list vecteur_to_list (Pvecteur v)
 =========================================================================== More...
 
Ppolynome old_vecteur_to_polynome (Pvecteur vec)
 =========================================================================== More...
 
list meld (list l1, list l2, bool(*compare_obj)())
 =========================================================================== More...
 
static int compare_objects (gen_chunk **p1, gen_chunk **p2)
 
list new_general_merge_sort (list l, bool(*compare_obj)())
 no way validate Prgm_mapping with this function... More...
 
list general_merge_sort (list l, bool(*compare_obj)())
 I guess there is some kind of memory leaks here... More...
 
expression rational_op_exp (string op_name, expression exp1, expression exp2)
 ======================================================================== More...
 
Pvecteur vect_var_subst (Pvecteur vect, Variable var, Pvecteur new_vect)
 ================================================================= More...
 
Ppolynome prototype_var_subst (Ppolynome pp, Variable var, Ppolynome ppsubst)
 ================================================================= More...
 
Ppolynome vecteur_mult (Pvecteur v1, Pvecteur v2)
 ======================================================================== More...
 
Pvecteur prototype_factorize (Ppolynome pp, Variable var)
 ======================================================================== More...
 
Pcontrainte simplify_minmax_contrainte (Pcontrainte pc, Psysteme ps_cont, int min_or_max)
 ================================================================== More...
 
list vectors_to_expressions (Pcontrainte pc)
 ================================================================= More...
 
Pcontrainte expressions_to_vectors (list lexp)
 ================================================================= More...
 
list simplify_minmax (list lexp, Psysteme ps_cont, int min_or_max)
 ================================================================= More...
 
Psysteme find_implicit_equation (Psysteme ps)
 ======================================================================== More...
 
void set_current_stco_map (statement_mapping scm)
 ======================================================================== More...
 
void reset_current_stco_map (void)
 ======================================================================== More...
 
static_control get_stco_from_current_map (statement s)
 ======================================================================== More...
 
expression make_rational_exp (Pvecteur v, Value d)
 ===================================================================== More...
 
int stco_common_loops_of_statements (statement_mapping in_map, statement in_s, statement in_s2)
 AP, sep 25th 1995 : I have added a function from static_controlise/utils.c. More...
 

Variables

static bool(* bool_compare_objects )()
 =========================================================================== More...
 
static statement_mapping current_stco_map = hash_table_undefined
 These three functions respectively initialize, return and reset the static map of the static control on the statements. More...
 

Macro Definition Documentation

◆ ENTITY_FOUR_OPERATION_P

#define ENTITY_FOUR_OPERATION_P (   s)    (ENTITY_PLUS_P(s) || ENTITY_MINUS_P(s) || ENTITY_MULTIPLY_P(s) || ENTITY_DIVIDE_P(s))

Definition at line 107 of file utils.c.

◆ MINMAX_REF_NAME

#define MINMAX_REF_NAME   "MMREF"

Definition at line 2121 of file utils.c.

◆ STRING_FOUR_OPERATION_P

#define STRING_FOUR_OPERATION_P (   s)
Value:
( \
(strcmp(s,PLUS_OPERATOR_NAME) == 0) || \
(strcmp(s,MINUS_OPERATOR_NAME) == 0) || \
(strcmp(s,MULTIPLY_OPERATOR_NAME) == 0) || \
(strcmp(s,DIVIDE_OPERATOR_NAME) == 0) )
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define DIVIDE_OPERATOR_NAME
#define MULTIPLY_OPERATOR_NAME

Macro functions.

Definition at line 102 of file utils.c.

Typedef Documentation

◆ arc_label

Name : utils.c Package : paf-util Author : Alexis Platonoff Date : july 1993.

Historic :

Documents:

Comments : This file contains useful functions used for the computation of paf_ri. Ansi includes
include <varargs.h> (not ANSI but SUN:-) Newgen includes
C3 includes
Pips includes

Definition at line 88 of file utils.c.

◆ vertex_label

Definition at line 89 of file utils.c.

Function Documentation

◆ better_elim_var_with_eg()

Psysteme better_elim_var_with_eg ( Psysteme  ps,
list init_l,
list elim_l 
)

===========================================================================

Psysteme better_elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l): Computes the elimination of variables in the system "ps" using its equalities. All the used equalities are removed directly from "ps".

However, we keep all these "used" equalities in "sc_elim". The return value of this function is this system.

Initially, "init_l" gives the list of variables that can be eliminated and "elim_l" is empty. At the end, "init_l" contains the variables that are not eliminated and "elim_l" contains the variables that are eliminated. We keep the order of "init_l" in our process of elimination.

At the end, to each equality of "sc_elim" will be associated a variable of "elim_l". These lists are built so as to be able to match them directly. Each variable of "elim_l" appears in one constraint of "sc_elim" and only one. There will be as many equalities in "sc_elim" as variables in "elim_l"

A variable can be eliminated using a given equality if it appears in this equality, i.e. its associated coefficient is not equal to zero. Moreover, for a given variable, we look for the equation in which it has the smallest coefficient.

Algo:

BEGIN vl = a copy of init_l; el = NIL; sc_elim = system with no constraints; loop over the list of variables to eliminate vl v = current variable; eq = the equality of ps in which the coefficient of v is the smallest if eq is not NULL eq is taken off the list of equalities of ps loop over the list of equalities of ps eg = current equality substitute in eg the value of v given by eq end loop loop over the list of inequalities of ps eg = current inequality substitute in eg the value of v given by eq end loop loop over the list of equalities of sc_elim eg = current equality substitute in eg the value of v given by eq end loop loop over the list of inequalities of sc_elim eg = current inequality substitute in eg the value of v given by eq end loop add eq in the list of equalities of sc_elim remove v from init_l add v in el end if end loop

elim_l = el END

Note: Here is how we "substitute in eg the value of v given by eq": if eg and eq are as follows (Vaux and Vsub do not contained v): eg <=> c*v + Vaux = 0 eq <=> val*v = Vsub let p = gcd(val,c) after the substitution, we have: eg <=> (c/p)*Vsub + (val/p)*Vaux = 0

During the computation, we modify *init_l, so we duplicate it. We use "el" not *elim_l, which should be empty at the beginning.

si eq etait en tete il faut l'enlever de la liste, sinon, eq a ete enleve par la fonction contrainte_var_min_coeff().

Parameters
pss
init_lnit_l
elim_llim_l

Definition at line 1537 of file utils.c.

1540 {
1541  Psysteme sc_elim = sc_new();
1542 
1543  /* During the computation, we modify *init_l, so we duplicate it.
1544  * We use "el" not *elim_l, which should be empty at the beginning.
1545  */
1546  list vl = gen_append(*init_l, NIL),
1547  el = NIL,
1548  l;
1549  Pcontrainte eq, eg;
1550 
1551  for(l = vl; !ENDP(l); POP(l)) {
1552  Variable v = (Variable) ENTITY(CAR(l));
1553  Value coeff;
1554 
1555  if ((eq = contrainte_var_min_coeff(ps->egalites,v, &coeff, true))
1556  != NULL) {
1557 
1558  if(get_debug_level() > 7) {
1559 fprintf(stderr, "System is :");
1560 fprint_psysteme(stderr, ps);
1561 fprintf(stderr, "\t\tElim var %s in equation:", entity_local_name((entity) v));
1562 pu_vect_fprint(stderr, eq->vecteur);
1563 fprintf(stderr, "\n");
1564  }
1565 
1566  if(!egalite_normalize(eq))
1567  pips_internal_error("Strange equality");
1568 
1569  sc_nbre_egalites(ps)--;
1570  if (eq == (ps->egalites)) ps->egalites = eq->succ;
1571  /* si eq etait en tete il faut l'enlever de la liste, sinon, eq a
1572  ete enleve par la fonction contrainte_var_min_coeff(). */
1573 
1574  for(eg = ps->egalites; eg != NULL; eg = eg->succ)
1575  (void) contrainte_subst_ofl_ctrl(v, eq, eg, true, NO_OFL_CTRL);
1576  for(eg = ps->inegalites; eg != NULL; eg = eg->succ)
1577  (void) contrainte_subst_ofl_ctrl(v, eq, eg, false, NO_OFL_CTRL);
1578 
1579  for(eg = sc_elim->egalites; eg != NULL; eg = eg->succ)
1580  (void) contrainte_subst_ofl_ctrl(v, eq, eg, true, NO_OFL_CTRL);
1581  for(eg = sc_elim->inegalites; eg != NULL; eg = eg->succ)
1582  (void) contrainte_subst_ofl_ctrl(v, eq, eg, false, NO_OFL_CTRL);
1583 
1584  sc_add_egalite(sc_elim, eq);
1585  gen_remove(init_l, (void *) v);
1586  el = CONS(ENTITY, (entity) v, el);
1587  }
1588  }
1589 
1590  *elim_l = el;
1591  sc_elim->base = NULL;
1592  sc_creer_base(sc_elim);
1593 
1594  ifdebug(7) {
1595 fprintf(stderr, "[new_elim_var_with_eg] Results:\n");
1596 fprintf(stderr, "Elim sys:\n");
1597 fprint_entity_list(stderr, el);
1598 fprint_psysteme(stderr, sc_elim);
1599 fprintf(stderr, "Remnants sys:\n");
1600 fprint_entity_list(stderr, *init_l);
1601 fprint_psysteme(stderr, ps);
1602 fprintf(stderr, "\n");
1603  }
1604 
1605  return(sc_elim);
1606 }
int Value
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c, bool eq_p, int ofl_ctrl)
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c Boolean eq_p,...
Definition: binaires.c:107
Pcontrainte contrainte_var_min_coeff(Pcontrainte, Variable, Value *, bool)
Pcontrainte contrainte_var_min_coeff(Pcontrainte contraintes, Variable v, int *coeff) input : a list ...
Definition: unaires.c:345
bool egalite_normalize(Pcontrainte)
bool egalite_normalize(Pcontrainte eg): reduction d'une equation diophantienne par le pgcd de ses coe...
Definition: normalize.c:136
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
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 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
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_append(list l1, const list l2)
Definition: list.c:471
void fprint_entity_list(FILE *fp, list l)
void fprint_entity_list(FILE *fp,list l): prints a list of entities on file fp.
Definition: entity.c:3188
#define pips_internal_error
Definition: misc-local.h:149
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void pu_vect_fprint(FILE *, Pvecteur)
===========================================================================
Definition: print.c:446
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
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
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
Pbase base
Definition: sc-local.h:75
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define NO_OFL_CTRL
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References Ssysteme::base, CAR, CONS, contrainte_subst_ofl_ctrl(), contrainte_var_min_coeff(), egalite_normalize(), Ssysteme::egalites, ENDP, ENTITY, entity_local_name(), eq, fprint_entity_list(), fprint_psysteme(), fprintf(), gen_append(), gen_remove(), get_debug_level(), ifdebug, Ssysteme::inegalites, NIL, NO_OFL_CTRL, pips_internal_error, POP, pu_vect_fprint(), sc_add_egalite(), sc_creer_base(), sc_new(), Scontrainte::succ, and Scontrainte::vecteur.

+ Here is the call graph for this function:

◆ comp_exec_domain()

void comp_exec_domain ( graph  g,
hash_table  STS 
)

===========================================================================

void comp_exec_domain(graph g, STS): computes the execution domain of each statement. The englobing loops are obtained through the static control map.

We update the graph global variable with the exec domain.

loop aux_loop = ENTITY(CAR(loop_l));

Parameters
STSTS

Definition at line 877 of file utils.c.

880 {
881  int stmt;
882  list loop_l, dfg_edge_l;
883 
884  /* We update the graph global variable with the exec domain. */
885  dfg_edge_l = graph_vertices(g);
886  for(; dfg_edge_l != NIL; dfg_edge_l = CDR(dfg_edge_l)) {
887  vertex v = VERTEX(CAR(dfg_edge_l));
888  dfg_vertex_label dvl;
889  Psysteme new_sc = sc_new();
890 
892  stmt = vertex_int_stmt(v);
894  (char *) ((long)stmt)));
895 
896  for( ; loop_l != NIL; loop_l = CDR(loop_l))
897  {
898  Pvecteur vect_index, vect;
899  normalized nub, nlb;
900  /* loop aux_loop = ENTITY(CAR(loop_l)); */
901  loop aux_loop = LOOP(CAR(loop_l));
902  entity index_ent = loop_index(aux_loop);
903 
904  vect_index = vect_new((char *) index_ent, VALUE_ONE);
905  nlb = NORMALIZE_EXPRESSION(range_lower(loop_range(aux_loop)));
906  nub = NORMALIZE_EXPRESSION(range_upper(loop_range(aux_loop)));
907 
908  if (normalized_linear_p(nlb))
909  {
910  vect = vect_substract((Pvecteur) normalized_linear(nlb), vect_index);
911  if(!VECTEUR_NUL_P(vect))
912  sc_add_inegalite(new_sc, contrainte_make(vect));
913  }
914  if (normalized_linear_p(nub))
915  {
916  vect = vect_substract(vect_index, (Pvecteur) normalized_linear(nub));
917  if(!VECTEUR_NUL_P(vect))
918  sc_add_inegalite(new_sc, contrainte_make(vect));
919  }
920  }
921  sc_creer_base(new_sc);
922 
924  }
925 }
predicate make_predicate(Psysteme a1)
Definition: ri.c:1820
static hash_table STS
The "STS" global variable is the hash table that maps the static_control on the statements.
Definition: adg_read_paf.c:155
#define VALUE_ONE
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#define vertex_vertex_label(x)
Definition: graph.h:152
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
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
int vertex_int_stmt(vertex v)
===========================================================================
Definition: utils.c:866
#define static_control_loops(x)
Definition: paf_ri.h:757
struct _newgen_struct_dfg_vertex_label_ * dfg_vertex_label
Definition: paf_ri.h:112
#define dfg_vertex_label_exec_domain(x)
Definition: paf_ri.h:415
#define NORMALIZE_EXPRESSION(e)
#define LOOP(x)
LOOP.
Definition: ri.h:1606
#define normalized_linear_p(x)
Definition: ri.h:1779
#define range_upper(x)
Definition: ri.h:2290
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
#define normalized_linear(x)
Definition: ri.h:1781
#define loop_index(x)
Definition: ri.h:1640
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
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Definition: statement.c:54
#define VECTEUR_NUL_P(v)
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75

References CAR, CDR, contrainte_make(), dfg_vertex_label_exec_domain, graph_vertices, hash_get(), LOOP, loop_index, loop_range, make_predicate(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, range_lower, range_upper, sc_add_inegalite(), sc_creer_base(), sc_new(), static_control_loops, STS, VALUE_ONE, vect_new(), vect_substract(), VECTEUR_NUL_P, VERTEX, vertex_int_stmt(), and vertex_vertex_label.

+ Here is the call graph for this function:

◆ compare_objects()

static int compare_objects ( gen_chunk **  p1,
gen_chunk **  p2 
)
static

Definition at line 1712 of file utils.c.

1714 {
1715  return(bool_compare_objects(*p2, *p1)-bool_compare_objects(*p1, *p2));
1716 }
static bool(* bool_compare_objects)()
===========================================================================
Definition: utils.c:1711

References bool_compare_objects.

Referenced by new_general_merge_sort().

+ Here is the caller graph for this function:

◆ contraintes_with_sym_cst_to_matrices()

void contraintes_with_sym_cst_to_matrices ( Pcontrainte  pc,
Pbase  index_base,
Pbase  const_base,
matrice  A,
matrice  B,
int  n,
int  m1,
int  m2 
)

Creation de la matrice A correspondant au systeme lineaire et de la matrice correspondant a la partie constante B Le systeme peut contenir des constantes symboliques.

Dans ce cas, la base index_base ne doit contenir que les variables etant des indices de boucles et la base const_base les constantes symboliques. La matrice B represente toutes les contraintes sur les constantes.

Les parametres de la fonction :

Psysteme ps : systeme lineaire !int A[] : matrice !int B[] : matrice int n : nombre de lignes de la matrice int m : nombre de colonnes de la matrice

Parameters
pcc
index_basendex_base
const_baseonst_base
m11
m22

Definition at line 446 of file utils.c.

452 {
453 
454  int i,j;
455  Pcontrainte eq;
456  Pvecteur pv;
457 
458  matrice_nulle(B,n,m2);
459  matrice_nulle(A,n,m1);
460 
461  for (eq = pc,i=1; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ,i++) {
462  for(pv = index_base, j=1; pv != NULL; pv = pv->succ, j++){
463  ACCESS(A,n,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur);
464  }
465  for(pv = const_base, j=1; pv != NULL; pv = pv->succ, j++){
466  ACCESS(B,n,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur);
467  }
468  ACCESS(B,n,i,m2) = vect_coeff(TCST,eq->vecteur);
469  }
470 
471 }
#define CONTRAINTE_UNDEFINED_P(c)
#define B(A)
Definition: iabrev.h:61
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
void matrice_nulle(matrice Z, int n, int m)
void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrice.c:311
Definition: pip__tab.h:25
struct Svecteur * succ
Definition: vecteur-local.h:92
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References ACCESS, B, CONTRAINTE_UNDEFINED_P, eq, matrice_nulle(), Scontrainte::succ, Svecteur::succ, TCST, vect_coeff(), Scontrainte::vecteur, and vecteur_var.

Referenced by broadcast_conditions(), system_inversion_restrict(), and vecteurs_libres_p().

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

◆ elim_var_with_eg()

Psysteme elim_var_with_eg ( Psysteme  ps,
list init_l,
list elim_l 
)

===========================================================================

Psysteme elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l): Computes the elimination of variables in the system "ps" using its equalities. All the used equalities are removed directly from "ps".

However, we keep all these "used" equalities in "sc_elim". The return value of this function is this system.

Initially, "init_l" gives the list of variables that can be eliminated and "elim_l" is empty. At the end, "init_l" contains the variables that are not eliminated and "elim_l" contains the variables that are eliminated.

At the end, to each equality of "sc_elim" will be associated a variable of "elim_l". These lists are built so as to be able to match them directly. Each variable of "elim_l" appears in one constraint of "sc_elim" and only one. There will be as many equalities in "sc_elim" as variables in "elim_l"

A variable can be eliminated using a given equality if it appears in this equality, i.e. its associated coefficient is not equal to zero. Moreover, it is easier to eliminate a variable with a value of 1 or -1. So, first we try to find such a variable.

Algo:

BEGIN vl = init_l; el = NIL; eqs = list of equalities of ps sc_elim = system with no constraints while eqs is not empty init_vec = vector of the first equality of eqs var_not_found = TRUE coeff_one_not_found = TRUE l = vl while coeff_one_not_found and l is not empty crt_var = first variable of l crt_val = its value in init_vec if crt_val is 1 or -1 coeff_one_not_found = FALSE var_not_found = FALSE (var, val) = (crt_var, crt_val) else if crt_val is not 0 and var_not_found var_not_found = FALSE (var, val) = (crt_var, crt_val) end if l = CDR(l) end while if var_not_found is false (means that a variable has been found) (var, val) = variable and its value to eliminate in init_vec remove var from vl add var to el pv_elim = val*var - init_vec substitute val*var by pv_elim in ps substitute val*var by pv_elim in sc_elim add init_vec to sc_elim eqs = new list of equalities of ps else eqs = CDR(eqs) end if end while init_l = vl elim_l = el END

Note: the substitution of val*var by pv_elim in a vector V uses the gcd: V = c*var + Vaux p = gcd(val,c) Vnew = (c/p)*pv_elim + (val/p)*Vaux

BUG: reuse of freed memory.

We use "vl" during the computation, not *init_l

We use "el" during the computation, not *elim_l

Nothing do if there is no variable to eliminate

This elimination works only on equalities. While there remains equalities, we can eliminate variables.

We look, in vl (i.e. init_l), for a variable that we can eliminate in init_vec, i.e. with a coefficient not equal to 0. We prefer a coefficient * equal to 1 or -1, so we scan all the equality. We take the first * variable of "init_l" that has a coeff of 1 or -1. If there is no such * variable, we take the first with a coeff not equal to zero.

If we get such a variable, we eliminate it.

First, we remove it from "vl".

Then, we add it to "el".

We compute the expression (pv_elim) by which we are going to substitute our variable (var):

We have: val*var = pv_elim

The equality is: V = 0, with: V = val*var + Vaux

So, we have: pv_elim = -Vaux, with: Vaux = V - val*var

So: pv_elim = val*var - V

??? memory leak...

substitute "val*var" by its value (pv_elim) in the system

s = sc_normalize(ps);

We substitute var by its value (pv_elim) in "sc_elim".

The initial equality is added to "sc_elim".

We reinitialize the list of equalities.

Else, we try on the next equality.

Parameters
pss
init_lnit_l
elim_llim_l

Definition at line 1361 of file utils.c.

1362 {
1363  Psysteme sc_elim = sc_new();
1364  Pcontrainte eqs;
1365  list vl = *init_l, /* We use "vl" during the computation, not *init_l */
1366  el = NIL, /* We use "el" during the computation, not *elim_l */
1367  l;
1368 
1369  /* Nothing do if there is no variable to eliminate */
1370  if(!ENDP(vl)) {
1371  /* This elimination works only on equalities. While there remains
1372  * equalities, we can eliminate variables. */
1373  eqs = ps->egalites;
1374  while(eqs != NULL)
1375  {
1376  bool coeff_one_not_found, var_found;
1377  entity var = entity_undefined;
1378  Value val = VALUE_ZERO;
1379  Pvecteur init_vec, pv_elim;
1380  Pcontrainte next = eqs->succ;
1381 
1382  init_vec = vect_dup(eqs->vecteur);
1383 
1384  /* We look, in vl (i.e. init_l), for a variable that we can
1385  * eliminate in init_vec, i.e. with a coefficient not equal to
1386  * 0. We prefer a coefficient * equal to 1 or -1, so we scan
1387  * all the equality. We take the first * variable of "init_l"
1388  * that has a coeff of 1 or -1. If there is no such *
1389  * variable, we take the first with a coeff not equal to zero.
1390  */
1391  var_found = false;
1392  coeff_one_not_found = true;
1393 
1394  for(l = vl ; (l != NIL) && coeff_one_not_found; l = CDR(l))
1395  {
1396  entity crt_var = ENTITY(CAR(l));
1397  Value crt_val = vect_coeff((Variable) crt_var, init_vec);
1398 
1399  if(value_one_p(crt_val) || value_mone_p(crt_val))
1400  {
1401  coeff_one_not_found = false;
1402  var_found = true;
1403  var = crt_var;
1404  val = crt_val;
1405  }
1406  else if((value_notzero_p(crt_val)) && !var_found)
1407  {
1408  var_found = true;
1409  var = crt_var;
1410  val = crt_val;
1411  }
1412  }
1413 
1414  if(var_found) /* If we get such a variable, we eliminate it. */
1415  {
1416  /* First, we remove it from "vl". */
1417  gen_remove(&vl, (void *) var);
1418 
1419  /* Then, we add it to "el". */
1420  el = CONS(ENTITY, var, el);
1421 
1422  /* We compute the expression (pv_elim) by which we are
1423  * going to substitute our variable (var):
1424  *
1425  * We have: val*var = pv_elim
1426  *
1427  * The equality is: V = 0, with: V = val*var + Vaux
1428  *
1429  * So, we have: pv_elim = -Vaux, with: Vaux = V - val*var
1430  *
1431  * So: pv_elim = val*var - V
1432  *
1433  * ??? memory leak...
1434  */
1435  pv_elim = vect_cl2_ofl_ctrl
1436  (VALUE_MONE, vect_dup(init_vec),
1437  VALUE_ONE, vect_new((Variable) var, val),
1438  NO_OFL_CTRL);
1439 
1440  /* substitute "val*var" by its value (pv_elim) in the system */
1441  substitute_var_with_vec(ps, var, val, vect_dup(pv_elim));
1442  /*ps = sc_normalize(ps);*/
1443  ps = sc_elim_db_constraints(ps);
1444 
1445  /* We substitute var by its value (pv_elim) in "sc_elim". */
1446  substitute_var_with_vec(sc_elim, var, val, vect_dup(pv_elim));
1447 
1448  /* The initial equality is added to "sc_elim". */
1449  sc_add_egalite(sc_elim, contrainte_make(vect_dup(init_vec)));
1450 
1451  /* We reinitialize the list of equalities. */
1452  eqs = ps->egalites;
1453  }
1454  /* Else, we try on the next equality. */
1455  else
1456  eqs = next;
1457 
1458  vect_rm(init_vec);
1459  }
1460  }
1461  *init_l = vl;
1462  *elim_l = el;
1463  sc_elim->base = NULL;
1464  sc_creer_base(sc_elim);
1465 
1466  return(sc_elim);
1467 }
#define VALUE_ZERO
#define value_mone_p(val)
#define value_notzero_p(val)
#define value_one_p(val)
#define VALUE_MONE
void substitute_var_with_vec(Psysteme ps, entity var, Value val, Pvecteur vec)
===========================================================================
Definition: utils.c:1210
#define entity_undefined
Definition: ri.h:2761
Psysteme sc_elim_db_constraints(Psysteme ps)
Psysteme sc_elim_db_constraints(Psysteme ps): elimination des egalites et des inegalites identiques o...
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_cl2_ofl_ctrl(Value x1, Pvecteur v1, Value x2, Pvecteur v2, int ofl_ctrl)
Pvecteur vect_cl2_ofl(Value x1, Pvecteur v1, Value x2, Pvecteur v2): allocation d'un vecteur v dont l...
Definition: binaires.c:204

References Ssysteme::base, CAR, CDR, CONS, contrainte_make(), Ssysteme::egalites, ENDP, ENTITY, entity_undefined, gen_remove(), NIL, NO_OFL_CTRL, sc_add_egalite(), sc_creer_base(), sc_elim_db_constraints(), sc_new(), substitute_var_with_vec(), Scontrainte::succ, VALUE_MONE, value_mone_p, value_notzero_p, VALUE_ONE, value_one_p, VALUE_ZERO, vect_cl2_ofl_ctrl(), vect_coeff(), vect_dup(), vect_new(), vect_rm(), and Scontrainte::vecteur.

Referenced by compose_vvs(), edge_weight(), make_causal_external(), make_causal_internal(), partial_broadcast_coefficients(), plc_make_distance(), simplify_bdt(), valuer(), and vvs_on_vvs().

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

◆ expressions_to_predicate()

predicate expressions_to_predicate ( list  exp_l)

===========================================================================

predicate expressions_to_predicate(list exp_l): returns the predicate that has the inequalities given as expressions in "exp_l". For example: if A is an expresion of "exp_l" then we'll have the inequality A <= 0 in the predicate.

If an expression is not linear, we warn the user.

Note: if "exp_l" is empty then we return an undefined predicate.

Parameters
exp_lxp_l

Definition at line 826 of file utils.c.

828 {
829  predicate new_pred;
830  Psysteme new_sc;
831  list l;
832 
833  if(exp_l == NIL)
834  return(predicate_undefined);
835 
836  new_sc = sc_new();
837 
838  for(l = exp_l; l != NIL; l = CDR(l))
839  {
842 
843  if(normalized_linear_p(nexp))
844  {
845  Pvecteur new_vec = (Pvecteur) normalized_linear(nexp);
846  sc_add_inegalite(new_sc, contrainte_make(new_vec));
847  }
848  else
849  {
850  printf("\nNon linear expression :");
851  printf(" %s\n", expression_to_string(exp));
852  }
853  }
854 
855  sc_creer_base(new_sc);
856  new_pred = make_predicate(new_sc);
857 
858  return(new_pred);
859 }
string expression_to_string(expression e)
Definition: expression.c:77
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define predicate_undefined
Definition: ri.h:2046
int printf()
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
struct Svecteur * Pvecteur

References CAR, CDR, contrainte_make(), exp, EXPRESSION, expression_to_string(), make_predicate(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, predicate_undefined, printf(), sc_add_inegalite(), sc_creer_base(), and sc_new().

Referenced by bdt_new_shedule(), and new_df_gov_pred().

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

◆ expressions_to_vectors()

Pcontrainte expressions_to_vectors ( list  lexp)

=================================================================

Parameters
lexpexp

Definition at line 2260 of file utils.c.

2262 {
2263  list ll;
2265 
2266  for(ll = lexp; !ENDP(ll); POP(ll)){
2267  Pvecteur pv;
2268  expression cexp = EXPRESSION(CAR(ll));
2269  normalized cnor;
2270 
2271  cnor = NORMALIZE_EXPRESSION(cexp);
2273  pips_internal_error("Expressions MUST be linear");
2274 
2275  pv = (Pvecteur) normalized_linear(cnor);
2276 
2277  if(CONTRAINTE_UNDEFINED_P(pc)) {
2278  pc = contrainte_make(pv);
2279  epc = pc;
2280  }
2281  else {
2282  Pcontrainte apc = contrainte_make(pv);
2283  epc->succ = apc;
2284  epc = epc->succ;
2285  }
2286  }
2287  return(pc);
2288 }
static list lexp
#define CONTRAINTE_UNDEFINED
#define normalized_tag(x)
Definition: ri.h:1778
@ is_normalized_complex
Definition: ri.h:1761

References CAR, contrainte_make(), CONTRAINTE_UNDEFINED, CONTRAINTE_UNDEFINED_P, ENDP, EXPRESSION, is_normalized_complex, lexp, NORMALIZE_EXPRESSION, normalized_linear, normalized_tag, pips_internal_error, POP, and Scontrainte::succ.

Referenced by simplify_minmax().

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

◆ find_el_with_num()

static list find_el_with_num ( int  stmt)
static

===========================================================================

static list find_el_with_num(int stmt): returns the englobing loops list corresponding to the statement number "stmt".

This function uses an hash table, which contains the static_control associated to each statement.

Definition at line 964 of file utils.c.

965 {
967 
968  static_control stct = (static_control) hash_get(scm, (char *) ((long)stmt));
969 
970  return(static_control_loops(stct));
971 }
statement_mapping get_current_stco_map(void)
========================================================================
Definition: utils.c:2417
struct _newgen_struct_static_control_ * static_control
Definition: paf_ri.h:184

References get_current_stco_map(), hash_get(), and static_control_loops.

Referenced by make_base_of_nest().

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

◆ find_implicit_equation()

Psysteme find_implicit_equation ( Psysteme  ps)

========================================================================

We put the equalities of the system in our implicit system.

We duplicate "ps" in order to keep it unchanged.

We make the test on each inequality. We count them.

We replace the original inequality (Expr <= 0) by the modified one (Expr + 1 <= 0).

We test the feasibility. If it is not feasible, we add one more implicit equation in our implicit system : Expr == 0.

We put the old value back

Parameters
pss

Definition at line 2350 of file utils.c.

2351 {
2352  Pcontrainte ineg, eg;
2353  Psysteme impl_ps, aux_ps;
2354 
2355  if(ps == NULL)
2356  return(NULL);
2357 
2358  /* We put the equalities of the system in our implicit system. */
2359  impl_ps = sc_new();
2360  for(eg = ps->egalites; eg != NULL; eg = eg->succ)
2361  sc_add_egalite(impl_ps, contrainte_dup(eg));
2362 
2363  /* We duplicate "ps" in order to keep it unchanged. */
2364  aux_ps = sc_dup(ps);
2365 
2366  /* We make the test on each inequality. We count them. */
2367  for(ineg = aux_ps->inegalites; ineg != NULL; ineg = ineg->succ) {
2368  Pvecteur expr;
2369 
2370  /* We replace the original inequality (Expr <= 0) by the modified
2371  * one (Expr + 1 <= 0).
2372  */
2373  expr = ineg->vecteur;
2374  ineg->vecteur = vect_add(expr, vect_new(TCST, VALUE_ONE));
2375 
2376  /* We test the feasibility. If it is not feasible, we add one more
2377  * implicit equation in our implicit system : Expr == 0.
2378  */
2379  if(! sc_rational_feasibility_ofl_ctrl(aux_ps, NO_OFL_CTRL, true)) {
2380  Pcontrainte pc_expr = contrainte_make(expr);
2381 
2382  if(get_debug_level() > 7) {
2383  fprintf(stderr, "Equation implicit : ");
2384  pu_egalite_fprint(stderr, pc_expr, entity_local_name);
2385  fprintf(stderr, "\n");
2386  }
2387  sc_add_egalite(impl_ps, pc_expr);
2388  }
2389 
2390  /* We put the old value back */
2391  ineg->vecteur = expr;
2392  }
2393 
2394  sc_creer_base(impl_ps);
2395  impl_ps = sc_normalize(impl_ps);
2396 
2397  return(impl_ps);
2398 }
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
void pu_egalite_fprint(FILE *, Pcontrainte, const char *(*)(entity))
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
bool sc_rational_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53

References contrainte_dup(), contrainte_make(), Ssysteme::egalites, entity_local_name(), fprintf(), get_debug_level(), Ssysteme::inegalites, NO_OFL_CTRL, pu_egalite_fprint(), sc_add_egalite(), sc_creer_base(), sc_dup(), sc_new(), sc_normalize(), sc_rational_feasibility_ofl_ctrl(), Scontrainte::succ, TCST, VALUE_ONE, vect_add(), vect_new(), and Scontrainte::vecteur.

Referenced by broadcast_of_dataflow(), count_implicit_equation(), plc_make_distance(), and simplify_bdt().

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

◆ first_df_of_succ()

dataflow first_df_of_succ ( successor  s)

===========================================================================

dataflow first_df_of_succ(successor s): returns the first dataflow of "s".

Definition at line 1004 of file utils.c.

1006 {
1008 successor_arc_label(s)))));
1009 }
#define successor_arc_label(x)
Definition: graph.h:116
#define DATAFLOW(x)
DATAFLOW.
Definition: paf_ri.h:308
#define dfg_arc_label_dataflows(x)
Definition: paf_ri.h:378

References CAR, DATAFLOW, dfg_arc_label_dataflows, and successor_arc_label.

Referenced by finish_new_df_ref(), and new_df_gov_pred().

+ Here is the caller graph for this function:

◆ first_succ_of_vertex()

successor first_succ_of_vertex ( vertex  v)

===========================================================================

successor first_succ_of_vertex(vertex v): returns the first successor of "v".

Definition at line 994 of file utils.c.

995 {
996  return(SUCCESSOR(CAR(vertex_successors(v))));
997 }
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86

References CAR, SUCCESSOR, and vertex_successors.

Referenced by finish_new_df_ref(), new_df_gov_pred(), and new_df_sink_ins().

+ Here is the caller graph for this function:

◆ general_merge_sort()

list general_merge_sort ( list  l,
bool (*)()  compare_obj 
)

I guess there is some kind of memory leaks here...

I tried the one above, but I could not go thru the validation...

FC 02/01/94

First step

current sublist containing sorted objects

tail of "ch"

Current sublist stops here, we put it in our LIFO queue and ...

... we reinitialize our current sublist.

Else, current sublist increases.

The last current sublist is put in our LIFO queue.

Second step

Definition at line 1748 of file utils.c.

1751 {
1752  list ch1, ch2, ch, ch_t, aux_l, head = NIL, tail = NIL;
1753  void * crt_obj, * prev_obj;
1754 
1755  pips_debug(9, "Debut\n");
1756 
1757  if( ENDP(l) || ENDP(CDR(l)) )
1758  return(l);
1759 
1760  /* First step */
1761  ch = l; /* current sublist containing sorted objects */
1762  ch_t = ch; /* tail of "ch" */
1763  prev_obj = CHUNK(CAR(l));
1764  for(aux_l = CDR(ch_t); !ENDP(aux_l); aux_l = CDR(ch_t), prev_obj = crt_obj) {
1765  crt_obj = CHUNK(CAR(aux_l));
1766  if(compare_obj(crt_obj, prev_obj)) {
1767  /* Current sublist stops here, we put it in our LIFO queue and ... */
1768  if(tail == NIL) {
1769  head = CONS(CONSP, ch, NIL);
1770  tail = head;
1771  }
1772  else {
1773  CDR(tail) = CONS(CONSP, ch, NIL);
1774  POP(tail);
1775  }
1776 
1777  /* ... we reinitialize our current sublist. */
1778  ch = CDR(ch_t);
1779  CDR(ch_t) = NIL;
1780  ch_t = ch;
1781  }
1782  else
1783  /* Else, current sublist increases. */
1784  POP(ch_t);
1785  }
1786  /* The last current sublist is put in our LIFO queue. */
1787  if(tail == NIL) {
1788  head = CONS(CONSP, ch, NIL);
1789  tail = head;
1790  }
1791  else {
1792  CDR(tail) = CONS(CONSP, ch, NIL);
1793  POP(tail);
1794  }
1795 
1796  /* Second step */
1797  for( ; ! ENDP(CDR(head)) ; ) {
1798  ch1 = CONSP(CAR(head));
1799  POP(head);
1800  ch2 = CONSP(CAR(head));
1801  POP(head);
1802  ch = meld(ch1, ch2, compare_obj);
1803 
1804  if(head == NIL) {
1805  head = CONS(CONSP, ch, NIL);
1806  tail = head;
1807  }
1808  else {
1809  CDR(tail) = CONS(CONSP, ch, NIL);
1810  POP(tail);
1811  }
1812  }
1813  pips_debug(9, "Fin\n");
1814 
1815  return(CONSP(CAR(head)));
1816 }
#define CHUNK(x)
Definition: genC.h:90
#define CONSP(x)
Definition: genC.h:88
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
list meld(list l1, list l2, bool(*compare_obj)())
===========================================================================
Definition: utils.c:1665

References CAR, CDR, CHUNK, CONS, CONSP, ENDP, meld(), NIL, pips_debug, and POP.

+ Here is the call graph for this function:

◆ get_current_stco_map()

statement_mapping get_current_stco_map ( void  )

========================================================================

Definition at line 2417 of file utils.c.

2418 {
2419  return current_stco_map;
2420 }
static statement_mapping current_stco_map
These three functions respectively initialize, return and reset the static map of the static control ...
Definition: utils.c:2405

References current_stco_map.

Referenced by find_el_with_num(), and get_stco_from_current_map().

+ Here is the caller graph for this function:

◆ get_stco_from_current_map()

◆ in_dfg_vertex_list()

vertex in_dfg_vertex_list ( list  l,
vertex  v 
)

===========================================================================

void pu_egalites_to_matrice(matrice a, int n m, Pcontrainte leg, Pbase b): constructs the matrix "a" with the equalities contained in "leg". The base "b" gives the column number of each variable. The first element of the matrix is a(1,1), the ACCESS macro makes the conversion to the C array numbering which begins at (0,0).

The constant term is not included. The matrix "a" is supposed to have been already allocated in memory.

"n" must be the exact number of equalities contained in "leg". "m" must be the exact number of variables contained in "b". never called void pu_egalites_to_matrice(a, n, m, leg, b) matrice a; int n; int m; Pcontrainte leg; Pbase b; { Pvecteur v; Pcontrainte peq; int ligne = 1;

matrice_nulle(a, n, m);

for(peq = leg; peq != NULL; peq = peq->succ, ligne++) { pips_assert("pu_egalites_to_matrice",ligne<=n);

for(v = peq->vecteur; !VECTEUR_UNDEFINED_P(v); v = v->succ) { int rank; if(vecteur_var(v) != TCST) { rank = base_find_variable_rank(base_dup(b), vecteur_var(v), pu_variable_name); pips_assert("pu_egalites_to_matrice", rank <= m);

ACCESS(a, n, ligne, rank) = vecteur_val(v); } } } } end MATRIX functions ====================================================================== vertex in_dfg_vertex_list( (list) l, (vertex) v ) AL 30/06/93 Input : A list l of vertices. A vertex v of a dependence graph. Returns vertex_undefined if v is not in list l. Returns v' that has the same statement_ordering than v.

Definition at line 620 of file utils.c.

621 {
622  vertex ver;
623  int in;
624 
625  pips_debug(9, "doing \n");
626 
628  vertex_vertex_label(v) );
629  for(;!ENDP(l); POP(l)) {
630  int prov_i;
631  ver = VERTEX(CAR( l ));
633  vertex_vertex_label(ver) );
634  if ( prov_i == in ) return( ver );
635  }
636 
637  return vertex_undefined;
638 }
#define vertex_undefined
Definition: graph.h:128
#define dfg_vertex_label_statement(x)
Definition: paf_ri.h:413

References CAR, dfg_vertex_label_statement, ENDP, pips_debug, POP, VERTEX, vertex_undefined, and vertex_vertex_label.

Referenced by adg_update_dfg().

+ Here is the caller graph for this function:

◆ in_dg_vertex_list()

vertex in_dg_vertex_list ( list  l,
vertex  v 
)

======================================================================

vertex in_dg_vertex_list( (list) l, (vertex) v ) AL 30/06/93 Input : A list l of vertices. A vertex v of a dependence graph. Returns vertex_undefined if v is not in list l. Returns v' that has the same statement_ordering than v.

Definition at line 647 of file utils.c.

648 {
649  vertex ver;
650  int in;
651 
652  pips_debug(9, "doing \n");
653 
655  vertex_vertex_label(v) );
656  for(;!ENDP(l); POP(l)) {
657  int prov_i;
658  ver = VERTEX(CAR( l ));
660  vertex_vertex_label(ver) );
661  if ( prov_i == in ) return( ver );
662  }
663 
664  return vertex_undefined;
665 }
#define dg_vertex_label_statement(x)
Definition: dg.h:235

References CAR, dg_vertex_label_statement, ENDP, pips_debug, POP, VERTEX, vertex_undefined, and vertex_vertex_label.

◆ is_entity_in_list_p()

bool is_entity_in_list_p ( entity  e,
list  l 
)

===========================================================================

bool is_entity_in_list_p(entity e, list l): returns true if entity "e" is in the list of entities "l", false otherwise. FI: many similar functions. See ri-util/arguments.c which deals with entity lists, i.e. entities.

Definition at line 1281 of file utils.c.

1282 {
1283  bool is_in_list = false;
1284  for( ; (l != NIL) && (! is_in_list); l = CDR(l))
1285  if(same_entity_p(e, ENTITY(CAR(l))))
1286  is_in_list = true;
1287  return(is_in_list);
1288 }
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References CAR, CDR, ENTITY, NIL, and same_entity_p().

Referenced by add_others_variables(), adg_dataflowgraph_with_extremities(), adg_get_read_entity_vertices(), clean_list_of_unk(), get_list_of_all_param(), make_list_of_unk(), read_reference_list(), reorder_base(), and system_new_var_subst().

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

◆ lisp_exp_to_ri_exp()

expression lisp_exp_to_ri_exp ( lisp_expression  le)

===========================================================================

expression lisp_exp_to_ri_exp(lisp_expression le): returns the expression that represent the lisp_expression given in argument ("le"). A lisp_expression is a Newgen structure that defines an expression as a list with the operator as the first object and the arguments as the rest of the list.

There are a few cases. If the operator is "aref" or "aset" then this lisp expression is a reference to an array. We use make_array_ref(). If the operator is not one of the four operations (+,-,*,/), then we use make_func_op(). Else (the operator is one of the four operation) we use rational_op_exp().

Parameters
lee

Definition at line 755 of file utils.c.

757 {
758  expression exp1, exp2;
759  string exp_op = lisp_expression_operation(le);
760  list exp_args = lisp_expression_args(le);
761 
762  if( (strncmp(exp_op, "aref", 4) == 0) || (strncmp(exp_op, "aset", 4) == 0) )
763  return(make_array_ref(exp_args));
764 
765  if(! STRING_FOUR_OPERATION_P(exp_op))
766  return(make_func_op(exp_op, exp_args));
767 
768  exp1 = EXPRESSION(CAR(exp_args));
769  exp_args = CDR(exp_args);
770 
771  if(exp_args == NIL)
772  pips_internal_error("Only 1 argument for a binary (or more) operation");
773 
774  for(; exp_args != NIL; exp_args = CDR(exp_args))
775  {
776  exp2 = EXPRESSION(CAR(exp_args));
777 
778  exp1 = rational_op_exp(exp_op, exp1, exp2);
779  }
780  return(exp1);
781 }
expression rational_op_exp(string op_name, expression exp1, expression exp2)
========================================================================
Definition: utils.c:1846
expression make_array_ref(list l)
===========================================================================
Definition: utils.c:702
#define STRING_FOUR_OPERATION_P(s)
Macro functions.
Definition: utils.c:102
expression make_func_op(string func_name, list args)
===========================================================================
Definition: utils.c:725
#define lisp_expression_operation(x)
Definition: paf_ri.h:487
#define lisp_expression_args(x)
Definition: paf_ri.h:489

References CAR, CDR, EXPRESSION, lisp_expression_args, lisp_expression_operation, make_array_ref(), make_func_op(), NIL, pips_internal_error, rational_op_exp(), and STRING_FOUR_OPERATION_P.

Referenced by bdt_save_exp(), and save_exp().

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

◆ loop_dup()

loop loop_dup ( loop  l)

===========================================================================

loop loop_dup(loop l): returns the duplication of "l".

Definition at line 1014 of file utils.c.

1015 {
1016  /*
1017  loop new_loop;
1018 
1019  new_loop = make_loop(loop_index(l), range_dup(loop_range(l)), loop_body(l),
1020  loop_label(l), loop_execution(l), loop_locals(l));
1021 
1022  return(new_loop);
1023  */
1024  return copy_loop(l);
1025 }
loop copy_loop(loop p)
LOOP.
Definition: ri.c:1265

References copy_loop().

Referenced by finish_new_gd_ins().

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

◆ make_array_ref()

expression make_array_ref ( list  l)

===========================================================================

expression make_array_ref(list l): returns an expression which is a reference to an array. The list "l" is composed of expressions, the first one is the array itself and the others are the indices. In order to create the desire expression, we only have to put the CDR of "l" into the list of indices of the reference contained in the first expression of "l".

Definition at line 702 of file utils.c.

703 {
704  expression new_exp;
705  list array_inds;
706 
707  if(l == NIL)
708  pips_internal_error("No args for array ref");
709 
710  new_exp = EXPRESSION(CAR(l));
711  array_inds = CDR(l);
712 
713  if(! syntax_reference_p(expression_syntax(new_exp)))
714  pips_internal_error("Array ref is not a reference");
715 
716  reference_indices(syntax_reference(expression_syntax(new_exp))) = array_inds;
717 
718  return(new_exp);
719 }
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_indices(x)
Definition: ri.h:2328
#define expression_syntax(x)
Definition: ri.h:1247

References CAR, CDR, EXPRESSION, expression_syntax, NIL, pips_internal_error, reference_indices, syntax_reference, and syntax_reference_p.

Referenced by lisp_exp_to_ri_exp().

+ Here is the caller graph for this function:

◆ make_base_of_nest()

Pbase make_base_of_nest ( int  stmt)

===========================================================================

Pbase make_base_of_nest(int stmt): returns the Pbase that contains the indices of the englobing loops of "stmt".

Parameters
stmttmt

Definition at line 977 of file utils.c.

978 {
979  Pbase new_b = NULL;
980  list el_l;
981 
982  for(el_l = find_el_with_num(stmt) ; el_l != NIL; el_l = CDR(el_l))
983  vect_add_elem((Pvecteur *) &new_b,
984  (Variable) loop_index(LOOP(CAR(el_l))),
985  VALUE_ONE);
986 
987  return(new_b);
988 }
static list find_el_with_num(int stmt)
===========================================================================
Definition: utils.c:964
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References CAR, CDR, find_el_with_num(), LOOP, loop_index, NIL, VALUE_ONE, and vect_add_elem().

+ Here is the call graph for this function:

◆ make_expression_equalities()

Psysteme make_expression_equalities ( list  le)

===========================================================================

Psysteme make_expression_equalities(list le): returns a Psysteme that has equalities computed from "le", a list of expressions.

Parameters
lee

Definition at line 931 of file utils.c.

932 {
933  Psysteme new_sc;
934  list l;
935 
936  new_sc = sc_new();
937 
938  for(l = le; l != NIL; l = CDR(l))
939  {
942 
943  if(normalized_linear_p(nexp))
944  {
945  Pvecteur new_vec = (Pvecteur) normalized_linear(nexp);
946  sc_add_egalite(new_sc, contrainte_make(new_vec));
947  }
948  else
949  {
950  printf("\nNon linear expression :");
951  printf(" %s\n", expression_to_string(exp));
952  }
953  }
954  sc_creer_base(new_sc);
955  return(new_sc);
956 }

References CAR, CDR, contrainte_make(), exp, EXPRESSION, expression_to_string(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, printf(), sc_add_egalite(), sc_creer_base(), and sc_new().

Referenced by broadcast_of_dataflow(), and edge_weight().

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

◆ make_func_op()

expression make_func_op ( string  func_name,
list  args 
)

===========================================================================

expression make_func_op(string func_name, list args): returns an expression that represent the call to "func_name" with "args" as arguments.

Parameters
func_nameunc_name
argsrgs

Definition at line 725 of file utils.c.

728 {
729  entity func_ent;
730 
732  func_name), entity_domain);
733 
734  if(func_ent == entity_undefined)
735  pips_internal_error("Function unknown : %s", func_name);
736 
738  make_call(func_ent, args)),
740 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define normalized_undefined
Definition: ri.h:1745
@ is_syntax_call
Definition: ri.h:2693
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References entity_domain, entity_undefined, gen_find_tabulated(), is_syntax_call, make_call(), make_entity_fullname(), make_expression(), make_syntax(), normalized_undefined, pips_internal_error, and TOP_LEVEL_MODULE_NAME.

Referenced by lisp_exp_to_ri_exp().

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

◆ make_id_expression()

expression make_id_expression ( string  s)

===========================================================================

expression make_id_expression(string s): makes an expression with the name of a variable. For this variable, we create a new entity if it does not exist yet.

U

Definition at line 672 of file utils.c.

673 {
674  entity new_ent;
675  string exp_full_name;
676 
678  s, (char *) NULL));
679 
680  new_ent = gen_find_tabulated(exp_full_name, entity_domain);
681 
682  if(new_ent == entity_undefined)
683  new_ent = make_entity(exp_full_name,
685  make_variable(make_basic_int(4/*UU*/),
686  NIL, NIL)),
689 
691  make_reference(new_ent,NIL)),
693 }
value make_value_unknown(void)
Definition: ri.c:2847
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define DFG_MODULE_NAME
#define make_entity(n, t, s, i)
#define ram_undefined
Definition: ri.h:2221
@ is_syntax_reference
Definition: ri.h:2691
@ is_storage_ram
Definition: ri.h:2492
@ is_type_variable
Definition: ri.h:2900
char * strdup()

References concatenate(), DFG_MODULE_NAME, entity_domain, entity_undefined, gen_find_tabulated(), is_storage_ram, is_syntax_reference, is_type_variable, make_basic_int(), make_entity, make_expression(), make_reference(), make_storage(), make_syntax(), make_type(), make_value_unknown(), make_variable(), MODULE_SEP_STRING, NIL, normalized_undefined, ram_undefined, and strdup().

Referenced by bdt_save_id(), and save_id().

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

◆ make_rational_exp()

expression make_rational_exp ( Pvecteur  v,
Value  d 
)

=====================================================================

expression make_rational_exp(v, d)

From the vector v and the integer d creates the expression of the following form: v/d . AC 94/03/25

Modification: this is an extension that verifies that v is not a multiple of d, in which case it can be simplified, and no divide operation is needed. AP 94/08/19

make a "zero" expression

divide "v" by "d", and make the expression with no denominator

build the denominator

build the numerator

create the symbol of dividing

make the expression

Definition at line 2446 of file utils.c.

2449 {
2450  expression e;
2451 
2452  if(VECTEUR_NUL_P(v))
2453  /* make a "zero" expression */
2454  e = int_to_expression(0);
2455  else if(value_zero_p(value_mod(vect_pgcd_all(v), value_abs(d))))
2456  /* divide "v" by "d", and make the expression with no denominator */
2457  e = make_vecteur_expression(vect_div(v, d));
2458  else {
2459  expression e1, e2;
2460  entity ent;
2461  list le = NIL;
2462 
2463  /* build the denominator */
2464  e2 = Value_to_expression(d);
2465  le = CONS(EXPRESSION, e2, NIL);
2466 
2467  /* build the numerator */
2468  vect_normalize(v);
2469  e1 = make_vecteur_expression(v);
2470  le = CONS(EXPRESSION, e1, le);
2471 
2472  /* create the symbol of dividing */
2475  entity_domain);
2476 
2477  /* make the expression */
2479  make_call(ent, le)),
2481  }
2482 
2483  return(e);
2484 }
#define value_zero_p(val)
#define value_abs(val)
#define value_mod(v1, v2)
Value vect_pgcd_all(Pvecteur v)
Value vect_pgcd(Pvecteur v): calcul du pgcd de tous les coefficients non nul d'un vecteur v.
Definition: reductions.c:108
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
Pvecteur vect_div(Pvecteur v, Value x)
Pvecteur vect_div(Pvecteur v, Value x): division du vecteur v par le scalaire x, si x est different d...
Definition: scalaires.c:52
void vect_normalize(Pvecteur v)
void vect_normalize(Pvecteur v): division de tous les coefficients de v par leur pgcd; "normalisation...
Definition: unaires.c:59

References CONS, DIVIDE_OPERATOR_NAME, entity_domain, EXPRESSION, gen_find_tabulated(), int_to_expression(), is_syntax_call, make_call(), make_entity_fullname(), make_expression(), make_syntax(), make_vecteur_expression(), NIL, normalized_undefined, TOP_LEVEL_MODULE_NAME, value_abs, value_mod, Value_to_expression(), value_zero_p, vect_div(), vect_normalize(), vect_pgcd_all(), and VECTEUR_NUL_P.

Referenced by constraint_to_bound(), get_bounds_expression(), make_array_bounds(), and simplify_dimension().

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

◆ matrices_to_contraintes_with_sym_cst()

void matrices_to_contraintes_with_sym_cst ( Pcontrainte pc,
Pbase  index_base,
Pbase  const_base,
matrice  A,
matrice  B,
int  n,
int  m1,
int  m2 
)

build the constant terme if it exists

build a new vecteur if there is not constant term

build a new vecteur if there is not constant term

Parameters
pcc
index_basendex_base
const_baseonst_base
m11
m22

Definition at line 503 of file utils.c.

508 {
509  Pvecteur vect,pv=NULL;
510  Pcontrainte cp,newpc= NULL;
511  int i,j;
512  Value cst,coeff,dena,denb;
513  bool trouve ;
514 
515  dena = DENOMINATOR(A);
516  denb = DENOMINATOR(B);
517 
518  for (i=n;i>=1; i--) {
519  trouve = false;
520  cp = contrainte_new();
521 
522  /* build the constant terme if it exists */
523  if (value_notzero_p(cst = ACCESS(B,n,i,m2))) {
524  pv = vect_new(TCST, value_mult(dena,cst));
525  trouve = true;
526  }
527 
528  for (vect = base_union(index_base, const_base),j=1;
529  j<=m1;vect=vect->succ,j++) {
530  if (value_notzero_p(coeff = ACCESS(A,n,i,j))) {
531  if (trouve) {
532  vect_chg_coeff(&pv, vecteur_var(vect),
533  value_mult(denb, coeff));
534  }
535  else {
536  /* build a new vecteur if there is not constant term */
537  pv = vect_new(vecteur_var(vect), value_mult(denb, coeff));
538  trouve = true;
539  }
540  }
541  }
542 
543  for (j=1;j<=m2-1;vect=vect->succ,j++) {
544  if (value_notzero_p(coeff = ACCESS(B,n,i,j))) {
545  if (trouve) {
546  vect_chg_coeff(&pv, vecteur_var(vect),
547  value_mult(denb, coeff));
548  }
549  else {
550  /* build a new vecteur if there is not constant term */
551  pv = vect_new(vecteur_var(vect),
552  value_mult(denb, coeff));
553  trouve = true;
554  }
555  }
556  }
557 
558  cp->vecteur = pv;
559  cp->succ = newpc;
560  newpc = cp;
561  }
562  *pc = newpc;
563 }
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
Pbase base_union(Pbase b1, Pbase b2)
Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all eleme...
Definition: base.c:428
Pcontrainte contrainte_new(void)
package contrainte - allocations et desallocations
Definition: alloc.c:47
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Definition: sc_read.c:87
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References ACCESS, B, base_union(), contrainte_new(), cp, DENOMINATOR, Svecteur::succ, TCST, value_mult, value_notzero_p, vect_chg_coeff(), vect_new(), and vecteur_var.

Referenced by partial_broadcast_coefficients().

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

◆ meld()

list meld ( list  l1,
list  l2,
bool (*)()  compare_obj 
)

===========================================================================

list meld(list l1, list l2, bool (*compare_obj)()):

Definition at line 1665 of file utils.c.

1668 {
1669  if( ENDP(l1) ) {
1670  return(l2);
1671  }
1672  else if( ENDP(l2) ) {
1673  return(l1);
1674  }
1675  else if(compare_obj(CHUNK(CAR(l1)), CHUNK(CAR(l2)))) {
1676  return(gen_nconc(CONS(CHUNK, CHUNK(CAR(l1)), NIL),
1677  meld(CDR(l1), l2, compare_obj)));
1678  }
1679  else {
1680  return(gen_nconc(CONS(CHUNK, CHUNK(CAR(l2)), NIL),
1681  meld(l1, CDR(l2), compare_obj)));
1682  }
1683 }
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344

References CAR, CDR, CHUNK, CONS, ENDP, gen_nconc(), and NIL.

Referenced by general_merge_sort().

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

◆ negate_expression()

expression negate_expression ( expression  exp)

===========================================================================

expression negate_expression(expression exp): returns the negation of the expression given in argument "exp".

In fact this computation is done only if the expression is linear with integer coefficients. If so, we use the Pvecteur form. Else, we return the duplication of the expression.

Parameters
expxp

Definition at line 792 of file utils.c.

794 {
795  expression neg_exp;
796  normalized nexp;
797 
798  nexp = NORMALIZE_EXPRESSION(exp);
799 
800  if(normalized_complex_p(nexp))
801  neg_exp = copy_expression(exp);
802  else
803  {
804  Pvecteur vexp, new_vec;
805 
806  vexp = (Pvecteur) normalized_linear(nexp);
807  new_vec = vect_dup(vexp);
808  vect_chg_sgn(new_vec);
809 
810  neg_exp = make_vecteur_expression(new_vec);
811  }
812 
813  return(neg_exp);
814 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
#define normalized_complex_p(x)
Definition: ri.h:1782
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151

References copy_expression(), exp, make_vecteur_expression(), NORMALIZE_EXPRESSION, normalized_complex_p, normalized_linear, vect_chg_sgn(), and vect_dup().

Referenced by bdt_save_pred(), and save_pred().

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

◆ new_general_merge_sort()

list new_general_merge_sort ( list  l,
bool (*)()  compare_obj 
)

no way validate Prgm_mapping with this function...

push

sort

pop

Definition at line 1720 of file utils.c.

1723 {
1724  bool (*current)();
1725  list lnew = gen_copy_seq(l);
1726 
1727  /* push
1728  */
1730  bool_compare_objects = compare_obj;
1731 
1732  /* sort
1733  */
1735 
1736  /* pop
1737  */
1739 
1740  return(lnew);
1741 }
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
Definition: list.c:796
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
Definition: newgen_types.h:78
static int compare_objects(gen_chunk **p1, gen_chunk **p2)
Definition: utils.c:1712
static size_t current
Definition: string.c:115

References bool_compare_objects, compare_objects(), current, gen_copy_seq(), and gen_sort_list().

+ Here is the call graph for this function:

◆ old_polynome_to_sc()

Psysteme old_polynome_to_sc ( Ppolynome  pp,
list  l 
)

===========================================================================

Psysteme polynome_to_sc(Ppolynome pp, list l): returns a system of equalities ("new_ps") computed from a polynome "pp" and a list of variables "l".

This list gives the variables of the polynome for which we need to nullify the factor. Thus, the resulting system contains the equations that nullify these factors (the degree of the polynome must be less or equal to two).

When all these equations are computed, the remaining polynome, from each we have removed all the occurences of these variables, is also nullify and the equation added to the system (then, this remnant must be of degree 1).

For each variable, we nullify its factor in the polynome.

We get the current variable.

We get its factor in the polynome.

We add a new equality in the system.

We delete the occurences of this variable in the polynome.

The remnant is added to the system.

Parameters
ppp

Definition at line 1115 of file utils.c.

1118 {
1119  Ppolynome aux_pp = polynome_dup(pp);
1120  Psysteme new_ps = sc_new();
1121 
1122  /* For each variable, we nullify its factor in the polynome. */
1123  for( ; l != NIL; l = CDR(l))
1124  {
1125  /* We get the current variable. */
1126  entity var = ENTITY(CAR(l));
1127 
1128  /* We get its factor in the polynome. */
1129  Ppolynome pp_fac = polynome_factorize(aux_pp, (Variable) var, 1);
1130 
1131  /* We add a new equality in the system. */
1132  sc_add_egalite(new_ps, polynome_to_contrainte(pp_fac));
1133 
1134  /* We delete the occurences of this variable in the polynome. */
1135  aux_pp = prototype_var_subst(aux_pp, (Variable) var, POLYNOME_NUL);
1136  }
1137  /* The remnant is added to the system. */
1138  sc_add_egalite(new_ps, polynome_to_contrainte(aux_pp));
1139 
1140  sc_creer_base(new_ps);
1141  return(new_ps);
1142 }
Ppolynome prototype_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst)
=================================================================
Definition: utils.c:1978
Pcontrainte polynome_to_contrainte(Ppolynome pp)
========================================================================
Definition: utils.c:1095
Ppolynome polynome_dup(Ppolynome pp)
Ppolynome polynome_dup(Ppolynome pp) creates and returns a copy of pp.
Definition: pnome-alloc.c:211
Ppolynome polynome_factorize(Ppolynome pp, Variable var, int n)
Ppolynome polynome_factorize(Ppolynome pp, Variable var, int n) returns the (polynomial) coefficient ...
Definition: pnome-reduc.c:131
#define POLYNOME_NUL

References CAR, CDR, ENTITY, NIL, polynome_dup(), polynome_factorize(), POLYNOME_NUL, polynome_to_contrainte(), prototype_var_subst(), sc_add_egalite(), sc_creer_base(), and sc_new().

+ Here is the call graph for this function:

◆ old_vecteur_to_polynome()

Ppolynome old_vecteur_to_polynome ( Pvecteur  vec)

===========================================================================

Ppolynome old_vecteur_to_polynome(Pvecteur vec): translates a Pvecteur into a Ppolynome. FI: To be moved

Parameters
vecec

Definition at line 1648 of file utils.c.

1649 {
1650  Ppolynome pp_new = POLYNOME_NUL;
1651 
1652  for( ; vec != NULL; vec = vec->succ)
1653  polynome_add(&pp_new,
1654  make_polynome(VALUE_TO_FLOAT(vec->val), vec->var, VALUE_ONE));
1655 
1656  return(pp_new);
1657 }
#define VALUE_TO_FLOAT(val)
Ppolynome make_polynome(float coeff, Variable var, Value expo)
Ppolynome make_polynome(float coeff, Variable var, Value expo) PRIVATE allocates space for,...
Definition: pnome-alloc.c:100
void polynome_add(Ppolynome *ppp, Ppolynome pp2)
void polynome_add(Ppolynome* ppp, Ppolynome pp2) (*ppp) = (*ppp) + pp2.
Definition: pnome-bin.c:171
Value val
Definition: vecteur-local.h:91
Variable var
Definition: vecteur-local.h:90

References make_polynome(), polynome_add(), POLYNOME_NUL, Svecteur::succ, Svecteur::val, VALUE_ONE, VALUE_TO_FLOAT, and Svecteur::var.

+ Here is the call graph for this function:

◆ polynome_to_contrainte()

Pcontrainte polynome_to_contrainte ( Ppolynome  pp)

========================================================================

Parameters
ppp

Definition at line 1095 of file utils.c.

1097 {
1098  return(contrainte_make(polynome_to_vecteur(pp)));
1099 }
Pvecteur polynome_to_vecteur(Ppolynome pp)
========================================================================
Definition: utils.c:1063

References contrainte_make(), and polynome_to_vecteur().

Referenced by add_constraint_on_x(), nullify_factors(), old_polynome_to_sc(), and polynome_to_sc().

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

◆ polynome_to_sc()

Psysteme polynome_to_sc ( Ppolynome  pp,
list  l 
)

===========================================================================

Psysteme new_polynome_to_sc(Ppolynome pp, list l): returns a system of equalities ("new_ps") computed from a polynome "pp" and a list of variables "l".

This list gives the variables of the polynome for which we need to nullify the factor. Thus, the resulting system contains the equations that nullify these factors (the degree of the polynome must be less or equal to two).

When all these equations are computed, the remaining polynome, from each we have removed all the occurences of these variables, is also nullify and the equation added to the system (then, this remnant must be of degree 1).

For each variable, we nullify its factor in the polynome.

We get the current variable.

We get its factor in the polynome.

We delete the occurences of this variable in the polynome.

The remnant is added to the system.

Parameters
ppp

Definition at line 1158 of file utils.c.

1161 {
1162  Ppolynome aux_pp = polynome_dup(pp);
1163  Psysteme new_ps = sc_new();
1164 
1165  /* For each variable, we nullify its factor in the polynome. */
1166  for( ; l != NIL; l = CDR(l))
1167  {
1168  /* We get the current variable. */
1169  entity var = ENTITY(CAR(l));
1170 
1171  /* We get its factor in the polynome. */
1172  Pvecteur pv_fac = prototype_factorize(aux_pp, (Variable) var);
1173 
1174  if(!VECTEUR_NUL_P(pv_fac)) {
1175  sc_add_egalite(new_ps, contrainte_make(pv_fac));
1176 
1177  /* We delete the occurences of this variable in the polynome. */
1178  aux_pp = prototype_var_subst(aux_pp, (Variable) var, POLYNOME_NUL);
1179  }
1180  }
1181  /* The remnant is added to the system. */
1182  sc_add_egalite(new_ps, polynome_to_contrainte(aux_pp));
1183 
1184  sc_creer_base(new_ps);
1185  return(new_ps);
1186 }
Pvecteur prototype_factorize(Ppolynome pp, Variable var)
========================================================================
Definition: utils.c:2070

References CAR, CDR, contrainte_make(), ENTITY, NIL, polynome_dup(), POLYNOME_NUL, polynome_to_contrainte(), prototype_factorize(), prototype_var_subst(), sc_add_egalite(), sc_creer_base(), sc_new(), and VECTEUR_NUL_P.

Referenced by make_causal_external(), and make_causal_internal().

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

◆ polynome_to_vecteur()

Pvecteur polynome_to_vecteur ( Ppolynome  pp)

========================================================================

Parameters
ppp

Definition at line 1063 of file utils.c.

1064 {
1065  Pvecteur new_pv = VECTEUR_NUL;
1066  Ppolynome ppp;
1067 
1068  for(ppp = pp; ppp != NULL; ppp = ppp->succ) {
1069  entity var;
1070  Value val;
1071  Pvecteur pv = (ppp->monome)->term;
1072 
1073  if(VECTEUR_NUL_P(pv))
1074  pips_internal_error("A null vector in a monome");
1075  else if(pv->succ != NULL)
1076  pips_internal_error("Polynome is not of degree one");
1077 
1078  var = (entity) pv->var;
1079  val = float_to_value((ppp->monome)->coeff);
1080  vect_add_elem(&new_pv, (Variable) var, val);
1081  }
1082  return(new_pv);
1083 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define float_to_value(f)
static void term(Pproblem XX, int s, Value k, int x)
Definition: isolve.c:315
Pmonome monome
struct Spolynome * succ
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.

References float_to_value, Spolynome::monome, pips_internal_error, Spolynome::succ, Svecteur::succ, term(), Svecteur::var, vect_add_elem(), VECTEUR_NUL, and VECTEUR_NUL_P.

Referenced by include_trans_in_sc(), polynome_to_contrainte(), and prgm_mapping().

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

◆ prototype_factorize()

Pvecteur prototype_factorize ( Ppolynome  pp,
Variable  var 
)

========================================================================

Parameters
ppp
varar

Definition at line 2070 of file utils.c.

2071 {
2072  Pvecteur pv = NULL;
2073 
2074  if(POLYNOME_NUL_P(pp))
2075  pv = VECTEUR_NUL;
2076  else if(var == TCST)
2077  {
2078  float f = polynome_TCST(pp);
2079  pv = vect_new(TCST, float_to_value(f));
2080  }
2081  else {
2082  Ppolynome ppp;
2083 
2084  for(ppp = pp; ppp != NULL; ppp = ppp->succ) {
2085  Variable newvar = VARIABLE_UNDEFINED;
2086  Value newval;
2087  Pvecteur vec, newpv;
2088  entity first = entity_undefined, second = entity_undefined;
2089  bool factor_found = true;
2090 
2091  vec = (ppp->monome)->term;
2092  for(; (vec != NULL) && (second == entity_undefined); vec = vec->succ) {
2093  second = first;
2094  first = (entity) vec->var;
2095  }
2096  if(vec != NULL)
2097  pips_internal_error("Vecteur should contains 2 var");
2098  else if(same_entity_p(first, (entity) var))
2099  if(second == entity_undefined)
2100  newvar = TCST;
2101  else
2102  newvar = (Variable) second;
2103  else if(same_entity_p(second, (entity) var))
2104  newvar = (Variable) first;
2105  else
2106  factor_found = false;
2107 
2108  if(factor_found) {
2109  newval = float_to_value((ppp->monome)->coeff);
2110  newpv = vect_new(newvar, newval);
2111  newpv->succ = pv;
2112  pv = newpv;
2113  }
2114  }
2115  }
2116 
2117  return(pv);
2118 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
float polynome_TCST(Ppolynome pp)
float polynome_TCST(Ppolynome pp) returns the constant term of polynomial pp.
Definition: pnome-reduc.c:156
#define POLYNOME_NUL_P(pp)
#define VARIABLE_UNDEFINED
Definition: vecteur-local.h:64

References entity_undefined, f(), float_to_value, Spolynome::monome, pips_internal_error, POLYNOME_NUL_P, polynome_TCST(), same_entity_p(), Spolynome::succ, Svecteur::succ, TCST, term(), Svecteur::var, VARIABLE_UNDEFINED, vect_new(), and VECTEUR_NUL.

Referenced by broadcast_dimensions(), nullify_factors(), partial_broadcast_coefficients(), partition_unknowns(), plc_make_distance(), polynome_to_sc(), prototype_dimension(), and sort_unknowns().

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

◆ prototype_var_subst()

Ppolynome prototype_var_subst ( Ppolynome  pp,
Variable  var,
Ppolynome  ppsubst 
)

=================================================================

Parameters
ppp
varar
ppsubstpsubst

Definition at line 1978 of file utils.c.

1982 {
1983  Ppolynome newpp;
1984 
1985  if(POLYNOME_NUL_P(ppsubst)) {
1986  Ppolynome ppp, p = POLYNOME_UNDEFINED;
1987  Pvecteur pv;
1988 
1989  newpp = polynome_dup(pp);
1990  for(ppp = newpp; ppp != NULL; ppp = ppp->succ) {
1991  entity first = entity_undefined,
1992  second = entity_undefined;
1993  pv = (ppp->monome)->term;
1994  for(; (pv != NULL) && (second == entity_undefined); pv = pv->succ) {
1995  second = first;
1996  first = (entity) pv->var;
1997  }
1998  if(pv != NULL)
1999  pips_internal_error("Vecteur should contains 2 var");
2000  else if( same_entity_p(first, (entity) var) ||
2001  same_entity_p(second, (entity) var)) {
2002  if(POLYNOME_UNDEFINED_P(p)) {
2003  newpp = ppp->succ;
2004  }
2005  else
2006  p->succ = ppp->succ;
2007  }
2008  else
2009  p = ppp;
2010  }
2011  }
2012  else
2013  newpp = polynome_var_subst(pp, var, ppsubst);
2014  return(newpp);
2015 }
Ppolynome polynome_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst)
Ppolynome polynome_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst) creates and returns a Ppo...
Definition: pnome-reduc.c:47
#define POLYNOME_UNDEFINED
#define POLYNOME_UNDEFINED_P(pp)

References entity_undefined, Spolynome::monome, pips_internal_error, polynome_dup(), POLYNOME_NUL_P, POLYNOME_UNDEFINED, POLYNOME_UNDEFINED_P, polynome_var_subst(), same_entity_p(), Spolynome::succ, Svecteur::succ, term(), and Svecteur::var.

Referenced by include_trans_in_poly(), nullify_factors(), old_polynome_to_sc(), plc_make_distance(), polynome_to_sc(), and vvs_on_polynome().

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

◆ pu_contraintes_to_matrices()

void pu_contraintes_to_matrices ( Pcontrainte  pc,
Pbase  b,
matrice  A,
matrice  B,
int  n,
int  m 
)

===========================================================================

void pu_contraintes_to_matrices(Pcontrainte pc, Pbase b, matrice A B, int n m): constructs the matrices "A" and "B" corresponding to the linear constraints "pc", so: Ab + B <=> pc(b).

The base "b" gives the variables of the linear system.

The matrices "A" and "B" are supposed to have been already allocated in memory, respectively of dimension (n, m) and (n, 1).

"n" must be the exact number of constraints contained in "pc". "m" must be the exact number of variables contained in "b".

Parameters
pcc

Definition at line 408 of file utils.c.

414 {
415  int i,j;
416  Pvecteur pv;
417  Pcontrainte eq;
418  matrice_nulle(B,n,1);
419  matrice_nulle(A,n,m);
420 
421  for(eq = pc,i=1; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ,i++) {
422  for(pv = b, j=1; pv != NULL; pv = pv->succ, j++){
423  ACCESS(A,n,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur);
424  }
425  ACCESS(B,n,i,1) = vect_coeff(0,eq->vecteur);
426  }
427 }

References ACCESS, B, CONTRAINTE_UNDEFINED_P, eq, matrice_nulle(), Scontrainte::succ, Svecteur::succ, vect_coeff(), Scontrainte::vecteur, and vecteur_var.

Referenced by broadcast_of_dataflow(), partial_broadcast_coefficients(), and prototype_dimension().

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

◆ pu_matrices_to_contraintes()

void pu_matrices_to_contraintes ( Pcontrainte pc,
Pbase  b,
matrice  A,
matrice  B,
int  n,
int  m 
)

Global variables

utils.c

Internal variables
Local defines: FI, they are needed earlier in the file because newgen is now fully typed statically begin MATRIX functions ======================================================================== never called void matrix_scalar_multiply(A, nb) Pmatrix A; int nb; { int i, j, m, n, d, p;

m = MATRIX_NB_LINES(A); n = MATRIX_NB_COLUMNS(A); d = MATRIX_DENOMINATOR(A); p = pgcd(d, nb);

MATRIX_DENOMINATOR(A) = d/p; for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) MATRIX_ELEM(A,i,j) = (nb/p) * MATRIX_ELEM(A,i,j); } ==================================================================== never called void pu_matrix_add(a,b,c) Pmatrix a; Pmatrix b, c; { int d1, d2, i, j, n, m;

n = MATRIX_NB_LINES(a); m = MATRIX_NB_COLUMNS(a); pips_assert("matrix_add", (n > 0) && (m > 0));

d1 = MATRIX_DENOMINATOR(b); d2 = MATRIX_DENOMINATOR(c); if (d1 == d2) { for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) MATRIX_ELEM(a,i,j)=MATRIX_ELEM(b,i,j)+MATRIX_ELEM(c,i,j); MATRIX_DENOMINATOR(a) = d1; } else { int lcm = ppcm(d1,d2); d1 = lcm/d1; d2 = lcm/d2; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) MATRIX_ELEM(a,i,j)=MATRIX_ELEM(b,i,j)*d1+MATRIX_ELEM(c,i,j)*d2; MATRIX_DENOMINATOR(a) = lcm; } } ======================================================================= never called void pu_constraints_with_sym_cst_to_matrices(pc,ib,cb,A,B) Pcontrainte pc; Pbase ib,cb; Pmatrix A, B; { int i,j; Pcontrainte eq; Pvecteur pv; int n, m1, m2;

for (eq = pc, n = 0; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ) { n++; } m1 = vect_size(ib); m2 = vect_size(cb) + 1;

pips_assert("constraints_with_sym_cst_to_matrices", (MATRIX_NB_LINES(A) == n) && (MATRIX_NB_COLUMNS(A) == m1) && (MATRIX_NB_LINES(B) == n) && (MATRIX_NB_COLUMNS(B) == m2));

matrix_nulle(B); matrix_nulle(A);

for (eq = pc,i=1; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ,i++) { for(pv = ib, j=1; pv != NULL; pv = pv->succ, j++){ MATRIX_ELEM(A,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur); } for(pv = cb, j=1; pv != NULL; pv = pv->succ, j++){ MATRIX_ELEM(B,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur); } MATRIX_ELEM(B,i,m2) = vect_coeff(TCST,eq->vecteur); } } ======================================================================= never called void pu_matrices_to_constraints_with_sym_cst(pc,ib,cb,A,B) Pcontrainte *pc; Pbase ib,cb; Pmatrix A, B; { Pcontrainte newpc = NULL; int i, j, coeff, dena, denb, n, m1, m2, lcm;

n = MATRIX_NB_LINES(A); m1 = MATRIX_NB_COLUMNS(A); m2 = MATRIX_NB_COLUMNS(B);

pips_assert("constraints_with_sym_cst_to_matrices", (MATRIX_NB_LINES(B) == n) && (vect_size(ib) == m1) && ((vect_size(cb) + 1) == m2));

dena = MATRIX_DENOMINATOR(A); denb = MATRIX_DENOMINATOR(B); lcm = ppcm(dena, denb);

for (i=n;i>=1; i–) { bool found = false; Pcontrainte cp = contrainte_new(); Pvecteur vect, pv = NULL;

if ((coeff = MATRIX_ELEM(B,i,m2)) != 0) { pv = vect_new(TCST, (lcm/denb) * coeff); found = true; } for (j=1, vect=ib;j<=m1;vect=vect->succ,j++) { if ((coeff = MATRIX_ELEM(A,i,j)) != 0) if (found) vect_chg_coeff(&pv, vecteur_var(vect),(lcm/dena) * coeff); else { pv = vect_new(vecteur_var(vect), (lcm/dena) * coeff); found = true; } } for (j=1, vect=cb;j<=m2-1;vect=vect->succ,j++) { if ((coeff = MATRIX_ELEM(B,i,j)) != 0) if (found) vect_chg_coeff(&pv, vecteur_var(vect),(lcm/denb) * coeff); else { pv = vect_new(vecteur_var(vect), (lcm/denb) * coeff); found = true; } } cp->vecteur = pv; cp->succ = newpc; newpc = cp; } pc = newpc; } =========================================================================== void pu_matrices_to_contraintes(Pcontrainte *pc, Pbase b, matrice A B, int n m): constructs the constraints "pc" corresponding to the matrices "A" and "B" so: pc(b) <=> Ab + B

B represents the constant term.

The base "b" gives the variables of the linear system. The matrices "A" and "B" are respectively of dimension (n, m) and (n, 1).

"n" will be the exact number of constraints contained in "pc". "m" must be the exact number of variables contained in "b".

build the constant terme if it is null

build a new vecteur if there is a null constant term

Parameters
pcc

Definition at line 350 of file utils.c.

355 {
356  Pvecteur vect,pv=NULL;
357  Pcontrainte cp, newpc= NULL;
358  int i,j;
359  Value cst,coeff,dena,denb;
360  bool trouve ;
361 
362  dena = DENOMINATOR(A);
363  denb = DENOMINATOR(B);
364 
365  for (i=n;i>=1; i--) {
366  trouve = false;
367  cp = contrainte_new();
368 
369  /* build the constant terme if it is null */
370  if (value_notzero_p(cst = ACCESS(B,n,i,1))) {
371  pv = vect_new(TCST, value_mult(dena,cst));
372  trouve = true;
373  }
374 
375  for (vect = b,j=1;j<=m;vect=vect->succ,j++) {
376  if (value_notzero_p(coeff = ACCESS(A,n,i,j))) {
377  if (trouve)
378  vect_chg_coeff(&pv, vecteur_var(vect),
379  value_mult(denb,coeff));
380  else {
381  /* build a new vecteur if there is a null constant term */
382  pv = vect_new(vecteur_var(vect), value_mult(denb,coeff));
383  trouve = true;
384  }
385  }
386  }
387  cp->vecteur = pv;
388  cp->succ = newpc;
389  newpc = cp;
390  }
391  *pc = newpc;
392 }

References ACCESS, B, contrainte_new(), cp, DENOMINATOR, Svecteur::succ, TCST, value_mult, value_notzero_p, vect_chg_coeff(), vect_new(), and vecteur_var.

Referenced by broadcast_conditions(), make_primal(), and system_inversion_restrict().

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

◆ rational_op_exp()

expression rational_op_exp ( string  op_name,
expression  exp1,
expression  exp2 
)

========================================================================

expression rational_op_exp(char *op_name, expression exp1 exp2): Returns an expression containing the operation "op_name" between "exp1" and "exp2". "op_name" must be one of the four classic operations : +, -, * or /.

If both expressions are integer constant values and the operation result is an integer then the returned expression contained the calculated result, but this calculus is a rational one, not an integer one as in make_op_exp().

Else, we treat five special cases : _ exp1 and exp2 are integer linear and op_name is + or -. This case is resolved by make_lin_op_exp(). _ exp1 = 0 _ exp1 = 1 _ exp2 = 0 _ exp2 = 1

Else, we create a new expression with a binary call.

Note: The function MakeBinaryCall() comes from Pips/.../syntax/expression.c The function int_to_expression() comes from ri-util. Note: This function is almost equivalent to make_op_exp() but for the rational calculus. FI: to be moved in ri-util/expression.c

ENTITY_DIVIDE_P(op_ent)

rational calculus

We need to know the integer linearity of both expressions.

ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent)

ENTITY_DIVIDE_P(op_ent)

Both expressions are unnormalized because they might be reused in an unnormalized expression.

Parameters
op_namep_name
exp1xp1
exp2xp2

Definition at line 1846 of file utils.c.

1847 {
1848  expression result_exp = expression_undefined;
1849  entity op_ent, unary_minus_ent;
1850 
1851  pips_debug(7, "doing\n");
1853  op_name), entity_domain);
1854  unary_minus_ent =
1857  entity_domain);
1858 
1859  pips_debug(5, "begin OP EXP : %s %s %s\n",
1860  expression_to_string(exp1),
1861  op_name,
1862  expression_to_string(exp2));
1863 
1864  if( ! ENTITY_FOUR_OPERATION_P(op_ent) )
1865  user_error("rational_op_exp", "operation must be : +, -, * or /");
1866 
1867  if( expression_constant_p(exp1) && expression_constant_p(exp2) ) {
1868  int val1, val2;
1869 
1870  pips_debug(6, "Constant expressions\n");
1871  val1 = expression_to_int(exp1);
1872  val2 = expression_to_int(exp2);
1873 
1874  if (ENTITY_PLUS_P(op_ent))
1875  result_exp = int_to_expression(val1 + val2);
1876  else if(ENTITY_MINUS_P(op_ent))
1877  result_exp = int_to_expression(val1 - val2);
1878  else if(ENTITY_MULTIPLY_P(op_ent))
1879  result_exp = int_to_expression(val1 * val2);
1880  else { /* ENTITY_DIVIDE_P(op_ent) */
1881  /* rational calculus */
1882  if((val1 % val2) == 0)
1883  result_exp = int_to_expression((int) (val1 / val2));
1884  }
1885  }
1886  else {
1887  /* We need to know the integer linearity of both expressions. */
1888  normalized nor1 = NORMALIZE_EXPRESSION(exp1);
1889  normalized nor2 = NORMALIZE_EXPRESSION(exp2);
1890 
1891  if((normalized_tag(nor1) == is_normalized_linear) &&
1892  (normalized_tag(nor2) == is_normalized_linear) &&
1893  (ENTITY_PLUS_P(op_ent) || ENTITY_MINUS_P(op_ent)) ) {
1894  pips_debug(6, "Linear operation\n");
1895 
1896  result_exp = make_lin_op_exp(op_ent, exp1, exp2);
1897  }
1898  else if(expression_equal_integer_p(exp1, 0)) {
1899  if (ENTITY_PLUS_P(op_ent))
1900  result_exp = exp2;
1901  else if(ENTITY_MINUS_P(op_ent))
1902  result_exp = MakeUnaryCall(unary_minus_ent, exp2);
1903  else /* ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent) */
1904  result_exp = int_to_expression(0);
1905  }
1906  else if(expression_equal_integer_p(exp1, 1)) {
1907  if(ENTITY_MULTIPLY_P(op_ent))
1908  result_exp = exp2;
1909  }
1910  else if(expression_equal_integer_p(exp2, 0)) {
1911  if (ENTITY_PLUS_P(op_ent) || ENTITY_MINUS_P(op_ent))
1912  result_exp = exp1;
1913  else if (ENTITY_MULTIPLY_P(op_ent))
1914  result_exp = int_to_expression(0);
1915  else /* ENTITY_DIVIDE_P(op_ent) */
1916  user_error("rational_op_exp", "division by zero");
1917  }
1918  else if(expression_equal_integer_p(exp2, 1)) {
1919  if(ENTITY_MULTIPLY_P(op_ent) || ENTITY_DIVIDE_P(op_ent))
1920  result_exp = exp1;
1921  }
1922 
1923  /* Both expressions are unnormalized because they might be reused in
1924  * an unnormalized expression. */
1925  unnormalize_expression(exp1);
1926  unnormalize_expression(exp2);
1927  }
1928 
1929  if(result_exp == expression_undefined)
1930  result_exp = MakeBinaryCall(op_ent, exp1, exp2);
1931 
1932  pips_debug(5, "end OP EXP : %s\n",
1933  expression_to_string(result_exp));
1934 
1935  return (result_exp);
1936 }
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
#define user_error(fn,...)
Definition: misc-local.h:265
#define ENTITY_FOUR_OPERATION_P(s)
Definition: utils.c:107
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
#define ENTITY_DIVIDE_P(e)
#define ENTITY_MINUS_P(e)
#define ENTITY_PLUS_P(e)
#define ENTITY_MULTIPLY_P(e)
#define UNARY_MINUS_OPERATOR_NAME
expression make_lin_op_exp(entity op_ent, expression exp1, expression exp2)
================================================================
Definition: expression.c:2147
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
Definition: expression.c:342
bool expression_equal_integer_p(expression exp, int i)
================================================================
Definition: expression.c:1977
#define expression_undefined
Definition: ri.h:1223
@ is_normalized_linear
Definition: ri.h:1760

References ENTITY_DIVIDE_P, entity_domain, ENTITY_FOUR_OPERATION_P, ENTITY_MINUS_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_P, expression_constant_p(), expression_equal_integer_p(), expression_to_int(), expression_to_string(), expression_undefined, gen_find_tabulated(), int_to_expression(), is_normalized_linear, make_entity_fullname(), make_lin_op_exp(), MakeBinaryCall(), MakeUnaryCall(), NORMALIZE_EXPRESSION, normalized_tag, pips_debug, TOP_LEVEL_MODULE_NAME, UNARY_MINUS_OPERATOR_NAME, unnormalize_expression(), and user_error.

Referenced by lisp_exp_to_ri_exp().

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

◆ reset_current_stco_map()

void reset_current_stco_map ( void  )

========================================================================

Definition at line 2423 of file utils.c.

2424 {
2426 }
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References current_stco_map, and hash_table_undefined.

Referenced by prgm_mapping(), print_parallelizedCMF_code(), print_parallelizedCRAFT_code(), reindexing(), scheduling(), and single_assign().

+ Here is the caller graph for this function:

◆ set_current_stco_map()

void set_current_stco_map ( statement_mapping  scm)

========================================================================

Parameters
scmcm

Definition at line 2408 of file utils.c.

2409 {
2410  pips_assert("current_stco_map is defined", current_stco_map ==
2412 
2413  current_stco_map = scm;
2414 }
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172

References current_stco_map, hash_table_undefined, and pips_assert.

Referenced by adg_read_paf(), prgm_mapping(), print_parallelizedCMF_code(), print_parallelizedCRAFT_code(), reindexing(), scheduling(), and single_assign().

+ Here is the caller graph for this function:

◆ simplify_minmax()

list simplify_minmax ( list  lexp,
Psysteme  ps_cont,
int  min_or_max 
)

=================================================================

list simplify_minmax(list lexp, Psysteme ps_cont, int min_or_max)

Parameters : _ lexp : list of LINEAR expressions _ ps_cont : system of equations, called the context _ min_or_max : flag, says in which case we are (MIN or MAX)

Result : list of LINEAR expressions

Aims : simplify "lexp", i.e. suppress one or more of its expressions. A given expression can be suppressed if it surely smaller (case MAX) or greater (case MIN) than one of the other. The case (MIN or MAX) is given by "min_or_max". If two expressions can not be compared, both are kept.The context allows the user to introduce relationship between variables without which some vectors can not be eliminate.

Algorithm : see simplify_minmax_contrainte().

Note : "lexp" is not changed, the returned list of expressions is a new one.

Parameters
lexpexp
ps_conts_cont
min_or_maxin_or_max

Definition at line 2313 of file utils.c.

2317 {
2318  list new_lexp = NIL;
2319  Pcontrainte pc, new_pc;
2320 
2322 
2323  new_pc = simplify_minmax_contrainte(pc, ps_cont, min_or_max);
2324 
2325  new_lexp = vectors_to_expressions(new_pc);
2326 
2327  return(new_lexp);
2328 }
Pcontrainte expressions_to_vectors(list lexp)
=================================================================
Definition: utils.c:2260
Pcontrainte simplify_minmax_contrainte(Pcontrainte pc, Psysteme ps_cont, int min_or_max)
==================================================================
Definition: utils.c:2154
list vectors_to_expressions(Pcontrainte pc)
=================================================================
Definition: utils.c:2245

References expressions_to_vectors(), lexp, NIL, simplify_minmax_contrainte(), and vectors_to_expressions().

Referenced by re_do_it().

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

◆ simplify_minmax_contrainte()

Pcontrainte simplify_minmax_contrainte ( Pcontrainte  pc,
Psysteme  ps_cont,
int  min_or_max 
)

==================================================================

We get (or create) our special variable "X".

U

We put our special variable in our vectors.

min_or_max == IS_MAX

We add the context.

We remove our MINMAX variable.

Parameters
pcc
ps_conts_cont
min_or_maxin_or_max

Definition at line 2154 of file utils.c.

2158 {
2159  Pcontrainte newnew_pc, new_pc, apc, pcc = CONTRAINTE_UNDEFINED,
2160  epc = CONTRAINTE_UNDEFINED;
2161  Psysteme psc, new_ps;
2162  entity ref_ent;
2163  int count;
2164  string exp_full_name;
2165 
2166  /* We get (or create) our special variable "X". */
2167  exp_full_name = strdup(concatenate(PAF_UTIL_MODULE_NAME,
2169  MINMAX_REF_NAME, (char *) NULL));
2170  ref_ent = gen_find_tabulated(exp_full_name, entity_domain);
2171  if(ref_ent == entity_undefined)
2172  ref_ent = make_entity(exp_full_name,
2174  make_variable(make_basic_int(4/*UU*/),
2175  NIL, NIL)),
2177  make_value_unknown());
2178 
2179 
2180  /* We put our special variable in our vectors. */
2181  for(apc = pc, count = 0; apc != NULL; apc = apc->succ, count++) {
2182  Pvecteur pv;
2183  Pcontrainte aapc;
2184 
2185  pv = vect_dup(apc->vecteur);
2186  if(min_or_max == IS_MIN) {
2187  vect_chg_sgn(pv);
2188  vect_add_elem(&pv, (Variable) ref_ent, (Value) 1);
2189  }
2190  else {/* min_or_max == IS_MAX */
2191  vect_add_elem(&pv, (Variable) ref_ent, (Value) -1);
2192  }
2193 
2194  aapc = contrainte_make(pv);
2195  if(CONTRAINTE_UNDEFINED_P(pcc)) {
2196  pcc = aapc;
2197  epc = aapc;
2198  }
2199  else {
2200  epc->succ = aapc;
2201  epc = epc->succ;
2202  }
2203  }
2204 
2205  /* We add the context. */
2206  psc = sc_dup(ps_cont);
2207  epc->succ = psc->inegalites;
2208  psc->inegalites = pcc;
2209  psc->nb_ineq += count;
2210  psc->base = NULL;
2211  sc_creer_base(psc);
2212 
2213  new_ps = sc_elim_redund(psc);
2214 
2215  new_pc = new_ps->inegalites;
2216 
2217  /* We remove our MINMAX variable. */
2218  newnew_pc = CONTRAINTE_UNDEFINED;
2219  for(apc = new_pc; apc != NULL; apc = apc->succ) {
2220  Pvecteur pv;
2221  Pcontrainte aapc;
2222  Value xc;
2223 
2224  pv = vect_dup(apc->vecteur);
2225  xc = vect_coeff((Variable) ref_ent, pv);
2226  if(value_one_p(xc) && (min_or_max == IS_MIN)) {
2227  vect_erase_var(&pv, (Variable) ref_ent);
2228  vect_chg_sgn(pv);
2229  aapc = contrainte_make(pv);
2230  aapc->succ = newnew_pc;
2231  newnew_pc = aapc;
2232  }
2233  else if(value_mone_p(xc) && (min_or_max == IS_MAX)) {
2234  vect_erase_var(&pv, (Variable) ref_ent);
2235  aapc = contrainte_make(pv);
2236  aapc->succ = newnew_pc;
2237  newnew_pc = aapc;
2238  }
2239  }
2240  return(newnew_pc);
2241 }
static int count
Definition: SDG.c:519
#define PAF_UTIL_MODULE_NAME
#define IS_MIN
#define IS_MAX
#define MINMAX_REF_NAME
Definition: utils.c:2121
Psysteme sc_elim_redund(Psysteme ps)
Psysteme sc_elim_redund(Psysteme ps): elimination des contraintes lineaires redondantes dans le syste...
int nb_ineq
Definition: sc-local.h:73
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106

References Ssysteme::base, concatenate(), contrainte_make(), CONTRAINTE_UNDEFINED, CONTRAINTE_UNDEFINED_P, count, entity_domain, entity_undefined, gen_find_tabulated(), Ssysteme::inegalites, IS_MAX, IS_MIN, is_storage_ram, is_type_variable, make_basic_int(), make_entity, make_storage(), make_type(), make_value_unknown(), make_variable(), MINMAX_REF_NAME, MODULE_SEP_STRING, Ssysteme::nb_ineq, NIL, PAF_UTIL_MODULE_NAME, ram_undefined, sc_creer_base(), sc_dup(), sc_elim_redund(), strdup(), Scontrainte::succ, value_mone_p, value_one_p, vect_add_elem(), vect_chg_sgn(), vect_coeff(), vect_dup(), vect_erase_var(), and Scontrainte::vecteur.

Referenced by simplify_minmax().

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

◆ single_var_vecteur_p()

bool single_var_vecteur_p ( Pvecteur  pv)

===========================================================================

bool single_var_vecteur_p(Pvecteur pv): returns true if the vector "pv" contains only one element.

Note: This element should not be a constant term (this is not tested).

Parameters
pvv

Definition at line 1615 of file utils.c.

1616 {
1617  return(vect_size(pv) == 1);
1618 }
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47

References vect_size().

+ Here is the call graph for this function:

◆ static_control_to_indices()

list static_control_to_indices ( static_control  stct)

package mapping : Alexis Platonoff, july 1993

=========================================================================== list static_control_to_indices(static_control stct): returns the list of the loop indices (entities) corresponding to the list of loops contained in "stct". The list of indices is in the same order than the list of loop, i.e. for example, if "stct" contains a list of loops like (LOOP1, LOOP3, LOOP5, LOOP2) then the list of indices will be (I1, I3, I5, I2).

We keep the same order.

Parameters
stcttct

Definition at line 1037 of file utils.c.

1039 {
1040  list lo_l = static_control_loops(stct);
1041  list ind_l = NIL;
1042 
1043  for( ; lo_l != NIL; lo_l = CDR(lo_l))
1044  {
1045  loop lo = LOOP(CAR(lo_l));
1046 
1047  /* We keep the same order. */
1048  ind_l = gen_nconc(ind_l, CONS(ENTITY, loop_index(lo), NIL));
1049  }
1050  return(ind_l);
1051 }

References CAR, CDR, CONS, ENTITY, gen_nconc(), LOOP, loop_index, NIL, and static_control_loops.

Referenced by broadcast_conditions(), broadcast_of_dataflow(), cmf_layout_align(), craft_layout_align(), cutting_conditions(), edge_weight(), get_list_of_all_param(), include_trans_in_poly(), is_not_trivial_p(), mapping_on_broadcast(), partial_broadcast_coefficients(), plc_make_dim(), plc_make_distance(), plc_make_min_dim(), plc_make_proto(), prepare_reindexing(), sa_do_it(), simplify_bdt(), sort_dfg_node(), and valuer().

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

◆ stco_common_loops_of_statements()

int stco_common_loops_of_statements ( statement_mapping  in_map,
statement  in_s,
statement  in_s2 
)

AP, sep 25th 1995 : I have added a function from static_controlise/utils.c.

====================================================================== int stco_common_loops_of_statements(in_map, in_s, in_s2 ) AL 22/10/93 Input : A statement mapping in_map wich associates a static_control to each statement, and two statements in_s and in_s2. Output : Number of same enclosing loops around ins_s and in_s2.

Parameters
in_mapn_map
in_sn_s
in_s2n_s2

Definition at line 2497 of file utils.c.

2500 {
2501  debug(9, "stco_common_loops_of_statements","doing\n");
2502  return( gen_length(stco_same_loops( in_map, in_s, in_s2 )) );
2503 }
size_t gen_length(const list l)
Definition: list.c:150
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
list stco_same_loops(statement_mapping in_map, statement in_s, statement in_s2)
======================================================================
Definition: utils.c:98

References debug(), gen_length(), and stco_same_loops().

Referenced by adg_dataflowgraph(), adg_max_of_leaves(), adg_path_max_source(), and adg_path_possible_source().

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

◆ substitute_var_with_vec()

void substitute_var_with_vec ( Psysteme  ps,
entity  var,
Value  val,
Pvecteur  vec 
)

===========================================================================

void substitute_var_with_vec(Psysteme ps, entity var, int val, Pvecteur vec): Substitutes in a system ("ps") a variable ("var"), factor of a positive value ("val"), by an expression ("vec").

This substitution is done on all assertions of the system (equalities and inequalities). For each assertion (represented by a vector Vold) we have:

 Vold = c*var + Vaux
 val*var = vec

Vnew represents the new assertion. With: p = pgcd(c, val) >= 1, we have:

 Vnew = (c/p)*vec + (val/p)*Vaux = (c/p)*vec + (val/p)*(Vold - c*var)

Note: we have: Vold == 0 <=> (val/p)*Vold == 0 Vold > 0 <=> (val/p)*Vold > 0 ...

because "val" is positive.

"val" must be positive.

Vnew = (c/p)*vec + (val/p)*Vaux = (c/p)*vec + (val/p)*(Vold - c*var)

Parameters
pss
varar
valal
vecec

Definition at line 1210 of file utils.c.

1215 {
1216  Variable Var = (Variable) var;
1218 
1219  ifdebug(7) {
1220 fprintf(stdout, "\t\t\tAvant Sub: \n");
1221 fprint_psysteme(stdout, ps);
1222 fprintf(stdout, "\n");
1223  }
1224 
1225  /* "val" must be positive. */
1226  if(value_neg_p(val)) {
1227  value_oppose(val);
1228  vect_chg_sgn(vec);
1229  }
1230 
1231  /* Vnew = (c/p)*vec + (val/p)*Vaux = (c/p)*vec + (val/p)*(Vold - c*var) */
1232  for(assert = ps->egalites; assert != NULL; assert = assert->succ) {
1233  Pvecteur v_old = assert->vecteur;
1234  Value coeff = vect_coeff(Var, v_old);
1235  if(value_notzero_p(coeff)) {
1236  Value p = pgcd_slow(coeff, val);
1237 
1238  assert->vecteur = vect_cl2_ofl_ctrl
1239  (value_div(coeff,p), vec,
1240  value_div(val,p),
1242  vect_new(Var, coeff),
1243  NO_OFL_CTRL),
1244  NO_OFL_CTRL);
1245  }
1246  }
1247  for(assert = ps->inegalites; assert != NULL; assert = assert->succ) {
1248  Pvecteur v_old = assert->vecteur;
1249  Value coeff = vect_coeff(Var, v_old);
1250  if(value_notzero_p(coeff)) {
1251  Value p = pgcd_slow(coeff, val);
1252 
1253  assert->vecteur = vect_cl2_ofl_ctrl
1254  (value_div(coeff,p), vec,
1255  value_div(val,p),
1257  vect_new(Var, coeff),
1258  NO_OFL_CTRL),
1259  NO_OFL_CTRL);
1260  }
1261  }
1262  vect_rm((Pvecteur) ps->base);
1263  ps->base = (Pbase) NULL;
1264  sc_creer_base(ps);
1265 
1266  ifdebug(7) {
1267  fprintf(stdout, "\t\t\tApres Sub: \n");
1268  fprint_psysteme(stdout, ps);
1269  fprintf(stdout, "\n");
1270  }
1271 
1272 }
#define value_oppose(ref)
#define value_neg_p(val)
#define value_div(v1, v2)
Value pgcd_slow(Value, Value)
pgcd.c
Definition: pgcd.c:44
#define assert(ex)
Definition: newgen_assert.h:41
struct Svecteur * Pbase

References assert, fprint_psysteme(), fprintf(), ifdebug, NO_OFL_CTRL, pgcd_slow(), sc_creer_base(), value_div, VALUE_MONE, value_neg_p, value_notzero_p, VALUE_ONE, value_oppose, vect_chg_sgn(), vect_cl2_ofl_ctrl(), vect_coeff(), vect_new(), and vect_rm().

Referenced by build_third_comb(), change_base_in_sc(), elim_var_with_eg(), and vvs_on_systeme().

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

◆ vect_var_subst()

Pvecteur vect_var_subst ( Pvecteur  vect,
Variable  var,
Pvecteur  new_vect 
)

=================================================================

Pvecteur vect_var_subst(vect,var,new_vect): substitute in the vector "vect", the variable "var" by new_vect. (vect) = (val)x(var) + (vect_aux) => (vect) = (val)x(new_vect) + (vect_aux)

AC 93/12/06

Parameters
vectect
varar
new_vectew_vect

Definition at line 1948 of file utils.c.

1952 {
1954  Value val;
1955 
1956  if ((val = vect_coeff(var,vect)) != 0)
1957  {
1958  vect_erase_var(&vect,var);
1959  vect_aux = vect_multiply(new_vect,val);
1960  vect = vect_add(vect, vect_aux);
1961  }
1962 
1963  return(vect);
1964 }
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
Pvecteur vect_aux
Definition: solpip.c:102

References vect_add(), vect_aux, vect_coeff(), vect_erase_var(), and vect_multiply().

Referenced by constraint_to_bound(), and converti_psysmin_psysmax().

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

◆ vecteur_mult()

Ppolynome vecteur_mult ( Pvecteur  v1,
Pvecteur  v2 
)

========================================================================

Parameters
v11
v22

Definition at line 2024 of file utils.c.

2025 {
2026  Ppolynome pp = POLYNOME_NUL, new_pp;
2027  Pvecteur pv1, pv2, ppv;
2028 
2029  if(VECTEUR_NUL_P(v1) || VECTEUR_NUL_P(v2))
2030  return(POLYNOME_NUL);
2031 
2032  for(pv1 = v1; pv1 != NULL; pv1 = pv1->succ) {
2033  Variable var1 = pv1->var;
2034  Value val1 = pv1->val;
2035  for(pv2 = v2; pv2 != NULL; pv2 = pv2->succ) {
2036  Variable var2 = pv2->var;
2037  Value val2 = pv2->val;
2038  Value p = value_mult(val1,val2);
2039  float f = VALUE_TO_FLOAT(p);
2040 
2041  if(var1 == TCST)
2042  new_pp = make_polynome(f, var2, VALUE_ONE);
2043  else if(var2 == TCST)
2044  new_pp = make_polynome(f, var1, VALUE_ONE);
2045  else if(same_entity_p((entity) var1, (entity) var2))
2046  new_pp = make_polynome(f, var1, VALUE_CONST(2));
2047  else {
2048  new_pp = make_polynome(f, var1, VALUE_ONE);
2049  ppv = (new_pp->monome)->term;
2050  pips_assert("succ is NULL", ppv->succ == NULL);
2051  ppv->succ = vect_new(var2, VALUE_ONE);
2052  }
2053  polynome_add(&pp, new_pp);
2054  }
2055  }
2056  return(pp);
2057 }
#define VALUE_CONST(val)

References f(), make_polynome(), pips_assert, polynome_add(), POLYNOME_NUL, same_entity_p(), Svecteur::succ, TCST, term(), Svecteur::val, VALUE_CONST, value_mult, VALUE_ONE, VALUE_TO_FLOAT, Svecteur::var, vect_new(), and VECTEUR_NUL_P.

Referenced by apply_farkas(), and create_farkas_poly().

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

◆ vecteur_to_list()

list vecteur_to_list ( Pvecteur  v)

===========================================================================

list vecteur_to_list(Pvecteur v): translates a Pvecteur into a list of entities, in the same order. FI: same comment as above: to be moved

Definition at line 1626 of file utils.c.

1627 {
1628  list l = NIL;
1629 
1630  for( ; v != NULL; v = v->succ)
1631  {
1632  entity var = (entity) v->var;
1633  if(var != (entity) TCST)
1634  l = gen_nconc(l, CONS(ENTITY, var, NIL));
1635  }
1636 
1637  return(l);
1638 }

References CONS, ENTITY, gen_nconc(), NIL, Svecteur::succ, TCST, and Svecteur::var.

Referenced by compose_vvs(), plc_make_vvs_with_vector(), system_new_var_subst(), and vvs_on_vvs().

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

◆ vectors_to_expressions()

list vectors_to_expressions ( Pcontrainte  pc)

=================================================================

Parameters
pcc

Definition at line 2245 of file utils.c.

2247 {
2248  list lexp = NIL;
2249  Pcontrainte apc;
2250 
2251  for(apc = pc; apc != NULL; apc = apc->succ) {
2252  expression new_exp = make_vecteur_expression(apc->vecteur);
2253  ADD_ELEMENT_TO_LIST(lexp, EXPRESSION, new_exp);
2254  }
2255  return(lexp);
2256 }
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50

References ADD_ELEMENT_TO_LIST, EXPRESSION, lexp, make_vecteur_expression(), NIL, Scontrainte::succ, and Scontrainte::vecteur.

Referenced by simplify_minmax().

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

◆ vertex_int_stmt()

int vertex_int_stmt ( vertex  v)

===========================================================================

int vertex_int_stmt(vertex v): returns the statement number contained in the vertex. It is a "dfg" vertex.

Definition at line 866 of file utils.c.

References dfg_vertex_label_statement, and vertex_vertex_label.

Referenced by adg_fprint_dfg(), broadcast(), comp_exec_domain(), compare_nodes_dim(), dataflows_on_reference(), edge_weight(), fprint_dfg(), fprint_sccs(), get_predicate_system_of_node(), is_not_trivial_p(), partition_unknowns(), plc_fprint_distance(), plc_make_dim(), plc_make_distance(), plc_make_min_dim(), prgm_mapping(), search_scc_bdt(), sort_dfg_node(), sort_unknowns(), valuer(), and vvs_on_prototypes().

+ Here is the caller graph for this function:

Variable Documentation

◆ bool_compare_objects

bool(* bool_compare_objects) () ( )
static

===========================================================================

list general_merge_sort(list l, bool (*compare_obj)()): returns the result of sorting the list "l" using the comparison function "compare_obj". This bool function should retuns true if its first argument has to be placed before its second argument in the sorted list, else FALSE.

This is a generic function that accepts any homogene list of newgen objects. The comparison function must be coded by the user, its prototype should be: bool my_compare_obj(chunk * obj1, chunk * obj2);

This function uses the merge sort algorithm which has a mean and worst case complexity of n*log(n). There are two steps. First, we look for sublists that are in the right order, each time we found one we put it in a list of lists, a LIFO queue ("head" is the out point, "tail" is the in point). Second, we take the first two lists of our LIFO queue (i.e. at the "head") and meld then into one list that we put again in our LIFO (i.e. at the "tail"). We continue until there remains only one list in our LIFO queue, which in that case is the sorted list we wanted. hack to preserve the bool comparison while using qsort...

Definition at line 1711 of file utils.c.

Referenced by compare_objects(), and new_general_merge_sort().

◆ current_stco_map

statement_mapping current_stco_map = hash_table_undefined
static

These three functions respectively initialize, return and reset the static map of the static control on the statements.

Definition at line 2405 of file utils.c.

Referenced by get_current_stco_map(), reset_current_stco_map(), and set_current_stco_map().