This series implements APX support; the main reason to do this is actually to have some initial infrastructure for EVEX, without requiring all the complexity of AVX512 but introducing the required changes in the emulator. It also forces some changes that (hopefully) make QEMU's decoder align a bit more with what Intel processors actually do.
In fact, most of the new code is for EVEX decoding. The extensions to existing instruction can be implemented almost entirely by tweaking the decode tables: the new data destination feature comes almost for free thanks to the existing support for BMI instructions. Variants such as no flags update and zero-upper are quite easy as well. The new instructions (CCMP/CTEST, CFCMOV, PUSH2/POP2) are trivial except for CCMP/CTEST, which try to be reasonably efficient. A lot of the recent changes to AF/CF/OF computation make the changes to helpers very small, while efficient implementation of JL/JLE/JB/JBE takes a bit of effort. The main design decision was whether to treat VEX and EVEX maps as an extension of the regular maps, or just bite the bullet, copy them over to a new array and define them from scratch. Here I went the copying route due to some annoying differences in accepted prefixes and due to opcodes that were moved to a different spot. But in some cases APX's three-operand variants end up being visible in the regular table, due to shared code in decode_group*. Don't expect any performance gains. APX binaries do produce about 1% fewer TCG ops, but they map to about 1% *more* assembly instructions, at least for x86-on-x86: that's because while the optimizer could already produce roughly the same ops as NDD or NF instructions, the new PUSH2/POP2 instructions include a stack alignment check that isn't there in non-APX code. I don't think it's worth wasting a precious HF_ bit for it, at least not for the next few years. Other than the first three patches, and other than not reusing decode_root, this is mostly the same as the RFC[1] since I didn't have much more time to work on it. System mode emulation was tested very little, basically nothing more than a simple initrd that runs a few instructions and does xsave/xrstor. Paolo [1] https://lore.kernel.org/qemu-devel/[email protected]/ Paolo Bonzini (20): target/i386/tcg: do not reuse cc_srcT target/i386/tcg: inline gen_ext_tl target/i386/tcg: simplify return value of gen_prepare_cc target/i386/tcg: move check bits out of validate_vex target/i386/tcg: add APX support to XSAVE/XRSTOR target/i386/tcg: treat VEX as disabling high-byte registers target/i386/tcg: add definition for REX2 prefix target/i386/tcg: mark XSAVE* as not allowing REX2 target/i386/tcg: decode REX2 prefix target/i386/tcg: implement JMPABS instruction target/i386/tcg: fetch modrm early target/i386/tcg: move VEX validation early target/i386/tcg: extend VEX.vvvv parsing for APX target/i386/tcg: decode EVEX prefix target/i386/tcg: add ZU writeback target/i386/tcg: add decode functionality for APX target/i386/tcg: implement CCMP/CTEST target/i386/tcg: decode APX instructions target/i386/tcg: mark APX as supported target/i386/tcg: optimize CCMP configs/targets/x86_64-bsd-user.mak | 2 +- configs/targets/x86_64-linux-user.mak | 2 +- target/i386/cpu.h | 8 + target/i386/helper.h | 1 + target/i386/tcg/decode-new.h | 20 + target/i386/tcg/tcg-cpu.h | 16 +- target/i386/tcg/cc_helper_template.h.inc | 11 + target/i386/cpu.c | 15 +- target/i386/helper.c | 11 + target/i386/tcg/cc_helper.c | 10 + target/i386/tcg/excp_helper.c | 5 + target/i386/tcg/fpu_helper.c | 59 +- target/i386/tcg/tcg-cpu.c | 5 +- target/i386/tcg/translate.c | 203 +++-- target/i386/tcg/decode-new.c.inc | 896 +++++++++++++++++++---- target/i386/tcg/emit.c.inc | 256 ++++++- 16 files changed, 1274 insertions(+), 246 deletions(-) -- 2.55.0
