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 /* Builds a basic program representation, so modes can be added. */
77 /* initialize all modes an ir node can consist of */
79 /* initialize tarvals, and floating point arithmetic */
81 /* init graph construction */
83 /* kind of obstack initialization */
85 /* initialize all op codes an irnode can consist of */
87 /* called once for each run of this library */
88 init_cons(def_params.initialize_local_func);
89 /* initialize reassociation */
90 firm_init_reassociation();
91 /* Builds a construct allowing to access all information to be constructed
94 /* Constructs some idents needed. */
97 /* allocate a hash table. */
98 init_type_identify(def_params.ti_if);
99 /* Init reflection facility. */
102 /* Init architecture dependent optimizations. */
103 arch_dep_init(arch_dep_default_factory);
104 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
106 firm_archops_init(def_params.arch_op_settings);
110 void free_firm(void) {
113 for (i = get_irp_n_irgs() - 1; i >= 0; --i)
114 free_ir_graph(get_irp_irg(i));
116 free_type_entities(get_glob_type());
117 for (i = get_irp_n_types() - 1; i >= 0; --i)
118 free_type_entities(get_irp_type(i));
120 for (i = get_irp_n_types() - 1; i >= 0; --i)
121 free_type(get_irp_type(i));