PIPS
prettyprint.c File Reference
#include "local-header.h"
#include "text.h"
#include "text-util.h"
#include "semantics.h"
#include "prettyprint.h"
+ Include dependency graph for prettyprint.c:

Go to the source code of this file.

Macros

#define PROP_SUFFIX   ".proper_reductions"
 
#define CUMU_SUFFIX   ".cumulated_reductions"
 
#define PROP_DECO   "proper reductions"
 
#define CUMU_DECO   "cumulated reductions"
 

Functions

string note_for_statement (statement s)
 generates a short note to tell about the type of the statement being decorated. More...
 
string reduction_operator_tag_name (tag t)
 returns a (static) string describing the tag t reduction More...
 
string reduction_operator_name (reduction_operator o)
 allocates and returns the name of the operator More...
 
string reduction_name (reduction r)
 returns the name of the reduction (!!! not allocated) More...
 
static list words_reduction (reduction r)
 allocates and returns a list of strings for reduction r More...
 
static list words_reductions (string note, reductions rs)
 allocates and returns a list of string with note ahead if not empty. More...
 
void print_reduction (reduction r)
 
static text text_reductions (__attribute__((unused)) entity module, __attribute__((unused)) int margin, statement s)
 function to allocate and returns a text, passed to the prettyprinter uses some static variables: More...
 
static text text_code_reductions (statement s)
 returns a reduction-decorated text for statement s More...
 
static bool print_any_reductions (const char *module_name, string resource_name, string decoration_name, string summary_name, string file_suffix)
 handles the required prettyprint ??? what about summary reductions? should be pprinted with cumulated regions. More...
 
bool print_code_proper_reductions (const char *module_name)
 Handlers for PIPSMAKE. More...
 
bool print_code_cumulated_reductions (const char *module_name)
 

Variables

static string reduction_decoration = NULL
 

Macro Definition Documentation

◆ CUMU_DECO

#define CUMU_DECO   "cumulated reductions"

Definition at line 43 of file prettyprint.c.

◆ CUMU_SUFFIX

#define CUMU_SUFFIX   ".cumulated_reductions"

Definition at line 40 of file prettyprint.c.

◆ PROP_DECO

#define PROP_DECO   "proper reductions"

Definition at line 42 of file prettyprint.c.

◆ PROP_SUFFIX

#define PROP_SUFFIX   ".proper_reductions"

Definition at line 39 of file prettyprint.c.

Function Documentation

◆ note_for_statement()

string note_for_statement ( statement  s)

generates a short note to tell about the type of the statement being decorated.

Definition at line 55 of file prettyprint.c.

56 {
58  switch (instruction_tag(i))
59  {
60  case is_instruction_sequence: return "seq ";
61  case is_instruction_loop: return "loop ";
62  case is_instruction_test: return "test ";
63  case is_instruction_call: return "call ";
64  case is_instruction_unstructured: return "unst ";
65  case is_instruction_whileloop: return "while ";
66  case is_instruction_goto: return "goto ";
67  case is_instruction_forloop: return "for ";
68  case is_instruction_expression: return "expr ";
69  default:
70  pips_internal_error("unexpected instruction tag");
71  break;
72  }
73  return "";
74 }
#define pips_internal_error
Definition: misc-local.h:149
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_expression
Definition: ri.h:1478
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define statement_instruction(x)
Definition: ri.h:2458

References instruction_tag, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, pips_internal_error, and statement_instruction.

Referenced by build_creductions_of_statement(), build_reduction_of_variable(), compute_cumulated_reductions(), list_of_reduced_variables(), and text_reductions().

+ Here is the caller graph for this function:

◆ print_any_reductions()

static bool print_any_reductions ( const char *  module_name,
string  resource_name,
string  decoration_name,
string  summary_name,
string  file_suffix 
)
static

handles the required prettyprint ??? what about summary reductions? should be pprinted with cumulated regions.

@ return true if succeed

Parameters
module_namethe module name to process
resource_namethe resource to use
decoration_name
summary_name
file_suffix

Definition at line 203 of file prettyprint.c.

209 {
210  text t;
211 
212  debug_on("REDUCTIONS_DEBUG_LEVEL");
213  pips_debug(1, "considering module %s for %s\n",
214  module_name, decoration_name);
215 
220  db_get_memory_resource(DBR_CODE, module_name, true));
221  reduction_decoration = decoration_name;
222 
224 
225  if (summary_name)
226  {
227  reductions rs = (reductions)
228  db_get_memory_resource(summary_name, module_name, true);
229  text p =
232  MERGE_TEXTS(p, t);
233  t=p;
234  }
235 
236  make_text_resource_and_free(module_name, DBR_PRINTED_FILE, file_suffix, t);
237 
241  reduction_decoration = NULL;
242 
243  debug_off();
244  return true;
245 }
#define resource_name(x)
Definition: database.h:108
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
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
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 debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
string get_comment_sentinel()
Start a single line comment.
Definition: misc.c:154
bool make_text_resource_and_free(const char *, const char *, const char *, text)
Definition: print.c:82
static list words_reductions(string note, reductions rs)
allocates and returns a list of string with note ahead if not empty.
Definition: prettyprint.c:128
static string reduction_decoration
Definition: prettyprint.c:48
static text text_code_reductions(statement s)
returns a reduction-decorated text for statement s
Definition: prettyprint.c:181
void set_printed_reductions(pstatement_reductions)
void reset_printed_reductions(void)
struct _newgen_struct_reductions_ * reductions
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
text words_predicate_to_commentary(list w_pred, string comment_prefix)
text words_predicate_to_commentary(list w_pred, string comment_prefix) input : a list of strings,...
Definition: prettyprint.c:653
#define MERGE_TEXTS(r, t)

References db_get_memory_resource(), debug_off, debug_on, get_comment_sentinel(), get_current_module_statement(), local_name_to_top_level_entity(), make_text_resource_and_free(), MERGE_TEXTS, module_name(), pips_debug, reduction_decoration, reset_current_module_entity(), reset_current_module_statement(), reset_printed_reductions(), resource_name, set_current_module_entity(), set_current_module_statement(), set_printed_reductions(), text_code_reductions(), words_predicate_to_commentary(), and words_reductions().

Referenced by print_code_cumulated_reductions(), and print_code_proper_reductions().

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

◆ print_code_cumulated_reductions()

bool print_code_cumulated_reductions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 258 of file prettyprint.c.

259 {
261  DBR_CUMULATED_REDUCTIONS,
262  CUMU_DECO,
263  DBR_SUMMARY_REDUCTIONS,
264  CUMU_SUFFIX);
265 }
static bool print_any_reductions(const char *module_name, string resource_name, string decoration_name, string summary_name, string file_suffix)
handles the required prettyprint ??? what about summary reductions? should be pprinted with cumulated...
Definition: prettyprint.c:203
#define CUMU_SUFFIX
Definition: prettyprint.c:40
#define CUMU_DECO
Definition: prettyprint.c:43

References CUMU_DECO, CUMU_SUFFIX, module_name(), and print_any_reductions().

+ Here is the call graph for this function:

◆ print_code_proper_reductions()

bool print_code_proper_reductions ( const char *  module_name)

Handlers for PIPSMAKE.

Parameters
module_nameodule_name

Definition at line 249 of file prettyprint.c.

250 {
252  DBR_PROPER_REDUCTIONS,
253  PROP_DECO,
254  NULL,
255  PROP_SUFFIX);
256 }
#define PROP_SUFFIX
Definition: prettyprint.c:39
#define PROP_DECO
Definition: prettyprint.c:42

References module_name(), print_any_reductions(), PROP_DECO, and PROP_SUFFIX.

+ Here is the call graph for this function:

◆ print_reduction()

void print_reduction ( reduction  r)

Definition at line 137 of file prettyprint.c.

138 {
140  fprintf(stderr, "reduction is %s[",
144  fprintf(stderr, "]\n");
145 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
void print_reference(reference r)
Definition: expression.c:142
string reduction_operator_tag_name(tag t)
returns a (static) string describing the tag t reduction
Definition: prettyprint.c:78
#define reduction_operator_tag(x)
#define reduction_op(x)
#define reduction_reference(x)
#define reference_undefined_p(x)
Definition: ri.h:2303
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), print_reference(), reduction_op, reduction_operator_tag, reduction_operator_tag_name(), reduction_reference, ref, and reference_undefined_p.

Referenced by replace_reductions_in_statement().

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

◆ reduction_name()

string reduction_name ( reduction  r)

returns the name of the reduction (!!! not allocated)

Definition at line 110 of file prettyprint.c.

111 {
113 }
#define reduction_tag(r)

References reduction_operator_tag_name(), and reduction_tag.

+ Here is the call graph for this function:

◆ reduction_operator_name()

string reduction_operator_name ( reduction_operator  o)

allocates and returns the name of the operator

Definition at line 103 of file prettyprint.c.

104 {
106 }
char * strdup()

References reduction_operator_tag, reduction_operator_tag_name(), and strdup().

Referenced by words_reduction().

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

◆ reduction_operator_tag_name()

string reduction_operator_tag_name ( tag  t)

returns a (static) string describing the tag t reduction

Definition at line 78 of file prettyprint.c.

79 {
80  switch(t)
81  {
82  case is_reduction_operator_none: return "none";
83  case is_reduction_operator_sum: return "sum";
84  case is_reduction_operator_csum: return "csum";
85  case is_reduction_operator_prod: return "prod";
86  case is_reduction_operator_min: return "min";
87  case is_reduction_operator_max: return "max";
88  case is_reduction_operator_and: return "and";
89  case is_reduction_operator_or: return "or";
90  case is_reduction_operator_bitwise_or: return "bitwise_or";
91  case is_reduction_operator_bitwise_xor: return "bitwise_xor";
92  case is_reduction_operator_bitwise_and: return "bitwise_and";
93  case is_reduction_operator_eqv: return "eqv";
94  case is_reduction_operator_neqv: return "neqv";
95  default: pips_internal_error("unexpected reduction operator tag!");
96  }
97 
98  return NULL;
99 }
@ is_reduction_operator_bitwise_xor
@ is_reduction_operator_none
@ is_reduction_operator_min
@ is_reduction_operator_bitwise_and
@ is_reduction_operator_neqv
@ is_reduction_operator_max
@ is_reduction_operator_bitwise_or
@ is_reduction_operator_csum
@ is_reduction_operator_eqv
@ is_reduction_operator_prod
@ is_reduction_operator_or
@ is_reduction_operator_and
@ is_reduction_operator_sum

References is_reduction_operator_and, is_reduction_operator_bitwise_and, is_reduction_operator_bitwise_or, is_reduction_operator_bitwise_xor, is_reduction_operator_csum, is_reduction_operator_eqv, is_reduction_operator_max, is_reduction_operator_min, is_reduction_operator_neqv, is_reduction_operator_none, is_reduction_operator_or, is_reduction_operator_prod, is_reduction_operator_sum, and pips_internal_error.

Referenced by call_proper_reduction_p(), print_reduction(), reduction_name(), reduction_operator_name(), remove_variable_from_reduction(), and update_reduction_under_effect().

+ Here is the caller graph for this function:

◆ text_code_reductions()

static text text_code_reductions ( statement  s)
static

returns a reduction-decorated text for statement s

Definition at line 181 of file prettyprint.c.

182 {
183  text t;
184  debug_on("PRETTYPRINT_DEBUG_LEVEL");
188  debug_off();
189  return t;
190 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
void close_prettyprint()
because some prettyprint functions may be used for debug, so the last hook set by somebody may have s...
Definition: misc.c:242
void init_prettyprint(text(*hook)(entity, int, statement))
checks that the prettyprint hook was actually reset...
Definition: misc.c:231
text text_module(entity, statement)
static text text_reductions(__attribute__((unused)) entity module, __attribute__((unused)) int margin, statement s)
function to allocate and returns a text, passed to the prettyprinter uses some static variables:
Definition: prettyprint.c:161

References close_prettyprint(), debug_off, debug_on, get_current_module_entity(), init_prettyprint(), text_module(), and text_reductions().

Referenced by print_any_reductions().

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

◆ text_reductions()

static text text_reductions ( __attribute__((unused)) entity  module,
__attribute__((unused)) int  margin,
statement  s 
)
static

function to allocate and returns a text, passed to the prettyprinter uses some static variables:

  • printed_reductions function
  • function to allocate and returns a text, passed to the prettyprinter uses some static variables:
  • printed_reductions function

unreachable statements?

Definition at line 161 of file prettyprint.c.

162 {
163  text t;
164 
165  debug_on("REDUCTIONS_DEBUG_LEVEL");
166  pips_debug(1, "considering statement %p\n", s);
167 
168  t = bound_printed_reductions_p(s)? /* unreachable statements? */
173  make_text(NIL);
174 
175  debug_off();
176  return t;
177 }
text make_text(list a)
Definition: text.c:107
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
string note_for_statement(statement s)
generates a short note to tell about the type of the statement being decorated.
Definition: prettyprint.c:55
reductions load_printed_reductions(statement)
bool bound_printed_reductions_p(statement)

References bound_printed_reductions_p(), debug_off, debug_on, get_comment_sentinel(), load_printed_reductions(), make_text(), NIL, note_for_statement(), pips_debug, words_predicate_to_commentary(), and words_reductions().

Referenced by text_code_reductions().

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

◆ words_reduction()

static list words_reduction ( reduction  r)
static

allocates and returns a list of strings for reduction r

of string

Definition at line 117 of file prettyprint.c.

118 {
120  CONS(STRING, strdup("["),
122  CONS(STRING, strdup("],"), NIL))));
123 }
#define STRING(x)
Definition: genC.h:87
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
list Words_Reference(reference obj)
Definition: misc.c:786
string reduction_operator_name(reduction_operator o)
allocates and returns the name of the operator
Definition: prettyprint.c:103

References CONS, gen_nconc(), NIL, reduction_op, reduction_operator_name(), reduction_reference, strdup(), STRING, and Words_Reference().

Referenced by words_reductions().

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

◆ words_reductions()

static list words_reductions ( string  note,
reductions  rs 
)
static

allocates and returns a list of string with note ahead if not empty.

it describes the reductions in rs. of string

of string

Definition at line 128 of file prettyprint.c.

129 {
130  list /* of string */ ls = NIL;
132  ls = gen_nconc(words_reduction(r), ls);
133  }
134  return ls? CONS(STRING, strdup(note), ls): NIL;
135 }
#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
static list words_reduction(reduction r)
allocates and returns a list of strings for reduction r
Definition: prettyprint.c:117
#define REDUCTION(x)
REDUCTION.
#define reductions_list(x)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, FOREACH, gen_nconc(), NIL, REDUCTION, reductions_list, strdup(), STRING, and words_reduction().

Referenced by print_any_reductions(), and text_reductions().

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

Variable Documentation

◆ reduction_decoration

string reduction_decoration = NULL
static

Definition at line 48 of file prettyprint.c.

Referenced by print_any_reductions().