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
98beada6
Commit
98beada6
authored
Jul 13, 2012
by
Christoph Mallon
Browse files
Let foreach_pset() declare its iterator variable.
parent
26b90086
Changes
14
Hide whitespace changes
Inline
Side-by-side
include/libfirm/adt/pset.h
View file @
98beada6
...
...
@@ -215,7 +215,7 @@ FIRM_API void pset_break(pset *pset);
* @param type type of iterator variable
* @param entry the iterator
*/
#define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset))
#define foreach_pset(pset, type, entry) for (
type
entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset))
/**
* Inserts all elements of the pointer set src into
...
...
ir/adt/set.c
View file @
98beada6
...
...
@@ -437,7 +437,6 @@ void *(pset_insert) (SET *se, const void *key, unsigned hash)
void
pset_insert_pset_ptr
(
pset
*
target
,
pset
*
src
)
{
void
*
elt
;
foreach_pset
(
src
,
void
*
,
elt
)
{
pset_insert_ptr
(
target
,
elt
);
}
...
...
ir/ana/callgraph.c
View file @
98beada6
...
...
@@ -270,8 +270,7 @@ void compute_callgraph(void)
/* Change the sets to arrays. */
for
(
i
=
0
;
i
<
n_irgs
;
++
i
)
{
size_t
j
,
count
;
cg_callee_entry
*
callee
;
ir_graph
*
c
,
*
irg
=
get_irp_irg
(
i
);
ir_graph
*
irg
=
get_irp_irg
(
i
);
pset
*
callee_set
,
*
caller_set
;
callee_set
=
(
pset
*
)
irg
->
callees
;
...
...
ir/ana/cgana.c
View file @
98beada6
...
...
@@ -119,7 +119,6 @@ static ir_entity **get_impl_methods(ir_entity *method)
/* no overwriting methods found */
arr
=
NULL
;
}
else
{
ir_entity
*
ent
;
arr
=
NEW_ARR_F
(
ir_entity
*
,
size
);
foreach_pset
(
set
,
ir_entity
*
,
ent
)
{
arr
[
--
size
]
=
ent
;
...
...
@@ -529,7 +528,6 @@ static size_t get_free_methods(ir_entity ***free_methods)
pset
*
free_set
=
pset_new_ptr_default
();
size_t
i
,
n
,
j
,
m
;
ir_entity
**
arr
;
ir_entity
*
ent
;
ir_graph
*
irg
;
ir_type
*
tp
;
size_t
length
;
...
...
@@ -537,7 +535,7 @@ static size_t get_free_methods(ir_entity ***free_methods)
for
(
i
=
0
,
n
=
get_irp_n_irgs
();
i
<
n
;
++
i
)
{
ir_linkage
linkage
;
irg
=
get_irp_irg
(
i
);
ent
=
get_irg_entity
(
irg
);
ir_entity
*
const
ent
=
get_irg_entity
(
irg
);
linkage
=
get_entity_linkage
(
ent
);
if
((
linkage
&
IR_LINKAGE_HIDDEN_USER
)
||
entity_is_externally_visible
(
ent
))
{
...
...
@@ -554,12 +552,12 @@ static size_t get_free_methods(ir_entity ***free_methods)
/* insert all methods that are used in global variables initializers */
tp
=
get_glob_type
();
for
(
j
=
0
,
m
=
get_class_n_members
(
tp
);
j
<
m
;
++
j
)
{
ent
=
get_class_member
(
tp
,
j
);
ir_entity
*
const
ent
=
get_class_member
(
tp
,
j
);
add_method_address
(
ent
,
free_set
);
}
tp
=
get_tls_type
();
for
(
j
=
0
,
m
=
get_compound_n_members
(
tp
);
j
<
m
;
++
j
)
{
ent
=
get_compound_member
(
tp
,
j
);
ir_entity
*
const
ent
=
get_compound_member
(
tp
,
j
);
add_method_address
(
ent
,
free_set
);
}
...
...
@@ -713,7 +711,6 @@ static void callee_walker(ir_node *call, void *env)
(
void
)
env
;
if
(
is_Call
(
call
))
{
pset
*
methods
=
pset_new_ptr_default
();
ir_entity
*
ent
;
ir_entity
**
arr
;
size_t
i
;
...
...
@@ -773,7 +770,6 @@ static void callee_ana(void)
/** Frees intermediate data structures. */
static
void
sel_methods_dispose
(
void
)
{
ir_entity
*
ent
;
assert
(
entities
);
foreach_pset
(
entities
,
ir_entity
*
,
ent
)
{
ir_entity
**
arr
=
(
ir_entity
**
)
get_entity_link
(
ent
);
...
...
ir/be/becopyilp2.c
View file @
98beada6
...
...
@@ -414,7 +414,6 @@ static void build_clique_star_cstr(ilp_env_t *ienv)
/* search for a candidate to extend the clique */
for
(
i
=
0
;
i
<
n_nodes
;
++
i
)
{
ir_node
*
cand
=
nodes
[
i
];
ir_node
*
member
;
bool
is_cand
;
/* if its already in the clique try the next */
...
...
@@ -447,10 +446,9 @@ static void build_clique_star_cstr(ilp_env_t *ienv)
/* now the clique is maximal. Finally add the constraint */
{
ir_node
*
member
;
int
var_idx
;
int
cst_idx
;
char
buf
[
32
];
int
var_idx
;
int
cst_idx
;
char
buf
[
32
];
cst_idx
=
lpp_add_cst
(
ienv
->
lp
,
NULL
,
lpp_greater_equal
,
pset_count
(
clique
)
-
1
);
...
...
ir/be/beifg.c
View file @
98beada6
...
...
@@ -244,7 +244,6 @@ static inline int get_next_clique(cliques_iter_t *it)
/* before shrinking the set, return the current maximal clique */
if
(
output_on_shrink
)
{
int
count
=
0
;
ir_node
*
irn
;
/* fill the output buffer */
foreach_pset
(
it
->
living
,
ir_node
*
,
irn
)
{
...
...
ir/common/irtools.c
View file @
98beada6
...
...
@@ -211,8 +211,6 @@ void irn_rewire_inputs(ir_node *node)
void
firm_pset_dump
(
pset
*
set
)
{
void
*
obj
;
foreach_pset
(
set
,
void
*
,
obj
)
{
ir_fprintf
(
stderr
,
"%+F
\n
"
,
obj
);
}
...
...
ir/ir/irdump.c
View file @
98beada6
...
...
@@ -2284,7 +2284,6 @@ void dump_loop(FILE *F, ir_loop *l)
{
pset
*
loopnodes
=
pset_new_ptr_default
();
pset
*
extnodes
=
pset_new_ptr_default
();
ir_node
*
n
,
*
b
;
char
name
[
50
];
snprintf
(
name
,
sizeof
(
name
),
"loop_%ld"
,
get_loop_loop_nr
(
l
));
...
...
@@ -2303,14 +2302,14 @@ void dump_loop(FILE *F, ir_loop *l)
}
foreach_pset
(
loopnodes
,
ir_node
*
,
n
)
{
if
(
!
is_Block
(
n
))
{
b
=
get_nodes_block
(
n
);
ir_node
*
const
b
=
get_nodes_block
(
n
);
set_irn_link
(
n
,
get_irn_link
(
b
));
set_irn_link
(
b
,
n
);
}
}
foreach_pset
(
extnodes
,
ir_node
*
,
n
)
{
if
(
!
is_Block
(
n
))
{
b
=
get_nodes_block
(
n
);
ir_node
*
const
b
=
get_nodes_block
(
n
);
set_irn_link
(
n
,
get_irn_link
(
b
));
set_irn_link
(
b
,
n
);
}
...
...
@@ -2329,7 +2328,7 @@ void dump_loop(FILE *F, ir_loop *l)
dump_ir_data_edges
(
F
,
b
);
/* dump the nodes that go into the block */
for
(
n
=
(
ir_node
*
)
get_irn_link
(
b
);
n
;
n
=
(
ir_node
*
)
get_irn_link
(
n
))
{
for
(
ir_node
*
n
=
(
ir_node
*
)
get_irn_link
(
b
);
n
;
n
=
(
ir_node
*
)
get_irn_link
(
n
))
{
if
(
pset_find_ptr
(
extnodes
,
n
))
overrule_nodecolor
=
ird_color_block_inout
;
dump_node
(
F
,
n
);
...
...
@@ -2353,7 +2352,7 @@ void dump_loop(FILE *F, ir_loop *l)
fprintf
(
F
,
"
\"
status:clustered color:lightblue
\n
"
);
/* dump the nodes that go into the block */
for
(
n
=
(
ir_node
*
)
get_irn_link
(
b
);
n
;
n
=
(
ir_node
*
)
get_irn_link
(
n
))
{
for
(
ir_node
*
n
=
(
ir_node
*
)
get_irn_link
(
b
);
n
;
n
=
(
ir_node
*
)
get_irn_link
(
n
))
{
if
(
!
pset_find_ptr
(
loopnodes
,
n
))
overrule_nodecolor
=
ird_color_block_inout
;
dump_node
(
F
,
n
);
...
...
ir/ir/iropt.c
View file @
98beada6
...
...
@@ -6619,7 +6619,6 @@ void add_identities(ir_node *node)
void
visit_all_identities
(
ir_graph
*
irg
,
irg_walk_func
visit
,
void
*
env
)
{
ir_node
*
node
;
ir_graph
*
rem
=
current_ir_graph
;
current_ir_graph
=
irg
;
...
...
ir/opt/proc_cloning.c
View file @
98beada6
...
...
@@ -585,7 +585,7 @@ restart:
*/
void
proc_cloning
(
float
threshold
)
{
entry_t
*
entry
=
NULL
,
*
p
;
entry_t
*
p
;
size_t
i
,
n
;
q_set
hmap
;
...
...
@@ -651,14 +651,14 @@ void proc_cloning(float threshold)
#ifdef DEBUG_libfirm
/* Print some information about the list. */
DB
((
dbg
,
LEVEL_2
,
"-----------------
\n
"
));
for
(
entry
=
hmap
.
heavy_uses
;
entry
;
entry
=
entry
->
next
)
{
for
(
entry
_t
*
entry
=
hmap
.
heavy_uses
;
entry
;
entry
=
entry
->
next
)
{
DB
((
dbg
,
LEVEL_2
,
"
\n
weight: is %f
\n
"
,
entry
->
weight
));
DB
((
dbg
,
LEVEL_2
,
"Call for Method %E
\n
"
,
entry
->
q
.
ent
));
DB
((
dbg
,
LEVEL_2
,
"Position %zu
\n
"
,
entry
->
q
.
pos
));
DB
((
dbg
,
LEVEL_2
,
"Value %T
\n
"
,
entry
->
q
.
tv
));
}
#endif
entry
=
hmap
.
heavy_uses
;
entry_t
*
const
entry
=
hmap
.
heavy_uses
;
if
(
entry
)
{
quadruple_t
*
qp
=
&
entry
->
q
;
...
...
ir/stat/distrib.c
View file @
98beada6
...
...
@@ -186,7 +186,6 @@ void stat_insert_int_distrib_tbl(distrib_tbl_t *tbl, int key)
*/
int
stat_get_count_distrib_tbl
(
distrib_tbl_t
*
tbl
)
{
distrib_entry_t
*
entry
;
counter_t
cnt
=
ZERO_CNT
;
foreach_pset
(
tbl
->
hash_map
,
distrib_entry_t
*
,
entry
)
...
...
@@ -199,7 +198,6 @@ int stat_get_count_distrib_tbl(distrib_tbl_t *tbl)
*/
double
stat_calc_mean_distrib_tbl
(
distrib_tbl_t
*
tbl
)
{
distrib_entry_t
*
entry
;
size_t
count
;
double
sum
;
...
...
@@ -240,9 +238,8 @@ double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
*/
double
stat_calc_avg_distrib_tbl
(
distrib_tbl_t
*
tbl
)
{
distrib_entry_t
*
entry
;
size_t
count
=
0
;
double
sum
=
0
.
0
;
size_t
count
=
0
;
double
sum
=
0
.
0
;
if
(
tbl
->
int_dist
)
{
if
(
pset_count
(
tbl
->
hash_map
)
<=
0
)
...
...
@@ -267,8 +264,6 @@ double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl)
*/
void
stat_iterate_distrib_tbl
(
const
distrib_tbl_t
*
tbl
,
eval_distrib_entry_fun
eval
,
void
*
env
)
{
distrib_entry_t
*
entry
;
foreach_pset
(
tbl
->
hash_map
,
distrib_entry_t
*
,
entry
)
eval
(
entry
,
env
);
}
ir/stat/firmstat.c
View file @
98beada6
...
...
@@ -1101,7 +1101,6 @@ static void count_adr_ops(ir_node *node, void *env)
*/
static
void
update_graph_stat
(
graph_entry_t
*
global
,
graph_entry_t
*
graph
)
{
node_entry_t
*
entry
;
int
i
;
/* clear first the alive counter in the graph */
...
...
@@ -1253,8 +1252,6 @@ static void stat_dump_registered(graph_entry_t *entry)
for
(
dumper
=
status
->
dumper
;
dumper
;
dumper
=
dumper
->
next
)
{
if
(
dumper
->
func_map
)
{
dump_graph_FUNC
func
;
foreach_pset
(
dumper
->
func_map
,
dump_graph_FUNC
,
func
)
func
(
dumper
,
entry
);
}
/* if */
...
...
@@ -2032,7 +2029,6 @@ void stat_dump_snapshot(const char *name, const char *phase)
STAT_ENTER
;
{
graph_entry_t
*
entry
;
graph_entry_t
*
global
=
graph_get_entry
(
NULL
,
status
->
irg_hash
);
/*
...
...
@@ -2090,7 +2086,7 @@ void stat_dump_snapshot(const char *name, const char *phase)
/* some calculations are dependent, we pushed them on the wait_q */
while
(
!
pdeq_empty
(
status
->
wait_q
))
{
entry
=
(
graph_entry_t
*
)
pdeq_getr
(
status
->
wait_q
);
graph_entry_t
*
const
entry
=
(
graph_entry_t
*
)
pdeq_getr
(
status
->
wait_q
);
update_graph_stat_2
(
global
,
entry
);
}
/* while */
...
...
@@ -2132,15 +2128,11 @@ void stat_dump_snapshot(const char *name, const char *phase)
stat_finish_pattern_history
(
fname
);
/* clear the global counters here */
{
node_entry_t
*
entry
;
foreach_pset
(
global
->
opcode_hash
,
node_entry_t
*
,
entry
)
{
opcode_clear_entry
(
entry
);
}
/* for */
/* clear all global counter */
graph_clear_entry
(
global
,
/*all=*/
1
);
}
foreach_pset
(
global
->
opcode_hash
,
node_entry_t
*
,
entry
)
{
opcode_clear_entry
(
entry
);
}
/* for */
/* clear all global counter */
graph_clear_entry
(
global
,
/*all=*/
1
);
}
STAT_LEAVE
;
}
/* stat_dump_snapshot */
...
...
ir/stat/pattern.c
View file @
98beada6
...
...
@@ -745,7 +745,6 @@ static void calc_nodes_pattern(ir_node *node, void *ctx)
static
void
store_pattern
(
const
char
*
fname
)
{
FILE
*
f
;
pattern_entry_t
*
entry
;
size_t
count
=
pset_count
(
status
->
pattern_hash
);
if
(
count
<=
0
)
...
...
@@ -828,7 +827,6 @@ read_error:
*/
static
void
pattern_output
(
const
char
*
fname
)
{
pattern_entry_t
*
entry
;
pattern_entry_t
**
pattern_arr
;
pattern_dumper_t
*
dump
;
size_t
i
,
count
=
pset_count
(
status
->
pattern_hash
);
...
...
@@ -853,7 +851,7 @@ static void pattern_output(const char *fname)
qsort
(
pattern_arr
,
count
,
sizeof
(
*
pattern_arr
),
pattern_count_cmp
);
for
(
i
=
0
;
i
<
count
;
++
i
)
{
entry
=
pattern_arr
[
i
];
pattern_entry_t
*
const
entry
=
pattern_arr
[
i
];
if
(
cnt_to_uint
(
&
entry
->
count
)
<
status
->
bound
)
continue
;
...
...
ir/stat/stat_dmp.c
View file @
98beada6
...
...
@@ -193,7 +193,6 @@ static const char *if_conv_names[IF_RESULT_LAST] = {
*/
static
void
simple_dump_opcode_hash
(
dumper_t
*
dmp
,
pset
*
set
)
{
node_entry_t
*
entry
;
counter_t
f_alive
;
counter_t
f_new_node
;
counter_t
f_Id
;
...
...
@@ -244,7 +243,6 @@ static const char *get_opt_name(int index)
static
void
simple_dump_opt_hash
(
dumper_t
*
dmp
,
pset
*
set
,
int
index
)
{
if
(
pset_count
(
set
)
>
0
)
{
opt_entry_t
*
entry
;
const
char
*
name
=
get_opt_name
(
index
);
fprintf
(
dmp
->
f
,
"
\n
%s:
\n
"
,
name
);
...
...
@@ -262,18 +260,16 @@ static void simple_dump_opt_hash(dumper_t *dmp, pset *set, int index)
*/
static
void
simple_dump_be_block_reg_pressure
(
dumper_t
*
dmp
,
graph_entry_t
*
entry
)
{
be_block_entry_t
*
b_entry
=
(
be_block_entry_t
*
)
pset_first
(
entry
->
be_block_hash
);
reg_pressure_entry_t
*
rp_entry
;
/* return if no be statistic information available */
if
(
!
b_entry
)
be_block_entry_t
*
const
b_first
=
(
be_block_entry_t
*
)
pset_first
(
entry
->
be_block_hash
);
if
(
!
b_first
)
return
;
fprintf
(
dmp
->
f
,
"
\n
REG PRESSURE:
\n
"
);
fprintf
(
dmp
->
f
,
"%12s"
,
"Block Nr"
);
/* print table head (register class names) */
foreach_pset
(
b_
entry
->
reg_pressure
,
reg_pressure_entry_t
*
,
rp_entry
)
foreach_pset
(
b_
first
->
reg_pressure
,
reg_pressure_entry_t
*
,
rp_entry
)
fprintf
(
dmp
->
f
,
"%15s"
,
rp_entry
->
class_name
);
fprintf
(
dmp
->
f
,
"
\n
"
);
...
...
@@ -300,8 +296,7 @@ static void simple_dump_distrib_entry(const distrib_entry_t *entry, void *env)
static
void
simple_dump_be_block_sched_ready
(
dumper_t
*
dmp
,
graph_entry_t
*
entry
)
{
if
(
pset_count
(
entry
->
be_block_hash
)
>
0
)
{
be_block_entry_t
*
b_entry
;
int
i
;
int
i
;
fprintf
(
dmp
->
f
,
"
\n
SCHEDULING: NUMBER OF READY NODES
\n
"
);
fprintf
(
dmp
->
f
,
"%12s %12s %12s %12s %12s %12s %12s
\n
"
,
...
...
@@ -335,11 +330,10 @@ static void add_distrib_entry(const distrib_entry_t *entry, void *env)
*/
static
void
simple_dump_be_block_permstat_class
(
dumper_t
*
dmp
,
perm_class_entry_t
*
entry
)
{
perm_stat_entry_t
*
ps_ent
;
distrib_tbl_t
*
sum_chains
=
stat_new_int_distrib_tbl
();
distrib_tbl_t
*
sum_cycles
=
stat_new_int_distrib_tbl
();
char
buf
[
16
];
int
i
;
distrib_tbl_t
*
sum_chains
=
stat_new_int_distrib_tbl
();
distrib_tbl_t
*
sum_cycles
=
stat_new_int_distrib_tbl
();
char
buf
[
16
];
int
i
;
fprintf
(
dmp
->
f
,
"%12s %12s %12s %12s %12s %12s
\n
"
,
"size"
,
...
...
@@ -405,12 +399,8 @@ static void simple_dump_be_block_permstat_class(dumper_t *dmp, perm_class_entry_
static
void
simple_dump_be_block_permstat
(
dumper_t
*
dmp
,
graph_entry_t
*
entry
)
{
if
(
pset_count
(
entry
->
be_block_hash
)
>
0
)
{
be_block_entry_t
*
b_entry
;
fprintf
(
dmp
->
f
,
"
\n
PERMUTATION STATISTICS BEGIN:
\n
"
);
foreach_pset
(
entry
->
be_block_hash
,
be_block_entry_t
*
,
b_entry
)
{
perm_class_entry_t
*
pc_ent
;
fprintf
(
dmp
->
f
,
"BLOCK %ld:
\n
"
,
b_entry
->
block_nr
);
if
(
b_entry
->
perm_class_stat
)
{
...
...
@@ -470,7 +460,6 @@ static void simple_dump_edges(dumper_t *dmp, counter_t *cnt)
static
void
simple_dump_graph
(
dumper_t
*
dmp
,
graph_entry_t
*
entry
)
{
int
dump_opts
=
1
;
block_entry_t
*
b_entry
;
if
(
!
dmp
->
f
)
return
;
...
...
@@ -728,7 +717,6 @@ const dumper_t simple_dumper = {
*/
static
void
csv_count_nodes
(
dumper_t
*
dmp
,
graph_entry_t
*
graph
,
counter_t
cnt
[])
{
node_entry_t
*
entry
;
int
i
;
for
(
i
=
0
;
i
<
4
;
++
i
)
...
...
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