irgopt.h 3.4 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * 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.
 */

Michael Beck's avatar
Michael Beck committed
20
/**
Matthias Braun's avatar
Matthias Braun committed
21
22
23
24
 * @file
 * @brief   Optimizations for a whole ir graph, i.e., a procedure.
 * @author  Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
 * @version $Id$
Götz Lindenmaier's avatar
Götz Lindenmaier committed
25
 */
Matthias Braun's avatar
Matthias Braun committed
26
27
#ifndef FIRM_IR_IRGOPT_H
#define FIRM_IR_IRGOPT_H
Boris Boesler's avatar
Boris Boesler committed
28

29
#include "firm_types.h"
30
#include "begin.h"
Christian Schäfer's avatar
Christian Schäfer committed
31

32
33
/** Applies local optimizations (see iropt.h) to all nodes reachable from node
 * @p n.
34
 *
Michael Beck's avatar
Michael Beck committed
35
36
 * @param n The node to be optimized.
 */
Michael Beck's avatar
Michael Beck committed
37
FIRM_API void local_optimize_node(ir_node *n);
38

Beyhan's avatar
Beyhan committed
39
40
/** Applies local optimizations (see iropt.h) to all nodes in the graph.
 *
Michael Beck's avatar
Michael Beck committed
41
42
 * @param irg  The graph to be optimized.
 *
Michael Beck's avatar
Michael Beck committed
43
 * After applying local_optimize_graph() to a IR-graph, Bad nodes
44
 * only occur as predecessor of Block and Phi nodes.
Michael Beck's avatar
Michael Beck committed
45
 */
Michael Beck's avatar
Michael Beck committed
46
FIRM_API void local_optimize_graph(ir_graph *irg);
Christian Schäfer's avatar
Christian Schäfer committed
47

48
49
/** Applies local optimizations (see iropt.h) to all nodes in the graph.
 *
50
51
 * After applying optimize_graph_df() to a IR-graph, Bad nodes
 * only occur as predecessor of Block and Phi nodes.
52
 *
53
54
55
 * This version uses fixpoint iteration.
 *
 * @param irg  The graph to be optimized.
56
 *
57
 * @return non-zero if the optimization could be applied, 0 else
58
 */
Michael Beck's avatar
Michael Beck committed
59
FIRM_API int optimize_graph_df(ir_graph *irg);
60

61
/**
62
 * Eliminates (obviously) unreachable code
63
 */
64
FIRM_API void remove_unreachable_code(ir_graph *irg);
65

66
67
68
69
70
71
72
73
74
/**
 * Removes all Bad nodes from a graph.
 *
 * @param irg  The graph to be optimized.
 *
 * @return non-zero if at least one Bad was removed, otherwise 0
 */
FIRM_API int remove_bads(ir_graph *irg);

Andreas Zwinkau's avatar
Andreas Zwinkau committed
75
76
77
78
79
80
81
82
83
/**
 * Removes all Tuple nodes from a graph.
 *
 * @param irg  The graph to be optimized.
 *
 * @return non-zero if at least one Tuple was removed, otherwise 0
 */
FIRM_API int remove_tuples(ir_graph *irg);

84
85
86
87
88
89
90
/**
 * Creates an ir_graph pass for optimize_graph_df().
 *
 * @param name     the name of this pass or NULL
 *
 * @return  the newly created ir_graph pass
 */
Michael Beck's avatar
Michael Beck committed
91
FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
92

Michael Beck's avatar
Michael Beck committed
93
/** Places an empty basic block on critical control flow edges thereby
Michael Beck's avatar
Michael Beck committed
94
95
96
97
 * removing them.
 *
 * A critical control flow edge is an edge from a block with several
 * control exits to a block with several control entries (See Muchnic
98
 * p. 407). Exception edges are always ignored.
Michael Beck's avatar
Michael Beck committed
99
 *
100
 * @param irg  IR Graph
Michael Beck's avatar
Michael Beck committed
101
 */
Michael Beck's avatar
Michael Beck committed
102
FIRM_API void remove_critical_cf_edges(ir_graph *irg);
103

104
105
106
107
108
109
110
111
112
113
/** Places an empty basic block on critical control flow edges thereby
 * removing them.
 *
 * A critical control flow edge is an edge from a block with several
 * control exits to a block with several control entries (See Muchnic
 * p. 407).
 *
 * @param irg                     IR Graph
 * @param ignore_exception_edges  if non-zero, exception edges will be ignored
 */
Michael Beck's avatar
Michael Beck committed
114
FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
115
116
117
                                          int ignore_exception_edges);

#include "end.h"
118

Matthias Braun's avatar
Matthias Braun committed
119
#endif