2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Central firm functionality.
23 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
28 #ifdef HAVE_FIRM_REVISION_H
29 # include "firm_revision.h"
46 #include "irgraph_t.h"
52 #include "iredges_t.h"
53 #include "irmemory_t.h"
59 /* returns the firm root */
60 lc_opt_entry_t *firm_opt_get_root(void)
62 static lc_opt_entry_t *grp = NULL;
64 grp = lc_opt_get_grp(lc_opt_root_grp(), "firm");
68 void ir_init(const firm_parameter_t *param)
70 firm_parameter_t def_params;
73 /* for historical reasons be_init must be run first */
76 memset(&def_params, 0, sizeof(def_params));
79 /* check for reasonable size */
80 assert(param->size <= sizeof(def_params) && (param->size & 3) == 0 &&
81 "parameter struct not initialized ???");
82 size = sizeof(def_params);
83 if (param->size < size)
86 memcpy(&def_params, param, size);
89 /* initialize firm flags */
91 /* initialize all ident stuff */
92 init_ident(def_params.id_if, 1024);
93 /* enhanced statistics, need idents and hooks */
94 firm_init_stat(def_params.enable_statistics);
95 /* Edges need hooks. */
97 /* create the type kinds. */
99 /* create an obstack and put all tarvals in a pdeq */
100 init_tarval_1(0l, /* support_quad_precision */0);
101 /* Builds a basic program representation, so modes can be added. */
103 /* initialize all modes an ir node can consist of */
105 /* initialize tarvals, and floating point arithmetic */
107 /* init graph construction */
109 /* kind of obstack initialization */
111 /* initialize all op codes an irnode can consist of */
113 /* called once for each run of this library */
114 firm_init_cons(def_params.initialize_local_func);
115 /* initialize reassociation */
116 firm_init_reassociation();
117 /* initialize function call optimization */
118 firm_init_funccalls();
119 /* initialize function inlining */
121 /* initialize scalar replacement */
122 firm_init_scalar_replace();
123 /* Builds a construct allowing to access all information to be constructed
126 /* Initialize the type module and construct some idents needed. */
127 firm_init_type(def_params.cc_mask);
128 /* initialize the entity module */
130 /* class cast optimization */
131 firm_init_class_casts_opt();
132 /* memory disambiguation */
133 firm_init_memory_disambiguator();
134 firm_init_loop_opt();
136 /* Init architecture dependent optimizations. */
137 arch_dep_init(arch_dep_default_factory);
138 arch_dep_set_opts(0);
143 /* integrated debugger extension */
144 firm_init_debugger();
152 for (i = get_irp_n_irgs() - 1; i >= 0; --i)
153 free_ir_graph(get_irp_irg(i));
154 for (i = get_irp_n_pseudo_irgs() - 1; i >= 0; --i)
155 free_ir_graph(get_irp_pseudo_irg(i));
157 free_type_entities(get_glob_type());
158 for (i = get_irp_n_types() - 1; i >= 0; --i)
159 free_type_entities(get_irp_type(i));
161 for (i = get_irp_n_types() - 1; i >= 0; --i)
162 free_type(get_irp_type(i));
174 unsigned ir_get_version_major(void)
176 return libfirm_VERSION_MAJOR;
179 unsigned ir_get_version_minor(void)
181 return libfirm_VERSION_MINOR;
184 const char *ir_get_version_revision(void)
186 #ifdef libfirm_VERSION_REVISION
187 return libfirm_VERSION_REVISION;
193 const char *ir_get_version_build(void)