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