Commit dc3225d5 authored by Sebastian Hack's avatar Sebastian Hack
Browse files

Moved insert_Perm_after to benode.c

parent 2cc256e5
......@@ -9,12 +9,6 @@
#include "obst.h"
#include <beirgmod.h>
#include <bearch.h>
#include "benode_t.h"
#if 0
typedef struct _phase_t {
const char *name;
......@@ -29,14 +23,14 @@ int phase_invalidates(const ir_graph *irg, const phase_t *phase, int n, ...);
typedef struct _be_main_env_t {
struct obstack obst;
be_node_factory_t *node_factory;
arch_env_t *arch_env;
struct _be_node_factory_t *node_factory;
struct _arch_env_t *arch_env;
} be_main_env_t;
typedef struct _be_main_session_env_t {
const be_main_env_t *main_env;
ir_graph *irg;
dom_front_info_t *dom_front;
struct _dom_front_info_t *dom_front;
} be_main_session_env_t;
#endif
......@@ -349,59 +349,3 @@ void be_introduce_copies(dom_front_info_t *info, ir_node *orig, int n, ir_node *
del_pset(copies);
del_pset(copy_blocks);
}
void insert_Perm_after(const be_main_session_env_t *env,
const arch_register_class_t *cls, ir_node *pos)
{
const arch_env_t *arch_env = env->main_env->arch_env;
ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_graph *irg = get_irn_irg(bl);
pset *live_end = get_live_end(bl);
pset *live = pset_new_ptr_default();
ir_node *curr, *irn, *perm, **nodes;
int i, n;
/* put all live ends in the live set. */
for(irn = pset_first(live_end); irn; irn = pset_next(live_end))
pset_insert_ptr(live, irn);
sched_foreach_reverse(bl, irn) {
if(arch_irn_has_reg_class(arch_env, irn, arch_pos_make_out(0), cls))
pset_remove_ptr(live, irn);
for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
ir_node *op = get_irn_n(irn, i);
if(arch_irn_has_reg_class(arch_env, op, arch_pos_make_out(0), cls))
pset_insert_ptr(live, op);
}
if(sched_prev(irn) == pos)
break;
}
n = pset_count(live);
nodes = malloc(n * sizeof(nodes[0]));
for(irn = pset_first(live), i = 0; irn; irn = pset_next(live), i++)
nodes[i] = irn;
curr = perm = new_Perm(env->main_env->node_factory, cls, irg, bl, n, nodes);
sched_add_after(pos, perm);
free(nodes);
for(i = 0; i < n; ++i) {
ir_node *copies[1];
ir_node *perm_op = get_irn_n(perm, i);
ir_mode *mode = get_irn_mode(perm_op);
ir_node *proj = new_r_Proj(irg, bl, perm, mode, i);
sched_add_after(curr, proj);
curr = proj;
copies[0] = proj;
be_introduce_copies(env->dom_front, perm_op, array_size(copies), copies);
}
}
......@@ -19,9 +19,15 @@
#include "irop_t.h"
#include "irmode_t.h"
#include "irnode_t.h"
#include "ircons_t.h"
#include "be_t.h"
#include "belive_t.h"
#include "besched_t.h"
#include "benode_t.h"
#include "beirgmod.h"
typedef enum _node_kind_t {
node_kind_spill,
node_kind_reload,
......@@ -310,25 +316,57 @@ be_node_factory_t *be_node_factory_init(be_node_factory_t *factory,
return factory;
}
#if 0
ir_node *be_spill(const be_node_factory_t *factory,
const arch_env_t *env, ir_node *node_to_spill)
void insert_Perm_after(const be_main_session_env_t *env,
const arch_register_class_t *cls, ir_node *pos)
{
ir_node *res;
if(is_Reload(node_to_spill))
res = get_irn_n(node_to_spill, 0);
else {
ir_node *bl = get_nodes_block(node_to_spill);
ir_graph *irg = get_irn_irg(bl);
res = new_Spill(factory, cls, irg, bl, node_to_spill);
const arch_env_t *arch_env = env->main_env->arch_env;
ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_graph *irg = get_irn_irg(bl);
pset *live_end = get_live_end(bl);
pset *live = pset_new_ptr_default();
ir_node *curr, *irn, *perm, **nodes;
int i, n;
/* put all live ends in the live set. */
for(irn = pset_first(live_end); irn; irn = pset_next(live_end))
pset_insert_ptr(live, irn);
sched_foreach_reverse(bl, irn) {
if(arch_irn_has_reg_class(arch_env, irn, arch_pos_make_out(0), cls))
pset_remove_ptr(live, irn);
for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
ir_node *op = get_irn_n(irn, i);
if(arch_irn_has_reg_class(arch_env, op, arch_pos_make_out(0), cls))
pset_insert_ptr(live, op);
}
if(sched_prev(irn) == pos)
break;
}
return res;
}
n = pset_count(live);
nodes = malloc(n * sizeof(nodes[0]));
ir_node *be_reload(const be_node_factory_t *factory,
const arch_env_t *env, ir_node *spill)
{
for(irn = pset_first(live), i = 0; irn; irn = pset_next(live), i++)
nodes[i] = irn;
curr = perm = new_Perm(env->main_env->node_factory, cls, irg, bl, n, nodes);
sched_add_after(pos, perm);
free(nodes);
for(i = 0; i < n; ++i) {
ir_node *copies[1];
ir_node *perm_op = get_irn_n(perm, i);
ir_mode *mode = get_irn_mode(perm_op);
ir_node *proj = new_r_Proj(irg, bl, perm, mode, i);
sched_add_after(curr, proj);
curr = proj;
copies[0] = proj;
be_introduce_copies(env->dom_front, perm_op, array_size(copies), copies);
}
}
#endif
......@@ -17,6 +17,7 @@
#include "irmode.h"
#include "irnode.h"
#include "be_t.h"
#include "bearch.h"
struct _be_node_factory_t {
......@@ -59,10 +60,7 @@ ir_node *be_reload(const be_node_factory_t *factory, const arch_env_t *env, ir_n
int is_Spill(const be_node_factory_t *f, const ir_node *irn);
ir_node *get_Reload_Spill(ir_node *reload);
void insert_perm(const be_node_factory_t *factory,
const arch_register_class_t *reg_class,
ir_node *in_front_of);
void insert_Perm_after(const be_main_session_env_t *env,
const arch_register_class_t *cls, ir_node *pos);
#endif /* _BENODE_T_H */
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