Commit Graph

4310 Commits

Author SHA1 Message Date
Jan Beulich
676dcbb0a0 x86: {LD,ST}TILECFG use an extension opcode
It being zero and happening to work right now doesn't mean the insns
shouldn't be spelled out properly.
2023-02-14 08:34:42 +01:00
Michael Matz
25a0d393c7 PR30120: fix x87 fucomp misassembled
this fixes the entry for 'fucomp' to use the correct Reg value
(otherwise it's assembled as 'fucom').
2023-02-13 18:41:05 +01:00
Andrew Burgess
77be725744 opcodes/mips: disassemble unknown micromips instructions as two shorts
Before commit:

  commit 2438b771ee
  Date:   Wed Nov 2 15:53:43 2022 +0000

      opcodes/mips: use .word/.short for undefined instructions

unknown 32-bit microMIPS instructions were disassembled as a raw
32-bit number with no '.word' directive.  The above commit changed
this and added a '.word' directive before the 32-bit number.

It was pointed out on the mailing list, that for microMIPS it would be
better to display such 32-bit instructions using a '.short' directive
followed by two 16-bit values.

This commit updates the mips disassembler to do this, and adds a new
test that validates this output.
2023-02-13 12:05:32 +00:00
Jan Beulich
aa1807419b x86: drop use of VEX3SOURCES
The attribute really specifies that the sum of register and memory
operands is 4. Express it like that in most places, while using the 2nd
(apart from XOP) CPU feature flags (FMA4) in reversed operand matching
logic.

With the use in build_modrm_byte() gone, part of an assertion there
also becomes meaningless - simplify that at the same time.

With all uses of the opcode modifier field gone, also drop that.
2023-02-10 08:15:11 +01:00
Jan Beulich
5dab1799d7 x86: drop use of XOP2SOURCES
The few XOP insns which used it wrongly didn't have VexVVVV specified.
With that added, the only further missing piece to use more generic code
elsewhere is SwapSources - see e.g. the BMI2 insns for similar operand
patterns.

With the only users gone, drop the #define as well as the special case
code.
2023-02-10 08:14:46 +01:00
Jan Beulich
ba3ffa6de0 x86: limit use of XOP2SOURCES
The VPROT* forms with an immediate operand are entirely standard in the
way their ModR/M bytes are built. There's no reason to invoke special
case code. With that the handling of an immediate there can also be
dropped; it was partially bogus anyway, as in its "no memory operands"
portion it ignores the possibility of an immediate operand (which was
okay only because that case was already handled by more generic code).
2023-02-10 08:14:27 +01:00
Jan Beulich
ddb6249593 x86: move (and rename) opcodespace attribute
This really isn't a "modifier" and rather ought to live next to the base
opcode anyway. Use the bits we presently have available to fit in the
field, renaming it to opcode_space. As an intended side effect this
helps readability at the use sites, by shortening the references quite a
bit.

In generated code arrange for human readable output, by using the
SPACE_* constants there rather than raw numbers. This may aid debugging
down the road.
2023-02-10 08:10:38 +01:00
Guillermo E. Martinez
7f6ebecd56 bpf: fix error conversion from long unsigned int to unsigned int [-Werror=overflow]
Regenerating BPF target using the maintainer mode emits:
.../opcodes/bpf-opc.c:57:11: error: conversion from ‘long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709486335’ to ‘4294902015’ [-Werror=overflow]
  57 |   64, 64, 0xffffffffffff00ff, { { F (F_IMM32) }, { F (F_OFFSET16) }, { F (F_SRCLE) }, { F (F_OP_CODE) }, { F (F_DSTLE) }, { F (F_OP_SRC) }, { F (F_OP_CLASS) }, { 0 } }

The use of a narrow size to handle the mask CGEN in instruction format
is causing this error.  Additionally eBPF `call' instructions
constructed by expressions using symbols (BPF_PSEUDO_CALL) emits
annotations in `src' field of the instruction, used to identify BPF
target endianness.

cpu/
	* bpf.cpu (define-call-insn): Remove `src' field from
	instruction mask.

include/
	*opcode/cge.h (CGEN_IFMT): Adjust mask bit width.

opcodes/
	* bpf-opc.c: Regenerate.
2023-02-03 11:18:50 -06:00
Jan Beulich
0655669b86 RISC-V: don't disassemble unrecognized insns as .byte
Insn width granularity being 16 bits, producing byte granular output
isn't very useful. With there being a way to specific otherwise
unknown insns to the assembler, use that same representation (to be
precise: its <length>,<encoding> flavor) for disassembly.
2023-02-03 08:20:32 +01:00
Jan Beulich
a3c2d24868 RISC-V: make C-extension JAL available again for (32-bit) assembly
Along with the normal JAL alias, the C-extension one should have been
moved as well by 839189bc93 ("RISC-V: re-arrange opcode table for
consistent alias handling"), for the assembler to actually be able to
use it where/when possible.

Since neither this nor any other compressed branch insn was being tested
so far, take the opportunity and introduce a new testcase covering those.
2023-01-31 09:47:22 +01:00
Jan Beulich
bd78280846 x86: use ModR/M for FPU insns with operands
This is the correct way of expressing things; encoding the ModR/M byte
directly in base_opcode has always been bogus.
2023-01-27 09:22:49 +01:00
Jan Beulich
800c5dd7b3 opcodes: suppress internationalization on build helper tools
While one of the two actually having been instrumented (i386-gen.c) now
has that instrumentation dropped, there's still no point in honoring
such instrumentation in general (i.e. now for ia64-gen.c only), as that
only leads to a waste of resources.

With CFILES then being merely an alias of LIBOPCODES_CFILES, drop the
former variable altogether.
2023-01-27 09:20:58 +01:00
Jan Beulich
06ceca3a90 x86: remove internationalization from i386-gen.c
This is a build time helper utility, which doesn't require translation.
2023-01-27 09:20:26 +01:00
Jan Beulich
a2e2f5ad74 x86: split i386-gen's opcode hash entry struct
All glibc malloc() implementations I've checked have a smallest
allocation size worth of 3 pointers, with an increment worth of 2
pointers. Hence mnemonics with multiple templates can be stored more
efficiently when maintaining the shared "name" field only in the actual
hash entry. (To express the shared nature, also convert "name" to by
pointer-to-const.)

While doing the conversation also pull out common code from the involved
if/else construct in expand_templates().
2023-01-20 10:18:40 +01:00
Jan Beulich
2d9e089097 x86: embed register and alike names in disassembler
Register names are (including their nul terminators) on average almost 4
bytes long. Otoh no register name is longer than 8 bytes. Hence even for
32-bit builds using a pointer is only slightly more space efficient than
embedding the strings. A level of indirection can be also avoided by
embedding the names as an array of 8 characters directly in the arrays,
and the number of base relocations in libopcodes.so (or PIE builds of
statically linked executables) goes down as well.

To amortize for the otherwise reduced folding of string literals by the
linker, use att_names_seg[] in place of string literals in append_seg()
and OP_ESreg().
2023-01-20 10:18:17 +01:00
Jan Beulich
edf772580d x86: embed register names in reg_entry
Register names are (including their nul terminators) on average almost 4
bytes long. Otoh no register name is longer than 7 bytes. Hence even for
32-bit builds using a pointer is only slightly more space efficient than
embedding the strings. A level of indirection can be also avoided by
embedding the names as an array of 8 characters directly in the struct,
and the number of base relocations in PIE builds of gas goes down as
well.
2023-01-20 10:17:53 +01:00
Jan Beulich
992dd393c9 x86: absorb allocation in i386-gen
When generating the mnemonic string table we already set up an
identifier for the following entry in a number of cases. Re-use that on
the next loop iteration rather than re-doing allocation and conversion.
2023-01-20 10:16:56 +01:00
Jan Beulich
3e451ee4a6 x86: re-use insn mnemonic strings as much as possible
Compact the mnemonic string table such that the tails of longer
mnemonics are re-used for shorter ones, going beyond what compilers
would typically do, but matching what ELF linkers may do when processing
SHF_MERGE|SHF_STRINGS sections. This reduces table size by about 12.5%.
2023-01-20 10:16:17 +01:00
Jan Beulich
5c13920291 x86: move insn mnemonics to a separate table
Using full pointers to reference the insn mnemonic strings is not very
efficient. With overall string size presently just slightly over 20k,
even a 16-bit value would suffice. Use "unsigned int" for now, as
there's no good use we could presently make of the otherwise saved 16
bits.

For 64-bit builds this reduces table size by 6.25% (prior to the recent
ISA extension additions it would have been 12.5%), with a similar effect
on cache occupation of table entries accessed. For PIE builds of gas
this also reduces the number of base relocations quite a bit (obviously
independent of bitness).
2023-01-20 10:15:48 +01:00
Max Filippov
e80512c8d8 opcodes: xtensa: fix jump visualization for FLIX
opcodes/
	* xtensa-dis.c (print_insn_xtensa): Add local variables
	insn_type, target and imm_pcrel to track control flow across
	multiple slots.
2023-01-03 13:30:57 -08:00
Max Filippov
39086586b7 opcodes: xtensa: implement styled disassembly
opcodes/
	* xtensa-dis.c (print_xtensa_operand)
	(print_insn_xtensa): Replace fprintf_func with
	fprintf_styled_func.
2023-01-03 13:30:57 -08:00
Nick Clifton
11982f9f8b Updated translations for various languages and sub-directories 2023-01-03 11:32:42 +00:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Nick Clifton
96e786d198 Update version number and regenerate files 2022-12-31 12:23:00 +00:00
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Jan Beulich
760ab3d0db x86: correct/improve TSX controls
TSXLDTRK takes RTM as a prereq. Additionally introduce an umbrella "tsx"
extension option covering both RTM and HLE, paralleling the "abm" one we
already have.
2022-12-22 09:36:16 +01:00
Jan Beulich
0919e770af x86: add dependencies on SVME
SEV-ES is an extension to SVME. SNP in turn is an extension to SEV-ES,
and yet in turn RMPQUERY is a SNP extension.

Note that cpu_arch[] has no SNP entry, so CPU_ANY_SNP_FLAGS remains
unused (just like CPU_SNP_FLAGS already is).
2022-12-22 09:35:53 +01:00
Jan Beulich
25626f7939 x86: add dependencies on VMX
Both EPT and VMFUNC are extensions to VMX.
2022-12-22 09:35:32 +01:00
Jan Beulich
af1ad9aac5 x86: correct XSAVE* dependencies
Like various other features AMX-TILE takes XSAVE as a prereq.

XSAVES, unconditionally using compacted format, in turn effectively
takes XSAVEC as a prereq (an SDM clarification to this effect is in the
works).
2022-12-22 09:35:11 +01:00
Jan Beulich
9a019125a6 x86: correct dependencies of a few AVX512 sub-features
Like AVX512-FP16, several other extensions require wider than 16-bit
mask registers. As a result they take AVX512BW as a prereq, not (just)
AVX512F. Which in turn points out wrong expectations in the noavx512-1
testcase.
2022-12-22 09:34:50 +01:00
Jan Beulich
b20f426174 x86: add dependencies on AVX2
Like AVX-VNNI both VAES and VPCLMUL take AVX2 as a prereq, for operating
on up to 256-bit packed integer vectors.
2022-12-22 09:33:53 +01:00
Jan Beulich
88bd2203ef x86: correct SSE dependencies
SSE itself takes FXSR as a prereq. Like AES, PCLMUL, and SHA both GFNI
and KL take SSE2 as a prereq, for operating on packed integers. And
while correcting KL also record it as a prereq to WIDEKL.
2022-12-22 09:33:26 +01:00
Jan Beulich
4d97c5c833 x86: re-work ISA extension dependency handling
Getting both forward and reverse ISA dependencies right / consistent has
been a permanent source of mistakes. Reduce what needs specifying
manually to just the direct forward dependencies. Transitive forward
dependencies as well as reverse ones are now derived and hence cannot go
out of sync anymore (at least in the vast majority of cases; there are a
few special cases to still take care of manually). In the course of this
several CPU_ANY_*_FLAGS disappear, requiring adjustment to the
assembler's cpu_arch[].

Note that to retain the correct reverse dependency of AVX512F wrt
AVX512-VP2INTERSECT, the latter has the previously missing AVX512F
prereq added.

Note further that to avoid adding the following undue prereqs:
* ATHLON, K8, and AMDFAM10 gain CMOV and FXSR,
* IAMCU gains 387,
auxiliary table entries (including a colon-separated modifier) are
introduced in addition to the ones representing from converting the old
table.

To maintain forward-only dependencies between AVX (XOP) and SSE* (SSE4a)
(i.e. "nosse" not disabling AVX), reverse dependency tracking is
artifically suppressed.

As a side effect disabling of SSE or SSE2 will now also disable AES,
PCLMUL, and SHA (respective elements were missing from
CPU_ANY_SSE2_FLAGS).
2022-12-22 09:32:29 +01:00
Jan Beulich
9c19e9ec4d x86: rename CheckRegSize to CheckOperandSize
While originally indeed used for register size checking only, the
attribute has been used for memory operand size checking as well already
for quite a while, with more such uses recently having been added.
2022-12-21 09:07:03 +01:00
Alan Modra
b3737aadf1 Re: x86: remove i386-opc.c
Regen opcodes/po/POTFILES.in
2022-12-20 19:01:10 +10:30
Jan Beulich
4fdeb2a379 x86: omit Cpu prefixes from opcode table
These enumerators can be used in only one specific field, and hence the
Cpu prefix isn't needed ther for disambiguation / name space separation.
2022-12-19 09:22:33 +01:00
Jan Beulich
689933867a x86: change representation of extension opcode
Having a "None" field in the vast majority of entries is needlessly
cluttering the overall table. Instead of this being a separate field,
use a representation matching that of Intel SDM and AMD PM for the main
use of the field: Append the value after a / as the separator.
2022-12-16 09:00:23 +01:00
Jan Beulich
a28fedbc3f x86: further re-work insn/suffix recognition to also cover MOVSX
PR gas/29524

Having templates with a suffix explicitly present has always been
quirky. After prior adjustment all that's left to also eliminate the
anomaly from move-with-sign-extend is to consolidate the insn templates
and to make may_need_pass2() cope (plus extend testsuite coverage).
2022-12-12 14:01:02 +01:00
Jan Beulich
77a19f0e19 x86: drop (now) stray IsString
The need for them on the operand-less string insns has gone away with
the removal of maybe_adjust_templates() and associated logic. Since
i386_index_check() needs adjustment then anyway, take the opportunity
and also simplify it, possible again as a result of said removal (plus
the opcode template adjustments done here).
2022-12-12 13:53:40 +01:00
Jan Beulich
04784e33fa x86: re-work insn/suffix recognition
Having templates with a suffix explicitly present has always been
quirky. Introduce a 2nd matching pass in case the 1st one couldn't find
a suitable template _and_ didn't itself already need to trim off a
suffix to find a match at all. This requires error reporting adjustments
(albeit luckily fewer than I was afraid might be necessary), as errors
previously reported during matching now need deferring until after the
2nd pass (because, obviously, we must not emit any error if the 2nd pass
succeeds). While also related to PR gas/29524, it was requested that
move-with-sign-extend be left as broken as it always was.

PR gas/29525
Note that with the dropped CMPSD and MOVSD Intel Syntax string insn
templates taking operands, mixed IsString/non-IsString template groups
(with memory operands) cannot occur anymore. With that
maybe_adjust_templates() becomes unnecessary (and is hence being
removed).

PR gas/29526
Note further that while the additions to the intel16 testcase aren't
really proper Intel syntax, we've been permitting all of those except
for the MOVD variant. The test therefore is to avoid re-introducing such
an inconsistency.
2022-12-12 13:51:46 +01:00
Jan Beulich
6825a3bc86 x86: revert disassembler parts of "x86: Allow 16-bit register source for LAR and LSL"
This reverts the disassembler parts of 859aa2c86d ("x86: Allow 16-bit
register source for LAR and LSL"), adjusting testcases as necessary.
That change was itself a partial revert of c9f5b96bda ("x86: correct
handling of LAR and LSL"), without actually saying so. While the earlier
commit was properly agreed upon, the partial revert was not, and hence
should not have been committed. This is even more so that the revert
part of that change wasn't even necessary to address PR gas/29844.
2022-12-12 13:49:56 +01:00
Jan Beulich
65f440c8fb x86: generate template sets data at build time
Speed up gas startup by avoiding runtime allocation of the instances of
type "templates". At the same time cut the memory requirement to just
very little over half (not even accounting for any overhead
notes_alloc() may incur) by reusing the "end" slot of a preceding entry
for the "start" slot of the subsequent one.
2022-12-12 08:49:26 +01:00
Jan Beulich
daf15e3e96 x86: drop sentinel from i386_optab[]
Now that the table is local to gas, ARRAY_SIZE() can be used to
determine the end of the table. Re-arrange the processing loop in
md_begin() accordingly, at the same time folding the two calls to
notes_alloc() into just one.
2022-12-12 08:49:00 +01:00
Jan Beulich
bc30b54aef x86: remove i386-opc.c
Remove the now empty i386-opc.c. To compensate, tie table generation in
opcodes/ to the building of i386-dis.o, despite the file not really
depending on the generated data.
2022-12-12 08:47:26 +01:00
Jan Beulich
99f0fb12d5 x86: instantiate i386_{op,reg}tab[] in gas instead of in libopcodes
Unlike many other architectures, x86 does not share an opcode table
between assembly and disassembly. Any consumer of libopcodes would only
ever access one of the two. Since gas is the only consumer of the
assembly data, move it there. While doing so mark respective entities
"static" in i386-gen (we may want to do away with i386_regtab_size
altogether).

This also shrinks the number of relocations to be processed for
libopcodes.so by about 30%.
2022-12-12 08:46:47 +01:00
Peter Bergner
51b52f4ade PowerPC: Add support for RFC02655 - Saturating Subtract Instruction
opcodes/
	* ppc-opc.c (XOL): New define.
	(XOL_MASK): Likewise.
	(powerpc_opcodes): Add subfus, subfus., subwus, subwus., subdus, subdus.

gas/
	* testsuite/gas/ppc/rfc02655.s: New test.
	* testsuite/gas/ppc/rfc02655.d: Likewise
	* testsuite/gas/ppc/future-raw.s: Likewise.
	* testsuite/gas/ppc/future-raw.d: Likewise.
	* testsuite/gas/ppc/ppc.exp: Run them.
2022-12-07 11:47:16 -06:00
Peter Bergner
a60038c648 PowerPC: Add support for RFC02656 - Enhanced Load Store with Length Instructions
opcodes/
	* ppc-opc.c (PPCVSXF): New define.
	(powerpc_opcodes): Add lxvrl, lxvrll, lxvprl, lxvprll, stxvrl,
	stxvrll, stxvprl, stxvprl.

gas/
	* testsuite/gas/ppc/rfc02656.s: New test.
	* testsuite/gas/ppc/rfc02656.d: Likewise.
	* testsuite/gas/ppc/ppc.exp: Run it.
2022-12-07 11:47:16 -06:00
Haochen Jiang
40849d84cb x86: Remove unnecessary vex.w check for xh_mode in disassembler
For all the xh_mode usage in table, they are all using %XH, which will
print "{bad}" while EVEX.W=1. This makes this vex.w check unnecessary.

opcodes/ChangeLog:

	* i386-dis.c (OP_E_memory): Remove vex.w check for xh_mode.
2022-12-06 15:49:40 +08:00
Andrew Burgess
ecfbeec8d0 libopcodes/mips: add support for disassembler styling
This commit adds disassembler styling support for MIPS.  After this
commit objdump and GDB will style disassembler output.

This is a pretty straight forward change, we switch to use the
disassemble_info::fprintf_styled_func callback, and pass an
appropriate style through as needed.  No additional tricks were
needed (compared to say i386, or ARM).

Tested by running all of the objdump commands used by the gas
testsuite and manually inspecting the styled output, everything looks
reasonable, though I'm not a MIPS expert, so it is possible that I've
missed some corner cases.  Worst case though is that something will be
styled incorrectly, the actual content should be unchanged.

All the gas, ld, and binutils tests still pass for me.
2022-12-05 10:05:45 +00:00
Andrew Burgess
2438b771ee opcodes/mips: use .word/.short for undefined instructions
While working on disassembler styling for MIPS, I noticed that
undefined instructions are printed by the disassembler as raw number
with no assembler directive prefix (e.g. without .word or .short).

I think adding something like .word, or .short, helps to make it
clearer the size of the value that is being displayed, and is inline
with what many of the other libopcode disassemblers do.

In this commit I've added the .word and .short directives, and updated
all the tests that I spotted that failed as a result.
2022-12-05 10:05:45 +00:00