PIPS
prettyprint.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include "genC.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrix.h"
#include "ri.h"
#include "effects.h"
#include "graph.h"
#include "paf_ri.h"
#include "database.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "text.h"
#include "static_controlize.h"
#include "text-util.h"
#include "pipsdbm.h"
#include "resources.h"
#include "prettyprint.h"
#include "paf-util.h"
+ Include dependency graph for prettyprint.c:

Go to the source code of this file.

Macros

#define MAX_STATIC_CONTROL_LINE_NUMBER   2048
 
#define CODE_WITH_STATIC_CONTROLIZE_EXT   ".stco"
 
#define MAX_CHAR_NUMBER   39
 

Typedefs

typedef void * arc_label
 Name : prettyprint.c package : static_controlize Author : Arnauld LESERVOT Date : May 93 Modified : Documents : "Implementation of Array Data Flow Graph in Pips" Comments : More...
 
typedef void * vertex_label
 

Functions

bool print_code_static_control (const string module_name)
 ================================================================ More...
 
text text_static_control (entity module __attribute__((unused)), int margin __attribute__((unused)), statement stat)
 ================================================================ More...
 
text store_sc_text_line (static_control sc)
 ================================================================ More...
 
conswords_test_list (list obj)
 ================================================================ More...
 
conswords_loop_list (list obj)
 ================================================================ More...
 
list words_entity_list (list obj)
 ================================================================ More...
 

Variables

static statement_mapping Gsc_map
 Global variables. More...
 

Macro Definition Documentation

◆ CODE_WITH_STATIC_CONTROLIZE_EXT

#define CODE_WITH_STATIC_CONTROLIZE_EXT   ".stco"

Definition at line 78 of file prettyprint.c.

◆ MAX_CHAR_NUMBER

#define MAX_CHAR_NUMBER   39

Definition at line 189 of file prettyprint.c.

◆ MAX_STATIC_CONTROL_LINE_NUMBER

#define MAX_STATIC_CONTROL_LINE_NUMBER   2048

Definition at line 77 of file prettyprint.c.

Typedef Documentation

◆ arc_label

typedef void* arc_label

Name : prettyprint.c package : static_controlize Author : Arnauld LESERVOT Date : May 93 Modified : Documents : "Implementation of Array Data Flow Graph in Pips" Comments :

Ansi includes
Newgen includes Pips includes
Types arc_label and vertex_label must be defined although they are not used

Definition at line 61 of file prettyprint.c.

◆ vertex_label

typedef void* vertex_label

Definition at line 62 of file prettyprint.c.

Function Documentation

◆ print_code_static_control()

bool print_code_static_control ( const string  module_name)

================================================================

cproto-generated files

void print_code_static_control((char*) module_name) AL 05/93 Prettyprints a static_control mapping attached to a module_name.

Parameters
module_nameodule_name

Definition at line 87 of file prettyprint.c.

88 {
89  entity module;
90  statement module_stat;
91  text txt = make_text(NIL);
92  bool success;
93 
94  debug_on( "PRINT_STATIC_CONTROL_DEBUG_LEVEL" );
95 
96  ifdebug(1)
97  user_log("\n\n *** PRINTING STATIC CONTROL for %s\n",
98  module_name);
99 
101  module_stat = (statement)
104  db_get_memory_resource( DBR_STATIC_CONTROL, module_name, true);
106 
107 /*
108  filename = strdup(concatenate(db_get_current_workspace_directory(),
109  "/", module_name, ".stco", NULL));
110  fd = safe_fopen(filename, "w");
111 */
112 
113  MERGE_TEXTS(txt, text_module(module, module_stat));
114 
115 /*
116  print_text(fd, txt);
117  safe_fclose(fd, filename);
118  DB_PUT_FILE_RESOURCE(DBR_PRINTED_FILE, strdup(module_name),
119  filename);
120 */
121 
123  DBR_PRINTED_FILE,
125  txt);
126 
128 
129  debug_off();
130 
131  return(success);
132 }
void user_log(const char *format,...)
Definition: message.c:234
text make_text(list a)
Definition: text.c:107
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool success
Definition: gpips-local.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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 debug_off()
Definition: misc-local.h:160
#define true
Definition: newgen_types.h:81
static char * module
Definition: pips.c:74
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)
bool make_text_resource(const char *, const char *, const char *, text)
print.c
Definition: print.c:55
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
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
return(s1)
#define ifdebug(n)
Definition: sg.c:47
text text_static_control(entity module __attribute__((unused)), int margin __attribute__((unused)), statement stat)
================================================================
Definition: prettyprint.c:139
#define CODE_WITH_STATIC_CONTROLIZE_EXT
Definition: prettyprint.c:78
static statement_mapping Gsc_map
Global variables.
Definition: prettyprint.c:81
#define MERGE_TEXTS(r, t)

References close_prettyprint(), CODE_WITH_STATIC_CONTROLIZE_EXT, db_get_memory_resource(), debug_off, debug_on, Gsc_map, ifdebug, init_prettyprint(), local_name_to_top_level_entity(), make_text(), make_text_resource(), MERGE_TEXTS, module, module_name(), NIL, text_module(), text_static_control(), and user_log().

+ Here is the call graph for this function:

◆ store_sc_text_line()

text store_sc_text_line ( static_control  sc)

================================================================

text store_sc_text_line((static_control) sc) AL 05/93 Stores a static_control prettyprinted.

pips_assert("store_text_line", sefs_list != NIL);

Parameters
scc

Definition at line 152 of file prettyprint.c.

154 {
155  text sc_text = make_text(NIL);
156  char *t = NULL;
157  string comment;
158 
159  /* pips_assert("store_text_line", sefs_list != NIL); */
161  comment = "//";
162  else
163  comment = "C";
164 
165 
166  t = concatenate(comment,"\t\t< is static >",
167  (static_control_yes(sc)?" TRUE":" FALSE"), "\n", NULL);
168  ADD_SENTENCE_TO_TEXT( sc_text,
170  t = concatenate(comment,"\t\t< parameter >",
172  "\n", NULL);
173  ADD_SENTENCE_TO_TEXT( sc_text,
175  t = concatenate(comment,"\t\t< loops >",
177  NULL);
178  ADD_SENTENCE_TO_TEXT( sc_text,
180  t = concatenate(comment,"\t\t< tests >",
182  NULL);
183  ADD_SENTENCE_TO_TEXT( sc_text,
185 
186  return ( sc_text );
187 }
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
Definition: freia_spoc.c:52
enum language_utype get_prettyprint_language_tag()
Definition: language.c:67
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define static_control_loops(x)
Definition: paf_ri.h:757
#define static_control_params(x)
Definition: paf_ri.h:755
#define static_control_yes(x)
Definition: paf_ri.h:753
#define static_control_tests(x)
Definition: paf_ri.h:759
@ is_language_c
Definition: ri.h:1567
char * strdup()
cons * words_test_list(list obj)
================================================================
Definition: prettyprint.c:195
list words_entity_list(list obj)
================================================================
Definition: prettyprint.c:265
cons * words_loop_list(list obj)
================================================================
Definition: prettyprint.c:226
#define ADD_SENTENCE_TO_TEXT(t, p)
string words_to_string(cons *lw)
Definition: print.c:211
@ is_sentence_formatted
Definition: text.h:57

References ADD_SENTENCE_TO_TEXT, comment(), concatenate(), get_prettyprint_language_tag(), is_language_c, is_sentence_formatted, make_sentence(), make_text(), NIL, static_control_loops, static_control_params, static_control_tests, static_control_yes, strdup(), words_entity_list(), words_loop_list(), words_test_list(), and words_to_string().

Referenced by text_static_control().

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

◆ text_static_control()

text text_static_control ( entity module   __attribute__(unused),
int margin   __attribute__(unused),
statement  stat 
)

================================================================

text text_static_control((entity) module, (int) margin, (statement) stat) Function hook used by package text-util to prettyprint a static_control.

Definition at line 139 of file prettyprint.c.

142 {
144 
145  return( store_sc_text_line( sc ));
146 }
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
struct _newgen_struct_static_control_ * static_control
Definition: paf_ri.h:184
text store_sc_text_line(static_control sc)
================================================================
Definition: prettyprint.c:152

References GET_STATEMENT_MAPPING, Gsc_map, and store_sc_text_line().

Referenced by print_code_static_control().

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

◆ words_entity_list()

list words_entity_list ( list  obj)

================================================================

cons *words_entity_list((list) obj) AL 05/93 Returns a list of strings from a list of entities.

FI: Should be moved in ri-util/entity.c or entities.c when it exists

Parameters
objbj

Definition at line 265 of file prettyprint.c.

266 {
267  list the_list = NIL;
268  pips_debug(7, "doing \n");
269  the_list = CHAIN_SWORD(the_list, " ");
270  FOREACH(ENTITY, ent, obj)
271  {
272  string s = strdup(concatenate(entity_local_name(ent), ", ", NULL));
273  ADD_ELEMENT_TO_LIST( the_list, STRING, s );
274  }
275  return the_list;
276 }
#define STRING(x)
Definition: genC.h:87
#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
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
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 ENTITY(x)
ENTITY.
Definition: ri.h:2755
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define CHAIN_SWORD(l, s)

References ADD_ELEMENT_TO_LIST, CHAIN_SWORD, concatenate(), ENTITY, entity_local_name(), FOREACH, NIL, pips_debug, strdup(), and STRING.

Referenced by print_structurals(), and store_sc_text_line().

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

◆ words_loop_list()

cons* words_loop_list ( list  obj)

================================================================

cons *words_loop_list((list) obj) AL 05/93 Returns a list of strings from a list of loops.

Parameters
objbj

Definition at line 226 of file prettyprint.c.

228 {
229  cons* ret_cons = NIL;
230  string before_string = strdup(" ");
231  string blank_string;
233  blank_string = strdup("// ");
234  else
235  blank_string = strdup("C ");
236 
237 
238  pips_debug(7, "doing \n");
239  FOREACH(LOOP, l, obj) {
240  cons* pc = NIL;
241  entity ind = loop_index( l );
242  expression low = range_lower(loop_range( l ));
243  expression up = range_upper(loop_range( l ));
244  pc = CHAIN_SWORD(pc, strdup( before_string ));
245  pc = gen_nconc(pc, Words_Expression(low));
246  pc = CHAIN_SWORD(pc," <= ");
247  pc = CHAIN_SWORD(pc, entity_local_name(ind));
248  pc = CHAIN_SWORD(pc," <= ");
249  pc = gen_nconc(pc, Words_Expression(up));
250  pc = CHAIN_SWORD(pc,"\n") ;
251  ret_cons = gen_nconc(ret_cons, gen_copy_seq(pc));
252  before_string = blank_string;
253  }
254 
255  if( ret_cons == NIL ) ret_cons = CHAIN_SWORD(ret_cons, "\n");
256  return( ret_cons );
257 }
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
list Words_Expression(expression obj)
of string
Definition: misc.c:2616
#define LOOP(x)
LOOP.
Definition: ri.h:1606
#define range_upper(x)
Definition: ri.h:2290
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640

References CHAIN_SWORD, entity_local_name(), FOREACH, gen_copy_seq(), gen_nconc(), get_prettyprint_language_tag(), is_language_c, LOOP, loop_index, loop_range, NIL, pips_debug, range_lower, range_upper, strdup(), and Words_Expression().

Referenced by store_sc_text_line().

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

◆ words_test_list()

cons* words_test_list ( list  obj)

================================================================

cons *words_test_list((list) obj) AL 05/93 Makes a list of strings from a list of test expressions.

Parameters
objbj

Definition at line 195 of file prettyprint.c.

197 {
198  cons* ret_cons = NIL;
199  string before_string = strdup(" ");
200  string blank_string;
202  blank_string = strdup("// ");
203  else
204  blank_string = strdup("C ");
205 
206  pips_debug(7, "doing \n");
207  MAPL( exp_ptr, {
208  cons* pc = NIL;
209  expression exp = EXPRESSION(CAR(exp_ptr));
210 
211  pc = CHAIN_SWORD(pc, strdup( before_string ));
212  pc = gen_nconc(pc, Words_Expression(exp));
213  pc = CHAIN_SWORD(pc,"\n") ;
214  ret_cons = gen_nconc(ret_cons, gen_copy_seq(pc));
215  before_string = blank_string;
216  }, obj);
217 
218  if( ret_cons == NIL ) ret_cons = CHAIN_SWORD(ret_cons, "\n");
219  return( ret_cons );
220 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#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
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References CAR, CHAIN_SWORD, exp, EXPRESSION, gen_copy_seq(), gen_nconc(), get_prettyprint_language_tag(), is_language_c, MAPL, NIL, pips_debug, strdup(), and Words_Expression().

Referenced by store_sc_text_line().

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

Variable Documentation

◆ Gsc_map

statement_mapping Gsc_map
static

Global variables.

Definition at line 81 of file prettyprint.c.

Referenced by print_code_static_control(), and text_static_control().