0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00
Commit Graph

274 Commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
e3f26e25a2 Reshuffle shift and rotate patterns for APX
The shift and rotate patterns are "interesting" in the following way:

1. Even though only 4/5/6 bits of the input are ever used, for the
   regular instructions the input is specified as the CL register, but
   for the -X instructions as a size-matching register. This makes the
   optimization patterns "interesting."

2. The sequencing of legacy, VEX -X versions, APX EVEX, and APX -X

For #1, allow any size register to contain the shift count.

For #2, split up the macro generation of the patterns, and add a new
"$xmacro" macro to deal with the combinatorics of generating all the
-X patterns.  Written directly in Perl since it seemed easier than
trying to make anything more general for what is very much a special
case...

Reported-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 16:26:09 -07:00
Henrik Gramner
86919accd9 x86/insns.dat: Enable contracted forms for a few EVEX vcvt* instructions
Most instructions support contracted forms, but those had been overlooked.

Signed-off-by: Henrik Gramner <henrik@gramner.com>
[ hpa: manual merge ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 11:08:58 -07:00
Henrik Gramner
162d245c30 x86/insns.dat: Fix {er} usage on EVEX vcvtsi2* instructions
The rounding specifier should be applied to src2, not src1.

Furthermore, VCVTSI2SD with a 32-bit source operand does not
support specifying a rounding mode (as no rounding can occur).

Signed-off-by: Henrik Gramner <henrik@gramner.com>
[ hpa: manual merge ]
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 11:06:52 -07:00
Iouri Kharon
89439aa58d Remove unneeded (illegal) evex-encoding of VCVTPS2PH
According to the June edition of SDM evex-form of the VCVTPS2PH command only exists with mmmmm equal to 0f38, and map5 only exists for the VCVTPS2PHX command
2025-10-07 10:16:36 -07:00
H. Peter Anvin (Intel)
41d35bb483 Merge multiple fixes from "InstLatx64" 2025-10-07 10:13:12 -07:00
H. Peter Anvin
e72a54174c insns.dat: correct the [LD][GI]DT patterns
It is somewhat counterintuitive, but the correct flag for the memory
operand is "OSIZE". The "nw" flag takes care of promoting the default
operand size on 64 bits to 64.

Fixes: https://github.com/netwide-assembler/nasm/issues/130
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-07 09:58:54 -07:00
InstLatx64
f4b1a206e0 Remove duplicates
Remove duplicates:
- V{MAX,MIN}{P,S}H
- VEXTRACT{F,I}{32x4,64x2}
- VF{,C}MULCPH
- VF{,N}M{ADD,SUB}{132,213,231}SH
Removed AVX10_1 label from VADDPH/VCMPPH due to consistency
2025-10-07 11:35:15 +02:00
InstLatx64
fb43244978 KUNPCK* fix
KUNPCK* fix, it compiles k_test.asm without errors
2025-10-07 11:07:33 +02:00
InstLatx64
172c4b2342 Missing AVX-VNNI_INT{,8,16} instructions
-- AVX-VNNI_INT{,8,16} instructions: VPDP{B,W}{SS,SU,US,UU}{D,DS}
- AVX-VNNI_INT{,8,16}  test files
Checked with XED version: [v2025.06.08]
2025-10-07 09:52:13 +02:00
H. Peter Anvin
b3358fe63e insns.dat: reinstate TEST reg,mem alias
Officially the syntax for TEST is "rm,reg"; however TEST is
commutative in every aspect, and as such "reg,mem" is an equivalent
form that NASM has also supported in the past.

Reinstate it properly.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392962
Reported-by: E. C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-06 13:07:09 -07:00
InstLatx64
2488b6cfb3 AVX512_FP16 mnemonic fix
-- VGETMAXPH -> VMAXPH
-- VGETMINPH -> VMINPH
-- VFCMULCPCH -> VFCMULCPH
-- VFMULCPCH -> VFMULCPH
-- VPMADD{132,213,231}SH -> VFMADD{132,213,231}SH
-- VPMSUB{132,213,231}SH -> VFMSUB{132,213,231}SH
2025-10-06 19:29:33 +02:00
InstLatx64
70ed10d2e2 AVX512BF16 fix
AVX512BF16 fix:
-- VCVTNEPS2BF16 operand count
-- VDPBF16PS operand size
AVX512BF16 test files
Checked with XED version: [v2025.06.08]
2025-10-06 19:17:51 +02:00
Maciej Wieczor-Retman
0fb33913d6 x86: tools: Remove unused perl code variables
Merged version of a PR by mknos:
https://github.com/netwide-assembler/nasm/pull/91

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-10-06 19:17:51 +02:00
InstLatx64
62f5f6990f AMX-COMPLEX support
-- TCMMIMFP16PS, TCMMRLFP16PS instructions
-- AMX.asm fix: Similar to GATHER instructions, 3-operand AMX instructions cannot have the same operand more than once
Checked with XED version: [v2025.06.08]
2025-10-06 19:17:43 +02:00
Iouri Kharon
8f47ba7cc7 fix TCVTROWPS2PHL (typo?):
see Intel® Architecture Instruction Set Extensions and Future Features Programming Reference, March 2025 319433-057
else (without this correction) it conflict with VPERMI2PS
2025-10-06 18:56:51 +02:00
yjh-styx
ad0a206964 Merge branch 'netwide-assembler:master' into master 2025-10-01 23:04:07 +03:00
H. Peter Anvin
23ce05f906 treewide: replace verbose copyright headers with SPDX tags
SPDX is an international standard for documenting software license
requirements. Remove the existing headers and replace with a brief
SPDX preamble.

See: https://spdx.dev/use/specifications/

The script used to convert the files is added to "tools", and the
file header templates in headers/ are updated.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-10-01 11:45:31 -07:00
Iouri Kharon
eb4e4470cc Absent command 'BTS' (typo?) 2025-10-01 11:08:18 +03:00
H. Peter Anvin
48f7170772 insns.pl: sanity-check that instruction encodings match operands
Error out if an encoding position is invalid, like an "r" operand
matches an "xmmrm" operand.

Document the instruction encoding symbols; there are too many of them
by now.

Add symbols 'n' and 'w' meaning immediates that are supposed to be
encoded as if they were 'm' memory addresses and 'v' register numbers,
respectively; this is necessary to indicate a validation exception.

Remove broken ARPL "memory-like" encoding. It probably never worked
anyway.

This verification caught two bugs already:

- VPMASKMOV[DQ] cannot omit the second operand.

- Incorrect operand encoding order for VREDUCESH.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-30 12:06:11 -07:00
Yongjie Sheng
95095b325c add few more avx10.2 convert instructions 2025-09-30 23:29:30 +08:00
Sheng, Yongjie
f350ad1f4b Update vmovd and vmovw operand sequence 2025-09-30 15:34:08 +01:00
Yongjie2017
c33fd34969 Correct operands sequence for VEXTRACT instruction family 2025-09-30 09:34:07 +08:00
Maciej Wieczor-Retman
c5f7fb183a insns: Move NOP and HINT_NOP at the end of the file
For disassembler to work correctly NOPs should be at the very end of the
database file.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-29 17:17:39 +02:00
Yongjie Sheng
8ce0504457 update instruction VP2INTERSECT 2025-09-24 22:12:45 +08:00
Yongjie Sheng
d12a5b5156 add instruction VBCSTNEBF162PS 2025-09-24 21:09:36 +08:00
Yongjie Sheng
e548c76ab3 add AMX instruction TDPFP16PS 2025-09-24 19:52:27 +08:00
Yongjie Sheng
b15f0373d6 insns.dat: add the keylocker AESKLEWIDE_KL instructions
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-23 21:07:56 -07:00
Yongjie Sheng
8a30c94a09 add aes key locker instructions 2025-09-24 11:25:51 +08:00
H. Peter Anvin
af40cc63d2 isnsn.dat: remove unnecessary SM from PSHUF* instructions
The MMX and early SSE PSHUF* instructions were annotated SM0-1, which
is unnecessary (no ambiguity) but broke the tighter SM matching the
assembler now uses.

This is almost certainly underspecified now, but the MMX and early SSE
instruction patterns need to be tidied up anyway, and this is the
least impactful change that seems to fix the problem.

This unbreaks compiling ffmpeg.

Reported-by: Yongjie Sheng (Intel) <sheng.yongjie@outlook.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-23 15:45:42 -07:00
H. Peter Anvin
c0be53fc85 insns.dat: fix flags for the MSR instructions
- The MSR immediate instructions are under a separate flag
- All MSR instructions are privileged

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-23 12:12:12 -07:00
H. Peter Anvin
d782d1339f Merge remote-tracking branch 'maciej/apx.wip.for-hpa' 2025-09-23 12:01:24 -07:00
H. Peter Anvin
e8a0c32ba7 DFV: allow {dfv=pf} as an alias for {dfv=cf}; EQU {dfv}
PF and CF are always set to the same value; allow the programmer to
specify either or both.

Allow EQU to take a {dfv} expression without needing parens.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-23 11:56:31 -07:00
Maciej Wieczor-Retman
3edef01637 insns: avx: amx: Add missing instructions from ISE june 2025
Add all the missing instructions / instruction variants that are
specified in the 2025 June Intel ISE.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-23 18:56:26 +02:00
Maciej Wieczor-Retman
b92e1c638b insns: avx: Correct VSM4KEY4 memory operand size
Memory operand size for all VSM4KEY4 versions is specified as 128 bit
long, while the ymm register version should use 256 bit size.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-23 18:56:25 +02:00
Yongjie Sheng
f7f750a849 correct target operand from rm to mem only 2025-09-20 11:17:40 +08:00
H. Peter Anvin
c714d66d34 Fixes for JMP|CALL near, RETF, and segment instructions
Some weird things happened when macroizing.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 18:55:54 -07:00
H. Peter Anvin
a0396faf3b Fix control/debug register patterns
The control and debug registers are always using the default operand
size. It is probably easiest to just encode it explicitly for now.

Control registers are particularly weird because of the AMD "lock as
REX.R" hack...

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 16:26:35 -07:00
H. Peter Anvin
b390ce4bb8 insns.dat: fix far jmp/call patterns
Far jmp and call are special in many ways... not the least because of
the old legacy syntax of putting the size on the segment instead of
the offset.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 16:06:25 -07:00
H. Peter Anvin
ca50adfb7d BR 3392957: 64-bit K registers allowed in non-64-bit mode
Do not force the operand size for K registers and "ko#"
encodings. This resolves BR 3392957.

Reported-by: ig <glucksmann@avast.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 13:39:26 -07:00
H. Peter Anvin
8dae3d681d insns.dat: fix broken XCHG pattern (BR 3392951)
A pattern for XCHG was incompletely macroized. This caused a
fallthrough to the next pattern, reversing the operands, but would
probably have had generated incorrect code in at least some cases.

Beef up the xchg test.

Reported-by: E. C. Masloch <pushbx@ulukai.org>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 12:56:19 -07:00
H. Peter Anvin
9aecb094a8 insns.dat: use explict macro flags for arithmetic flags
Instead of do more ad hoc hacks in preinsns.pl, add explicit macro
flags for the arithmetic instructions. This also allows folding CMP
back into the standard arithmetic instructions.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-09-19 12:28:07 -07:00
Maciej Wieczor-Retman
f0efb28d98 assemble: apx: Add NF forbidden flag and fix SBB and ADC
ADC and SBB don't support using the {nf} prefix. They are the only one
in the arithmetic instructions group that are this way.

Add a flag that will warn when an instructions wants to use {nf} but
doesnt' support it.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-19 14:53:04 +02:00
Maciej Wieczor-Retman
936cc5bbf6 insns: travis: apx: Fix msr instructions missing IMM operand
APX variants of RDMSR and WRMSRNS were missing the immediate operand.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-19 14:53:04 +02:00
Maciej Wieczor-Retman
0fd4cff921 insns: travis: apx: CTESTcc instruction
Add the database entry for CTESTcc and the relevant test cases. The
syntax is basically CCMPSCC without two syntax variants.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-16 14:18:05 +02:00
H. Peter Anvin
42795e59a7 Merge remote-tracking branch 'maciej/apx.wip.travis' 2025-09-15 20:06:57 -07:00
H. Peter Anvin
3ea17cb2f8 Merge commit '4a5bc1cec672240515d04e15bbcb7b58a50c23b0' 2025-09-15 13:04:34 -07:00
H. Peter Anvin
53fe1a132c Merge remote-tracking branch 'yongjie/master' 2025-09-15 13:00:26 -07:00
Maciej Wieczor-Retman
eb25e7ab8e insns: CFCMOVcc
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-15 19:07:43 +02:00
Maciej Wieczor-Retman
4a5bc1cec6 insns: Fix ccmpscc T/F encoding
The encodings of 'true' and 'false' variants of the CCMPSCC instructions
were swapped. Correct that in the preprocessor script.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-15 18:05:15 +02:00
Maciej Wieczor-Retman
fbccbfba0f insns: travis: apx: WRSSD/Q and WRUSSD/Q instructions
Add database entries and test cases for WRSSD, WRSSQ, WRUSSD and WRUSSQ
instructions.

Fix whitespace in legacy database entries.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
2025-09-15 16:16:26 +02:00