Commit 0b898220 authored by Matthias Braun's avatar Matthias Braun
Browse files

allocate spillslots at beginning/end of stackframe depending on omit_fp mode

parent 07615f9f
......@@ -237,11 +237,13 @@ static void amd64_collect_frame_entity_nodes(ir_node *node, void *data)
static void amd64_after_ra(ir_graph *irg)
{
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
bool at_begin = stack_layout->sp_relative ? true : false;
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
/* create and coalesce frame entities */
irg_walk_graph(irg, NULL, amd64_collect_frame_entity_nodes, fec_env);
be_assign_entities(fec_env, amd64_set_frame_entity);
be_assign_entities(fec_env, amd64_set_frame_entity, at_begin);
be_free_frame_entity_coalescer(fec_env);
irg_block_walk_graph(irg, NULL, amd64_after_ra_walker, NULL);
......
......@@ -269,10 +269,12 @@ static void arm_set_frame_entity(ir_node *node, ir_entity *entity)
static void arm_after_ra(ir_graph *irg)
{
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
bool at_begin = stack_layout->sp_relative ? true : false;
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
irg_walk_graph(irg, NULL, arm_collect_frame_entity_nodes, fec_env);
be_assign_entities(fec_env, arm_set_frame_entity);
be_assign_entities(fec_env, arm_set_frame_entity, at_begin);
be_free_frame_entity_coalescer(fec_env);
irg_block_walk_graph(irg, NULL, arm_after_ra_walker, NULL);
......
......@@ -74,6 +74,8 @@ struct be_fec_env_t {
affinity_edge_t **affinity_edges;
set *memperms;
set_frame_entity_func set_frame_entity;
bool at_begin; /**< frame entities should be allocate at
the beginning of the stackframe */
};
/** Compare 2 affinity edges (used in quicksort) */
......@@ -522,12 +524,10 @@ static memperm_t *get_memperm(be_fec_env_t *env, ir_node *block)
static ir_entity* create_stack_entity(be_fec_env_t *env, spill_slot_t *slot)
{
ir_graph *irg = env->irg;
ir_type *frame = get_irg_frame_type(irg);
/* TODO: backend should be able to specify wether we want spill slots
* at begin or end of frame */
int at_start = 1;
ir_entity *res = frame_alloc_area(frame, slot->size, slot->align, at_start);
ir_graph *irg = env->irg;
ir_type *frame = get_irg_frame_type(irg);
ir_entity *res = frame_alloc_area(frame, slot->size, slot->align,
env->at_begin);
/* adjust size of the entity type... */
ir_type *enttype = get_entity_type(res);
......@@ -783,9 +783,11 @@ void be_free_frame_entity_coalescer(be_fec_env_t *env)
}
void be_assign_entities(be_fec_env_t *env,
set_frame_entity_func set_frame_entity)
set_frame_entity_func set_frame_entity,
bool alloc_entities_at_begin)
{
env->set_frame_entity = set_frame_entity;
env->at_begin = alloc_entities_at_begin;
stat_ev_dbl("spillslots", set_count(env->spills));
......
......@@ -27,6 +27,7 @@
#ifndef FIRM_BE_BESPILLSLOTS_H
#define FIRM_BE_BESPILLSLOTS_H
#include <stdbool.h>
#include "beirg.h"
typedef struct be_fec_env_t be_fec_env_t;
......@@ -60,6 +61,7 @@ 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, set_frame_entity_func set_frame);
void be_assign_entities(be_fec_env_t *env, set_frame_entity_func set_frame,
bool alloc_entities_at_begin);
#endif
......@@ -1328,11 +1328,13 @@ need_stackent:
*/
static void ia32_after_ra(ir_graph *irg)
{
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
bool at_begin = stack_layout->sp_relative ? true : false;
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
/* create and coalesce frame entities */
irg_walk_graph(irg, NULL, ia32_collect_frame_entity_nodes, fec_env);
be_assign_entities(fec_env, ia32_set_frame_entity);
be_assign_entities(fec_env, ia32_set_frame_entity, at_begin);
be_free_frame_entity_coalescer(fec_env);
irg_block_walk_graph(irg, NULL, ia32_after_ra_walker, NULL);
......
......@@ -281,10 +281,12 @@ static void sparc_set_frame_entity(ir_node *node, ir_entity *entity)
static void sparc_after_ra(ir_graph *irg)
{
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
bool at_begin = stack_layout->sp_relative ? true : false;
be_fec_env_t *fec_env = be_new_frame_entity_coalescer(irg);
irg_walk_graph(irg, NULL, sparc_collect_frame_entity_nodes, fec_env);
be_assign_entities(fec_env, sparc_set_frame_entity);
be_assign_entities(fec_env, sparc_set_frame_entity, at_begin);
be_free_frame_entity_coalescer(fec_env);
irg_block_walk_graph(irg, NULL, sparc_after_ra_walker, NULL);
......
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