PIPS
prettyprint.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "text-util.h"
#include "top-level.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "points_to_private.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "effects-util.h"
#include "database.h"
#include "resources.h"
#include "properties.h"
#include "misc.h"
+ Include dependency graph for prettyprint.c:

Go to the source code of this file.

Macros

#define PT_TO_SUFFIX   ".points_to"
 
#define PT_TO_DECO   "points to = "
 
#define SUMMARY_PT_TO_SUFFIX   ".summary_points_to"
 
#define SUMMARY_PT_TO_DECO   "summary points to = "
 
#define append(s)   add_to_current_line(line_buffer, s, str_prefix, tpv)
 

Functions

list effect_words_reference (reference obj)
 made from words_reference this function can print entity_name instead of entity_local_name, when the entity is not called in the current program. More...
 
string effect_reference_to_string (reference ref)
 
const char * pips_region_user_name (entity ent)
 char * pips_region_user_name(entity ent) output : the name of entity. More...
 
static bool variable_p (entity e)
 lready exist in cprettyprint but in mode static. More...
 
list words_fictious_reference (reference obj)
 To modelize the heap locations we manufacture fictious reference, that triggered a bug when it appears as an argument of entity_user_name(). More...
 
list points_to_words_reference (reference r)
 Specific handling of references appearing in points_to. More...
 
list word_points_to (points_to pt)
 
int points_to_compare_cells (const void *vpt1, const void *vpt2)
 Comparison of two points-to arcs based on their source and sink nodes. More...
 
list points_to_list_sort (list ptl)
 Allocate a copy of ptl and sort it. More...
 
list words_points_to_list (__attribute__((unused)) string note, points_to_list s)
 Make sure that points-to are fully ordered before prettyprinting them or validation will be in trouble sooner or later. More...
 
list words_pointer_value (cell_relation pv)
 
string approximation_to_string (approximation a)
 
text text_pointer_value (cell_relation pv)
 text text_region(effect reg) input : a region output : a text consisting of several lines of commentaries, representing the region modifies : nothing More...
 
text text_pointer_values (list lpv, string header)
 
void print_pointer_value (cell_relation pv)
 
void print_pointer_values (list lpv)
 

Macro Definition Documentation

◆ append

#define append (   s)    add_to_current_line(line_buffer, s, str_prefix, tpv)

Definition at line 472 of file prettyprint.c.

◆ PT_TO_DECO

#define PT_TO_DECO   "points to = "

Definition at line 202 of file prettyprint.c.

◆ PT_TO_SUFFIX

#define PT_TO_SUFFIX   ".points_to"

Definition at line 201 of file prettyprint.c.

◆ SUMMARY_PT_TO_DECO

#define SUMMARY_PT_TO_DECO   "summary points to = "

Definition at line 204 of file prettyprint.c.

◆ SUMMARY_PT_TO_SUFFIX

#define SUMMARY_PT_TO_SUFFIX   ".summary_points_to"

Definition at line 203 of file prettyprint.c.

Function Documentation

◆ approximation_to_string()

string approximation_to_string ( approximation  a)

Definition at line 458 of file prettyprint.c.

459 {
460  string as = string_undefined;
461  if(approximation_may_p(a))
462  as = "may";
463  else if(approximation_must_p(a))
464  as = "must"; // could be "exact"
465  else if(approximation_exact_p(a))
466  as = "exact";
467  else
468  pips_internal_error("Unknown approximation tag.\n");
469  return as;
470 }
#define approximation_exact_p(x)
Definition: effects.h:369
#define approximation_may_p(x)
Definition: effects.h:363
#define approximation_must_p(x)
Definition: effects.h:366
#define pips_internal_error
Definition: misc-local.h:149
#define string_undefined
Definition: newgen_types.h:40

References approximation_exact_p, approximation_may_p, approximation_must_p, pips_internal_error, and string_undefined.

Referenced by print_or_dump_points_to().

+ Here is the caller graph for this function:

◆ effect_reference_to_string()

string effect_reference_to_string ( reference  ref)
Parameters
refef

Definition at line 155 of file prettyprint.c.

156 {
158 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
list effect_words_reference(reference obj)
made from words_reference this function can print entity_name instead of entity_local_name,...
Definition: prettyprint.c:68
string words_to_string(cons *lw)
Definition: print.c:211

References effect_words_reference(), ref, and words_to_string().

Referenced by check_type_of_points_to_cells(), generic_eval_cell_with_points_to(), generic_transform_sink_cells_from_matching_list(), list_assignment_to_points_to(), offset_cell(), points_to_cell_to_string(), reference_dereferencing_to_points_to(), reference_to_points_to_sinks(), references_may_conflict_p(), and references_must_conflict_p().

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

◆ effect_words_reference()

list effect_words_reference ( reference  obj)

made from words_reference this function can print entity_name instead of entity_local_name, when the entity is not called in the current program.

prettyprint.c

of string

Parameters
objbj

Definition at line 68 of file prettyprint.c.

69 {
70  list pc = NIL;
71  string begin_attachment;
72  entity e = reference_variable(obj);
73 
74  if (get_bool_property("PRETTYPRINT_WITH_COMMON_NAMES")
75  && entity_in_common_p(e)) {
77  } else if (get_bool_property("PRETTYPRINT_EFFECT_WITH_FULL_ENTITY_NAME")) {
78  pc = CHAIN_SWORD(pc, entity_name(e));
79  } else {
80  pc = CHAIN_SWORD(pc, entity_minimal_name(e));
81  }
82 
83  begin_attachment = STRING(CAR(pc));
84 
85  if (reference_indices(obj) != NIL)
86  {
87  string before_first_index = string_undefined;
88  string before_index = string_undefined;
89  string after_index = string_undefined;
90  string after_last_index = string_undefined;
91  string before_field = string_undefined;
92  string after_field = string_undefined;
93 
95  {
98  before_first_index = "(";
99  before_index = "";
100  after_index = ",";
101  after_last_index = ")";
102  before_field = "";
103  after_field = "";
104  break;
105  case is_language_c:
106  before_first_index = "[";
107  before_index = "[";
108  after_index = "]";
109  after_last_index = "]";
110  before_field = ".";
111  after_field = "";
112  break;
113  default:
114  pips_internal_error("Language unknown !");
115  break;
116  }
117 
118  bool first = true;
119  for(list pi = reference_indices(obj); !ENDP(pi); POP(pi))
120  {
121  expression ind_exp = EXPRESSION(CAR(pi));
122  syntax s = expression_syntax(ind_exp);
123  if (syntax_reference_p(s) &&
125  {
126  // add a '.' to disambiguate field names from variable names
127  pc = CHAIN_SWORD(pc, before_field);
128  pc = gen_nconc(pc, Words_Expression(ind_exp));
129  pc = CHAIN_SWORD(pc, after_field);
130  }
131  else
132  {
133  if (first)
134  {
135  pc = CHAIN_SWORD(pc,before_first_index);
136  first = false;
137  }
138  else
139  pc = CHAIN_SWORD(pc,before_index);
140 
141  pc = gen_nconc(pc, Words_Expression(ind_exp));
142  if (CDR(pi) != NIL)
143  pc = CHAIN_SWORD(pc,after_index);
144  else
145  pc = CHAIN_SWORD(pc,after_last_index);
146  }
147  }
148  }
149 
150  attach_reference_to_word_list(begin_attachment, STRING(CAR(gen_last(pc))),
151  obj);
152  return(pc);
153 }
void attach_reference_to_word_list(string begin_word, string end_word, reference r)
Attach a module usage (CALL or function call):
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define STRING(x)
Definition: genC.h:87
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
enum language_utype get_prettyprint_language_tag()
Definition: language.c:67
const char * entity_minimal_name(entity e)
Do preserve scope informations.
Definition: naming.c:214
list Words_Expression(expression obj)
of string
Definition: misc.c:2616
bool entity_field_p(entity e)
e is the field of a structure
Definition: entity.c:857
const char * entity_and_common_name(entity e)
See next function!
Definition: entity.c:654
bool entity_in_common_p(entity e)
Definition: entity.c:1082
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_name(x)
Definition: ri.h:2790
#define reference_indices(x)
Definition: ri.h:2328
#define expression_syntax(x)
Definition: ri.h:1247
@ is_language_fortran
Definition: ri.h:1566
@ is_language_fortran95
Definition: ri.h:1568
@ is_language_c
Definition: ri.h:1567
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define CHAIN_SWORD(l, s)

References attach_reference_to_word_list(), CAR, CDR, CHAIN_SWORD, ENDP, entity_and_common_name(), entity_field_p(), entity_in_common_p(), entity_minimal_name(), entity_name, EXPRESSION, expression_syntax, gen_last(), gen_nconc(), get_bool_property(), get_prettyprint_language_tag(), is_language_c, is_language_fortran, is_language_fortran95, NIL, pips_internal_error, POP, reference_indices, reference_variable, STRING, string_undefined, syntax_reference, syntax_reference_p, and Words_Expression().

Referenced by conflicts_sort_callback(), effect_reference_first_pointer_dimension_rank(), effect_reference_to_string(), make_filtered_dg_or_dvdg(), prettyprint_dependence_graph(), prettyprint_dot_dependence_graph(), text_pointer_value(), text_points_to_relation(), text_region_no_action(), words_pointer_value(), and words_points_to().

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

◆ pips_region_user_name()

const char* pips_region_user_name ( entity  ent)

char * pips_region_user_name(entity ent) output : the name of entity.

modifies : nothing. comment : allows to "catch" the PHIs entities, else, it works like pips_user_value_name() (see semantics.c).

external_value_name cannot be used because there is no need for the #new suffix, but the #old one is necessary

take care of the constant term TCST

ent is a PHI entity from the regions module

if (!hash_entity_to_values_undefined_p() && !entity_has_values_p(ent))

name = external_value_name(ent);

else

Parameters
entnt

Definition at line 169 of file prettyprint.c.

170 {
171  /* external_value_name cannot be used because there is no need for
172  the #new suffix, but the #old one is necessary */
173  const char* name;
174  if(ent == NULL)
175  /* take care of the constant term TCST */
176  name = "";
177  else {
178  char *ent_name = entity_name(ent);
179 
180  if (strncmp(ent_name, REGIONS_MODULE_NAME, 7) == 0)
181  /* ent is a PHI entity from the regions module */
182  name = entity_local_name(ent);
183  else
184  {
185  /* if (!hash_entity_to_values_undefined_p() && !entity_has_values_p(ent)) */
186 /* name = external_value_name(ent); */
187 /* else */
188  name = entity_minimal_name(ent);
189  }
190  }
191 
192  return name;
193 }
#define REGIONS_MODULE_NAME
Already defined.
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

References entity_local_name(), entity_minimal_name(), entity_name, and REGIONS_MODULE_NAME.

Referenced by copy_write_statement_with_cumulated_regions(), reg_sc_debug(), reg_v_debug(), text_pointer_value(), text_points_to_relation(), and text_region_no_action().

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

◆ points_to_compare_cells()

int points_to_compare_cells ( const void *  vpt1,
const void *  vpt2 
)

Comparison of two points-to arcs based on their source and sink nodes.

This comparison function is used to sort a list of points-to before storage and print-out.

It must return -1, 0 or 1 like strcmp(). It should avoid 0 because we want a total order to avoid validation problems. Hence the exploitation of the references, number of indices, subscript expressions, etc. if the entity names are not sufficient to disambiguate the references.

When subscript expressions are used, fields are replaced by the corresponding field number. So the sort is based on the field ranks in the data structure and not on the the field names.

For abstract locations, the local name is used for the sort and the global names is sometimes used in the prettyprint. Hence, the alphabetical order is not obvious in the print-out.

Parameters
vpt1pt1
vpt2pt2

Definition at line 295 of file prettyprint.c.

296 {
297  int i = 0;
298 
299  points_to pt1 = *((points_to *) vpt1);
300  points_to pt2 = *((points_to *) vpt2);
301 
302  cell c1so = points_to_source(pt1);
303  cell c2so = points_to_source(pt2);
304  cell c1si = points_to_sink(pt1);
305  cell c2si = points_to_sink(pt2);
306 
307  //cell c1 = CELL(CAR(vc1));
308  //cell c2 = CELL(CAR(vc2));
309  // FI: bypass of GAP case
310  reference r1so = cell_to_reference(c1so);
311  reference r2so = cell_to_reference(c2so);
312  reference r1si = cell_to_reference(c1si);
313  reference r2si = cell_to_reference(c2si);
314 
315  entity v1so = reference_variable(r1so);
316  entity v2so = reference_variable(r2so);
317  entity v1si = reference_variable(r1si);
319  list sl1 = NIL, sl2 = NIL, sli1 = NIL, sli2 = NIL ;
320  // FI: memory leak? generation of a new string?
321  extern const char* entity_minimal_user_name(entity);
322  string n1so = entity_abstract_location_p(v1so)?
324  string n2so = entity_abstract_location_p(v2so)?
326  string n1si = entity_abstract_location_p(v1si)?
328  string n2si = entity_abstract_location_p(v2si)?
330 
331  i = strcmp(n1so, n2so);
332  if(i==0) {
333  i = strcmp(n1si, n2si);
334  if(i==0) {
335  sl1 = reference_indices(r1so);
336  sl2 = reference_indices(r2so);
337  int i1 = gen_length(sl1);
338  int i2 = gen_length(sl2);
339 
340  i = i2>i1? 1 : (i2<i1? -1 : 0);
341 
342  if(i==0) {
343  sli1 = reference_indices(r1si);
344  sli2 = reference_indices(r2si);
345  int i1 = gen_length(sli1);
346  int i2 = gen_length(sli2);
347 
348  i = i2>i1? 1 : (i2<i1? -1 : 0);
349  // if(i==0) {
350  for(;i==0 && !ENDP(sl1); POP(sl1), POP(sl2)){
351  expression se1 = EXPRESSION(CAR(sl1));
352  expression se2 = EXPRESSION(CAR(sl2));
354  int i1 = expression_to_int(se1);
355  int i2 = expression_to_int(se2);
356  i = i2>i1? -11 : (i2<i1? 1 : 0);
357  } else {
358  string s1 = expression_to_string(se1);
359  string s2 = expression_to_string(se2);
360  i = strcmp(s1, s2);
361  }
362  }
363  // if(i==0) {
364  // i = strcmp(entity_minimal_user_name(v1si), entity_minimal_user_name(v2si));
365  for(;i==0 && !ENDP(sli1); POP(sli1), POP(sli2)){
366  expression sei1 = EXPRESSION(CAR(sli1));
367  expression sei2 = EXPRESSION(CAR(sli2));
368  if(expression_constant_p(sei1) && expression_constant_p(sei2)){
369  int i1 = expression_to_int(sei1);
370  int i2 = expression_to_int(sei2);
371  i = i2>i1? -1 : (i2<i1? 1 : 0);
372  } else {
373  // FI: memory leak?
374  string s1 = expression_to_string(sei1);
375  string s2 = expression_to_string(sei2);
376  i = strcmp(s1, s2);
377  }
378  }
379  }
380  }
381  }
382  // }
383  return i;
384 }
__m64 v2si
Definition: 3dnow.h:7
bool entity_abstract_location_p(entity al)
reference cell_to_reference(cell)
FI: probably to be moved elsewhere in ri-util.
Definition: effects.c:1326
size_t gen_length(const list l)
Definition: list.c:150
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
const char * entity_minimal_user_name(entity e)
Do not preserve scope information.
Definition: naming.c:223
char * string
STRING.
Definition: newgen_types.h:39
#define points_to_sink(x)
#define points_to_source(x)
string expression_to_string(expression e)
Definition: expression.c:77
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
s1
Definition: set.c:247

References CAR, cell_to_reference(), ENDP, entity_abstract_location_p(), entity_local_name(), entity_minimal_user_name(), EXPRESSION, expression_constant_p(), expression_to_int(), expression_to_string(), gen_length(), NIL, points_to_sink, points_to_source, POP, reference_indices, reference_variable, and s1.

Referenced by fi_points_to_storage(), init_points_to_analysis(), points_to_list_sort(), and points_to_storage().

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

◆ points_to_list_sort()

list points_to_list_sort ( list  ptl)

Allocate a copy of ptl and sort it.

It might be better to admit a side effect on ptl and to let the caller copy the liste before sorting.

(gen_cmp_func_t)

Parameters
ptltl

Definition at line 389 of file prettyprint.c.

390 {
391  list sptl = gen_full_copy_list(ptl);
392 
393  gen_sort_list(sptl, /* (gen_cmp_func_t) */ points_to_compare_cells);
394 
395  return sptl;
396 }
int points_to_compare_cells(const void *vpt1, const void *vpt2)
Comparison of two points-to arcs based on their source and sink nodes.
Definition: prettyprint.c:295
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
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

References gen_full_copy_list(), gen_sort_list(), and points_to_compare_cells().

Referenced by text_points_to_relations(), and words_points_to_list().

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

◆ points_to_words_reference()

list points_to_words_reference ( reference  r)

Specific handling of references appearing in points_to.

Definition at line 232 of file prettyprint.c.

233 {
234  extern const char* entity_minimal_user_name(entity);
235 
236  // Normal implementation, used for validation:
238  // To ease debugging, use:
239  //return words_any_reference(r, NIL, entity_full_name);
240 }
list Words_Any_Reference(reference obj, list pdl, const char *(*enf)(entity))
Definition: misc.c:773

References entity_minimal_user_name(), NIL, and Words_Any_Reference().

Referenced by word_points_to().

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

◆ print_pointer_value()

void print_pointer_value ( cell_relation  pv)
Parameters
pvv

Definition at line 615 of file prettyprint.c.

616 {
617  text t = text_pointer_value(pv);
618  print_text(stderr, t);
619  free_text(t);
620 }
void free_text(text p)
Definition: text.c:74
text text_pointer_value(cell_relation pv)
text text_region(effect reg) input : a region output : a text consisting of several lines of commenta...
Definition: prettyprint.c:480
void print_text(FILE *fd, text t)
Definition: print.c:195

References free_text(), print_text(), and text_pointer_value().

Referenced by print_pointer_values().

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

◆ print_pointer_values()

void print_pointer_values ( list  lpv)
Parameters
lpvpv

Definition at line 622 of file prettyprint.c.

623 {
624  fprintf(stderr,"\n");
625  if (ENDP(lpv))
626  fprintf(stderr,"<none>");
627  else
628  {
629  FOREACH(CELL_RELATION, pv, lpv)
630  {
632  }
633  }
634  fprintf(stderr,"\n");
635 }
void print_pointer_value(cell_relation pv)
Definition: prettyprint.c:615
#define CELL_RELATION(x)
CELL_RELATION.
Definition: effects.h:479
#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
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References CELL_RELATION, ENDP, FOREACH, fprintf(), and print_pointer_value().

Referenced by print_pv_results().

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

◆ text_pointer_value()

text text_pointer_value ( cell_relation  pv)

text text_region(effect reg) input : a region output : a text consisting of several lines of commentaries, representing the region modifies : nothing

of string

PREFIX

REFERENCES

DESCRIPTOR

sorts in such a way that constraints with phi variables come first.

APPROXIMATION

CLOSE

Parameters
pvv

Definition at line 480 of file prettyprint.c.

481 {
482  text tpv = text_undefined;
483 
484  bool foresys = false;
485  string str_prefix = get_comment_continuation();
487  Psysteme sc;
488  list /* of string */ ls;
489 
491  {
492  ifdebug(1)
493  {
494  return make_text(CONS(SENTENCE,
496  strdup(concatenate(str_prefix,
497  "undefined pointer value\n",
498  NULL))),
499  NIL));
500  }
501  else
502  pips_user_warning("unexpected pointer value undefined\n");
503  }
504  else
505  tpv = make_text(NIL);
506 
507  cell first_c = cell_relation_first_cell(pv);
508  cell second_c = cell_relation_second_cell(pv);
509 
510  pips_assert("there should not be preference cells in pointer values (first) \n",
511  !cell_preference_p(first_c));
512  pips_assert("there should not be preference cells in pointer values (second) \n",
513  !cell_preference_p(second_c));
514 
515  pips_assert("gaps not handled yet (first)", !cell_gap_p(first_c));
516  pips_assert("gaps not handled yet (second)", !cell_gap_p(second_c));
517 
518  pips_assert("the first cell must have value_of interpretation\n",
520 
521 
522  reference first_r = cell_reference(first_c);
523  reference second_r = cell_reference(second_c);
526 
527  /* PREFIX
528  */
530  append(" ");
531 
532  /* REFERENCES */
533  ls = effect_words_reference(first_r);
534 
535  FOREACH(STRING, s, ls) {append(s);}
536  gen_free_string_list(ls); ls = NIL;
537 
538  append(" == ");
539 
540  ls = effect_words_reference(second_r);
542  append("&");
543 
544  FOREACH(STRING, s, ls) {append(s);}
545  gen_free_string_list(ls); ls = NIL;
546 
547  /* DESCRIPTOR */
548  /* sorts in such a way that constraints with phi variables come first.
549  */
550  if(!descriptor_none_p(d))
551  {
552  sc = sc_copy(descriptor_convex(d));
554  system_sorted_text_format(line_buffer, str_prefix, tpv, sc,
556  vect_contains_phi_p, foresys);
557  sc_rm(sc);
558  }
559 
560  /* APPROXIMATION */
561  append(approximation_may_p(ap) ? " (may);" : " (exact);");
562 
563  /* CLOSE */
564  close_current_line(line_buffer, tpv,str_prefix);
565 
566  return tpv;
567 }
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
text make_text(list a)
Definition: text.c:107
int is_inferior_cell_descriptor_pvarval(Pvecteur *pvarval1, Pvecteur *pvarval2)
weight function for Pvecteur passed as argument to sc_lexicographic_sort in prettyprint functions inv...
Definition: compare.c:305
void system_sorted_text_format(string line, string prefix, text txt, Psysteme ps, string(*variable_name)(Variable), bool(*put_first)(Pvecteur), bool a_la_fortran)
lower level hook for regions.
#define cell_relation_second_cell(cr)
#define cell_relation_second_address_of_p(cr)
#define cell_relation_first_cell(cr)
#define cell_relation_first_value_of_p(cr)
const char * pips_region_user_name(entity ent)
char * pips_region_user_name(entity ent) output : the name of entity.
Definition: prettyprint.c:169
#define append(s)
Definition: prettyprint.c:472
bool vect_contains_phi_p(Pvecteur)
bool vect_contains_phi_p(Pvecteur v) input : a vector output : true if v contains a PHI variable,...
Definition: effects.c:1427
#define cell_reference(x)
Definition: effects.h:469
#define cell_relation_descriptor(x)
Definition: effects.h:517
#define cell_relation_approximation(x)
Definition: effects.h:515
#define cell_gap_p(x)
Definition: effects.h:473
#define descriptor_convex(x)
Definition: effects.h:601
#define cell_preference_p(x)
Definition: effects.h:470
#define descriptor_none_p(x)
Definition: effects.h:602
#define cell_relation_undefined_p(x)
Definition: effects.h:486
void gen_free_string_list(list ls)
Definition: list.c:564
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define pips_user_warning
Definition: misc-local.h:146
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
string get_comment_sentinel()
Start a single line comment.
Definition: misc.c:154
string get_comment_continuation()
Start a single line comment with continuation (blank spaces)
Definition: misc.c:167
static int * line_buffer
le buffer contenant la ligne que l'on doit lire en avance pour se rendre compte qu'on a finit de lire...
Definition: reader.c:251
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
Psysteme sc_copy(Psysteme ps)
Psysteme sc_copy(Psysteme ps): duplication d'un systeme (allocation et copie complete des champs sans...
Definition: sc_alloc.c:230
char * strdup()
void sc_lexicographic_sort(Psysteme sc, int(*compare)(Pvecteur *, Pvecteur *))
Minimize first the lexico-graphic weight of each constraint according to the comparison function "com...
Definition: sc_unaires.c:206
#define ifdebug(n)
Definition: sg.c:47
#define MAX_LINE_LENGTH
maximum length of a line when prettyprinting...
void close_current_line(string, text, string)
Definition: util.c:235
#define SENTENCE(x)
newgen_unformatted_domain_defined
Definition: text.h:36
#define text_undefined
Definition: text.h:91
@ is_sentence_formatted
Definition: text.h:57
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62

References append, approximation_may_p, cell_gap_p, cell_preference_p, cell_reference, cell_relation_approximation, cell_relation_descriptor, cell_relation_first_cell, cell_relation_first_value_of_p, cell_relation_second_address_of_p, cell_relation_second_cell, cell_relation_undefined_p, close_current_line(), concatenate(), CONS, descriptor_convex, descriptor_none_p, effect_words_reference(), FOREACH, gen_free_string_list(), get_comment_continuation(), get_comment_sentinel(), ifdebug, is_inferior_cell_descriptor_pvarval(), is_sentence_formatted, line_buffer, make_sentence(), make_text(), MAX_LINE_LENGTH, NIL, pips_assert, pips_region_user_name(), pips_user_warning, sc_copy(), sc_lexicographic_sort(), sc_rm(), SENTENCE, strdup(), STRING, system_sorted_text_format(), text_undefined, and vect_contains_phi_p().

Referenced by print_pointer_value(), and text_pointer_values().

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

◆ text_pointer_values()

text text_pointer_values ( list  lpv,
string  header 
)

in case of loose_prettyprint, at least one region to print?

GO: No redundant test anymore, see text_statement_array_regions

header first

Parameters
lpvpv
headereader

Definition at line 571 of file prettyprint.c.

572 {
573  text tpv = make_text(NIL);
574  /* in case of loose_prettyprint, at least one region to print? */
575  bool loose_p = get_bool_property("PRETTYPRINT_LOOSE");
576 
577  /* GO: No redundant test anymore, see text_statement_array_regions */
578  if (lpv != (list) HASH_UNDEFINED_VALUE && lpv != list_undefined)
579  {
580  /* header first */
582  string str_prefix = get_comment_continuation();
583  if (loose_p)
584  {
585  strcpy(line_buffer,"\n");
587  }
588  else
589  {
591  }
592  append(" ");
593  append(header);
594  if(ENDP(lpv))
595  append(" none\n");
596  else
597  append("\n");
600  strdup(line_buffer)));
601  gen_sort_list(lpv, (int (*)(const void *,const void *)) pointer_value_compare);
602  FOREACH(CELL_RELATION, pv, lpv)
603  {
605  }
606 
607  if (loose_p)
610  strdup("\n")));
611  }
612  return tpv;
613 }
int pointer_value_compare(cell_relation *ppv1, cell_relation *ppv2)
Compares two pointer values for sorting.
Definition: compare.c:255
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
#define MERGE_TEXTS(r, t)
#define ADD_SENTENCE_TO_TEXT(t, p)

References ADD_SENTENCE_TO_TEXT, append, CELL_RELATION, ENDP, FOREACH, gen_sort_list(), get_bool_property(), get_comment_continuation(), get_comment_sentinel(), HASH_UNDEFINED_VALUE, is_sentence_formatted, line_buffer, list_undefined, make_sentence(), make_text(), MAX_LINE_LENGTH, MERGE_TEXTS, NIL, pointer_value_compare(), strdup(), and text_pointer_value().

Referenced by generic_print_code_pv(), and text_pv().

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

◆ variable_p()

static bool variable_p ( entity  e)
static

lready exist in cprettyprint but in mode static.

To be removed later.

Definition at line 207 of file prettyprint.c.

208 {
209  return type_undefined_p(entity_type(e));
210 }
#define type_undefined_p(x)
Definition: ri.h:2884
#define entity_type(x)
Definition: ri.h:2792

References entity_type, and type_undefined_p.

Referenced by gfc2pips_test_variable(), and word_points_to().

+ Here is the caller graph for this function:

◆ word_points_to()

list word_points_to ( points_to  pt)
Parameters
ptt

Definition at line 242 of file prettyprint.c.

243 {
244  list l2 = NIL, l1 = NIL, rlt1 = NIL;
245 
246  pips_assert("pt is defined", !points_to_undefined_p(pt));
248  cell c1 = points_to_source(pt);
249  cell c2 = points_to_sink(pt);
250  // FI->AM: check all your copy_xxxx(); you often copy a large object
251  // to obtain a small part of it
252  reference r1 = cell_to_reference(c1);
253  reference r2 = cell_to_reference(c2);
255  string l3 = "-MAY-";
256 
257  if (approximation_exact_p(rel))
258  l3 = "-Exact-";
260  l2 = words_fictious_reference(r2);
261  else
262  l2 = points_to_words_reference(r2);
263 
264  l1 = points_to_words_reference(r1);
265 
266  rlt1 = gen_nconc((CONS(STRING,strdup("("), NIL)),l1);
267  rlt1 = gen_nconc(rlt1,(CONS(STRING,strdup(","), NIL)));
268 
269  rlt1 = gen_nconc(rlt1, l2);
270  rlt1 = gen_nconc(rlt1,(CONS(STRING,strdup(","), NIL)));
271  rlt1 = gen_nconc(rlt1,(CONS(STRING,strdup(l3), NIL)));
272  rlt1 = gen_nconc(rlt1,(CONS(STRING,strdup(")"), NIL)));
273  return rlt1;
274 }
bool points_to_consistent_p(points_to p)
static bool variable_p(entity e)
lready exist in cprettyprint but in mode static.
Definition: prettyprint.c:207
list words_fictious_reference(reference obj)
To modelize the heap locations we manufacture fictious reference, that triggered a bug when it appear...
Definition: prettyprint.c:215
list points_to_words_reference(reference r)
Specific handling of references appearing in points_to.
Definition: prettyprint.c:232
#define points_to_approximation(x)
#define points_to_undefined_p(x)

References approximation_exact_p, cell_to_reference(), CONS, gen_nconc(), NIL, pips_assert, points_to_approximation, points_to_consistent_p(), points_to_sink, points_to_source, points_to_undefined_p, points_to_words_reference(), reference_variable, strdup(), STRING, variable_p(), and words_fictious_reference().

Referenced by generic_reference_to_points_to_matching_list(), generic_transform_sink_cells_from_matching_list(), and words_points_to_list().

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

◆ words_fictious_reference()

list words_fictious_reference ( reference  obj)

To modelize the heap locations we manufacture fictious reference, that triggered a bug when it appears as an argument of entity_user_name().

Parameters
objbj

Definition at line 215 of file prettyprint.c.

216 {
217  list pc = NIL;
218  entity e = reference_variable(obj);
219  pc = CHAIN_SWORD(pc, entity_name(e));
220  return(pc);
221 }

References CHAIN_SWORD, entity_name, NIL, and reference_variable.

Referenced by word_points_to().

+ Here is the caller graph for this function:

◆ words_pointer_value()

list words_pointer_value ( cell_relation  pv)
Parameters
pvv

Definition at line 428 of file prettyprint.c.

429 {
430  cell first_c = cell_relation_first_cell(pv);
431  cell second_c = cell_relation_second_cell(pv);
432 
433  pips_assert("there should not be preference cells in pointer values (first) \n",
434  !cell_preference_p(first_c));
435  pips_assert("there should not be preference cells in pointer values (second) \n",
436  !cell_preference_p(second_c));
437 
438  pips_assert("gaps not handled yet (first)", !cell_gap_p(first_c));
439  pips_assert("gaps not handled yet (second)", !cell_gap_p(second_c));
440 
441  pips_assert("the first cell must have value_of interpretation\n",
443 
444  list w = NIL;
445 
446  reference first_r = cell_reference(first_c);
447  reference second_r = cell_reference(second_c);
449  pips_assert("approximation is not must\n", !approximation_exact_p(ap));
450 
451  w= gen_nconc(w, effect_words_reference(first_r));
452  w = CHAIN_SWORD(w," == ");
453  w= gen_nconc(w, effect_words_reference(second_r));
454  w = CHAIN_SWORD(w, approximation_may_p(ap) ? " (may)" : " (exact)" );
455  return (w);
456 }

References approximation_exact_p, approximation_may_p, cell_gap_p, cell_preference_p, cell_reference, cell_relation_approximation, cell_relation_first_cell, cell_relation_first_value_of_p, cell_relation_second_cell, CHAIN_SWORD, effect_words_reference(), gen_nconc(), NIL, and pips_assert.

+ Here is the call graph for this function:

◆ words_points_to_list()

list words_points_to_list ( __attribute__((unused)) string  note,
points_to_list  s 
)

Make sure that points-to are fully ordered before prettyprinting them or validation will be in trouble sooner or later.

The sort could occur before storing the points-to information into the hash table or just before prettypriting it.

Definition at line 403 of file prettyprint.c.

404 {
405  list l = NIL;
406  int i = 0;
407  list ptl = points_to_list_list(s);
408  list sptl = points_to_list_sort(ptl);
409 
410  FOREACH(POINTS_TO, j, sptl) {
411  if(i>0)
412  l = gen_nconc(l, (CONS(STRING,strdup(";"), NIL)));
413  else
414  i++;
415  l = gen_nconc(l,word_points_to(j));
416  }
417  l = CONS(STRING,strdup("{"), l);
418  l = gen_nconc(l,(CONS(STRING,strdup("}"), NIL)));
419 
420  gen_full_free_list(sptl);
421 
422  return l;
423 }
list word_points_to(points_to pt)
Definition: prettyprint.c:242
list points_to_list_sort(list ptl)
Allocate a copy of ptl and sort it.
Definition: prettyprint.c:389
void gen_full_free_list(list l)
Definition: genClib.c:1023
#define points_to_list_list(x)
#define POINTS_TO(x)
POINTS_TO.

References CONS, FOREACH, gen_full_free_list(), gen_nconc(), NIL, POINTS_TO, points_to_list_list, points_to_list_sort(), strdup(), STRING, and word_points_to().

+ Here is the call graph for this function: