diff mbox

[RFC,1/3] tcg/aarch64: Introduce and use jump to register

Message ID 20170607225212.23714-2-bobby.prani@gmail.com
State New
Headers show

Commit Message

Pranith Kumar June 7, 2017, 10:52 p.m. UTC
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 tcg/aarch64/tcg-target.inc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Richard Henderson June 8, 2017, 4:50 p.m. UTC | #1
On 06/07/2017 03:52 PM, Pranith Kumar wrote:
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
> ---
>   tcg/aarch64/tcg-target.inc.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
> index 1fa3bccc89..ab0a8caa03 100644
> --- a/tcg/aarch64/tcg-target.inc.c
> +++ b/tcg/aarch64/tcg-target.inc.c
> @@ -819,6 +819,12 @@ static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target)
>       tcg_out_insn(s, 3206, B, offset);
>   }
>   
> +static inline void tcg_out_goto_register(TCGContext *s, intptr_t target)
> +{
> +    tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, target);
> +    tcg_out_insn(s, 3207, BR, TCG_REG_TMP);
> +}
> +
>   static inline void tcg_out_goto_noaddr(TCGContext *s)
>   {
>       /* We pay attention here to not modify the branch target by reading from
> @@ -1364,10 +1370,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
>       case INDEX_op_exit_tb:
>           /* Reuse the zeroing that exists for goto_ptr.  */
>           if (a0 == 0) {
> -            tcg_out_goto(s, s->code_gen_epilogue);
> +            tcg_out_goto_register(s, (intptr_t)(s->code_gen_epilogue));

This pessimises the first 128MB of the buffer by not using a direct branch when 
it fits.  I think you should call the new function tcg_out_goto_long, and 
structure the function like tcg_out_call.


r~
diff mbox

Patch

diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
index 1fa3bccc89..ab0a8caa03 100644
--- a/tcg/aarch64/tcg-target.inc.c
+++ b/tcg/aarch64/tcg-target.inc.c
@@ -819,6 +819,12 @@  static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target)
     tcg_out_insn(s, 3206, B, offset);
 }
 
+static inline void tcg_out_goto_register(TCGContext *s, intptr_t target)
+{
+    tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, target);
+    tcg_out_insn(s, 3207, BR, TCG_REG_TMP);
+}
+
 static inline void tcg_out_goto_noaddr(TCGContext *s)
 {
     /* We pay attention here to not modify the branch target by reading from
@@ -1364,10 +1370,10 @@  static void tcg_out_op(TCGContext *s, TCGOpcode opc,
     case INDEX_op_exit_tb:
         /* Reuse the zeroing that exists for goto_ptr.  */
         if (a0 == 0) {
-            tcg_out_goto(s, s->code_gen_epilogue);
+            tcg_out_goto_register(s, (intptr_t)(s->code_gen_epilogue));
         } else {
             tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, a0);
-            tcg_out_goto(s, tb_ret_addr);
+            tcg_out_goto_register(s, (intptr_t)(tb_ret_addr));
         }
         break;