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
3bd57592
Commit
3bd57592
authored
Sep 18, 2008
by
Michael Beck
Browse files
- simplify the code, check atomic entities for reinterpret casts
[r22100]
parent
1e7ccff0
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/opt/ldstopt.c
View file @
3bd57592
...
@@ -1071,6 +1071,7 @@ static unsigned optimize_load(ir_node *load)
...
@@ -1071,6 +1071,7 @@ static unsigned optimize_load(ir_node *load)
}
}
if
(
variability_constant
==
get_entity_variability
(
ent
))
{
if
(
variability_constant
==
get_entity_variability
(
ent
))
{
ir_node
*
c
=
NULL
;
if
(
is_atomic_entity
(
ent
))
{
if
(
is_atomic_entity
(
ent
))
{
/* Might not be atomic after
/* Might not be atomic after
lowering of Sels. In this
lowering of Sels. In this
...
@@ -1079,27 +1080,8 @@ static unsigned optimize_load(ir_node *load)
...
@@ -1079,27 +1080,8 @@ static unsigned optimize_load(ir_node *load)
/* more simpler case: we load the content of a constant value:
/* more simpler case: we load the content of a constant value:
* replace it by the constant itself
* replace it by the constant itself
*/
*/
c
=
get_atomic_ent_value
(
ent
);
/* no memory */
if
(
info
->
projs
[
pn_Load_M
])
{
exchange
(
info
->
projs
[
pn_Load_M
],
mem
);
res
|=
DF_CHANGED
;
}
/* no result :-) */
if
(
info
->
projs
[
pn_Load_res
])
{
if
(
is_atomic_entity
(
ent
))
{
ir_node
*
c
=
copy_const_value
(
get_irn_dbg_info
(
load
),
get_atomic_ent_value
(
ent
));
DBG_OPT_RC
(
load
,
c
);
exchange
(
info
->
projs
[
pn_Load_res
],
c
);
res
|=
DF_CHANGED
;
}
}
kill_node
(
load
);
reduce_adr_usage
(
ptr
);
return
res
;
}
else
{
}
else
{
ir_node
*
c
=
NULL
;
if
(
ent
->
has_initializer
)
{
if
(
ent
->
has_initializer
)
{
/* new style initializer */
/* new style initializer */
c
=
find_compound_ent_value
(
ptr
);
c
=
find_compound_ent_value
(
ptr
);
...
@@ -1114,51 +1096,42 @@ static unsigned optimize_load(ir_node *load)
...
@@ -1114,51 +1096,42 @@ static unsigned optimize_load(ir_node *load)
free_compound_graph_path
(
path
);
free_compound_graph_path
(
path
);
}
}
}
}
if
(
c
!=
NULL
)
{
}
/* check, if the mode matches OR can be easily converted info */
if
(
c
!=
NULL
)
{
ir_mode
*
c_mode
=
get_irn_mode
(
c
);
/* check, if the mode matches OR can be easily converted info */
ir_mode
*
l_mode
=
get_Load_mode
(
load
);
ir_mode
*
c_mode
=
get_irn_mode
(
c
);
ir_mode
*
l_mode
=
get_Load_mode
(
load
);
if
(
c_mode
!=
l_mode
)
{
if
(
is_reinterpret_cast
(
c_mode
,
l_mode
))
{
if
(
c_mode
!=
l_mode
)
{
/* we can safely cast */
if
(
is_reinterpret_cast
(
c_mode
,
l_mode
))
{
dbg_info
*
dbg
=
get_irn_dbg_info
(
load
);
/* we can safely cast */
ir_node
*
block
=
get_nodes_block
(
load
);
dbg_info
*
dbg
=
get_irn_dbg_info
(
load
);
ir_node
*
block
=
get_nodes_block
(
load
);
/* copy the value from the const code irg and cast it */
c
=
copy_const_value
(
dbg
,
c
);
/* copy the value from the const code irg and cast it */
c
=
new_rd_Conv
(
dbg
,
current_ir_graph
,
block
,
c
,
l_mode
);
c
=
copy_const_value
(
dbg
,
c
);
}
else
{
c
=
new_rd_Conv
(
dbg
,
current_ir_graph
,
block
,
c
,
l_mode
);
/* must be some operation */
c
=
NULL
;
}
}
else
{
}
else
{
/*
copy the value from the const code irg
*/
/*
must be some operation
*/
c
=
copy_const_value
(
get_irn_dbg_info
(
load
),
c
)
;
c
=
NULL
;
}
}
}
if
(
c
!=
NULL
)
{
if
(
info
->
projs
[
pn_Load_M
])
{
exchange
(
info
->
projs
[
pn_Load_M
],
mem
);
res
|=
DF_CHANGED
;
}
if
(
info
->
projs
[
pn_Load_res
])
{
exchange
(
info
->
projs
[
pn_Load_res
],
c
);
res
|=
DF_CHANGED
;
}
kill_node
(
load
);
reduce_adr_usage
(
ptr
);
return
res
;
}
else
{
}
else
{
/*
We can not determine a correct access path. E.g., in jack, we load
/*
copy the value from the const code irg */
a byte from an object to generate an exception. Happens in test program
c
=
copy_const_value
(
get_irn_dbg_info
(
load
),
c
);
Reflectiontest.
}
printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent),
}
get_entity_name(get_irg_entity(current_ir_graph)));
if
(
c
!=
NULL
)
{
ir_printf(" load: %+F\n", load);
if
(
info
->
projs
[
pn_Load_M
])
{
ir_printf(" ptr: %+F\n", ptr
);
exchange
(
info
->
projs
[
pn_Load_M
],
mem
);
*/
res
|=
DF_CHANGED
;
}
}
if
(
info
->
projs
[
pn_Load_res
])
{
exchange
(
info
->
projs
[
pn_Load_res
],
c
);
res
|=
DF_CHANGED
;
}
kill_node
(
load
);
reduce_adr_usage
(
ptr
);
return
res
;
}
}
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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