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
2672e202
Commit
2672e202
authored
Mar 14, 2013
by
Matthias Braun
Browse files
coding style cleanup, use C99
parent
9697d318
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
ir/ana/analyze_irg_args.c
View file @
2672e202
...
...
@@ -31,16 +31,11 @@
*/
static
ptr_access_kind
analyze_arg
(
ir_node
*
arg
,
ptr_access_kind
bits
)
{
int
i
,
p
;
ir_node
*
succ
;
/* We must visit a node once to avoid endless recursion.*/
mark_irn_visited
(
arg
);
for
(
i
=
get_irn_n_outs
(
arg
)
-
1
;
i
>=
0
;
--
i
)
{
succ
=
get_irn_out
(
arg
,
i
);
/* We was here.*/
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
if
(
irn_visited
(
succ
))
continue
;
...
...
@@ -68,7 +63,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
if
(
is_SymConst_addr_ent
(
ptr
))
{
meth_ent
=
get_SymConst_entity
(
ptr
);
for
(
p
=
get_Call_n_params
(
succ
)
-
1
;
p
>
=
0
;
--
p
)
{
for
(
int
p
=
get_Call_n_params
(
succ
);
p
--
>
0
;
)
{
if
(
get_Call_param
(
succ
,
p
)
==
arg
)
{
/* an arg can be used more than once ! */
bits
|=
get_method_param_access
(
meth_ent
,
p
);
...
...
@@ -76,11 +71,10 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
}
}
else
if
(
is_Sel
(
ptr
)
&&
get_irp_callee_info_state
()
==
irg_callee_info_consistent
)
{
/* is be a polymorphic call but callee information is available */
int
n_params
=
get_Call_n_params
(
succ
);
int
c
;
size_t
n_params
=
get_Call_n_params
(
succ
);
/* simply look into ALL possible callees */
for
(
c
=
get_Call_n_callees
(
succ
)
-
1
;
c
>
=
0
;
--
c
)
{
for
(
int
c
=
get_Call_n_callees
(
succ
);
c
--
>
0
;
)
{
meth_ent
=
get_Call_callee
(
succ
,
c
);
/* unknown_entity is used to signal that we don't know what is called */
...
...
@@ -89,7 +83,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
break
;
}
for
(
p
=
n_params
-
1
;
p
>
=
0
;
--
p
)
{
for
(
size_t
p
=
n_params
;
p
--
>
0
;
)
{
if
(
get_Call_param
(
succ
,
p
)
==
arg
)
{
/* an arg can be used more than once ! */
bits
|=
get_method_param_access
(
meth_ent
,
p
);
...
...
@@ -162,16 +156,8 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
*/
static
void
analyze_ent_args
(
ir_entity
*
ent
)
{
ir_graph
*
irg
;
ir_node
*
irg_args
,
*
arg
;
ir_mode
*
arg_mode
;
int
nparams
,
i
;
long
proj_nr
;
ir_type
*
mtp
;
ptr_access_kind
*
rw_info
;
mtp
=
get_entity_type
(
ent
);
nparams
=
get_method_n_params
(
mtp
);
ir_type
*
mtp
=
get_entity_type
(
ent
);
size_t
nparams
=
get_method_n_params
(
mtp
);
ent
->
attr
.
mtd_attr
.
param_access
=
NEW_ARR_F
(
ptr_access_kind
,
nparams
);
...
...
@@ -181,37 +167,36 @@ static void analyze_ent_args(ir_entity *ent)
if
(
nparams
<=
0
)
return
;
irg
=
get_entity_irg
(
ent
);
/* we have not yet analyzed the graph, set ALL access for pointer args */
for
(
i
=
nparams
-
1
;
i
>
=
0
;
--
i
)
{
for
(
size_t
i
=
nparams
;
i
--
>
0
;
)
{
ir_type
*
type
=
get_method_param_type
(
mtp
,
i
);
ent
->
attr
.
mtd_attr
.
param_access
[
i
]
=
is_Pointer_type
(
type
)
?
ptr_access_all
:
ptr_access_none
;
}
if
(
!
irg
)
{
ir_graph
*
irg
=
get_entity_irg
(
ent
);
if
(
irg
==
NULL
)
{
/* no graph, no better info */
return
;
}
assure_irg_outs
(
irg
);
irg_args
=
get_irg_args
(
irg
);
ir_node
*
irg_args
=
get_irg_args
(
irg
);
/* A array to save the information for each argument with
mode reference.*/
ptr_access_kind
*
rw_info
;
NEW_ARR_A
(
ptr_access_kind
,
rw_info
,
nparams
);
/* We initialize the element with none state. */
for
(
i
=
nparams
-
1
;
i
>
=
0
;
--
i
)
for
(
size_t
i
=
nparams
;
i
--
>
0
;
)
rw_info
[
i
]
=
ptr_access_none
;
/* search for arguments with mode reference
to analyze them.*/
for
(
i
=
get_irn_n_outs
(
irg_args
)
-
1
;
i
>
=
0
;
--
i
)
{
arg
=
get_irn_out
(
irg_args
,
i
);
arg_mode
=
get_irn_mode
(
arg
);
proj_nr
=
get_Proj_proj
(
arg
);
for
(
int
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
ir_mode
*
arg_mode
=
get_irn_mode
(
arg
);
long
proj_nr
=
get_Proj_proj
(
arg
);
if
(
mode_is_reference
(
arg_mode
))
rw_info
[
proj_nr
]
|=
analyze_arg
(
arg
,
rw_info
[
proj_nr
]);
...
...
@@ -219,30 +204,27 @@ static void analyze_ent_args(ir_entity *ent)
/* copy the temporary info */
memcpy
(
ent
->
attr
.
mtd_attr
.
param_access
,
rw_info
,
nparams
*
sizeof
(
ent
->
attr
.
mtd_attr
.
param_access
[
0
]));
nparams
*
sizeof
(
ent
->
attr
.
mtd_attr
.
param_access
[
0
]));
}
void
analyze_irg_args
(
ir_graph
*
irg
)
{
ir_entity
*
ent
;
if
(
irg
==
get_const_code_irg
())
return
;
ent
=
get_irg_entity
(
irg
);
if
(
!
ent
)
ir_entity
*
entity
=
get_irg_entity
(
irg
);
if
(
!
ent
ity
)
return
;
if
(
!
ent
->
attr
.
mtd_attr
.
param_access
)
analyze_ent_args
(
ent
);
if
(
!
ent
ity
->
attr
.
mtd_attr
.
param_access
)
analyze_ent_args
(
ent
ity
);
}
ptr_access_kind
get_method_param_access
(
ir_entity
*
ent
,
size_t
pos
)
{
#ifndef NDEBUG
ir_type
*
mtp
=
get_entity_type
(
ent
);
int
is_variadic
=
get_method_variadicity
(
mtp
)
==
variadicity_variadic
;
bool
is_variadic
=
get_method_variadicity
(
mtp
)
==
variadicity_variadic
;
assert
(
is_variadic
||
pos
<
get_method_n_params
(
mtp
));
#endif
...
...
@@ -278,17 +260,12 @@ enum args_weight {
*/
static
unsigned
calc_method_param_weight
(
ir_node
*
arg
)
{
int
i
,
j
,
k
;
ir_node
*
succ
,
*
op
;
unsigned
weight
=
null_weight
;
/* We mark the nodes to avoid endless recursion */
mark_irn_visited
(
arg
);
for
(
i
=
get_irn_n_outs
(
arg
)
-
1
;
i
>=
0
;
i
--
)
{
succ
=
get_irn_out
(
arg
,
i
);
/* We was here.*/
unsigned
weight
=
null_weight
;
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
if
(
irn_visited
(
succ
))
continue
;
...
...
@@ -304,9 +281,10 @@ static unsigned calc_method_param_weight(ir_node *arg)
weight
+=
indirect_call_weight
;
}
break
;
case
iro_Cmp
:
case
iro_Cmp
:
{
/* We have reached a cmp and we must increase the
weight with the cmp_weight. */
ir_node
*
op
;
if
(
get_Cmp_left
(
succ
)
==
arg
)
op
=
get_Cmp_right
(
succ
);
else
...
...
@@ -317,6 +295,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
}
else
weight
+=
cmp_weight
;
break
;
}
case
iro_Cond
:
/* the argument is used for a SwitchCond, a big win */
weight
+=
const_cmp_weight
*
get_irn_n_outs
(
succ
);
...
...
@@ -327,11 +306,11 @@ static unsigned calc_method_param_weight(ir_node *arg)
break
;
case
iro_Tuple
:
/* unoptimized tuple */
for
(
j
=
get_Tuple_n_preds
(
succ
)
-
1
;
j
>
=
0
;
--
j
)
{
for
(
int
j
=
get_Tuple_n_preds
(
succ
);
j
--
>
0
;
)
{
ir_node
*
pred
=
get_Tuple_pred
(
succ
,
j
);
if
(
pred
==
arg
)
{
/* look for Proj(j) */
for
(
k
=
get_irn_n_outs
(
succ
)
-
1
;
k
>
=
0
;
--
k
)
{
for
(
int
k
=
get_irn_n_outs
(
succ
);
k
--
>
0
;
)
{
ir_node
*
succ_succ
=
get_irn_out
(
succ
,
k
);
if
(
is_Proj
(
succ_succ
))
{
if
(
get_Proj_proj
(
succ_succ
)
==
j
)
{
...
...
@@ -352,6 +331,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
BinOp is a constant we increase the weight with const_binop_weight
and call the function recursive.
*/
ir_node
*
op
;
if
(
get_binop_left
(
succ
)
==
arg
)
op
=
get_binop_right
(
succ
);
else
...
...
@@ -383,15 +363,9 @@ static unsigned calc_method_param_weight(ir_node *arg)
*/
static
void
analyze_method_params_weight
(
ir_entity
*
ent
)
{
ir_type
*
mtp
;
ir_graph
*
irg
;
int
nparams
,
i
,
proj_nr
;
ir_node
*
irg_args
,
*
arg
;
mtp
=
get_entity_type
(
ent
);
nparams
=
get_method_n_params
(
mtp
);
/* allocate a new array. currently used as 'analysed' flag */
ir_type
*
mtp
=
get_entity_type
(
ent
);
size_t
nparams
=
get_method_n_params
(
mtp
);
ent
->
attr
.
mtd_attr
.
param_weight
=
NEW_ARR_F
(
unsigned
,
nparams
);
/* If the method haven't parameters we have nothing to do. */
...
...
@@ -399,10 +373,10 @@ static void analyze_method_params_weight(ir_entity *ent)
return
;
/* First we initialize the parameter weights with 0. */
for
(
i
=
nparams
-
1
;
i
>
=
0
;
i
--
)
for
(
size_t
i
=
nparams
;
i
--
>
0
;
)
ent
->
attr
.
mtd_attr
.
param_weight
[
i
]
=
null_weight
;
irg
=
get_entity_irg
(
ent
);
ir_graph
*
irg
=
get_entity_irg
(
ent
);
if
(
irg
==
NULL
)
{
/* no graph, no better info */
return
;
...
...
@@ -411,10 +385,10 @@ static void analyze_method_params_weight(ir_entity *ent)
/* Call algorithm that computes the out edges */
assure_irg_outs
(
irg
);
irg_args
=
get_irg_args
(
irg
);
for
(
i
=
get_irn_n_outs
(
irg_args
)
-
1
;
i
>
=
0
;
--
i
)
{
arg
=
get_irn_out
(
irg_args
,
i
);
proj_nr
=
get_Proj_proj
(
arg
);
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
);
ent
->
attr
.
mtd_attr
.
param_weight
[
proj_nr
]
+=
calc_method_param_weight
(
arg
);
}
}
...
...
ir/ana/callgraph.c
View file @
2672e202
This diff is collapsed.
Click to expand it.
ir/ana/cdep.c
View file @
2672e202
...
...
@@ -69,8 +69,10 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
ir_cdep
*
newdep
;
for
(;;)
{
if
(
get_cdep_node
(
dep
)
==
dep_on
)
return
;
if
(
dep
->
next
==
NULL
)
break
;
if
(
get_cdep_node
(
dep
)
==
dep_on
)
return
;
if
(
dep
->
next
==
NULL
)
break
;
dep
=
dep
->
next
;
}
newdep
=
OALLOC
(
&
cdep_data
->
obst
,
ir_cdep
);
...
...
@@ -86,16 +88,14 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
static
void
cdep_pre
(
ir_node
*
node
,
void
*
ctx
)
{
(
void
)
ctx
;
for
(
int
i
=
get_Block_n_cfgpreds
(
node
);
i
--
!=
0
;)
{
for
(
int
i
=
get_Block_n_cfgpreds
(
node
);
i
--
>
0
;
)
{
ir_node
*
pred
=
get_Block_cfgpred_block
(
node
,
i
);
ir_node
*
pdom
;
ir_node
*
dependee
;
if
(
is_Bad
(
pred
))
continue
;
if
(
is_Bad
(
pred
))
continue
;
pdom
=
get_Block_ipostdom
(
pred
);
for
(
dependee
=
node
;
dependee
!=
pdom
;
dependee
=
get_Block_ipostdom
(
dependee
))
{
ir_node
*
pdom
=
get_Block_ipostdom
(
pred
);
for
(
ir_node
*
dependee
=
node
;
dependee
!=
pdom
;
dependee
=
get_Block_ipostdom
(
dependee
))
{
assert
(
!
is_Bad
(
pdom
));
add_cdep
(
dependee
,
pred
);
}
...
...
@@ -108,15 +108,10 @@ static void cdep_pre(ir_node *node, void *ctx)
*/
static
int
cdep_edge_hook
(
FILE
*
F
,
ir_node
*
block
)
{
ir_cdep
*
cd
;
for
(
cd
=
find_cdep
(
block
);
cd
!=
NULL
;
cd
=
cd
->
next
)
{
fprintf
(
F
,
"edge:{sourcename:
\"
n%ld
\"
targetname:
\"
n%ld
\"
"
"linestyle:dashed color:gold}
\n
"
,
get_irn_node_nr
(
block
),
get_irn_node_nr
(
cd
->
node
)
);
for
(
ir_cdep
*
cd
=
find_cdep
(
block
);
cd
!=
NULL
;
cd
=
cd
->
next
)
{
fprintf
(
F
,
"edge:{sourcename:
\"
n%ld
\"
targetname:
\"
n%ld
\"
"
"linestyle:dashed color:gold}
\n
"
,
get_irn_node_nr
(
block
),
get_irn_node_nr
(
cd
->
node
));
}
return
0
;
...
...
@@ -162,10 +157,10 @@ void free_cdep(ir_graph *irg)
int
is_cdep_on
(
const
ir_node
*
dependee
,
const
ir_node
*
candidate
)
{
const
ir_cdep
*
dep
;
for
(
dep
=
find_cdep
(
dependee
);
dep
!=
NULL
;
dep
=
dep
->
next
)
{
if
(
get_cdep_node
(
dep
)
==
candidate
)
return
1
;
for
(
const
ir_cdep
*
dep
=
find_cdep
(
dependee
);
dep
!=
NULL
;
dep
=
dep
->
next
)
{
if
(
get_cdep_node
(
dep
)
==
candidate
)
return
1
;
}
return
0
;
}
...
...
@@ -173,13 +168,11 @@ int is_cdep_on(const ir_node *dependee, const ir_node *candidate)
ir_node
*
get_unique_cdep
(
const
ir_node
*
block
)
{
ir_cdep
*
cdep
=
find_cdep
(
block
);
return
cdep
!=
NULL
&&
cdep
->
next
==
NULL
?
get_cdep_node
(
cdep
)
:
NULL
;
}
int
has_multiple_cdep
(
const
ir_node
*
block
)
{
ir_cdep
*
cdep
=
find_cdep
(
block
);
return
cdep
!=
NULL
&&
cdep
->
next
!=
NULL
;
}
ir/ana/dfs.c
View file @
2672e202
...
...
@@ -27,19 +27,17 @@
static
int
cmp_edge
(
const
void
*
a
,
const
void
*
b
,
size_t
sz
)
{
(
void
)
sz
;
const
dfs_edge_t
*
p
=
(
const
dfs_edge_t
*
)
a
;
const
dfs_edge_t
*
q
=
(
const
dfs_edge_t
*
)
b
;
(
void
)
sz
;
return
!
(
p
->
src
==
q
->
src
&&
p
->
tgt
==
q
->
tgt
);
}
static
int
cmp_node
(
const
void
*
a
,
const
void
*
b
,
size_t
sz
)
{
(
void
)
sz
;
const
dfs_node_t
*
p
=
(
const
dfs_node_t
*
)
a
;
const
dfs_node_t
*
q
=
(
const
dfs_node_t
*
)
b
;
(
void
)
sz
;
return
p
->
node
!=
q
->
node
;
}
...
...
@@ -48,8 +46,8 @@ static int cmp_node(const void *a, const void *b, size_t sz)
static
dfs_edge_t
*
get_edge
(
const
dfs_t
*
self
,
const
void
*
src
,
const
void
*
tgt
)
{
unsigned
hash
=
hash_combine
(
hash_ptr
(
src
),
hash_ptr
(
tgt
));
dfs_edge_t
templ
;
dfs_edge_t
templ
;
templ
.
src
=
src
;
templ
.
tgt
=
tgt
;
templ
.
kind
=
(
dfs_edge_kind_t
)
-
1
;
...
...
@@ -60,10 +58,7 @@ static dfs_edge_t *get_edge(const dfs_t *self, const void *src, const void *tgt)
static
void
dfs_perform
(
dfs_t
*
dfs
,
void
*
n
,
void
*
anc
,
int
level
)
{
dfs_node_t
*
node
=
get_node
(
dfs
,
n
);
void
**
succs
,
**
iter
;
assert
(
node
->
visited
==
0
);
node
->
visited
=
1
;
node
->
node
=
n
;
node
->
ancestor
=
anc
;
...
...
@@ -73,9 +68,9 @@ static void dfs_perform(dfs_t *dfs, void *n, void *anc, int level)
dfs
->
graph_impl
->
grow_succs
(
dfs
->
graph
,
n
,
&
dfs
->
obst
);
obstack_ptr_grow
(
&
dfs
->
obst
,
NULL
);
succs
=
(
void
**
)
obstack_finish
(
&
dfs
->
obst
);
void
**
succs
=
(
void
**
)
obstack_finish
(
&
dfs
->
obst
);
for
(
iter
=
succs
;
*
iter
;
++
iter
)
{
for
(
void
**
iter
=
succs
;
*
iter
!=
NULL
;
++
iter
)
{
void
*
p
=
*
iter
;
/* get the node */
...
...
@@ -201,11 +196,7 @@ void dfs_free(dfs_t *dfs)
static
void
dfs_dump_edge
(
const
dfs_edge_t
*
edge
,
FILE
*
file
)
{
dfs_node_t
*
src
=
edge
->
s
;
dfs_node_t
*
tgt
=
edge
->
t
;
const
char
*
s
,
*
style
;
int
weight
;
const
char
*
s
;
#define XXX(e) case DFS_EDGE_ ## e: s = #e; break
switch
(
edge
->
kind
)
{
XXX
(
FWD
);
...
...
@@ -215,9 +206,11 @@ static void dfs_dump_edge(const dfs_edge_t *edge, FILE *file)
}
#undef XXX
weight
=
edge
->
kind
==
DFS_EDGE_BACK
?
1
:
1000
;
style
=
edge
->
kind
==
DFS_EDGE_BACK
?
"dashed"
:
"solid"
;
int
weight
=
edge
->
kind
==
DFS_EDGE_BACK
?
1
:
1000
;
const
char
*
style
=
edge
->
kind
==
DFS_EDGE_BACK
?
"dashed"
:
"solid"
;
dfs_node_t
*
src
=
edge
->
s
;
dfs_node_t
*
tgt
=
edge
->
t
;
ir_fprintf
(
file
,
"
\t
n%d -> n%d [label=
\"
%s
\"
,style=
\"
%s
\"
,weight=
\"
%d
\"
];
\n
"
,
src
->
pre_num
,
tgt
->
pre_num
,
s
,
style
,
weight
);
}
...
...
@@ -225,7 +218,6 @@ static int node_level_cmp(const void *a, const void *b)
{
const
dfs_node_t
*
p
=
*
(
const
dfs_node_t
**
)
a
;
const
dfs_node_t
*
q
=
*
(
const
dfs_node_t
**
)
b
;
if
(
p
->
level
==
q
->
level
)
return
p
->
pre_num
-
q
->
pre_num
;
return
p
->
level
-
q
->
level
;
...
...
@@ -234,16 +226,16 @@ static int node_level_cmp(const void *a, const void *b)
void
dfs_dump
(
const
dfs_t
*
dfs
,
FILE
*
file
)
{
dfs_node_t
**
nodes
=
XMALLOCN
(
dfs_node_t
*
,
dfs
->
pre_num
);
int
i
,
n
=
0
;
ir_fprintf
(
file
,
"digraph G {
\n
ranksep=0.5
\n
"
);
int
n
=
0
;
foreach_set
(
dfs
->
nodes
,
dfs_node_t
,
node
)
{
nodes
[
n
++
]
=
node
;
}
qsort
(
nodes
,
n
,
sizeof
(
nodes
[
0
]),
node_level_cmp
);
i
=
0
;
int
i
=
0
;
while
(
i
<
n
)
{
int
level
=
nodes
[
i
]
->
level
;
...
...
@@ -255,7 +247,7 @@ void dfs_dump(const dfs_t *dfs, FILE *file)
}
for
(
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
dfs_node_t
*
const
node
=
nodes
[
i
];
ir_fprintf
(
file
,
"
\t
n%d [label=
\"
%d
\"
]
\n
"
,
node
->
pre_num
,
get_Block_dom_tree_pre_num
((
ir_node
*
)
node
->
node
));
}
...
...
ir/ana/domfront.c
View file @
2672e202
...
...
@@ -40,7 +40,6 @@ static inline ir_node *get_idom(ir_node *bl)
*/
static
ir_node
**
compute_df
(
ir_node
*
blk
,
ir_dom_front_info_t
*
info
)
{
ir_node
*
c
;
ir_node
**
df_list
=
NEW_ARR_F
(
ir_node
*
,
0
);
/* Add local dominance frontiers */
...
...
@@ -57,12 +56,12 @@ static ir_node **compute_df(ir_node *blk, ir_dom_front_info_t *info)
* into the dominance frontiers of the children, which are not
* dominated by the given block.
*/
for
(
c
=
get_Block_dominated_first
(
blk
);
c
;
c
=
get_Block_dominated_next
(
c
))
{
size_t
i
;
for
(
ir_node
*
c
=
get_Block_dominated_first
(
blk
);
c
!=
NULL
;
c
=
get_Block_dominated_next
(
c
))
{
ir_node
**
df_c_list
=
compute_df
(
c
,
info
);
for
(
i
=
ARR_LEN
(
df_c_list
);
i
>
0
;)
{
ir_node
*
w
=
df_c_list
[
--
i
];
for
(
size_t
i
=
ARR_LEN
(
df_c_list
);
i
--
>
0
;)
{
ir_node
*
w
=
df_c_list
[
i
];
if
(
get_idom
(
w
)
!=
blk
)
ARR_APP1
(
ir_node
*
,
df_list
,
w
);
}
...
...
ir/ana/execfreq.c
View file @
2672e202
...
...
@@ -99,16 +99,15 @@ void exit_execfreq(void)
static
double
*
solve_lgs
(
gs_matrix_t
*
mat
,
double
*
x
,
int
size
)
{
double
init
=
1
.
0
/
size
;
double
dev
;
int
i
,
iter
=
0
;
/* better convergence. */
for
(
i
=
0
;
i
<
size
;
++
i
)
double
init
=
1
.
0
/
size
;
for
(
int
i
=
0
;
i
<
size
;
++
i
)
x
[
i
]
=
init
;
stat_ev_dbl
(
"execfreq_matrix_size"
,
size
);
stat_ev_tim_push
();
int
iter
=
0
;
double
dev
;
do
{
++
iter
;
dev
=
gs_matrix_gauss_seidel
(
mat
,
x
,
size
);
...
...
ir/ana/heights.c
View file @
2672e202
...
...
@@ -70,10 +70,6 @@ static void height_dump_cb(void *data, FILE *f, const ir_node *irn)
*/
static
bool
search
(
ir_heights_t
*
h
,
const
ir_node
*
curr
,
const
ir_node
*
tgt
)
{
irn_height_t
*
h_curr
;
irn_height_t
*
h_tgt
;
int
i
,
n
;
/* if the current node is the one we were looking for, we're done. */
if
(
curr
==
tgt
)
return
true
;
...
...
@@ -85,12 +81,12 @@ static bool search(ir_heights_t *h, const ir_node *curr, const ir_node *tgt)
return
false
;
/* Check, if we have already been here. Coming more often won't help :-) */
h_curr
=
maybe_get_height_data
(
h
,
curr
);
irn_height_t
*
h_curr
=
maybe_get_height_data
(
h
,
curr
);
if
(
h_curr
->
visited
>=
h
->
visited
)
return
false
;
/* If we are too deep into the DAG we won't find the target either. */
h_tgt
=
maybe_get_height_data
(
h
,
tgt
);
irn_height_t
*
h_tgt
=
maybe_get_height_data
(
h
,
tgt
);
if
(
h_curr
->
height
>
h_tgt
->
height
)
return
false
;
...
...
@@ -98,7 +94,7 @@ static bool search(ir_heights_t *h, const ir_node *curr, const ir_node *tgt)
h_curr
->
visited
=
h
->
visited
;
/* Start a search from this node. */
for
(
i
=
0
,
n
=
get_irn_ins_or_deps
(
curr
);
i
<
n
;
++
i
)
{
for
(
int
i
=
0
,
n
=
get_irn_ins_or_deps
(
curr
);
i
<
n
;
++
i
)
{
ir_node
*
op
=
get_irn_in_or_dep
(
curr
,
i
);
if
(
search
(
h
,
op
,
tgt
))
return
true
;
...
...
@@ -110,9 +106,9 @@ static bool search(ir_heights_t *h, const ir_node *curr, const ir_node *tgt)
int
heights_reachable_in_block
(
ir_heights_t
*
h
,
const
ir_node
*
n
,
const
ir_node
*
m
)
{
int
res
=
0
;
irn_height_t
*
hn
=
maybe_get_height_data
(
h
,
n
);
irn_height_t
*
hm
=
maybe_get_height_data
(
h
,
m
);
int
res
=
0
;
irn_height_t
*
hn
=
maybe_get_height_data
(
h
,
n
);
irn_height_t
*
hm
=
maybe_get_height_data
(
h
,
m
);
assert
(
get_nodes_block
(
n
)
==
get_nodes_block
(
m
));
assert
(
hn
!=
NULL
&&
hm
!=
NULL
);
...
...
@@ -170,10 +166,9 @@ static unsigned compute_height(ir_heights_t *h, ir_node *irn, const ir_node *bl)
static
unsigned
compute_heights_in_block
(
ir_node
*
bl
,
ir_heights_t
*
h
)
{
int
max_height
=
-
1
;
h
->
visited
++
;
int
max_height
=
-
1
;
foreach_out_edge
(
bl
,
edge
)
{
ir_node
*
dep
=
get_edge_src_irn
(
edge
);
int
curh
=
compute_height
(
h
,
dep
,
bl
);
...
...
@@ -200,14 +195,13 @@ static void compute_heights_in_block_walker(ir_node *block, void *data)
unsigned
get_irn_height
(
const
ir_heights_t
*
heights
,
const
ir_node
*
irn
)
{
const
irn_height_t
*
height
=
maybe_get_height_data
(
heights
,
irn
);
assert
(
height
!=
NULL
&&
"No height information for node"
);
assert
(
height
!=
NULL
);
return
height
->
height
;
}
unsigned
heights_recompute_block
(
ir_heights_t
*
h
,
ir_node
*
block
)
{
ir_graph
*
irg
=
get_irn_irg
(
block
);
assure_edges
(
irg
);
/* reset data for all nodes in the block */
...
...
ir/ana/irbackedge.c
View file @
2672e202
...
...
@@ -32,12 +32,13 @@ static bitset_t *mere_get_backarray(const ir_node *n)
{
switch
(
get_irn_opcode
(
n
))
{
case
iro_Block
:
if
(
!
get_Block_matured
(
n
))
return
NULL
;
if
(
!
get_Block_matured
(
n
))
return
NULL
;
assert
(
n
->
attr
.
block
.
backedge
&&
"backedge array not allocated!"
);
assert
(
n
->
attr
.
block
.
backedge
!=
NULL
);
return
n
->
attr
.
block
.
backedge
;
case
iro_Phi
:
assert
(
n
->
attr
.
phi
.
u
.
backedge
&&
"backedge array not allocated!"
);
assert
(
n
->
attr
.
phi
.
u
.
backedge
!=
NULL
);
return
n
->
attr
.
phi
.
u
.
backedge
;
default:
break
;
...
...
@@ -52,12 +53,11 @@ static bitset_t *mere_get_backarray(const ir_node *n)
static
bitset_t
*
get_backarray
(
const
ir_node
*
n
)
{
bitset_t
*
ba
=
mere_get_backarray
(
n
);
#ifndef NDEBUG
if
(
ba
)
{
if
(
ba
!=
NULL
)
{
size_t
bal
=
bitset_size
(
ba
);
/* avoid macro expansion in assertion. */
size_t
inl
=
get_irn_arity
(
n
);
assert
(
bal
==
inl
&&
"backedge array with faulty length"
);
assert
(
bal
==
inl
);
}
#endif
...
...
@@ -81,17 +81,14 @@ static int legal_backarray(const ir_node *n)
void
fix_backedges
(
struct
obstack
*
obst
,
ir_node
*
n
)