PIPS
prettyprint.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "misc.h"
#include "properties.h"
#include "text-util.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "semantics.h"
#include "transformer.h"
#include "pipsdbm.h"
#include "prettyprint.h"
+ Include dependency graph for prettyprint.c:

Go to the source code of this file.

Macros

#define REGION_BUFFER_SIZE   2048
 
#define REGION_FORESYS_PREFIX   "C$REG"
 
#define PIPS_NORMAL_PREFIX   "C"
 
#define append(s)   add_to_current_line(line_buffer, s, str_prefix, t_reg)
 text text_region_no_action(effect reg) input : a region output : a text consisting of several lines of commentaries, representing the region BUT WITHOUT THE ACTION TAG (IN/OUT) modifies : nothing COPIED FROM THE FUNCTION text_region IN FILE effects-convex/prettyprint.c AND MODIFIED TO NOT PRINT ACTION (IN/OUT) More...
 

Functions

static text text_region_no_action (effect reg)
 
static text aliases_text (const char *module_name, string resource_name)
 
static bool print_aliases (const char *module_name, string resource_name, string file_extn)
 
bool print_in_alias_pairs (const char *module_name)
 prettyprint.c More...
 
bool print_out_alias_pairs (const char *module_name)
 
bool print_alias_lists (const char *module_name)
 
bool print_alias_classes (const char *module_name)
 

Macro Definition Documentation

◆ append

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

text text_region_no_action(effect reg) input : a region output : a text consisting of several lines of commentaries, representing the region BUT WITHOUT THE ACTION TAG (IN/OUT) modifies : nothing COPIED FROM THE FUNCTION text_region IN FILE effects-convex/prettyprint.c AND MODIFIED TO NOT PRINT ACTION (IN/OUT)

Definition at line 77 of file prettyprint.c.

◆ PIPS_NORMAL_PREFIX

#define PIPS_NORMAL_PREFIX   "C"

Definition at line 61 of file prettyprint.c.

◆ REGION_BUFFER_SIZE

#define REGION_BUFFER_SIZE   2048

Definition at line 59 of file prettyprint.c.

◆ REGION_FORESYS_PREFIX

#define REGION_FORESYS_PREFIX   "C$REG"

Definition at line 60 of file prettyprint.c.

Function Documentation

◆ aliases_text()

static text aliases_text ( const char *  module_name,
string  resource_name 
)
static

ATTENTION: all this is necessary to call module_to_value_mappings to set up the hash table to translate value into value names before the call to text_region below

that's it, but we musn't forget to rest everything after the call

set_action_interpretation(ACTION_IN,ACTION_OUT);

have to copy alias_list here

set_action_interpretation(ACTION_IN,ACTION_OUT); MERGE_TEXTS(txt,text_region(alias)); reset_action_interpretation();

reset_action_interpretation();

Definition at line 161 of file prettyprint.c.

162 {
164  list al = NIL;
165  entity module;
166  text txt = make_text(NIL);
167 
168  pips_debug(4,"module %s resource %s\n",module_name,resource_name);
169 
173 
174  pips_debug(9,"got aliases\n");
175 
176  /* ATTENTION: all this is necessary to call module_to_value_mappings
177  * to set up the hash table to translate value into value names
178  * before the call to text_region below
179  */
183  (DBR_CODE, module_name, true));
185  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
187  db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true));
188  /* that's it, but we musn't forget to rest everything after the call
189  */
190 
192 
193  pips_debug(9,"hash table set up\n");
194 
195 /* set_action_interpretation(ACTION_IN,ACTION_OUT); */
196 
197  MAP(EFFECTS,alias_list_effects,
198  {
199  list alias_list = effects_effects(alias_list_effects);
200 
201  pips_debug(9,"make text for alias list\n");
202 
203  if (alias_list != (list) HASH_UNDEFINED_VALUE
204  && alias_list != list_undefined)
205  {
206  /* have to copy alias_list here */
207  al = alias_list;
208  MAP(EFFECT,alias,
209  {
210  pips_debug(9,"make text for alias:\n");
211 
212  ifdebug(9)
213  {
215  print_region(alias);
217  }
218 
219 /* set_action_interpretation(ACTION_IN,ACTION_OUT);
220  MERGE_TEXTS(txt,text_region(alias));
221  reset_action_interpretation();
222  */
223 
225  },
226  al);
227 
229  txt,
231  );
232 
233  pips_debug(9,"made text for alias list\n");
234  }
235  },alias_lists);
236 
237  pips_debug(4,"end\n");
238 
239 /* reset_action_interpretation(); */
245 
246  return txt;
247 }
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
text make_text(list a)
Definition: text.c:107
static text text_region_no_action(effect reg)
Definition: prettyprint.c:80
bool alias_lists(const string)
alias_lists.c
Definition: alias_lists.c:328
#define resource_name(x)
Definition: database.h:108
#define ACTION_IN
#define ACTION_OUT
void reset_action_interpretation(void)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void set_action_interpretation(string, string)
prettyprint.c
void reset_cumulated_rw_effects(void)
#define EFFECTS(x)
EFFECTS.
Definition: effects.h:682
#define effects_effects(x)
Definition: effects.h:710
#define effects_classes_classes(x)
Definition: effects.h:678
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
#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
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#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
static char * module
Definition: pips.c:74
#define print_region(x)
Definition: print.c:343
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
char * strdup()
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define MERGE_TEXTS(r, t)
#define ADD_SENTENCE_TO_TEXT(t, p)
@ is_sentence_formatted
Definition: text.h:57
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References ACTION_IN, ACTION_OUT, ADD_SENTENCE_TO_TEXT, alias_lists(), db_get_memory_resource(), EFFECT, EFFECTS, effects_classes_classes, effects_effects, free_value_mappings(), get_current_module_entity(), HASH_UNDEFINED_VALUE, ifdebug, is_sentence_formatted, list_undefined, local_name_to_top_level_entity(), make_sentence(), make_text(), MAP, MERGE_TEXTS, module, module_name(), module_to_value_mappings(), NIL, pips_debug, print_region, reset_action_interpretation(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), resource_name, set_action_interpretation(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_proper_rw_effects(), strdup(), and text_region_no_action().

Referenced by print_aliases().

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

◆ print_alias_classes()

bool print_alias_classes ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 319 of file prettyprint.c.

320 {
321  bool success = true;
322 
323  debug_on("ALIAS_CLASSES_DEBUG_LEVEL");
324  pips_debug(4,"module %s\n",module_name);
325 
326 
327  success = print_aliases(module_name,DBR_ALIAS_CLASSES,".alias_classes");
328 
329  pips_debug(4,"end\n");
330  debug_off();
331 
332  return success;
333 }
static bool print_aliases(const char *module_name, string resource_name, string file_extn)
Definition: prettyprint.c:251
bool success
Definition: gpips-local.h:59
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160

References debug_off, debug_on, module_name(), pips_debug, and print_aliases().

+ Here is the call graph for this function:

◆ print_alias_lists()

bool print_alias_lists ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 304 of file prettyprint.c.

305 {
306  bool success = true;
307 
308  debug_on("ALIAS_LISTS_DEBUG_LEVEL");
309  pips_debug(4,"module %s\n",module_name);
310 
311  success = print_aliases(module_name,DBR_ALIAS_LISTS,".alias_lists");
312 
313  pips_debug(4,"end\n");
314  debug_off();
315 
316  return success;
317 }

References debug_off, debug_on, module_name(), pips_debug, and print_aliases().

+ Here is the call graph for this function:

◆ print_aliases()

static bool print_aliases ( const char *  module_name,
string  resource_name,
string  file_extn 
)
static

Definition at line 251 of file prettyprint.c.

252 {
253  char *file_resource_name;
254  bool success = true;
255 
256  pips_debug(4,"module %s resource %s file extn %s\n",
257  module_name,resource_name,file_extn);
258 
259  file_resource_name = DBR_ALIAS_FILE;
260 
261  success =
263  file_resource_name,
264  file_extn,
266 
267  pips_debug(4,"end\n");
268 
269  return(success);
270 }
static text aliases_text(const char *module_name, string resource_name)
Definition: prettyprint.c:161
bool make_text_resource(const char *, const char *, const char *, text)
print.c
Definition: print.c:55

References aliases_text(), make_text_resource(), module_name(), pips_debug, and resource_name.

Referenced by print_alias_classes(), print_alias_lists(), print_in_alias_pairs(), and print_out_alias_pairs().

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

◆ print_in_alias_pairs()

bool print_in_alias_pairs ( const char *  module_name)

prettyprint.c

Parameters
module_nameodule_name

Definition at line 273 of file prettyprint.c.

274 {
275  bool success = true;
276 
277  debug_on("ALIAS_PAIRS_DEBUG_LEVEL");
278  pips_debug(4,"module %s\n",module_name);
279 
280  success = print_aliases(module_name,DBR_IN_ALIAS_PAIRS,".in_alias");
281 
282  pips_debug(4,"end\n");
283  debug_off();
284 
285  return success;
286 }

References debug_off, debug_on, module_name(), pips_debug, and print_aliases().

+ Here is the call graph for this function:

◆ print_out_alias_pairs()

bool print_out_alias_pairs ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 289 of file prettyprint.c.

290 {
291  bool success = true;
292 
293  debug_on("ALIAS_PAIRS_DEBUG_LEVEL");
294  pips_debug(4,"module %s\n",module_name);
295 
296  success = print_aliases(module_name,DBR_OUT_ALIAS_PAIRS,".out_alias");
297 
298  pips_debug(4,"end\n");
299  debug_off();
300 
301  return success;
302 }

References debug_off, debug_on, module_name(), pips_debug, and print_aliases().

+ Here is the call graph for this function:

◆ text_region_no_action()

static text text_region_no_action ( effect  reg)
static

action ac;

of string

else the effect is defined...

PREFIX

REFERENCE

ACTION and APPROXIMATION

ac = effect_action(reg);

append(action_read_p(ac) ? "R," : "W,");

PIPS prettyprint

append("-"); append(action_interpretation(action_tag(ac)));

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

CLOSE

Definition at line 80 of file prettyprint.c.

81 {
82  text t_reg;
83  bool foresys = get_bool_property("PRETTYPRINT_FOR_FORESYS");
84  string str_prefix = foresys?
87  reference r;
88 /* action ac; */
89  approximation ap;
90  Psysteme sc;
91  Pbase sorted_base;
92  list /* of string */ ls;
93 
94  if(effect_undefined_p(reg))
95  {
96  user_log("[text_region] unexpected effect undefined\n");
97  return
99  strdup(concatenate(str_prefix, "<REGION_UNDEFINED>\n", NULL))),
100  NIL));
101  }
102  /* else the effect is defined...
103  */
104 
105  /* PREFIX
106  */
107  t_reg = make_text(NIL);
109  if (!foresys) append(" <");
110 
111  /* REFERENCE
112  */
113  r = effect_any_reference(reg);
114  ls = foresys? Words_Reference(r): effect_words_reference(r);
115 
116  MAP(STRING, s, append(s), ls);
117  gen_map(free, ls); gen_free_list(ls); ls = NIL;
118 
119  /* ACTION and APPROXIMATION
120  */
121 /* ac = effect_action(reg); */
122  ap = effect_approximation(reg);
123 
124  if (foresys)
125  {
126  append(", RGSTAT(");
127 /* append(action_read_p(ac) ? "R," : "W,"); */
128  append(approximation_may_p(ap) ? "MAY), " : "EXACT), ");
129  }
130  else /* PIPS prettyprint */
131  {
132 /* append("-");
133  append(action_interpretation(action_tag(ac))); */
134  append(approximation_may_p(ap) ? "-MAY" : "-EXACT");
135  append("-");
136  }
137 
138  /* SYSTEM
139  * sorts in such a way that constraints with phi variables come first.
140  */
141  sorted_base = region_sorted_base_dup(reg);
142  sc = sc_dup(region_system(reg));
143  region_sc_sort(sc, sorted_base);
144 
145  system_sorted_text_format(line_buffer, str_prefix, t_reg, sc,
147  vect_contains_phi_p, foresys);
148 
149  sc_rm(sc);
150  base_rm(sorted_base);
151 
152  /* CLOSE */
153  if (!foresys) append(">");
154  close_current_line(line_buffer, t_reg,str_prefix);
155 
156  return t_reg;
157 }
void user_log(const char *format,...)
Definition: message.c:234
#define REGION_FORESYS_PREFIX
Definition: prettyprint.c:60
#define append(s)
text text_region_no_action(effect reg) input : a region output : a text consisting of several lines o...
Definition: prettyprint.c:77
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 region_system(reg)
Pbase region_sorted_base_dup(effect)
void region_sc_sort(Psysteme, Pbase)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
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
const char * pips_region_user_name(entity ent)
char * pips_region_user_name(entity ent) output : the name of entity.
Definition: prettyprint.c:169
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 effect_undefined_p(x)
Definition: effects.h:615
#define approximation_may_p(x)
Definition: effects.h:363
#define effect_approximation(x)
Definition: effects.h:644
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
void free(void *)
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
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
list Words_Reference(reference obj)
Definition: misc.c:786
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_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define FORESYS_CONTINUATION_PREFIX
#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
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
#define base_rm(b)

References append, approximation_may_p, base_rm, close_current_line(), concatenate(), CONS, effect_any_reference, effect_approximation, effect_undefined_p, effect_words_reference(), FORESYS_CONTINUATION_PREFIX, free(), gen_free_list(), gen_map(), get_bool_property(), get_comment_continuation(), get_comment_sentinel(), is_sentence_formatted, line_buffer, make_sentence(), make_text(), MAP, MAX_LINE_LENGTH, NIL, pips_region_user_name(), REGION_FORESYS_PREFIX, region_sc_sort(), region_sorted_base_dup(), region_system, sc_dup(), sc_rm(), SENTENCE, strdup(), STRING, system_sorted_text_format(), user_log(), vect_contains_phi_p(), and Words_Reference().

Referenced by aliases_text().

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