Commit 9beeb71e authored by Matthias Braun's avatar Matthias Braun
Browse files

merge belive_t.h and belive.h

parent 093e290c
......@@ -33,7 +33,7 @@
#include "beabihelper.h"
#include "bearch.h"
#include "benode.h"
#include "belive_t.h"
#include "belive.h"
#include "besched.h"
#include "beirg.h"
#include "bessaconstr.h"
......
......@@ -13,7 +13,7 @@
#include "bechordal_draw.h"
#include "bechordal_t.h"
#include "beinsn_t.h"
#include "belive_t.h"
#include "belive.h"
#include "besched.h"
#include "beirg.h"
#include "bemodule.h"
......
......@@ -24,7 +24,7 @@
#include "benode.h"
#include "bemodule.h"
#include "belive.h"
#include "belive_t.h"
#include "belive.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
......
......@@ -18,7 +18,7 @@
#include "util.h"
#include "bearch.h"
#include "belive_t.h"
#include "belive.h"
#include "bechordal_t.h"
#include "besched.h"
#include "bechordal_draw.h"
......
......@@ -40,7 +40,7 @@
#include "beutil.h"
#include "besched.h"
#include "besched.h"
#include "belive_t.h"
#include "belive.h"
#include "bearch.h"
#include "beifg.h"
#include "benode.h"
......
......@@ -24,7 +24,7 @@
#include "becopyopt_t.h"
#include "becopystat.h"
#include "belive_t.h"
#include "belive.h"
#include "beirg.h"
#include "bemodule.h"
......
......@@ -15,7 +15,7 @@
#include <stdlib.h>
#include <limits.h>
#include "belive_t.h"
#include "belive.h"
#include "beirg.h"
#include "list.h"
#include "pdeq.h"
......
......@@ -12,7 +12,7 @@
#include <stdbool.h>
#include "be_t.h"
#include "belive_t.h"
#include "belive.h"
#include "beirg.h"
#include "irtools.h"
#include "irprintf.h"
......
......@@ -30,7 +30,7 @@
* x_nc, y_ij \in N, w_ij \in R^+
*/
#include "be_t.h"
#include "belive_t.h"
#include "belive.h"
#include "beirg.h"
#include "panic.h"
#include "raw_bitset.h"
......
......@@ -37,7 +37,7 @@
#include "beifg.h"
#include "beinsn_t.h"
#include "beirg.h"
#include "belive_t.h"
#include "belive.h"
#include "bemodule.h"
#include "benode.h"
#include "besched.h"
......
......@@ -23,7 +23,7 @@
#include "becopyopt_t.h"
#include "becopystat.h"
#include "bemodule.h"
#include "belive_t.h"
#include "belive.h"
#define DEBUG_LVL SET_LEVEL_1
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
......
......@@ -14,7 +14,7 @@
#include "irgwalk.h"
#include "beifg.h"
#include "becopyopt_t.h"
#include "belive_t.h"
#include "belive.h"
static void dump_ifg_nodes(FILE *F, const be_ifg_t *ifg)
{
......
......@@ -26,7 +26,7 @@
#include "becopyopt.h"
#include "beirg.h"
#include "bemodule.h"
#include "belive_t.h"
#include "belive.h"
void be_ifg_free(be_ifg_t *self)
{
......
......@@ -15,7 +15,7 @@
#include "benode.h"
#include "besched.h"
#include "bedump.h"
#include "belive_t.h"
#include "belive.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "irdump_t.h"
......
......@@ -38,7 +38,7 @@
#include "bechordal_t.h"
#include "bearch.h"
#include "besched.h"
#include "belive_t.h"
#include "belive.h"
#include "benode.h"
#include "beutil.h"
#include "beinsn_t.h"
......
......@@ -30,7 +30,7 @@
#include "bemodule.h"
#include "besched.h"
#include "beutil.h"
#include "belive_t.h"
#include "belive.h"
#include "belistsched.h"
#include "bearch.h"
#include "bestat.h"
......
......@@ -23,7 +23,7 @@
#include "be_t.h"
#include "bearch.h"
#include "beutil.h"
#include "belive_t.h"
#include "belive.h"
#include "besched.h"
#include "bemodule.h"
#include "beirg.h"
......@@ -32,21 +32,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
#define LV_STD_SIZE 64
bool (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);
}
bool (be_is_live_out)(const be_lv_t *lv, const ir_node *block, const ir_node *irn)
{
return _be_is_live_xxx(lv, block, irn, be_lv_state_out);
}
bool (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn)
{
return _be_is_live_xxx(lv, block, irn, be_lv_state_end);
}
static unsigned _be_liveness_bsearch(const be_lv_info_t *arr,
const ir_node *node)
{
......
......@@ -14,6 +14,9 @@
#include "be_types.h"
#include "irnodeset.h"
#include "irnodehashmap.h"
#include "irlivechk.h"
#include "bearch.h"
typedef enum {
be_lv_state_none = 0,
......@@ -73,30 +76,6 @@ void be_liveness_remove(be_lv_t *lv, const ir_node *irn);
*/
void be_liveness_introduce(be_lv_t *lv, ir_node *irn);
/**
* Check, if a node is live in at a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the entrance of @p block
*/
bool (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
/**
* Check, if a node is live out at a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the exit of @p block
*/
bool (be_is_live_out)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
/**
* Check, if a node is live at the end of a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the end of the block
*/
bool (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
/**
* The liveness transfer function.
* Updates a live set over a single step from a given node to its predecessor.
......@@ -150,4 +129,131 @@ void be_liveness_nodes_live_before(be_lv_t const *lv,
arch_register_class_t const *cls,
ir_node const *pos, ir_nodeset_t *live);
struct be_lv_t {
ir_nodehashmap_t map;
struct obstack obst;
bool sets_valid;
ir_graph *irg;
lv_chk_t *lvc;
};
typedef struct be_lv_info_node_t be_lv_info_node_t;
struct be_lv_info_node_t {
ir_node *node;
unsigned flags;
};
struct be_lv_info_head_t {
unsigned n_members;
unsigned n_size;
};
union be_lv_info_t {
struct be_lv_info_head_t head;
struct be_lv_info_node_t node;
};
be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *block,
const ir_node *irn);
static inline bool _be_is_live_xxx(const be_lv_t *li, const ir_node *block,
const ir_node *irn, unsigned flags)
{
if (li->sets_valid) {
be_lv_info_node_t *info = be_lv_get(li, block, irn);
return info != NULL ? (info->flags & flags) : false;
} else {
return lv_chk_bl_xxx(li->lvc, block, irn) & flags;
}
}
/**
* Check, if a node is live in at a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the entrance of @p block
*/
static inline bool be_is_live_in(const be_lv_t *li, const ir_node *block,
const ir_node *node)
{
return _be_is_live_xxx(li, block, node, be_lv_state_in);
}
/**
* Check, if a node is live out at a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the exit of @p block
*/
static inline bool be_is_live_out(const be_lv_t *li, const ir_node *block,
const ir_node *node)
{
return _be_is_live_xxx(li, block, node, be_lv_state_out);
}
/**
* Check, if a node is live at the end of a block.
* @param block The block.
* @param irn The node to check for.
* @return true, if @p irn is live at the end of the block
*/
static inline bool be_is_live_end(const be_lv_t *li, const ir_node *block,
const ir_node *node)
{
return _be_is_live_xxx(li, block, node, be_lv_state_end);
}
typedef struct lv_iterator_t
{
be_lv_info_t *info;
size_t i;
} lv_iterator_t;
static inline lv_iterator_t be_lv_iteration_begin(const be_lv_t *lv,
const ir_node *block)
{
lv_iterator_t res;
res.info = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
res.i = res.info != NULL ? res.info[0].head.n_members : 0;
return res;
}
static inline ir_node *be_lv_iteration_next(lv_iterator_t *iterator,
be_lv_state_t flags)
{
while (iterator->i != 0) {
const be_lv_info_t *info = iterator->info + iterator->i--;
if (info->node.flags & flags)
return info->node.node;
}
return NULL;
}
static inline ir_node *be_lv_iteration_cls_next(lv_iterator_t *iterator,
be_lv_state_t flags,
const arch_register_class_t *cls)
{
while (iterator->i != 0) {
const be_lv_info_t *info = iterator->info + iterator->i--;
if (!(info->node.flags & flags))
continue;
ir_node *node = info->node.node;
if (!arch_irn_consider_in_reg_alloc(cls, node))
continue;
return node;
}
return NULL;
}
#define be_lv_foreach(lv, block, flags, node) \
for (bool once = true; once;) \
for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
for (ir_node *node; (node = be_lv_iteration_next(&iter, (flags))) != NULL;)
#define be_lv_foreach_cls(lv, block, flags, cls, node) \
for (bool once = true; once;) \
for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
for (ir_node *node; (node = be_lv_iteration_cls_next(&iter, (flags), (cls))) != NULL;)
#endif
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Internal headers for liveness analysis.
* @author Sebastian Hack
* @date 06.12.2004
*/
#ifndef FIRM_BE_BELIVE_T_H
#define FIRM_BE_BELIVE_T_H
#include <stdbool.h>
#include "irnodehashmap.h"
#include "irhooks.h"
#include "irlivechk.h"
#include "belive.h"
#include "bearch.h"
#define be_is_live_in(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_in)
#define be_is_live_end(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_end)
#define be_is_live_out(lv, bl, irn) _be_is_live_xxx(lv, bl, irn, be_lv_state_out)
struct be_lv_t {
ir_nodehashmap_t map;
struct obstack obst;
bool sets_valid;
ir_graph *irg;
lv_chk_t *lvc;
};
typedef struct be_lv_info_node_t be_lv_info_node_t;
struct be_lv_info_node_t {
ir_node *node;
unsigned flags;
};
struct be_lv_info_head_t {
unsigned n_members;
unsigned n_size;
};
union be_lv_info_t {
struct be_lv_info_head_t head;
struct be_lv_info_node_t node;
};
be_lv_info_node_t *be_lv_get(const be_lv_t *li, const ir_node *block,
const ir_node *irn);
static inline unsigned _be_is_live_xxx(const be_lv_t *li, const ir_node *block,
const ir_node *irn, unsigned flags)
{
unsigned res;
if (li->sets_valid) {
be_lv_info_node_t *info = be_lv_get(li, block, irn);
res = info != NULL ? (info->flags & flags) != 0 : 0;
} else {
res = (lv_chk_bl_xxx(li->lvc, block, irn) & flags) != 0;
}
return res;
}
typedef struct lv_iterator_t
{
be_lv_info_t *info;
size_t i;
} lv_iterator_t;
static inline lv_iterator_t be_lv_iteration_begin(const be_lv_t *lv,
const ir_node *block)
{
lv_iterator_t res;
res.info = ir_nodehashmap_get(be_lv_info_t, &lv->map, block);
res.i = res.info != NULL ? res.info[0].head.n_members : 0;
return res;
}
static inline ir_node *be_lv_iteration_next(lv_iterator_t *iterator, be_lv_state_t flags)
{
while (iterator->i != 0) {
const be_lv_info_t *info = iterator->info + iterator->i--;
if (info->node.flags & flags)
return info->node.node;
}
return NULL;
}
static inline ir_node *be_lv_iteration_cls_next(lv_iterator_t *iterator, be_lv_state_t flags, const arch_register_class_t *cls)
{
while (iterator->i != 0) {
const be_lv_info_t *info = iterator->info + iterator->i--;
if (!(info->node.flags & flags))
continue;
ir_node *node = info->node.node;
if (!arch_irn_consider_in_reg_alloc(cls, node))
continue;
return node;
}
return NULL;
}
#define be_lv_foreach(lv, block, flags, node) \
for (bool once = true; once;) \
for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
for (ir_node *node; (node = be_lv_iteration_next(&iter, (flags))) != NULL;)
#define be_lv_foreach_cls(lv, block, flags, cls, node) \
for (bool once = true; once;) \
for (lv_iterator_t iter = be_lv_iteration_begin((lv), (block)); once; once = false) \
for (ir_node *node; (node = be_lv_iteration_cls_next(&iter, (flags), (cls))) != NULL;)
#endif
......@@ -32,7 +32,7 @@
#include "besched.h"
#include "bestat.h"
#include "bessaconstr.h"
#include "belive_t.h"
#include "belive.h"
#undef KEEP_ALIVE_COPYKEEP_HACK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment