All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Artyom Tarasenko <atar4qemu@gmail.com>
Subject: Re: [PATCH for-6.2 1/2] target/sparc: Drop use of gen_io_end()
Date: Sun, 25 Jul 2021 10:00:30 +0100	[thread overview]
Message-ID: <e3c72904-7d45-3c72-375d-04cea0b62d0d@ilande.co.uk> (raw)
In-Reply-To: <20210724134902.7785-2-peter.maydell@linaro.org>

On 24/07/2021 14:49, Peter Maydell wrote:

> The gen_io_end() function is obsolete (as documented in
> docs/devel/tcg-icount.rst). Where an instruction is an I/O
> operation, the translator frontend should call gen_io_start()
> before generating the code which does the I/O, and then
> end the TB immediately after this insn.
> 
> Remove the calls to gen_io_end() in the SPARC frontend,
> and ensure that the insns which were calling it end the
> TB if they didn't do so already.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   target/sparc/translate.c | 25 ++++++++++---------------
>   1 file changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/target/sparc/translate.c b/target/sparc/translate.c
> index 11de5a49631..bb70ba17deb 100644
> --- a/target/sparc/translate.c
> +++ b/target/sparc/translate.c
> @@ -3401,7 +3401,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                           tcg_temp_free_i32(r_const);
>                           gen_store_gpr(dc, rd, cpu_dst);
>                           if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                            gen_io_end();
> +                            /* I/O operations in icount mode must end the TB */
> +                            dc->base.is_jmp = DISAS_EXIT;
>                           }
>                       }
>                       break;
> @@ -3454,7 +3455,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                           tcg_temp_free_i32(r_const);
>                           gen_store_gpr(dc, rd, cpu_dst);
>                           if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                            gen_io_end();
> +                            /* I/O operations in icount mode must end the TB */
> +                            dc->base.is_jmp = DISAS_EXIT;
>                           }
>                       }
>                       break;
> @@ -3588,7 +3590,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                           tcg_temp_free_ptr(r_tickptr);
>                           tcg_temp_free_i32(r_const);
>                           if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                            gen_io_end();
> +                            /* I/O operations in icount mode must end the TB */
> +                            dc->base.is_jmp = DISAS_EXIT;
>                           }
>                       }
>                       break;
> @@ -4582,7 +4585,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                                   }
>                                   gen_helper_wrpstate(cpu_env, cpu_tmp0);
>                                   if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                                    gen_io_end();
> +                                    /* I/O ops in icount mode must end the TB */
> +                                    dc->base.is_jmp = DISAS_EXIT;
>                                   }
>                                   dc->npc = DYNAMIC_PC;
>                                   break;
> @@ -4598,7 +4602,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                                   }
>                                   gen_helper_wrpil(cpu_env, cpu_tmp0);
>                                   if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                                    gen_io_end();
> +                                    /* I/O ops in icount mode must end the TB */
> +                                    dc->base.is_jmp = DISAS_EXIT;
>                                   }
>                                   break;
>                               case 9: // cwp
> @@ -4697,10 +4702,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                                       gen_helper_tick_set_limit(r_tickptr,
>                                                                 cpu_hstick_cmpr);
>                                       tcg_temp_free_ptr(r_tickptr);
> -                                    if (tb_cflags(dc->base.tb) &
> -                                           CF_USE_ICOUNT) {
> -                                        gen_io_end();
> -                                    }
>                                       /* End TB to handle timer interrupt */
>                                       dc->base.is_jmp = DISAS_EXIT;
>                                   }
> @@ -5327,9 +5328,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                                   gen_io_start();
>                               }
>                               gen_helper_done(cpu_env);
> -                            if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                                gen_io_end();
> -                            }
>                               goto jmp_insn;
>                           case 1:
>                               if (!supervisor(dc))
> @@ -5340,9 +5338,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
>                                   gen_io_start();
>                               }
>                               gen_helper_retry(cpu_env);
> -                            if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
> -                                gen_io_end();
> -                            }
>                               goto jmp_insn;
>                           default:
>                               goto illegal_insn;
> 

Thanks Peter, this is something that has been in the back of my mind as a TODO for a 
while but I haven't managed to get around to it. From what I can see the conversion 
looks good so:

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.


  reply	other threads:[~2021-07-25  9:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-24 13:49 [PATCH for-6.2 0/2] target/sparc: Drop use of gen_io_end() Peter Maydell
2021-07-24 13:49 ` [PATCH for-6.2 1/2] " Peter Maydell
2021-07-25  9:00   ` Mark Cave-Ayland [this message]
2021-07-24 13:49 ` [PATCH for-6.2 2/2] tcg: Drop gen_io_end() Peter Maydell
2021-07-24 19:07 ` [PATCH for-6.2 0/2] target/sparc: Drop use of gen_io_end() Richard Henderson
2021-07-24 20:27 ` Peter Maydell
2021-07-24 20:47   ` Richard Henderson
2021-07-25 15:00     ` Peter Maydell
2021-09-01  7:58 ` Peter Maydell
2021-09-01  8:12   ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3c72904-7d45-3c72-375d-04cea0b62d0d@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=atar4qemu@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.