#include "iredges_t.h"
#include "irgwalk.h"
-#include "irprintf_t.h"
+#include "irprintf.h"
#include "irdump_t.h"
#include "irnodeset.h"
#include "belive_t.h"
#include "besched.h"
#include "bemodule.h"
-#include "bedump.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
#define LV_STD_SIZE 64
-/**
- * Filter out some nodes for which we never need liveness.
- *
- * @param irn the node t check
- * @return 0 if no liveness info is needed, 1 else
- */
-static inline int is_liveness_node(const ir_node *irn)
-{
- switch (get_irn_opcode(irn)) {
- case iro_Block:
- case iro_Bad:
- case iro_End:
- case iro_Anchor:
- case iro_NoMem:
- return 0;
- default:
- return 1;
- }
-}
-
int (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn)
{
return _be_is_live_xxx(lv, block, irn, be_lv_state_in);
return _be_is_live_xxx(lv, block, irn, be_lv_state_end);
}
-static inline unsigned _be_liveness_bsearch(be_lv_info_t *arr, unsigned idx)
+static inline unsigned _be_liveness_bsearch(be_lv_info_t *arr, const ir_node *node)
{
be_lv_info_t *payload = arr + 1;
return 0;
do {
- int md = lo + ((hi - lo) >> 1);
- unsigned md_idx = payload[md].node.idx;
+ int md = lo + ((hi - lo) >> 1);
+ ir_node *md_node = payload[md].node.node;
- if (idx > md_idx)
+ if (node > md_node)
lo = md + 1;
- else if (idx < md_idx)
+ else if (node < md_node)
hi = md;
else {
res = md;
- assert(payload[res].node.idx == idx);
break;
}
stat_ev_tim_push();
irn_live = ir_nodehashmap_get(be_lv_info_t, &li->map, bl);
if (irn_live != NULL) {
- unsigned idx = get_irn_idx(irn);
-
/* Get the position of the index in the array. */
- int pos = _be_liveness_bsearch(irn_live, idx);
+ int pos = _be_liveness_bsearch(irn_live, irn);
/* Get the record in question. 1 must be added, since the first record contains information about the array and must be skipped. */
be_lv_info_node_t *rec = &irn_live[pos + 1].node;
/* Check, if the irn is in deed in the array. */
- if (rec->idx == idx)
+ if (rec->node == irn)
res = rec;
}
stat_ev_tim_pop("be_lv_get");
ir_nodehashmap_insert(&li->map, bl, irn_live);
}
- unsigned idx = get_irn_idx(irn);
-
/* Get the position of the index in the array. */
- unsigned pos = _be_liveness_bsearch(irn_live, idx);
+ unsigned pos = _be_liveness_bsearch(irn_live, irn);
/* Get the record in question. 1 must be added, since the first record contains information about the array and must be skipped. */
be_lv_info_node_t *res = &irn_live[pos + 1].node;
/* Check, if the irn is in deed in the array. */
- if (res->idx != idx) {
+ if (res->node != irn) {
be_lv_info_t *payload;
unsigned n_members = irn_live[0].head.n_members;
unsigned n_size = irn_live[0].head.n_size;
++irn_live[0].head.n_members;
- res = &payload[pos].node;
- res->idx = idx;
- res->flags = 0;
+ res = &payload[pos].node;
+ res->node = irn;
+ res->flags = 0;
}
return res;
if (irn_live != NULL) {
unsigned n = irn_live[0].head.n_members;
- unsigned idx = get_irn_idx(irn);
- unsigned pos = _be_liveness_bsearch(irn_live, idx);
+ unsigned pos = _be_liveness_bsearch(irn_live, irn);
be_lv_info_t *payload = irn_live + 1;
be_lv_info_node_t *res = &payload[pos].node;
/* The node is in deed in the block's array. Let's remove it. */
- if (res->idx == idx) {
+ if (res->node == irn) {
unsigned i;
for (i = pos + 1; i < n; ++i)
payload[i - 1] = payload[i];
- payload[n - 1].node.idx = 0;
+ payload[n - 1].node.node = NULL;
payload[n - 1].node.flags = 0;
--irn_live[0].head.n_members;
DEL_ARR_F(nodes);
free(re.visited);
- register_hook(hook_node_info, &lv->hook_info);
be_timer_pop(T_LIVE);
{
if (!lv->sets_valid)
return;
- unregister_hook(hook_node_info, &lv->hook_info);
obstack_free(&lv->obst, NULL);
ir_nodehashmap_destroy(&lv->map);
lv->sets_valid = false;
be_lv_t *lv = XMALLOCZ(be_lv_t);
lv->irg = irg;
- lv->hook_info.context = lv;
- lv->hook_info.hook._hook_node_info = be_dump_liveness_block;
return lv;
}
* function. */
assert(!is_Phi(node) && "liveness_transfer produces invalid results for phi nodes");
- be_foreach_definition(node, cls, value,
+ be_foreach_definition(node, cls, value, req,
ir_nodeset_remove(nodeset, value);
);
- int arity = get_irn_arity(node);
- for (int i = 0; i < arity; ++i) {
- ir_node *op = get_irn_n(node, i);
- if (!arch_irn_consider_in_reg_alloc(cls, op))
- continue;
+ be_foreach_use(node, cls, in_req, op, op_req,
ir_nodeset_insert(nodeset, op);
- }
+ );
}
const ir_node *block, ir_nodeset_t *live)
{
assert(lv->sets_valid && "live sets must be computed");
- be_lv_foreach(lv, block, be_lv_state_end, node) {
- if (!arch_irn_consider_in_reg_alloc(cls, node))
- continue;
-
+ be_lv_foreach_cls(lv, block, be_lv_state_end, cls, node) {
ir_nodeset_insert(live, node);
}
}