public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups
@ 2026-01-15 11:33 Paolo Bonzini
  2026-01-15 11:33 ` [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1 Paolo Bonzini
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

Some fixes for AVX (accepting instructions that don't exist), and 
more code cleanups for both historic and new code in the x86 TCG
frontend.

Paolo Bonzini (6):
  target/i386/tcg: fix a few instructions that do not support VEX.L=1
  target/i386/tcg: fix typo in dpps/dppd instructions
  target/i386/tcg: remove dead constants
  target/i386/tcg: merge decode_modrm and decode_modrm_address split
  target/i386/tcg: replace havesib variable with the SIB byte itself
  target/i386/tcg: cleanup #ifdef TARGET_X86_64

 target/i386/tcg/translate.c      | 35 +++----------
 target/i386/tcg/decode-new.c.inc | 85 +++++++++++++-------------------
 target/i386/tcg/emit.c.inc       | 22 ++++++---
 3 files changed, 54 insertions(+), 88 deletions(-)

-- 
2.52.0



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-19  0:56   ` Richard Henderson
  2026-01-15 11:33 ` [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions Paolo Bonzini
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson, qemu-stable

Match the contents of table 2-17 ("#UD Exception and VEX.L Field Encoding")
in the SDM, for instruction in exception class 5.  They were incorrectly
accepting 256-bit versions that do not exist.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 09e3d8884cf..e44b92710cf 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -628,7 +628,7 @@ static void decode_0F7E(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
     static const X86OpEntry opcodes_0F7E[4] = {
         X86_OP_ENTRY3(MOVD_from,  E,y, None,None, P,y, vex5 mmx),
         X86_OP_ENTRY3(MOVD_from,  E,y, None,None, V,y, vex5),
-        X86_OP_ENTRY3(MOVQ,       V,x, None,None, W,q, vex5),  /* wrong dest Vy on SDM! */
+        X86_OP_ENTRY3(MOVQ,       V,dq,None,None, W,q, vex5),  /* wrong dest Vq on SDM! */
         {},
     };
     *entry = *decode_by_prefix(s, opcodes_0F7E);
@@ -693,7 +693,7 @@ static void decode_0FD6(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
 {
     static const X86OpEntry movq[4] = {
         {},
-        X86_OP_ENTRY3(MOVQ,    W,x,  None, None, V,q, vex5),
+        X86_OP_ENTRY3(MOVQ,    W,dq, None, None, V,q, vex5),
         X86_OP_ENTRY3(MOVq_dq, V,dq, None, None, N,q),
         X86_OP_ENTRY3(MOVq_dq, P,q,  None, None, U,q),
     };
@@ -1102,7 +1102,7 @@ static void decode_0F12(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
     };
     static const X86OpEntry opcodes_0F12_reg[4] = {
         X86_OP_ENTRY3(VMOVHLPS,  V,dq, H,dq,       U,dq, vex7),
-        X86_OP_ENTRY3(VMOVLPx,   W,x,  H,x,        U,q,  vex5), /* MOVLPD */
+        X86_OP_ENTRY3(VMOVLPx,   W,dq, H,dq,       U,q,  vex5), /* MOVLPD */
         X86_OP_ENTRY3(VMOVSLDUP, V,x,  None,None,  U,x,  vex4 cpuid(SSE3)),
         X86_OP_ENTRY3(VMOVDDUP,  V,x,  None,None,  U,x,  vex5 cpuid(SSE3)),
     };
@@ -1465,7 +1465,7 @@ static const X86OpEntry opcodes_0F[256] = {
     [0x6b] = X86_OP_ENTRY3(PACKSSDW,   V,x, H,x, W,x,  vex4 mmx avx2_256 p_00_66),
     [0x6c] = X86_OP_ENTRY3(PUNPCKLQDQ, V,x, H,x, W,x,  vex4 p_66 avx2_256),
     [0x6d] = X86_OP_ENTRY3(PUNPCKHQDQ, V,x, H,x, W,x,  vex4 p_66 avx2_256),
-    [0x6e] = X86_OP_ENTRY3(MOVD_to,    V,x, None,None, E,y, vex5 mmx p_00_66),  /* wrong dest Vy on SDM! */
+    [0x6e] = X86_OP_ENTRY3(MOVD_to,    V,dq,None,None, E,y, vex5 mmx p_00_66),  /* wrong dest Vy on SDM! */
     [0x6f] = X86_OP_GROUP0(0F6F),
 
     [0x78] = X86_OP_GROUP0(0F78),
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
  2026-01-15 11:33 ` [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1 Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-19  0:56   ` Richard Henderson
  2026-01-15 11:33 ` [PATCH 3/6] target/i386/tcg: remove dead constants Paolo Bonzini
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

Their gen_* functions were incorrectly named gen_VDDPS and gen_VDDPD.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 4 ++--
 target/i386/tcg/emit.c.inc       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index e44b92710cf..b00ea3e86e8 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -977,8 +977,8 @@ static const X86OpEntry opcodes_0F3A[256] = {
     [0x21] = X86_OP_GROUP0(VINSERTPS),
     [0x22] = X86_OP_ENTRY4(PINSR,      V,dq, H,dq, E,y,  vex5 cpuid(SSE41) p_66),
 
-    [0x40] = X86_OP_ENTRY4(VDDPS,      V,x,  H,x,  W,x,  vex2 cpuid(SSE41) p_66),
-    [0x41] = X86_OP_ENTRY4(VDDPD,      V,dq, H,dq, W,dq, vex2 cpuid(SSE41) p_66),
+    [0x40] = X86_OP_ENTRY4(VDPPS,      V,x,  H,x,  W,x,  vex2 cpuid(SSE41) p_66),
+    [0x41] = X86_OP_ENTRY4(VDPPD,      V,dq, H,dq, W,dq, vex2 cpuid(SSE41) p_66),
     [0x42] = X86_OP_ENTRY4(VMPSADBW,   V,x,  H,x,  W,x,  vex2 cpuid(SSE41) avx2_256 p_66),
     [0x44] = X86_OP_ENTRY4(PCLMULQDQ,  V,dq, H,dq, W,dq, vex4 cpuid(PCLMULQDQ) p_66),
     [0x46] = X86_OP_ENTRY4(VPERM2x128, V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX2) p_66),
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index bc3a07f972c..f5f12e48b77 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -788,9 +788,9 @@ static void gen_##uname(DisasContext *s, X86DecodedInsn *decode)
 BINARY_IMM_SSE(VBLENDPD,   blendpd)
 BINARY_IMM_SSE(VBLENDPS,   blendps)
 BINARY_IMM_SSE(VPBLENDW,   pblendw)
-BINARY_IMM_SSE(VDDPS,      dpps)
+BINARY_IMM_SSE(VDPPS,      dpps)
 #define gen_helper_dppd_ymm NULL
-BINARY_IMM_SSE(VDDPD,      dppd)
+BINARY_IMM_SSE(VDPPD,      dppd)
 BINARY_IMM_SSE(VMPSADBW,   mpsadbw)
 BINARY_IMM_SSE(PCLMULQDQ,  pclmulqdq)
 
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] target/i386/tcg: remove dead constants
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
  2026-01-15 11:33 ` [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1 Paolo Bonzini
  2026-01-15 11:33 ` [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-15 19:57   ` Philippe Mathieu-Daudé
  2026-01-19  0:57   ` Richard Henderson
  2026-01-15 11:33 ` [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split Paolo Bonzini
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

NB_OP_SIZES has been dead since the conversion to TCG, REG_L_OFFSET
since 2015, the others somewhere in the middle.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/translate.c | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 460848e4223..20aa94347b0 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -374,30 +374,6 @@ static void gen_update_cc_op(DisasContext *s)
     }
 }
 
-#ifdef TARGET_X86_64
-
-#define NB_OP_SIZES 4
-
-#else /* !TARGET_X86_64 */
-
-#define NB_OP_SIZES 3
-
-#endif /* !TARGET_X86_64 */
-
-#if HOST_BIG_ENDIAN
-#define REG_B_OFFSET (sizeof(target_ulong) - 1)
-#define REG_H_OFFSET (sizeof(target_ulong) - 2)
-#define REG_W_OFFSET (sizeof(target_ulong) - 2)
-#define REG_L_OFFSET (sizeof(target_ulong) - 4)
-#define REG_LH_OFFSET (sizeof(target_ulong) - 8)
-#else
-#define REG_B_OFFSET 0
-#define REG_H_OFFSET 1
-#define REG_W_OFFSET 0
-#define REG_L_OFFSET 0
-#define REG_LH_OFFSET 4
-#endif
-
 /* In instruction encodings for byte register accesses the
  * register number usually indicates "low 8 bits of register N";
  * however there are some special cases where N 4..7 indicates
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
                   ` (2 preceding siblings ...)
  2026-01-15 11:33 ` [PATCH 3/6] target/i386/tcg: remove dead constants Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-19  0:57   ` Richard Henderson
  2026-01-15 11:33 ` [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself Paolo Bonzini
  2026-01-15 11:33 ` [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64 Paolo Bonzini
  5 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

Unlike the older code in translate.c, mod=11b *is* filtered out earlier
by decode_modrm, and it would have returned bogus code.  Since the register
case is so simple, just inline decode_modrm_address into its caller instead
of removing the "if".

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 64 ++++++++++++--------------------
 1 file changed, 24 insertions(+), 40 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index b00ea3e86e8..662d1d707d0 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -2007,33 +2007,34 @@ static void decode_root(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
     *entry = opcodes_root[*b];
 }
 
-/* Decompose an address.  */
-static AddressParts decode_modrm_address(CPUX86State *env, DisasContext *s,
-                                         int modrm, bool is_vsib)
+/* Decode the MODRM and SIB bytes into a register or memory operand.  */
+static void decode_modrm(DisasContext *s, CPUX86State *env,
+                         X86DecodedInsn *decode, X86DecodedOp *op)
 {
-    int def_seg, base, index, scale, mod, rm;
-    target_long disp;
-    bool havesib;
-
-    def_seg = R_DS;
-    index = -1;
-    scale = 0;
-    disp = 0;
-
-    mod = (modrm >> 6) & 3;
-    rm = modrm & 7;
-    base = rm | REX_B(s);
+    int modrm = get_modrm(s, env);
+    int mod = (modrm >> 6) & 3;
+    int rm = modrm & 7;
+    bool is_vsib = decode->e.vex_class == 12;
+    bool havesib = false;
 
     if (mod == 3) {
-        /* Normally filtered out earlier, but including this path
-           simplifies multi-byte nop, as well as bndcl, bndcu, bndcn.  */
-        goto done;
+        op->n = rm;
+        if (op->unit != X86_OP_MMX) {
+            op->n |= REX_B(s);
+        }
+        return;
     }
 
+    /* Decompose an address.  */
+    int def_seg = R_DS;
+    int base = rm | REX_B(s);
+    int index = -1;
+    int scale = 0;
+    target_ulong disp = 0;
+
     switch (s->aflag) {
     case MO_64:
     case MO_32:
-        havesib = 0;
         if (rm == 4) {
             int code = x86_ldub_code(env, s);
             scale = (code >> 6) & 3;
@@ -2042,7 +2043,7 @@ static AddressParts decode_modrm_address(CPUX86State *env, DisasContext *s,
                 index = -1;  /* no index */
             }
             base = (code & 7) | REX_B(s);
-            havesib = 1;
+            havesib = true;
         }
 
         switch (mod) {
@@ -2127,26 +2128,9 @@ static AddressParts decode_modrm_address(CPUX86State *env, DisasContext *s,
         g_assert_not_reached();
     }
 
- done:
-    return (AddressParts){ def_seg, base, index, scale, disp };
-}
-
-static int decode_modrm(DisasContext *s, CPUX86State *env,
-                        X86DecodedInsn *decode, X86DecodedOp *op)
-{
-    int modrm = get_modrm(s, env);
-    if ((modrm >> 6) == 3) {
-        op->n = (modrm & 7);
-        if (op->unit != X86_OP_MMX) {
-            op->n |= REX_B(s);
-        }
-    } else {
-        op->has_ea = true;
-        op->n = -1;
-        decode->mem = decode_modrm_address(env, s, get_modrm(s, env),
-                                           decode->e.vex_class == 12);
-    }
-    return modrm;
+    op->has_ea = true;
+    op->n = -1;
+    decode->mem = (AddressParts){ def_seg, base, index, scale, disp };
 }
 
 static bool decode_op_size(DisasContext *s, X86OpEntry *e, X86OpSize size, MemOp *ot)
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
                   ` (3 preceding siblings ...)
  2026-01-15 11:33 ` [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-19  0:58   ` Richard Henderson
  2026-01-15 11:33 ` [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64 Paolo Bonzini
  5 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 662d1d707d0..086a3bcec18 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -2015,7 +2015,7 @@ static void decode_modrm(DisasContext *s, CPUX86State *env,
     int mod = (modrm >> 6) & 3;
     int rm = modrm & 7;
     bool is_vsib = decode->e.vex_class == 12;
-    bool havesib = false;
+    int sib = -1;
 
     if (mod == 3) {
         op->n = rm;
@@ -2036,14 +2036,13 @@ static void decode_modrm(DisasContext *s, CPUX86State *env,
     case MO_64:
     case MO_32:
         if (rm == 4) {
-            int code = x86_ldub_code(env, s);
-            scale = (code >> 6) & 3;
-            index = ((code >> 3) & 7) | REX_X(s);
+            sib = x86_ldub_code(env, s);
+            scale = (sib >> 6) & 3;
+            index = ((sib >> 3) & 7) | REX_X(s);
             if (index == 4 && !is_vsib) {
                 index = -1;  /* no index */
             }
-            base = (code & 7) | REX_B(s);
-            havesib = true;
+            base = (sib & 7) | REX_B(s);
         }
 
         switch (mod) {
@@ -2051,7 +2050,7 @@ static void decode_modrm(DisasContext *s, CPUX86State *env,
             if ((base & 7) == 5) {
                 base = -1;
                 disp = (int32_t)x86_ldl_code(env, s);
-                if (CODE64(s) && !havesib) {
+                if (CODE64(s) && sib == -1) {
                     base = -2;
                     disp += s->pc + s->rip_offset;
                 }
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64
  2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
                   ` (4 preceding siblings ...)
  2026-01-15 11:33 ` [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself Paolo Bonzini
@ 2026-01-15 11:33 ` Paolo Bonzini
  2026-01-19  1:09   ` Richard Henderson
  5 siblings, 1 reply; 14+ messages in thread
From: Paolo Bonzini @ 2026-01-15 11:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: richard.henderson

32-bit TCG opcodes produced for the i386 target usually looks the same
as 64-bit TCG opcodes produced for the x86_64.  The special one that
needs extensions is 32-bit TCG opcodes produced for the x86_64 target.
Make all #ifdefs look the same, like this:

    case MO_32:
  #ifdef TARGET_X86_64
      /* code using 32-bit opcodes */

    case MO_64:
  #endif
      /* code using target_long opcodes */

  default:
    g_assert_not_reached();

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/translate.c | 11 ++++++-----
 target/i386/tcg/emit.c.inc  | 18 ++++++++++++------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 20aa94347b0..7186517239c 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -430,17 +430,15 @@ static TCGv gen_op_deposit_reg_v(DisasContext *s, MemOp ot, int reg, TCGv dest,
         tcg_gen_deposit_tl(dest, cpu_regs[reg], t0, 0, 16);
         break;
     case MO_32:
-        /* For x86_64, this sets the higher half of register to zero.
-           For i386, this is equivalent to a mov. */
+#ifdef TARGET_X86_64
         dest = dest ? dest : cpu_regs[reg];
         tcg_gen_ext32u_tl(dest, t0);
         break;
-#ifdef TARGET_X86_64
     case MO_64:
+#endif
         dest = dest ? dest : cpu_regs[reg];
         tcg_gen_mov_tl(dest, t0);
         break;
-#endif
     default:
         g_assert_not_reached();
     }
@@ -1585,8 +1583,8 @@ static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp ot,
             tcg_gen_shri_i64(s->T0, s->T0, 32);
         }
         break;
+    case MO_64:
 #endif
-    default:
         hishift = tcg_temp_new();
         tcg_gen_subi_tl(tmp, count, 1);
         if (is_right) {
@@ -1615,6 +1613,9 @@ static TCGv gen_shiftd_rm_T1(DisasContext *s, MemOp ot,
                            tcg_constant_tl(0), s->T1);
         tcg_gen_or_tl(s->T0, s->T0, s->T1);
         break;
+
+    default:
+        g_assert_not_reached();
     }
 
     return cc_src;
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index f5f12e48b77..ca0ee4d630d 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1236,8 +1236,8 @@ static void gen_ADCOX(DisasContext *s, X86DecodedInsn *decode, int cc_op)
     }
 
     switch (ot) {
-#ifdef TARGET_X86_64
     case MO_32:
+#ifdef TARGET_X86_64
         /* If TL is 64-bit just do everything in 64-bit arithmetic.  */
         tcg_gen_ext32u_tl(s->T0, s->T0);
         tcg_gen_ext32u_tl(s->T1, s->T1);
@@ -1245,12 +1245,16 @@ static void gen_ADCOX(DisasContext *s, X86DecodedInsn *decode, int cc_op)
         tcg_gen_add_i64(s->T0, s->T0, carry_in);
         tcg_gen_shri_i64(*carry_out, s->T0, 32);
         break;
+
+    case MO_64:
 #endif
-    default:
         zero = tcg_constant_tl(0);
         tcg_gen_add2_tl(s->T0, *carry_out, s->T0, zero, carry_in, zero);
         tcg_gen_add2_tl(s->T0, *carry_out, s->T0, *carry_out, s->T1, zero);
         break;
+
+    default:
+        g_assert_not_reached();
     }
 }
 
@@ -1991,7 +1995,6 @@ static void gen_DIV(DisasContext *s, X86DecodedInsn *decode)
     case MO_16:
         gen_helper_divw_AX(tcg_env, s->T0);
         break;
-    default:
     case MO_32:
         gen_helper_divl_EAX(tcg_env, s->T0);
         break;
@@ -2000,6 +2003,8 @@ static void gen_DIV(DisasContext *s, X86DecodedInsn *decode)
         gen_helper_divq_EAX(tcg_env, s->T0);
         break;
 #endif
+    default:
+        g_assert_not_reached();
     }
 }
 
@@ -2065,7 +2070,6 @@ static void gen_IDIV(DisasContext *s, X86DecodedInsn *decode)
     case MO_16:
         gen_helper_idivw_AX(tcg_env, s->T0);
         break;
-    default:
     case MO_32:
         gen_helper_idivl_EAX(tcg_env, s->T0);
         break;
@@ -2074,6 +2078,8 @@ static void gen_IDIV(DisasContext *s, X86DecodedInsn *decode)
         gen_helper_idivq_EAX(tcg_env, s->T0);
         break;
 #endif
+    default:
+        g_assert_not_reached();
     }
 }
 
@@ -2895,7 +2901,7 @@ static inline void gen_pextr(DisasContext *s, X86DecodedInsn *decode, MemOp ot)
         tcg_gen_ld_tl(s->T0, tcg_env, vector_elem_offset(&decode->op[1], ot, val));
         break;
     default:
-        abort();
+        g_assert_not_reached();
     }
 }
 
@@ -2942,7 +2948,7 @@ static inline void gen_pinsr(DisasContext *s, X86DecodedInsn *decode, MemOp ot)
         tcg_gen_st_tl(s->T1, tcg_env, vector_elem_offset(&decode->op[0], ot, val));
         break;
     default:
-        abort();
+        g_assert_not_reached();
     }
 }
 
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] target/i386/tcg: remove dead constants
  2026-01-15 11:33 ` [PATCH 3/6] target/i386/tcg: remove dead constants Paolo Bonzini
@ 2026-01-15 19:57   ` Philippe Mathieu-Daudé
  2026-01-19  0:57   ` Richard Henderson
  1 sibling, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-01-15 19:57 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: richard.henderson

On 15/1/26 12:33, Paolo Bonzini wrote:
> NB_OP_SIZES has been dead since the conversion to TCG, REG_L_OFFSET
> since 2015, the others somewhere in the middle.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/tcg/translate.c | 24 ------------------------
>   1 file changed, 24 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1
  2026-01-15 11:33 ` [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1 Paolo Bonzini
@ 2026-01-19  0:56   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  0:56 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-stable

On 1/15/26 22:33, Paolo Bonzini wrote:
> Match the contents of table 2-17 ("#UD Exception and VEX.L Field Encoding")
> in the SDM, for instruction in exception class 5.  They were incorrectly
> accepting 256-bit versions that do not exist.
> 
> Cc:qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/decode-new.c.inc | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions
  2026-01-15 11:33 ` [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions Paolo Bonzini
@ 2026-01-19  0:56   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  0:56 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 1/15/26 22:33, Paolo Bonzini wrote:
> Their gen_* functions were incorrectly named gen_VDDPS and gen_VDDPD.
> 
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/decode-new.c.inc | 4 ++--
>   target/i386/tcg/emit.c.inc       | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] target/i386/tcg: remove dead constants
  2026-01-15 11:33 ` [PATCH 3/6] target/i386/tcg: remove dead constants Paolo Bonzini
  2026-01-15 19:57   ` Philippe Mathieu-Daudé
@ 2026-01-19  0:57   ` Richard Henderson
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  0:57 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 1/15/26 22:33, Paolo Bonzini wrote:
> NB_OP_SIZES has been dead since the conversion to TCG, REG_L_OFFSET
> since 2015, the others somewhere in the middle.
> 
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/translate.c | 24 ------------------------
>   1 file changed, 24 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split
  2026-01-15 11:33 ` [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split Paolo Bonzini
@ 2026-01-19  0:57   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  0:57 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 1/15/26 22:33, Paolo Bonzini wrote:
> Unlike the older code in translate.c, mod=11b*is* filtered out earlier
> by decode_modrm, and it would have returned bogus code.  Since the register
> case is so simple, just inline decode_modrm_address into its caller instead
> of removing the "if".
> 
> Suggested-by: Richard Henderson<richard.henderson@linaro.org>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/decode-new.c.inc | 64 ++++++++++++--------------------
>   1 file changed, 24 insertions(+), 40 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself
  2026-01-15 11:33 ` [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself Paolo Bonzini
@ 2026-01-19  0:58   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  0:58 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 1/15/26 22:33, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   target/i386/tcg/decode-new.c.inc | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64
  2026-01-15 11:33 ` [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64 Paolo Bonzini
@ 2026-01-19  1:09   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2026-01-19  1:09 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel

On 1/15/26 22:33, Paolo Bonzini wrote:
> 32-bit TCG opcodes produced for the i386 target usually looks the same
> as 64-bit TCG opcodes produced for the x86_64.  The special one that
> needs extensions is 32-bit TCG opcodes produced for the x86_64 target.
> Make all #ifdefs look the same, like this:
> 
>      case MO_32:
>    #ifdef TARGET_X86_64
>        /* code using 32-bit opcodes */
> 
>      case MO_64:
>    #endif
>        /* code using target_long opcodes */
> 
>    default:
>      g_assert_not_reached();
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/tcg/translate.c | 11 ++++++-----
>   target/i386/tcg/emit.c.inc  | 18 ++++++++++++------
>   2 files changed, 18 insertions(+), 11 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


>       case MO_32:
> -        /* For x86_64, this sets the higher half of register to zero.
> -           For i386, this is equivalent to a mov. */
> +#ifdef TARGET_X86_64
>           dest = dest ? dest : cpu_regs[reg];
>           tcg_gen_ext32u_tl(dest, t0);
>           break;
> -#ifdef TARGET_X86_64
>       case MO_64:
> +#endif
>           dest = dest ? dest : cpu_regs[reg];
>           tcg_gen_mov_tl(dest, t0);
>           break;
> -#endif
>       default:
>           g_assert_not_reached();
>       }

This could plausibly share the dest selection code and then use

   tcg_gen_ext_tl(dest, t0, mop).

> @@ -1236,8 +1236,8 @@ static void gen_ADCOX(DisasContext *s, X86DecodedInsn *decode, int cc_op)
...
> +    case MO_64:
>   #endif
> -    default:
>           zero = tcg_constant_tl(0);
>           tcg_gen_add2_tl(s->T0, *carry_out, s->T0, zero, carry_in, zero);
>           tcg_gen_add2_tl(s->T0, *carry_out, s->T0, *carry_out, s->T1, zero);
>           break;

A fairly new function, but this could use

   tcg_gen_addcio_tl(s->T0, *carry_out, s->T0, s->T1, carry_in);


r~


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-01-19  1:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 11:33 [PATCH 0/6] Next round of target/i386/tcg fixes and cleanups Paolo Bonzini
2026-01-15 11:33 ` [PATCH 1/6] target/i386/tcg: fix a few instructions that do not support VEX.L=1 Paolo Bonzini
2026-01-19  0:56   ` Richard Henderson
2026-01-15 11:33 ` [PATCH 2/6] target/i386/tcg: fix typo in dpps/dppd instructions Paolo Bonzini
2026-01-19  0:56   ` Richard Henderson
2026-01-15 11:33 ` [PATCH 3/6] target/i386/tcg: remove dead constants Paolo Bonzini
2026-01-15 19:57   ` Philippe Mathieu-Daudé
2026-01-19  0:57   ` Richard Henderson
2026-01-15 11:33 ` [PATCH 4/6] target/i386/tcg: merge decode_modrm and decode_modrm_address split Paolo Bonzini
2026-01-19  0:57   ` Richard Henderson
2026-01-15 11:33 ` [PATCH 5/6] target/i386/tcg: replace havesib variable with the SIB byte itself Paolo Bonzini
2026-01-19  0:58   ` Richard Henderson
2026-01-15 11:33 ` [PATCH 6/6] target/i386/tcg: cleanup #ifdef TARGET_X86_64 Paolo Bonzini
2026-01-19  1:09   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox