aboutsummaryrefslogtreecommitdiff
path: root/opcodes
AgeCommit message (Collapse)AuthorFilesLines
2023-03-30aarch64: Resync field namesRichard Sandiford1-7/+7
This patch just makes the comments in aarch64-opc.c:fields match the names of the associated FLD_* enum.
2023-03-30aarch64: Regularise FLD_* suffixesRichard Sandiford6-55/+55
Some FLD_imm* suffixes used a counting scheme such as FLD_immN, FLD_immN_2, FLD_immN_3, etc., while others used the lsb as the suffix. The latter seems more mnemonic, and was a big help in doing the SME2 work. Similarly, the _10 suffix on FLD_SME_size_10 was nonobvious. Presumably it indicated a 2-bit field, but it actually starts in bit 22.
2023-03-30aarch64: Add a aarch64_cpu_supports_inst_p helperRichard Sandiford1-0/+13
Quite a lot of SME2 instructions have an opcode bit that selects between 32-bit and 64-bit forms of an instruction, with the 32-bit forms being part of base SME2 and with the 64-bit forms being part of an optional extension. It's nevertheless useful to have a single opcode entry for both forms since (a) that matches the ISA definition and (b) it tends to improve error reporting. This patch therefore adds a libopcodes function called aarch64_cpu_supports_inst_p that tests whether the target supports a particular instruction. In future it will depend on internal libopcodes routines.
2023-03-30aarch64: Reorder some OP_SVE_* macrosRichard Sandiford1-16/+16
This patch just moves some out-of-order-looking OP_SVE_* macros.
2023-03-30aarch64: Rename aarch64-tbl.h OP_SME_* macrosRichard Sandiford1-81/+77
This patch renames the OP_SME_* macros in aarch64-tbl.h so that they follow the same scheme as the OP_SVE_* ones. It also uses OP_SVE_ as the prefix, since there is no real distinction between the SVE and SME uses of qualifiers: a macro defined for one can be useful for the other too.
2023-03-30aarch64: Try to report invalid variants against the closest matchRichard Sandiford3-19/+30
If an instruction has invalid qualifiers, GAS would report the error against the final opcode entry that got to the qualifier- checking stage. It seems better to report the error against the opcode entry that had the closest match, just like we pick the closest match within an opcode entry for the "did you mean this?" message. This patch adds the number of invalid operands as an argument to AARCH64_OPDE_INVALID_VARIANT and then picks the AARCH64_OPDE_INVALID_VARIANT with the lowest argument.
2023-03-30aarch64: Make AARCH64_OPDE_REG_LIST take a bitfieldRichard Sandiford1-1/+1
AARCH64_OPDE_REG_LIST took a single operand that specified the expected number of registers. However, there are quite a few SME2 instructions that have both 2-register forms and (separate) 4-register forms. If the user tries to use a 3-register list, it isn't obvious which opcode entry they meant. Saying that we expect 2 registers and saying that we expect 4 registers would both be wrong. This patch therefore switches the operand to a bitfield. If a AARCH64_OPDE_REG_LIST is reported against multiple opcode entries, the patch ORs up the expected lengths. This has no user-visible effect yet. A later patch adds more error strings, alongside tests that use them.
2023-03-30aarch64: Add an operand class for SVE register listsRichard Sandiford3-14/+13
SVE register lists were classified as SVE_REG, since there had been no particular reason to separate them out. However, some SME2 instructions have tied register list operands, and so we need to distinguish registers and register lists when checking whether two operands match. Also, the register list operands used a general error message, even though we already have a dedicated error code for register lists that are the wrong length.
2023-03-30aarch64: Commonise checks for index operandsRichard Sandiford1-18/+32
This patch splits out the constraint checking for index operands, so that it can be reused by new SME2 operands.
2023-03-30aarch64: Add an error code for out-of-range registersRichard Sandiford1-6/+14
libopcodes currently reports out-of-range registers as a general AARCH64_OPDE_OTHER_ERROR. However, this means that each register range needs its own hard-coded string, which is a bit cumbersome if the range is determined programmatically. This patch therefore adds a dedicated error type for out-of-range errors.
2023-03-30aarch64: Move w12-w15 range check to libopcodesRichard Sandiford1-6/+20
In SME, the vector select register had to be in the range w12-w15, so it made sense to enforce that during parsing. However, SME2 adds instructions for which the range is w8-w11 instead. This patch therefore moves the range check from the parsing stage to the constraint-checking stage. Also, the previous error used a capitalised range W12-W15, whereas other register range errors used lowercase ranges like p0-p7. A quick internal poll showed a preference for the lowercase form, so the patch uses that. The patch uses "selection register" rather than "vector select register" so that the terminology extends more naturally to PSEL.
2023-03-30aarch64: Move ZA range checks to aarch64-opc.cRichard Sandiford3-25/+67
This patch moves the range checks on ZA vector select offsets from gas to libopcodes. Doing the checks there means that the error messages contain the expected range. It also fits in better with the error severity scheme, which becomes important later. (This is because out-of-range indices are treated as more severe than syntax errors, on the basis that parsing must have succeeded if we get to the point of checking the completed opcode.) The patch also adds a new check_za_access function for checking ZA accesses. That's a bit over the top for one offset check, but the function becomes more complex with later patches. sme-9-illegal.s checked for an invalid .q suffix using: psel p1, p15, p3.q[w15] but this is doubly invalid because it misses the immediate part of the index. The patch keeps that test but adds another with a zero index, so that .q is the only thing wrong. The aarch64-tbl.h change includes neatening up the backslash positions.
2023-03-30aarch64: Make indexed_za use 64-bit immediatesRichard Sandiford1-3/+3
A later patch moves the range checking for ZA vector select offsets from gas to libopcodes. That in turn requires the immediate field to be big enough to support all parsed values. This shouldn't be a particularly size-sensitive structure, so there should be no memory problems with doing this.
2023-03-30aarch64: Rename za_tile_vector to za_indexRichard Sandiford3-36/+36
za_tile_vector is also used for indexing ZA as a whole, rather than just for indexing tiles. The former is more common than the latter in SME2, so this patch generalises the name to "indexed_za". The patch also names the associated structure, so that later patches can reuse it during parsing.
2023-03-30aarch64: Treat ZA as a registerRichard Sandiford2-2/+2
We already treat the ZA tiles ZA0-ZA15 as registers. This patch does the same for ZA itself. parse_sme_zero_mask can then parse ZA tiles and ZA in the same way, through parsed_type_reg. One important effect of going through parsed_type_reg (in general) is that it allows ZA to take qualifiers. This is necessary for many SME2 instructions. However, to support existing unqualified uses of ZA, parse_reg_with_qual needs to treat the qualiier as optional. Hopefully the net effect is to give better error messages, since now that SME2 makes "za.<T>" valid in some contexts, it might be natural to use it (incorrectly) in ZERO too. While there, the patch also tweaks the error messages for invalid ZA tiles, to try to make some cases more specific. For now, parse_sme_za_array just uses parse_reg, rather than parse_typed_reg/parse_reg_with_qual. A later patch consolidates the parsing further.
2023-03-30aarch64: Make SME instructions use F_STRICTRichard Sandiford3-57/+62
This patch makes all SME instructions use F_STRICT, so that qualifiers have to be provided explicitly rather than being inferred from other operands. The main change is to move the qualifier setting from the operand-level decoders to the opcode level. This is one step towards consolidating the ZA parsing code and extending it to handle SME2.
2023-03-30aarch64: Restrict range of PRFM opcodesRichard Sandiford1-0/+9
In the register-index forms of PRFM, the unallocated prefetch opcodes 24-31 have been reused for the encoding of the new RPRFM instruction. The PRFM opcode space is now capped at 23 for these forms. The other forms of PRFM are unaffected.
2023-03-30aarch64: Fix PSEL opcode maskRichard Sandiford1-1/+1
The opcode mask for PSEL was missing some bits, which meant that some upcoming SME2 opcodes would be misinterpreted as PSELs.
2023-03-30aarch64: Add sme-i16i64 and sme-f64f64 aliasesRichard Sandiford1-22/+22
Most extension flags are named after the associated architectural FEAT_* flags, but sme-i64 and sme-f64 were exceptions. This patch adds sme-i16i64 and sme-f64f64 aliases, but keeps the old names too for compatibility.
2023-03-21RISC-V: Fix disassemble fetch fail return value.Jiawei1-2/+2
This bug reported in https://sourceware.org/bugzilla/show_bug.cgi?id=30184 And discussed in https://sourceware.org/pipermail/binutils/2023-February/126213.html We also checked the implementation of return value in arm and mips. So this patch changes the return value to -1, that can fix bugs and maintain consistency with other architectures. opcodes/ChangeLog: * riscv-dis.c (print_insn_riscv):Change the return value.
2023-03-20x86: drop "shimm" special case template expansionsJan Beulich1-15/+15
With VexVVVV only being boolean, the SSE shift-by-immediate instructions don't need special casing anymore for SSE2AVX handling. Simplify the two respective templates. (No change to generated tables.)
2023-03-20x86: VexVVVV is now merely a booleanJan Beulich3-260/+247
With the SDM long having dropped the NDS/NDD/DDS concept of identifying encoding variants, we can finally do away with this concept as well. Of the few consumers of the attribute, only an assertion was still checking for a particular value, which we don't really need to retain. When touching lines anyway, modernize other aspects as well. This often improves similarity to adjacent lines.
2023-03-20x86: re-work build_modrm_byte()'s register assignmentJan Beulich2-57/+57
The function has accumulated a number of special cases for no real reason. Some were necessary because insn attributes (SwapSources in particular) weren't suitably utilized instead. Note that the addition of SwapSources actually increases consistency among the templates: Like others which already have the attribute, these are all insns where the VEX.VVVV-encoded register comes first (or last when looking at the SDM). Note that the vexvvvv attribute now has merely boolean meaning anymore, in line with the SDM long having dropped the NDS/NDD/DDS concept of identifying encoding variants. The fallout will be taken care of subsequently, though, to not further clutter the change here. As to the TILEZERO special case: If more instructions like this appeared, a new attribute would likely be the way to go. But as long as it's only a single insn, going from the mnemonic is cheaper.
2023-03-20Revert "segfault at i386-dis.c:9815"Alan Modra1-9/+4
This reverts commit 92d450c79ad321e42f9a77692b5db10d0f7b9344. Accessing these local var structs using a volatile qualified pointer may indeed read the object, but I don't think changed values are guaranteed to be written back to the object unless the actual object is declared volatile. That would probably slow down i386 disassembly unacceptably.
2023-03-19segfault at i386-dis.c:9815Alan Modra1-4/+9
* i386-dis.c (print_insn): Access "ins" and "priv" via volatile pointers after second sigsetjmp return.
2023-03-16cpu/mem.opc whitespace tidyAlan Modra2-24/+23
cpu/ * mep.opc: Whitespace and formatting. opcodes/ * mep-asm.c: Regenerate. * mep-dis.c: Regenerate.
2023-03-15Fix an illegal memory access when disassembling a corrupt MeP file.Nick Clifton2-0/+19
PR 30231 * mep.opc (mep_print_insn): Check for an out of range index.
2023-03-15Fix an illegal memory access when disassebling a corrupt ARM file.Nick Clifton2-5/+17
PR 30230 * arm-dis.c (get_sym_code_type): Check for non-ELF symbols.
2023-02-28[Aarch64] Add Binutils support for MECRichard Ball2-0/+13
This change supports MEC which is part of RME (Realm Management Extension).
2023-02-27Updated Serbian translations for gold, gprof and opcodes sub-directoriesNick Clifton1-300/+301
2023-02-25opcodes/m68k: enable libopcodes styling for GDBAndrew Burgess1-0/+5
The following commit added libopcodes styling for m68k: commit c22ff449275c91e4842bb10c650e83c572580f65 Date: Tue Feb 14 18:07:19 2023 +0100 opcodes: style m68k disassembler output but didn't set disassemble_info::created_styled_output in disassemble.c, which is needed in order for GDB to start using the libopcodes based styling. This commit fixes this small oversight. GDB now styles correctly.
2023-02-24x86: MONITOR/MWAIT are not SSE3 insnsJan Beulich5-7148/+7161
These have their own CPUID bit and hence they should also have their own separate control.
2023-02-24x86-64: don't permit LAHF/SAHF with "generic64"Jan Beulich5-5127/+5166
The feature isn't universally available on 64-bit CPUs. Note that in i386-gen.c:isa_dependencies[] I'm only adding it to models where I'm certain the functionality exists. For Nocona and Core I'm uncertain in particular.
2023-02-24x86: have insns acting on segment selector values allow for consistent operandsJan Beulich2-897/+964
While MOV to/from segment register as well as selector storing insns already permit 32- and 64-bit GPR operands, selector loading insns and ARPL do not. Split templates accordingly.
2023-02-24x86: restrict insn templates accepting negative 8-bit immediatesJan Beulich2-154/+154
For shifts (but not ordinary rotates) and other cases where an immediate describes e.g. a bit count or position, allowing negative operands is at best confusing. An extreme example would be the two rotate-through-carry insns, where a negative value would _not_ mean rotating the corresponding number of bits in the other direction. To refuse such, give meaning to the combination of Imm8 and Imm8S in templates (so far these weren't used together anywhere). The issue was with smallest_imm_type() blindly setting .imm8 for signed numbers determined to fit in a byte. VPROT{B,W,D,Q} is a little special: The rotate count there is a signed quantity, so Imm8 is replaced by Imm8S. Adjust affected testcases accordingly as well. Another small adjustment to the testsuite is necessary: AAM and AAD were never sensible to use with 0xffffff90 operands. This should have been an error.
2023-02-22x86-64: LAR and LSL don't need REX.WJan Beulich2-8/+8
Just like we suppress emitting REX.W for e.g. MOV from/to segment register, there's also no need for it for LAR and LSL - these can only ever return 32-bit values and hence always zero-extend their results anyway. While there also drop the redundant Word from the first operand of the second template each - this is already implied by Reg16.
2023-02-22x86: optimize BT{,C,R,S} $imm,%regJan Beulich2-8/+8
In 64-bit mode BT can have REX.W or a data size prefix dropped in certain cases. Outside of 64-bit mode all 4 insns can have the data size prefix dropped in certain cases.
2023-02-20opcodes: style m68k disassembler outputAndreas Schwab1-116/+238
2023-02-14x86: {LD,ST}TILECFG use an extension opcodeJan Beulich2-4/+4
It being zero and happening to work right now doesn't mean the insns shouldn't be spelled out properly.
2023-02-13PR30120: fix x87 fucomp misassembledMichael Matz2-2/+2
this fixes the entry for 'fucomp' to use the correct Reg value (otherwise it's assembled as 'fucom').
2023-02-13opcodes/mips: disassemble unknown micromips instructions as two shortsAndrew Burgess1-5/+8
Before commit: commit 2438b771ee07be19d5b01ea55e077dd8b7cef445 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-10x86: drop use of VEX3SOURCESJan Beulich4-7676/+3850
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-10x86: drop use of XOP2SOURCESJan Beulich3-29/+27
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-10x86: limit use of XOP2SOURCESJan Beulich2-5/+5
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-10x86: move (and rename) opcodespace attributeJan Beulich3-10991/+11023
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-03bpf: fix error conversion from long unsigned int to unsigned int ↵Guillermo E. Martinez2-26/+30
[-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-03RISC-V: don't disassemble unrecognized insns as .byteJan Beulich1-30/+20
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-01-31RISC-V: make C-extension JAL available again for (32-bit) assemblyJan Beulich1-1/+1
Along with the normal JAL alias, the C-extension one should have been moved as well by 839189bc932e ("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-27x86: use ModR/M for FPU insns with operandsJan Beulich3-216/+216
This is the correct way of expressing things; encoding the ModR/M byte directly in base_opcode has always been bogus.
2023-01-27opcodes: suppress internationalization on build helper toolsJan Beulich3-47/+2
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.