allocate spillslots at beginning/end of stackframe depending on omit_fp mode
authorMatthias Braun <matze@braunis.de>
Mon, 7 Mar 2011 19:05:11 +0000 (20:05 +0100)
committerMatthias Braun <matze@braunis.de>
Wed, 16 Mar 2011 17:52:43 +0000 (18:52 +0100)
ir/be/amd64/bearch_amd64.c
ir/be/arm/bearch_arm.c
ir/be/bespillslots.c
ir/be/bespillslots.h
ir/be/ia32/bearch_ia32.c
ir/be/sparc/bearch_sparc.c

index 167cbe5..40c133e 100644 (file)
@@ -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);
index dd03ae5..b301e61 100644 (file)
@@ -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);
index dd0f505..3a5c2c2 100644 (file)
@@ -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));
 
index 19b5df9..752813c 100644 (file)
@@ -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
index 0dd54ba..6112ed4 100644 (file)
@@ -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);
index b5a16a1..51606ba 100644 (file)
@@ -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);