PIPS
polynome_ri.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "complexity_ri.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "effects-util.h"
#include "misc.h"
#include "matrice.h"
#include "complexity.h"
+ Include dependency graph for polynome_ri.c:

Go to the source code of this file.

Functions

char * variable_name (Variable var)
 polynome_ri.c More...
 
char * variable_local_name (Variable var)
 
bool is_inferior_var (Variable var1, Variable var2)
 
int is_inferior_varval (Pvecteur varval1, Pvecteur varval2)
 
int is_inferior_pvarval (Pvecteur *pvarval1, Pvecteur *pvarval2)
 
Variable name_to_variable (char *name)
 
Variable local_name_to_variable (char *name)
 

Function Documentation

◆ is_inferior_pvarval()

int is_inferior_pvarval ( Pvecteur pvarval1,
Pvecteur pvarval2 
)
Parameters
pvarval1varval1
pvarval2varval2

Definition at line 149 of file polynome_ri.c.

150 {
151  int is_inferior;
152 
153  if (term_cst(*pvarval1))
154  is_inferior = -1;
155  else if(term_cst(*pvarval2))
156  is_inferior = 1;
157  else {
158  // FI: should be entity_user_name...
159  is_inferior = strcmp(variable_local_name(vecteur_var(*pvarval1)),
160  variable_local_name(vecteur_var(*pvarval2)));
161  }
162 
163  // FI: Make sure that you do not return 0 for two different entities
164  if(is_inferior==0 && vecteur_var(*pvarval1)!=vecteur_var(*pvarval2)) {
165  is_inferior = strcmp(entity_name((entity)vecteur_var(*pvarval1)),
166  entity_name((entity)vecteur_var(*pvarval2)));
167  }
168 
169  return is_inferior;
170 }
char * variable_local_name(Variable var)
Definition: polynome_ri.c:95
#define entity_name(x)
Definition: ri.h:2790
#define vecteur_var(v)
#define term_cst(varval)

References entity_name, term_cst, variable_local_name(), and vecteur_var.

Referenced by complexity_sprint(), prp(), and translate_complexity_from_local_to_current_name().

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

◆ is_inferior_var()

bool is_inferior_var ( Variable  var1,
Variable  var2 
)
Parameters
var1ar1
var2ar2

Definition at line 118 of file polynome_ri.c.

120 {
121  bool is_inferior = true;
122 
123  if (var1 == TCST)
124  is_inferior = true;
125  else if(var2 == TCST)
126  is_inferior = false;
127  else
128  is_inferior = (strcmp(variable_local_name(var1),
129  variable_local_name(var2)) <= 0 );
130 
131  return is_inferior;
132 }
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.

References TCST, and variable_local_name().

Referenced by is_inferior_monome(), polynome_fprint(), polynome_sort(), polynome_sprint(), and polynome_used_var().

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

◆ is_inferior_varval()

int is_inferior_varval ( Pvecteur  varval1,
Pvecteur  varval2 
)
Parameters
varval1arval1
varval2arval2

Definition at line 134 of file polynome_ri.c.

135 {
136  int is_inferior;
137 
138  if (term_cst(varval1))
139  is_inferior = 1;
140  else if(term_cst(varval2))
141  is_inferior = -1;
142  else
143  is_inferior = - strcmp(variable_local_name(vecteur_var(varval1)),
144  variable_local_name(vecteur_var(varval2)));
145 
146  return is_inferior;
147 }

References term_cst, variable_local_name(), and vecteur_var.

+ Here is the call graph for this function:

◆ local_name_to_variable()

Variable local_name_to_variable ( char *  name)
Parameters
nameame

Definition at line 194 of file polynome_ri.c.

196 {
197  string s = make_entity_fullname("TOP-LEVEL", name);
198 
199  if (strcmp(name, TCST_NAME)==0)
200  return(TCST);
201  /*
202  else if (strcmp(name, UNKNOWN_VARIABLE_NAME) == 0)
203  return (UNKNOWN_VARIABLE);
204  else if (strcmp(name, UNKNOWN_RANGE_NAME) == 0)
205  return (UNKNOWN_RANGE);
206  */
207  else {
209  if (e != entity_undefined)
210  return ((Variable) e);
211  else {
212  user_warning("local_name_to_variable",
213  "entity '%s' not found:return chunk_undefined\n", name);
214  return((Variable) chunk_undefined);
215  }
216  }
217 }
#define TCST_NAME
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define chunk_undefined
obsolete
Definition: genC.h:79
#define user_warning(fn,...)
Definition: misc-local.h:262
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
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 chunk_undefined, entity_domain, entity_undefined, gen_find_tabulated(), make_entity_fullname(), TCST, TCST_NAME, and user_warning.

+ Here is the call graph for this function:

◆ name_to_variable()

Variable name_to_variable ( char *  name)
Parameters
nameame

Definition at line 172 of file polynome_ri.c.

173 {
174  if (strcmp(name, TCST_NAME) == 0)
175  return(TCST);
176  /*
177  else if (strcmp(name, UNKNOWN_VARIABLE_NAME) == 0)
178  return (UNKNOWN_VARIABLE);
179  else if (strcmp(name, UNKNOWN_RANGE_NAME) == 0)
180  return (UNKNOWN_RANGE);
181  */
182  else {
184  if (e != entity_undefined)
185  return ((Variable) e);
186  else {
187  user_warning("name_to_variable",
188  "entity '%s' not found:return chunk_undefined\n", name);
189  return((Variable) chunk_undefined);
190  }
191  }
192 }

References chunk_undefined, entity_domain, entity_undefined, gen_find_tabulated(), TCST, TCST_NAME, and user_warning.

Referenced by polynome_sscanf(), and translate_complexity_from_local_to_current_name().

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

◆ variable_local_name()

char* variable_local_name ( Variable  var)
Parameters
varar

Definition at line 95 of file polynome_ri.c.

97 {
98  string s = NULL;
99 
100  if (var == TCST)
101  s = strdup(TCST_NAME);
102  /*
103  else if (var == UNKNOWN_VARIABLE)
104  s = strdup(UNKNOWN_VARIABLE_NAME);
105  else if (var == UNKNOWN_RANGE)
106  s = strdup(UNKNOWN_RANGE_NAME);
107  */
108  else if (var == (Variable) chunk_undefined)
109  pips_internal_error("unexpected var == chunk_undefined.");
110  else {
111  // s = strdup(entity_local_name((entity) var));
112  s = strdup(entity_minimal_name((entity) var));
113  }
114 
115  return (s);
116 }
#define pips_internal_error
Definition: misc-local.h:149
const char * entity_minimal_name(entity e)
Do preserve scope informations.
Definition: naming.c:214
char * strdup()

References chunk_undefined, entity_minimal_name(), pips_internal_error, strdup(), TCST, and TCST_NAME.

Referenced by complexity_sprint(), final_statement_to_complexity_evaluation(), is_inferior_pvarval(), is_inferior_var(), and is_inferior_varval().

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

◆ variable_name()

char* variable_name ( Variable  var)

polynome_ri.c

This file gathers some functions interfacing polynomial library and the RI.

The "Variable" type used by polynomials is casted to "entity", the "Value" type, to int.

char *variable_name(Variable var) return the complete name of the entity var

char *variable_local_name(Variable var) return the abbreviated, local name of var

bool is_inferior_var(Variable var1, var2) return true if the complete name of var1 is lexicographically before var2's one.

Variable name_to_variable(char *name) inverse function of variable_name. name must be the complete name of the variable. Modif: – entity_local_name is replaced by module_local_name. LZ 230993

FI: no longer useful

Parameters
varar

Definition at line 73 of file polynome_ri.c.

75 {
76  string s = (string) malloc(10);
77 
78  if (var == TCST)
79  s = strdup(TCST_NAME);
80  /* FI: no longer useful */
81  /*
82  else if (var == UNKNOWN_VARIABLE)
83  s = strdup(UNKNOWN_VARIABLE_NAME);
84  else if (var == UNKNOWN_RANGE)
85  s = strdup(UNKNOWN_RANGE_NAME);
86  */
87  else if (var == (Variable) chunk_undefined)
88  pips_internal_error("unexpected var == chunk_undefined.");
89  else
90  s = strdup(entity_name((entity) var));
91 
92  return (s);
93 }
void * malloc(YYSIZE_T)
char * string
STRING.
Definition: newgen_types.h:39

References chunk_undefined, entity_name, malloc(), pips_internal_error, strdup(), TCST, and TCST_NAME.

Referenced by add_parameter_variable_to_module(), add_private_variable_to_module(), adg_contrainte_fprint(), adg_egalite_fprint(), adg_inegalite_fprint(), adg_vecteur_fprint(), base_find_variable_name(), base_find_variable_rank(), base_fprint(), complexity_sprint(), complexity_var_subst(), contrainte_fprint(), contrainte_sprint(), contrainte_sprint_format(), contrainte_text_format(), contrainte_to_text_1(), contrainte_to_text_2(), contrainte_translate(), contraintes_text_format(), egalite_fprint(), egalite_sprint(), egalite_sprint_format(), egalite_text_format(), egalites_fprint(), egalites_to_matrice(), fprint_contrainte_vecteur(), generate_variable_with_unique_name_to_module(), generic_make_entity_copy_with_new_name(), heuristique_1(), heuristique_3(), inegalite_fprint(), inegalite_sprint(), inegalite_sprint_format(), inegalite_text_format(), inegalites_fprint(), make_new_derived_entity_with_prefix(), make_new_scalar_variable_with_prefix(), make_variable_from_name_and_entity(), monome_fprint(), monome_sprint(), polynome_fprint(), polynome_sprint(), print_homogeneous_arguments(), prp(), prv(), pu_contrainte_fprint(), pu_egalite_fprint(), pu_inegalite_fprint(), pvecteur_to_polynome(), relation_to_string(), replace_formal_parameters_by_real_ones(), sc_strong_normalize4(), sc_strong_normalize5(), sc_strong_normalize_and_check_feasibility2(), sc_translate(), sc_variables_rename(), signed_operation_to_textline(), system_sorted_text_format(), system_text_format(), translate_complexity_from_local_to_current_name(), unsigned_operation_to_textline(), vect_fprint(), vect_fprint_as_monome(), vect_print(), vect_rename(), vect_sprint_as_monome(), vect_translate(), and vecteur_fprint().

+ Here is the call graph for this function: