From 059edf8b977782457c358b408a71caba4b0311e4 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 14 Jul 2020 10:29:55 +0200 Subject: [PATCH] x86: merge/move logic determining the EVEX disp8 shift Fold redundant case blocks and move the extra adjustments logic into the single case block that actually needs it - there's no need to go through the extra logic for all the other cases. Also utilize there that vex.b cannot be set at this point, due to earlier logic. Reduce the comment there, which was partly stale anyway. --- opcodes/ChangeLog | 7 +++++++ opcodes/i386-dis.c | 45 ++++++++++++++++----------------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index f0b4d8c99a4..88ea70d54a5 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2020-07-14 Jan Beulich + + * i386-dis.c (OP_E_memory): Move xmm_mw_mode, xmm_mb_mode, + dqd_mode, xmm_md_mode, d_mode, d_swap_mode, and + d_scalar_swap_mode case handling. Move shift adjsutment into + the case its applicable to. + 2020-07-14 Jan Beulich * i386-dis.c (EVEX_W_0F3862_P_2, EVEX_W_0F3863_P_2): Delete. diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index b68e737bd79..708d820f51d 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -14517,15 +14517,22 @@ OP_E_memory (int bytemode, int sizeflag) { case dqw_mode: case dw_mode: + case xmm_mw_mode: shift = 1; break; case dqb_mode: case db_mode: + case xmm_mb_mode: shift = 0; break; case dq_mode: if (address_mode != mode_64bit) { + case dqd_mode: + case xmm_md_mode: + case d_mode: + case d_swap_mode: + case d_scalar_swap_mode: shift = 2; break; } @@ -14566,6 +14573,15 @@ OP_E_memory (int bytemode, int sizeflag) default: abort (); } + /* Make necessary corrections to shift for modes that need it. */ + if (bytemode == xmmq_mode + || bytemode == evex_half_bcst_xmmq_mode + || (bytemode == ymmq_mode && vex.length == 128)) + shift -= 1; + else if (bytemode == xmmqd_mode) + shift -= 2; + else if (bytemode == xmmdw_mode) + shift -= 3; break; case ymm_mode: shift = 5; @@ -14579,41 +14595,12 @@ OP_E_memory (int bytemode, int sizeflag) case q_scalar_swap_mode: shift = 3; break; - case dqd_mode: - case xmm_md_mode: - case d_mode: - case d_swap_mode: - case d_scalar_swap_mode: - shift = 2; - break; case bw_unit_mode: shift = vex.w ? 1 : 0; break; - case xmm_mw_mode: - shift = 1; - break; - case xmm_mb_mode: - shift = 0; - break; default: abort (); } - /* Make necessary corrections to shift for modes that need it. - For these modes we currently have shift 4, 5 or 6 depending on - vex.length (it corresponds to xmmword, ymmword or zmmword - operand). We might want to make it 3, 4 or 5 (e.g. for - xmmq_mode). In case of broadcast enabled the corrections - aren't needed, as element size is always 32 or 64 bits. */ - if (!vex.b - && (bytemode == xmmq_mode - || bytemode == evex_half_bcst_xmmq_mode)) - shift -= 1; - else if (bytemode == xmmqd_mode) - shift -= 2; - else if (bytemode == xmmdw_mode) - shift -= 3; - else if (bytemode == ymmq_mode && vex.length == 128) - shift -= 1; } else shift = 0; -- 2.30.2