3 * File name: ir/common/firm.c
4 * Purpose: Central firm functionality.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
21 /* init functions are not public */
24 # include "irprog_t.h"
25 # include "irnode_t.h"
26 # include "irmode_t.h"
27 # include "ircons_t.h"
28 # include "irgraph_t.h"
30 # include "type_identify.h"
31 # include "firmstat.h"
34 init_firm(const firm_parameter_t *param)
36 firm_parameter_t def_params;
39 memset(&def_params, 0, sizeof(def_params));
42 /* check for reasonale size */
43 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
44 "parameter struct not initialized ???");
45 size = sizeof(def_params);
46 if (param->size < size)
49 memcpy(&def_params, param, size);
52 /* initialize all ident stuff */
54 /* enhanced statistics, need idents */
55 init_stat(def_params.enable_statistics);
56 /* create the type kinds. */
58 /* create an obstack and put all tarvals in a pdeq */
60 /* initialize all modes an ir node can consist of */
62 /* initialize tarvals, and floating point arithmetic */
64 /* init graph construction */
66 /* kind of obstack initialization */
68 /* initalize all op codes an irnode can consist of */
70 /* called once for each run of this library */
71 init_cons(def_params.initialize_local_func);
72 /* Builds a construct allowing to access all information to be constructed
75 /* Constructs some idents needed. */
77 /* allocate a hash table. */
78 init_type_identify(def_params.compare_types_func, def_params.hash_types_func);
82 void free_firm(void) {
85 for (i = 0; i < get_irp_n_irgs(); i++)
86 free_ir_graph(get_irp_irg(i));
88 for (i = 0; i < get_irp_n_types(); i++) {
89 free_type_entities(get_irp_type(i));
90 free_type(get_irp_type(i));
93 free_type_entities(get_glob_type());