pto.c 3.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* -*- c -*- */

/*
   Project:     libFIRM
   File name:   ir/ana/pto.c
   Purpose:     Entry to PTO
   Author:      Florian
   Modified by:
   Created:     Tue Nov 23 18:37:09 CET 2004
   CVS-ID:      $Id$
   Copyright:   (c) 1999-2004 Universitt Karlsruhe
   Licence:     This file is protected by the GPL -  GNU GENERAL PUBLIC LICENSE.
*/

Michael Beck's avatar
Michael Beck committed
15
16
17
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
18
19
20
21
22

/*
 pto: Entry to PTO
*/

Michael Beck's avatar
Michael Beck committed
23
24
25
#ifdef HAVE_STRING_H
# include <string.h>
#endif
26
27
28

# include "pto.h"

Michael Beck's avatar
Michael Beck committed
29
# include "irnode_t.h"
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# include "irprog.h"
# include "xmalloc.h"

# include "pto_debug.h"
# include "pto_init.h"
# include "pto_name.h"
# include "pto_ctx.h"
# include "ecg.h"

/* Local Defines: */

/* Local Data Types: */

/* Local Variables: */
extern char *spaces;

/* Local Prototypes: */

/* ===================================================
   Local Implementation:
   =================================================== */

/* Helper to pto_init */
static void pto_init_graph_wrapper (graph_info_t *ginfo, void *__unused)
{
  ir_graph *graph = ginfo->graph;

  pto_init_graph (graph);
}

/* ===================================================
   Exported Implementation:
   =================================================== */
/* Initialise the module (not in pto_init.c because it's the entry to pto) */
void pto_init (int lvl)
{
  set_dbg_lvl (lvl);

  ecg_init (1);

  /* Initialise the name module */
  pto_name_init ();
Florian Liekweg's avatar
Florian Liekweg committed
72

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  /* Initialise the init module */
  pto_init_init ();

  /* allocate ctx-sens names for allocs and set ... etc etc */
  pto_init_type_names ();

  /* initialise all graphs with the static names */
  ecg_iterate_graphs (pto_init_graph_wrapper, NULL);

  /* debugging only */
  spaces = (char*) xmalloc (512 * sizeof (char));
  memset (spaces, ' ', 512);
  spaces += 511;
  *spaces = '\0';

  /* initialise for the CTX-sensitive ecg-traversal */
  set_curr_ctx (get_main_ctx ());
}

void pto_run ()
{
  ir_graph *graph = get_irp_main_irg ();
95
96

  pto_reset_graph_pto (graph, 0);
97
98
  fake_main_args (graph);

99
100
  DBGPRINT (1, (stdout, "START PTO\n"));
  DBGPRINT (1, (stdout, "START GRAPH (0x%08x) of \"%s.%s\"\n",
101
102
103
104
                (int) graph,
                get_type_name (get_entity_owner (get_irg_entity (graph))),
                get_entity_name (get_irg_entity (graph))));

Florian Liekweg's avatar
Florian Liekweg committed
105
106
107
108
  /* we need some kind of environment here: NULL */
  ir_graph *save = get_current_ir_graph ();
  pto_graph (graph, 0, NULL);
  set_current_ir_graph (save);
109

110
  DBGPRINT (1, (stdout, "END   PTO\n"));
111
112
}

Florian Liekweg's avatar
Florian Liekweg committed
113
114
115
116
117
118
/* Dump all interesting stuff to a bunch of files */
void pto_dump ()
{
  pto_dump_names ("names.dot");
}

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
void pto_cleanup ()
{
  /* todo: clean up our own mess */
  spaces -= 511;                /* hope that all changes to spaces are
                                   properly nested */
  memset (spaces, 0x00, 512);
  free (spaces);

  /* Cleanup the name module */
  pto_name_cleanup ();
  /* Cleanup the Init module */
  pto_init_cleanup ();

  /* clean up ecg infos */
  ecg_cleanup ();
}


/*
  $Log$
Florian Liekweg's avatar
Florian Liekweg committed
139
140
141
  Revision 1.13  2004/12/20 17:34:34  liekweg
  fix recursion handling

Michael Beck's avatar
Michael Beck committed
142
143
144
  Revision 1.12  2004/12/02 16:17:51  beck
  fixed config.h include

Florian Liekweg's avatar
Florian Liekweg committed
145
146
147
  Revision 1.11  2004/11/30 15:49:27  liekweg
  include 'dump'

148
149
150
  Revision 1.10  2004/11/30 14:46:41  liekweg
  Correctly reset main graph; remove dbugging stuff

Florian Liekweg's avatar
Florian Liekweg committed
151
152
153
  Revision 1.9  2004/11/26 16:01:56  liekweg
  debugging annotations

154
155
156
157
158
  Revision 1.8  2004/11/24 14:54:21  liekweg
  Added pto.c as main entry point


*/