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
dba012ef
Commit
dba012ef
authored
Feb 13, 2014
by
yb9976
Browse files
Use node map to access bit information.
parent
5adc0bfe
Changes
5
Hide whitespace changes
Inline
Side-by-side
ir/ana/constbits.c
View file @
dba012ef
...
...
@@ -22,6 +22,7 @@
#include
"irgraph_t.h"
#include
"irgwalk.h"
#include
"irnode_t.h"
#include
"irnodemap.h"
#include
"iroptimize.h"
#include
"tv.h"
#include
"irmemory.h"
...
...
@@ -111,17 +112,24 @@ static bool is_undefined(bitinfo const* const b)
return
tarval_is_null
(
b
->
z
)
&&
tarval_is_all_one
(
b
->
o
);
}
inline
bitinfo
*
get_bitinfo
(
ir_node
const
*
const
irn
)
bitinfo
*
get_bitinfo
(
ir_node
const
*
const
irn
)
{
return
(
bitinfo
*
)
get_irn_link
(
irn
);
ir_graph
*
const
irg
=
get_irn_irg
(
irn
);
ir_nodemap
*
const
map
=
&
irg
->
bitinfo
.
map
;
if
(
map
->
data
==
NULL
)
return
NULL
;
return
ir_nodemap_get
(
bitinfo
,
map
,
irn
);
}
int
set_bitinfo
(
ir_node
*
const
irn
,
ir_tarval
*
const
z
,
ir_tarval
*
const
o
)
{
bitinfo
*
b
=
get_bitinfo
(
irn
);
if
(
b
==
NULL
)
{
ir_graph
*
const
irg
=
get_irn_irg
(
irn
);
ir_nodemap
*
const
map
=
&
irg
->
bitinfo
.
map
;
b
=
OALLOCZ
(
obst
,
bitinfo
);
set_irn_link
(
irn
,
b
);
ir_nodemap_insert
(
map
,
irn
,
b
);
}
else
if
(
z
==
b
->
z
&&
o
==
b
->
o
)
{
return
0
;
}
else
{
...
...
@@ -613,10 +621,9 @@ static void queue_users(pdeq* const q, ir_node* const n)
}
}
static
void
clear_
link
s
(
ir_node
*
irn
,
void
*
env
)
static
void
clear_
phi_list
s
(
ir_node
*
irn
,
void
*
env
)
{
(
void
)
env
;
set_irn_link
(
irn
,
NULL
);
if
(
is_Block
(
irn
))
set_Block_phis
(
irn
,
NULL
);
}
...
...
@@ -631,12 +638,11 @@ static void build_phi_lists(ir_node *irn, void *env)
void
constbits_analyze
(
ir_graph
*
const
irg
,
struct
obstack
*
client_obst
)
{
obst
=
client_obst
;
ir_nodemap_init
(
&
irg
->
bitinfo
.
map
,
irg
);
FIRM_DBG_REGISTER
(
dbg
,
"firm.ana.fp-vrp"
);
DB
((
dbg
,
LEVEL_1
,
"===> Performing constant propagation on %+F (analysis)
\n
"
,
irg
));
assert
(((
ir_resources_reserved
(
irg
)
&
IR_RESOURCE_IRN_LINK
)
!=
0
)
&&
"user of fp-vrp analysis must reserve links"
);
assert
(((
ir_resources_reserved
(
irg
)
&
IR_RESOURCE_PHI_LIST
)
!=
0
)
&&
"user of fp-vrp analysis must reserve phi list"
);
...
...
@@ -645,7 +651,7 @@ void constbits_analyze(ir_graph* const irg, struct obstack *client_obst)
/* We need this extra step because the dom tree does not contain
* unreachable blocks in Firm. Moreover build phi list. */
irg_walk_anchors
(
irg
,
clear_
link
s
,
build_phi_lists
,
NULL
);
irg_walk_anchors
(
irg
,
clear_
phi_list
s
,
build_phi_lists
,
NULL
);
{
ir_tarval
*
const
f
=
get_tarval_b_false
();
...
...
@@ -666,3 +672,8 @@ void constbits_analyze(ir_graph* const irg, struct obstack *client_obst)
del_pdeq
(
q
);
}
}
void
constbits_clear
(
ir_graph
*
const
irg
)
{
ir_nodemap_destroy
(
&
irg
->
bitinfo
.
map
);
}
ir/ana/constbits.h
View file @
dba012ef
...
...
@@ -20,4 +20,10 @@ int set_bitinfo(ir_node* const irn, ir_tarval* const z, ir_tarval* const o);
* The result is available via links to bitinfo*, allocated on client_obst. */
void
constbits_analyze
(
ir_graph
*
const
irg
,
struct
obstack
*
client_obst
);
/* Clears the bit information for the given graph.
*
* This does not affect the obstack passed to constbits_analyze.
*/
void
constbits_clear
(
ir_graph
*
const
irg
);
#endif
ir/ir/irtypes.h
View file @
dba012ef
...
...
@@ -472,6 +472,11 @@ typedef struct cg_callee_entry {
size_t
max_depth
;
/**< Maximum depth of all Call nodes to irg. */
}
cg_callee_entry
;
typedef
struct
ir_bitinfo
{
struct
ir_nodemap
map
;
struct
obstack
obst
;
}
ir_bitinfo
;
typedef
struct
ir_vrp_info
{
struct
ir_nodemap
infos
;
struct
obstack
obst
;
...
...
@@ -524,6 +529,7 @@ struct ir_graph {
pset
*
value_table
;
struct
obstack
out_obst
;
/**< Space for the Def-Use arrays. */
bool
out_obst_allocated
;
ir_bitinfo
bitinfo
;
/**< bit info */
ir_vrp_info
vrp
;
/**< vrp info */
ir_loop
*
loop
;
/**< The outermost loop for this graph. */
ir_dom_front_info_t
domfront
;
/**< dominance frontier analysis data */
...
...
ir/opt/fp-vrp.c
View file @
dba012ef
...
...
@@ -311,6 +311,7 @@ void fixpoint_vrp(ir_graph* const irg)
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
|
IR_RESOURCE_PHI_LIST
);
constbits_clear
(
irg
);
obstack_free
(
&
private_obst
,
NULL
);
confirm_irg_properties
(
irg
,
...
...
ir/opt/occult_const.c
View file @
dba012ef
...
...
@@ -105,6 +105,7 @@ void occult_consts(ir_graph *irg)
ir_nodemap_destroy
(
&
env
.
dca
);
ir_nodemap_destroy
(
&
env
.
vrp
);
constbits_clear
(
irg
);
obstack_free
(
&
env
.
obst
,
NULL
);
confirm_irg_properties
(
irg
,
env
.
changed
?
IR_GRAPH_PROPERTIES_NONE
:
IR_GRAPH_PROPERTIES_ALL
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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