firm.c 3.48 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

/**
 * @file
 * @brief     Central firm functionality.
 * @author    Martin Trapp, Christian Schaefer, Goetz Lindenmaier
Götz Lindenmaier's avatar
Götz Lindenmaier committed
24
 */
Matthias Braun's avatar
Matthias Braun committed
25
#include "config.h"
Michael Beck's avatar
Michael Beck committed
26

27
28
29
#ifdef HAVE_FIRM_REVISION_H
# include "firm_revision.h"
#endif
30

31
#include <string.h>
32
#include <stdio.h>
Michael Beck's avatar
Michael Beck committed
33

Matthias Braun's avatar
Matthias Braun committed
34
#include "lc_opts.h"
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "ident_t.h"
#include "firm.h"
#include "irflag_t.h"
#include "tv_t.h"
#include "tpop_t.h"
#include "irprog_t.h"
#include "irnode_t.h"
#include "irmode_t.h"
#include "ircons_t.h"
#include "irgraph_t.h"
#include "type_t.h"
#include "entity_t.h"
#include "firmstat.h"
#include "irarch.h"
#include "irhooks.h"
#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"
Christian Schäfer's avatar
Christian Schäfer committed
57

58
/* returns the firm root */
59
60
lc_opt_entry_t *firm_opt_get_root(void)
{
61
	static lc_opt_entry_t *grp = NULL;
62
	if (!grp)
63
64
65
		grp = lc_opt_get_grp(lc_opt_root_grp(), "firm");
	return grp;
}
66

67
void ir_init(void)
Christian Schäfer's avatar
Christian Schäfer committed
68
{
69
70
71
	/* for historical reasons be_init must be run first */
	firm_be_init();

Matthias Braun's avatar
Matthias Braun committed
72
73
74
	/* initialize firm flags */
	firm_init_flags();
	/* initialize all ident stuff */
75
	init_ident();
Matthias Braun's avatar
Matthias Braun committed
76
77
78
79
80
	/* Edges need hooks. */
	init_edges();
	/* create the type kinds. */
	init_tpop();
	/* create an obstack and put all tarvals in a pdeq */
Michael Beck's avatar
Michael Beck committed
81
	init_tarval_1(0l, /* support_quad_precision */0);
Matthias Braun's avatar
Matthias Braun committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
	/* Builds a basic program representation, so modes can be added. */
	init_irprog_1();
	/* initialize all modes an ir node can consist of */
	init_mode();
	/* initialize tarvals, and floating point arithmetic */
	init_tarval_2();
	/* init graph construction */
	firm_init_irgraph();
	/* kind of obstack initialization */
	firm_init_mangle();
	/* initialize all op codes an irnode can consist of */
	init_op();
	/* initialize reassociation */
	firm_init_reassociation();
96
97
	/* initialize function call optimization */
	firm_init_funccalls();
98
99
	/* initialize function inlining */
	firm_init_inline();
100
101
	/* initialize scalar replacement */
	firm_init_scalar_replace();
Matthias Braun's avatar
Matthias Braun committed
102
103
104
	/* Builds a construct allowing to access all information to be constructed
	   later. */
	init_irprog_2();
105
106
	/* class cast optimization */
	firm_init_class_casts_opt();
107
108
	/* memory disambiguation */
	firm_init_memory_disambiguator();
109
	firm_init_loop_opt();
Matthias Braun's avatar
Matthias Braun committed
110
111

	/* Init architecture dependent optimizations. */
112
	arch_dep_set_opts(arch_dep_none);
Matthias Braun's avatar
Matthias Braun committed
113

114
115
	init_irnode();

Matthias Braun's avatar
Matthias Braun committed
116
#ifdef DEBUG_libfirm
Matthias Braun's avatar
Matthias Braun committed
117
118
	/* integrated debugger extension */
	firm_init_debugger();
Michael Beck's avatar
Michael Beck committed
119
#endif
120
}
121

122
123
void ir_finish(void)
{
Matthias Braun's avatar
Matthias Braun committed
124
	free_ir_prog();
125

Matthias Braun's avatar
Matthias Braun committed
126
127
128
129
	finish_tarval();
	finish_mode();
	finish_tpop();
	finish_ident();
130
131

	firm_be_finish();
132
}
Michael Beck's avatar
Michael Beck committed
133

134
unsigned ir_get_version_major(void)
135
136
137
138
{
	return libfirm_VERSION_MAJOR;
}

139
unsigned ir_get_version_minor(void)
140
141
142
143
{
	return libfirm_VERSION_MINOR;
}

144
const char *ir_get_version_revision(void)
145
{
146
#ifdef libfirm_VERSION_REVISION
147
	return libfirm_VERSION_REVISION;
148
#else
149
	return "";
150
#endif
151
152
}

153
const char *ir_get_version_build(void)
154
155
{
	return "";
Michael Beck's avatar
Michael Beck committed
156
}