PIPS
expression.c File Reference
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "text.h"
#include "text-util.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "prettyprint.h"
+ Include dependency graph for expression.c:

Go to the source code of this file.

Functions

void fprint_expression (FILE *f, expression e)
 expression.c More...
 
void print_expression (expression e)
 no file descriptor is passed to make is easier to use in a debugging stage. More...
 
string expression_to_string (expression e)
 
string reference_to_string (reference r)
 
void print_expressions (list le)
 
void print_syntax_expressions (list le)
 
void print_syntax (syntax s)
 
void fprint_reference (FILE *fd, reference r)
 
void print_reference (reference r)
 
void print_reference_list (list lr)
 
void print_references (list rl)
 
void print_normalized (normalized n)
 
bool maxima_simplify (expression *presult)
 call maxima to simplify an expression prefer simplify_expression ! More...
 
void fprint_list_of_exp (FILE *fp, list exp_l)
 void fprint_list_of_exp(FILE *fp, list exp_l): prints in the file "fp" the list of expression "exp_l". More...
 

Function Documentation

◆ expression_to_string()

string expression_to_string ( expression  e)

Definition at line 77 of file expression.c.

77  {
78  list pdl = NIL;
79  list l = words_expression(e, &pdl) ;
80  string out = words_to_string(l);
81  FOREACH(STRING,w,l) free(w);
82  gen_free_list(l);
83  gen_free_list(pdl);
84  return out;
85 }
static FILE * out
Definition: alias_check.c:128
#define STRING(x)
Definition: genC.h:87
void free(void *)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
list words_expression(expression obj, list *ppdl)
This one is exported.
Definition: misc.c:2611
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
string words_to_string(cons *lw)
Definition: print.c:211

References FOREACH, free(), gen_free_list(), NIL, out, STRING, words_expression(), and words_to_string().

Referenced by adg_get_conjonctions(), any_assign_operation_to_transformer(), any_basic_update_to_transformer(), any_expression_to_transformer(), any_scalar_assign_to_transformer_list(), any_scalar_assign_to_transformer_without_effect(), any_update_to_transformer(), atomize_or_associate_for_level(), atomizer_of_array_indices(), atomizer_of_expression(), atomizer_of_intrinsic(), build_third_comb(), c_brace_expression_string(), c_convex_effects_on_formal_parameter_backward_translation(), c_dim_string(), cell_reference_compare(), comp_regions_of_instruction(), consecutive_expression_p(), constraint_to_bound(), copy_n_reference(), do_atomize_if_different_level(), edge_cost_polynome(), equal_condition_to_points_to(), equal_must_vreference(), expression_to_post_pv(), expressions_to_predicate(), fprint_bdt(), fprint_bdt_with_stat(), fprint_plc(), freed_pointer_to_points_to(), freia_is_transpose_call(), get_bounds_expression(), have_null_value_in_pointer_expression_p(), have_sizeof_value_in_multiply_pointer_expression_p(), imprime_quast(), internal_pointer_assignment_to_points_to(), interprocedural_abc_arrays(), intrinsic_call_to_points_to(), is_param_dynamic(), loop_annotate(), make_available_scalar(), make_bottom_up_abc_tests(), make_bounds(), make_expression_equalities(), make_interprocedural_abc_tests(), make_reindex(), MakeCaseStatement(), malloc_arg_to_type(), malloc_to_abstract_location(), mppa_compile_dag(), mppa_helper_args_params(), my_adg_expressions_to_predicate(), ndf_normalized_test(), nlc_linear_expression_p(), non_equal_condition_to_points_to(), normal_expression_of_expression(), normalize_test_leaves(), opkill_may_vreference(), opkill_must_vreference(), perform_array_element_substitutions_in_transformer(), perform_substitution_in_expression(), plc_make_distance(), pointer_binary_operation_to_transformer(), points_to_compare_cell(), points_to_compare_cells(), points_to_compare_location(), points_to_compare_ptr_cell(), points_to_unary_operation_to_transformer(), predicate_to_expression(), prepare_array_bounds(), print_list_of_expressions(), psystem_to_expression(), rational_op_exp(), remove_minmax(), sa_print_ins(), sc_conditional(), sc_delimiter(), semantics_usable_points_to_reference_p(), set_entity_initial(), side_effects_p(), sigmac_params_decl(), sp_feautrier_expression_p(), sp_linear_expression_p(), splc_feautrier_expression_p(), splc_linear_expression_p(), splc_positive_relation_p(), st_brace_expression_as_string(), st_declaration_init(), this_entity_cdeclaration(), translate_IO_ref(), vect_to_string(), words_points_to_reference(), xml_Argument(), xml_Array(), xml_AssignArgument(), xml_Bounds(), xml_Bounds_and_Stride(), xml_Call(), xml_Chain_Graph(), xml_loop(), and xml_Pattern_Paving().

+ Here is the call graph for this function:

◆ fprint_expression()

void fprint_expression ( FILE *  f,
expression  e 
)

expression.c

Definition at line 47 of file expression.c.

48 {
49  list pdl = NIL;
51  gen_free_list(pdl);
52 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
list words_syntax(syntax obj, list *ppdl)
exported for expression.c
Definition: misc.c:2623
#define expression_syntax(x)
Definition: ri.h:1247
void print_words(FILE *fd, cons *lw)
Definition: print.c:263

References expression_syntax, f(), gen_free_list(), NIL, print_words(), and words_syntax().

+ Here is the call graph for this function:

◆ fprint_list_of_exp()

void fprint_list_of_exp ( FILE *  fp,
list  exp_l 
)

void fprint_list_of_exp(FILE *fp, list exp_l): prints in the file "fp" the list of expression "exp_l".

We separate the expressions with a colon (","). We do not end the print with a line feed.

Parameters
fpp
exp_lxp_l

Definition at line 229 of file expression.c.

230 {
231  list aux_l;
232  expression exp;
233  list pdl = NIL;
234 
235  for(aux_l = exp_l; aux_l != NIL; aux_l = CDR(aux_l))
236  {
237  exp = EXPRESSION(CAR(aux_l));
238  fprintf(fp,"%s", words_to_string(words_expression(exp, &pdl)));
239  if(CDR(aux_l) != NIL)
240  fprintf(fp,",");
241  }
242  gen_free_list(pdl);
243 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References CAR, CDR, exp, EXPRESSION, fprintf(), gen_free_list(), NIL, words_expression(), and words_to_string().

Referenced by analyze_quast(), build_first_comb(), build_new_ref(), calculate_delay(), compatible_pc_p(), fprint_call(), fprint_dataflow(), fprint_loop(), get_unsatisfied_system(), include_trans_on_LC_in_ref(), list_of_exp_equals_1n_p(), make_causal_external(), make_causal_internal(), make_reindex(), printf_loop(), search_scc_bdt(), and simplify_dimension().

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

◆ fprint_reference()

void fprint_reference ( FILE *  fd,
reference  r 
)
Parameters
fdd

Definition at line 128 of file expression.c.

129 {
130  if(reference_undefined_p(r))
131  fprintf(fd, "reference undefined\n");
132  // For debugging with gdb, dynamic type checking
134  fprintf(fd, "Not a Newgen \"reference\" object\n");
135  else {
136  list pdl = NIL;
137  print_words(fd,words_reference(r, &pdl));
138  gen_free_list(pdl);
139  }
140 }
list words_reference(reference obj, list *ppdl)
Definition: misc.c:781
#define reference_undefined_p(x)
Definition: ri.h:2303
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define reference_domain_number(x)
Definition: ri.h:2324

References fprintf(), gen_free_list(), NIL, print_words(), reference_domain, reference_domain_number, reference_undefined_p, and words_reference().

Referenced by fprint_wp65_hash_tables(), and print_reference().

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

◆ maxima_simplify()

bool maxima_simplify ( expression presult)

call maxima to simplify an expression prefer simplify_expression !

try to call maxima to simplify this expression

strip out banner

look for first %

skip the three next chars

parse the output

Parameters
presultresult

Definition at line 180 of file expression.c.

180  {
181  bool success = true;
182  expression result = *presult;
183  /* try to call maxima to simplify this expression */
184  if(!expression_undefined_p(result) ) {
185  list pdl = NIL;
186  list w = words_expression(result,&pdl);
187  gen_free_list(pdl);
188  string str = words_to_string(w);
189  gen_free_list(w);
190  char * cmd;
191  asprintf(&cmd,"maxima -q --batch-string \"string(fullratsimp(%s));\"\n",str);
192  free(str);
193  FILE* pout = popen(cmd,"r");
194  if(pout) {
195  /* strip out banner */
196  fgetc(pout);fgetc(pout);
197  /* look for first % */
198  while(!feof(pout) && fgetc(pout)!='%');
199  if(!feof(pout)) {
200  /* skip the three next chars */
201  fgetc(pout);fgetc(pout);fgetc(pout);
202  /* parse the output */
203  char bufline[strlen(cmd)];
204  if(fscanf(pout," %s\n",&bufline[0]) == 1 ) {
207  free_expression(result);
208  *presult=exp;
209  }
210  else
211  success= false;
212  }
213  }
214  else
215  success= false;
216  pclose(pout);
217  }
218  else
219  success= false;
220  free(cmd);
221  }
222  return success;
223 }
void free_expression(expression p)
Definition: ri.c:853
expression string_to_expression(const char *s, entity module)
Functions using simultaneously pipsdbm, which is based on strings, and ri-util, which contains basic ...
Definition: expressions.c:50
bool success
Definition: gpips-local.h:59
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define asprintf
Definition: misc-local.h:225
#define expression_undefined_p(x)
Definition: ri.h:1224

References asprintf, exp, expression_undefined_p, free(), free_expression(), gen_free_list(), get_current_module_entity(), NIL, string_to_expression(), words_expression(), and words_to_string().

+ Here is the call graph for this function:

◆ print_expression()

void print_expression ( expression  e)

no file descriptor is passed to make is easier to use in a debugging stage.

Do not make macros of those printing functions

Definition at line 58 of file expression.c.

59 {
61  (void) fprintf(stderr,"EXPRESSION UNDEFINED\n");
62  // For debugging with gdb, dynamic type checking
64  (void) fprintf(stderr,"Arg. \"e\"is not an expression.\n");
65  else {
66  normalized n;
67  (void) fprintf(stderr,"syntax = ");
69  (void) fprintf(stderr,"\nnormalized = ");
72  else
73  (void) fprintf(stderr,"NORMALIZED UNDEFINED\n");
74  }
75 }
void print_normalized(normalized n)
Definition: expression.c:168
void print_syntax(syntax s)
Definition: expression.c:121
#define normalized_undefined
Definition: ri.h:1745
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define expression_undefined
Definition: ri.h:1223
#define expression_normalized(x)
Definition: ri.h:1249
#define expression_domain_number(x)
Definition: ri.h:1245

References expression_domain, expression_domain_number, expression_normalized, expression_syntax, expression_undefined, fprintf(), normalized_undefined, print_normalized(), and print_syntax().

Referenced by abc_with_allocation_size(), affine_expression_of_loop_index_p(), alias_check_array_and_scalar_variable_in_caller_flt(), alias_check_array_variable_in_caller_flt(), any_basic_update_to_transformer(), any_expression_to_transformer(), array_size_stride(), atom_cse_expression(), atomize_this_expression(), bottom_up_abc_base_reference_implied_do(), bottom_up_abc_reference(), call_rwt(), copy_from_statement(), copy_from_test(), copy_to_statement(), copy_to_test(), cse_expression_flt(), debug_cost_expression_array(), dprint(), expr_cse_flt(), expression_equal_in_context_p(), expression_in_array_subscript(), expression_less_than_in_context(), expression_substitute_variable(), expression_to_points_to_sources(), find_entities_to_wrap(), formal_variable_add_aliases(), gfc2pips_code2instruction_(), Hierarchical_tiling(), HpfcExpressionToInt(), impact_check_two_scalar_variables_in_path(), integer_expression_to_transformer(), interprocedural_abc_arrays(), invariant_expression_p(), loop_flt(), loop_strip_mine(), make_list_of_flags(), make_send_receive_conversion(), MakeDimension(), MemberIdentifierToExpression(), partial_eval_reference(), pointer_expression_to_transformer(), print_alias_association(), print_alignment(), print_dimension(), print_distribution(), print_eformat(), print_expressions(), proper_to_summary_simple_effect(), ram_variable_add_aliases(), remove_minmax(), rename_statement_declarations(), same_or_equivalence_argument_add_aliases(), size_of_dummy_array(), split_update_call(), store_initial_value(), subscript_value(), substitute_and_create(), substitute_ghost_variable_in_expression(), Tiling_buffer_allocation(), top_down_abc_array(), top_down_abc_call(), transformer_add_condition_information_updown(), transformer_add_integer_relation_information(), translate_to_module_frame(), verify_array_element(), verify_used_before_set_call(), and verify_used_before_set_expression().

+ Here is the call graph for this function:

◆ print_expressions()

void print_expressions ( list  le)
Parameters
lee

Definition at line 98 of file expression.c.

99 {
100 
101  MAP(EXPRESSION, e , {
102  print_expression(e);
103  },
104  le);
105 
106 }
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58

References EXPRESSION, MAP, and print_expression().

Referenced by add_prettyprint_control_list_to_declaration_statement(), dprint(), MakeFunctionExpression(), outliner_parameters(), and verify_used_before_set_call().

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

◆ print_normalized()

void print_normalized ( normalized  n)

should be replaced by a call to expression_fprint() if it's ever added to linear library

Definition at line 168 of file expression.c.

169 {
170  if(normalized_complex_p(n))
171  (void) fprintf(stderr,"COMPLEX\n");
172  else
173  /* should be replaced by a call to expression_fprint() if it's
174  ever added to linear library */
176 }
void vect_debug(Pvecteur v)
constraint.c
Definition: constraint.c:43
#define normalized_complex_p(x)
Definition: ri.h:1782
#define normalized_linear(x)
Definition: ri.h:1781
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89

References fprintf(), normalized_complex_p, normalized_linear, and vect_debug().

Referenced by print_expression().

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

◆ print_reference()

◆ print_reference_list()

void print_reference_list ( list  lr)
Parameters
lrr

Definition at line 147 of file expression.c.

148 {
149  if(ENDP(lr))
150  fputs("NIL", stderr);
151  else
152  MAPL(cr,
153  {
154  reference r = REFERENCE(CAR(cr));
155  entity e = reference_variable(r);
156  (void) fprintf(stderr,"%s, ", entity_local_name(e));
157  },
158  lr);
159 
160  (void) putc('\n', stderr);
161 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
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 REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define reference_variable(x)
Definition: ri.h:2326

References CAR, ENDP, entity_local_name(), fprintf(), MAPL, REFERENCE, and reference_variable.

Referenced by call_instruction_to_communications(), loop_nest_to_local_variables(), and print_references().

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

◆ print_references()

void print_references ( list  rl)
Parameters
rll

Definition at line 163 of file expression.c.

164 {
166 }
void print_reference_list(list lr)
Definition: expression.c:147

References print_reference_list().

Referenced by dprint(), and UseFormalArguments().

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

◆ print_syntax()

void print_syntax ( syntax  s)

Definition at line 121 of file expression.c.

122 {
123  list pdl = NIL;
124  print_words(stderr,words_syntax(s, &pdl));
125  gen_free_list(pdl);
126 }

References gen_free_list(), NIL, print_words(), and words_syntax().

Referenced by interprocedural_mapping(), make_send_receive_conversion(), print_expression(), and print_syntax_expressions().

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

◆ print_syntax_expressions()

void print_syntax_expressions ( list  le)
Parameters
lee

Definition at line 108 of file expression.c.

109 {
110 
111  MAP(EXPRESSION, e , {
113  if(!ENDP(CDR(le))) {
114  (void) fprintf(stderr, ", ");
115  }
116  },
117  le);
118 
119 }

References CDR, ENDP, EXPRESSION, expression_syntax, fprintf(), MAP, and print_syntax().

+ Here is the call graph for this function:

◆ reference_to_string()

string reference_to_string ( reference  r)

Definition at line 87 of file expression.c.

87  {
88  list pdl = NIL;
89  list l = words_reference(r,&pdl) ;
90  gen_free_list(pdl);
91  string out = words_to_string(l);
92  FOREACH(STRING,w,l) free(w);
93  gen_free_list(l);
94  return out;
95 }

References FOREACH, free(), gen_free_list(), NIL, out, STRING, words_reference(), and words_to_string().

Referenced by adapt_reference_to_type(), add_address_of_value(), analyzed_reference_p(), any_assign_to_transformer(), any_basic_update_to_transformer(), any_update_to_transformer(), attach_ref_to_loop(), basic_update_reflhs_with_rhs_to_transformer(), cell_is_xxx_p(), cell_reference_to_type(), constant_memory_access_path_to_location_name(), convex_cell_reference_preceding_p(), count_dataflows_on_ref(), dereferencing_to_sinks(), extended_source_to_sinks(), filter_formal_context_according_to_actual_context(), forward_substitute_array_location_in_transformer(), fprint_dataflow(), generic_eval_cell_with_points_to(), lhs_subs_in_ins(), new_array_element_backward_substitution_in_transformer(), new_filter_formal_context_according_to_actual_context(), perform_substitution_in_expression(), points_to_cell_name(), points_to_name(), points_to_rank(), points_to_unary_operation_to_transformer(), potential_to_effective_memory_leaks(), print_value_mappings(), print_variables(), process_ref_list(), reduction_as_str(), reference_to_address_entity(), reference_to_address_of_value(), sa_do_it(), semantics_usable_points_to_reference_p(), simple_cell_reference_preceding_p(), simple_pv_translate(), successor_only_has_rr_conflict_p(), and update_reflhs_with_rhs_to_transformer().

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