normalized various stuff
[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 /* init functions are not public */
22 # include "tv_t.h"
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   /* allocate a hash table. */
59   init_type_identify();
60 }
61
62
63 void free_firm (void) {
64   int i;
65
66   for (i = 0; i < get_irp_n_irgs(); i++)
67     free_ir_graph(get_irp_irg(i));
68
69   for (i = 0; i < get_irp_n_types(); i++) {
70     free_type_entities(get_irp_type(i));
71     free_type(get_irp_type(i));
72   }
73
74   free_type_entities(get_glob_type());
75   free_ir_prog();
76
77   finish_tarval();
78   finish_op();
79   finish_mode();
80   finish_tpop();
81   id_finish();
82 }