statistic module needs idents now
[libfirm] / ir / common / firm.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/common/firm.c
4  * Purpose:     Central firm functionality.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
16
17 # include <stdio.h>
18 # include "ident_t.h"
19 # include "firm.h"
20 # include "mangle.h"
21 # include "tv_t.h"
22 /* init functions are not public */
23 # include "tpop_t.h"
24 # include "irnode_t.h"
25 # include "irmode_t.h"
26 # include "irgraph_t.h"
27 # include "type_t.h"
28 # include "firmstat.h"
29
30 void
31 init_firm (default_initialize_local_variable_func_t *func)
32 {
33   /* initialize all ident stuff */
34   id_init (1024);
35   /* enhanced statistics, need idents */
36   stat_init();
37   /* create the type kinds. */
38   init_tpop ();
39   /* create an obstack and put all tarvals in a pdeq */
40   init_tarval_1 ();
41   /* initialize all modes an ir node can consist of */
42   init_mode ();
43   /* initialize tarvals, and floating point arithmetic */
44   init_tarval_2 ();
45   /* init graph construction */
46   init_irgraph();
47   /* kind of obstack initialization */
48   init_mangle ();
49   /* initalize all op codes an irnode can consist of */
50   init_op ();
51   /* called once for each run of this library */
52   init_cons (func);
53   /* Builds a construct allowing to access all information to be constructed
54      later. */
55   init_irprog ();
56   /* Constructs some idents needed. */
57   init_type();
58 }
59
60
61 void free_firm (void) {
62   int i;
63
64   for (i = 0; i < get_irp_n_irgs(); i++)
65     free_ir_graph(get_irp_irg(i));
66
67   for (i = 0; i < get_irp_n_types(); i++) {
68     free_type_entities(get_irp_type(i));
69     free_type(get_irp_type(i));
70   }
71
72   free_type_entities(get_glob_type());
73   free_ir_prog();
74
75   finish_tarval();
76   finish_op();
77   finish_mode();
78   finish_tpop();
79   id_finish();
80 }