Commit Graph

3773 Commits

Author SHA1 Message Date
Nick Clifton
5fe73d4624 Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories 2022-01-24 14:22:49 +00:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00
Nick Clifton
a74e1cb344 Add markers for 2.38 branch 2022-01-22 12:08:55 +00:00
Nick Clifton
6c037fdbf0 Update the config.guess and config.sub files from the master repository and regenerate files. 2022-01-17 16:21:22 +00:00
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
Marcus Nilsson
96c7115a9a Allow the --visualize-jumps feature to work with the AVR disassembler.
* avr-dis.c (avr_operand); Pass in disassemble_info and fill
	in insn_type on branching instructions.
2021-12-02 13:57:11 +00:00
Andrew Burgess
3a337a86d9 opcodes/riscv: add disassembler options support to libopcodes
In preparation for the next commit, which will add GDB support for
RISC-V disassembler options, this commit restructures how the
disassembler options are managed within libopcodes.

The implementation provided here is based on this mailing list patch
which was never committed:

  https://sourceware.org/pipermail/binutils/2021-January/114944.html

which in turn took inspiration from the MIPS implementation of the
same feature.

The biggest changes from the original mailing list post are:

  1. The GDB changes have been split into a separate patch, and

  2. The `riscv_option_args_privspec` variable, which held the valid
  priv-spec values is now gone, instead we use the `riscv_priv_specs`
  array from bfd/cpu-riscv.c instead.

Co-authored-by: Simon Cook <simon.cook@embecosm.com>

include/ChangeLog:

	* dis-asm.h (disassembler_options_riscv): Declare.

opcodes/ChangeLog:

	* riscv-dis.c (enum riscv_option_arg_t): New enum typedef.
	(riscv_options): New static global.
	(disassembler_options_riscv): New function.
	(print_riscv_disassembler_options): Rewrite to use
	disassembler_options_riscv.
2021-11-26 10:18:35 +00:00
Nick Clifton
7060c28edd Fix building the AArch64 assembler and disassembler when assertions are disabled.
PR 28614
	* aarch64-asm.c: Replace assert(0) with real code.
	* aarch64-dis.c: Likewise.
	* aarch64-opc.c: Likewise.
2021-11-25 13:11:25 +00:00
Nick Clifton
79abb93930 Updated French translation for the opcodes directory.
* po/fr.po; Updated French translation.
2021-11-25 11:13:32 +00:00
Maciej W. Rozycki
2b677209fe opcodes: Fix RPATH not being set for dynamic libbfd dependency
If built as a shared library, libopcodes has a load-time dependency on
libbfd, which is recorded in the dynamic section, however without a
corresponding RPATH entry for the directory to find libbfd in.  This
causes loading to fail whenever libbfd is only pulled by libopcodes
indirectly and libbfd has been installed in a directory that is not in
the dynamic loader's search path.

It does not happen with the programs included with binutils or GDB,
because they all also pull libbfd when using libopcodes, but it can
happen with external software, e.g.:

$ gdbserver --help
gdbserver: error while loading shared libraries: libbfd-[...].so: cannot open shared object file: No such file or directory
$

(not our `gdbserver').

Indirect dynamic dependencies are handled by libtool automatically by
adding RPATH entries as required, however our setup for libopcodes
prevents this from happening by linking in libbfd with an explicit file
reference sneaked through to the linker directly behind libtool's back
via the `-Wl' linker command-line option rather than via `-l' combined
with a suitable library search path specified via `-L', as it would be
usually the case, or just referring to the relevant .la file in a fully
libtool-enabled configuration such as ours.

According to an observation in the discussion back in 2007[1][2][3] that
has led to the current arrangement it is to prevent libtool from picking
up the wrong version of libbfd.  It does not appear to be needed though,
not at least with our current libtool incarnation, as directly referring
`libbfd.la' does exactly what it should, as previously suggested[4], and
with no link-time reference to the installation directory other than to
set RPATH.  Uninstalled version of libopcodes has libbfd's build-time
location prepended to RPATH too, as also expected.

Use a direct reference to `libbfd.la' then, making the load error quoted
above go away.  Alternatively `-L' and `-l' could be used to the same
effect, but it seems an unnecessary complication and just another way to
circumvent rather than making use of libtool.

References:

[1] "compile failure due to undefined symbol",
    <https://sourceware.org/ml/binutils/2007-08/msg00476.html>

[2] same, <https://sourceware.org/ml/binutils/2007-09/msg00000.html>

[3] same, <https://sourceware.org/ml/binutils/2007-10/msg00019.html>

[4] same, <https://sourceware.org/ml/binutils/2007-10/msg00034.html>

	opcodes/
	* Makefile.am: Remove obsolete comment.
	* configure.ac: Refer `libbfd.la' to link shared BFD library
	except for Cygwin.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2021-10-27 12:21:14 +01:00
Nick Alcock
b9004024b9 configure: regenerate in all projects that use libtool.m4
(including sim/, which has no changelog.)

bfd/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

binutils/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gas/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gprof/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

ld/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

libctf/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
	* Makefile.in: Regenerate.

opcodes/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

zlib/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
2021-09-27 20:31:24 +01:00
Peter Bergner
4d5d5d4689 PowerPC: Enable mfppr mfppr32, mtppr and mtppr32 extended mnemonics on POWER5
SPR 896 and the mfppr mfppr32, mtppr and mtppr32 extended mnemonics were added
in ISA 2.03, so enable them on POWER5 and later.

opcodes/
	* ppc-opc.c (powerpc_opcodes) <mfppr, mfppr32, mtppr, mtppr32>: Enable
	on POWER5 and later.

gas/
	* testsuite/gas/ppc/power5.s: New test.
	* testsuite/gas/ppc/power5.d: Likewise.
	* testsuite/gas/ppc/ppc.exp: Run it.
	* testsuite/gas/ppc/power7.s: Remove tests for mfppr, mfppr32, mtppr
	and mtppr32.
	* testsuite/gas/ppc/power7.d: Likewise.
2021-09-25 18:21:17 -05:00
Andrew Burgess
6a7f57668a riscv: print .2byte or .4byte before an unknown instruction encoding
When the RISC-V disassembler encounters an unknown instruction, it
currently just prints the value of the bytes, like this:

  Dump of assembler code for function custom_insn:
     0x00010132 <+0>:	addi	sp,sp,-16
     0x00010134 <+2>:	sw	s0,12(sp)
     0x00010136 <+4>:	addi	s0,sp,16
     0x00010138 <+6>:	0x52018b
     0x0001013c <+10>:	0x9c45

My proposal, in this patch, is to change the behaviour to this:

  Dump of assembler code for function custom_insn:
     0x00010132 <+0>:	addi	sp,sp,-16
     0x00010134 <+2>:	sw	s0,12(sp)
     0x00010136 <+4>:	addi	s0,sp,16
     0x00010138 <+6>:	.4byte	0x52018b
     0x0001013c <+10>:	.2byte	0x9c45

Adding the .4byte and .2byte opcodes.  The benefit that I see here is
that in the patched version of the tools, the disassembler output can
be fed back into the assembler and it should assemble to the same
binary format.  Before the patch, the disassembler output is invalid
assembly.

I've started a RISC-V specific test file under binutils so that I can
add a test for this change.

binutils/ChangeLog:

	* testsuite/binutils-all/riscv/riscv.exp: New file.
	* testsuite/binutils-all/riscv/unknown.d: New file.
	* testsuite/binutils-all/riscv/unknown.s: New file.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_disassemble_insn): Print a .%dbyte opcode
	before an unknown instruction, '%d' is replaced with the
	instruction length.
2021-09-20 09:45:34 +01:00
Nick Clifton
718aefcf55 Fix the V850 assembler's generation of relocations for the st.b instruction.
PR 28292
gas	* config/tc-v850.c (handle_lo16): Also accept
	BFD_RELOC_V850_LO16_SPLIT_OFFSET.
	* testsuite/gas/v850/split-lo16.s: Add extra line.
	* testsuite/gas/v850/split-lo16.d: Update expected disassembly.

opcodes	* v850-opc.c (D16): Use BFD_RELOC_V850_LO16_SPLIT_OFFSET in place
	of BFD_RELOC_16.
2021-09-02 12:16:10 +01:00
Shahab Vahedi
5d9cff510e opcodes: Fix the auxiliary register numbers for ARC HS
The numbers for the auxiliary registers "tlbindex" and
"tlbcommand" of ARCv2HS are incorrect.  This patch makes
the following changes to correct that error.

 ,------------.-----------------.---------------.
 | aux. reg.  | old (incorrect) | new (correct) |
 |------------+-----------------+---------------|
 | tlbindex   |      0x463      |     0x464     |
 | tlbcommand |      0x464      |     0x465     |
 `------------^-----------------^---------------'

opcodes/
2021-08-17  Shahab Vahedi <shahab@synopsys.com>

	* arc-regs.h (DEF): Fix the register numbers.
2021-08-17 18:33:05 +02:00
Nick Clifton
3ee0cd9e55 Updated Serbian and Russian translations for various sub-directories 2021-08-10 16:40:37 +01:00
Chenghua Xu
8d56b9fcf3 Correct gs264e bfd_mach in mips_arch_choices.
opcodes/
    * mips-dis.c (mips_arch_choices): Correct gs264e bfd_mach.
2021-07-27 09:18:27 +08:00
Andreas Krebbel
b180e8298b Add changelog entries for last commit 2021-07-07 14:17:05 +02:00
Nick Clifton
346d80ef33 Update version number and regenerate files 2021-07-03 15:16:48 +01:00
Nick Clifton
514192487e Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
Alan Modra
62194b631d Re: Fix minor NDS32 renaming snafu
Some extern declarations differ in constnes to their definitions too.
Let's make sure this sort of thing doesn't happen again, but putting
the externs in a header where they belong.

gas/
	* config/tc-nds32.c (nds32_keyword_gpr): Don't declare.
	(md_begin): Constify k.
opcodes/
	* nds32-dis.c (nds32_find_reg_keyword): Constify arg and return.
	(nds32_parse_audio_ext, nds32_parse_opcode): Constify psys_reg.
	(nds32_field_table, nds32_opcode_table, nds32_keyword_table),
	(nds32_opcodes, nds32_operand_fields, nds32_keywords),
	(nds32_keyword_gpr): Move declarations to..
	* nds32-asm.h: ..here, constifying to match definitions.
2021-07-02 20:48:55 +09:30
Mike Frysinger
2fe36d31f9 cgen: split GUILE setting out
This makes it easier to override to point to an older version of guile.
The current cgen code doesn't work with guile-2, so need to point to an
older guile-1.8.
2021-07-01 18:05:40 -04:00
Mike Frysinger
f375d32b35 opcodes: constify & local meps macros
Avoid exporting this common variable name into writable data.
2021-07-01 18:04:16 -04:00
Mike Frysinger
9b2beaf778 opcodes: cleanup nds32 variables
For the variables that don't need to be exported, mark them static.
For the ones shared between modules, add a "nds32_" prefix to avoid
collisions with these common variable names.
2021-07-01 18:03:02 -04:00
Mike Frysinger
ac8ef6961e opcodes: constify & localize z80 opcodes
These aren't used outside of this module, and are never modified.
Mark it static to avoid bad exported variable name issues.
2021-07-01 17:56:24 -04:00
Mike Frysinger
52b8387412 opcodes: constify & scope microblaze opcodes
This is exporting the variable "opcodes" as a large writable blob.
This is not a namespace friendly name, so add a "microblaze" prefix,
and then sprinkle const over its definition & use.
2021-07-01 17:55:26 -04:00
Mike Frysinger
6c2ede018c opcodes: constify aarch64_opcode_tables
This table is huge (~350k), so stop putting it into writable .data
since it's only const data.
2021-07-01 17:51:00 -04:00
Andrew Burgess
46b8b3d6f8 opcodes: make use of __builtin_popcount when available
This commit provides a small performance improvement when starting up
CGEN based disassemblers by making use of __builtin_popcount.

The #if check used in this commit was copied from bfd/elf32-arm.c
where __builtin_popcount is also used.

I ran into this code while investigating some GDB tests that would
occasionally timeout.  One of the reason these tests were having
problems is that the m16c and m32c disassemblers take so long to
initialise themselves.  Speeding up count_decodable_bits helps, but is
not a total solution.  Still, this felt like an easy win which added
minimal extra complexity, so I figure its worth doing.

opcodes/ChangeLog:

	* cgen-dis.c (count_decodable_bits): Use __builtin_popcount when
	available.
2021-06-22 09:53:13 +01:00
Alan Modra
ded5cb9444 picojava assembler and disassembler fixes
Commit 54758c3e39 made changes to the picojava support based on
https://sourceware.org/pipermail/binutils/2005-November/045136.html
An update from picojava to picojava II, I think.  Unfortunately the
patch neglected any changes to the gas testsuite, resulting in
"FAIL: pj" since that date.  This patch makes a few relatively simple
changes to cure the regression.

gas/
	* config/tc-pj.c (md_apply_fix): Apply PJ_CODE_REL32 relocs.
	* testsuite/gas/pj/ops.s: Update jsr, ret, getstatic,
	putstatic, getfield, putfield, invokevirtual, invokespecial,
	invokestatic, invokeinterface, goto_w, jsr_w assembly.  Delete
	version 1 picojava opcodes.
	* testsuite/gas/pj/ops.d: Match expected output.
opcodes/
	* pj-dis.c (print_insn_pj): Don't print trailing tab.  Do
	print separator for pcrel insns.
2021-06-22 17:44:45 +09:30
Alan Modra
47399e9c45 ubsan: vax: pointer overflow
"VAX export class call relocation test" fails with ubsan on a 32-bit
host.

	* vax-dis.c (print_insn_vax): Avoid pointer overflow.
2021-06-19 11:08:56 +09:30
Alan Modra
d984392e75 Fix another strncpy warning
* tic30-dis.c (get_register_operand): Don't ask strncpy to fill
	entire buffer.
2021-06-19 11:08:55 +09:30
Alan Modra
7993124ee2 powerpc: move cell "or rx,rx,rx" hints
* ppc-opc.c (powerpc_opcodes): Move cell db*cyc to proper location
	in table.
2021-06-17 15:38:09 +09:30
Alan Modra
a38d139645 PR1202, mcore disassembler: wrong address loopt
Fixes a 16 year old bug report, which even came with a patch.

opcodes/
	PR 1202
	* mcore-dis.c (print_insn_mcore): Correct loopt disassembly.
	Use unsigned int for inst.
gas/
	PR 1202
	* testsuite/gas/mcore/allinsn.d: Correct loopt expected output.
2021-06-03 13:05:57 +09:30
Shahab Vahedi
8f46711443 arc: Construct disassembler options dynamically
The idea of this change is simple: Populate a data structure, namely
"disasm_option_and_arg_t" from "include/dis-asm.h", to encompass the
disassembly options and their possible arguments.

This will make it easier to manage or extend those options by adapting
entries in a data structure, "arc_options".  There will be lesser need
to hard-code the options in the code itself.  Moreover, ARC GDB will
use this population function, "disassembler_options_arc ()", to enable
the "set disassembler-option" for ARC targets.  The gdb change will be
in a separate patch though.

The changes in this patch can be divided into:

1) Introduction of "disassembler_options_arc ()" that will return a
"disasm_option_and_arg_t" structure representing the disassembly
options and their likely arguments.

2) New data type "arc_options_arg_t" and new data "arc_options".
These are the internals for keeping track of options and arguments
entries that can easily be extended.

3) To print the options, the "print_arc_disassembler_options ()" has
been adjusted to use this dynamically built structure instead of having
them hard-coded inside.

To see this in effect, one can look into the output of:
$ ./binutils/objdump --help
  ...
  The following ARC specific disassembler options are...
  ...

include/ChangeLog:

	* dis-asm.h (disassembler_options_arc): New prototype.

opcodes/ChangeLog:

	* arc-dis.c (arc_option_arg_t): New enumeration.
	(arc_options): New variable.
	(disassembler_options_arc): New function.
	(print_arc_disassembler_options): Reimplement in terms of
	"disassembler_options_arc".
2021-06-02 15:32:58 +03:00
Alan Modra
1ff6a3b8e5 PowerPC table driven -Mraw disassembly
opcodes/
	* ppc-dis.c (lookup_powerpc): Test deprecated field when -Many.
	Don't special case PPC_OPCODE_RAW.
	(lookup_prefix): Likewise.
	(lookup_vle, lookup_spe2): Similarly.  Add dialect parameter and..
	(print_insn_powerpc): ..update caller.
	* ppc-opc.c (EXT): Define.
	(powerpc_opcodes): Mark extended mnemonics with EXT.
	(prefix_opcodes, vle_opcodes): Likewise.
	(XISEL, XISEL_MASK): Add cr field and simplify.
	(powerpc_opcodes): Use XISEL with extended isel mnemonics and sort
	all isel variants to where the base mnemonic belongs.  Sort dstt,
	dststt and dssall.
gas/
	* testsuite/gas/ppc/raw.s,
	* testsuite/gas/ppc/raw.d: New test.
	* testsuite/gas/ppc/ppc.exp: Run it.
2021-05-29 21:06:06 +09:30
Maciej W. Rozycki
49149d595c MIPS/opcodes: Reorder legacy COP0, COP2, COP3 opcode instructions
Group legacy instructions using the COP0, COP2, COP3 opcodes together
and by their coprocessor number, and move them towards the end of the
opcode table.  No functional change.

With the addition of explicit ISA exclusions this is maybe not strictly
necessary anymore as the individual legacy instructions are not supposed
to match ISA levels or CPU implementations that have discarded them or
replaced with a new instruction each, but let's not have them scattered
randomly across blocks of unrelated instruction sets where someone chose
to put them previously.  Perhaps they could be put back in alphabetical
order in the main instruction block, but let's leave it for another
occasion.

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Reorder legacy COP0, COP2,
	COP3 opcode instructions.
2021-05-29 03:26:33 +02:00
Maciej W. Rozycki
9573a461da MIPS/opcodes: Accurately record coprocessor opcode CPU/ISA membership
Adjust opcode table entries for coprocessor instructions that have been
removed from certain ISA levels or CPU implementations as follows:

- remove CP0 memory access instructions from MIPS II up as the LWC0 and
  SWC0 opcodes have been reused for the LL and SC instructions
  respectively[1]; strictly speaking LWC0 and SWC0 have never really
  been defined in the first place[2], but let's keep them for now in
  case an odd implementation did,

- remove CP0 branch instructions from MIPS IV[3] and MIPS32[4] up, as
  they have been removed as from those ISAs,

- remove CP0 control register move instructions from MIPS32 up, as they
  have been removed as from that ISA[5],

- remove the RFE instruction from MIPS III[6] and MIPS32[7] up, as it
  has been removed as from those ISAs in favour to ERET,

- remove CP2 instructions from Vr5400 CPUs as their encodings have been
  reused for the multimedia instruction set extensions[8] and no CP2
  registers exist[9],

- remove CP3 memory access instructions from MIPS III up as coprocessor
  3 has been removed as from that ISA[10][11] and from MIPS32 up as the
  LWC3 opcode has been reused for the PREF instruction and consequently
  all the four memory access instructions removed from the ISA (though
  the COP3 opcode has been retained)[12].

Update the testsuite accordingly.

References:

[1]  Charles Price, "MIPS IV Instruction Set", MIPS Technologies, Inc.,
     Revision 3.2, September, 1995, Table A-38 "CPU Instruction Encoding
     - MIPS II Architecture", p. A-178

[2]  same, Section A.2.5.1 "Coprocessor Load and Store", p. A-12

[3]  "MIPS R10000 Microprocessor User's Manual", Version 2.0, MIPS
     Technologies, Inc., January 29, 1997, Section 14.25 "CP0
     Instructions", Subsection "Branch on Coprocessor 0", p. 285

[4]  "MIPS32 Architecture For Programmers, Volume II: The MIPS32
     Instruction Set", MIPS Technologies, Inc., Document Number:
     MD00086, Revision 1.00, June 9, 2003, Table A-9 "MIPS32 COP0
     Encoding of rs Field", p. 242

[5]  same

[6]  Joe Heinrich, "MIPS R4000 Microprocessor User's Manual", Second
     Edition, MIPS Technologies, Inc., April 1, 1994, Figure A-2 "R4000
     Opcode Bit Encoding", p. A-182

[8]  "Vr5432 64-bit MIPS RISC Microprocessor User's Manual, Volume 1",
     NEC Electronics Inc., Document No. U13751EU5V0UM00, May 2000,
     Section 1.2.3 "CPU Instruction Set Overview", p. 9

[9]  "Vr5432 64-bit MIPS RISC Microprocessor User's Manual, Volume 2",
     NEC Electronics Inc., Document No. U13751EU5V0UM00, May 2000,
     Section 19.2 "Multimedia Instruction Format", p. 681

[10] Charles Price, "MIPS IV Instruction Set", MIPS Technologies, Inc.,
     Revision 3.2, September, 1995, Section A 8.3.4 "Coprocessor 3 -
     COP3 and CP3 load/store", p. A-176

[11] same, Table A-39 "CPU Instruction Encoding - MIPS III
     Architecture", p. A-179

[12] "MIPS32 Architecture For Programmers, Volume II: The MIPS32
     Instruction Set", MIPS Technologies, Inc., Document Number:
     MD00086, Revision 1.00, August 29, 2002, Table A-2 "MIPS32 Encoding
     of the Opcode Field", p. 241

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Update exclusion list for
	"ldc2", "ldc3", "lwc0", "lwc2", "lwc3", "sdc2", "sdc3", "swc0",
	"swc2", "swc3", "cfc0", "ctc0", "bc2f", "bc2fl", "bc2t",
	"bc2tl", "cfc2", "ctc2", "dmfc2", "dmtc2", "mfc2", "mtc2",
	"bc3f", "bc3fl", "bc3t", "bc3tl", "cfc3", "ctc3", "mfc3",
	"mtc3", "bc0f", "bc0fl", "bc0t", "bc0tl", "rfe", "c2", "c3",
	"cop2", and "cop3" entries.

	gas/
	* testsuite/gas/mips/mips32@isa-override-1.d: Update for LDC3
	instruction removal.
	* testsuite/gas/mips/mips32r2@isa-override-1.d: Likewise.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
fa49574399 MIPS/opcodes: Remove DMFC3 and DMTC3 instructions
Coprocessor 3 has been removed from the MIPS ISA as from MIPS III[1][2]
with the LDC3 and SDC3 instructions having been replaced with LD and SD
instructions respectively and therefore the doubleword move instructions
from and to that coprocessor have never materialized (for 32-bit ISAs
coprocessor 3 has likewise been removed as from MIPS32r2[3]).  Remove
the DMFC3 and DMTC3 instructions from the opcode table then to avoid
confusion.

References:

[1] Charles Price, "MIPS IV Instruction Set", MIPS Technologies, Inc.,
    Revision 3.2, September, 1995, Section A 8.3.4 "Coprocessor 3 - COP3
    and CP3 load/store", p. A-176

[2] same, Table A-39 "CPU Instruction Encoding - MIPS III Architecture",
    p. A-179

[3] "MIPS32 Architecture For Programmers, Volume II: The MIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00086,
    Revision 2.00, June 9, 2003, Table A-2 "MIPS32 Encoding of the
    Opcode Field", p. 317

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Remove "dmfc3" and "dmtc3"
	entries and associated comments.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
b930964c42 MIPS/opcodes: Disassemble the RFE instruction
Fix a commit b015e599c7 ("[MIPS] Add new virtualization instructions"),
<https://sourceware.org/ml/binutils/2013-05/msg00118.html>, regression
and bring the disassembly of the RFE instruction back for the relevant
ISA levels.

It is because the "rfe" opcode table entry was incorrectly moved behind
the catch-all generic "c0" entry for CP0 instructions, causing output
like:

  00:	42000010 	c0	0x10

to be produced rather than:

  00:	42000010 	rfe

even for ISA levels that do include the RFE instruction.

Move the "rfe" entry ahead of "c0" then, correcting the problem.  Add a
suitable test case.

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Move the "rfe" entry ahead
	of "c0".

	gas/
	* testsuite/gas/mips/rfe.d: New test.
	* testsuite/gas/mips/rfe.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new test.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
dd84446824 MIPS/opcodes: Add legacy CP1 control register names
The two CP1 control registers defined by legacy ISAs used to be referred
to by various names, such as FCR0, FCR31, FSR, however their documented
full names have always been the Implementation and Revision, and Control
and Status respectively, so the FIR and FCSR acronyms coming from modern
ISA revisions will be just as unambiguous while improving the clarity of
disassembly.  Do not update the TX39 though as it did not have an FPU.

	opcodes/
	* mips-dis.c (mips_cp1_names_mips): New variable.
	(mips_arch_choices): Use it rather than `mips_cp1_names_numeric'
	for "r3000", "r4000", "r4010", "vr4100", "vr4111", "vr4120",
	"r4300", "r4400", "r4600", "r4650", "r5000", "vr5400", "vr5500",
	"r5900", "r6000", "rm7000", "rm9000", "r8000", "r10000",
	"r12000", "r14000", "r16000", "mips5", "loongson2e", and
	"loongson2f".

	gas/
	* testsuite/gas/mips/cp1-names-r3900.d: New test.
	* testsuite/gas/mips/mips.exp: Run the new test.
	* testsuite/gas/mips/branch-misc-3.d: Update disassembly
	according to changes to opcodes.
	* testsuite/gas/mips/cp1-names-r3000.d: Likewise.
	* testsuite/gas/mips/cp1-names-r4000.d: Likewise.
	* testsuite/gas/mips/relax-swap1-mips1.d: Likewise.
	* testsuite/gas/mips/relax-swap1-mips2.d: Likewise.
	* testsuite/gas/mips/trunc.d: Likewise.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
9204ccd4b1 MIPS/opcodes: Do not use CP0 register names for control registers
The CP0 control register set has never been defined, however encodings
for the CFC0 and CTC0 instructions remained available for implementers
up until the MIPS32 ISA declared them invalid and causing the Reserved
Instruction exception[1].  Therefore we handle them for both assembly
and disassembly, however in the latter case the names of CP0 registers
from the regular set are incorrectly printed if named registers are
requested.  This is because we do not define separate operand classes
for coprocessor regular and control registers respectively, which means
the disassembler has no way to tell the two cases apart.  Consequently
nonsensical disassembly is produced like:

	cfc0	v0,c0_random

Later the MIPSr5 ISA reused the encodings for XPA ASE MFHC0 and MTHC0
instructions[2] although it failed to document them in the relevant
opcode table until MIPSr6 only.

Correct the issue then by defining a new register class, OP_REG_CONTROL,
and corresponding operand codes, `g' and `y' for the two positions in
the machine instruction a control register operand can take.  Adjust the
test cases affected accordingly.

While at it swap the regular MIPS opcode table "cfc0" and "ctc0" entries
with each other so that they come in the alphabetical order.

References:

[1] "MIPS32 Architecture For Programmers, Volume II: The MIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00086,
    Revision 1.00, August 29, 2002, Table A-9 "MIPS32 COP0 Encoding of
    rs Field", p. 242

[2] "MIPS Architecture For Programmers, Volume II-A: The MIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00086,
    Revision 5.04, December 11, 2013, Section 3.2 "Alphabetical List of
    Instructions", pp. 195, 216

	include/
	* opcode/mips.h: Document `g' and `y' operand codes.
	(mips_reg_operand_type): Add OP_REG_CONTROL enumeration
	constant.

	gas/
	* tc-mips.c (convert_reg_type) <OP_REG_CONTROL>: New case.
	(macro) <M_TRUNCWS, M_TRUNCWD>: Use the `g' rather than `G'
	operand code.

	opcodes/
	* mips-dis.c (print_reg) <OP_REG_COPRO>: Move control register
	handling code over to...
	<OP_REG_CONTROL>: ... this new case.
	* mips-opc.c (decode_mips_operand) <'g', 'y'>: New cases.
	(mips_builtin_opcodes): Update "cfc1", "ctc1", "cttc1", "cttc2",
	"cfc0", "ctc0", "cfc2", "ctc2", "cfc3", and "ctc3" entries
	replacing the `G' operand code with `g'.  Update "cftc1" and
	"cftc2" entries replacing the `E' operand code with `y'.
	* micromips-opc.c (decode_micromips_operand) <'g'>: New case.
	(micromips_opcodes): Update "cfc1", "cfc2", "ctc1", and "ctc2"
	entries replacing the `G' operand code with `g'.

	binutils/
	* testsuite/binutils-all/mips/mips-xpa-virt-1.d: Correct CFC0
	operand disassembly.
	* testsuite/binutils-all/mips/mips-xpa-virt-3.d: Likewise.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
a3fb396f2d MIPS/opcodes: Add TX39 CP0 register names
The TX39 core has its distinct set of CP0 registers[1], so it needs a
separate table to hold their names.  Add a test case accordingly.

References:

[1] "32-Bit RISC Microprocessor TX39 Family Core Architecture User's
    Manual", Toshiba, Jul. 27, 1995, Section 2.2.2 "System control
    coprocessor (CP0) registers", pp. 9-10

	opcodes/
	* mips-dis.c (mips_cp0_names_r3900): New variable.
	(mips_arch_choices): Use it rather than `mips_cp0_names_numeric'
	for "r3900".

	gas/
	* testsuite/gas/mips/cp0-names-r3900.d: New test.
	* testsuite/gas/mips/mips.exp: Run it.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
cccc84faff MIPS/opcodes: Free up redundant `g' operand code
In the operand handling rewrite made for the MIPS disassembler with
commit ab90248154 ("Add structures to describe MIPS operands"),
<https://sourceware.org/ml/binutils/2013-07/msg00135.html>, the `g'
operand code has become redundant for the regular MIPS instruction set
by duplicating the OP_REG_COPRO semantics of the `G' operand code.

Later commit 351cdf24d2 ("Implement O32 FPXX, FP64 and FP64A ABI
extensions") converted the CTTC1 instruction from the `g' to the `G'
operand code, but still left a few instructions behind.

Convert the three remaining instructions still using the `g' code then,
namely: CTTC2, MTTC2 and MTTHC2, and remove all traces of the operand
code, freeing it up for other use.

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Switch "cttc2", "mttc2",
	and "mtthc2" to using the `G' rather than `g' operand code for
	the coprocessor control register referred.

	include/
	* opcode/mips.h: Complement change made to opcodes and remove
	references to the `g' regular MIPS ISA operand code.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
c9de3168a9 microMIPS/opcodes: Refer FPRs rather than FCRs with DMTC1
The DMTC1 instruction operates on a floating-point general register as
its second operand, however in the disassembly of the microMIPS encoding
a floating-point control register is shown instead.  This is due to an
incorrect ordering of the two "dmtc1" entries in the opcode table, which
gives precedence to one using the `G' aka coprocessor format over one
using the `S' or floating-point register format.

The coprocessor format, or OP_REG_COPRO, is used so that GAS supports
referring to FPRs by their numbers in assembly, such as $0, $1, etc.
however in the case of CP1/FPU it is also used by the disassembler to
decode those numbers to the names of corresponding control registers.
This in turn causes nonsensical disassembly such as:

	dmtc1	a1,c1_fir

in a reference to $f0.  It has been like this ever since microMIPS ISA
support has been added.

Correct the ordering of the two entries then by swapping them with each
other, making disassembly output consistent with the regular MIPS DMTC1
instruction as well all the remaining CP1 move instructions.  Adjust all
the test cases affected accordingly.

	opcodes/
	* micromips-opc.c (micromips_opcodes): Swap the two "dmtc1"
	entries with each other.

	gas/
	* testsuite/gas/mips/micromips.d: Update disassembly according
	to "dmtc1" entry fix with opcodes.
	* testsuite/gas/mips/micromips-compact.d: Likewise.
	* testsuite/gas/mips/micromips-insn32.d: Likewise.
	* testsuite/gas/mips/micromips-noinsn32.d: Likewise.
	* testsuite/gas/mips/micromips-trap.d: Likewise.
	* testsuite/gas/mips/micromips@isa-override-1.d: Likewise.
2021-05-29 03:26:32 +02:00
Peter Bergner
ebcab74124 PowerPC: Add new xxmr and xxlnot extended mnemonics
opcodes/
	* ppc-opc.c (powerpc_opcodes) <xxmr, xxlnot>: New extended mnemonics.

gas/
	* testsuite/gas/ppc/vsx.d <xxmr, xxlnot>: Add tests.
	* testsuite/gas/ppc/vsx.s: Likewise.
2021-05-27 16:59:15 -05:00
Alan Modra
bc30a119f3 Regen cris files
* cris-desc.c: Regenerate.
	* cris-desc.h: Regenerate.
	* cris-opc.h: Regenerate.
	* po/POTFILES.in: Regenerate.
2021-05-25 17:17:04 +09:30
Mike Frysinger
5471128011 opcodes: cris: move desc & opc files from sim/
All other cgen ports keep their generated desc & opc files under
opcodes/, so move the cris files over too.  The cris-opc.c file,
while not generated, is already here to complement.
2021-05-24 18:42:34 -04:00
Job Noorman
113bb7618a RISC-V: PR27814, Objdump crashes when disassembling a non-ELF RISC-V binary.
2021-05-18  Job Noorman  <mtvec@pm.me>

opcodes/
    PR 27814
    * riscv-dis.c (riscv_get_disassembler): Get elf attributes only for
    the elf objects.
2021-05-18 09:26:39 +08:00
Alex Coplan
e683cb4120 arm: Fix bugs with MVE vmov from two GPRs to vector lanes
The initial problem I wanted to fix here is that GAS was rejecting MVE
instructions such as:

vmov q3[2], q3[0], r2, r2

with:

Error: General purpose registers may not be the same -- `vmov q3[2],q3[0],r2,r2'

which is incorrect; such instructions are valid. Note that for moves in
the other direction, e.g.:

vmov r2, r2, q3[2], q3[0]

GAS is correct in rejecting this as it does not make sense to move both
lanes into the same register (the Arm ARM says this is CONSTRAINED
UNPREDICTABLE).

After fixing this issue, I added assembly/disassembly tests for these
vmovs. This revealed several disassembly issues, including incorrectly
marking the moves into vector lanes as UNPREDICTABLE, and disassembling
many of the vmovs as vector loads. These are now fixed.

gas/ChangeLog:

	* config/tc-arm.c (do_mve_mov): Only reject vmov if we're moving
	into the same GPR twice.
	* testsuite/gas/arm/mve-vmov-bad-2.l: Tweak error message.
	* testsuite/gas/arm/mve-vmov-3.d: New test.
	* testsuite/gas/arm/mve-vmov-3.s: New test.

opcodes/ChangeLog:

	* arm-dis.c (mve_opcodes): Fix disassembly of
	MVE_VMOV2_GP_TO_VEC_LANE when idx == 1.
	(is_mve_encoding_conflict): MVE vector loads should not match
	when P = W = 0.
	(is_mve_unpredictable): It's not unpredictable to use the same
	source register twice (for MVE_VMOV2_GP_TO_VEC_LANE).
2021-05-17 15:12:39 +01:00
Nick Clifton
a680affc63 Fix an illegal memory access when attempting to disassemble a corrupt TIC30 binary.
PR 27840
	* tic30-dis.c (print_insn_tic30): Prevent attempts to read beyond
	the end of the code buffer.
2021-05-11 11:29:58 +01:00