verify pto_{load,store}
[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   /* Initialise the init module */
72   pto_init_init ();
73
74   /* allocate ctx-sens names for allocs and set ... etc etc */
75   pto_init_type_names ();
76
77   /* initialise all graphs with the static names */
78   ecg_iterate_graphs (pto_init_graph_wrapper, NULL);
79
80   /* debugging only */
81   spaces = (char*) xmalloc (512 * sizeof (char));
82   memset (spaces, ' ', 512);
83   spaces += 511;
84   *spaces = '\0';
85
86   /* initialise for the CTX-sensitive ecg-traversal */
87   set_curr_ctx (get_main_ctx ());
88   HERE ("end");
89 }
90
91 void pto_run ()
92 {
93   HERE ("start");
94
95   ir_graph *graph = get_irp_main_irg ();
96   fake_main_args (graph);
97
98   DBGPRINT (0, (stdout, "START PTO\n"));
99   DBGPRINT (0, (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n",
100                 (int) graph,
101                 get_type_name (get_entity_owner (get_irg_entity (graph))),
102                 get_entity_name (get_irg_entity (graph))));
103
104   /* do we need some kind of environment here? */
105   pto_graph (graph, 0);
106
107   DBGPRINT (0, (stdout, "END   PTO\n"));
108   HERE ("end");
109 }
110
111 void pto_cleanup ()
112 {
113   HERE ("start");
114   /* todo: clean up our own mess */
115   spaces -= 511;                /* hope that all changes to spaces are
116                                    properly nested */
117   memset (spaces, 0x00, 512);
118   free (spaces);
119
120   /* Cleanup the name module */
121   pto_name_cleanup ();
122   /* Cleanup the Init module */
123   pto_init_cleanup ();
124
125   /* clean up ecg infos */
126   ecg_cleanup ();
127   HERE ("end");
128 }
129
130 \f
131 /*
132   $Log$
133   Revision 1.8  2004/11/24 14:54:21  liekweg
134   Added pto.c as main entry point
135
136
137 */