Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
e89d2463
Commit
e89d2463
authored
May 10, 2011
by
Michael Beck
Browse files
Moved some helper functions from irgopt to irtools for reuse.
parent
8e4bc2eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/common/irtools.c
View file @
e89d2463
/*
* Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
* Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
...
...
@@ -51,6 +51,20 @@ void firm_clear_node_and_phi_links(ir_node *n, void *env)
set_Phi_next
(
n
,
NULL
);
}
void
firm_clear_block_phis
(
ir_node
*
node
,
void
*
env
)
{
(
void
)
env
;
if
(
is_Block
(
node
))
set_Block_phis
(
node
,
NULL
);
}
void
firm_collect_block_phis
(
ir_node
*
node
,
void
*
env
)
{
(
void
)
env
;
if
(
is_Phi
(
node
))
add_Block_phi
(
get_nodes_block
(
node
),
node
);
}
void
copy_irn_to_irg
(
ir_node
*
n
,
ir_graph
*
irg
)
{
ir_op
*
op
=
get_irn_op
(
n
);
...
...
ir/common/irtools.h
View file @
e89d2463
...
...
@@ -77,10 +77,23 @@ void firm_clear_link(ir_node *n, void *env);
* The famous clear_link_and_block_lists() walker-function.
* Sets all links fields of visited nodes to NULL.
* Additionally, clear all Phi-lists of visited blocks.
* Do not implement it by yourself, use this one
* Do not implement it by yourself, use this one
.
*/
void
firm_clear_node_and_phi_links
(
ir_node
*
n
,
void
*
env
);
/**
* Walker function, sets all phi list heads fields of visited Blocks
* to NULL.
* Use in conjunction with firm_collect_block_phis().
*/
void
firm_clear_block_phis
(
ir_node
*
node
,
void
*
env
);
/**
* Walker function, links all visited Phi nodes into its block links.
* Use in conjunction with firm_clear_block_phis().
*/
void
firm_collect_block_phis
(
ir_node
*
node
,
void
*
env
);
/**
* Creates an exact copy of a node with same inputs and attributes in the
* same block.
...
...
ir/ir/irgopt.c
View file @
e89d2463
...
...
@@ -182,20 +182,6 @@ static void opt_walker(ir_node *n, void *env)
}
}
static
void
clear_block_phis
(
ir_node
*
node
,
void
*
env
)
{
(
void
)
env
;
if
(
is_Block
(
node
))
{
set_Block_phis
(
node
,
NULL
);
}
}
static
void
collect_block_phis
(
ir_node
*
node
,
void
*
env
)
{
(
void
)
env
;
if
(
is_Phi
(
node
))
{
add_Block_phi
(
get_nodes_block
(
node
),
node
);
}
}
static
int
count_non_bads
(
ir_node
*
node
)
{
int
arity
=
get_irn_arity
(
node
);
int
count
=
0
;
...
...
@@ -275,7 +261,7 @@ static void block_remove_bads(ir_node *block, int *changed) {
static
int
remove_Bads
(
ir_graph
*
irg
)
{
int
changed
=
0
;
/* build phi list per block */
irg_walk_graph
(
irg
,
clear_block_phis
,
collect_block_phis
,
NULL
);
irg_walk_graph
(
irg
,
firm_
clear_block_phis
,
firm_
collect_block_phis
,
NULL
);
/* actually remove Bads */
irg_block_walk_graph
(
irg
,
NULL
,
(
void
(
*
)(
struct
ir_node
*
,
void
*
))
block_remove_bads
,
&
changed
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment