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 "irnode_t.h"
25 # include "irmode_t.h"
26 # include "irgraph_t.h"
28 # include "type_identify.h"
29 # include "firmstat.h"
32 init_firm(const firm_parameter_t *param)
34 firm_parameter_t def_params;
37 memset(&def_params, 0, sizeof(def_params));
40 /* check for reasonale size */
41 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
42 "parameter struct not initialized ???");
43 size = sizeof(def_params);
44 if (param->size < size)
47 memcpy(&def_params, param, size);
50 /* initialize all ident stuff */
52 /* enhanced statistics, need idents */
54 /* create the type kinds. */
56 /* create an obstack and put all tarvals in a pdeq */
58 /* initialize all modes an ir node can consist of */
60 /* initialize tarvals, and floating point arithmetic */
62 /* init graph construction */
64 /* kind of obstack initialization */
66 /* initalize all op codes an irnode can consist of */
68 /* called once for each run of this library */
69 init_cons(def_params.initialize_local_func);
70 /* Builds a construct allowing to access all information to be constructed
73 /* Constructs some idents needed. */
75 /* allocate a hash table. */
76 init_type_identify(def_params.compare_types_func, def_params.hash_types_func);
80 void free_firm(void) {
83 for (i = 0; i < get_irp_n_irgs(); i++)
84 free_ir_graph(get_irp_irg(i));
86 for (i = 0; i < get_irp_n_types(); i++) {
87 free_type_entities(get_irp_type(i));
88 free_type(get_irp_type(i));
91 free_type_entities(get_glob_type());