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 && "parameter struct not initialized ???");
42 size = sizeof(def_params);
43 if (param->size < size)
46 memcpy(&def_params, param, size);
49 /* initialize all ident stuff */
51 /* enhanced statistics, need idents */
52 stat_init(def_params.enable_statistics);
53 /* create the type kinds. */
55 /* create an obstack and put all tarvals in a pdeq */
57 /* initialize all modes an ir node can consist of */
59 /* initialize tarvals, and floating point arithmetic */
61 /* init graph construction */
63 /* kind of obstack initialization */
65 /* initalize all op codes an irnode can consist of */
67 /* called once for each run of this library */
68 init_cons(def_params.initialize_local_func);
69 /* Builds a construct allowing to access all information to be constructed
72 /* Constructs some idents needed. */
74 /* allocate a hash table. */
75 init_type_identify(def_params.compare_types_func, def_params.hash_types_func);
79 void free_firm(void) {
82 for (i = 0; i < get_irp_n_irgs(); i++)
83 free_ir_graph(get_irp_irg(i));
85 for (i = 0; i < get_irp_n_types(); i++) {
86 free_type_entities(get_irp_type(i));
87 free_type(get_irp_type(i));
90 free_type_entities(get_glob_type());