Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
68a66d3f
Commit
68a66d3f
authored
Mar 19, 2014
by
Christoph Mallon
Browse files
irouts: Add and use foreach_irn_out{,_r}().
parent
b926bc14
Changes
15
Hide whitespace changes
Inline
Side-by-side
ir/ana/analyze_irg_args.c
View file @
68a66d3f
...
...
@@ -10,7 +10,7 @@
*/
#include
<stdlib.h>
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irnode_t.h"
#include
"irmode_t.h"
#include
"array.h"
...
...
@@ -33,8 +33,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
/* We must visit a node once to avoid endless recursion.*/
mark_irn_visited
(
arg
);
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
foreach_irn_out_r
(
arg
,
i
,
succ
)
{
if
(
irn_visited
(
succ
))
continue
;
...
...
@@ -189,8 +188,7 @@ static void analyze_ent_args(ir_entity *ent)
/* search for arguments with mode reference
to analyze them.*/
for
(
int
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
foreach_irn_out_r
(
irg_args
,
i
,
arg
)
{
ir_mode
*
arg_mode
=
get_irn_mode
(
arg
);
long
proj_nr
=
get_Proj_proj
(
arg
);
...
...
@@ -260,8 +258,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
mark_irn_visited
(
arg
);
unsigned
weight
=
null_weight
;
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
foreach_irn_out_r
(
arg
,
i
,
succ
)
{
if
(
irn_visited
(
succ
))
continue
;
...
...
@@ -306,8 +303,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
ir_node
*
pred
=
get_Tuple_pred
(
succ
,
j
);
if
(
pred
==
arg
)
{
/* look for Proj(j) */
for
(
int
k
=
get_irn_n_outs
(
succ
);
k
--
>
0
;
)
{
ir_node
*
succ_succ
=
get_irn_out
(
succ
,
k
);
foreach_irn_out_r
(
succ
,
k
,
succ_succ
)
{
if
(
is_Proj
(
succ_succ
))
{
if
(
get_Proj_proj
(
succ_succ
)
==
j
)
{
/* found */
...
...
@@ -382,9 +378,8 @@ static void analyze_method_params_weight(ir_entity *ent)
assure_irg_outs
(
irg
);
ir_node
*
irg_args
=
get_irg_args
(
irg
);
for
(
int
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
long
proj_nr
=
get_Proj_proj
(
arg
);
foreach_irn_out_r
(
irg_args
,
i
,
arg
)
{
long
const
proj_nr
=
get_Proj_proj
(
arg
);
ent
->
attr
.
mtd_attr
.
param_weight
[
proj_nr
]
+=
calc_method_param_weight
(
arg
);
}
}
...
...
ir/ana/irmemory.c
View file @
68a66d3f
...
...
@@ -21,7 +21,7 @@
#include
"irflag.h"
#include
"hashptr.h"
#include
"irflag.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irgwalk.h"
#include
"irprintf.h"
#include
"debug.h"
...
...
@@ -824,9 +824,7 @@ static ir_entity_usage determine_entity_usage(const ir_node *irn,
ir_entity
*
entity
)
{
unsigned
res
=
0
;
for
(
int
i
=
get_irn_n_outs
(
irn
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
irn
,
i
);
foreach_irn_out_r
(
irn
,
i
,
succ
)
{
switch
(
get_irn_opcode
(
succ
))
{
case
iro_Load
:
/* beware: irn might be a Id node here, so irn might be not
...
...
@@ -916,11 +914,8 @@ static ir_entity_usage determine_entity_usage(const ir_node *irn,
--
input_nr
)
{
ir_node
*
pred
=
get_Tuple_pred
(
succ
,
input_nr
);
if
(
pred
==
irn
)
{
int
k
;
/* we found one input */
for
(
k
=
get_irn_n_outs
(
succ
)
-
1
;
k
>=
0
;
--
k
)
{
ir_node
*
proj
=
get_irn_out
(
succ
,
k
);
foreach_irn_out_r
(
succ
,
k
,
proj
)
{
if
(
is_Proj
(
proj
)
&&
get_Proj_proj
(
proj
)
==
input_nr
)
{
res
|=
determine_entity_usage
(
proj
,
entity
);
break
;
...
...
@@ -966,8 +961,7 @@ static void analyse_irg_entity_usage(ir_graph *irg)
ir_node
*
irg_frame
=
get_irg_frame
(
irg
);
for
(
int
j
=
get_irn_n_outs
(
irg_frame
);
j
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
irg_frame
,
j
);
foreach_irn_out_r
(
irg_frame
,
j
,
succ
)
{
ir_entity
*
entity
;
unsigned
flags
;
...
...
@@ -993,13 +987,9 @@ static void analyse_irg_entity_usage(ir_graph *irg)
assure_irg_outs
(
inner_irg
);
ir_node
*
args
=
get_irg_args
(
inner_irg
);
for
(
int
j
=
get_irn_n_outs
(
args
);
j
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
args
,
j
);
foreach_irn_out_r
(
args
,
j
,
arg
)
{
if
(
get_Proj_proj
(
arg
)
==
static_link_arg
)
{
for
(
int
k
=
get_irn_n_outs
(
arg
);
k
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
k
);
foreach_irn_out_r
(
arg
,
k
,
succ
)
{
if
(
is_Sel
(
succ
))
{
ir_entity
*
entity
=
get_Sel_entity
(
succ
);
...
...
ir/ana/irouts.c
View file @
68a66d3f
...
...
@@ -10,7 +10,7 @@
* @date 1.2002
*/
#include
"xmalloc.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irnode_t.h"
#include
"irgraph_t.h"
#include
"irprog_t.h"
...
...
@@ -48,8 +48,7 @@ unsigned get_Block_n_cfg_outs(const ir_node *bl)
{
assert
(
is_Block
(
bl
));
unsigned
n_cfg_outs
=
0
;
for
(
unsigned
i
=
0
;
i
<
get_irn_n_outs
(
bl
);
++
i
)
{
const
ir_node
*
succ
=
get_irn_out
(
bl
,
i
);
foreach_irn_out
(
bl
,
i
,
succ
)
{
if
(
get_irn_mode
(
succ
)
!=
mode_X
)
continue
;
if
(
is_End
(
succ
)
||
is_Bad
(
succ
))
...
...
@@ -63,8 +62,7 @@ unsigned get_Block_n_cfg_outs_ka(const ir_node *bl)
{
assert
(
is_Block
(
bl
));
unsigned
n_cfg_outs
=
0
;
for
(
unsigned
i
=
0
;
i
<
get_irn_n_outs
(
bl
);
++
i
)
{
const
ir_node
*
succ
=
get_irn_out
(
bl
,
i
);
foreach_irn_out
(
bl
,
i
,
succ
)
{
if
(
get_irn_mode
(
succ
)
!=
mode_X
)
continue
;
if
(
is_Bad
(
succ
))
...
...
@@ -84,8 +82,7 @@ unsigned get_Block_n_cfg_outs_ka(const ir_node *bl)
ir_node
*
get_Block_cfg_out
(
const
ir_node
*
bl
,
unsigned
pos
)
{
assert
(
is_Block
(
bl
));
for
(
unsigned
i
=
0
;
i
<
get_irn_n_outs
(
bl
);
++
i
)
{
const
ir_node
*
succ
=
get_irn_out
(
bl
,
i
);
foreach_irn_out
(
bl
,
i
,
succ
)
{
if
(
get_irn_mode
(
succ
)
!=
mode_X
)
continue
;
if
(
is_End
(
succ
)
||
is_Bad
(
succ
))
...
...
@@ -103,8 +100,7 @@ ir_node *get_Block_cfg_out(const ir_node *bl, unsigned pos)
ir_node
*
get_Block_cfg_out_ka
(
const
ir_node
*
bl
,
unsigned
pos
)
{
assert
(
is_Block
(
bl
));
for
(
unsigned
i
=
0
;
i
<
get_irn_n_outs
(
bl
);
++
i
)
{
const
ir_node
*
succ
=
get_irn_out
(
bl
,
i
);
foreach_irn_out
(
bl
,
i
,
succ
)
{
if
(
get_irn_mode
(
succ
)
!=
mode_X
)
continue
;
if
(
is_Bad
(
succ
))
...
...
@@ -144,8 +140,7 @@ static void irg_out_walk_2(ir_node *node, irg_walk_func *pre,
if
(
pre
!=
NULL
)
pre
(
node
,
env
);
for
(
int
i
=
0
,
n
=
get_irn_n_outs
(
node
);
i
<
n
;
++
i
)
{
ir_node
*
succ
=
get_irn_out
(
node
,
i
);
foreach_irn_out
(
node
,
i
,
succ
)
{
if
(
get_irn_visited
(
succ
)
<
get_irg_visited
(
irg
))
irg_out_walk_2
(
succ
,
pre
,
post
,
env
);
}
...
...
@@ -195,8 +190,7 @@ void irg_out_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
inc_irg_block_visited
(
irg
);
if
(
get_irn_mode
(
node
)
==
mode_X
)
{
for
(
int
i
=
0
,
n
=
get_irn_n_outs
(
node
);
i
<
n
;
++
i
)
{
ir_node
*
succ
=
get_irn_out
(
node
,
i
);
foreach_irn_out
(
node
,
i
,
succ
)
{
irg_out_block_walk2
(
succ
,
pre
,
post
,
env
);
}
}
else
{
...
...
ir/ana/irouts_t.h
0 → 100644
View file @
68a66d3f
/*
* This file is part of libFirm.
* Copyright (C) 2014 University of Karlsruhe.
*/
#ifndef FIRM_ANA_IROUTS_T_H
#define FIRM_ANA_IROUTS_T_H
#include
"irouts.h"
#define foreach_irn_out(irn, idx, succ) \
for (bool succ##__b = true; succ##__b;) \
for (ir_node const *const succ##__irn = (irn); succ##__b; succ##__b = false) \
for (unsigned idx = 0, succ##__n = get_irn_n_outs(succ##__irn); succ##__b && idx != succ##__n; ++idx) \
for (ir_node *const succ = (succ##__b = false, get_irn_out(succ##__irn, idx)); !succ##__b; succ##__b = true)
#define foreach_irn_out_r(irn, idx, succ) \
for (bool succ##__b = true; succ##__b;) \
for (ir_node const *const succ##__irn = (irn); succ##__b; succ##__b = false) \
for (unsigned idx = get_irn_n_outs(succ##__irn); succ##__b && idx-- != 0;) \
for (ir_node *const succ = (succ##__b = false, get_irn_out(succ##__irn, idx)); !succ##__b; succ##__b = true)
#endif
ir/ana/vrp.c
View file @
68a66d3f
...
...
@@ -11,7 +11,7 @@
#include
"irtypes.h"
#include
"vrp.h"
#include
"iroptimize.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irgraph_t.h"
#include
"irgopt.h"
#include
"irgwalk.h"
...
...
@@ -472,8 +472,7 @@ static void vrp_first_pass(ir_node *n, void *e)
vrp_update_node
(
env
->
info
,
n
);
for
(
int
i
=
get_irn_n_outs
(
n
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
n
,
i
);
foreach_irn_out_r
(
n
,
i
,
succ
)
{
if
(
bitset_is_set
(
env
->
visited
,
get_irn_idx
(
succ
)))
{
/* we found a loop*/
waitq_put
(
env
->
workqueue
,
succ
);
...
...
@@ -533,8 +532,7 @@ void set_vrp_data(ir_graph *irg)
if
(
vrp_update_node
(
info
,
node
))
{
/* if something changed, add successors to worklist*/
for
(
int
i
=
get_irn_n_outs
(
node
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
node
,
i
);
foreach_irn_out_r
(
node
,
i
,
succ
)
{
waitq_put
(
env
->
workqueue
,
succ
);
}
}
...
...
ir/ir/irdump.c
View file @
68a66d3f
...
...
@@ -25,7 +25,7 @@
#include
"irgwalk.h"
#include
"tv_t.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"iredges.h"
#include
"irdom.h"
#include
"irloop_t.h"
...
...
@@ -1595,9 +1595,7 @@ static void dump_class_hierarchy_node(ir_type *const tp, ir_entity *const ent, v
static
void
dump_out_edge
(
ir_node
*
n
,
void
*
env
)
{
FILE
*
F
=
(
FILE
*
)
env
;
for
(
int
i
=
get_irn_n_outs
(
n
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
n
,
i
);
assert
(
succ
);
foreach_irn_out_r
(
n
,
i
,
succ
)
{
print_node_edge_kind
(
F
,
succ
);
fprintf
(
F
,
"{sourcename: "
);
print_nodeid
(
F
,
n
);
...
...
ir/lower/lower_switch.c
View file @
68a66d3f
...
...
@@ -16,14 +16,11 @@
#include
"irgopt.h"
#include
"irgwalk.h"
#include
"irnode_t.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"lowering.h"
#include
"error.h"
#include
"irnodeset.h"
#define foreach_out_irn(irn, i, outirn) \
for (unsigned i = get_irn_n_outs(irn); i-- != 0 ? outirn = get_irn_out(irn, i), 1 : 0;)
typedef
struct
walk_env_t
{
ir_nodeset_t
processed
;
ir_mode
*
selector_mode
;
...
...
@@ -111,8 +108,7 @@ static void analyse_switch1(switch_info_t *info)
unsigned
c
=
0
;
size_t
e
;
ir_node
*
proj
=
NULL
;
foreach_out_irn
(
switchn
,
i
,
proj
)
{
foreach_irn_out_r
(
switchn
,
i
,
proj
)
{
long
pn
=
get_Proj_proj
(
proj
);
ir_node
*
target
=
get_irn_out
(
proj
,
0
);
...
...
@@ -211,8 +207,7 @@ static void create_out_of_bounds_check(switch_info_t *info)
set_nodes_block
(
switchn
,
new_block
);
/* adjust projs */
ir_node
*
proj
=
NULL
;
foreach_out_irn
(
switchn
,
i
,
proj
)
{
foreach_irn_out_r
(
switchn
,
i
,
proj
)
{
long
pn
=
get_Proj_proj
(
proj
);
if
(
pn
==
pn_Switch_default
)
{
assert
(
default_block
==
NULL
);
...
...
ir/opt/cfopt.c
View file @
68a66d3f
...
...
@@ -33,7 +33,7 @@
#include
"array.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irbackedge_t.h"
#include
"irflag_t.h"
...
...
@@ -852,18 +852,13 @@ void optimize_cf(ir_graph *irg)
ir_node
*
ka
=
get_End_keepalive
(
end
,
i
);
if
(
is_Phi
(
ka
))
{
int
k
;
for
(
k
=
get_irn_n_outs
(
ka
)
-
1
;
k
>=
0
;
--
k
)
{
ir_node
*
user
=
get_irn_out
(
ka
,
k
);
foreach_irn_out_r
(
ka
,
k
,
user
)
{
if
(
user
!=
ka
&&
user
!=
end
)
{
/* Is it a real user or just a self loop ? */
in
[
j
++
]
=
ka
;
break
;
}
}
if
(
k
>=
0
)
in
[
j
++
]
=
ka
;
}
else
in
[
j
++
]
=
ka
;
}
...
...
ir/opt/combo.c
View file @
68a66d3f
...
...
@@ -35,7 +35,7 @@
#include
"iropt_t.h"
#include
"irgwalk.h"
#include
"irop.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irgmod.h"
#include
"iropt_dbg.h"
#include
"debug.h"
...
...
@@ -765,9 +765,8 @@ static void add_to_cprop(node_t *y, environment_t *env)
if
(
get_irn_mode
(
irn
)
==
mode_T
)
{
/* mode_T nodes always produce tarval_top, so we must explicitly
* add its Projs to get constant evaluation to work */
for
(
unsigned
i
=
get_irn_n_outs
(
irn
);
i
--
>
0
;
)
{
node_t
*
proj
=
get_irn_node
(
get_irn_out
(
irn
,
i
));
foreach_irn_out_r
(
irn
,
i
,
succ
)
{
node_t
*
const
proj
=
get_irn_node
(
succ
);
add_to_cprop
(
proj
,
env
);
}
}
else
if
(
is_Block
(
irn
))
{
...
...
@@ -2641,10 +2640,8 @@ static void propagate(environment_t *env)
++
n_fallen
;
DB
((
dbg
,
LEVEL_2
,
"Add node %+F to fallen
\n
"
,
x
->
node
));
}
for
(
unsigned
i
=
get_irn_n_outs
(
x
->
node
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
x
->
node
,
i
);
node_t
*
y
=
get_irn_node
(
succ
);
foreach_irn_out_r
(
x
->
node
,
i
,
succ
)
{
node_t
*
const
y
=
get_irn_node
(
succ
);
/* Add y to y.partition.cprop. */
add_to_cprop
(
y
,
env
);
}
...
...
@@ -2728,9 +2725,7 @@ static ir_node *get_leader(node_t *node)
static
bool
only_one_reachable_proj
(
ir_node
*
n
)
{
unsigned
k
=
0
;
for
(
unsigned
i
=
get_irn_n_outs
(
n
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
n
,
i
);
foreach_irn_out_r
(
n
,
i
,
proj
)
{
/* skip non-control flow Proj's */
if
(
get_irn_mode
(
proj
)
!=
mode_X
)
continue
;
...
...
@@ -2969,10 +2964,8 @@ static void exchange_leader(ir_node *irn, ir_node *leader)
*/
static
bool
all_users_are_dead
(
const
ir_node
*
irn
)
{
unsigned
n
=
get_irn_n_outs
(
irn
);
for
(
unsigned
i
=
0
;
i
<
n
;
++
i
)
{
const
ir_node
*
succ
=
get_irn_out
(
irn
,
i
);
const
node_t
*
block
=
get_irn_node
(
get_nodes_block
(
succ
));
foreach_irn_out
(
irn
,
i
,
succ
)
{
node_t
const
*
const
block
=
get_irn_node
(
get_nodes_block
(
succ
));
if
(
!
is_reachable
(
block
))
{
/* block is unreachable */
...
...
ir/opt/opt_frame.c
View file @
68a66d3f
...
...
@@ -14,7 +14,7 @@
#include
"iroptimize.h"
#include
"irgraph_t.h"
#include
"type_t.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"iredges.h"
/*
...
...
@@ -25,9 +25,8 @@ void opt_frame_irg(ir_graph *irg)
{
ir_type
*
frame_tp
=
get_irg_frame_type
(
irg
);
ir_entity
*
ent
,
*
list
;
ir_node
*
frame
,
*
sel
;
ir_node
*
frame
;
size_t
i
,
n
=
get_class_n_members
(
frame_tp
);
int
o
;
if
(
n
<=
0
)
return
;
...
...
@@ -46,8 +45,7 @@ void opt_frame_irg(ir_graph *irg)
frame
=
get_irg_frame
(
irg
);
/* mark all used entities */
for
(
o
=
get_irn_n_outs
(
frame
)
-
1
;
o
>=
0
;
--
o
)
{
sel
=
get_irn_out
(
frame
,
o
);
foreach_irn_out_r
(
frame
,
o
,
sel
)
{
if
(
is_Sel
(
sel
))
{
ent
=
get_Sel_entity
(
sel
);
/* only entities on the frame */
...
...
ir/opt/opt_inline.c
View file @
68a66d3f
...
...
@@ -30,7 +30,7 @@
#include
"xmalloc.h"
#include
"pqueue.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irloop_t.h"
#include
"irbackedge_t.h"
#include
"opt_init.h"
...
...
@@ -784,10 +784,7 @@ static call_entry *duplicate_call_entry(const call_entry *entry,
static
unsigned
calc_method_local_weight
(
ir_node
*
arg
)
{
unsigned
weight
=
0
;
for
(
unsigned
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
foreach_irn_out_r
(
arg
,
i
,
succ
)
{
switch
(
get_irn_opcode
(
succ
))
{
case
iro_Load
:
case
iro_Store
:
...
...
@@ -819,8 +816,7 @@ static unsigned calc_method_local_weight(ir_node *arg)
ir_node
*
pred
=
get_Tuple_pred
(
succ
,
j
);
if
(
pred
==
arg
)
{
/* look for Proj(j) */
for
(
unsigned
k
=
get_irn_n_outs
(
succ
);
k
--
>
0
;
)
{
ir_node
*
succ_succ
=
get_irn_out
(
succ
,
k
);
foreach_irn_out_r
(
succ
,
k
,
succ_succ
)
{
if
(
is_Proj
(
succ_succ
))
{
if
(
get_Proj_proj
(
succ_succ
)
==
j
)
{
/* found */
...
...
@@ -855,9 +851,8 @@ static void analyze_irg_local_weights(inline_irg_env *env, ir_graph *irg)
assure_irg_outs
(
irg
);
ir_node
*
irg_args
=
get_irg_args
(
irg
);
for
(
unsigned
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
long
pn
=
get_Proj_proj
(
arg
);
foreach_irn_out_r
(
irg_args
,
i
,
arg
)
{
long
const
pn
=
get_Proj_proj
(
arg
);
env
->
local_weights
[
pn
]
=
calc_method_local_weight
(
arg
);
}
}
...
...
ir/opt/opt_ldst.c
View file @
68a66d3f
...
...
@@ -16,7 +16,7 @@
#include
"irdom.h"
#include
"irgmod.h"
#include
"irgwalk.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irgopt.h"
#include
"iropt.h"
#include
"iroptimize.h"
...
...
@@ -228,17 +228,13 @@ static void walk_memory(ir_node *irn, irg_walk_func *pre, irg_walk_func *post, v
mode
=
get_irn_mode
(
irn
);
if
(
mode
==
mode_M
)
{
/* every successor uses memory */
for
(
unsigned
i
=
get_irn_n_outs
(
irn
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
irn
,
i
);
foreach_irn_out_r
(
irn
,
i
,
succ
)
{
if
(
!
irn_visited
(
succ
))
walk_memory
(
succ
,
pre
,
post
,
ctx
);
}
}
else
if
(
mode
==
mode_T
)
{
/* only some Proj's uses memory */
for
(
unsigned
i
=
get_irn_n_outs
(
irn
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
irn
,
i
);
foreach_irn_out_r
(
irn
,
i
,
proj
)
{
if
(
get_irn_mode
(
proj
)
==
mode_M
&&
!
irn_visited
(
proj
))
walk_memory
(
proj
,
pre
,
post
,
ctx
);
}
...
...
@@ -624,15 +620,12 @@ static void update_Load_memop(memop_t *m)
m
->
value
.
address
=
ptr
;
for
(
unsigned
i
=
get_irn_n_outs
(
load
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
load
,
i
);
long
pn
;
foreach_irn_out_r
(
load
,
i
,
proj
)
{
/* beware of keep edges */
if
(
is_End
(
proj
))
continue
;
pn
=
get_Proj_proj
(
proj
);
long
const
pn
=
get_Proj_proj
(
proj
);
m
->
projs
[
pn
]
=
proj
;
switch
(
pn
)
{
case
pn_Load_res
:
...
...
@@ -704,15 +697,12 @@ static void update_Store_memop(memop_t *m)
m
->
value
.
address
=
adr
;
for
(
unsigned
i
=
get_irn_n_outs
(
store
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
store
,
i
);
long
pn
;
foreach_irn_out_r
(
store
,
i
,
proj
)
{
/* beware of keep edges */
if
(
is_End
(
proj
))
continue
;
pn
=
get_Proj_proj
(
proj
);
long
const
pn
=
get_Proj_proj
(
proj
);
m
->
projs
[
pn
]
=
proj
;
switch
(
pn
)
{
case
pn_Store_X_except
:
...
...
@@ -750,9 +740,7 @@ static void update_Call_memop(memop_t *m)
}
else
m
->
flags
=
FLAG_KILL_ALL
;
for
(
unsigned
i
=
get_irn_n_outs
(
call
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
call
,
i
);
foreach_irn_out_r
(
call
,
i
,
proj
)
{
/* beware of keep edges */
if
(
is_End
(
proj
))
continue
;
...
...
@@ -777,9 +765,7 @@ static void update_Div_memop(memop_t *m)
{
ir_node
*
div
=
m
->
node
;
for
(
unsigned
i
=
get_irn_n_outs
(
div
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
div
,
i
);
foreach_irn_out_r
(
div
,
i
,
proj
)
{
/* beware of keep edges */
if
(
is_End
(
proj
))
continue
;
...
...
@@ -799,9 +785,7 @@ static void update_Mod_memop(memop_t *m)
{
ir_node
*
div
=
m
->
node
;
for
(
unsigned
i
=
get_irn_n_outs
(
div
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
div
,
i
);
foreach_irn_out_r
(
div
,
i
,
proj
)
{
/* beware of keep edges */
if
(
is_End
(
proj
))
continue
;
...
...
ir/opt/proc_cloning.c
View file @
68a66d3f
...
...
@@ -25,7 +25,7 @@
#include
"analyze_irg_args.h"
#include
"irprintf.h"
#include
"ircons.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"irnode_t.h"
#include
"irtools.h"
#include
"irgmod.h"
...
...
@@ -277,8 +277,7 @@ static ir_node *get_irg_arg(ir_graph *irg, size_t pos)
assure_irg_outs
(
irg
);
/* Search the argument with the number pos.*/
for
(
unsigned
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
irg_args
,
i
);
foreach_irn_out_r
(
irg_args
,
i
,
proj
)
{
if
((
int
)
pos
==
get_Proj_proj
(
proj
))
{
if
(
arg
)
{
/*
...
...
ir/opt/scalar_replace.c
View file @
68a66d3f
...
...
@@ -22,7 +22,7 @@
#include
"irgwalk.h"
#include
"irnode_t.h"
#include
"iroptimize.h"
#include
"irouts.h"
#include
"irouts
_t
.h"
#include
"opt_init.h"
#include
"pset.h"
#include
"scalar_replace.h"
...
...
@@ -157,9 +157,7 @@ bool is_address_taken(ir_node *sel)
if
(
!
is_const_sel
(
sel
))
return
true
;
for
(
unsigned
i
=
get_irn_n_outs
(
sel
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
sel
,
i
);
foreach_irn_out_r
(
sel
,
i
,
succ
)
{
switch
(
get_irn_opcode
(
succ
))
{
case
iro_Load
:
{
/* do not remove volatile variables */
...
...
@@ -227,9 +225,7 @@ bool is_address_taken(ir_node *sel)
if
(
pred
!=
sel
)
continue
;
/* we found one input */
for
(
unsigned
k
=
get_irn_n_outs
(
succ
);
k
--
>
0
;
)
{
ir_node
*
proj
=
get_irn_out
(
succ
,
k
);
foreach_irn_out_r
(
succ
,
k
,
proj
)
{
if
(
is_Proj
(
proj
)
&&
get_Proj_proj
(
proj
)
==
input_nr
)
{
bool
res
=
is_address_taken
(
proj
);
if
(
res
)
...
...
@@ -267,9 +263,7 @@ static leaf_state_t link_all_leaf_sels(ir_entity *ent, ir_node *sel)
{
/** A leaf Sel is a Sel that is used directly by a Load or Store. */
leaf_state_t
state
=
POSSIBLE_LEAF
;
for
(
unsigned
i
=
get_irn_n_outs
(
sel
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
sel
,
i
);
foreach_irn_out_r
(
sel
,
i
,
succ
)
{
if
(
is_Load
(
succ
)
||
is_Store
(
succ
))
{
state
|=
HAS_CHILD_LOAD_STORE
;
continue
;
...
...
@@ -343,13 +337,11 @@ static bool find_possible_replacements(ir_graph *irg)
assure_irg_properties
(
inner_irg
,
IR_GRAPH_PROPERTY_CONSISTENT_OUTS
|
IR_GRAPH_PROPERTY_NO_TUPLES
);
args
=
get_irg_args
(
inner_irg
);
for
(
unsigned
j
=
get_irn_n_outs
(
args
);
j
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
args
,
j
);
foreach_irn_out_r
(
args
,
j
,
arg
)
{
if
(
get_Proj_proj
(
arg
)
!=
static_link_arg
)
continue
;
for
(
unsigned
k
=
get_irn_n_outs
(
arg
);
k
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
k
);
foreach_irn_out_r
(
arg
,
k
,
succ
)
{
if
(
!
is_Sel
(
succ
))
continue
;
ir_entity
*
ent
=
get_Sel_entity
(
succ
);
...
...
@@ -365,8 +357,7 @@ static bool find_possible_replacements(ir_graph *irg)
* replacement set the link of this entity to ADDRESS_TAKEN. */
ir_node
*
irg_frame
=
get_irg_frame
(
irg
);