[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 07/20] tcg-arm: Fold epilogue into INDEX_op_exit_
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v3 07/20] tcg-arm: Fold epilogue into INDEX_op_exit_tb |
Date: |
Thu, 28 Mar 2013 08:32:48 -0700 |
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 <address@hidden>
---
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.4
- [Qemu-devel] [PATCH v3 01/20] tcg-arm: Use bic to implement and with constant, (continued)
[Qemu-devel] [PATCH v3 03/20] tcg-arm: Allow constant first argument to sub, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 06/20] tcg-arm: Improve constant generation, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 07/20] tcg-arm: Fold epilogue into INDEX_op_exit_tb,
Richard Henderson <=
[Qemu-devel] [PATCH v3 08/20] tcg-arm: Implement deposit for armv7, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 09/20] tcg-arm: Implement division instructions, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 10/20] tcg-arm: Use TCG_REG_TMP name for the tcg temporary, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 11/20] tcg-arm: Use R12 for the tcg temporary, Richard Henderson, 2013/03/28
[Qemu-devel] [PATCH v3 12/20] tcg-arm: Cleanup multiply subroutines, Richard Henderson, 2013/03/28