added needed header
[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 "type_identify.h"
29 # include "firmstat.h"
30
31 void
32 init_firm (default_initialize_local_variable_func_t *func)
33 {
34   /* initialize all ident stuff */
35   id_init (1024);
36   /* enhanced statistics, need idents */
37   stat_init();
38   /* create the type kinds. */
39   init_tpop ();
40   /* create an obstack and put all tarvals in a pdeq */
41   init_tarval_1 ();
42   /* initialize all modes an ir node can consist of */
43   init_mode ();
44   /* initialize tarvals, and floating point arithmetic */
45   init_tarval_2 ();
46   /* init graph construction */
47   init_irgraph();
48   /* kind of obstack initialization */
49   init_mangle ();
50   /* initalize all op codes an irnode can consist of */
51   init_op ();
52   /* called once for each run of this library */
53   init_cons (func);
54   /* Builds a construct allowing to access all information to be constructed
55      later. */
56   init_irprog ();
57   /* Constructs some idents needed. */
58   init_type();
59   /* allocate a hash table. */
60   init_type_identify();
61 }
62
63
64 void free_firm (void) {
65   int i;
66
67   for (i = 0; i < get_irp_n_irgs(); i++)
68     free_ir_graph(get_irp_irg(i));
69
70   for (i = 0; i < get_irp_n_types(); i++) {
71     free_type_entities(get_irp_type(i));
72     free_type(get_irp_type(i));
73   }
74
75   free_type_entities(get_glob_type());
76   free_ir_prog();
77
78   finish_tarval();
79   finish_op();
80   finish_mode();
81   finish_tpop();
82   id_finish();
83 }