qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 01/18] tcg-arm: Fix local stack frame


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v4 01/18] tcg-arm: Fix local stack frame
Date: Sat, 30 Mar 2013 21:14:16 +0000

On 30 March 2013 20:43, Richard Henderson <address@hidden> wrote:
>  static void tcg_target_qemu_prologue(TCGContext *s)
>  {
> -    /* Calling convention requires us to save r4-r11 and lr;
> -     * save also r12 to maintain stack 8-alignment.
> -     */
> +    int frame_size;
>
> +    /* Calling convention requires us to save r4-r11 and lr; save also r12
> +       to maintain stack 8-alignment.  */
>      /* stmdb sp!, { r4 - r12, lr } */
>      tcg_out32(s, (COND_AL << 28) | 0x092d5ff0);
>
> +    /* Allocate the local stack frame.  */
> +    frame_size = TCG_STATIC_CALL_ARGS_SIZE;
> +    frame_size += CPU_TEMP_BUF_NLONGS * sizeof(long);
> +    tcg_out_dat_rI(s, COND_AL, ARITH_SUB, TCG_REG_CALL_STACK,
> +                   TCG_REG_CALL_STACK, frame_size, 1);

If you're doing a sub sp, sp, #n anyway, you might as well
add 4 to that and drop the save/load of r12 from the stmdb/ldmia.
It was only in there to save having an extra sub/add insn.

> +    tcg_set_frame(s, TCG_REG_CALL_STACK, TCG_STATIC_CALL_ARGS_SIZE,
> +                  CPU_TEMP_BUF_NLONGS * sizeof(long));
> +
>      tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]);
>
>      tcg_out_bx(s, COND_AL, tcg_target_call_iarg_regs[1]);
>      tb_ret_addr = s->code_ptr;
>
> +    /* Epilogue.  We branch here via tb_ret_addr.  */
> +    tcg_out_dat_rI(s, COND_AL, ARITH_ADD, TCG_REG_CALL_STACK,
> +                   TCG_REG_CALL_STACK, frame_size, 1);
> +
>      /* ldmia sp!, { r4 - r12, pc } */
>      tcg_out32(s, (COND_AL << 28) | 0x08bd9ff0);
>  }
> --
> 1.8.1.4
>
>

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]