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"
43 init_firm(const firm_parameter_t *param)
45 firm_parameter_t def_params;
48 memset(&def_params, 0, sizeof(def_params));
51 /* check for reasonale size */
52 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
53 "parameter struct not initialized ???");
54 size = sizeof(def_params);
55 if (param->size < size)
58 memcpy(&def_params, param, size);
61 /* initialize all ident stuff */
62 init_ident(def_params.id_if, 1024);
63 /* initialize Firm hooks */
65 /* enhanced statistics, need idents and hooks */
66 init_stat(def_params.enable_statistics);
67 /* create the type kinds. */
69 /* create an obstack and put all tarvals in a pdeq */
71 /* initialize all modes an ir node can consist of */
73 /* initialize tarvals, and floating point arithmetic */
75 /* init graph construction */
77 /* kind of obstack initialization */
79 /* initalize all op codes an irnode can consist of */
81 /* called once for each run of this library */
82 init_cons(def_params.initialize_local_func);
83 /* initialize reassociation */
84 firm_init_reassociation();
85 /* Builds a construct allowing to access all information to be constructed
88 /* Constructs some idents needed. */
91 /* allocate a hash table. */
92 init_type_identify(def_params.ti_if);
93 /* Init reflection facility. */
96 /* Init architecture dependent optimizations. */
97 arch_dep_init(arch_dep_default_factory);
98 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
102 void free_firm(void) {
105 for (i = 0; i < get_irp_n_irgs(); i++)
106 free_ir_graph(get_irp_irg(i));
108 for (i = 0; i < get_irp_n_types(); i++) {
109 free_type_entities(get_irp_type(i));
110 free_type(get_irp_type(i));
113 free_type_entities(get_glob_type());