Commit Graph

11846 Commits

Author SHA1 Message Date
Liwei Xu
3bac89e65f Support Intel AVX10.2 convert instructions
In this patch, we will support AVX10.2 convert instructions. All
of them are new instruction forms.

Among all the instructions, vcvtbiasph2[b,h]f8[,s] needs extra care.
Since Operand 2 could indicate memory size, we do not need suffix
under ATTmode. However, we could not fold all three templates but only
XMM/YMM since the dst operand size are the same for them. Also, a new
iterator <cvt8> is added to reduce redundancy.

gas/
	* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx10_2-256-cvt-intel.d: New.
	* testsuite/gas/i386/avx10_2-256-cvt.d: Ditto.
	* testsuite/gas/i386/avx10_2-256-cvt.s: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt-intel.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-cvt.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-cvt.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-cvt.s: Ditto.

opcodes/
	* i386-dis-evex-prefix.h: Add PREFIX_EVEX_0F3874,
	PREFIX_EVEX_MAP5_18, PREFIX_EVEX_MAP5_1B,
	PREFIX_EVEX_MAP5_1E and PREFIX_EVEX_MAP5_74.
	* i386-dis-evex.h: Add table pass for AVX10.2
	instructions.
	* i386-dis.c (MOD_EVEX_0F38B1): New.
	(PREFIX_EVEX_0F3874): Ditto.
	(PREFIX_EVEX_MAP5_18): Ditto.
	(PREFIX_EVEX_MAP5_1B): Ditto.
	(PREFIX_EVEX_MAP5_1E): Ditto.
	(PREFIX_EVEX_MAP5_74): Ditto.
	* i386-opc.tbl: Add AVX10.2 instructions.
	* i386-mnem.h: Regenerated.
	* i386-tbl.h: Ditto.

Co-authored-by: Kong Lingling <lingling.kong@intel.com>
Co-authored-by: Haochen Jiang <haochen.jiang@intel.com>
2024-10-16 10:25:35 +08:00
Cui, Lili
9c5b0ee4d5 x86: Refine instruction check in x86_check_tls_relocation
gas/ChangeLog:

        * config/tc-i386.c
	(x86_check_tls_relocation): Refine instruction check.
2024-10-15 14:17:57 +08:00
Haochen Jiang
990c7d444c x86/testsuite: Rename AVX10.2 media testcases
Change these testcase name to make them clearer.

gas/ChangeLog:

	* testsuite/gas/i386/avx10_2-256-1-intel.d: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media-intel.d: ...this.
	* testsuite/gas/i386/avx10_2-256-1.d: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media.d: ...this.
	* testsuite/gas/i386/avx10_2-256-1.s: Renamed to...
	* testsuite/gas/i386/avx10_2-256-media.s: ...this.
	* testsuite/gas/i386/avx10_2-512-1-intel.d: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media-intel.d: ...this.
	* testsuite/gas/i386/avx10_2-512-1.d: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media.d: ...this.
	* testsuite/gas/i386/avx10_2-512-1.s: Renamed to...
	* testsuite/gas/i386/avx10_2-512-media.s: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media-intel.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-256-media.s: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media-intel.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media.d: ...this.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Renamed to...
	* testsuite/gas/i386/x86-64-avx10_2-512-media.s: ...this.
	* testsuite/gas/i386/i386.exp: Change testcase name.
	* testsuite/gas/i386/x86-64.exp: Ditto.
2024-10-15 09:48:50 +08:00
Jan Beulich
4444dac517 ia64/ELF: fix HPUX testsuite fallout
... from 1f1b5e506b ("bfd/ELF: restrict file alignment for object
files"), as noticed / reported by Alan.
2024-10-14 14:38:23 +02:00
Jan Beulich
b03815327a gas: drop SKIP_WHITESPACE_AFTER_NAME()
Exclusively all users should use restore_line_pointer() instead, at
which point SKIP_WHITESPACE() suffices as a check afterwards.
2024-10-14 14:37:29 +02:00
Lulu Cai
22c6209285 LoongArch: Fixed R_LARCH_[32/64]_PCREL generation bug
The enum BFD_RELOC_[32/64] was mistakenly used in the macro instead
of the relocation in fixp. This can cause the second relocation
of a pair to be deleted when -mthin-add-sub is enabled. Apply the
correct macro to fix this.

Also sets the initial value of -mthin-add-sub.
2024-10-14 09:15:16 +08:00
Jan Beulich
d55d7b35c4 x86: bring 64-bit-only cmdline option handling in sync
--64 and --x32 are already suppressed in --help output when BFD64 is not
defined. Also avoid recognizing these options in such configurations.
2024-10-11 08:20:33 +02:00
Jan Beulich
1f1b5e506b bfd/ELF: restrict file alignment for object files
While for executables properly aligning sections within the file can be
quite relevant, the same is of pretty little importance for relocatable
object files. Avoid passing "true" into
_bfd_elf_assign_file_position_for_section() when dealing with object
files, but compensate minimally by applying log_file_align in such
cases as a cap to the alignment put in place.
2024-10-11 08:19:34 +02:00
Haochen Jiang
873e7b6cf6 Support Intel AVX10.2 media instructions
In disassembler part, for vnni instructions, we extended previous
VEX part using %XE in disassembler to promote them to EVEX by reusing
the original VEX table. For vmpsadbw, we will also use %XE. However,
it is hard to reuse the VEX table, so we are using new ones.

In assmbler part, we put the vnni table entries with previous vnni
instructions since they are just promotion from AVX-VNNI-INT{8,16}.
Since we will prefer VEX encoding, we need to use the different table
order in template <vnni>, which prefers EVEX due to earlier introduction
for AVX512_VNNI than AVX_VNNI. This means a new <vnni>. For vdpphps
and vmpsadbw, we put them at the end of the table, with future AVX10.2
instructions.

Nit: I will remove the arch requirement for avx_vnni_int{8,16} in
evex-promote testcases after AVX10.2 implies AVX-VNNI-INT{8,16}.

gas/Changelog:

	* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
	* testsuite/gas/i386/x86-64.exp: Ditto.
	* testsuite/gas/i386/avx10_2-256-1-intel.d: New.
	* testsuite/gas/i386/avx10_2-256-1.d: Ditto.
	* testsuite/gas/i386/avx10_2-256-1.s: Ditto.
	* testsuite/gas/i386/avx10_2-512-1-intel.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-1.d: Ditto.
	* testsuite/gas/i386/avx10_2-512-1.s: Ditto.
	* testsuite/gas/i386/avx10_2-promote.d: Ditto.
	* testsuite/gas/i386/avx10_2-promote.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-promote.d: Ditto.
	* testsuite/gas/i386/x86-64-avx10_2-promote.s: Ditto.

opcodes/Changelog:

	* i386-dis-evex-prefix.h: Adjust PREFIX_EVEX_0F3852.
	Add PREFIX_EVEX_0F3A42_W_0.
	* i386-dis-evex-w.h: Adjust EVEX_W_0F3A42.
	* i386-dis-evex.h: Add table pass for AVX10.2
	instructions.
	* i386-dis.c: Adjust PREFIX_VEX_0F3850_W_0, PREFIX_VEX_0F3851_W_0,
	PREFIX_VEX_0F38D2_W_0 and PREFIX_VEX_0F38D3_W_0.
	* i386-opc.tbl: Add AVX10.2 instructions.
	* i386-mnem.h: Regenerated.
	* i386-tbl.h: Ditto.

Co-authored-by: Lili Cui <lili.cui@intel.com>
2024-10-11 10:38:27 +08:00
Andreas Krebbel
a98a6fa2d8 s390: Add arch15 instructions
opcodes/
	* s390-mkopc.c (main) Accept arch15 as CPU string.
	* s390-opc.txt: Add arch15 instructions.

include/
	* opcode/s390.h (enum s390_opcode_cpu_val): Add
	S390_OPCODE_ARCH15.

gas/
	* config/tc-s390.c (s390_parse_cpu): New entry for arch15.
	* doc/c-s390.texi: Document arch15 march option.
	* doc/as.texi: Likewise.
	* testsuite/gas/s390/s390.exp: Run the arch15 related tests.
	* testsuite/gas/s390/zarch-arch15.d: Tests for arch15
	instructions.
	* testsuite/gas/s390/zarch-arch15.s: Likewise.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
2024-10-10 12:09:40 +02:00
Xiao Zeng
542d8137f9 RISC-V: Fix implicit dependency of Zabha and Zacas
1 Zabha depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc>

2 Zacas depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc>

bfd/ChangeLog:

	* elfxx-riscv.c: Zabha and Zacas implicitly depend on Zaamo.

gas/ChangeLog:

	* testsuite/gas/riscv/imply.d: Updated.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2024-10-08 11:45:28 +08:00
Jan Beulich
85ef4a5ed8 gas: hide emulation struct format_ops instances when not needed
Most targets don't even support emulations, so this data (and certain
functions) are entirely dead code for them.
2024-10-04 09:42:45 +02:00
Jan Beulich
e9285aa046 x86: prune OBJ_MAYBE_... uses
With the removal of emulations, OBJ_MAYBE_... can no longer be defined.
Tidy code wherever they're used, which also includes the dropping of
most IS_ELF and uses and checks of OUTPUT_FLAVOR.

Where touching such constructs anyway, also drop TE_PEP checks when used
together with TE_PE ones (the former implies the latter).
2024-10-04 09:42:13 +02:00
Jan Beulich
46f44aa700 x86: drop largely defunct gas emulations
Both ELF and COFF have various sub-flavors, each of which would then
require its own emulation: Right now when configuring a COFF/PE
secondary target (with perhaps an ELF primary one), one gets plain COFF
emulation rather than COFF/PE one.

As such a multitude of emulations would be unwieldy (and likely fragile)
drop gas emulations altogether instead.
2024-10-04 09:41:38 +02:00
Jan Beulich
87d2a20152 include: de-duplicate i386.h and x86_64.h
Move common definitions to a new x86.h, thus allowing gas'es obj-coff.h
to include just that, getting rid of a TE_PEP compile-time dependency.
2024-10-04 09:39:36 +02:00
Jan Beulich
d6b42c3035 gas: drop generate_asm_lineno emulation hook
It's not wired up, so can't be used.
2024-10-04 09:38:05 +02:00
Jan Beulich
ccaa95c887 gas: don't use COFF-specific SF_SET_LOCAL() directly from read.c
Make this a proper obj-format hook instead.
2024-10-04 09:37:37 +02:00
Jan Beulich
833c28eefb gas/dw2gencfi: correct .sframe section conditional
While originally this was in preparation of a subsequent change making
SUPPORT_FRAME_LINKONCE potentially dependent on a global variable, the
construct appears unlikely to have been correct in the first place: The
variable would have been passed reliably uninitialized when
SUPPORT_FRAME_LINKONCE is build-time true.

While there correct indentation of the parameters passed to
get_cfi_seg().
2024-10-04 09:36:56 +02:00
Jan Beulich
c41215350b gas: put emul decls in emul.h
The individual struct emulation instances shouldn't be declared in a .c
file; it and the producers of the symbols want to both see the
declarations, so declarations and definitions don't go out of sync. Move
these declarations to emul.h.

While there also adjust the conditional around this_format: That symbol
is never #define-d anywhere, and it's needed only when USE_EMULATIONS is
defined. (Really, when obj-multi isn't in use, it also is effectively
only ever written to.)
2024-10-04 09:36:24 +02:00
Jan Beulich
2ced0b79da gas: drop unused fields from struct emulation
Neither .match not .bfd_name appear to ever have been used in the last
about 25 years. Purge them.
2024-10-04 09:35:56 +02:00
Alan Modra
444ae19249 segv in read_a_source_file
On some paths through read_a_source file, "s" may not be set.

	* read.c (read_a_source_file): Correct code ignoring comment.
2024-10-01 08:35:00 +09:30
Alan Modra
eb5903a8e2 gas buffer overflow with --listing-rhs-width
With listings enabled, gas keeps a small cache of source lines.  They
are stored in buffers of size LISTING_RHS_WIDTH, ie. 100.  Given
listing-rhs-width larger than 100 it is of course possible to overflow
the buffer.  Fix that by allocating as needed.  We could allocate all
buffers on the first call to print_source using listing_rhs_width, but
I chose not to do that in case some future assembly directive allows
changes to listing_rhs_width similarly to the way paper_width can
change during assembly.
2024-09-28 15:47:47 +09:30
Jan Beulich
dfa9ee01a4 x86: fix Solaris gas testsuite run
Commits 8015b1b0c1 ("x86-64: Never make R_X86_64_GOT64 section
relative"), d774bf9b36 ("x86: Add tls check in gas"), and
1b714c14e4 ("x86: Turn PLT32 to PC32 only for PC-relative
relocations") all should have adjusted the Solaris counterpart of the
reloc64 test as well.
2024-09-27 11:41:27 +02:00
Jan Beulich
9a788db16a RISC-V: odd data padding vs mapping symbols
Odd data padding has a $d label inserted at its beginning. When a $x...
label is removed instead, a replacement is inserted after the padding.
The same, however, needs to also happen when there's no $x to replace.
2024-09-27 11:41:00 +02:00
Jan Beulich
784e2ef54b RISC-V: correct alignment directive handling for text sections
.insn or data emitted inside text sections can lead to positions not
being at insn granularity. In such situations using alignment
directives should reliably enforce the requested alignment.
Specifically requests to align back to insn granularity may not be
ignored (where, as a subcase thereof, the ordering of ".option norvc"
and e.g. ".p2align 2" should not matter; so far the alignment directive
needs to come first to have any effect). Similarly ahead of emitting
NOPs alignment first needs to be forced back to insn granularity.

The new testcases actually point out a corner case issue in the
disassembler as well, which is being corrected at the same time: We
don't want to print "0x" without any subsequent digits.
2024-09-27 11:40:22 +02:00
Jan Beulich
ca6b6f9d6e x86: optimize {,V}INSERTPS with certain immediates
They are equivalent to simple moves or xors, which are up to 3 bytes
shorter to encode (and maybe/likely also cheaper to execute).
2024-09-27 11:23:12 +02:00
Jan Beulich
f079b0c4b2 x86: optimize {,V}EXTRACT{F,I}{128,32x{4,8},64x{2,4}} with immediate 0
They, too, are equivalent to simple moves, which are up to 3 bytes
shorter to encode (and maybe also cheaper to execute).
2024-09-27 11:22:34 +02:00
Jan Beulich
afd5b33bc7 x86: optimize {,V}EXTRACTPS with immediate 0
They are equivalent to simple moves, which are up to 2 bytes shorter to
encode (and maybe also cheaper to execute).
2024-09-27 11:21:51 +02:00
Jan Beulich
0fcb4bfcd4 x86: correct {,V}PEXTR{D,Q} optimization
A possible relocation associated with a memory operand also needs
moving.
2024-09-27 11:20:37 +02:00
Haochen Jiang
24979a6d5a x86/testsuite: Refine AVX10.2 rounding testcases
Using hard byte code is not a good idea in dump file. Add a label
for intel syntax test check to avoid that.

gas/ChangeLog:

	* testsuite/gas/i386/avx10_2-rounding-intel.d: Use label for
	test split.
	* testsuite/gas/i386/avx10_2-rounding.s: Add label to avoid
	hard coding in dump file.
2024-09-26 11:03:44 +08:00
Alan Modra
437a3b0fa2 x86 TLS relocation checks
Some configurations (eg. i386-bsd, i386-msdos) broke with the addition
of the TLS relocation checking.  The "x86_elf_abi undeclared" error
has been fixed, but "gotrel defined but not used" remains.  Fix that.
Also invert the preprocessor test around lex_got to make it positive
logic and remove the LEX_AT condition which is no longer necessary.
(The only x86 config files defining LEX_AT also define TE_PE.)
2024-09-26 08:08:52 +09:30
Jiawei
f0bdf8c169 RISC-V: Add Smrnmi extension csrs.
This patch support Smrnmi extension[1],
The csrs address can be find in[2].

[1] 35eb3948bf
[2] https://github.com/riscv/riscv-isa-manual/blob/smrnmi-1.0/src/priv-csrs.adoc

bfd/ChangeLog:

	* elfxx-riscv.c: New extension.

gas/ChangeLog:

	* NEWS: Add Smrnmi extension support.
	* config/tc-riscv.c (enum riscv_csr_class): New extension class.
	(riscv_csr_address): Ditto.
	* testsuite/gas/riscv/csr-version-1p10.d: New csrs.
	* testsuite/gas/riscv/csr-version-1p10.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.l: Ditto.
	* testsuite/gas/riscv/csr.s:  Ditto.
	* testsuite/gas/riscv/march-help.l: New extension.

include/ChangeLog:

	* opcode/riscv-opc.h (CSR_MNSCRATCH): New csr.
	(CSR_MNEPC): Ditto.
	(CSR_MNCAUSE): Ditto.
	(CSR_MNSTATUS): Ditto.
	(DECLARE_CSR): New csr declarations.
2024-09-25 09:28:27 +08:00
H.J. Lu
9e0840deed x86: Enable TLS relocation check only for ELF
Since TLS relocation check is ELF specific, enable it only for ELF.

	PR gas/32022
	* config/tc-i386.c (x86_tls_error_type): Define only if
	OBJ_MAYBE_ELF or OBJ_ELF is defined.
	(x86_check_tls_relocation): Likewise.
	(x86_report_tls_error): Likewise.
	(i386_assemble): Check TLS relocations only if OBJ_MAYBE_ELF or
	OBJ_ELF is defined.
	(md_show_usage): Output -mtls-check= only if OBJ_MAYBE_ELF or
	OBJ_ELF is defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-24 05:52:43 +08:00
Nick Clifton
9923d66894
Fix compile time error introduced by d774bf9b36 for non-ELF x86 targets 2024-09-23 12:27:29 +01:00
H.J. Lu
1b714c14e4 x86: Turn PLT32 to PC32 only for PC-relative relocations
commit 292676c15a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 13 13:44:17 2020 -0800

    x86: Resolve PLT32 reloc aganst local symbol to section

resolved PLT32 relocation against local symbol to section and

commit 2585b7a5ce
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Jul 19 06:51:19 2020 -0700

    x86: Change PLT32 reloc against section to PC32

turned PLT32 relocation against section into PC32 relocation.  But these
transformations are valid only for PC-relative relocations.  Add fx_pcrel
check for PC-relative relocations when performing these transformations
to keep PLT32 relocation in `movq $foo@PLT, %rax`.

gas/

	PR gas/32196
	* config/tc-i386.c (tc_i386_fix_adjustable): Return fixP->fx_pcrel
	for PLT32 relocations.
	(i386_validate_fix): Turn PLT32 relocation into PC32 relocation
	only if fixp->fx_pcrel is set.
	* testsuite/gas/i386/reloc32.d: Updated.
	* testsuite/gas/i386/reloc64.d: Likewise.
	* testsuite/gas/i386/reloc32.s: Add PR gas/32196 test.
	* testsuite/gas/i386/reloc64.s: Likewise.

ld/

	PR gas/32196
	* testsuite/ld-x86-64/plt3.s: New file.
	* testsuite/ld-x86-64/x86-64.exp: Run plt3.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-23 03:45:19 +08:00
Cui, Lili
d774bf9b36 x86: Add tls check in gas
Assembler shouldn't accept invalid TLS instructions, TLS relocations
can only be used with specific instructions as specified in TLS psABI
and linker issues an error when TLS relocations are used with wrong
instructions or format. Since it is inconvenient for gcc to rely on
linker to report errors, adding TLS check in the assembler stage so
that gcc can know TLS errors earlier.

gas/ChangeLog:

        PR gas/32022
        * config.in: Regenerate.
        * config/tc-i386.c
        *(enum x86_tls_error_type): New.
        *(struct _i386_insn): Added has_gotrel to indicate whether TLS
	relocations need to be checked.
        (x86_check_tls_relocation): Added a new function to check TLS
	relocation.
        (x86_report_tls_error): Created a new function to report TLS error.
        (i386_assemble): Handle x86_check_tls_relocation.
        (lex_got): Set i.has_gotrel.
        (OPTION_MTLS_CHECK): Added a new option to contrl TLS check.
        (struct option): Ditto.
        (md_parse_option): Ditto.
        (md_show_usage): Ditto.
        * configure.ac: Added a new option to check TLS relocation by
	default.
        * configure: Regenerated.
        * doc/c-i386.texi: Document -mtls-check=.
        * testsuite/gas/i386/i386.exp: Added new tests.
        * testsuite/gas/i386/ilp32/ilp32.exp: Ditto.
        * testsuite/gas/i386/ilp32/reloc64.d: Disable TLS check for it.
        * testsuite/gas/i386/ilp32/x32-tls.d: Ditto.
        * testsuite/gas/i386/inval-tls.l: Added more test cases.
        * testsuite/gas/i386/inval-tls.s: Ditto.
        * testsuite/gas/i386/reloc32.d: Disable TLS check for it.
        * testsuite/gas/i386/reloc64.d: Ditto.
        * testsuite/gas/i386/x86-64-inval-tls.l: Added more test cases.
        * testsuite/gas/i386/x86-64-inval-tls.s: Ditto.
        * testsuite/gas/i386/x86-64.exp: Added new tests.
        * testsuite/gas/i386/ilp32/x32-inval-tls.l: New test.
        * testsuite/gas/i386/ilp32/x32-inval-tls.s: Ditto.
        * testsuite/gas/i386/ilp32/x86-64-tls.d: Ditto.
        * testsuite/gas/i386/tls.d: Ditto.
        * testsuite/gas/i386/tls.s: Ditto.
        * testsuite/gas/i386/x86-64-tls.d: Ditto.
        * testsuite/gas/i386/x86-64-tls.s: Ditto.

ld/ChangeLog:

        PR gas/32022
        * testsuite/ld-i386/tlsgdesc1.d: Disable TLS check for it.
        * testsuite/ld-i386/tlsgdesc2.d: Ditto.
        * testsuite/ld-i386/tlsie2.d: Ditto.
        * testsuite/ld-i386/tlsie3.d: Ditto.
        * testsuite/ld-i386/tlsie4.d: Ditto.
        * testsuite/ld-i386/tlsie5.d: Ditto.
        * testsuite/ld-i386/tlsgdesc3.d: Ditto.
        * testsuite/ld-x86-64/tlsdesc3.d: Ditto.
        * testsuite/ld-x86-64/tlsdesc4.d: Ditto.
        * testsuite/ld-x86-64/tlsie2.d: Ditto.
        * testsuite/ld-x86-64/tlsie3.d: Ditto.
        * testsuite/ld-x86-64/tlsie5.d: Ditto.
        * testsuite/ld-x86-64/tlsdesc5.d: Ditto.
2024-09-21 05:19:16 +08:00
H.J. Lu
8015b1b0c1 x86-64: Never make R_X86_64_GOT64 section relative
R_X86_64_GOT64 relocation should never be made section relative.  Change
tc_i386_fix_adjustable to return 0 for BFD_RELOC_X86_64_GOT64.

gas/

	PR gas/32189
	* config/tc-i386.c (tc_i386_fix_adjustable): Return 0 for
	BFD_RELOC_X86_64_GOT64.
	* testsuite/gas/i386/reloc64.d: Updated.
	* testsuite/gas/i386/reloc64.s: Add more tests for R_X86_64_GOT64
	and R_X86_64_GOTOFF64.

ld/

	PR gas/32189
	* testsuite/ld-x86-64/x86-64.exp: Run PR gas/32189 test.
	* testsuite/ld-x86-64/pr32189.s: New file.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-20 05:44:35 +08:00
H.J. Lu
2963d7d80d x86/APX: Don't promote AVX/AVX2 instructions out of APX spec
V{BROADCAST,EXTRACT,INSERT}{F,I}128 and VROUND{P,S}{S,D} aren't promoted
to support EGPR in APX spec.  Don't promote them out of APX spec.  This
commit effectively reverted:

ec3babb8c1 x86/APX: V{BROADCAST,EXTRACT,INSERT}{F,I}128 can also be expressed
5a635f1f59 x86/APX: VROUND{P,S}{S,D} encodings require AVX512{F,VL}
eea4357967 x86/APX: VROUND{P,S}{S,D} can generally be encoded

gas/

	PR gas/32171
	* testsuite/gas/i386/x86-64-apx-egpr-promote-inval.s: Add
	V{BROADCAST,EXTRACT,INSERT}{F,I}128 tests with EGPR.
	* testsuite/gas/i386/x86-64-apx-evex-promoted.s: Remove
	V{BROADCAST,EXTRACT,INSERT}{F,I}128 and VROUND{P,S}{S,D} tests
	with EGPR.
	* testsuite/gas/i386/x86-64-apx-egpr-inval.l: Updated.
	* testsuite/gas/i386/x86-64-apx-egpr-promote-inval.l: Likewise.
	* testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-evex-promoted-wig.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-evex-promoted.d: Likewise.

opcodes/

	PR gas/32171
	* i386-opc.tbl: Remove V{BROADCAST,EXTRACT,INSERT}{F,I}128 and
	VROUND{P,S}{S,D} entries with EGPR.
	* i386-tbl.h: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-18 10:11:02 +08:00
Maciej W. Rozycki
c26846ab06 MIPS/GAS: Discard redundant instruction from DDIV/DREM macros
A sequence such as:

	li	at,-1
	bne	xx,at,0f
	 li	at,1
	dsll32	at,at,0x1f

is produced in the expansion of the DDIV and DREM assembly macros, where
a redundant `li at,1' instruction is used to load an intermediate value
of 1 into $at, which is then left-shifted by 63 with `dsll32 at,at,0x1f'
yielding 0x8000000000000000.  However this value likewise results from
left-shifting the value of -1, already present in $at at this point.

Remove the extraneous instruction then, shortening the sequence emitted.
Adjust dumps in the testsuite accordingly.
2024-09-15 15:28:18 +01:00
Maciej W. Rozycki
248f96fba6 MIPS/GAS/testsuite: Print instructions in hex in division tests
Add `--show-raw-insn' to division tests so as to verify branch offsets
without the need to know actual offsets into the text section individual
instructions have been assembled at.  Add `-z' where applicable to make
interlock NOP instructions appear in output so as to verify them without
the need to know the offsets too.  Replace individual offsets to match
against with generic patterns so that a change in the expansion of an
assembly macro does not affect code that follows.
2024-09-15 15:28:18 +01:00
Jens Remus
b8b60e2d0c s390: Relax risbg[n]z, risb{h|l}gz, {rns|ros|rxs}bgt operand constraints
This leverages commit ("s390: Simplify (dis)assembly of insn operands
with const bits") to relax the operand constraints of the immediate
operand that contains the constant Z- or T-bit of the following extended
mnemonics:
risbgz, risbgnz, risbhgz, risblgz, rnsbgt, rosbgt, rxsbgt

Previously those instructions were the only ones where the assembler
on s390 restricted the specification of the subject I3/I4 operand values
exactly according to their specification to an unsigned 6- or 5-bit
unsigned integer. For any other instructions the assembler allows to
specify any operand value allowed by the instruction format, regardless
of whether the instruction specification is more restrictive.

Allow to specify the subject I3/I4 operand as unsigned 8-bit integer
with the constant operand bits being ORed during assembly.
Relax the instructions subject significant operand bit masks to only
consider the Z/T-bit as significant, so that the instructions get
disassembled as their *z or *t flavor regardless of whether any reserved
bits are set in addition to the Z/T-bit.
Adapt the rnsbg, rosbg, and rxsbg test cases not to inadvertently set
the T-bit in operand I3, as they otherwise get disassembled as their
rnsbgt, rosbgt, and rxsbgt counterpart.

This aligns GNU Assembler to LLVM Assembler.

opcodes/
	* s390-opc.c (U6_18, U5_27, U6_26): Remove.
	(INSTR_RIE_RRUUU2, INSTR_RIE_RRUUU3, INSTR_RIE_RRUUU4): Define
	as INSTR_RIE_RRUUU while retaining insn fmt mask.
	(MASK_RIE_RRUUU2, MASK_RIE_RRUUU3, MASK_RIE_RRUUU4): Treat only
	Z/T-bit of I3/I4 operand as significant.

gas/testsuite/
	* gas/s390/zarch-z10.s (rnsbg, rosbg, rxsbg): Do not set T-bit.

Reported-by: Dominik Steenken <dost@de.ibm.com>
Suggested-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-09-12 15:06:06 +02:00
Jens Remus
a3f1e7c56a s390: Simplify (dis)assembly of insn operands with const bits
Simplify assembly and disassembly of extended mnemonics with operands
with constant ORed bits:
Their instruction template already contains the respective constant
operand bits, as they are significant to distinguish the extended from
their base mnemonic. Operands are ORed into the instruction template.
Therefore it is not necessary to OR the constant bits into the operand
value during assembly in s390_insert_operand.
Additionally the constant operand bits from the instruction template
can be used to mask them from the operand value during disassembly in
s390_print_insn_with_opcode. For now do so for non-length unsigned
integer operands only.

The separate instruction formats need to be retained, as their masks
differ, which is relevant during disassembly to distinguish the base
and extended mnemonics from each other.

This affects the following extended mnemonics:
- vfaebs, vfaehs, vfaefs
- vfaezb, vfaezh, vfaezf
- vfaezbs, vfaezhs, vfaezfs
- vstrcbs, vstrchs, vstrcfs
- vstrczb, vstrczh, vstrczf
- vstrczbs, vstrczhs, vstrczfs
- wcefb, wcdgb
- wcelfb, wcdlgb
- wcfeb, wcgdb
- wclfeb, wclgdb
- wfisb, wfidb, wfixb
- wledb, wflrd, wflrx

include/
	* opcode/s390.h (S390_OPERAND_OR1, S390_OPERAND_OR2,
	S390_OPERAND_OR8): Remove.

opcodes/
	* s390-opc.c (U4_OR1_24, U4_OR2_24, U4_OR8_28): Remove.
	(INSTR_VRR_VVV0U1, INSTR_VRR_VVV0U2, INSTR_VRR_VVV0U3): Define
	as INSTR_VRR_VVV0U0 while retaining respective insn fmt mask.
	(INSTR_VRR_VV0UU8): Define as INSTR_VRR_VV0UU while retaining
	respective insn fmt mask.
	(INSTR_VRR_VVVU0VB1, INSTR_VRR_VVVU0VB2, INSTR_VRR_VVVU0VB3):
	Define as INSTR_VRR_VVVU0VB while retaining respective insn fmt
	mask.
	* s390-dis.c (s390_print_insn_with_opcode): Mask constant
	operand bits set in insn template of non-length unsigned
	integer operands.

gas/
	* config/tc-s390.c (s390_insert_operand): Do not OR constant
	operand value bits.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-09-12 15:06:06 +02:00
Jan Beulich
6fc346a4b3 gas: avoid (scrubber) diagnostics for stuff past .end
What's past an active .end directive (when that has its default purpose)
is supposed to be entirely ignored. That should be true not just for
regular processing, but also for "pre-processing" (aka scrubbing). A
complication is that such a directive may of course occur inside a
(false) conditional or a macro definition. To deal with that make sure
we can continue as usual if called another time.

Note however that .end inside a macro will still have the full macro
body expanded; dealing with that would require further (perhaps
intrusive) adjustments in sb_scrub_and_add_sb() and/or callers thereof.
However, at least some of the warnings issued by do_scrub_chars() are
unlikely to occur when expanding a macro. (If we needed to go that far,
presumably .exitm would also want recognizing.)
2024-09-11 13:56:36 +02:00
Jan Beulich
5d2142f10e gas: restrict scrubber mri_{state,last_ch} vars
They're needed with TC_M68K only. Group them accordingly, just like is
the case for Arm's symver vars.
2024-09-11 13:55:49 +02:00
Jan Beulich
9135fac423 arm: don't engage symver scrubber hack in CCS mode
In that mode the comment char is ; while @ has no special meaning.
Engaging the special logic in that case results in comments not being
respected on .symver lines.
2024-09-11 13:55:01 +02:00
Jan Beulich
b7ee8ec914 x86: error handling in set_cpu_arch()
Error messages there would better not be followed by further "junk at
end of line" diagnostics. Arrange for this to be the case uniformly.

While there also replace a somewhat unhelpful open-coding of
restore_line_pointer().
2024-09-11 13:52:18 +02:00
Jens Remus
e75cfa9f0f s390: Document syntax to omit base register operand
Document the s390-specific assembler syntax introduced by commit
aacf780bca ("s390: Allow to explicitly omit base register operand in
assembly") to omit the base register operand B in D(X,B) and D(L,B) by
coding D(X,) and D(L,).

While at it document the alternative syntax to omit the index register
operand X in D(X,B) by coding D(,B) instead of D(B).

gas/
	* doc/c-s390.texi (s390 Operands): Document syntax to omit base
	register operand.

Fixes: aacf780bca ("s390: Allow to explicitly omit base register operand in assembly")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-09-09 17:05:27 +02:00
Lulu Cai
6c2358b90a LoongArch: Fixed precedence of expression operators in instructions
The precedence of the operators "+" and "-" in the current loongarch
instruction expression is higher than "<<" and ">>", which is different
from the explanation in the user guide.

We modified the precedence of "<<" and ">>" to be higher than "+" and "-".
2024-09-09 15:11:53 +08:00
Xin Wang
2bbe107902 Add macros to get opcode of instructions approriately
LoongArch: Add macros to get opcode and register of instructions appropriately

Currently, we get opcode of an instruction by manipulate the binary with
it's mask, it's a bit of a pain. Now a macro is defined to do this and a
macro to get the RD and RJ registers which is applicable to most instructions
of LoongArch are added.
2024-09-07 10:06:03 +08:00
Jan Beulich
4eb59a5243 x86/APX: use D for 2-operand CFCMOVcc
There's no need to have 30 redundant templates when we can easily take
care of the operand swapping like we do for various other insns.
2024-09-06 08:35:42 +02:00