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 @@
...
@@ -31,16 +31,11 @@
*/
*/
static
ptr_access_kind
analyze_arg
(
ir_node
*
arg
,
ptr_access_kind
bits
)
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.*/
/* We must visit a node once to avoid endless recursion.*/
mark_irn_visited
(
arg
);
mark_irn_visited
(
arg
);
for
(
i
=
get_irn_n_outs
(
arg
)
-
1
;
i
>=
0
;
--
i
)
{
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
succ
=
get_irn_out
(
arg
,
i
);
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
/* We was here.*/
if
(
irn_visited
(
succ
))
if
(
irn_visited
(
succ
))
continue
;
continue
;
...
@@ -68,7 +63,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
...
@@ -68,7 +63,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
if
(
is_SymConst_addr_ent
(
ptr
))
{
if
(
is_SymConst_addr_ent
(
ptr
))
{
meth_ent
=
get_SymConst_entity
(
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
)
{
if
(
get_Call_param
(
succ
,
p
)
==
arg
)
{
/* an arg can be used more than once ! */
/* an arg can be used more than once ! */
bits
|=
get_method_param_access
(
meth_ent
,
p
);
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)
...
@@ -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
)
{
}
else
if
(
is_Sel
(
ptr
)
&&
get_irp_callee_info_state
()
==
irg_callee_info_consistent
)
{
/* is be a polymorphic call but callee information is available */
/* is be a polymorphic call but callee information is available */
int
n_params
=
get_Call_n_params
(
succ
);
size_t
n_params
=
get_Call_n_params
(
succ
);
int
c
;
/* simply look into ALL possible callees */
/* 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
);
meth_ent
=
get_Call_callee
(
succ
,
c
);
/* unknown_entity is used to signal that we don't know what is called */
/* 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)
...
@@ -89,7 +83,7 @@ static ptr_access_kind analyze_arg(ir_node *arg, ptr_access_kind bits)
break
;
break
;
}
}
for
(
p
=
n_params
-
1
;
p
>
=
0
;
--
p
)
{
for
(
size_t
p
=
n_params
;
p
--
>
0
;
)
{
if
(
get_Call_param
(
succ
,
p
)
==
arg
)
{
if
(
get_Call_param
(
succ
,
p
)
==
arg
)
{
/* an arg can be used more than once ! */
/* an arg can be used more than once ! */
bits
|=
get_method_param_access
(
meth_ent
,
p
);
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)
...
@@ -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
)
static
void
analyze_ent_args
(
ir_entity
*
ent
)
{
{
ir_graph
*
irg
;
ir_type
*
mtp
=
get_entity_type
(
ent
);
ir_node
*
irg_args
,
*
arg
;
size_t
nparams
=
get_method_n_params
(
mtp
);
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
);
ent
->
attr
.
mtd_attr
.
param_access
=
NEW_ARR_F
(
ptr_access_kind
,
nparams
);
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)
...
@@ -181,37 +167,36 @@ static void analyze_ent_args(ir_entity *ent)
if
(
nparams
<=
0
)
if
(
nparams
<=
0
)
return
;
return
;
irg
=
get_entity_irg
(
ent
);
/* we have not yet analyzed the graph, set ALL access for pointer args */
/* 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
);
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
;
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 */
/* no graph, no better info */
return
;
return
;
}
}
assure_irg_outs
(
irg
);
assure_irg_outs
(
irg
);
ir_node
*
irg_args
=
get_irg_args
(
irg
);
irg_args
=
get_irg_args
(
irg
);
/* A array to save the information for each argument with
/* A array to save the information for each argument with
mode reference.*/
mode reference.*/
ptr_access_kind
*
rw_info
;
NEW_ARR_A
(
ptr_access_kind
,
rw_info
,
nparams
);
NEW_ARR_A
(
ptr_access_kind
,
rw_info
,
nparams
);
/* We initialize the element with none state. */
/* 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
;
rw_info
[
i
]
=
ptr_access_none
;
/* search for arguments with mode reference
/* search for arguments with mode reference
to analyze them.*/
to analyze them.*/
for
(
i
=
get_irn_n_outs
(
irg_args
)
-
1
;
i
>
=
0
;
--
i
)
{
for
(
int
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
arg
=
get_irn_out
(
irg_args
,
i
);
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
arg_mode
=
get_irn_mode
(
arg
);
ir_mode
*
arg_mode
=
get_irn_mode
(
arg
);
proj_nr
=
get_Proj_proj
(
arg
);
long
proj_nr
=
get_Proj_proj
(
arg
);
if
(
mode_is_reference
(
arg_mode
))
if
(
mode_is_reference
(
arg_mode
))
rw_info
[
proj_nr
]
|=
analyze_arg
(
arg
,
rw_info
[
proj_nr
]);
rw_info
[
proj_nr
]
|=
analyze_arg
(
arg
,
rw_info
[
proj_nr
]);
...
@@ -219,30 +204,27 @@ static void analyze_ent_args(ir_entity *ent)
...
@@ -219,30 +204,27 @@ static void analyze_ent_args(ir_entity *ent)
/* copy the temporary info */
/* copy the temporary info */
memcpy
(
ent
->
attr
.
mtd_attr
.
param_access
,
rw_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
)
void
analyze_irg_args
(
ir_graph
*
irg
)
{
{
ir_entity
*
ent
;
if
(
irg
==
get_const_code_irg
())
if
(
irg
==
get_const_code_irg
())
return
;
return
;
ent
=
get_irg_entity
(
irg
);
ir_entity
*
entity
=
get_irg_entity
(
irg
);
if
(
!
ent
)
if
(
!
ent
ity
)
return
;
return
;
if
(
!
ent
->
attr
.
mtd_attr
.
param_access
)
if
(
!
ent
ity
->
attr
.
mtd_attr
.
param_access
)
analyze_ent_args
(
ent
);
analyze_ent_args
(
ent
ity
);
}
}
ptr_access_kind
get_method_param_access
(
ir_entity
*
ent
,
size_t
pos
)
ptr_access_kind
get_method_param_access
(
ir_entity
*
ent
,
size_t
pos
)
{
{
#ifndef NDEBUG
#ifndef NDEBUG
ir_type
*
mtp
=
get_entity_type
(
ent
);
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
));
assert
(
is_variadic
||
pos
<
get_method_n_params
(
mtp
));
#endif
#endif
...
@@ -278,17 +260,12 @@ enum args_weight {
...
@@ -278,17 +260,12 @@ enum args_weight {
*/
*/
static
unsigned
calc_method_param_weight
(
ir_node
*
arg
)
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 */
/* We mark the nodes to avoid endless recursion */
mark_irn_visited
(
arg
);
mark_irn_visited
(
arg
);
for
(
i
=
get_irn_n_outs
(
arg
)
-
1
;
i
>=
0
;
i
--
)
{
unsigned
weight
=
null_weight
;
succ
=
get_irn_out
(
arg
,
i
);
for
(
int
i
=
get_irn_n_outs
(
arg
);
i
--
>
0
;
)
{
ir_node
*
succ
=
get_irn_out
(
arg
,
i
);
/* We was here.*/
if
(
irn_visited
(
succ
))
if
(
irn_visited
(
succ
))
continue
;
continue
;
...
@@ -304,9 +281,10 @@ static unsigned calc_method_param_weight(ir_node *arg)
...
@@ -304,9 +281,10 @@ static unsigned calc_method_param_weight(ir_node *arg)
weight
+=
indirect_call_weight
;
weight
+=
indirect_call_weight
;
}
}
break
;
break
;
case
iro_Cmp
:
case
iro_Cmp
:
{
/* We have reached a cmp and we must increase the
/* We have reached a cmp and we must increase the
weight with the cmp_weight. */
weight with the cmp_weight. */
ir_node
*
op
;
if
(
get_Cmp_left
(
succ
)
==
arg
)
if
(
get_Cmp_left
(
succ
)
==
arg
)
op
=
get_Cmp_right
(
succ
);
op
=
get_Cmp_right
(
succ
);
else
else
...
@@ -317,6 +295,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
...
@@ -317,6 +295,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
}
else
}
else
weight
+=
cmp_weight
;
weight
+=
cmp_weight
;
break
;
break
;
}
case
iro_Cond
:
case
iro_Cond
:
/* the argument is used for a SwitchCond, a big win */
/* the argument is used for a SwitchCond, a big win */
weight
+=
const_cmp_weight
*
get_irn_n_outs
(
succ
);
weight
+=
const_cmp_weight
*
get_irn_n_outs
(
succ
);
...
@@ -327,11 +306,11 @@ static unsigned calc_method_param_weight(ir_node *arg)
...
@@ -327,11 +306,11 @@ static unsigned calc_method_param_weight(ir_node *arg)
break
;
break
;
case
iro_Tuple
:
case
iro_Tuple
:
/* unoptimized 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
);
ir_node
*
pred
=
get_Tuple_pred
(
succ
,
j
);
if
(
pred
==
arg
)
{
if
(
pred
==
arg
)
{
/* look for Proj(j) */
/* 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
);
ir_node
*
succ_succ
=
get_irn_out
(
succ
,
k
);
if
(
is_Proj
(
succ_succ
))
{
if
(
is_Proj
(
succ_succ
))
{
if
(
get_Proj_proj
(
succ_succ
)
==
j
)
{
if
(
get_Proj_proj
(
succ_succ
)
==
j
)
{
...
@@ -352,6 +331,7 @@ static unsigned calc_method_param_weight(ir_node *arg)
...
@@ -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
BinOp is a constant we increase the weight with const_binop_weight
and call the function recursive.
and call the function recursive.
*/
*/
ir_node
*
op
;
if
(
get_binop_left
(
succ
)
==
arg
)
if
(
get_binop_left
(
succ
)
==
arg
)
op
=
get_binop_right
(
succ
);
op
=
get_binop_right
(
succ
);
else
else
...
@@ -383,15 +363,9 @@ static unsigned calc_method_param_weight(ir_node *arg)
...
@@ -383,15 +363,9 @@ static unsigned calc_method_param_weight(ir_node *arg)
*/
*/
static
void
analyze_method_params_weight
(
ir_entity
*
ent
)
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 */
/* 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
);
ent
->
attr
.
mtd_attr
.
param_weight
=
NEW_ARR_F
(
unsigned
,
nparams
);
/* If the method haven't parameters we have nothing to do. */
/* If the method haven't parameters we have nothing to do. */
...
@@ -399,10 +373,10 @@ static void analyze_method_params_weight(ir_entity *ent)
...
@@ -399,10 +373,10 @@ static void analyze_method_params_weight(ir_entity *ent)
return
;
return
;
/* First we initialize the parameter weights with 0. */
/* 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
;
ent
->
attr
.
mtd_attr
.
param_weight
[
i
]
=
null_weight
;
irg
=
get_entity_irg
(
ent
);
ir_graph
*
irg
=
get_entity_irg
(
ent
);
if
(
irg
==
NULL
)
{
if
(
irg
==
NULL
)
{
/* no graph, no better info */
/* no graph, no better info */
return
;
return
;
...
@@ -411,10 +385,10 @@ static void analyze_method_params_weight(ir_entity *ent)
...
@@ -411,10 +385,10 @@ static void analyze_method_params_weight(ir_entity *ent)
/* Call algorithm that computes the out edges */
/* Call algorithm that computes the out edges */
assure_irg_outs
(
irg
);
assure_irg_outs
(
irg
);
irg_args
=
get_irg_args
(
irg
);
ir_node
*
irg_args
=
get_irg_args
(
irg
);
for
(
i
=
get_irn_n_outs
(
irg_args
)
-
1
;
i
>
=
0
;
--
i
)
{
for
(
int
i
=
get_irn_n_outs
(
irg_args
);
i
--
>
0
;
)
{
arg
=
get_irn_out
(
irg_args
,
i
);
ir_node
*
arg
=
get_irn_out
(
irg_args
,
i
);
proj_nr
=
get_Proj_proj
(
arg
);
long
proj_nr
=
get_Proj_proj
(
arg
);
ent
->
attr
.
mtd_attr
.
param_weight
[
proj_nr
]
+=
calc_method_param_weight
(
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)
...
@@ -69,8 +69,10 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
ir_cdep
*
newdep
;
ir_cdep
*
newdep
;
for
(;;)
{
for
(;;)
{
if
(
get_cdep_node
(
dep
)
==
dep_on
)
return
;
if
(
get_cdep_node
(
dep
)
==
dep_on
)
if
(
dep
->
next
==
NULL
)
break
;
return
;
if
(
dep
->
next
==
NULL
)
break
;
dep
=
dep
->
next
;
dep
=
dep
->
next
;
}
}
newdep
=
OALLOC
(
&
cdep_data
->
obst
,
ir_cdep
);
newdep
=
OALLOC
(
&
cdep_data
->
obst
,
ir_cdep
);
...
@@ -86,16 +88,14 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
...
@@ -86,16 +88,14 @@ static void add_cdep(ir_node *node, ir_node *dep_on)
static
void
cdep_pre
(
ir_node
*
node
,
void
*
ctx
)
static
void
cdep_pre
(
ir_node
*
node
,
void
*
ctx
)
{
{
(
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
*
pred
=
get_Block_cfgpred_block
(
node
,
i
);
ir_node
*
pdom
;
if
(
is_Bad
(
pred
))
ir_node
*
dependee
;
continue
;
if
(
is_Bad
(
pred
))
continue
;
pdom
=
get_Block_ipostdom
(
pred
);
ir_node
*
pdom
=
get_Block_ipostdom
(
pred
);
for
(
dependee
=
node
;
dependee
!=
pdom
;
dependee
=
get_Block_ipostdom
(
dependee
))
{
for
(
ir_node
*
dependee
=
node
;
dependee
!=
pdom
;
dependee
=
get_Block_ipostdom
(
dependee
))
{
assert
(
!
is_Bad
(
pdom
));
assert
(
!
is_Bad
(
pdom
));
add_cdep
(
dependee
,
pred
);
add_cdep
(
dependee
,
pred
);
}
}
...
@@ -108,15 +108,10 @@ static void cdep_pre(ir_node *node, void *ctx)
...
@@ -108,15 +108,10 @@ static void cdep_pre(ir_node *node, void *ctx)
*/
*/
static
int
cdep_edge_hook
(
FILE
*
F
,
ir_node
*
block
)
static
int
cdep_edge_hook
(
FILE
*
F
,
ir_node
*
block
)
{
{
ir_cdep
*
cd
;
for
(
ir_cdep
*
cd
=
find_cdep
(
block
);
cd
!=
NULL
;
cd
=
cd
->
next
)
{
fprintf
(
F
,
"edge:{sourcename:
\"
n%ld
\"
targetname:
\"
n%ld
\"
"
for
(
cd
=
find_cdep
(
block
);
cd
!=
NULL
;
cd
=
cd
->
next
)
{
"linestyle:dashed color:gold}
\n
"
,
fprintf
(
get_irn_node_nr
(
block
),
get_irn_node_nr
(
cd
->
node
));
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
;
return
0
;
...
@@ -162,10 +157,10 @@ void free_cdep(ir_graph *irg)
...
@@ -162,10 +157,10 @@ void free_cdep(ir_graph *irg)
int
is_cdep_on
(
const
ir_node
*
dependee
,
const
ir_node
*
candidate
)
int
is_cdep_on
(
const
ir_node
*
dependee
,
const
ir_node
*
candidate
)
{
{
const
ir_cdep
*
dep
;
for
(
const
ir_cdep
*
dep
=
find_cdep
(
dependee
);
dep
!=
NULL
;
dep
=
dep
->
next
)
{
for
(
dep
=
find_cdep
(
dependee
);
dep
!=
NULL
;
dep
=
dep
->
next
)
{
if
(
get_cdep_node
(
dep
)
==
candidate
)
if
(
get_cdep_node
(
dep
)
==
candidate
)
return
1
;
return
1
;
}
}
return
0
;
return
0
;
}
}
...
@@ -173,13 +168,11 @@ int is_cdep_on(const ir_node *dependee, const ir_node *candidate)
...
@@ -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_node
*
get_unique_cdep
(
const
ir_node
*
block
)
{
{
ir_cdep
*
cdep
=
find_cdep
(
block
);
ir_cdep
*
cdep
=
find_cdep
(
block
);
return
cdep
!=
NULL
&&
cdep
->
next
==
NULL
?
get_cdep_node
(
cdep
)
:
NULL
;
return
cdep
!=
NULL
&&
cdep
->
next
==
NULL
?
get_cdep_node
(
cdep
)
:
NULL
;
}
}
int
has_multiple_cdep
(
const
ir_node
*
block
)
int
has_multiple_cdep
(
const
ir_node
*
block
)
{
{
ir_cdep
*
cdep
=
find_cdep
(
block
);
ir_cdep
*
cdep
=
find_cdep
(
block
);
return
cdep
!=
NULL
&&
cdep
->
next
!=
NULL
;
return
cdep
!=
NULL
&&
cdep
->
next
!=
NULL
;
}
}
ir/ana/dfs.c
View file @
2672e202
...
@@ -27,19 +27,17 @@
...
@@ -27,19 +27,17 @@
static
int
cmp_edge
(
const
void
*
a
,
const
void
*
b
,
size_t
sz
)
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
*
p
=
(
const
dfs_edge_t
*
)
a
;
const
dfs_edge_t
*
q
=
(
const
dfs_edge_t
*
)
b
;
const
dfs_edge_t
*
q
=
(
const
dfs_edge_t
*
)
b
;
(
void
)
sz
;
return
!
(
p
->
src
==
q
->
src
&&
p
->
tgt
==
q
->
tgt
);
return
!
(
p
->
src
==
q
->
src
&&
p
->
tgt
==
q
->
tgt
);
}
}
static
int
cmp_node
(
const
void
*
a
,
const
void
*
b
,
size_t
sz
)
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
*
p
=
(
const
dfs_node_t
*
)
a
;
const
dfs_node_t
*
q
=
(
const
dfs_node_t
*
)
b
;
const
dfs_node_t
*
q
=
(
const
dfs_node_t
*
)
b
;
(
void
)
sz
;
return
p
->
node
!=
q
->
node
;
return
p
->
node
!=
q
->
node
;
}
}
...
@@ -48,8 +46,8 @@ static int cmp_node(const void *a, const void *b, size_t sz)
...
@@ -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
)
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
));
unsigned
hash
=
hash_combine
(
hash_ptr
(
src
),
hash_ptr
(
tgt
));
dfs_edge_t
templ
;
dfs_edge_t
templ
;
templ
.
src
=
src
;
templ
.
src
=
src
;
templ
.
tgt
=
tgt
;
templ
.
tgt
=
tgt
;
templ
.
kind
=
(
dfs_edge_kind_t
)
-
1
;
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)
...
@@ -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
)
static
void
dfs_perform
(
dfs_t
*
dfs
,
void
*
n
,
void
*
anc
,
int
level
)
{
{
dfs_node_t
*
node
=
get_node
(
dfs
,
n
);
dfs_node_t
*
node
=
get_node
(
dfs
,
n
);
void
**
succs
,
**
iter
;
assert
(
node
->
visited
==
0
);
assert
(
node
->
visited
==
0
);
node
->
visited
=
1
;
node
->
visited
=
1
;
node
->
node
=
n
;
node
->
node
=
n
;
node
->
ancestor
=
anc
;
node
->
ancestor
=
anc
;
...
@@ -73,9 +68,9 @@ static void dfs_perform(dfs_t *dfs, void *n, void *anc, int level)
...
@@ -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
);
dfs
->
graph_impl
->
grow_succs
(
dfs
->
graph
,
n
,
&
dfs
->
obst
);
obstack_ptr_grow
(
&
dfs
->
obst
,
NULL
);
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
;
void
*
p
=
*
iter
;
/* get the node */
/* get the node */
...
@@ -201,11 +196,7 @@ void dfs_free(dfs_t *dfs)
...
@@ -201,11 +196,7 @@ void dfs_free(dfs_t *dfs)
static
void
dfs_dump_edge
(
const
dfs_edge_t
*
edge
,
FILE
*
file
)
static
void
dfs_dump_edge
(
const
dfs_edge_t
*
edge
,
FILE
*
file
)
{
{
dfs_node_t
*
src
=
edge
->
s
;
const
char
*
s
;
dfs_node_t
*
tgt
=
edge
->
t
;
const
char
*
s
,
*
style
;
int
weight
;
#define XXX(e) case DFS_EDGE_ ## e: s = #e; break
#define XXX(e) case DFS_EDGE_ ## e: s = #e; break
switch
(
edge
->
kind
)
{
switch
(
edge
->
kind
)
{
XXX
(
FWD
);
XXX
(
FWD
);
...
@@ -215,9 +206,11 @@ static void dfs_dump_edge(const dfs_edge_t *edge, FILE *file)
...
@@ -215,9 +206,11 @@ static void dfs_dump_edge(const dfs_edge_t *edge, FILE *file)
}
}
#undef XXX
#undef XXX
weight
=
edge
->
kind
==
DFS_EDGE_BACK
?
1
:
1000
;
int
weight
=
edge
->
kind
==
DFS_EDGE_BACK
?
1
:
1000
;
style
=
edge
->
kind
==
DFS_EDGE_BACK
?
"dashed"
:
"solid"
;
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
);
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)
...
@@ -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
*
p
=
*
(
const
dfs_node_t
**
)
a
;
const
dfs_node_t
*
q
=
*
(
const
dfs_node_t
**
)
b
;
const
dfs_node_t
*
q
=
*
(
const
dfs_node_t
**
)
b
;
if
(
p
->
level
==
q
->
level
)
if
(
p
->
level
==
q
->
level
)
return
p
->
pre_num
-
q
->
pre_num
;
return
p
->
pre_num
-
q
->
pre_num
;
return
p
->
level
-
q
->
level
;
return
p
->
level
-
q
->
level
;
...
@@ -234,16 +226,16 @@ static int node_level_cmp(const void *a, const void *b)
...
@@ -234,16 +226,16 @@ static int node_level_cmp(const void *a, const void *b)