Commit d1b570dc authored by Matthias Braun's avatar Matthias Braun
Browse files

remove beintlive_t header

Move the values interfere function to belive.h, move the inline
implementation into belive.c
parent 8f1ba92a
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "bechordal_draw.h" #include "bechordal_draw.h"
#include "bechordal_t.h" #include "bechordal_t.h"
#include "beinsn_t.h" #include "beinsn_t.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "besched.h"
#include "beirg.h" #include "beirg.h"
#include "bemodule.h" #include "bemodule.h"
#include "debug.h" #include "debug.h"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "becopyopt_t.h" #include "becopyopt_t.h"
#include "becopystat.h" #include "becopystat.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "bemodule.h" #include "bemodule.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "list.h" #include "list.h"
#include "pdeq.h" #include "pdeq.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "be_t.h" #include "be_t.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "irtools.h" #include "irtools.h"
#include "irprintf.h" #include "irprintf.h"
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* x_nc, y_ij \in N, w_ij \in R^+ * x_nc, y_ij \in N, w_ij \in R^+
*/ */
#include "be_t.h" #include "be_t.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "panic.h" #include "panic.h"
#include "raw_bitset.h" #include "raw_bitset.h"
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "bedump.h" #include "bedump.h"
#include "beifg.h" #include "beifg.h"
#include "beinsn_t.h" #include "beinsn_t.h"
#include "beintlive_t.h"
#include "beirg.h" #include "beirg.h"
#include "belive_t.h" #include "belive_t.h"
#include "bemodule.h" #include "bemodule.h"
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "becopyopt_t.h" #include "becopyopt_t.h"
#include "becopystat.h" #include "becopystat.h"
#include "bemodule.h" #include "bemodule.h"
#include "beintlive_t.h" #include "belive_t.h"
#define DEBUG_LVL SET_LEVEL_1 #define DEBUG_LVL SET_LEVEL_1
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "becopyopt.h" #include "becopyopt.h"
#include "beirg.h" #include "beirg.h"
#include "bemodule.h" #include "bemodule.h"
#include "beintlive_t.h" #include "belive_t.h"
void be_ifg_free(be_ifg_t *self) void be_ifg_free(be_ifg_t *self)
{ {
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 Universitaet Karlsruhe
*/
#ifndef _BELIVECHK_T_H
#define _BELIVECHK_T_H
#include "besched.h"
#include "belive_t.h"
#include "beutil.h"
#include "iredges_t.h"
/**
* Check, if one value dominates the other.
* The dominance is not strict here.
* @param a The first node.
* @param b The second node.
* @return true if a dominates b or if a == b.
*/
static inline bool value_strictly_dominates(const ir_node *a,
const ir_node *b)
{
/* if a and b are not in the same block, dominance is determined by the
* dominance of the blocks. */
const ir_node *block_a = get_block_const(a);
const ir_node *block_b = get_block_const(b);
if (block_a != block_b)
return block_dominates(block_a, block_b);
/* Dominance is determined by schedule. */
return sched_comes_before(a, b);
}
/**
* Check, if two values interfere.
* @param lv Liveness information
* @param a The first value.
* @param b The second value.
* @return true, if a and b interfere, false if not.
*/
static inline bool be_values_interfere(be_lv_t const *lv, ir_node const *a,
ir_node const *b)
{
assert(a != b);
if (value_strictly_dominates(b, a)) {
/* Adjust a and b so, that a dominates b if
* a dominates b or vice versa. */
ir_node const *const t = a;
a = b;
b = t;
} else if (!value_strictly_dominates(a, b)) {
/* If there is no dominance relation, they do not interfere. */
return false;
}
ir_node *const bb = get_nodes_block(b);
/* If a is live end in b's block it is
* live at b's definition (a dominates b) */
if (be_is_live_end(lv, bb, a))
return true;
/* Look at all usages of a.
* If there's one usage of a in the block of b, then
* we check, if this use is dominated by b, if that's true
* a and b interfere. Note that b must strictly dominate the user,
* since if b is the last user of in the block, b and a do not
* interfere.
* Uses of a not in b's block can be disobeyed, because the
* check for a being live at the end of b's block is already
* performed. */
foreach_out_edge(a, edge) {
ir_node const *const user = get_edge_src_irn(edge);
if (get_nodes_block(user) == bb && !is_Phi(user)
&& sched_comes_before(b, user))
return true;
}
return false;
}
#endif
...@@ -433,8 +433,6 @@ void be_liveness_end_of_block(const be_lv_t *lv, ...@@ -433,8 +433,6 @@ void be_liveness_end_of_block(const be_lv_t *lv,
} }
} }
void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_t const *const cls, ir_node const *const pos, ir_nodeset_t *const live) void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_t const *const cls, ir_node const *const pos, ir_nodeset_t *const live)
{ {
ir_node *const bl = get_nodes_block(pos); ir_node *const bl = get_nodes_block(pos);
...@@ -446,6 +444,43 @@ void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_ ...@@ -446,6 +444,43 @@ void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_
} }
} }
bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b)
{
assert(a != b);
if (value_strictly_dominates(b, a)) {
/* Adjust a and b so, that a dominates b if
* a dominates b or vice versa. */
const ir_node *const t = a;
a = b;
b = t;
} else if (!value_strictly_dominates(a, b)) {
/* If there is no dominance relation, they do not interfere. */
return false;
}
/* If a is live end in b's block it is
* live at b's definition (a dominates b) */
const ir_node *const bb = get_nodes_block(b);
if (be_is_live_end(lv, bb, a))
return true;
/* Look at all usages of a.
* If there's one usage of a in the block of b, then we check, if this use
* is dominated by b, if that's true a and b interfere. Note that b must
* strictly dominate the user, since if b is the last user of in the block,
* b and a do not interfere.
* Uses of a not in b's block can be disobeyed, because the check for a
* being live at the end of b's block is already performed. */
foreach_out_edge(a, edge) {
const ir_node *const user = get_edge_src_irn(edge);
if (get_nodes_block(user) == bb && !is_Phi(user)
&& sched_comes_before(b, user))
return true;
}
return false;
}
static void collect_node(ir_node *irn, void *data) static void collect_node(ir_node *irn, void *data)
{ {
struct obstack *obst = (struct obstack*)data; struct obstack *obst = (struct obstack*)data;
......
...@@ -121,6 +121,15 @@ void be_liveness_end_of_block(const be_lv_t *lv, ...@@ -121,6 +121,15 @@ void be_liveness_end_of_block(const be_lv_t *lv,
const arch_register_class_t *cls, const arch_register_class_t *cls,
const ir_node *bl, ir_nodeset_t *nodeset); const ir_node *bl, ir_nodeset_t *nodeset);
/**
* Check, if two values interfere.
* @param lv Liveness information
* @param a The first value.
* @param b The second value.
* @return true, if a and b interfere, false if not.
*/
bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b);
/** /**
* Compute a set of nodes which are live just before the given node. * Compute a set of nodes which are live just before the given node.
* @param cls The register class to consider. * @param cls The register class to consider.
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "besched.h" #include "besched.h"
#include "bestat.h" #include "bestat.h"
#include "bessaconstr.h" #include "bessaconstr.h"
#include "beintlive_t.h" #include "belive_t.h"
#undef KEEP_ALIVE_COPYKEEP_HACK #undef KEEP_ALIVE_COPYKEEP_HACK
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "beirg.h" #include "beirg.h"
#include "belive_t.h" #include "belive_t.h"
#include "bearch.h" #include "bearch.h"
#include "beintlive_t.h"
#include "benode.h" #include "benode.h"
#include "besched.h" #include "besched.h"
#include "bemodule.h" #include "bemodule.h"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "irtools.h" #include "irtools.h"
#include "statev_t.h" #include "statev_t.h"
#include "beintlive_t.h"
#include "beirg.h" #include "beirg.h"
#include "belive_t.h" #include "belive_t.h"
#include "bemodule.h" #include "bemodule.h"
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "beinfo.h" #include "beinfo.h"
#include "beutil.h"
#include "irdom.h"
static sched_info_t *get_irn_sched_info(const ir_node *node) static sched_info_t *get_irn_sched_info(const ir_node *node)
{ {
...@@ -157,6 +159,27 @@ static inline bool sched_comes_before(const ir_node *a, const ir_node *b) ...@@ -157,6 +159,27 @@ static inline bool sched_comes_before(const ir_node *a, const ir_node *b)
return as < bs; return as < bs;
} }
/**
* Check, if one value dominates the other.
* The dominance is not strict here.
* @param a The first node.
* @param b The second node.
* @return true if a dominates b or if a == b.
*/
static inline bool value_strictly_dominates(const ir_node *a,
const ir_node *b)
{
/* if a and b are not in the same block, dominance is determined by the
* dominance of the blocks. */
const ir_node *block_a = get_block_const(a);
const ir_node *block_b = get_block_const(b);
if (block_a != block_b)
return block_dominates(block_a, block_b);
/* Dominance is determined by schedule. */
return sched_comes_before(a, b);
}
#define sched_foreach_after(after, irn) \ #define sched_foreach_after(after, irn) \
for (ir_node *irn = (after); !sched_is_end(irn = sched_next(irn));) for (ir_node *irn = (after); !sched_is_end(irn = sched_next(irn));)
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "benode.h" #include "benode.h"
#include "besched.h" #include "besched.h"
#include "bera.h" #include "bera.h"
#include "beintlive_t.h"
#include "lc_opts.h" #include "lc_opts.h"
#include "lc_opts_enum.h" #include "lc_opts_enum.h"
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "bechordal_t.h" #include "bechordal_t.h"
#include "statev_t.h" #include "statev_t.h"
#include "bemodule.h" #include "bemodule.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "bearch.h" #include "bearch.h"
#include "bespillutil.h" #include "bespillutil.h"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "execfreq.h" #include "execfreq.h"
#include "panic.h" #include "panic.h"
#include "bearch.h" #include "bearch.h"
#include "belive_t.h"
#include "besched.h" #include "besched.h"
#include "bespill.h" #include "bespill.h"
#include "bespillutil.h" #include "bespillutil.h"
...@@ -37,7 +36,6 @@ ...@@ -37,7 +36,6 @@
#include "bessaconstr.h" #include "bessaconstr.h"
#include "beirg.h" #include "beirg.h"
#include "beirgmod.h" #include "beirgmod.h"
#include "beintlive_t.h"
#include "bemodule.h" #include "bemodule.h"
#include "be_t.h" #include "be_t.h"
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "bessaconstr.h" #include "bessaconstr.h"
#include "bemodule.h" #include "bemodule.h"
#include "besched.h" #include "besched.h"
#include "beintlive_t.h" #include "belive_t.h"
#include "beirg.h" #include "beirg.h"
#include "be_t.h" #include "be_t.h"
#include "benode.h" #include "benode.h"
......
...@@ -23,11 +23,10 @@ ...@@ -23,11 +23,10 @@
#include "iredges.h" #include "iredges.h"
#include "beverify.h" #include "beverify.h"
#include "belive.h" #include "belive_t.h"
#include "besched.h" #include "besched.h"
#include "benode.h" #include "benode.h"
#include "beirg.h" #include "beirg.h"
#include "beintlive_t.h"
#include "belistsched.h" #include "belistsched.h"
static bool my_values_interfere(const ir_node *a, const ir_node *b); static bool my_values_interfere(const ir_node *a, const ir_node *b);
......
Supports Markdown
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