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

put stack_layout into beirg instead of be_abi datastructures

[r27695]
parent 2922c6d1
......@@ -637,7 +637,7 @@ void amd64_gen_routine(const amd64_code_gen_t *cg, ir_graph *irg)
blk_sched = be_create_block_schedule(irg);
be_dbg_method_begin(entity, be_abi_get_stack_layout(be_get_irg_abi(cg->irg)));
be_dbg_method_begin(entity);
be_gas_emit_function_prolog(entity, 4);
irg_block_walk_graph(irg, amd64_gen_labels, NULL, NULL);
......
......@@ -1114,7 +1114,7 @@ void arm_gen_routine(const arm_code_gen_t *arm_cg, ir_graph *irg)
arm_register_emitters();
be_dbg_method_begin(entity, be_abi_get_stack_layout(be_get_irg_abi(cg->irg)));
be_dbg_method_begin(entity);
/* create the block schedule */
blk_sched = be_create_block_schedule(irg);
......
......@@ -42,7 +42,7 @@ void be_dbg_so(const char *filename);
void be_dbg_main_program(void);
/** debug for a method begin */
void be_dbg_method_begin(const ir_entity *ent, const be_stack_layout_t *layout);
void be_dbg_method_begin(const ir_entity *ent);
/** debug for a method end */
void be_dbg_method_end(void);
......
......@@ -48,7 +48,7 @@ typedef struct debug_ops {
void (*main_program)(dbg_handle *handle);
/** dumps the stabs for a method begin */
void (*method_begin)(dbg_handle *handle, const ir_entity *ent, const be_stack_layout_t *layout);
void (*method_begin)(dbg_handle *handle, const ir_entity *ent);
/** dumps the stabs for a method end */
void (*method_end)(dbg_handle *handle);
......
......@@ -57,7 +57,7 @@ typedef union _be_abi_call_flags_t be_abi_call_flags_t;
typedef struct _be_abi_callbacks_t be_abi_callbacks_t;
typedef struct _be_abi_call_t be_abi_call_t;
typedef struct _be_abi_irg_t be_abi_irg_t;
typedef struct _be_stack_layout_t be_stack_layout_t;
typedef struct be_stack_layout_t be_stack_layout_t;
typedef struct _be_dom_front_info_t be_dom_front_info_t;
......
......@@ -110,8 +110,6 @@ struct _be_abi_irg_t {
ir_node **calls; /**< flexible array containing all be_Call nodes */
arch_register_req_t *sp_req;
be_stack_layout_t frame; /**< The stack frame model. */
};
static heights_t *ir_heights;
......@@ -1789,6 +1787,7 @@ static void modify_irg(be_abi_irg_t *env)
ir_node *mem;
ir_type *method_type = get_entity_type(get_irg_entity(irg));
struct obstack *obst = be_get_be_obst(irg);
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
int n_params;
int i, n;
......@@ -1892,7 +1891,8 @@ static void modify_irg(be_abi_irg_t *env)
}
bet_type = call->cb->get_between_type(env->cb);
stack_frame_init(&env->frame, arg_type, bet_type, get_irg_frame_type(irg), arch_env->stack_dir, param_map);
stack_frame_init(stack_layout, arg_type, bet_type,
get_irg_frame_type(irg), arch_env->stack_dir, param_map);
/* Count the register params and add them to the number of Projs for the RegParams node */
for (i = 0; i < n_params; ++i) {
......@@ -1964,7 +1964,7 @@ static void modify_irg(be_abi_irg_t *env)
set_irg_initial_mem(irg, mem);
/* Generate the Prologue */
fp_reg = call->cb->prologue(env->cb, &mem, env->regs, &env->frame.initial_bias);
fp_reg = call->cb->prologue(env->cb, &mem, env->regs, &stack_layout->initial_bias);
/* do the stack allocation BEFORE the barrier, or spill code
might be added before it */
......@@ -2374,14 +2374,7 @@ void be_abi_set_non_ignore_regs(be_abi_irg_t *abi, const arch_register_class_t *
}
}
/* Returns the stack layout from a abi environment. */
const be_stack_layout_t *be_abi_get_stack_layout(const be_abi_irg_t *abi)
{
return &abi->frame;
}
/*
_____ _ ____ _ _
| ___(_)_ __ / ___|| |_ __ _ ___| | __
| |_ | \ \/ / \___ \| __/ _` |/ __| |/ /
......@@ -2486,6 +2479,7 @@ static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias)
int omit_fp = env->call->flags.bits.try_omit_fp;
ir_node *irn;
int wanted_bias = real_bias;
be_stack_layout_t *layout = be_get_irg_stack_layout(env->irg);
sched_foreach(bl, irn) {
int ofs;
......@@ -2498,7 +2492,7 @@ static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias)
ir_entity *ent = arch_get_frame_entity(irn);
if (ent != NULL) {
int bias = omit_fp ? real_bias : 0;
int offset = get_stack_entity_offset(&env->frame, ent, bias);
int offset = get_stack_entity_offset(layout, ent, bias);
arch_set_frame_offset(irn, offset);
DBG((dbg, LEVEL_2, "%F has offset %d (including bias %d)\n",
ent, offset, bias));
......@@ -2523,7 +2517,7 @@ static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias)
} else {
if (be_get_IncSP_align(irn)) {
/* patch IncSP to produce an aligned stack pointer */
ir_type *between_type = env->frame.between_type;
ir_type *between_type = layout->between_type;
int between_size = get_type_size_bytes(between_type);
int alignment = 1 << env->arch_env->stack_alignment;
int delta = (real_bias + ofs + between_size) & (alignment - 1);
......@@ -2584,6 +2578,7 @@ static void lower_outer_frame_sels(ir_node *sel, void *ctx)
ir_node *ptr;
ir_entity *ent;
ir_type *owner;
be_stack_layout_t *layout;
if (! is_Sel(sel))
return;
......@@ -2592,9 +2587,10 @@ static void lower_outer_frame_sels(ir_node *sel, void *ctx)
owner = get_entity_owner(ent);
ptr = get_Sel_ptr(sel);
if (owner == env->frame.frame_type || owner == env->frame.arg_type) {
layout = be_get_irg_stack_layout(env->irg);
if (owner == layout->frame_type || owner == layout->arg_type) {
/* found access to outer frame or arguments */
int offset = get_stack_entity_offset(&env->frame, ent, 0);
int offset = get_stack_entity_offset(layout, ent, 0);
if (offset != 0) {
ir_node *bl = get_nodes_block(sel);
......@@ -2612,16 +2608,18 @@ static void lower_outer_frame_sels(ir_node *sel, void *ctx)
void be_abi_fix_stack_bias(be_abi_irg_t *env)
{
ir_graph *irg = env->irg;
be_stack_layout_t *stack_layout = be_get_irg_stack_layout(irg);
ir_type *frame_tp;
int i;
struct bias_walk bw;
stack_frame_compute_initial_offset(&env->frame);
// stack_layout_dump(stdout, frame);
stack_frame_compute_initial_offset(stack_layout);
// stack_layout_dump(stdout, stack_layout);
/* Determine the stack bias at the end of the start block. */
bw.start_block_bias = process_stack_bias(env, get_irg_start_block(irg), env->frame.initial_bias);
bw.between_size = get_type_size_bytes(env->frame.between_type);
bw.start_block_bias = process_stack_bias(env, get_irg_start_block(irg),
stack_layout->initial_bias);
bw.between_size = get_type_size_bytes(stack_layout->between_type);
/* fix the bias is all other blocks */
bw.env = env;
......
......@@ -210,40 +210,10 @@ ir_node *be_abi_get_ignore_irn(be_abi_irg_t *abi, const arch_register_t *reg);
#define be_abi_reg_map_get(map, reg) pmap_get((map), (void *) (reg))
#define be_abi_reg_map_set(map, reg, irn) pmap_insert((map), (void *) (reg), (irn))
/** The number of parts of the stack layout. */
#define N_FRAME_TYPES 3
/**
* This type describes the stack layout.
* The stack is divided into 3 parts:
* - arg_type: A struct type describing the stack arguments and it's order.
* - between_type: A struct type describing the stack layout between arguments
* and frame type. In architectures that put the return address
* automatically on the stack, the return address is put here.
* - frame_type: A class type describing the frame layout.
*/
struct _be_stack_layout_t {
ir_type *arg_type; /**< A type describing the stack argument layout. */
ir_type *between_type; /**< A type describing the "between" layout. */
ir_type *frame_type; /**< The frame type. */
ir_type *order[N_FRAME_TYPES]; /**< arg, between and frame types ordered. */
ir_entity **param_map; /**< An array mapping type parameters to arg_type entries */
int initial_offset; /**< the initial difference between stack pointer and frame pointer */
int initial_bias; /**< the initial stack bias */
int stack_dir; /**< -1 for decreasing, 1 for increasing. */
};
/**
* Returns the stack layout from a abi environment.
*/
const be_stack_layout_t *be_abi_get_stack_layout(const be_abi_irg_t *abi);
/**
* Returns non-zero if the ABI has omitted the frame pointer in
* the current graph.
*/
int be_abi_omit_fp(const be_abi_irg_t *abi);
#endif /* FIRM_BE_BEABI_H */
#endif
......@@ -50,10 +50,10 @@ void be_dbg_main_program(void)
handle->ops->main_program(handle);
}
void be_dbg_method_begin(const ir_entity *ent, const be_stack_layout_t *layout)
void be_dbg_method_begin(const ir_entity *ent)
{
if (handle->ops->method_begin)
handle->ops->method_begin(handle, ent, layout);
handle->ops->method_begin(handle, ent);
}
void be_dbg_method_end(void)
......
......@@ -43,6 +43,31 @@ void be_invalidate_dom_front(ir_graph *irg);
*/
void be_free_birg(ir_graph *irg);
/** The number of parts of the stack layout. */
#define N_FRAME_TYPES 3
/**
* This type describes the stack layout.
* The stack is divided into 3 parts:
* - arg_type: A struct type describing the stack arguments and it's order.
* - between_type: A struct type describing the stack layout between arguments
* and frame type. In architectures that put the return address
* automatically on the stack, the return address is put here.
* - frame_type: A class type describing the frame layout.
*/
struct be_stack_layout_t {
ir_type *arg_type; /**< A type describing the stack argument layout. */
ir_type *between_type; /**< A type describing the "between" layout. */
ir_type *frame_type; /**< The frame type. */
ir_type *order[N_FRAME_TYPES]; /**< arg, between and frame types ordered. */
ir_entity **param_map; /**< An array mapping type parameters to arg_type entries */
int initial_offset; /**< the initial difference between stack pointer and frame pointer */
int initial_bias; /**< the initial stack bias */
int stack_dir; /**< -1 for decreasing, 1 for increasing. */
};
/**
* An ir_graph with additional analysis data about this irg. Also includes some
* backend structures
......@@ -55,6 +80,7 @@ typedef struct be_irg_t {
ir_exec_freq *exec_freq;
be_dom_front_info_t *dom_front;
be_lv_t *lv;
be_stack_layout_t stack_layout;
struct obstack obst; /**< birg obstack (mainly used to keep
register constraints which we can't keep
in the irg obst, because it gets replace
......@@ -118,4 +144,9 @@ static inline struct obstack *be_get_be_obst(const ir_graph *irg)
return &birg->obst;
}
#endif /* FIRM_BE_BEIRG_H */
static inline be_stack_layout_t *be_get_irg_stack_layout(const ir_graph *irg)
{
return &be_birg_from_irg(irg)->stack_layout;
}
#endif
......@@ -683,12 +683,14 @@ static void stabs_set_dbg_info(dbg_handle *h, dbg_info *dbgi)
/**
* dump the stabs for a method begin
*/
static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent, const be_stack_layout_t *layout)
static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent)
{
stabs_handle *h = (stabs_handle *)handle;
ir_graph *irg = get_entity_irg(ent);
ir_type *mtp, *rtp;
unsigned type_num;
int i, n, between_size;
be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
h->cur_ent = ent;
h->layout = layout;
......
......@@ -2224,7 +2224,7 @@ void ia32_gen_routine(ia32_code_gen_t *ia32_cg, ir_graph *irg)
get_unique_label(pic_base_label, sizeof(pic_base_label), "PIC_BASE");
be_dbg_method_begin(entity, be_abi_get_stack_layout(be_get_irg_abi(cg->irg)));
be_dbg_method_begin(entity);
be_gas_emit_function_prolog(entity, ia32_cg_config.function_alignment);
/* we use links to point to target blocks */
......
......@@ -731,13 +731,14 @@ void sparc_gen_routine(const sparc_code_gen_t *cg, ir_graph *irg)
ir_node *last_block = NULL;
ir_entity *entity = get_irg_entity(irg);
int i, n;
(void) cg;
be_gas_elf_type_char = '#';
be_gas_object_file_format = OBJECT_FILE_FORMAT_ELF_SPARC;
/* register all emitter functions */
sparc_register_emitters();
be_dbg_method_begin(entity, be_abi_get_stack_layout(be_get_irg_abi(cg->irg)));
be_dbg_method_begin(entity);
/* create the block schedule. For now, we don't need it earlier. */
blk_sched = be_create_block_schedule(irg);
......
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