On 30 March 2013 20:43, Richard Henderson <[email protected]> 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