query firmstat options through lc_opt system
[libfirm] / ir / common / firm.c
1 /*
2  * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief     Central firm functionality.
23  * @author    Martin Trapp, Christian Schaefer, Goetz Lindenmaier
24  */
25 #include "config.h"
26
27 #ifdef HAVE_FIRM_REVISION_H
28 # include "firm_revision.h"
29 #endif
30
31 #include <string.h>
32 #include <stdio.h>
33
34 #include "lc_opts.h"
35
36 #include "ident_t.h"
37 #include "firm.h"
38 #include "irflag_t.h"
39 #include "tv_t.h"
40 #include "tpop_t.h"
41 #include "irprog_t.h"
42 #include "irnode_t.h"
43 #include "irmode_t.h"
44 #include "ircons_t.h"
45 #include "irgraph_t.h"
46 #include "type_t.h"
47 #include "entity_t.h"
48 #include "firmstat.h"
49 #include "irarch.h"
50 #include "irhooks.h"
51 #include "iredges_t.h"
52 #include "irmemory_t.h"
53 #include "opt_init.h"
54 #include "debugger.h"
55 #include "be_t.h"
56 #include "irtools.h"
57 #include "execfreq_t.h"
58 #include "firmstat_t.h"
59
60 /* returns the firm root */
61 lc_opt_entry_t *firm_opt_get_root(void)
62 {
63         static lc_opt_entry_t *grp = NULL;
64         if (!grp)
65                 grp = lc_opt_get_grp(lc_opt_root_grp(), "firm");
66         return grp;
67 }
68
69 void ir_init(void)
70 {
71         /* for historical reasons be_init must be run first */
72         firm_be_init();
73
74         /* initialize firm flags */
75         firm_init_flags();
76         /* initialize all ident stuff */
77         init_ident();
78         /* Edges need hooks. */
79         init_edges();
80         /* create the type kinds. */
81         init_tpop();
82         /* create an obstack and put all tarvals in a pdeq */
83         init_tarval_1(0l, /* support_quad_precision */0);
84         /* Builds a basic program representation, so modes can be added. */
85         init_irprog_1();
86         /* initialize all modes an ir node can consist of */
87         init_mode();
88         /* initialize tarvals, and floating point arithmetic */
89         init_tarval_2();
90         /* initialize node opcodes */
91         firm_init_op();
92         /* init graph construction */
93         firm_init_irgraph();
94         /* kind of obstack initialization */
95         firm_init_mangle();
96         /* initialize reassociation */
97         firm_init_reassociation();
98         /* initialize function call optimization */
99         firm_init_funccalls();
100         /* initialize function inlining */
101         firm_init_inline();
102         /* initialize scalar replacement */
103         firm_init_scalar_replace();
104         /* Builds a construct allowing to access all information to be constructed
105            later. */
106         init_irprog_2();
107         /* class cast optimization */
108         firm_init_class_casts_opt();
109         /* memory disambiguation */
110         firm_init_memory_disambiguator();
111         firm_init_loop_opt();
112
113         /* Init architecture dependent optimizations. */
114         arch_dep_set_opts(arch_dep_none);
115
116         init_execfreq();
117
118         init_stat();
119
120 #ifdef DEBUG_libfirm
121         /* integrated debugger extension */
122         firm_init_debugger();
123 #endif
124 }
125
126 void ir_finish(void)
127 {
128 #ifdef DEBUG_libfirm
129         firm_finish_debugger();
130 #endif
131         exit_execfreq();
132         firm_be_finish();
133
134         free_ir_prog();
135         firm_finish_op();
136         finish_tarval();
137         finish_mode();
138         finish_tpop();
139         firm_finish_mangle();
140         finish_ident();
141 }
142
143 unsigned ir_get_version_major(void)
144 {
145         return libfirm_VERSION_MAJOR;
146 }
147
148 unsigned ir_get_version_minor(void)
149 {
150         return libfirm_VERSION_MINOR;
151 }
152
153 const char *ir_get_version_revision(void)
154 {
155 #ifdef libfirm_VERSION_REVISION
156         return libfirm_VERSION_REVISION;
157 #else
158         return "";
159 #endif
160 }
161
162 const char *ir_get_version_build(void)
163 {
164         return "";
165 }