Commit Graph

4799 Commits

Author SHA1 Message Date
Jan Beulich
acd86c81f0 x86: correct VCVT{,U}SI2SD
Properly reject inappropriate suffixes (No_lSuf / No_qSuf mistakenly
omitted by cf665fee1d ["x86: re-work AVX512 embedded rounding / SAE"]),
to avoid emitting bad or arbitrarily guessed instructions. Interestingly
check_{long,qword}_suffix() don't help here, which perhaps is another
indication that the way they work right now isn't quite appropriate.

Sadly correcting just the templates breaks operand ambiguity detection,
since so far that worked from a single template permitting more than one
suffix. Here we have ambiguity though which can now be noticed only when
taking all (matching) templates together. Therefore we need to determine
further matching templates (see code comments for constraints), to then
accumulate permitted suffixes across all of them.
2024-05-24 11:50:38 +02:00
Matthieu Longo
ef2d28fd02 aarch64: fix incorrect encoding for system register pmsdsfr_el1
This patch fixes a mistake in the encoding of the system register
pmsdsfr_el1.

Reference:
https://developer.arm.com/documentation/ddi0601/2022-09/AArch64-Registers/PMSDSFR-EL1--Sampling-Data-Source-Filter-Register?lang=en
2024-05-22 12:02:09 +01:00
Cui, Lili
bbe8d019ed Support APX zero-upper
This patch is to enable ZU for IMUL (opcodes 0x69 and 0x6B) and SETcc.
Since the spec only recommends one form of setzu, I won't be adding
set<cc>reg32/reg64 support in this patch.

gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Handle ZU.
        * testsuite/gas/i386/x86-64.exp: Added new tests for ZU.
        * testsuite/gas/i386/x86-64.exp: Added new tests for ZU.
        * testsuite/gas/i386/x86-64-apx-zu-intel.d: New test.
        * testsuite/gas/i386/x86-64-apx-zu-inval.l: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-zu.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-prefix.h: Handle PREFIX_EVEX_MAP4_40 ~
        PREFIX_EVEX_MAP4_4F.
        * i386-dis-evex.h: Ditto.
        * i386-dis.c (struct dis386): Add new micro 'ZU'.
        (putop): Handle %ZU.
        * i386-gen.c: Added ZU.
        * i386-opc.h: Ditto.
        * i386-opc.tbl: Added new templates to support ZU.
2024-05-22 16:15:47 +08:00
Srinath Parvathaneni
e63b1d5950 aarch64: Fix the hyphenated disassembly comment.
This patch fixes the following comment.

-  /* The hyphenated form is preferred for disassembly if there are
-     more than two registers in the list, and the register numbers
      are monotonically increasing in increments of one.  */

+  /* The hyphenated form is preferred for disassembly if there is
+     more than one register in the list, and the register numbers
      are monotonically increasing in increments of one.  */
2024-05-21 14:59:10 +01:00
Claudio Bantaloukas
e390d876ab aarch64: Add support for the fpmr system register 2024-05-20 15:18:10 +01:00
Jan Beulich
44fc9616c2 aarch64: correct SVE2.1 ld2q (scalar plus scalar)
It's opcode was wrong, as was e.g. easily visible from the inappropriate
testcase expectation.
2024-05-17 10:52:53 +02:00
Jan Beulich
132a0b0d77 aarch64: correct SVE2.1 ld{3,4}q / st{3,4}q (scalar plus immediate)
Like their byte, half, word, and doubleword counterparts their
immediates are multiples of 3 / 4 respectively.
2024-05-17 10:52:36 +02:00
Victor Do Nascimento
a09771e687 aarch64: fp8 convert and scale - add sme2 insn variants
Add the SME2 variant of the FP8 convert and scale
instructions, enabled at assembly-time using the `+sme2+fp8'
architectural extension flag.  More specifically, support is
added for the following instructions:

Multi-vector floating-point convert from FP8 to
BFloat16 (in-order):
-----------------------------------------------

  - bf1cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - bf2cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from FP8 to
deinterleaved BFloat16:
-----------------------------------------------

  - bf1cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - bf2cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from BFloat16
to packed FP8 format:
-------------------------------------------------

  - bfcvt <Zd>.B, { <Zn1>.H-<Zn2>.H }

Multi-vector floating-point convert from FP8 to
half-precision (in-order):
-----------------------------------------------

  - f1cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - f2cvt { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from FP8 to
deinterleaved half-precision:
-----------------------------------------------

  - f1cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B
  - f2cvtl { <Zd1>.H-<Zd2>.H }, <Zn>.B

Multi-vector floating-point convert from half-precision
to packed FP8 format:
-------------------------------------------------------

fcvt_2h

Multi-vector floating-point convert from single-precision
to packed FP8 format:
---------------------------------------------------------
fcvt_4s

Multi-vector floating-point convert from single-precision
to interleaved FP8 format:
---------------------------------------------------------

  - fcvtn <Zd>.B, { <Zn1>.S-<Zn4>.S }

Multi-vector floating-point adjust exponent by vector:
------------------------------------------------------

  - fscale { <Zdn1>.H-<Zdn2>.H }, { <Zdn1>.H-<Zdn2>.H },
	   <Zm>.H
  - fscale { <Zdn1>.S-<Zdn2>.S }, { <Zdn1>.S-<Zdn2>.S },
	   <Zm>.S
  - fscale { <Zdn1>.D-<Zdn2>.D }, { <Zdn1>.D-<Zdn2>.D },
	   <Zm>.D

Multi-vector floating-point adjust exponent:
--------------------------------------------

  - fscale { <Zdn1>.H-<Zdn2>.H }, { <Zdn1>.H-<Zdn2>.H },
	   { <Zm1>.H - <Zm2>.H }
  - fscale { <Zdn1>.S-<Zdn2>.S }, { <Zdn1>.S-<Zdn2>.S },
	   { <Zm1>.S - <Zm2>.S }
  - fscale { <Zdn1>.D-<Zdn2>.D }, { <Zdn1>.D-<Zdn2>.D },
	   { <Zm1>.D - <Zm2>.D }
2024-05-16 13:22:30 +01:00
Victor Do Nascimento
eef66d27fc aarch64: fp8 convert and scale - add sve2 insn variants
Add the SVE2 variant of the FP8 convert and scale instructions,
enabled at assembly-time using the `+sve2+fp8' architectural
extension flag.  More specifically, support is added for the
following instructions:

FP8 convert to BFloat16 (bottom/top):
-------------------------------------

  - bf1cvt Z<d>.H, Z<n>.B
  - bf2cvt Z<d>.H, Z<n>.B
  - bf1cvtlt Z<d>.H, Z<n>.B
  - bf2cvtlt Z<d>.H, Z<n>.B

FP8 convert to half-precision (bottom/top):
-------------------------------------------

  - f1cvt Z<d>.H, Z<n>.B
  - f2cvt Z<d>.H, Z<n>.B
  - f1cvtlt Z<d>.H, Z<n>.B
  - f2cvtlt Z<d>.H, Z<n>.B

BFloat16/half-precision convert, narrow and
interleave to FP8:
-------------------------------------------

  - bfcvtn Z<d>.B, { Z<n>1.H - Z<n>2.H }
  - fcvtn Z<d>.B, { Z<n>1.H - Z<n>2.H }

Single-precision convert, narrow and interleave
to FP8 (bottom/top):
-----------------------------------------------

  - fcvtnb Z<d>.B, { Z<n>1.S - Z<n>2.S }
  - fcvtnt Z<d>.B, { Z<n>1.S - Z<n>2.S }
2024-05-16 13:22:30 +01:00
Victor Do Nascimento
ab501c0dee aarch64: fp8 convert and scale - Add advsimd insn variants
Add the advanced SIMD variant of the FP8 convert and scale
instructions, enabled at assembly-time using the `+fp8'
architectural extension flag.  More specifically, support is
added for the following instructions:

FP8 convert to BFloat16 (vector):
---------------------------------

  - bf1cvtl V<d>.8H, V<n>.8B
  - bf2cvtl V<d>.8H, V<n>.8B
  - bf1cvtl2 V<d>.8H, V<n>.16B
  - bf2cvtl2 V<d>.8H, V<n>.16B

FP8 convert to half-precision (vector):
---------------------------------------

  - f1cvtl V<d>.8H, V<n>.8B
  - f2cvtl V<d>.8H, V<n>.8B
  - f1cvtl2 V<d>.8H, V<n>.16B
  - f2cvtl2 V<d>.8H, V<n>.16B

Single-precision to FP8 convert and narrow (vector):
----------------------------------------------------

  - fcvtn V<d>.8B, V<n>.4S, V<m>.4S
  - fcvtn2 V<d>.16B, V<n>.4S, V<m>.4S

Half-precision to FP8 convert and narrow (vector):
--------------------------------------------------

  - fcvtn V<d>.8B, V<n>.4H, V<m>.4H
  - fcvtn V<d>.16B, V<n>.8H, V<m>.8H

Floating-point adjust exponent by vector:
-----------------------------------------

  - fscale V<d>.4H, V<n>.4H, V<m>.4H
  - fscale V<d>.8H, V<n>.8H, V<m>.8H
  - fscale V<d>.2S, V<n>.2S, V<m>.2S
  - fscale V<d>.4S, V<n>.4S, V<m>.4S
  - fscale V<d>.2d, V<n>.2d, V<m>.2d
2024-05-16 13:22:30 +01:00
Victor Do Nascimento
7d0383ad39 aarch64: fp8 convert and scale - add feature flags and related structures 2024-05-16 13:22:30 +01:00
Matthieu Longo
f01ae0392e aarch64: add SPMU feature and its associated registers 2024-05-16 12:36:14 +01:00
Joseph Faulls
7a7ec56c81 RISC-V: Search for mapping symbols from the last one found
With previous behaviour, multiple mapping symbols within the same
function would result in all the mapping symbols being searched.
This could slow down disassembly dramatically.

Multiple mapping symbols within a function can be a result of encoding
instructions as data, like sometimes seen in random instruction
generators.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_search_mapping_symbol): Use last mapping
	symbol if it exists.
2024-05-15 07:01:54 +08:00
Richard Earnshaw
ad5da6e6d8 arm: opcodes: remove Maverick disassembly.
Remove the patterns to match Maverick co-processor instructions from
the disassembly tables.

This required fixing a couple of tests in the assembler testsuite
where we, probably incorrectly, disassembled generic co-processor
instructions as a Maverick instruction (it particularly made no sense
to do this for Armv6t2 in Thumb state).
2024-05-14 10:56:58 +01:00
Nelson Chu
c144f63833 RISC-V: Support B, Zaamo and Zalrsc extensions.
* https://github.com/riscv/riscv-b/tags
Added standard B extension back, which implies Zba, Zbb and Zbs extensions.

* https://github.com/riscv/riscv-zaamo-zalrsc/tags
Splited standard A extension into two new extensions, Zaamo and Zalrsc.
The A extension implies Zaamo and Zalrsc extensions.

Not sure if we need to do the similar check as i and zicsr/zifencei.

Passed riscv[32|64]-[elf/linux] binutils testcases.

bfd/
	* elfxx-riscv.c (riscv_implicit_subsets): Added imply rules
	for A and B extensions.  The A implies Zaamo and Zalrsc, the
	B implies Zba, Zbb and Zbs.
	(riscv_supported_std_ext): Supported B extension with v1.0.
	(riscv_supported_std_z_ext): Supported Zaamo and Zalrsc with v1.0.
	(riscv_multi_subset_supports, riscv_multi_subset_supports_ext): Updated.
include/
	* opcode/riscv.h (riscv_insn_class): Removed INSN_CLASS_A, Added
	INSN_CLASS_ZAAMO and INSN_CLASS_ZALRSC.
opcodes/
	* riscv-opc.c (riscv_opcodes): Splited standard A extension into two
	new extensions, Zaamo and Zalrsc.
gas/
	* testsuite/gas/riscv/march-imply-a.d: New testcase.
	* testsuite/gas/riscv/march-imply-b.d: New testcase.
	* testsuite/gas/riscv/attribute-01.d: Updated.
	* testsuite/gas/riscv/attribute-02.d: Updated.
	* testsuite/gas/riscv/attribute-03.d: Updated.
	* testsuite/gas/riscv/attribute-04.d: Updated.
	* testsuite/gas/riscv/attribute-05.d: Updated.
	* testsuite/gas/riscv/attribute-10.d: Updated.
	* testsuite/gas/riscv/mapping-symbols.d: Updated.
	* testsuite/gas/riscv/march-imply-g.d: Updated.
	* testsuite/gas/riscv/march-imply-unsupported.d: Updated.
	* testsuite/gas/riscv/march-ok-reorder.d: Updated.
ld/
	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Updated.
	* testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: Updated.
2024-05-08 12:34:58 +08:00
Cui, Lili
c8866e3ec5 x86: Drop using extension_opcode to encode vvvv register
gas/ChangeLog:

        * config/tc-i386.c (build_modrm_byte): Dropped the use of
        extension_opcode to encode the vvvv register.
        * testsuite/gas/i386/x86-64-sse2avx.d: Added new testcases.
        * testsuite/gas/i386/x86-64-sse2avx.s: Diito.

opcodes/ChangeLog:

        * i386-opc.tbl: Added DstVVVV to some extension_opcode instructions.
	* i386-tbl.h: Regenerated.
2024-05-06 18:33:45 +08:00
Cui, Lili
0820c9f5fc x86: Drop SwapSources
gas/ChangeLog:

        * config/tc-i386.c (build_modrm_byte): Dropped the use of
	SWAP_SOURCES to encode the vvvv register.

opcodes/ChangeLog:

        * i386-opc.h (SWAP_SOURCES): Dropped.
        (NO_DEFAULT_MASK): Adjusted the value.
        (ADDR_PREFIX_OP_REG): Ditto.
        (DISTINCT_DEST): Ditto.
        (IMPLICIT_STACK_OP): Ditto.
        (VexVVVV_SRC2): New.
        * i386-opc.tbl: Dropped SwapSources and replaced its VexVVVV
	with Src1VVVV.
	* i386-tbl.h: Regenerated.
2024-05-06 18:21:28 +08:00
Cui, Lili
f2a3a8814d x86: Use vexvvvv as the switch state to encode the vvvv register
Use vexvvvv as the switch state, and replace VexVVVV with Src1VVVV.
Src1VVVV means using VEX.vvvv encodes the first source register
operand. The old logic did not check vexvvvv first, which made the
logic here very complicated.

gas/ChangeLog:

        * config/tc-i386.c (optimize_encoding): Replaced 1 with Src1VVVV.
        (build_modrm_byte): Used vexvvvv to encode the vvvv register.
        (s_insn): Replaced 1 with Src1VVVV.

opcodes/ChangeLog:

        * i386-opc.h (VexVVVV_DST): Adjusted the value.
        (Src1VVVV): New.
        * i386-opc.tbl: Replaced part VexVVVV with Src1VVVV.
	* i386-tbl.h: Regenerated.
2024-05-06 18:16:42 +08:00
Jan Beulich
e6d60e7624 x86: tidy <sse*> templates
Some of them no longer need a separate vvvv attribute, thus allowing
them to be simplified. For <aes> the situation is slightly different:
None of the remaining uses make use of vvvv anymore.
2024-05-03 09:27:25 +02:00
Jan Beulich
1d026d6b19 x86/APX: further extend SSE2AVX coverage
Since {vex}/{vex3} are respected on legacy mnemonics when -msse2avx is
in use, {evex} should be respected, too. So far this is the case only
for insns where eGPR-s can come into play. Extend coverage to insns with
only %xmm register and possibly immediate operands.
2024-05-03 09:27:00 +02:00
Jan Beulich
24187fb9c0 x86/APX: extend SSE2AVX coverage
Legacy encoded SIMD insns are converted to AVX ones in that mode. When
eGPR-s are in use, i.e. with APX, convert to AVX10 insns (where
available; there are quite a few which can't be converted).

Note that LDDQU is represented as VMOVDQU32 (and the prior use of the
sse3 template there needs dropping, to get the order right).

Note further that in a few cases, due to the use of templates, AVX512VL
is used when AVX512F would suffice. Since AVX10 is the main reference,
this shouldn't be too much of a problem.
2024-05-03 09:26:25 +02:00
Jan Beulich
d125c4bbce x86: zap value-less Disp8MemShift from non-EVEX templates
In order to allow to continue to use templatized SSE2AVX templates when
enhancing those to also cover eGPR usage, Disp8MemShift wants using to
deviate from what general template attributes supply. That requires
using Disp8MemShift in a way also affecting non-EVEX templates, yet
having this attribute set would so far implicitly mean EVEX encoding.
Recognize the case and instead zap the attribute if no other attribute
indicates EVEX encoding.

No change in generated tables.
2024-05-03 09:24:48 +02:00
Claudio Bantaloukas
3e562e4be8 arm: Fix MVE vmla encoding 2024-04-23 17:59:57 +01:00
Victor Do Nascimento
911cb006bf aarch64: Fix coding style issue in `aarch64-dis.c'
Fix integer value being returned from boolean function, as introduced
in `aarch64: Remove asserts from operand qualifier decoders [PR31595]'.
2024-04-22 10:32:45 +01:00
Cui, Lili
b5247082c4 x86/APX: Add invalid check for APX EVEX.X4.
gas/ChangeLog:

        * config/tc-i386.c (build_apx_evex_prefix): Added invalid check for APX
        X4.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Added invalid
        testcase.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.

opcodes/ChangeLog:

        * i386-dis.c (get_valid_dis386): Added invalid check for APX X4.
2024-04-22 09:25:56 +08:00
Alan Modra
a1defbe426 mmix disassemble memory leak
It's a once-off and of no consequence, but fix it anyway.  The mmix
caonoicalize_syms array is an array of pointers.  Freeing it won't
lose symbol names.

	* mmix-dis.c (initialize_mmix_dis_info): Free syms.
2024-04-19 10:00:57 +09:30
Victor Do Nascimento
5b1c70bfe0 aarch64: Remove asserts from operand qualifier decoders [PR31595]
Given that the disassembler should never abort when decoding
(potentially random) data, assertion statements in the
`get_*reg_qualifier_from_value' function family prove problematic.

Consider the random 32-bit word W, encoded in a data segment and
encountered on execution of `objdump -D <obj_name>'.

If:

  (W & ~opcode_mask) == valid instruction

Then before `print_insn_aarch64_word' has a chance to report the
instruction as potentially undefined, an attempt will be made to have
the qualifiers for the instruction's register operands (if any)
decoded.  If the relevant bits do not map onto a valid qualifier for
the matched instruction-like word, an abort will be triggered and the
execution of objdump aborted.

As this scenario is perfectly feasible and, in light of the fact that
objdump must successfully decode all sections of a given object file,
it is not appropriate to assert in this family of functions.

Therefore, we add a new pseudo-qualifier `AARCH64_OPND_QLF_ERR' for
handling invalid qualifier-associated values and re-purpose the
assertion conditions in qualifier-retrieving functions to be the
predicate guarding the returning of the calculated qualifier type.
If the predicate fails, we return this new qualifier and allow the
caller to handle the error as appropriate.

As these functions are called either from within
`aarch64_extract_operand' or `do_special_decoding', both of which are
expected to return non-zero values, it suffices that callers return
zero upon encountering `AARCH64_OPND_QLF_ERR'.

Ar present the error presented in the hypothetical scenario has been
encountered in `get_sreg_qualifier_from_value', but the change is made
to the whole family to keep the interface consistent.

Bug: https://sourceware.org/PR31595
2024-04-17 11:18:55 +01:00
Hu, Lin1
e59144c6ed Add W table for USER_MSR under MAP4.
opcodes/ChangeLog:

	* i386-dis-evex-mod.h: Modify MOD_EVEX_MAP4_F8_P1,
	MOD_EVEX_MAP4_F8_P3.
	* i386-dis-evex-w.h (EVEX_W_MAP4_F8_P1_M_1): New.
	(EVEX_W_MAP4_F8_P3_M_1): Ditto.
	* i386-dis.c (vex_w_table): Add EVEX_W_MAP4_F8_P1_M_1,
	EVEX_W_MAP4_F8_P3_M_1.
	* i386-opc.tbl: Remove redundant '|'.
2024-04-17 13:57:50 +08:00
Jens Remus
6f3cf71845 aarch64: Treat operand "SME list of ZA tiles" as immediate (PR 31561)
The AArch64 instruction table (aarch64-tbl.h) defines the operand
"SME list of ZA tiles" (SME_list_of_64bit_tiles) as immediate. During
assembly it is correctly encoded as immediate value (imm.value) in
parse_operands. During disassembly it is first correctly decoded as
immediate value (imm.value) in aarch64_ext_imm called by
aarch64_extract_operand, but then erroneously treated as register
number (reg.regno) in aarch64_print_operand.

This resolves the assembler test case "SME extension (ZERO)" to
erroneously fail on s390. On AArch64 - being little-endian - the struct
aarch64_opnd_info union fields reg.regno and imm.value share their
least-significant bits. On s390 - being big-endian - they do not.

opcodes/
	PR binutils/31561
	* aarch64-opc.c: Treat operand "SME list of ZA tiles" as
	immediate.

Bug: https://sourceware.org/PR31561
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Acked-by: Nick Clifton <nickc@redhat.com>
2024-04-09 17:21:53 +02:00
Jens Remus
676b98078f s390: Flag conditional branch relative insns as condjump
Flag conditional branch relative (extended) mnemonics clij* and clgij*
as "condjump" for jump visualization in disassembly. They were missed
to be flagged as such in commit c5306fed7d ("s390: Support for jump
visualization in disassembly").

opcodes/
	* s390-opc.txt: Flag conditional branch relative instructions
	clij* and clgij* as condjump for jump visualization in
	disassembly.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Acked-by: Nick Clifton <nickc@redhat.com>
2024-04-09 17:17:02 +02:00
Alex Coplan
cd714ac07c arm: Fix disassembly of MVE vq[r]shr[u]n
This patch fixes the disassembly of vq[r]shr[u]n insns so that the
shift immediate is properly decoded.  See the description of the
previous patch for an example of the incorrect disassembly.

As part of this patch we also fix the mve-vqrshrn.d test which was
testing for the incorrect disassembly of the immediates.  The
disassembly now matches the assembled instructions in that test.

Finally we add an mve-vqshrn test which tests the non-rounding variants
of those insns, whose encoding we fixed with the previous patch in this
series.
2024-04-09 10:09:25 +01:00
Alex Coplan
f9d6cf2e9f arm: Refactor condition for print_mve_shift_n
This is intended to have no functional change, but refactors the
condition guarding the call to print_mve_shift_n in arm-dis.c ahead of a
later patch which adds additional insns to the set of those whose
shift immediate is disassembled using print_mve_shift_n.
2024-04-09 10:09:25 +01:00
Jiawei
9132c8152b RISC-V: Support Zcmp push/pop instructions.
Support zcmp extension push/pop/popret and popret zero instructions.
The `reg_list' is a list containing 1 to 13 registers, we can use:
"{ra}, {ra, s0}, {ra, s0-s1}, {ra, s0-s2} ... {ra, s0-sN}"
to present this feature.

Passed gcc/binutils regressions of riscv-gnu-toolchain.

Most of work was finished by Sinan Lin.
Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com>
Co-Authored by: Mary Bennett <mary.bennett@embecosm.com>
Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com>
Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com>
Co-Authored by: Simon Cook <simon.cook@embecosm.com>
Co-Authored by: Shihua Liao <shihua@iscas.ac.cn>
Co-Authored by: Yulong Shi <yulong@iscas.ac.cn>

bfd/ChangeLog:

        * elfxx-riscv.c (riscv_implicit_subset): Imply zca for zcmp.
	(riscv_supported_std_z_ext): Added zcmp with version 1.0.
	(riscv_parse_check_conflicts): Zcmp conflicts with d/zcd.
        (riscv_multi_subset_supports): Handle zcmp.
        (riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

	* NEWS: Updated.
        * config/tc-riscv.c (regno_to_reg_list): New function, used to map
	register to reg_list number.
        (reglist_lookup): Called reglist_lookup_internal.  Return false if
	reg_list number is zero, which is an invalid value.
	(reglist_lookup_internal): Parse register list, and return the last
	register by regno_to_reg_list.
        (validate_riscv_insn):  New operators.
        (riscv_ip): Ditto.
	* testsuite/gas/riscv/march-help.l: Updated.
        * testsuite/gas/riscv/zcmp-push-pop-fail.d: New test.
        * testsuite/gas/riscv/zcmp-push-pop-fail.l: New test.
        * testsuite/gas/riscv/zcmp-push-pop-fail.s: New test.
        * testsuite/gas/riscv/zcmp-push-pop.d: New test.
        * testsuite/gas/riscv/zcmp-push-pop.s: New test.

include/ChangeLog:

        * opcode/riscv-opc.h (MATCH/MASK_CM_PUSH): New macros for zcmp.
        (MATCH/MASK_CM_POP): Ditto.
        (MATCH/MASK_CM_POPRET): Ditto.
        (MATCH/MASK_CM_POPRETZ): Ditto.
        (DECLARE_INSN): New declarations for zcmp.
        * opcode/riscv.h (EXTRACT/ENCODE/VALID_ZCMP_SPIMM): Handle spimm
	operand for zcmp.
        (OP_MASK_REG_LIST): Handle operand for zcmp register list.
        (OP_SH_REG_LIST): Ditto.
        (ZCMP_SP_ALIGNMENT): New argument, used in riscv_get_sp_base.
        (X_S0, X_S1, X_S2, X_S10, X_S11): New register numbers.
        (enum riscv_insn_class): Added INSN_CLASS_ZCMP.
        (extern riscv_get_sp_base): Added.

opcodes/ChangeLog:

        * riscv-dis.c (print_reg_list): New function, used to get zcmp
	reg_list field.
        (riscv_get_spimm): New function, used to get zcmp sp adjustment
	immediate.
        (print_insn_args): Handle new operands for zcmp.
        * riscv-opc.c (riscv_get_sp_base): New function, used by gas and
	objdump.  Get sp base adjustment.
	(riscv_opcodes): Added zcmp instructions.
2024-04-09 15:56:12 +08:00
Hu, Lin1
edb30f5782 Support {evex} pseudo prefix for decode evex promoted insns without egpr32.
This patch is based on APX NF patch and also adds test cases for Checking 64-bit insns not sizeable through
register operands with evex.

gas/ChangeLog:

        * testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Added no-egpr testcases for movbe.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-wig.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Added tests.
        * testsuite/gas/i386/noreg64-evex.d: New test.
        * testsuite/gas/i386/noreg64-evex.e: Ditto.
        * testsuite/gas/i386/noreg64-evex.s: Ditto.
        * testsuite/gas/i386/x86-64-apx_f-evex.d: Ditto.
        * testsuite/gas/i386/x86-64-apx_f-evex.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex.h: Added %ME to movbe.
        * i386-dis.c : Added %XE to evex_from_vex instructions to output {evex}.
        (struct dis386): New %ME.
        (putop): Handle %ME and output {evex} for evex_from_legacy instructions.
        * Return early when the instruction name is (bad).
2024-04-09 11:18:23 +08:00
Cui, Lili
dd74a60337 Support APX NF
For the case when NDD and NF are both 0 in evex-promoted format,
we will fully support and test it in another patch.

gas/ChangeLog:

       * NEWS: Support Intel APX NF.
       * config/tc-i386.c (enum i386_error): Add unsupported_nf.
       (struct _i386_insn): Add has_nf.
       (is_apx_evex_encoding): Ditto.
       (build_apx_evex_prefix): Encode the NF bit.
       (md_assemble): Handle unsupported_nf.
       (parse_insn): Handle Prefix_NF and report bad for illegal combination.
       (can_convert_NDD_to_legacy): Replace i.tm.opcode_modifier.nf with i.has_nf.
       (match_template): Support D for APX_F insns and check NF support.
       * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Add bad test for NF bit.
       * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.
       * testsuite/gas/i386/x86-64-apx-inval.l: Ditto.
       * testsuite/gas/i386/x86-64-apx-inval.s: Ditto.
       * testsuite/gas/i386/x86-64.exp: Add apx nf tests.
       * testsuite/gas/i386/x86-64-apx-nf-intel.d: New test.
       * testsuite/gas/i386/x86-64-apx-nf.d: Ditto.
       * testsuite/gas/i386/x86-64-apx-nf.s: Ditto.

opcodes/ChangeLog:

       * i386-dis-evex.h: Add %NF to the instructions that support APX NF and
       add new instruction imul, popcnt, tzcnt and lzcnt to EVEX table.
       * i386-dis-evex-reg.h: Ditto.
       * i386-dis.c (struct instr_info): Add nf.
       (struct dis386): Add "NF" for EVEX.NF.
       (get_valid_dis386): Set ins->vex.nf and report bad-nf for illegal case.
       (print_insn): Handle ins.vex.nf.
       (putop): Handle "%NF".
       * i386-opc.h (Prefix_NF): New.
       * i386-opc.tbl: Added new entries to support full APX NF instructions.
       * i386-mnem.h: Regenerated.
       * i386-tbl.h: Regenerated.
2024-04-07 17:28:25 +08:00
H.J. Lu
cca46dea4d Revert "x86: Restore APX shift-double instructions with omitted shift count"
This reverts commit c2d698fe03.

GCC 14 has been changed to use explicit shift count in shift-double
instructions by the commit:

06a7e7514af x86: Use explicit shift count in double-precision shifts

gas/

	PR gas/31606
	* testsuite/gas/i386/x86-64-apx-ndd-wig.d: Updated.
	* testsuite/gas/i386/x86-64-apx-ndd.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-ndd.s: Remove tests for APX
	shift-double instructions with omitted shift count.

opcodes/

	PR gas/31606
	* i386-opc.tbl: Remove APX shift-double instructions with
	omitted shift count.
	* i386-tbl.h: Regenerated.
2024-04-06 05:07:18 -07:00
Christophe Lyon
54e2d897a6 Add missing install-dvi and install-ps Makefie targets.
For some reason, these targets are missing although others from the
same family are present. This looks like an oversight.

This enables calling 'make install-dvi' from the top-level build
directory.
2024-04-05 07:02:56 +00:00
H.J. Lu
c2d698fe03 x86: Restore APX shift-double instructions with omitted shift count
Restore APX shift-double instructions with omitted shift count since
they are generated by GCC as shown in:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114590

gas/

	PR gas/31606
	* testsuite/gas/i386/x86-64-apx-ndd-wig.d: Updated.
	* testsuite/gas/i386/x86-64-apx-ndd.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-ndd.s: Add tests for APX
	shift-double instructions with omitted shift count.

opcodes/

	PR gas/31606
	* i386-opc.tbl: Restore APX shift-double instructions with
	omitted shift count.
	* i386-tbl.h: Regenerated.
2024-04-04 13:16:20 -07:00
Jan Beulich
b1c4af2086 Arm64: check tied operand specifier in aarch64-gen
Make sure that field actually matches the specified operands. Don't
follow existing F_PSEUDO checking in using assertions, though. Print
meaningful error messages, thus - while not having a line number
available - at least providing some indication of where things are
wrong.

Fix SVE2.1's extq accordingly, but don't extend the testsuite there:
There are further issues with its operands (SVE_Zm_imm4 doesn't look to
be correct to use there, as that describes an indexed vector register,
while here a separate vector register and immediate operand are to be
specified).
2024-04-03 10:42:44 +02:00
Jan Beulich
ef9a6314d8 x86: add missing No_qSuf to non-64-bit PTWRITE
While largely benign, it still should have been put there when the
original single template was split (commit a04973848d).
2024-04-03 10:41:30 +02:00
Jan Beulich
0006623c18 x86: drop stray Size64 from WRSSQ
Like for WRUSSQ it's not needed here. The legacy insn had gained it in
the course of zapping Rex64, but that attribute wasn't needed here
either. The APX insn then simply gained it by copy-and-paste, I suppose.
2024-04-03 10:40:57 +02:00
Cui, Lili
8963a60d7b x86/APX: Remove KEYLOCKER and SHA promotions from EVEX MAP4
APX spec removed KEYLOCKER and SHA promotions from EVEX MAP4.
https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html

gas/ChangeLog:

        * NEWS: Mention that remove KEYLOCKER and SHA promotions from EVEX
	* MAP4.
        * config/tc-i386.c (process_operands): Removed special handling of
	* KEYLOCKER and SHA.
        * testsuite/gas/i386/x86-64-apx-egpr-promote-inval.l: Removed KEYLOCKER
        * and SHA instructions.
        * testsuite/gas/i386/x86-64-apx-egpr-promote-inval.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted-wig.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted.d: Ditto.
        * testsuite/gas/i386/x86-64-apx-evex-promoted.s: Ditto.

opcodes/ChangeLog:

        * i386-dis-evex-prefix.h: Removed KEYLOCKER and SHA instructions.
        * i386-dis-evex.h: Ditto.
        * i386-opc.tbl: Ditto.
        * i386-dis.c (print_vector_reg): Removed special handling of KEYLOCKER
	*  and SHA.
2024-04-03 09:50:00 +08:00
Jan Beulich
5fc0b1f79f x86: templatize RAO-INT insns
It's only four of them, but still better to reduce redundancy.
2024-03-28 11:50:27 +01:00
Jan Beulich
b38b161e54 x86: templatize ADX insns
It's only two of them, but still better to reduce redundancy.
2024-03-28 11:50:06 +01:00
Jan Beulich
ffa2571063 x86: templatize shift-double insns
With the multitude of new APX templates, it finally becomes desirable to
further remove redundancy by also templatizing basic arithmetic insns.
Continue with the shift-double ones.

While there also drop the APX form with ShiftCount omitted. Other shift
and rotate insns were deliberately left without this form as well. Note
that there's also no testsuite adjustment needed for this, indicating
that the form wasn't tested either.
2024-03-28 11:49:48 +01:00
Jan Beulich
fe17c02650 x86: templatize shift/rotate insns
With the multitude of new APX templates, it finally becomes desirable to
further remove redundancy by also templatizing basic arithmetic insns.
Continue with the "ordinary" shift and rotate ones.

While there also drop the APX form of RCL/RCR with Imm1 omitted. Other
shift insns as well as ROR/ROL were deliberately left without this form
as well. Note that there's also no testsuite adjustment needed for this,
indicating that the form wasn't tested either.

Furthermore since RCL/RCR already had non-NDD APX forms, those end up
being added for the other 6 mnemonics, too.
2024-03-28 11:49:24 +01:00
Jan Beulich
42eb20eb35 x86: templatize binary ALU insns
With the multitude of new APX templates, it finally becomes desirable to
further remove redundancy by also templatizing basic arithmetic insns.
Continue with a the more complex binary (two source) cases.

Note how this adds a missing CheckOperandSize to one of the APX sub
forms.

Furthermore since SBB already had a non-NDD APX form, one ends up
being added for the other 6 mnemonics, too.
2024-03-28 11:49:01 +01:00
Jan Beulich
568473a437 x86: templatize unary ALU insns
With the multitude of new APX templates, it finally becomes desirable to
further remove redundancy by also templatizing basic arithmetic insns.
Continue with a few simple unary (single source) cases.
2024-03-28 11:48:47 +01:00
Jan Beulich
cd9ca24dd2 x86: templatize INC/DEC
With the multitude of new APX templates, it finally becomes desirable to
further remove redundancy by also templatizing basic arithmetic insns.
Start with the simplest case, accompanied by a necessary adjustment to
i386-gen (such that template uses can also be at the start of a line).

While there also drop a bogus (meaningless / unreachable) "break" as
well as a unused variable (which I'm surprised compilers didn't warn
about).
2024-03-28 11:47:59 +01:00
Saurabh Jha
f3f34f2b26 gas, aarch64: Add faminmax extension 2024-03-19 15:41:41 +00:00