From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFIx4-0008TT-Eh for qemu-devel@nongnu.org; Tue, 12 Mar 2013 02:44:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFIwv-00070k-Mq for qemu-devel@nongnu.org; Tue, 12 Mar 2013 02:44:46 -0400 Received: from mail-ie0-x22d.google.com ([2607:f8b0:4001:c03::22d]:56869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFIwv-00070Q-FF for qemu-devel@nongnu.org; Tue, 12 Mar 2013 02:44:37 -0400 Received: by mail-ie0-f173.google.com with SMTP id 9so5944636iec.4 for ; Mon, 11 Mar 2013 23:44:37 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Mon, 11 Mar 2013 23:43:49 -0700 Message-Id: <1363070631-21187-8-git-send-email-rth@twiddle.net> In-Reply-To: <1363070631-21187-1-git-send-email-rth@twiddle.net> References: <1363070631-21187-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH v2 7/9] tcg-arm: Fold epilogue into INDEX_op_exit_tb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jay.foad@gmail.com The epilogue on ARM is one pop instruction, that pops the return address into PC. Avoid the jump to jump for this case. Use the standard movi32 routine for loading the return value if it's easy. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 5333fad..88f5689 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -1559,7 +1559,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) #endif } -static uint8_t *tb_ret_addr; +static uint32_t tb_pop_ret; static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, const int *const_args) @@ -1569,17 +1569,15 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, switch (opc) { case INDEX_op_exit_tb: - { - uint8_t *ld_ptr = s->code_ptr; - if (args[0] >> 8) - tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0); - else - tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R0, 0, args[0]); - tcg_out_goto(s, COND_AL, (tcg_target_ulong) tb_ret_addr); - if (args[0] >> 8) { - *ld_ptr = (uint8_t) (s->code_ptr - ld_ptr) - 8; - tcg_out32(s, args[0]); - } + a0 = args[0]; + if (use_armv7_instructions || check_fit_imm(a0)) { + tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]); + tcg_out32(s, tb_pop_ret); + } else { + /* pc is always current address + 8, so 0 reads the word. */ + tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0); + tcg_out32(s, tb_pop_ret); + tcg_out32(s, args[0]); } break; case INDEX_op_goto_tb: @@ -2025,8 +2023,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) 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; /* ldmia sp!, { r4 - r12, pc } */ - tcg_out32(s, (COND_AL << 28) | 0x08bd9ff0); + tb_pop_ret = (COND_AL << 28) | 0x08bd9ff0; } -- 1.8.1.2