mbox series

[00/25] target/i386: more progress towards new decoder

Message ID 20240608084113.2770363-1-pbonzini@redhat.com
Headers show
Series target/i386: more progress towards new decoder | expand

Message

Paolo Bonzini June 8, 2024, 8:40 a.m. UTC
Just like in previous installments, this series ends with a specific
thing that is now done entirely in the new decoder.  After removing
the legacy prefix decoding in the previous series, now it's _all_ decoding
that is done by decode-new.c.inc.  Most two byte opcodes are converted,
leaving out only five plus the x87 instructions, but even those only
use the X86DecodedInsn; they do not use anymore the CPUX86State (env)
to fetch bytes from the instruction stream.

The only reason why those five are left behind is that the decoding is a
bit gnarly and, having little or no commonality with the other opcodes,
there isn't much duplication between translate.c and emit.c.inc that
supports them.

It's nothing that's particularly hard, but this is just a nice place
to stop for now; and also I think it's enough to implement APX's 32
GPRs and REX2 prefix without the legacy translator getting in the way.
Of course APX quite some more work---there's all the EVEX special cases
and flags, and the new conditional instructions (CFCMOV, CCMP, CTEST)
to consider---but it's a start.

As in previous installments, there is some reduction in the total number
of lines of code, which is a bit surprising; but then again many of these
opcodes have modrm bytes for which there a lot of repeated lines, and
also it's possible to share some existing emit.c.inc code (for example
SHLD/SHRD mostly reuse the flag computations of SHL/SHR).

Patches 1-7: simplifications/cleanups in decode-new.c.inc

Patches 8-20: move all two-byte opcodes except for 00/01/1A/1B/C7
to new decoder.

Patches 21-25: move decoding of modrm bytes entirely to new decoder,
and cleanup.

Paolo Bonzini (25):
  target/i386: remove CPUX86State argument from generator functions
  target/i386: rewrite flags writeback for ADCX/ADOX
  target/i386: put BLS* input in T1, use generic flag writeback
  target/i386: change X86_ENTRYr to use T0
  target/i386: change X86_ENTRYwr to use T0, use it for moves
  target/i386: replace NoSeg special with NoLoadEA
  target/i386: fix processing of intercept 0 (read CR0)
  target/i386: convert MOV from/to CR and DR to new decoder
  target/i386: fix bad sorting of entries in the 0F table
  target/i386: finish converting 0F AE to the new decoder
  target/i386: replace read_crN helper with read_cr8
  target/i386: split X86_CHECK_prot into PE and VM86 checks
  target/i386: convert non-grouped, helper-based 2-byte opcodes
  target/i386: convert bit test instructions to new decoder
  target/i386: pull load/writeback out of gen_shiftd_rm_T1
  target/i386: adapt gen_shift_count for SHLD/SHRD
  target/i386: convert SHLD/SHRD to new decoder
  target/i386: convert LZCNT/TZCNT/BSF/BSR/POPCNT to new decoder
  target/i386: convert XADD to new decoder
  target/i386: convert CMPXCHG to new decoder
  target/i386: decode address before going back to translate.c
  target/i386: list instructions still in translate.c
  target/i386: assert that cc_op* and pc_save are preserved
  target/i386: do not check PREFIX_LOCK in old-style decoder
  target/i386: remove gen_ext_tl

 target/i386/cpu.h                    |    9 +-
 target/i386/helper.h                 |    2 +-
 target/i386/tcg/decode-new.h         |   46 +-
 target/i386/tcg/seg_helper.c         |   16 +-
 target/i386/tcg/sysemu/misc_helper.c |   20 +-
 target/i386/tcg/translate.c          | 1089 ++--------------------
 target/i386/tcg/decode-new.c.inc     |  473 +++++++---
 target/i386/tcg/emit.c.inc           | 1290 +++++++++++++++++++-------
 8 files changed, 1417 insertions(+), 1528 deletions(-)