Made lpp stuff modular.
[libfirm] / ir / be / belive_t.h
index 57bcc83..d46af6d 100644 (file)
@@ -9,15 +9,18 @@
 
 #include "config.h"
 
+#include "belive.h"
 #include "pset.h"
 
 typedef struct _block_live_info_t {
-       pset *in;
-       pset *out;
+       pset *in;                               /**< The set of all values live in at that block. */
+       pset *out;                              /**< The set of all values live out. */
+       pset *end;                              /**< The set of all values live at the end
+                                                                                       of the block (contains all live out). */
 } block_live_info_t;
 
 typedef struct _node_live_info_t {
-       unsigned last_use_in_block : 1;
+       int is_phi_op;          /**< Marks the node as a phi operand. */
 } node_live_info_t;
 
 typedef struct _live_info_t {
@@ -32,7 +35,14 @@ extern size_t live_irn_data_offset;
 #define get_irn_live_info(irn) get_irn_data(irn, live_info_t, live_irn_data_offset)
 #define get_live_info_irn(inf) get_irn_data_base(inf, live_irn_data_offset)
 
-#define get_block_live_info(irn) &(get_irn_live_info(irn)->v.block)
+#define get_block_live_info(irn) (&(get_irn_live_info(irn)->v.block))
+#define get_node_live_info(irn) (&(get_irn_live_info(irn)->v.node))
+
+static INLINE int _is_phi_operand(const ir_node *irn)
+{
+       assert(!is_Block(irn) && "No block node allowed here");
+       return get_node_live_info(irn)->is_phi_op;
+}
 
 static INLINE int _is_live_in(const ir_node *block, const ir_node *irn)
 {
@@ -50,8 +60,39 @@ static INLINE int _is_live_out(const ir_node *block, const ir_node *irn)
        return pset_find_ptr(info->out, irn) != NULL;
 }
 
-#define is_live_in(block,irn) _is_live_in(block, irn)
-#define is_live_out(block,irn) _is_live_out(block, irn)
+static INLINE int _is_live_end(const ir_node *block, const ir_node *irn)
+{
+       block_live_info_t *info = get_block_live_info(block);
+
+       assert(is_Block(block) && "Need a block here");
+       return pset_find_ptr(info->end, irn) != NULL;
+}
+
+static INLINE pset *_get_live_in(const ir_node *block)
+{
+       assert(is_Block(block) && "Need a block here");
+       return get_block_live_info(block)->in;
+}
+
+static INLINE pset *_get_live_out(const ir_node *block)
+{
+       assert(is_Block(block) && "Need a block here");
+       return get_block_live_info(block)->out;
+}
+
+static INLINE pset *_get_live_end(const ir_node *block)
+{
+       assert(is_Block(block) && "Need a block here");
+       return get_block_live_info(block)->end;
+}
+
+#define is_phi_operand(irn)                    _is_phi_operand(irn)
+#define is_live_in(bl,irn)                     _is_live_in(bl, irn)
+#define is_live_out(bl,irn)            _is_live_out(bl, irn)
+#define is_live_end(bl,irn)            _is_live_end(bl, irn)
+#define get_live_in(bl)                                        _get_live_in(bl)
+#define get_live_out(bl)                               _get_live_out(bl)
+#define get_live_end(bl)                               _get_live_end(bl)
 
 /**
  * Initialize the liveness module.