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.
26 /* init functions are not public */
29 # include "irprog_t.h"
30 # include "irnode_t.h"
31 # include "irmode_t.h"
32 # include "ircons_t.h"
33 # include "irgraph_t.h"
35 # include "type_identify.h"
36 # include "firmstat.h"
37 # include "irreflect_t.h"
39 # include "reassoc_t.h"
41 # include "iredges_t.h"
44 init_firm(const firm_parameter_t *param)
46 firm_parameter_t def_params;
49 memset(&def_params, 0, sizeof(def_params));
52 /* check for reasonale size */
53 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
54 "parameter struct not initialized ???");
55 size = sizeof(def_params);
56 if (param->size < size)
59 memcpy(&def_params, param, size);
63 /* initialize all ident stuff */
64 init_ident(def_params.id_if, 1024);
65 /* initialize Firm hooks */
67 /* enhanced statistics, need idents and hooks */
68 init_stat(def_params.enable_statistics);
69 /* Edges need hooks. */
71 /* create the type kinds. */
73 /* create an obstack and put all tarvals in a pdeq */
75 /* initialize all modes an ir node can consist of */
77 /* initialize tarvals, and floating point arithmetic */
79 /* init graph construction */
81 /* kind of obstack initialization */
83 /* initialize all op codes an irnode can consist of */
85 /* called once for each run of this library */
86 init_cons(def_params.initialize_local_func);
87 /* initialize reassociation */
88 firm_init_reassociation();
89 /* Builds a construct allowing to access all information to be constructed
92 /* Constructs some idents needed. */
95 /* allocate a hash table. */
96 init_type_identify(def_params.ti_if);
97 /* Init reflection facility. */
100 /* Init architecture dependent optimizations. */
101 arch_dep_init(arch_dep_default_factory);
102 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
104 firm_archops_init(def_params.arch_op_settings);
108 void free_firm(void) {
111 for (i = 0; i < get_irp_n_irgs(); i++)
112 free_ir_graph(get_irp_irg(i));
114 for (i = 0; i < get_irp_n_types(); i++) {
115 free_type_entities(get_irp_type(i));
116 free_type(get_irp_type(i));
119 free_type_entities(get_glob_type());