Commit 1894b7dd authored by Michael Beck's avatar Michael Beck
Browse files

- stack alignment is now power of two

[r19910]
parent 38aa2675
......@@ -359,7 +359,7 @@ static TEMPLATE_isa_t TEMPLATE_isa_template = {
&TEMPLATE_general_purpose_regs[REG_SP], /* stack pointer register */
&TEMPLATE_general_purpose_regs[REG_BP], /* base pointer register */
-1, /* stack direction */
1, /* stack alignment for calls */
2, /* power of two stack alignment for calls, 2^2 == 4 */
NULL, /* main environment */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
......
......@@ -746,7 +746,7 @@ static arm_isa_t arm_isa_template = {
&arm_gp_regs[REG_SP], /* stack pointer */
&arm_gp_regs[REG_R11], /* base pointer */
-1, /* stack direction */
1, /* stack alignment for calls */
2, /* power of two stack alignment for calls, 2^2 == 4 */
NULL, /* main environment */
7, /* spill costs */
5, /* reload costs */
......
......@@ -924,7 +924,7 @@ static ir_node *adjust_alloc(be_abi_irg_t *env, ir_node *alloc, ir_node *curr_sp
We cannot omit it. */
env->call->flags.bits.try_omit_fp = 0;
stack_alignment = env->arch_env->stack_alignment;
stack_alignment = 1 << env->arch_env->stack_alignment;
size = adjust_alloc_size(stack_alignment, size, irg, block, dbg);
new_alloc = be_new_AddSP(env->arch_env->sp, irg, block, curr_sp, size);
set_irn_dbg_info(new_alloc, dbg);
......@@ -993,7 +993,7 @@ static ir_node *adjust_free(be_abi_irg_t *env, ir_node *free, ir_node *curr_sp)
size = get_Free_size(free);
}
stack_alignment = env->arch_env->stack_alignment;
stack_alignment = 1 << env->arch_env->stack_alignment;
size = adjust_alloc_size(stack_alignment, size, irg, block, dbg);
/* The stack pointer will be modified in an unknown manner.
......@@ -2350,8 +2350,8 @@ static int process_stack_bias(be_abi_irg_t *env, ir_node *bl, int real_bias)
/* patch IncSP to produce an aligned stack pointer */
ir_type *between_type = env->frame->between_type;
int between_size = get_type_size_bytes(between_type);
int alignment = env->arch_env->stack_alignment;
int delta = (real_bias + ofs + between_size) % env->arch_env->stack_alignment;
int alignment = 1 << env->arch_env->stack_alignment;
int delta = (real_bias + ofs + between_size) & (alignment - 1);
assert(ofs >= 0);
if (delta > 0) {
be_set_IncSP_offset(irn, ofs + alignment - delta);
......
......@@ -543,13 +543,13 @@ struct arch_isa_if_t {
*/
struct arch_env_t {
const arch_isa_if_t *impl;
const arch_register_t *sp; /** The stack pointer register. */
const arch_register_t *bp; /** The base pointer register. */
int stack_dir; /** -1 for decreasing, 1 for increasing. */
int stack_alignment; /** stack alignment */
const be_main_env_t *main_env; /** the be main environment */
int spill_cost; /** cost for a be_Spill node */
int reload_cost; /** cost for a be_Reload node */
const arch_register_t *sp; /** The stack pointer register. */
const arch_register_t *bp; /** The base pointer register. */
int stack_dir; /** -1 for decreasing, 1 for increasing. */
int stack_alignment; /** power of 2 stack alignment */
const be_main_env_t *main_env; /** the be main environment */
int spill_cost; /** cost for a be_Spill node */
int reload_cost; /** cost for a be_Reload node */
};
#define arch_env_stack_dir(env) ((env)->stack_dir)
......
......@@ -1629,7 +1629,7 @@ static ia32_isa_t ia32_isa_template = {
&ia32_gp_regs[REG_ESP], /* stack pointer register */
&ia32_gp_regs[REG_EBP], /* base pointer register */
-1, /* stack direction */
16, /* stack alignment */
4, /* power of two stack alignment, 2^4 == 16 */
NULL, /* main environment */
7, /* costs for a spill instruction */
5, /* costs for a reload instruction */
......@@ -2179,7 +2179,7 @@ static const backend_params *ia32_get_libfirm_params(void) {
ia32_create_intrinsic_fkt,
&intrinsic_env, /* context for ia32_create_intrinsic_fkt */
NULL, /* will be set below */
NULL,
NULL /* will be set below */
};
ia32_setup_cg_config();
......@@ -2203,7 +2203,7 @@ static lc_opt_enum_int_var_t gas_var = {
static const lc_opt_table_entry_t ia32_options[] = {
LC_OPT_ENT_ENUM_INT("gasmode", "set the GAS compatibility mode", &gas_var),
LC_OPT_ENT_INT("stackalign", "set stack alignment for calls",
LC_OPT_ENT_INT("stackalign", "set power of two stack alignment for calls",
&ia32_isa_template.arch_env.stack_alignment),
LC_OPT_LAST
};
......
......@@ -584,7 +584,7 @@ static mips_isa_t mips_isa_template = {
&mips_gp_regs[REG_SP],
&mips_gp_regs[REG_FP],
-1, /* stack direction */
1, /* stack alignment for calls */
2, /* power of two stack alignment for calls, 2^2 == 4 */
NULL, /* main environment */
7, /* spill costs */
5, /* reload costs */
......
......@@ -640,7 +640,7 @@ static ppc32_isa_t ppc32_isa_template = {
&ppc32_gp_regs[REG_R1], /* stack pointer */
&ppc32_gp_regs[REG_R31], /* base pointer */
-1, /* stack is decreasing */
1, /* call stack alignment */
2, /* power of two stack alignment for calls, 2^2 == 4 */
NULL, /* main environment */
7, /* spill costs */
5, /* reload costs */
......
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