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

refactoring: set_frame_entity is a special callbacks for users of the advanced...

refactoring: set_frame_entity is a special callbacks for users of the advanced spillslot coalescing interface and not a generic bearch callback thingy anymore

[r27736]
parent 84bb5671
......@@ -66,13 +66,6 @@ static ir_entity *TEMPLATE_get_frame_entity(const ir_node *node)
return NULL;
}
static void TEMPLATE_set_frame_entity(ir_node *node, ir_entity *ent)
{
(void) node;
(void) ent;
/* TODO: set the ir_entity assigned to the frame */
}
/**
* This function is called by the generic backend to correct offsets for
* nodes accessing the stack.
......@@ -96,7 +89,6 @@ static const arch_irn_ops_t TEMPLATE_irn_ops = {
get_TEMPLATE_in_req,
TEMPLATE_classify,
TEMPLATE_get_frame_entity,
TEMPLATE_set_frame_entity,
TEMPLATE_set_frame_offset,
TEMPLATE_get_sp_bias,
NULL, /* get_inverse */
......
......@@ -82,13 +82,6 @@ static ir_entity *amd64_get_frame_entity(const ir_node *node)
return NULL;
}
static void amd64_set_frame_entity(ir_node *node, ir_entity *ent)
{
(void) node;
(void) ent;
/* TODO: set the ir_entity assigned to the frame */
}
/**
* This function is called by the generic backend to correct offsets for
* nodes accessing the stack.
......@@ -122,7 +115,6 @@ static const arch_irn_ops_t amd64_irn_ops = {
get_amd64_in_req,
amd64_classify,
amd64_get_frame_entity,
amd64_set_frame_entity,
amd64_set_frame_offset,
amd64_get_sp_bias,
NULL, /* get_inverse */
......
......@@ -93,13 +93,6 @@ static ir_entity *arm_get_frame_entity(const ir_node *irn)
return NULL;
}
static void arm_set_frame_entity(ir_node *irn, ir_entity *ent)
{
(void) irn;
(void) ent;
panic("arm_set_frame_entity() called. This should not happen.");
}
/**
* This function is called by the generic backend to correct offsets for
* nodes accessing the stack.
......@@ -130,7 +123,6 @@ static const arch_irn_ops_t arm_irn_ops = {
get_arm_in_req,
arm_classify,
arm_get_frame_entity,
arm_set_frame_entity,
arm_set_stack_bias,
arm_get_sp_bias,
NULL, /* get_inverse */
......
......@@ -97,12 +97,6 @@ ir_entity *arch_get_frame_entity(const ir_node *irn)
return ops->get_frame_entity(irn);
}
void arch_set_frame_entity(ir_node *irn, ir_entity *ent)
{
const arch_irn_ops_t *ops = get_irn_ops(irn);
ops->set_frame_entity(irn, ent);
}
int arch_get_sp_bias(ir_node *irn)
{
const arch_irn_ops_t *ops = get_irn_ops(irn);
......
......@@ -119,7 +119,6 @@ typedef enum arch_irn_class_t {
void arch_set_frame_offset(ir_node *irn, int bias);
ir_entity *arch_get_frame_entity(const ir_node *irn);
void arch_set_frame_entity(ir_node *irn, ir_entity *ent);
int arch_get_sp_bias(ir_node *irn);
int arch_get_op_estimated_cost(const ir_node *irn);
......@@ -405,13 +404,6 @@ struct arch_irn_ops_t {
*/
ir_entity *(*get_frame_entity)(const ir_node *irn);
/**
* Set the entity on the stack frame this node depends on.
* @param irn The node in question.
* @param ent The entity to set
*/
void (*set_frame_entity)(ir_node *irn, ir_entity *ent);
/**
* Set the offset of a node carrying an entity on the stack frame.
* @param irn The node.
......
......@@ -1078,7 +1078,7 @@ static ir_entity *be_node_get_frame_entity(const ir_node *irn)
return be_get_frame_entity(irn);
}
static void be_node_set_frame_entity(ir_node *irn, ir_entity *ent)
void be_node_set_frame_entity(ir_node *irn, ir_entity *ent)
{
be_frame_attr_t *a;
......@@ -1123,7 +1123,6 @@ static const arch_irn_ops_t be_node_irn_ops = {
be_node_get_in_reg_req,
be_node_classify,
be_node_get_frame_entity,
be_node_set_frame_entity,
be_node_set_frame_offset,
be_node_get_sp_bias,
NULL, /* get_inverse */
......@@ -1152,13 +1151,6 @@ static ir_entity* dummy_get_frame_entity(const ir_node *node)
return NULL;
}
static void dummy_set_frame_entity(ir_node *node, ir_entity *entity)
{
(void) node;
(void) entity;
panic("dummy_set_frame_entity() should not be called");
}
static void dummy_set_frame_offset(ir_node *node, int bias)
{
(void) node;
......@@ -1177,7 +1169,6 @@ static const arch_irn_ops_t dummy_be_irn_ops = {
dummy_reg_req,
dummy_classify,
dummy_get_frame_entity,
dummy_set_frame_entity,
dummy_set_frame_offset,
dummy_get_sp_bias,
NULL, /* get_inverse */
......@@ -1318,7 +1309,6 @@ static const arch_irn_ops_t phi_irn_ops = {
phi_get_irn_reg_req,
dummy_classify,
dummy_get_frame_entity,
dummy_set_frame_entity,
dummy_set_frame_offset,
dummy_get_sp_bias,
NULL, /* get_inverse */
......
......@@ -424,6 +424,8 @@ void be_set_CopyKeep_op(ir_node *cpy, ir_node *op);
*/
ir_entity *be_get_frame_entity(const ir_node *irn);
void be_node_set_frame_entity(ir_node *node, ir_entity *entity);
/**
* Returns the frame offset of this node.
*/
......
......@@ -53,27 +53,28 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
typedef struct _spill_t {
typedef struct spill_t {
ir_node *spill;
const ir_mode *mode; /**< mode of the spilled value */
int alignment; /**< alignment for the spilled value */
int spillslot; /**< index into spillslot_unionfind structure */
} spill_t;
typedef struct _affinity_edge_t {
typedef struct affinity_edge_t {
double affinity;
int slot1;
int slot2;
} affinity_edge_t;
struct _be_fec_env_t {
struct obstack obst;
const arch_env_t *arch_env;
ir_graph *irg;
set *spills;
ir_node **reloads;
affinity_edge_t **affinity_edges;
set *memperms;
struct be_fec_env_t {
struct obstack obst;
const arch_env_t *arch_env;
ir_graph *irg;
set *spills;
ir_node **reloads;
affinity_edge_t **affinity_edges;
set *memperms;
set_frame_entity_func set_frame_entity;
};
/** Compare 2 affinity edges (used in quicksort) */
......@@ -556,8 +557,8 @@ static void enlarge_spillslot(spill_slot_t *slot, int otheralign, int othersize)
}
}
static void assign_spill_entity(ir_node *node, ir_entity *entity)
static void assign_spill_entity(be_fec_env_t *env,
ir_node *node, ir_entity *entity)
{
if (is_NoMem(node))
return;
......@@ -569,7 +570,7 @@ static void assign_spill_entity(ir_node *node, ir_entity *entity)
ir_node *in = get_irn_n(node, i);
assert(!is_Phi(in));
assign_spill_entity(in, entity);
assign_spill_entity(env, in, entity);
}
return;
}
......@@ -578,7 +579,7 @@ static void assign_spill_entity(ir_node *node, ir_entity *entity)
instance */
node = skip_Proj(node);
assert(arch_get_frame_entity(node) == NULL);
arch_set_frame_entity(node, entity);
env->set_frame_entity(node, entity);
}
/**
......@@ -660,7 +661,7 @@ static void assign_spillslots(be_fec_env_t *env)
}
}
} else {
assign_spill_entity(node, slot->entity);
assign_spill_entity(env, node, slot->entity);
}
}
......@@ -672,7 +673,7 @@ static void assign_spillslots(be_fec_env_t *env)
assert(slot->entity != NULL);
arch_set_frame_entity(reload, slot->entity);
env->set_frame_entity(reload, slot->entity);
}
}
......@@ -791,8 +792,11 @@ void be_free_frame_entity_coalescer(be_fec_env_t *env)
free(env);
}
void be_assign_entities(be_fec_env_t *env)
void be_assign_entities(be_fec_env_t *env,
set_frame_entity_func set_frame_entity)
{
env->set_frame_entity = set_frame_entity;
stat_ev_dbl("spillslots", set_count(env->spills));
if (be_coalesce_spill_slots) {
......@@ -834,7 +838,7 @@ void be_coalesce_spillslots(ir_graph *irg)
/* collect reloads */
irg_walk_graph(irg, NULL, collect_spills_walker, env);
be_assign_entities(env);
be_assign_entities(env, be_node_set_frame_entity);
be_free_frame_entity_coalescer(env);
}
......
......@@ -29,7 +29,7 @@
#include "beirg.h"
typedef struct _be_fec_env_t be_fec_env_t;
typedef struct be_fec_env_t be_fec_env_t;
/**
* Initializes a new frame entity coalescer environment
......@@ -54,11 +54,13 @@ void be_free_frame_entity_coalescer(be_fec_env_t *env);
void be_node_needs_frame_entity(be_fec_env_t *env, ir_node *node,
const ir_mode *mode, int alignment);
typedef void (*set_frame_entity_func)(ir_node *node, ir_entity *entity);
/**
* Assigned frame entities to all the nodes added by be_node_needs_frame_entity.
* Adds memory perms where needed.
*/
void be_assign_entities(be_fec_env_t *env);
void be_assign_entities(be_fec_env_t *env, set_frame_entity_func set_frame);
//-------------------------------------------------------------------
// Old API
......
......@@ -229,9 +229,12 @@ static ir_entity *ia32_get_frame_entity(const ir_node *irn)
return is_ia32_irn(irn) ? get_ia32_frame_ent(irn) : NULL;
}
static void ia32_set_frame_entity(ir_node *irn, ir_entity *ent)
static void ia32_set_frame_entity(ir_node *node, ir_entity *entity)
{
set_ia32_frame_ent(irn, ent);
if (is_be_node(node))
be_node_set_frame_entity(node, entity);
else
set_ia32_frame_ent(node, entity);
}
static void ia32_set_frame_offset(ir_node *irn, int bias)
......@@ -789,7 +792,6 @@ static const arch_irn_ops_t ia32_irn_ops = {
get_ia32_in_req,
ia32_classify,
ia32_get_frame_entity,
ia32_set_frame_entity,
ia32_set_frame_offset,
ia32_get_sp_bias,
ia32_get_inverse,
......@@ -810,7 +812,6 @@ static const arch_irn_ops_t ia32_SwitchJmp_irn_ops = {
get_ia32_SwitchJmp_out_req,
ia32_classify,
ia32_get_frame_entity,
ia32_set_frame_entity,
ia32_set_frame_offset,
ia32_get_sp_bias,
ia32_get_inverse,
......@@ -1373,7 +1374,7 @@ static void ia32_after_ra(void *self)
/* create and coalesce frame entities */
irg_walk_graph(irg, NULL, ia32_collect_frame_entity_nodes, fec_env);
be_assign_entities(fec_env);
be_assign_entities(fec_env, ia32_set_frame_entity);
be_free_frame_entity_coalescer(fec_env);
irg_block_walk_graph(irg, NULL, ia32_after_ra_walker, cg);
......
......@@ -96,14 +96,6 @@ static ir_entity *sparc_get_frame_entity(const ir_node *irn)
return NULL;
}
static void sparc_set_frame_entity(ir_node *node, ir_entity *ent)
{
(void) node;
(void) ent;
panic("sparc_set_frame_entity() called. This should not happen.");
/* TODO: set the ir_entity assigned to the frame */
}
/**
* This function is called by the generic backend to correct offsets for
* nodes accessing the stack.
......@@ -132,7 +124,6 @@ static const arch_irn_ops_t sparc_irn_ops = {
get_sparc_in_req,
sparc_classify,
sparc_get_frame_entity,
sparc_set_frame_entity,
sparc_set_frame_offset,
sparc_get_sp_bias,
NULL, /* get_inverse */
......
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