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"
42 init_firm(const firm_parameter_t *param)
44 firm_parameter_t def_params;
47 memset(&def_params, 0, sizeof(def_params));
50 /* check for reasonale size */
51 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
52 "parameter struct not initialized ???");
53 size = sizeof(def_params);
54 if (param->size < size)
57 memcpy(&def_params, param, size);
60 /* initialize all ident stuff */
61 init_ident(def_params.id_if, 1024);
62 /* enhanced statistics, need idents */
63 init_stat(def_params.enable_statistics);
64 /* create the type kinds. */
66 /* create an obstack and put all tarvals in a pdeq */
68 /* initialize all modes an ir node can consist of */
70 /* initialize tarvals, and floating point arithmetic */
72 /* init graph construction */
74 /* kind of obstack initialization */
76 /* initalize all op codes an irnode can consist of */
78 /* called once for each run of this library */
79 init_cons(def_params.initialize_local_func);
80 /* initialize reassociation */
81 firm_init_reassociation();
82 /* Builds a construct allowing to access all information to be constructed
85 /* Constructs some idents needed. */
88 /* allocate a hash table. */
89 init_type_identify(def_params.ti_if);
90 /* Init reflection facility. */
93 /* Init architecture dependent optimizations. */
94 arch_dep_init(arch_dep_default_factory);
95 arch_dep_set_opts(arch_dep_mul_to_shift | arch_dep_div_by_const | arch_dep_mod_by_const);
99 void free_firm(void) {
102 for (i = 0; i < get_irp_n_irgs(); i++)
103 free_ir_graph(get_irp_irg(i));
105 for (i = 0; i < get_irp_n_types(); i++) {
106 free_type_entities(get_irp_type(i));
107 free_type(get_irp_type(i));
110 free_type_entities(get_glob_type());