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"
34 # include "reassoc_t.h"
37 init_firm(const firm_parameter_t *param)
39 firm_parameter_t def_params;
42 memset(&def_params, 0, sizeof(def_params));
45 /* check for reasonale size */
46 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
47 "parameter struct not initialized ???");
48 size = sizeof(def_params);
49 if (param->size < size)
52 memcpy(&def_params, param, size);
55 /* initialize all ident stuff */
56 init_ident(def_params.id_if, 1024);
57 /* enhanced statistics, need idents */
58 init_stat(def_params.enable_statistics);
59 /* create the type kinds. */
61 /* create an obstack and put all tarvals in a pdeq */
63 /* initialize all modes an ir node can consist of */
65 /* initialize tarvals, and floating point arithmetic */
67 /* init graph construction */
69 /* kind of obstack initialization */
71 /* initalize all op codes an irnode can consist of */
73 /* called once for each run of this library */
74 init_cons(def_params.initialize_local_func);
75 /* initialize reassociation */
76 firm_init_reassociation();
77 /* Builds a construct allowing to access all information to be constructed
80 /* Constructs some idents needed. */
83 /* allocate a hash table. */
84 init_type_identify(def_params.ti_if);
85 /* Init reflection facility. */
88 /* Init architecture dependent optimizations. */
89 arch_dep_init(arch_dep_default_factory);
90 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
94 void free_firm(void) {
97 for (i = 0; i < get_irp_n_irgs(); i++)
98 free_ir_graph(get_irp_irg(i));
100 for (i = 0; i < get_irp_n_types(); i++) {
101 free_type_entities(get_irp_type(i));
102 free_type(get_irp_type(i));
105 free_type_entities(get_glob_type());