Skip to content

RFC rewrite MMX/SSE*/AVX/AVX2 vector instruction translation

Jan Bobek qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 RFC Latest74 of 75 patches 5 repliesIn review
  2. v3 RFC46 patches 12 repliesSuperseded
  3. v2 RFC39 patches 19 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v1 RFC22 patches17 repliesSuperseded

Changes in v4 from the cover letter

- introduce disas_insn_prefix ([2])
- rename ck_cpuid to check_cpuid ([3])
- clarify this series deals with vector instructions only ([4])
- add a list of instructions per each vector ISA extension ([5])
- change return type of check_cpuid and insnop_init to bool ([6])

74 of 75 patches are in this archive. The cover letter announces 75.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/75target/i386: Push rex_r into DisasContexttarget/i386/translate.c+44 -410 replies
2/75target/i386: Push rex_w into DisasContexttarget/i386/translate.c+11 -81 reply
3/75target/i386: use dflag from DisasContexttarget/i386/translate.c+90 -900 replies
4/75target/i386: use prefix from DisasContexttarget/i386/translate.c+55 -550 replies
5/75target/i386: introduce disas_insn_prefixtarget/i386/translate.c+34 -140 replies
6/75target/i386: Simplify gen_exception argumentstarget/i386/translate.c+44 -450 replies
7/75target/i386: use pc_start from DisasContexttarget/i386/translate.c+65 -660 replies
8/75target/i386: make variable b1 consttarget/i386/translate.c+6 -90 replies
9/75target/i386: make variable is_xmm consttarget/i386/translate.c+6 -110 replies
10/75target/i386: add vector register file alignment constraintstarget/i386/cpu.h+3 -30 replies
11/75target/i386: introduce gen_sse_ngtarget/i386/translate.c+45 -10 replies
12/75target/i386: introduce CASES_* macros in gen_sse_ngtarget/i386/translate.c+54 -00 replies
13/75target/i386: decode the 0F38/0F3A prefix in gen_sse_ngtarget/i386/translate.c+16 -00 replies
14/75target/i386: introduce aliases for some tcg_gvec operationstarget/i386/translate.c+39 -00 replies
15/75target/i386: introduce function check_cpuidtarget/i386/translate.c+62 -00 replies
16/75target/i386: disable AVX/AVX2 cpuid bitcheckstarget/i386/translate.c+6 -60 replies
17/75target/i386: introduce instruction operand infrastructuretarget/i386/translate.c+28 -00 replies
18/75target/i386: introduce generic operand aliastarget/i386/translate.c+20 -00 replies
19/75target/i386: introduce generic either-or operandtarget/i386/translate.c+44 -00 replies
20/75target/i386: introduce generic load-store operandtarget/i386/translate.c+57 -00 replies
21/75target/i386: introduce tcg register operandstarget/i386/translate.c+44 -00 replies
22/75target/i386: introduce modrm operandtarget/i386/translate.c+20 -00 replies
23/75target/i386: introduce operands for decoding modrm fieldstarget/i386/translate.c+62 -00 replies
24/75target/i386: introduce operand for direct-only r/m fieldtarget/i386/translate.c+37 -00 replies
25/75target/i386: introduce Ib (immediate) operandtarget/i386/translate.c+18 -00 replies
26/75target/i386: introduce M* (memptr) operandstarget/i386/translate.c+36 -00 replies
27/75target/i386: introduce G*, R*, E* (general register) operandstarget/i386/translate.c+88 -00 replies
28/75target/i386: introduce P*, N*, Q* (MMX) operandstarget/i386/translate.c+80 -00 replies
29/75target/i386: introduce H*, L*, V*, U*, W* (SSE/AVX) operandstarget/i386/translate.c+220 -00 replies
30/75target/i386: alias H* operands with the V* operandstarget/i386/translate.c+4 -50 replies
31/75target/i386: introduce code generatorstarget/i386/translate.c+46 -01 reply
32/75target/i386: introduce helper-based code generator macrostarget/i386/translate.c+160 -00 replies
33/75target/i386: introduce gvec-based code generator macrostarget/i386/translate.c+25 -00 replies
34/75target/i386: introduce sse-opcode.inc.htarget/i386/sse-opcode.inc.h+75 -00 replies
35/75target/i386: introduce instruction translator macrostarget/i386/translate.c+272 -00 replies
36/75target/i386: introduce MMX translatorstarget/i386/translate.c+11 -00 replies
37/75target/i386: introduce MMX code generatorstarget/i386/translate.c+100 -00 replies
38/75target/i386: introduce MMX vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+136 -00 replies
39/75target/i386: introduce SSE translatorstarget/i386/translate.c+34 -00 replies
40/75target/i386: introduce SSE code generatorstarget/i386/translate.c+309 -00 replies
41/75target/i386: introduce SSE vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+161 -00 replies
42/75target/i386: introduce SSE2 translatorstarget/i386/translate.c+31 -00 replies
43/75target/i386: introduce SSE2 code generatorstarget/i386/translate.c+425 -20 replies
44/75target/i386: introduce SSE2 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+325 -10 replies
45/75target/i386: introduce SSE3 translatorstarget/i386/translate.c+1 -00 replies
46/75target/i386: introduce SSE3 code generatorstarget/i386/translate.c+61 -00 replies
47/75target/i386: introduce SSE3 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+23 -00 replies
48/75target/i386: introduce SSSE3 translatorstarget/i386/translate.c+1 -00 replies
49/75target/i386: introduce SSSE3 code generatorstarget/i386/translate.c+33 -00 replies
50/75target/i386: introduce SSSE3 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+67 -00 replies
51/75target/i386: introduce SSE4.1 translatorstarget/i386/translate.c+12 -00 replies
52/75target/i386: introduce SSE4.1 code generatorstarget/i386/translate.c+101 -00 replies
53/75target/i386: introduce SSE4.1 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+101 -00 replies
54/75target/i386: introduce SSE4.2 code generatorstarget/i386/translate.c+6 -00 replies
55/75target/i386: introduce SSE4.2 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+13 -00 replies
57/75target/i386: introduce AES and PCLMULQDQ code generatorstarget/i386/translate.c+15 -00 replies
58/75target/i386: introduce AES and PCLMULQDQ vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+34 -01 reply
59/75target/i386: introduce AVX translatorstarget/i386/translate.c+48 -00 replies
60/75target/i386: introduce AVX code generatorstarget/i386/translate.c+954 -00 replies
61/75target/i386: introduce AVX vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+779 -00 replies
62/75target/i386: introduce AVX2 translatorstarget/i386/translate.c+16 -30 replies
63/75target/i386: introduce AVX2 code generatorstarget/i386/translate.c+395 -120 replies
64/75target/i386: introduce AVX2 vector instructions to sse-opcode.inc.htarget/i386/sse-opcode.inc.h+359 -31 reply
65/75target/i386: remove obsoleted helperstarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+0 -1420 replies
66/75target/i386: cleanup leftovers in ops_sse_header.htarget/i386/ops_sse_header.h+6 -220 replies
67/75target/i386: introduce aliases for helper-based tcg_gen_gvec_* functionstarget/i386/translate.c+30 -00 replies
68/75target/i386: convert ps((l, r)l(w, d, q), ra(w, d)) to helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+306 -3400 replies
69/75target/i386: convert pmullw/pmulhw/pmulhuw helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+51 -240 replies
70/75target/i386: convert pavgb/pavgw helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+43 -170 replies
71/75target/i386: convert pmuludq/pmaddwd helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+27 -220 replies
72/75target/i386: convert psadbw helper to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+32 -430 replies
73/75target/i386: remove obsoleted helper_mov(l, q)_mm_T0target/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+0 -560 replies
74/75target/i386: convert pshuf(w, lw, hw, d), shuf(pd, ps) helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+119 -680 replies
75/75target/i386: convert pmovmskb/movmskps/movmskpd helpers to gvec styletarget/i386/ops_sse.h target/i386/ops_sse_header.h target/i386/translate.c+65 -1501 reply

Reviews trailers per patch

4 of 74 patches have a Reviewed-by or Acked-by.

PatchRichard Henderson
1/75
2/75
3/75
4/75
5/75
6/75
7/75R-b
8/75R-b
9/75R-b
10/75R-b
11/75
12/75
13/75
14/75
15/75
16/75
17/75
18/75
19/75
20/75
21/75
22/75
23/75
24/75
25/75
26/75
27/75
28/75
29/75
30/75
31/75
32/75
33/75
34/75
35/75
36/75
37/75
38/75
39/75
40/75
41/75
42/75
43/75
44/75
45/75
46/75
47/75
48/75
49/75
50/75
51/75
52/75
53/75
54/75
55/75
57/75
58/75
59/75
60/75
61/75
62/75
63/75
64/75
65/75
66/75
67/75
68/75
69/75
70/75
71/75
72/75
73/75
74/75
75/75

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [Qemu-devel] [RFC PATCH v4 00/75] rewrite MMX/SSE*/AVX/AVX2 vector instruction translation

Here comes the next version of my patch series, this time v4; the previous version can be found at [1].

This version can decode all vector instructions up to AVX2. However, note that this does not mean all of these instructions are implemented
correctly: to achieve that, the old ad-hoc style helpers will need to be rewritten into the style used by gvec helpers (initial effort towards that goal can be seen in patches 65-75). There is also a number of instructions which have not been previously implemented at all, for which the helpers need to be written from scratch.

Cheers,
-Jan

Changes from v3:
- introduce disas_insn_prefix ([2])
- rename ck_cpuid to check_cpuid ([3])
- clarify this series deals with vector instructions only ([4])
- add a list of instructions per each vector ISA extension ([5])
- change return type of check_cpuid and insnop_init to bool ([6])

References:
1. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg02616.html
2. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg02686.html
3. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg04120.html
4. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg04119.html
5. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg02689.html
6. https://lists.nongnu.org/archive/html/qemu-devel/2019-08/msg02701.html

Jan Bobek (72):
target/i386: use dflag from DisasContext
target/i386: use prefix from DisasContext
target/i386: introduce disas_insn_prefix
target/i386: use pc_start from DisasContext
target/i386: make variable b1 const
target/i386: make variable is_xmm const
target/i386: add vector register file alignment constraints target/i386: introduce gen_sse_ng
target/i386: introduce CASES_* macros in gen_sse_ng target/i386: decode the 0F38/0F3A prefix in gen_sse_ng target/i386: introduce aliases for some tcg_gvec operations target/i386: introduce function check_cpuid
target/i386: disable AVX/AVX2 cpuid bitchecks
target/i386: introduce instruction operand infrastructure target/i386: introduce generic operand alias
target/i386: introduce generic either-or operand target/i386: introduce generic load-store operand target/i386: introduce tcg register operands
target/i386: introduce modrm operand
target/i386: introduce operands for decoding modrm fields target/i386: introduce operand for direct-only r/m field target/i386: introduce Ib (immediate) operand
target/i386: introduce M* (memptr) operands
target/i386: introduce G*, R*, E* (general register) operands target/i386: introduce P*, N*, Q* (MMX) operands target/i386: introduce H*, L*, V*, U*, W* (SSE/AVX) operands target/i386: alias H* operands with the V* operands target/i386: introduce code generators
target/i386: introduce helper-based code generator macros target/i386: introduce gvec-based code generator macros target/i386: introduce sse-opcode.inc.h
target/i386: introduce instruction translator macros target/i386: introduce MMX translators
target/i386: introduce MMX code generators
target/i386: introduce MMX vector instructions to sse-opcode.inc.h target/i386: introduce SSE translators
target/i386: introduce SSE code generators
target/i386: introduce SSE vector instructions to sse-opcode.inc.h target/i386: introduce SSE2 translators
target/i386: introduce SSE2 code generators
target/i386: introduce SSE2 vector instructions to sse-opcode.inc.h target/i386: introduce SSE3 translators
target/i386: introduce SSE3 code generators
target/i386: introduce SSE3 vector instructions to sse-opcode.inc.h target/i386: introduce SSSE3 translators
target/i386: introduce SSSE3 code generators
target/i386: introduce SSSE3 vector instructions to sse-opcode.inc.h target/i386: introduce SSE4.1 translators
target/i386: introduce SSE4.1 code generators
target/i386: introduce SSE4.1 vector instructions to sse-opcode.inc.h target/i386: introduce SSE4.2 code generators
target/i386: introduce SSE4.2 vector instructions to sse-opcode.inc.h target/i386: introduce AES and PCLMULQDQ translators target/i386: introduce AES and PCLMULQDQ code generators target/i386: introduce AES and PCLMULQDQ vector instructions to
sse-opcode.inc.h
target/i386: introduce AVX translators
target/i386: introduce AVX code generators
target/i386: introduce AVX vector instructions to sse-opcode.inc.h target/i386: introduce AVX2 translators
target/i386: introduce AVX2 code generators
target/i386: introduce AVX2 vector instructions to sse-opcode.inc.h target/i386: remove obsoleted helpers
target/i386: cleanup leftovers in ops_sse_header.h target/i386: introduce aliases for helper-based tcg_gen_gvec_*
functions
target/i386: convert ps((l,r)l(w,d,q),ra(w,d)) to helpers to gvec
style
target/i386: convert pmullw/pmulhw/pmulhuw helpers to gvec style target/i386: convert pavgb/pavgw helpers to gvec style target/i386: convert pmuludq/pmaddwd helpers to gvec style target/i386: convert psadbw helper to gvec style target/i386: remove obsoleted helper_mov(l,q)_mm_T0 target/i386: convert pshuf(w,lw,hw,d),shuf(pd,ps) helpers to gvec
style
target/i386: convert pmovmskb/movmskps/movmskpd helpers to gvec style

Richard Henderson (3):
target/i386: Push rex_r into DisasContext
target/i386: Push rex_w into DisasContext
target/i386: Simplify gen_exception arguments

 target/i386/cpu.h            |    6 +-
 target/i386/ops_sse.h        |  812 +++---
 target/i386/ops_sse_header.h |  131 +-
 target/i386/sse-opcode.inc.h | 2069 +++++++++++++++
 target/i386/translate.c      | 4777 ++++++++++++++++++++++++++++++----
 5 files changed, 6842 insertions(+), 953 deletions(-)
 create mode 100644 target/i386/sse-opcode.inc.h
Signature · 1 line
2.20.1