All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Yoshinori Sato" <yoshinori.sato@nifty.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 2/3] target/sh4: Hold alignment as DisasContext::mo_align
Date: Wed, 13 May 2026 08:54:36 +0200	[thread overview]
Message-ID: <20260513065438.8680-3-philmd@linaro.org> (raw)
In-Reply-To: <20260513065438.8680-1-philmd@linaro.org>

Hold the alignment in DisasContext::mo_align,
initializing it once in TranslatorOps::init_disas_context().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sh4/translate.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 3ddd4f612e4..5957f294c22 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -39,6 +39,7 @@ typedef struct DisasContext {
     uint32_t tbflags;  /* should stay unmodified during the TB translation */
     uint32_t envflags; /* should stay in sync with env->flags using TCG ops */
     int memidx;
+    MemOp mo_align;
     int gbank;
     int fbank;
     uint32_t delayed_pc;
@@ -51,10 +52,10 @@ typedef struct DisasContext {
 
 #if defined(CONFIG_USER_ONLY)
 #define IS_USER(ctx) 1
-#define UNALIGN(C)   (ctx->tbflags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN)
+#define UNALIGN(C)   ctx->mo_align
 #else
 #define IS_USER(ctx) (!(ctx->tbflags & (1u << SR_MD)))
-#define UNALIGN(C)   MO_UNALN
+#define UNALIGN(C)   ctx->mo_align
 #endif
 
 /* Target-specific values for ctx->base.is_jmp.  */
@@ -2225,6 +2226,9 @@ static void sh4_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
             return;
         }
     }
+    ctx->mo_align = (ctx->tbflags & TB_FLAG_UNALIGN) ? MO_UNALN : MO_ALIGN;
+#else /* !CONFIG_USER_ONLY */
+    ctx->mo_align = MO_UNALN;
 #endif
 
     /* Since the ISA is fixed-width, we can bound by the number
-- 
2.53.0



  parent reply	other threads:[~2026-05-13  6:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13  6:54 [PATCH 0/3] target/sh4: Re-allow unaligned access on system emulation Philippe Mathieu-Daudé
2026-05-13  6:54 ` [PATCH 1/3] " Philippe Mathieu-Daudé
2026-05-13 18:24   ` Richard Henderson
2026-05-13 18:34     ` Guenter Roeck
2026-05-14  3:11       ` yoshinori.sato
2026-05-13  6:54 ` Philippe Mathieu-Daudé [this message]
2026-05-13  6:54 ` [PATCH 3/3] target/sh4: Inline UNALIGN() macro Philippe Mathieu-Daudé

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=20260513065438.8680-3-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=yoshinori.sato@nifty.com \
    /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.