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"
32 # include "irreflect_t.h"
35 init_firm(const firm_parameter_t *param)
37 firm_parameter_t def_params;
40 memset(&def_params, 0, sizeof(def_params));
43 /* check for reasonale size */
44 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
45 "parameter struct not initialized ???");
46 size = sizeof(def_params);
47 if (param->size < size)
50 memcpy(&def_params, param, size);
53 /* initialize all ident stuff */
55 /* enhanced statistics, need idents */
56 init_stat(def_params.enable_statistics);
57 /* create the type kinds. */
59 /* create an obstack and put all tarvals in a pdeq */
61 /* initialize all modes an ir node can consist of */
63 /* initialize tarvals, and floating point arithmetic */
65 /* init graph construction */
67 /* kind of obstack initialization */
69 /* initalize all op codes an irnode can consist of */
71 /* called once for each run of this library */
72 init_cons(def_params.initialize_local_func);
73 /* Builds a construct allowing to access all information to be constructed
76 /* Constructs some idents needed. */
78 /* allocate a hash table. */
79 init_type_identify(def_params.compare_types_func, def_params.hash_types_func);
80 /* Init reflection facility. */
86 void free_firm(void) {
89 for (i = 0; i < get_irp_n_irgs(); i++)
90 free_ir_graph(get_irp_irg(i));
92 for (i = 0; i < get_irp_n_types(); i++) {
93 free_type_entities(get_irp_type(i));
94 free_type(get_irp_type(i));
97 free_type_entities(get_glob_type());