projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
backend: put ignore regs into beirg
[libfirm]
/
ir
/
ir
/
irgopt.c
diff --git
a/ir/ir/irgopt.c
b/ir/ir/irgopt.c
index
0f7437c
..
1888d28
100644
(file)
--- a/
ir/ir/irgopt.c
+++ b/
ir/ir/irgopt.c
@@
-39,6
+39,7
@@
#include "adt/pdeq.h"
#include "adt/pdeq.h"
+#include "irpass_t.h"
#include "irflag_t.h"
#include "iredges_t.h"
#include "irtools.h"
#include "irflag_t.h"
#include "iredges_t.h"
#include "irtools.h"
@@
-50,7
+51,8
@@
/**
* A wrapper around optimize_inplace_2() to be called from a walker.
*/
/**
* A wrapper around optimize_inplace_2() to be called from a walker.
*/
-static void optimize_in_place_wrapper(ir_node *n, void *env) {
+static void optimize_in_place_wrapper(ir_node *n, void *env)
+{
ir_node *optimized = optimize_in_place_2(n);
(void) env;
ir_node *optimized = optimize_in_place_2(n);
(void) env;
@@
-67,26
+69,29
@@
static void optimize_in_place_wrapper(ir_node *n, void *env) {
*
* @note current_ir_graph must be set
*/
*
* @note current_ir_graph must be set
*/
-static inline void do_local_optimize(ir_node *n) {
+static inline void do_local_optimize(ir_node *n)
+{
+ ir_graph *irg = get_irn_irg(n);
+
/* Handle graph state */
/* Handle graph state */
- assert(get_irg_phase_state(
current_ir_graph
) != phase_building);
+ assert(get_irg_phase_state(
irg
) != phase_building);
if (get_opt_global_cse())
if (get_opt_global_cse())
- set_irg_pinned(
current_ir_graph
, op_pin_state_floats);
- set_irg_outs_inconsistent(
current_ir_graph
);
- set_irg_doms_inconsistent(
current_ir_graph
);
- set_irg_loopinfo_inconsistent(
current_ir_graph
);
+ set_irg_pinned(
irg
, op_pin_state_floats);
+ set_irg_outs_inconsistent(
irg
);
+ set_irg_doms_inconsistent(
irg
);
+ set_irg_loopinfo_inconsistent(
irg
);
/* Clean the value_table in irg for the CSE. */
/* Clean the value_table in irg for the CSE. */
- del_identities(current_ir_graph->value_table);
- current_ir_graph->value_table = new_identities();
+ new_identities(irg);
/* walk over the graph */
irg_walk(n, firm_clear_link, optimize_in_place_wrapper, NULL);
}
/* Applies local optimizations (see iropt.h) to all nodes reachable from node n */
/* walk over the graph */
irg_walk(n, firm_clear_link, optimize_in_place_wrapper, NULL);
}
/* Applies local optimizations (see iropt.h) to all nodes reachable from node n */
-void local_optimize_node(ir_node *n) {
+void local_optimize_node(ir_node *n)
+{
ir_graph *rem = current_ir_graph;
current_ir_graph = get_irn_irg(n);
ir_graph *rem = current_ir_graph;
current_ir_graph = get_irn_irg(n);
@@
-98,7
+103,8
@@
void local_optimize_node(ir_node *n) {
/**
* Block-Walker: uses dominance depth to mark dead blocks.
*/
/**
* Block-Walker: uses dominance depth to mark dead blocks.
*/
-static void kill_dead_blocks(ir_node *block, void *env) {
+static void kill_dead_blocks(ir_node *block, void *env)
+{
(void) env;
if (get_Block_dom_depth(block) < 0) {
(void) env;
if (get_Block_dom_depth(block) < 0) {
@@
-111,7
+117,8
@@
static void kill_dead_blocks(ir_node *block, void *env) {
}
/* Applies local optimizations (see iropt.h) to all nodes reachable from node n. */
}
/* Applies local optimizations (see iropt.h) to all nodes reachable from node n. */
-void local_optimize_graph(ir_graph *irg) {
+void local_optimize_graph(ir_graph *irg)
+{
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
@@
-127,7
+134,8
@@
void local_optimize_graph(ir_graph *irg) {
* Enqueue all users of a node to a wait queue.
* Handles mode_T nodes.
*/
* Enqueue all users of a node to a wait queue.
* Handles mode_T nodes.
*/
-static void enqueue_users(ir_node *n, pdeq *waitq) {
+static void enqueue_users(ir_node *n, pdeq *waitq)
+{
const ir_edge_t *edge;
foreach_out_edge(n, edge) {
const ir_edge_t *edge;
foreach_out_edge(n, edge) {
@@
-150,7
+158,8
@@
static void enqueue_users(ir_node *n, pdeq *waitq) {
* Optimizes all nodes and enqueue it's users
* if done.
*/
* Optimizes all nodes and enqueue it's users
* if done.
*/
-static void opt_walker(ir_node *n, void *env) {
+static void opt_walker(ir_node *n, void *env)
+{
pdeq *waitq = env;
ir_node *optimized;
pdeq *waitq = env;
ir_node *optimized;
@@
-164,7
+173,8
@@
static void opt_walker(ir_node *n, void *env) {
}
/* Applies local optimizations to all nodes in the graph until fixpoint. */
}
/* Applies local optimizations to all nodes in the graph until fixpoint. */
-int optimize_graph_df(ir_graph *irg) {
+int optimize_graph_df(ir_graph *irg)
+{
pdeq *waitq = new_pdeq();
ir_graph *rem = current_ir_graph;
ir_node *end;
pdeq *waitq = new_pdeq();
ir_graph *rem = current_ir_graph;
ir_node *end;
@@
-175,11
+185,10
@@
int optimize_graph_df(ir_graph *irg) {
state = edges_assure(irg);
if (get_opt_global_cse())
state = edges_assure(irg);
if (get_opt_global_cse())
- set_irg_pinned(
current_ir_graph
, op_pin_state_floats);
+ set_irg_pinned(
irg
, op_pin_state_floats);
/* Clean the value_table in irg for the CSE. */
/* Clean the value_table in irg for the CSE. */
- del_identities(irg->value_table);
- irg->value_table = new_identities();
+ new_identities(irg);
if (get_irg_dom_state(irg) == dom_consistent)
irg_block_walk_graph(irg, NULL, kill_dead_blocks, NULL);
if (get_irg_dom_state(irg) == dom_consistent)
irg_block_walk_graph(irg, NULL, kill_dead_blocks, NULL);
@@
-220,3
+229,9
@@
int optimize_graph_df(ir_graph *irg) {
current_ir_graph = rem;
return changed;
}
current_ir_graph = rem;
return changed;
}
+
+/* Creates an ir_graph pass for optimize_graph_df. */
+ir_graph_pass_t *optimize_graph_df_pass(const char *name)
+{
+ return def_graph_pass_ret(name ? name : "optimize_graph_df", optimize_graph_df);
+} /* optimize_graph_df_pass */