PIPS
icfg_scan.c
Go to the documentation of this file.
1 /*
2 
3  $Id: icfg_scan.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /*
28  icfg_scan.c
29  module_to_icfg(0, mod) recursively to_icfgs module "mod" and its callees
30  and writes its icfg in indented form
31 */
32 #include <stdio.h>
33 #include <string.h>
34 
35 #include "genC.h"
36 #include "linear.h"
37 
38 #include "properties.h" // get_bool_property
39 #include "misc.h"
40 #include "pipsdbm.h" // DB_PUT_FILE_RESOURCE
41 
42 #include "ri.h"
43 #include "effects.h"
44 #include "text.h"
45 
46 #include "text-util.h"
47 #include "ri-util.h"
48 #include "prettyprint.h" // for debugging
49 
50 #include "control.h" // CONTROL_MAP
51 
52 #include "icfg.h"
53 
54 // loops
55 #define st_DO prettyprint_fortran_icfg_p ? "do " : "for "
56 #define st_ENDDO prettyprint_fortran_icfg_p ? "enddo" : "}"
57 #define st_FOR "for "
58 #define st_ENDFOR "}"
59 #define st_DOWHILE prettyprint_fortran_icfg_p ? "do while " : "while "
60 #define st_ENDDOWHILE prettyprint_fortran_icfg_p ? "enddo" : "}"
61 #define st_REPEAT prettyprint_fortran_icfg_p ? "repeat " : "do {"
62 #define st_UNTIL prettyprint_fortran_icfg_p ? "until" : "} while ();"
63 // conditions
64 #define st_IF prettyprint_fortran_icfg_p ? "if" : "if () {"
65 #define st_THEN prettyprint_fortran_icfg_p ? "then" : ""
66 #define st_ELIF prettyprint_fortran_icfg_p ? "else if" : "} else if () {"
67 #define st_ELSE prettyprint_fortran_icfg_p ? "else" : "} else {"
68 #define st_ENDIF prettyprint_fortran_icfg_p ? "endif" : "}"
69 /* These last two strings are used for unstructured */
70 #define st_WHILE prettyprint_fortran_icfg_p? "while": "while () {"
71 #define st_ENDWHILE prettyprint_fortran_icfg_p? "endwhile": "}"
72 
73 #define some_text_p(t) (t!=text_undefined && text_sentences(t)!=NIL)
74 
75 /* We want to keep track of the current statement inside the recurse */
76 #define current_stmt_head() \
77  ((statement) gen_get_ancestor(statement_domain, gen_get_current_object()))
78 
79 /********************************************************** GLOBAL VARIABLES */
80 
81 // indentation
82 #define ICFG_DEFAULT_INDENTATION (4)
84 
85 /* We store the text for each statement in a mapping during a code traversal
86  in order to print it afterwards
87 */
89 
90 /* static drivers
91  */
92 static bool
93  print_loops = false,
94  print_ifs = false,
98 
99 static text (*module_decoration)(const string) = NULL;
101 
104 
105 static int current_margin;
106 
107 static list /* of vertex */ verlist = NIL; /* to make graph daVinci */
108 static vertex current_vertex = NULL; /* caller */
109 
110 /***************************************************************** FUNCTIONS */
111 
112 void icfg_set_indentation(int indent)
113 {
114  icfg_indent = indent;
115 }
116 
118 {
120 }
121 
123 {
124  // ???
125 }
126 
127 static void append_marged_text(
128  text t,
129  int margin,
130  const char* what1,
131  const char* what2)
132 {
133  char *buffer;
134  asprintf(&buffer, "%*s%s%s\n", margin, "", what1, what2);
136 }
137 
138 /* STATEMENT
139  */
140 static bool statement_flt(statement s)
141 {
142  text t;
143 
144  pips_debug (5,"going down\n");
145 
146  /* process the not call statement to print out filtered proper effects */
148  {
149  entity e_caller = get_current_module_entity();
150  t = (*filter_decoration_stmt)(e_caller, s);
151  }
152  else
153  t = make_text (NIL);
154 
155  store_statement_icfg(s, t);
156  return true;
157 }
158 
159 static void statement_rwt(statement s)
160 {
161  pips_debug (5,"going up\n");
162  ifdebug(9) print_text(stderr,(text) load_statement_icfg (s));
163  return;
164 }
165 
166 /* CALL
167  */
168 static void call_flt(call c)
169 {
170  entity e_callee = call_function(c);
171  const string callee_name = (const string) module_local_name(e_callee);
172 
173  pips_debug (5,"called entity is %s\n", entity_name(e_callee));
174 
175  /* If this is a "real function" (defined in the code elsewhere) */
176  if (value_code_p(entity_initial(e_callee))) {
177  text r = (text) load_statement_icfg (current_stmt_head());
178 
179  /* hum... pushes the current entity... */
180  entity e_caller = get_current_module_entity();
181 
182  vertex ver_child = get_vertex_by_string(callee_name, verlist);
183  if (ver_child != vertex_undefined)
185 
186  // this hack is really needed...
189 
190  if (module_decoration)
191  MERGE_TEXTS(r, (*module_decoration)(callee_name));
192  else if (precise_decoration)
193  MERGE_TEXTS(r,
194  (*precise_decoration)(e_caller, e_callee, current_stmt_head(), c));
195  else if (filter_decoration_call)
196  MERGE_TEXTS(r,
197  (*filter_decoration_call)(e_caller, current_stmt_head(), c));
198 
199  // really needed, retrieve the caller entity
201  set_current_module_entity(e_caller);
202 
203  /* append the callee' icfg */
204  /*append_icfg_file (r, callee_name);*/
205  append_marged_text(r, current_margin, CALL_MARK, callee_name);
206  /* store it to the statement mapping */
207  update_statement_icfg(current_stmt_head(), r);
208  }
209  return;
210 }
211 
212 /* LOOP
213  */
214 static bool loop_flt (loop __attribute__ ((unused)) l)
215 {
216  pips_debug (5, "Loop begin\n");
218  return true;
219 }
220 
221 static void anyloop_rwt(
222  const char* st_what,
223  const char* st_end_what,
224  const char* st_index,
225  statement body)
226 {
227  text inside_the_loop = text_undefined,
228  inside_the_do = text_undefined,
229  t = make_text (NIL);
230  bool text_in_do_p, text_in_loop_p;
231 
232  pips_debug (5,"Loop end\n");
233 
235 
236  inside_the_do = (text) load_statement_icfg (current_stmt_head());
237  text_in_do_p = some_text_p(inside_the_do);
238 
239  inside_the_loop = (text) load_statement_icfg (body);
240  text_in_loop_p = some_text_p(inside_the_loop);
241 
242  /* Print the text inside do expressions (before the DO!)
243  */
244  if (text_in_do_p)
245  {
246  pips_debug(9, "something inside_the_do\n");
247  MERGE_TEXTS (t, inside_the_do);
248  }
249 
250  /* Print the DO
251  */
252  if ((text_in_loop_p || text_in_do_p) && print_loops)
253  {
255  append_marged_text(t, current_margin, st_what, st_index);
256  else {
257  string st_end = string_undefined;
258  asprintf(&st_end, "(%s) {", st_index);
259  append_marged_text(t, current_margin, st_what, st_end);
260  free(st_end);
261  }
262  }
263 
264  /* Print the text inside the loop
265  */
266  if (text_in_loop_p)
267  {
268  pips_debug(9, "something inside_the_loop\n");
269  MERGE_TEXTS (t, inside_the_loop);
270  }
271 
272  /* Print the ENDDO
273  */
274  if ((text_in_loop_p || text_in_do_p) && print_loops)
275  {
276  append_marged_text(t, current_margin, st_end_what, "");
277  }
278 
279  /* store it to the statement mapping */
280  update_statement_icfg (current_stmt_head(), t);
281 
282  return ;
283 }
284 
285 static void loop_rwt(loop l)
286 {
288 }
289 
290 static void forloop_rwt(forloop l)
291 {
293 }
294 
295 static void while_rwt(whileloop w)
296 {
298 
299  if(evaluation_before_p(e))
301  else
303 }
304 
305 /* INSTRUCTION
306  */
308 {
311  pips_debug (5, "While begin\n");
313  }
314  return true;
315 }
316 
318 {
319  text t = make_text (NIL);
320  bool text_in_unstructured_p = false;
321 
322  pips_debug (5,"going up\n");
323  pips_debug (9,"instruction tag = %d\n", instruction_tag (i));
324 
325  switch (instruction_tag (i)) {
327  {
328  pips_debug (5,"dealing with a block, appending texts\n");
329 
330  MAP(STATEMENT, s,
331  MERGE_TEXTS(t, load_statement_icfg(s)),
332  instruction_block(i));
333 
334  /* store it to the statement mapping */
335  update_statement_icfg (current_stmt_head (), t);
336  break;
337  }
339  {
341  list blocs = NIL ;
342  control ct = unstructured_control(u) ;
343  text inside_the_unstructured = make_text(NIL);
344  bool while_p = false;
345 
346  pips_debug (5,"dealing with an unstructured, appending texts\n");
347 
348  if(unstructured_while_p(u)) {
349  while_p = true;
350  pips_debug (5,"dealing with a WHILE\n");
351  }
352 
353  /* SHARING! Every statement gets a pointer to the same precondition!
354  I do not know if it's good or not but beware the bugs!!! */
356  statement st = control_statement(c) ;
357  MERGE_TEXTS(inside_the_unstructured, load_statement_icfg (st));
358  }, ct, blocs) ;
359 
360  gen_free_list(blocs) ;
361 
362  text_in_unstructured_p = some_text_p(inside_the_unstructured);
363 
364  /* Print the WHILE
365  */
366  if(print_loops && while_p) {
368  if(text_in_unstructured_p) {
370  }
371  }
372 
373  /* Print the text inside the unstructured (possibly the while body)
374  */
375  if(text_in_unstructured_p) {
376  pips_debug(9, "something inside_the_loop\n");
377  MERGE_TEXTS (t, inside_the_unstructured);
378  }
379 
380  /* Print the ENDDWHILE
381  */
382  if (text_in_unstructured_p && print_loops && while_p)
383  {
385  }
386 
387  update_statement_icfg (current_stmt_head (), t);
388  break;
389  }
390  default:
391  break;
392  }
393 
394 }
395 
396 /* RANGE
397  * functions to avoid the indentation when dealing with DO expressions.
398  */
399 static bool range_flt(range __attribute__ ((unused)) r)
400 {
402 
405  return true;
406 }
407 
408 static void range_rwt(range __attribute__ ((unused)) r)
409 {
411 
414 }
415 
416 /* TEST
417  functions to deal with the indentation of ELSIFs.
418  */
419 
420 /* This function tests if t is the exact content of and ELSE clause.
421  */
422 static bool is_elsif_test_p(test t) {
423 
424  bool elsif_p = false;
425 
426  /*
427  gen_chunk p1 = gen_get_recurse_ancestor((void *)t);
428  gen_chunk * pp1 = &p1;
429  int * pi = pp1;
430  int i = *pi;
431  if (i != ((int)(HASH_UNDEFINED_VALUE)))
432  if ( i != ((int)(NULL)))
433  pips_debug(1, "Type of p1 %d\n", gen_type(i));
434  */
435 
436  /* Determine if t is inside another test */
437  test pt = (test)gen_get_ancestor_type(test_domain, (void *)t);
438  if (pt != (test)HASH_UNDEFINED_VALUE && pt != (test)(NULL)) {
439  // Get the "ELSE Clause" statement of the parent test
440  statement ptf = test_false(pt);
441  ifdebug(4) {
442  pips_debug(4, "Parent test_false is:\n");
443  print_statement(ptf);
444  fprintf(stderr, "\n");
445  }
446 
447  // Get the statement corresponding to t
449  if (ts != (statement)HASH_UNDEFINED_VALUE && ts != (statement)(NULL)) {
450  ifdebug(4) {
451  pips_debug(4, "My test statement is:\n");
452  print_statement(ts);
453  fprintf(stderr, "\n");
454  }
455  // If these two statements are the same, then we are in an ELSIF clause.
456  elsif_p = (ptf == ts);
457  }
458  }
459  return elsif_p;
460 }
461 
462 /* This function tests if the ELSE clause of t is an ELIF.
463  */
464 static bool has_elsif_test_p(test t) {
465 
466  bool has_elsif_p = false;
467 
468  pips_debug (3, ">>>has_elsif_test_p begins for test=%p\n", t);
469 
470  statement tfs = test_false(t);
472 
473  has_elsif_p = instruction_test_p(tfi);
474 
475  pips_debug (3, "has_elsif_p = %d\n", has_elsif_p);
476  pips_debug (3, ">>>has_elsif_test_p ends for test=%p\n", t);
477 
478  return (has_elsif_p);
479 }
480 
481 
482 static bool test_flt (test t)
483 {
484  bool is_elsif_p = false;
485 
486  pips_debug (3, ">>>Test_flt begins for test=%p\n", t);
487 
488  is_elsif_p = is_elsif_test_p(t);
489  int offset = (is_elsif_p ? 0 : icfg_indent);
490 
491  if (print_ifs) {
493  pips_debug( 4, "is_elsif_p = %d\n", is_elsif_p);
494  pips_debug( 4, "current_margin increased: %d -> %d\n",
496  );
497  }
498  pips_debug (3, ">>>Test_flt ends for test=%p\n", t);
499 
500  return true;
501 }
502 
503 static void test_rwt (test l)
504 {
505  text inside_then = text_undefined;
506  text inside_else = text_undefined;
507  text inside_if = text_undefined;
508  text t = make_text (NIL);
509  bool something_to_print;
510 
511  bool is_elsif_p = false;
512  bool has_elsif_p = false;
513  int offset;
514  int else_margin = current_margin;
515 
516  pips_debug (3, ">>>Test_rwt begins for test=%p\n", l);
517 
518  is_elsif_p = is_elsif_test_p(l);
519  has_elsif_p = has_elsif_test_p(l);
520  offset = (is_elsif_p ? 0 : icfg_indent);
521 
522  inside_if = copy_text((text) load_statement_icfg (current_stmt_head ()));
523  inside_then = copy_text((text) load_statement_icfg (test_true (l)));
524  inside_else = copy_text((text) load_statement_icfg (test_false (l)));
525 
526  something_to_print = (some_text_p(inside_else) ||
527  some_text_p(inside_then) ||
528  some_text_p(inside_if));
529 
530  if (print_ifs) {
532  pips_debug( 4, "is_elsif_p = %d\n", is_elsif_p);
533  pips_debug( 4, "current_margin decreased: %d -> %d\n",
535  );
536  }
537 
538  /* Print the IF.
539 
540  If this is the IF of an ELIF, don't print it.
541  */
542  if (something_to_print && print_ifs && !is_elsif_p)
544 
545  /* print things in the if expression*/
546  if (some_text_p(inside_if))
547  MERGE_TEXTS (t, inside_if);
548 
549  /* print then statements */
550  if (some_text_p(inside_then)) {
551  /* Print the THEN */
552  if (something_to_print && print_ifs && strlen(st_THEN)>0) {
554  }
555  MERGE_TEXTS (t, inside_then);
556  }
557 
558  /* print else/elif statements */
559  if (some_text_p(inside_else)){
560  /* Print the ELSE / ELIF */
561  if (something_to_print && print_ifs) {
562 
563  // Margin correction
564  else_margin -= (is_elsif_p ? icfg_indent : 0);
565  else_margin -= (has_elsif_p && !is_elsif_p ? icfg_indent : 0);
566 
567  //else_margin += (has_elsif_p ? icfg_indent : 0);
568  if (has_elsif_p)
569  append_marged_text(t, else_margin, st_ELIF, "");
570  else {
571  append_marged_text(t, else_margin, st_ELSE, "");
572  }
573  }
574  MERGE_TEXTS (t, inside_else);
575  }
576 
577  /* Print the ENDIF.
578 
579  If this is the ENDIF of an ELIF, don't print it
580  */
581  if (something_to_print && print_ifs && !is_elsif_p) {
583  }
584 
585  /* store it to the statement mapping */
586  update_statement_icfg (current_stmt_head(), t);
587 
588  pips_debug (3, ">>>Test_rwt ends for test=%p\n", l);
589 
590  return;
591 }
592 
594 {
595  const char* module_name = module_local_name(module);
597  text txt = make_text(NIL);
598  append_marged_text(txt, 0, module_name, "");
600 
602 
603  /* allocate the mapping */
604  make_icfg_map();
605 
607 
609 
612 
614  (s,
623  NULL);
624 
625  // ???
628  bool found = false;
629  MAP(SENTENCE, sen, {
630  string one_line = sentence_to_string(sen);
631  if (strstr(one_line, CALL_MARK) == NULL) {
632  found = true;
633  break;
634  }
635  }, text_sentences(load_statement_icfg(s)));
636  if (found) {
638  } else {
641  }
642  } else {
644  }
645  } else {
647  }
648 
650  MERGE_TEXTS(txt, (text) load_statement_icfg(s));
651 
653  get_bool_property(ICFG_IFs) ? ".icfgc" :
654  (get_bool_property(ICFG_DOs) ? ".icfgl" :
655  ".icfg"),
656  current_vertex, verlist, true);
657 
659  make_resource_from_starting_node(module_name, DBR_DVICFG_FILE, ".dvicfg",
660  current_vertex, verlist, false);
661 
662  // cleanup
663  free_icfg_map();
666 }
667 
669  const string module_name,
670  bool with_ifs,
671  bool with_loops,
672  bool do_graph,
673  bool do_reset,
674  text (*deco1)(const string),
675  text (*deco2)(entity, entity, statement, call),
676  text (*deco3)(entity, statement, call),
677  text (*deco4)(entity, statement))
678 {
680 
681  pips_debug(1,"===%s===%s===\n", module_name, entity_name(mod));
683 
684  // select language
687 
688  // hmm... not whether sure using properties is a good idea
689  set_bool_property(ICFG_IFs, with_ifs);
690  set_bool_property(ICFG_DOs, with_loops);
691  set_bool_property(ICFG_DV, do_graph);
692 
694 
695  module_decoration = deco1;
696  precise_decoration = deco2;
697  filter_decoration_call = deco3;
698  filter_decoration_stmt = deco4;
699 
700  icfg_set_indentation(get_int_property("ICFG_INDENTATION"));
701  print_module_icfg(mod);
703 
704  module_decoration = NULL;
705  precise_decoration = NULL;
706  filter_decoration_call = NULL;
707  filter_decoration_stmt = NULL;
708 
709  debug_off();
710  return true;
711 }
712 
714  const string module_name,
715  bool with_ifs,
716  bool with_loops,
717  bool do_graph,
718  text (*decoration)(const string))
719 {
720  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
721  true, decoration, NULL, NULL, NULL);
722 }
723 
725  const string module_name,
726  bool with_ifs,
727  bool with_loops,
728  bool do_graph,
729  text (*decoration)(entity, entity, statement, call))
730 {
731  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
732  true, NULL, decoration, NULL, NULL);
733 }
734 
736  const string module_name,
737  bool with_ifs,
738  bool with_loops,
739  bool do_graph,
740  text (*decoration_call)(entity, statement, call),
741  text (*decoration_stmt)(entity, statement))
742 {
743  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
744  false, NULL, NULL, decoration_call, decoration_stmt);
745 }
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
int get_int_property(const string)
vertex make_vertex(vertex_label a1, list a2)
Definition: graph.c:140
text copy_text(text p)
TEXT.
Definition: text.c:71
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
text make_text(list a)
Definition: text.c:107
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
bool unstructured_while_p(unstructured u)
Test if an unstructured is found to be like a structured while-loop.
Definition: cfg.c:191
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
static Value offset
Definition: translation.c:283
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_get_ancestor_type(i, o)
Definition: genC.h:276
void free(void *)
#define vertex_undefined
Definition: graph.h:128
#define vertex_successors(x)
Definition: graph.h:154
#define vertex_undefined_p(x)
Definition: graph.h:129
#define FORWARD_CONTROL_MAP(ctl, code, c, list)
Walk through all the controls forward-reachable from a given control node of an unstructured.
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
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
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#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 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
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement)
Definition: statement.c:349
#define CALL_MARK
Definition: icfg-local.h:49
#define ICFG_DV
Definition: icfg-local.h:38
#define ICFG_DEBUG_LEVEL
Definition: icfg-local.h:35
#define ICFG_IFs
Definition: icfg-local.h:37
#define ICFG_DOs
Definition: icfg-local.h:36
list safe_make_successor(vertex, vertex, list)
Definition: util.c:110
bool make_resource_from_starting_node(const char *, string, string, vertex, list, bool)
Definition: util.c:221
void safe_free_vertex(vertex, list)
util.c
Definition: util.c:43
vertex get_vertex_by_string(const char *, list)
Definition: util.c:92
list safe_add_vertex_to_list(vertex, list)
Definition: util.c:50
static void test_rwt(test l)
Definition: icfg_scan.c:503
static bool loop_flt(loop __attribute__((unused)) l)
LOOP.
Definition: icfg_scan.c:214
#define ICFG_DEFAULT_INDENTATION
Definition: icfg_scan.c:82
static void anyloop_rwt(const char *st_what, const char *st_end_what, const char *st_index, statement body)
Definition: icfg_scan.c:221
static int icfg_indent
Definition: icfg_scan.c:83
#define st_ENDFOR
Definition: icfg_scan.c:58
#define current_stmt_head()
We want to keep track of the current statement inside the recurse.
Definition: icfg_scan.c:76
#define st_THEN
Definition: icfg_scan.c:65
static text(* filter_decoration_call)(entity, statement, call)
Definition: icfg_scan.c:102
static void forloop_rwt(forloop l)
Definition: icfg_scan.c:290
#define st_ELSE
Definition: icfg_scan.c:67
static text(* precise_decoration)(entity, entity, statement, call)
Definition: icfg_scan.c:100
#define some_text_p(t)
Definition: icfg_scan.c:73
#define st_REPEAT
Definition: icfg_scan.c:61
static bool prettyprint_C_icfg_p
Definition: icfg_scan.c:97
static text(* module_decoration)(const string)
Definition: icfg_scan.c:99
bool generic_print_icfg_precise(const string module_name, bool with_ifs, bool with_loops, bool do_graph, text(*decoration)(entity, entity, statement, call))
Definition: icfg_scan.c:724
static void append_marged_text(text t, int margin, const char *what1, const char *what2)
Definition: icfg_scan.c:127
static bool internal_print_icfg(const string module_name, bool with_ifs, bool with_loops, bool do_graph, bool do_reset, text(*deco1)(const string), text(*deco2)(entity, entity, statement, call), text(*deco3)(entity, statement, call), text(*deco4)(entity, statement))
Definition: icfg_scan.c:668
#define st_ENDWHILE
Definition: icfg_scan.c:71
static vertex current_vertex
to make graph daVinci
Definition: icfg_scan.c:108
#define st_ELIF
Definition: icfg_scan.c:66
#define st_IF
Definition: icfg_scan.c:64
void icfg_reset_indentation(void)
Definition: icfg_scan.c:117
#define st_FOR
Definition: icfg_scan.c:57
#define st_DOWHILE
Definition: icfg_scan.c:59
static void range_rwt(range __attribute__((unused)) r)
Definition: icfg_scan.c:408
static void loop_rwt(loop l)
Definition: icfg_scan.c:285
void icfg_error_handler(void)
Definition: icfg_scan.c:122
static void instruction_rwt(instruction i)
Definition: icfg_scan.c:317
static bool do_reset_current_module_entity_on_decoration
Definition: icfg_scan.c:95
static bool print_ifs
Definition: icfg_scan.c:94
void icfg_set_indentation(int indent)
caller
Definition: icfg_scan.c:112
static int current_margin
Definition: icfg_scan.c:105
static void call_flt(call c)
CALL.
Definition: icfg_scan.c:168
#define st_ENDIF
Definition: icfg_scan.c:68
bool generic_print_icfg(const string module_name, bool with_ifs, bool with_loops, bool do_graph, text(*decoration)(const string))
Definition: icfg_scan.c:713
static bool has_elsif_test_p(test t)
This function tests if the ELSE clause of t is an ELIF.
Definition: icfg_scan.c:464
static bool is_elsif_test_p(test t)
TEST functions to deal with the indentation of ELSIFs.
Definition: icfg_scan.c:422
static void statement_rwt(statement s)
Definition: icfg_scan.c:159
#define st_WHILE
These last two strings are used for unstructured.
Definition: icfg_scan.c:70
static void print_module_icfg(entity module)
Definition: icfg_scan.c:593
static bool print_loops
We store the text for each statement in a mapping during a code traversal in order to print it afterw...
Definition: icfg_scan.c:93
static bool instruction_flt(instruction i)
INSTRUCTION.
Definition: icfg_scan.c:307
static bool range_flt(range __attribute__((unused)) r)
RANGE functions to avoid the indentation when dealing with DO expressions.
Definition: icfg_scan.c:399
static text(* filter_decoration_stmt)(entity, statement)
Definition: icfg_scan.c:103
static void while_rwt(whileloop w)
Definition: icfg_scan.c:295
static bool test_flt(test t)
Definition: icfg_scan.c:482
#define st_UNTIL
Definition: icfg_scan.c:62
bool generic_print_icfg_filtered(const string module_name, bool with_ifs, bool with_loops, bool do_graph, text(*decoration_call)(entity, statement, call), text(*decoration_stmt)(entity, statement))
Definition: icfg_scan.c:735
#define st_ENDDO
Definition: icfg_scan.c:56
#define st_ENDDOWHILE
Definition: icfg_scan.c:60
static bool statement_flt(statement s)
STATEMENT.
Definition: icfg_scan.c:140
static bool prettyprint_fortran_icfg_p
Definition: icfg_scan.c:96
#define st_DO
Definition: icfg_scan.c:55
static list verlist
of vertex
Definition: icfg_scan.c:107
#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 asprintf
Definition: misc-local.h:225
#define debug_off()
Definition: misc-local.h:160
void reset_hooks_unregister(reset_func_t)
remove registered cleanup hook.
Definition: reset_hooks.c:73
void reset_hooks_register(reset_func_t)
reset_hooks.c
Definition: reset_hooks.c:44
#define GENERIC_LOCAL_MAPPING(name, result, type)
to allow mappings local to a file.
#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 string_undefined
Definition: newgen_types.h:40
char * string
STRING.
Definition: newgen_types.h:39
static char * module
Definition: pips.c:74
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
void set_bool_property(const char *, bool)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
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
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
struct _newgen_struct_test_ * test
Definition: ri.h:423
#define forloop_domain
newgen_extensions_domain_defined
Definition: ri.h:178
#define loop_body(x)
Definition: ri.h:1644
#define test_domain
newgen_entity_domain_defined
Definition: ri.h:418
#define value_code_p(x)
Definition: ri.h:3065
#define call_function(x)
Definition: ri.h:709
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define test_false(x)
Definition: ri.h:2837
#define whileloop_evaluation(x)
Definition: ri.h:3166
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define instruction_domain
newgen_functional_domain_defined
Definition: ri.h:202
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
@ is_instruction_unstructured
Definition: ri.h:1475
#define instruction_tag(x)
Definition: ri.h:1511
#define entity_name(x)
Definition: ri.h:2790
struct _newgen_struct_call_ * call
Definition: ri.h:63
#define test_true(x)
Definition: ri.h:2835
#define instruction_unstructured_p(x)
Definition: ri.h:1530
#define whileloop_body(x)
Definition: ri.h:3162
#define whileloop_domain
newgen_variable_domain_defined
Definition: ri.h:466
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define instruction_test_p(x)
Definition: ri.h:1515
#define control_statement(x)
Definition: ri.h:941
#define range_domain
newgen_ram_domain_defined
Definition: ri.h:330
#define evaluation_before_p(x)
Definition: ri.h:1159
#define forloop_body(x)
Definition: ri.h:1372
#define instruction_unstructured(x)
Definition: ri.h:1532
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
return(s1)
#define ifdebug(n)
Definition: sg.c:47
static string buffer
Definition: string.c:113
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)
string sentence_to_string(sentence sen)
SG: moved here from icfdg.
Definition: print.c:230
void print_text(FILE *fd, text t)
Definition: print.c:195
struct _newgen_struct_text_ * text
Definition: text.h:23
#define SENTENCE(x)
newgen_unformatted_domain_defined
Definition: text.h:36
#define text_undefined
Definition: text.h:91
#define text_sentences(x)
Definition: text.h:113
@ is_sentence_formatted
Definition: text.h:57