[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 17/26] tcg/arm: Implement goto_ptr
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v7 17/26] tcg/arm: Implement goto_ptr |
Date: |
Fri, 26 May 2017 14:16:29 -0700 |
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/arm/tcg-target.h | 2 +-
tcg/arm/tcg-target.inc.c | 25 +++++++++++++++++++++----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h
index c114df7..5ef1086 100644
--- a/tcg/arm/tcg-target.h
+++ b/tcg/arm/tcg-target.h
@@ -123,7 +123,7 @@ extern bool use_idiv_instructions;
#define TCG_TARGET_HAS_mulsh_i32 0
#define TCG_TARGET_HAS_div_i32 use_idiv_instructions
#define TCG_TARGET_HAS_rem_i32 0
-#define TCG_TARGET_HAS_goto_ptr 0
+#define TCG_TARGET_HAS_goto_ptr 1
enum {
TCG_AREG0 = TCG_REG_R6,
diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c
index 590c57d..9f5cb66 100644
--- a/tcg/arm/tcg-target.inc.c
+++ b/tcg/arm/tcg-target.inc.c
@@ -1655,8 +1655,14 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode
opc,
switch (opc) {
case INDEX_op_exit_tb:
- tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]);
- tcg_out_goto(s, COND_AL, tb_ret_addr);
+ /* Reuse the zeroing that exists for goto_ptr. */
+ a0 = args[0];
+ if (a0 == 0) {
+ tcg_out_goto(s, COND_AL, s->code_gen_epilogue);
+ } else {
+ tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]);
+ tcg_out_goto(s, COND_AL, tb_ret_addr);
+ }
break;
case INDEX_op_goto_tb:
if (s->tb_jmp_insn_offset) {
@@ -1671,6 +1677,9 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode
opc,
}
s->tb_jmp_reset_offset[args[0]] = tcg_current_code_size(s);
break;
+ case INDEX_op_goto_ptr:
+ tcg_out_bx(s, COND_AL, args[0]);
+ break;
case INDEX_op_br:
tcg_out_goto_label(s, COND_AL, arg_label(args[0]));
break;
@@ -1961,6 +1970,7 @@ static const TCGTargetOpDef arm_op_defs[] = {
{ INDEX_op_exit_tb, { } },
{ INDEX_op_goto_tb, { } },
{ INDEX_op_br, { } },
+ { INDEX_op_goto_ptr, { "r" } },
{ INDEX_op_ld8u_i32, { "r", "r" } },
{ INDEX_op_ld8s_i32, { "r", "r" } },
@@ -2136,9 +2146,16 @@ 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;
- /* Epilogue. We branch here via tb_ret_addr. */
+ /*
+ * Return path for goto_ptr. Set return value to 0, a-la exit_tb,
+ * and fall through to the rest of the epilogue.
+ */
+ s->code_gen_epilogue = s->code_ptr;
+ tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0);
+
+ /* TB epilogue */
+ tb_ret_addr = s->code_ptr;
tcg_out_dat_rI(s, COND_AL, ARITH_ADD, TCG_REG_CALL_STACK,
TCG_REG_CALL_STACK, stack_addend, 1);
--
2.9.4
- [Qemu-devel] [PATCH v7 04/26] tcg: Introduce goto_ptr opcode and tcg_gen_lookup_and_goto_ptr, (continued)
- [Qemu-devel] [PATCH v7 04/26] tcg: Introduce goto_ptr opcode and tcg_gen_lookup_and_goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 07/26] target/arm: optimize indirect branches, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 08/26] target/i386: introduce gen_jr helper to generate lookup_and_goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 09/26] target/i386: optimize cross-page direct jumps in softmmu, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 10/26] target/i386: optimize indirect branches, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 12/26] tcg/ppc: Implement goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 11/26] tb-hash: improve tb_jmp_cache hash function in user mode, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 15/26] tcg/s390: Implement goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 14/26] tcg/sparc: Implement goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 13/26] tcg/aarch64: Implement goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 17/26] tcg/arm: Implement goto_ptr,
Richard Henderson <=
- [Qemu-devel] [PATCH v7 19/26] target/s390: Use tcg_gen_lookup_and_goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 16/26] tcg/arm: Clarify tcg_out_bx for arm4 host, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 20/26] target/hppa: Use tcg_gen_lookup_and_goto_ptr, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 21/26] target/aarch64: optimize cross-page direct jumps in softmmu, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 22/26] target/aarch64: optimize indirect branches, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 23/26] target/mips: optimize cross-page direct jumps in softmmu, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 24/26] target/mips: optimize indirect branches, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 25/26] target/alpha: Implement WTINT inline, Richard Henderson, 2017/05/26
- [Qemu-devel] [PATCH v7 26/26] target/alpha: Use goto_tb for fallthru between TBs, Richard Henderson, 2017/05/26