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 "entity_t.h"
36 # include "type_identify.h"
37 # include "firmstat.h"
38 # include "irreflect_t.h"
40 # include "reassoc_t.h"
42 # include "iredges_t.h"
43 # include "debugger.h"
46 init_firm(const firm_parameter_t *param)
48 firm_parameter_t def_params;
51 memset(&def_params, 0, sizeof(def_params));
54 /* check for reasonable size */
55 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
56 "parameter struct not initialized ???");
57 size = sizeof(def_params);
58 if (param->size < size)
61 memcpy(&def_params, param, size);
64 /* initialize all ident stuff */
65 init_ident(def_params.id_if, 1024);
66 /* initialize Firm hooks */
68 /* enhanced statistics, need idents and hooks */
69 init_stat(def_params.enable_statistics);
70 /* Edges need hooks. */
72 /* create the type kinds. */
74 /* create an obstack and put all tarvals in a pdeq */
76 /* Builds a basic program representation, so modes can be added. */
78 /* initialize all modes an ir node can consist of */
80 /* initialize tarvals, and floating point arithmetic */
82 /* init graph construction */
84 /* kind of obstack initialization */
86 /* initialize all op codes an irnode can consist of */
88 /* called once for each run of this library */
89 init_cons(def_params.initialize_local_func);
90 /* initialize reassociation */
91 firm_init_reassociation();
92 /* Builds a construct allowing to access all information to be constructed
95 /* Initialize the type module and construct some idents needed. */
96 firm_init_type(def_params.builtin_dbg, def_params.cc_mask);
97 /* initialize the entity module */
99 /* allocate a hash table. */
100 init_type_identify(def_params.ti_if);
101 /* Init reflection facility. */
104 /* Init architecture dependent optimizations. */
105 arch_dep_init(arch_dep_default_factory);
106 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
108 firm_archops_init(def_params.arch_op_settings);
111 /* integrated debugger extension */
112 firm_init_debugger();
117 void free_firm(void) {
120 for (i = get_irp_n_irgs() - 1; i >= 0; --i)
121 free_ir_graph(get_irp_irg(i));
123 free_type_entities(get_glob_type());
124 for (i = get_irp_n_types() - 1; i >= 0; --i)
125 free_type_entities(get_irp_type(i));
127 for (i = get_irp_n_types() - 1; i >= 0; --i)
128 free_type(get_irp_type(i));