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"
36 init_firm(const firm_parameter_t *param)
38 firm_parameter_t def_params;
41 memset(&def_params, 0, sizeof(def_params));
44 /* check for reasonale size */
45 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
46 "parameter struct not initialized ???");
47 size = sizeof(def_params);
48 if (param->size < size)
51 memcpy(&def_params, param, size);
54 /* initialize all ident stuff */
55 init_ident(def_params.id_if, 1024);
56 /* enhanced statistics, need idents */
57 init_stat(def_params.enable_statistics);
58 /* create the type kinds. */
60 /* create an obstack and put all tarvals in a pdeq */
62 /* initialize all modes an ir node can consist of */
64 /* initialize tarvals, and floating point arithmetic */
66 /* init graph construction */
68 /* kind of obstack initialization */
70 /* initalize all op codes an irnode can consist of */
72 /* called once for each run of this library */
73 init_cons(def_params.initialize_local_func);
74 /* Builds a construct allowing to access all information to be constructed
77 /* Constructs some idents needed. */
79 /* allocate a hash table. */
80 init_type_identify(def_params.ti_if);
81 /* Init reflection facility. */
84 /* Init architecture dependent optimizations. */
85 arch_dep_init(arch_dep_default_factory);
86 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_to_shift | arch_dep_mod_to_shift);
90 void free_firm(void) {
93 for (i = 0; i < get_irp_n_irgs(); i++)
94 free_ir_graph(get_irp_irg(i));
96 for (i = 0; i < get_irp_n_types(); i++) {
97 free_type_entities(get_irp_type(i));
98 free_type(get_irp_type(i));
101 free_type_entities(get_glob_type());