summaryrefslogtreecommitdiffhomepage
path: root/ir/common/firm.c
blob: 2c34dcdd2bdb40ac0df0084512e42309a616be87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * This file is part of libFirm.
 * Copyright (C) 2012 University of Karlsruhe.
 */

/**
 * @file
 * @brief     Central firm functionality.
 * @author    Martin Trapp, Christian Schaefer, Goetz Lindenmaier
 */
#include "firm_common.h"

#ifdef HAVE_FIRM_REVISION_H
#include "firm_revision.h"
#endif

#include "be_t.h"
#include "debugger.h"
#include "entity_t.h"
#include "execfreq_t.h"
#include "firm.h"
#include "ident_t.h"
#include "ircons_t.h"
#include "iredges_t.h"
#include "irflag_t.h"
#include "irgraph_t.h"
#include "irhooks.h"
#include "irmemory_t.h"
#include "irmode_t.h"
#include "irnode_t.h"
#include "irprog_t.h"
#include "irtools.h"
#include "lc_opts.h"
#include "opt_init.h"
#include "target_t.h"
#include "tv_t.h"
#include "type_t.h"
#include "version.h"
#include <stdio.h>
#include <stdio.h>

static bool initialized;

/* returns the firm root */
lc_opt_entry_t *firm_opt_get_root(void)
{
	static lc_opt_entry_t *grp = NULL;
	if (!grp)
		grp = lc_opt_get_grp(lc_opt_root_grp(), "firm");
	return grp;
}

void ir_init_library(void)
{
	if (initialized)
		panic("Double initialization");
	initialized = true;

	firm_init_flags();
	init_ident();
	init_edges();
	init_tarval_1();
	/* Builds a basic program representation, so modes can be added. */
	init_irprog_1();
	init_mode();
	init_tarval_2();
	firm_init_op();
	firm_init_reassociation();
	firm_init_funccalls();
	firm_init_inline();
	firm_init_scalar_replace();
	/* Builds a construct allowing to access all information to be constructed
	   later. */
	init_irprog_2();
	firm_init_memory_disambiguator();
	firm_init_loop_opt();

	init_execfreq();
	firm_be_init();

#ifdef DEBUG_libfirm
	firm_init_debugger();
#endif
}

void ir_finish(void)
{
#ifdef DEBUG_libfirm
	firm_finish_debugger();
#endif
	exit_execfreq();
	firm_be_finish();

	free_ir_prog();
	firm_finish_op();
	finish_tarval();
	finish_mode();
	finish_ident();
	finish_target();
	initialized = false;
}

unsigned ir_get_version_major(void)
{
	return libfirm_VERSION_MAJOR;
}

unsigned ir_get_version_minor(void)
{
	return libfirm_VERSION_MINOR;
}

unsigned ir_get_version_micro(void)
{
	return libfirm_VERSION_MICRO;
}

const char *ir_get_version_revision(void)
{
#ifdef libfirm_VERSION_REVISION
	return libfirm_VERSION_REVISION;
#else
	return "";
#endif
}

const char *ir_get_version_build(void)
{
	return "";
}