Moved memwalk stuf into irmemwalk
[libfirm] / ir / ana2 / pto.c
1 /* -*- c -*- */
2
3 /*
4  * Project:     libFIRM
5  * File name:   ir/ana2/pto.c
6  * Purpose:     Pto
7  * Author:      Florian
8  * Modified by:
9  * Created:     Mon 18 Oct 2004
10  * CVS-ID:      $Id$
11  * Copyright:   (c) 1999-2004 Universität Karlsruhe
12  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  */
14
15
16 # ifdef HAVE_CONFIG_H
17 #  include <config.h>
18 # endif
19
20 # include "pto.h"
21
22 # include "entity.h"
23
24
25 # include "irnode_t.h"
26 # include "irprog_t.h"
27
28 /* # include "eset.h" */
29 # include "irgraph.h"
30 # include "irgwalk.h"
31 # include "irgmod.h"
32 # include "irvrfy.h"
33 # include "trvrfy.h"
34 # include "xmalloc.h"
35
36 # include "irmemwalk.h"
37
38 # ifndef TRUE
39 #  define TRUE 1
40 #  define FALSE 0
41 # endif /* not defined TRUE */
42
43 /* BEGIN TEST */
44 /*
45 static void pto_node_pre (ir_node *node, void *__unused)
46 {
47   fprintf (stdout, "PRE  MEM Node (0x%08x) (%s)\n",
48            (int)  node,
49            get_op_name (get_irn_op (node)));
50            }
51 */
52
53 static void pto_node_post (ir_node *node, void *__unused)
54 {
55   const opcode op = get_irn_opcode (node);
56
57
58   if (iro_Call == op) {
59     entity *ent = NULL;
60     ir_graph *graph = NULL;
61     fprintf (stdout, "POST MEM Call Node (0x%08x)\n",
62              (int) node);
63
64     ir_node *ptr = get_Call_ptr (node);
65
66     if (iro_Sel == get_irn_opcode (ptr)) {
67       ent = get_Sel_entity (ptr);
68     } else if (iro_SymConst == get_irn_opcode (ptr)) {
69       if (get_SymConst_kind(ptr) == symconst_addr_ent) {
70         ent = get_SymConst_entity (ptr);
71       }
72     }
73
74     if (NULL != ent) {
75       graph = get_entity_irg (ent);
76       if (NULL != graph) {
77         if (! get_irg_is_mem_visited (graph)) {
78
79           fprintf (stdout, " -> visit  graph (0x%08x) of \"%s.%s\"\n",
80                    (int) graph,
81                    get_type_name (get_entity_owner (get_irg_entity (graph))),
82                    get_entity_name (get_irg_entity (graph)));
83
84           /* irg_walk_mem (graph, pto_node_pre, pto_node_post, NULL); */
85           irg_walk_mem (graph, NULL, pto_node_post, NULL);
86         }
87       }
88     }
89   } else {
90     fprintf (stdout, "POST MEM Node (0x%08x) (%s)\n",
91              (int)  node,
92              get_op_name (get_irn_op (node)));
93   }
94 }
95
96
97 /* END TEST */
98
99 /*
100    Test irg_walk_mem
101 */
102 void pto_test_mem ()
103 {
104   int i;
105
106   fprintf (stdout, "START PTO TEST\n");
107
108   for (i = 0; i < get_irp_n_irgs(); i++) {
109     ir_graph *graph = get_irp_irg (i);
110
111     fprintf (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n",
112              (int) graph,
113              get_type_name (get_entity_owner (get_irg_entity (graph))),
114              get_entity_name (get_irg_entity (graph)));
115     /* irg_walk_mem (graph, pto_node_pre, pto_node_post, NULL); */
116     irg_walk_mem (graph, NULL, pto_node_post, NULL);
117     fprintf (stdout, "END   GRAPH (0x%08x)\n", (int) graph);
118   }
119
120   fprintf (stdout, "END   PTO TEST\n");
121 }
122
123 \f
124 /*
125  * $Log$
126  * Revision 1.2  2004/10/21 11:09:37  liekweg
127  * Moved memwalk stuf into irmemwalk
128  * Moved lset stuff into lset
129  * Moved typalise stuff into typalise
130  *
131  * Revision 1.1  2004/10/20 14:59:42  liekweg
132  * Added ana2, added ecg and pto
133  *
134  */