fix graph dumping, remove 'HERE's
[libfirm] / ir / ana2 / pto.c
1 /* -*- c -*- */
2
3 /*
4    Project:     libFIRM
5    File name:   ir/ana/pto.c
6    Purpose:     Entry to PTO
7    Author:      Florian
8    Modified by:
9    Created:     Tue Nov 23 18:37:09 CET 2004
10    CVS-ID:      $Id$
11    Copyright:   (c) 1999-2004 Universität Karlsruhe
12    Licence:     This file is protected by the GPL -  GNU GENERAL PUBLIC LICENSE.
13 */
14
15 # ifdef HAVE_CONFIG_H
16 #  include <config.h>
17 # endif
18
19 /*
20  pto: Entry to PTO
21 */
22
23 #  include <string.h>
24
25 # include "pto.h"
26
27 # include "irnode.h"
28 # include "irprog.h"
29 # include "xmalloc.h"
30
31 # include "pto_debug.h"
32 # include "pto_init.h"
33 # include "pto_name.h"
34 # include "pto_ctx.h"
35 # include "ecg.h"
36
37 /* Local Defines: */
38
39 /* Local Data Types: */
40
41 /* Local Variables: */
42 extern char *spaces;
43
44 /* Local Prototypes: */
45
46 /* ===================================================
47    Local Implementation:
48    =================================================== */
49
50 /* Helper to pto_init */
51 static void pto_init_graph_wrapper (graph_info_t *ginfo, void *__unused)
52 {
53   ir_graph *graph = ginfo->graph;
54
55   pto_init_graph (graph);
56 }
57
58 /* ===================================================
59    Exported Implementation:
60    =================================================== */
61 /* Initialise the module (not in pto_init.c because it's the entry to pto) */
62 void pto_init (int lvl)
63 {
64   HERE ("start");
65   set_dbg_lvl (lvl);
66
67   ecg_init (1);
68
69   /* Initialise the name module */
70   pto_name_init ();
71
72   /* Initialise the init module */
73   pto_init_init ();
74
75   /* allocate ctx-sens names for allocs and set ... etc etc */
76   pto_init_type_names ();
77
78   /* initialise all graphs with the static names */
79   ecg_iterate_graphs (pto_init_graph_wrapper, NULL);
80
81   /* debugging only */
82   spaces = (char*) xmalloc (512 * sizeof (char));
83   memset (spaces, ' ', 512);
84   spaces += 511;
85   *spaces = '\0';
86
87   /* initialise for the CTX-sensitive ecg-traversal */
88   set_curr_ctx (get_main_ctx ());
89   HERE ("end");
90 }
91
92 void pto_run ()
93 {
94   HERE ("start");
95
96   ir_graph *graph = get_irp_main_irg ();
97   fake_main_args (graph);
98
99   DBGPRINT (0, (stdout, "START PTO\n"));
100   DBGPRINT (0, (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n",
101                 (int) graph,
102                 get_type_name (get_entity_owner (get_irg_entity (graph))),
103                 get_entity_name (get_irg_entity (graph))));
104
105   /* do we need some kind of environment here? */
106   pto_graph (graph, 0);
107
108   DBGPRINT (0, (stdout, "END   PTO\n"));
109   HERE ("end");
110 }
111
112 void pto_cleanup ()
113 {
114   HERE ("start");
115   /* todo: clean up our own mess */
116   spaces -= 511;                /* hope that all changes to spaces are
117                                    properly nested */
118   memset (spaces, 0x00, 512);
119   free (spaces);
120
121   /* Cleanup the name module */
122   pto_name_cleanup ();
123   /* Cleanup the Init module */
124   pto_init_cleanup ();
125
126   /* clean up ecg infos */
127   ecg_cleanup ();
128   HERE ("end");
129 }
130
131 \f
132 /*
133   $Log$
134   Revision 1.9  2004/11/26 16:01:56  liekweg
135   debugging annotations
136
137   Revision 1.8  2004/11/24 14:54:21  liekweg
138   Added pto.c as main entry point
139
140
141 */