diff mbox series

[RFC,v2,31/38] target/xtensa: fetch code with translator_ld

Message ID 20181209193749.12277-32-cota@braap.org (mailing list archive)
State New, archived
Headers show
Series Plugin support | expand

Commit Message

Emilio Cota Dec. 9, 2018, 7:37 p.m. UTC
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 target/xtensa/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alex Bennée Feb. 25, 2019, 2:54 p.m. UTC | #1
Emilio G. Cota <cota@braap.org> writes:

> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
>  target/xtensa/translate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
> index 46e1338448..c140742562 100644
> --- a/target/xtensa/translate.c
> +++ b/target/xtensa/translate.c
> @@ -882,7 +882,7 @@ static inline unsigned xtensa_op0_insn_len(DisasContext *dc, uint8_t op0)
>  static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
>  {
>      xtensa_isa isa = dc->config->isa;
> -    unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)};
> +    unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)};
>      unsigned len = xtensa_op0_insn_len(dc, b[0]);
>      xtensa_format fmt;
>      int slot, slots;
> @@ -914,7 +914,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
>                        dc->pc);
>      }
>      for (i = 1; i < len; ++i) {
> -        b[i] = cpu_ldub_code(env, dc->pc + i);
> +        b[i] = translator_ldub(env, dc->pc + i);
>      }
>      xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len);
>      fmt = xtensa_format_decode(isa, dc->insnbuf);

There is also:

  static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)
  {
      uint8_t b0 = cpu_ldub_code(env, dc->pc);
      return xtensa_op0_insn_len(dc, b0);
  }

Or is this usage a re-read of something we've already got?

--
Alex Bennée
Max Filippov March 4, 2019, 2:36 a.m. UTC | #2
On Mon, Feb 25, 2019 at 6:55 AM Alex Bennée <alex.bennee@linaro.org> wrote:
> Emilio G. Cota <cota@braap.org> writes:
> > Signed-off-by: Emilio G. Cota <cota@braap.org>
> > ---
> >  target/xtensa/translate.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
> > index 46e1338448..c140742562 100644
> > --- a/target/xtensa/translate.c
> > +++ b/target/xtensa/translate.c
> > @@ -882,7 +882,7 @@ static inline unsigned xtensa_op0_insn_len(DisasContext *dc, uint8_t op0)
> >  static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
> >  {
> >      xtensa_isa isa = dc->config->isa;
> > -    unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)};
> > +    unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)};
> >      unsigned len = xtensa_op0_insn_len(dc, b[0]);
> >      xtensa_format fmt;
> >      int slot, slots;
> > @@ -914,7 +914,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
> >                        dc->pc);
> >      }
> >      for (i = 1; i < len; ++i) {
> > -        b[i] = cpu_ldub_code(env, dc->pc + i);
> > +        b[i] = translator_ldub(env, dc->pc + i);
> >      }
> >      xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len);
> >      fmt = xtensa_format_decode(isa, dc->insnbuf);
>
> There is also:
>
>   static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)
>   {
>       uint8_t b0 = cpu_ldub_code(env, dc->pc);
>       return xtensa_op0_insn_len(dc, b0);
>   }
>
> Or is this usage a re-read of something we've already got?

FWIW xtensa_insn_len is used to look into the instruction that
follows the one that has just been translated, but it may only
touch the same page as the last translated instruction.
diff mbox series

Patch

diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 46e1338448..c140742562 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -882,7 +882,7 @@  static inline unsigned xtensa_op0_insn_len(DisasContext *dc, uint8_t op0)
 static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
 {
     xtensa_isa isa = dc->config->isa;
-    unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)};
+    unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)};
     unsigned len = xtensa_op0_insn_len(dc, b[0]);
     xtensa_format fmt;
     int slot, slots;
@@ -914,7 +914,7 @@  static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
                       dc->pc);
     }
     for (i = 1; i < len; ++i) {
-        b[i] = cpu_ldub_code(env, dc->pc + i);
+        b[i] = translator_ldub(env, dc->pc + i);
     }
     xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len);
     fmt = xtensa_format_decode(isa, dc->insnbuf);