Commit Graph

4007 Commits

Author SHA1 Message Date
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
Stafford Horne
0b3e14c902 or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
using the -mcmodel=large option.  This relocation is used along with
got() to generate 32-bit GOT offsets.  This increases the previous GOT
offset limit from the previous 16-bit (64K) limit.

This is needed on large binaries where the GOT grows larger than 64k.

bfd/ChangeLog:

	PR 21464
	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
	(or1k_final_link_relocate, or1k_elf_relocate_section,
	or1k_elf_check_relocs): Likewise.
	* libbfd.h (bfd_reloc_code_real_names): Likewise.
	* reloc.c: Likewise.

cpu/ChangeLog:

	PR 21464
	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
	for gotha() relocation.

include/ChangeLog:

	PR 21464
	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.

opcodes/ChangeLog:

	PR 21464
	* or1k-asm.c: Regenerate.

gas/ChangeLog:

	PR 21464
	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
	* testsuite/gas/or1k/reloc-1.d: Add test result for new
	relocation.

Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>

fixup reloc, add tests
2021-05-06 20:51:24 +09:00
Max Filippov
6aee2cb249 opcodes: xtensa: support branch visualization
2021-05-01  Max Filippov  <jcmvbkbc@gmail.com>
opcodes/
	* xtensa-dis.c (print_insn_xtensa): Fill in info->insn_type and
	info->insn_info_valid.
2021-05-01 02:47:30 -07:00
Jan Beulich
fe134c6569 x86: optimize LEA
Over the years I've seen a number of instances where people used

    lea     (%reg1), %reg2

or

    lea     symbol, %reg

despite the same thing being expressable via MOV. Since additionally
LEA often has restrictions towards the ports it can be issued to, while
MOV typically gets dealt with simply by register renaming, transform to
MOV when possible (without growing opcode size and without altering
involved relocation types).

Note that for Mach-O the new 64-bit testcases would fail (for
BFD_RELOC_X86_64_32S not having a representation), and hence get skipped
there.
2021-04-26 10:37:30 +02:00
Max Filippov
b3ea76397a opcodes: xtensa: display loaded literal value
Display literal value loaded with l32r opcode as a part of disassembly.
This significantly simplifies reading of disassembly output.

2020-04-23  Max Filippov  <jcmvbkbc@gmail.com>
opcodes/
	* xtensa-dis.c (print_xtensa_operand): For PC-relative operand
	of l32r fetch and display referenced literal value.
2021-04-23 03:29:39 -07:00
Max Filippov
c1cbb7d8a1 opcodes: xtensa: improve literal output
Output literals as 4-byte words, not as separate bytes.

2021-04-23  Max Filippov  <jcmvbkbc@gmail.com>
opcodes/
	* xtensa-dis.c (print_insn_xtensa): Set info->bytes_per_chunk
	to 4 for literal disassembly.
2021-04-23 03:28:38 -07:00
Przemyslaw Wirkus
02202574ec aarch64: New instructions for maintenance of GPT entries cached in a TLB
This patch adds support to four new system registers (RPAOS, RPALOS, PAALLOS,
PAALL) in conjunction with TLBI instruction. This change is part of RME (Realm
Management Extension).

gas/ChangeLog:

2021-04-19  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Update news.
	* testsuite/gas/aarch64/rme.d: Update test.
	* testsuite/gas/aarch64/rme.s: Update test.

opcodes/ChangeLog:

2021-04-19  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c: Add new registers (RPAOS, RPALOS, PAALLOS, PAALL) support for
	TLBI instruction.
2021-04-19 15:01:56 +01:00
Przemyslaw Wirkus
cd6608e49d aarch64: Add new data cache maintenance operations
This patch adds support to two new system registers (CIPAPA, CIGDPAPA) in
conjunction with DC instruction. This change is part of RME (Realm Management
Extension).

gas/ChangeLog:

2021-04-19  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* testsuite/gas/aarch64/rme.d: Update test.
	* testsuite/gas/aarch64/rme.s: Update test.

opcodes/ChangeLog:

2021-04-19  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c: Add new register (CIPAPA, CIGDPAPA) support for
	DC instruction.
2021-04-19 14:56:34 +01:00
Jan Beulich
fe1640ff8e arm64: add two initializers
Old enough gcc can't cope and would warn about the variables potentially
remaining uninitialized.
2021-04-19 15:41:35 +02:00
Przemyslaw Wirkus
100e914da3 aarch64: Define RME system registers
This patch introduces RME (Realm Management Extension) system registers.

gas/ChangeLog:

2021-03-01  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* testsuite/gas/aarch64/rme-invalid.d: New test.
	* testsuite/gas/aarch64/rme-invalid.l: New test.
	* testsuite/gas/aarch64/rme-invalid.s: New test.
	* testsuite/gas/aarch64/rme.d: New test.
	* testsuite/gas/aarch64/rme.s: New test.

opcodes/ChangeLog:

2021-03-01  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c: Add RME system registers.
2021-04-16 15:36:28 +01:00
Nelson Chu
a21b96dd66 Update the ChangeLog, and add the missing entries. 2021-04-16 16:48:27 +08:00
Lifang Xia
a8ab209320 RISC-V: compress "addi d,CV,z" to "c.mv d,CV"
PR 27732
gas/
	* testsuite/gas/riscv/c-zero-imm.d: Compress addi a4,a4,0 to
	c.mv a4,a4.
	* testsuite/gas/riscv/c-zero-imm.s: Likewise.
opcodes/
	* riscv-opc.c (riscv_opcodes): New insn alias for addi. Compress
	"addi d,CV,z" to "c.mv d,CV".
2021-04-16 11:25:15 +08:00
Alan Modra
43e05cd4f4 ENABLE_CHECKING in bfd, opcodes, binutils, ld
gas already has this.  Here it enables checking hash table type passed
to elf_link_hash_lookup and elf_link_hash_traverse.

bfd/
	* elf-bfd.h (ENABLE_CHECKING): Define.
	(elf_link_hash_lookup): Abort if wrong type of hash table.
	(elf_link_hash_traverse): Likewise.
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
binutils/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
ld/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
opcodes/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
2021-04-13 00:35:44 +09:30
Tejas Belagod
52efda8266 AArch64: Fix Atomic LD64/ST64 classification.
Patch 1: Fix diagnostics for exclusive load/stores and reclassify
	 Armv8.7-A ST/LD64 Atomics.

Following upstream pointing out some inconsistencies in diagnostics,

https://sourceware.org/pipermail/binutils/2021-February/115356.html

attached is a patch set that fixes the issues. I believe a combination
of two patches mainly contributed to these bugs:

https://sourceware.org/pipermail/binutils/2020-November/113961.html
https://sourceware.org/pipermail/binutils/2018-June/103322.html

A summary of what this patch set fixes:

For instructions

	STXR w0,x2,[x0]
	STLXR w0,x2,[x0]

The warning we emit currently is misleading:

Warning: unpredictable: identical transfer and status registers --`stlxr w0,x2,[x0]'
Warning: unpredictable: identical transfer and status registers --`stxr w0,x2,[x0]'

it ought to be:

Warning: unpredictable: identical base and status registers --`stlxr w0,x2,[x0]'
Warning: unpredictable: identical base and status registers --`stxr w0,x2,[x0]'

For instructions:

	ldaxp x0,x0,[x0]
	ldxp x0,x0,[x0]

The warning we emit is incorrect

Warning: unpredictable: identical transfer and status registers --`ldaxp x0,x0,[x0]'
Warning: unpredictable: identical transfer and status registers --`ldxp x0,x0,[x0]'

it ought to be:

Warning: unpredictable load of register pair -- `ldaxp x0,x0,[x0]'
Warning: unpredictable load of register pair -- `ldxp x0,x0,[x0]'

For instructions

	stlxp   w0, x2, x2, [x0]
	stxp    w0, x2, x2, [x0]

We don't emit any warning when it ought to be:

Warning: unpredictable: identical base and status registers --`stlxp w0,x2,x2,[x0]'
Warning: unpredictable: identical base and status registers --`stxp w0,x2,x2,[x0]'

For instructions:

	st64bv  x0, x2, [x0]
	st64bv  x2, x0, [x0]

We incorrectly warn when its not necessary. This is because we classify them
incorrectly as ldstexcl when it should be lse_atomics in the opcode table.
The incorrect classification makes it pick up the warnings from warning on
exclusive load/stores.

Patch 2: Reclassify Armv8.7-A ST/LD64 Atomics.

This patch reclassifies ST64B{V,V0}, LD64B as lse_atomics rather than ldstexcl
according to their encoding class as specified in the architecture. This also
has the fortunate side-effect of spurious unpredictable warnings getting
eliminated.

For eg. For instruction:

	st64bv  x0, x2, [x0]

We incorrectly warn when its not necessary:

Warning: unpredictable: identical transfer and status registers --`st64bv x0,x2,[x0]'

This is because we classify them incorrectly as ldstexcl when it should be
lse_atomics in the opcode table. The incorrect classification makes it pick
up the warnings from warning on exclusive load/stores. This patch fixes it
by reclassifying it and no warnings are issued for this instruction.

opcodes/ChangeLog:

2021-04-09  Tejas Belagod  <tejas.belagod@arm.com>

	* aarch64-tbl.h (struct aarch64_opcode aarch64_opcode_table): Reclassify
	LD64/ST64 instructions to lse_atomic instead of ldstexcl.
2021-04-09 12:27:54 +01:00
Alan Modra
c3f72de4f5 PowerPC disassembly of pcrel references
This adds some annotation to Power10 pcrel instructions, displaying
the target address (ie. pc + D34 field) plus a symbol if there is one
at exactly that target address.  pld from the .got or .plt will also
look up the entry and display it, symbolically if there is a dynamic
relocation on the entry.

include/
	* dis-asm.h (struct disassemble_info): Add dynrelbuf and dynrelcount.
binutils/
	* objdump.c (struct objdump_disasm_info): Delete dynrelbuf and
	dynrelcount.
	(find_symbol_for_address): Adjust for dynrelbuf and dynrelcount move.
	(disassemble_section, disassemble_data): Likewise.
opcodes/
	* ppc-dis.c (struct dis_private): Add "special".
	(POWERPC_DIALECT): Delete.  Replace uses with..
	(private_data): ..this.  New inline function.
	(disassemble_init_powerpc): Init "special" names.
	(skip_optional_operands): Add is_pcrel arg, set when detecting R
	field of prefix instructions.
	(bsearch_reloc, print_got_plt): New functions.
	(print_insn_powerpc): For pcrel instructions, print target address
	and symbol if known, and decode plt and got loads too.
gas/
	* testsuite/gas/ppc/prefix-pcrel.d: Update expected output.
	* testsuite/gas/ppc/prefix-reloc.d: Likewise.
	* gas/testsuite/gas/ppc/vsx_32byte.d: Likewise.
ld/
	* testsuite/ld-powerpc/inlinepcrel-1.d: Update expected output.
	* testsuite/ld-powerpc/inlinepcrel-2.d: Likewise.
	* testsuite/ld-powerpc/notoc2.d: Likewise.
	* testsuite/ld-powerpc/notoc3.d: Likewise.
	* testsuite/ld-powerpc/pcrelopt.d: Likewise.
	* testsuite/ld-powerpc/startstop.d: Likewise.
	* testsuite/ld-powerpc/tlsget.d: Likewise.
	* testsuite/ld-powerpc/tlsget2.d: Likewise.
	* testsuite/ld-powerpc/tlsld.d: Likewise.
	* testsuite/ld-powerpc/weak1.d: Likewise.
	* testsuite/ld-powerpc/weak1so.d: Likewise.
2021-04-09 16:56:43 +09:30
Alan Modra
ce7d813a0f PR27684, PowerPC missing mfsprg0 and others
PR 27684
	* ppc-opc.c (powerpc_opcodes): Correct usprg typos, add mfpir.
2021-04-08 08:28:27 +09:30
Alan Modra
97bf40d859 PR27676, PowerPC missing extended dcbt, dcbtst mnemonics
Note that this doesn't implement the ISA to the letter regarding
dcbtds (and dcbtstds), which says that the TH field may be zero.  That
doesn't make sense because allowing TH=0 would mean you no long have a
dcbtds but rather a dcbtct instruction.  I'm interpreting the ISA
wording about allowing TH=0 to mean that the TH field of dcbtds is
optional (in which case the TH value is 0b1000).

opcodes/
	PR 27676
	* ppc-opc.c (DCBT_EO): Move earlier.
	(insert_thct, extract_thct, insert_thds, extract_thds): New functions.
	(powerpc_operands): Add THCT and THDS entries.
	(powerpc_opcodes): Add dcbtstct, dcbtstds, dcbna, dcbtct, dcbtds.
gas/
	* testsuite/gas/ppc/pr27676.d,
	* testsuite/gas/ppc/pr27676.s: New test.
	* testsuite/gas/ppc/ppc.exp: Run it.
	* testsuite/gas/ppc/dcbt.d: Update.
	* testsuite/gas/ppc/power4_32.d: Update.
2021-04-08 08:28:11 +09:30
Alan Modra
a2e6677373 Return symbol from symbol_at_address_func
include/
	* dis-asm.h (struct disassemble_info <symbol_at_address_func>):
	Return asymbol*.
binutils/
	* objdump.c (objdump_symbol_at_address): Return asymbol*.
opcodes/
	* dis-buf.c (generic_symbol_at_address): Return symbol* NULL.
	* s12z-dis.c (decode_possible_symbol): Use symbol returned from
	symbol_at_address_func.
2021-04-06 23:25:09 +09:30
Alan Modra
ab2af25e83 C99 opcodes configury
* configure.ac: Don't check for limits.h, string.h, strings.h or
	stdlib.h.
	(AC_ISC_POSIX): Don't invoke.
	* sysdep.h: Include stdlib.h and string.h unconditionally.
	* i386-opc.h: Include limits.h unconditionally.
	* wasm32-dis.c: Likewise.
	* cgen-opc.c: Don't include alloca-conf.h.
	* config.in: Regenerate.
	* configure: Regenerate.
2021-04-05 15:28:04 +09:30
Martin Liska
e9b095a538 Remove strneq macro and use startswith.
bfd/ChangeLog:

	* ecoff.c (strneq): Remove strneq and use startswith.
	(_bfd_ecoff_slurp_armap): Likewise.

binutils/ChangeLog:

	* elfcomm.h (strneq): Remove strneq and use startswith.
	* readelf.c (ia64_process_unwind): Likewise.
	(process_note): Likewise.

gas/ChangeLog:

	* config/obj-coff.c (strneq): Remove strneq and use startswith.
	(weak_is_altname): Likewise.
	(obj_coff_section): Likewise.
	* config/tc-cr16.c (process_label_constant): Likewise.
	* config/tc-crx.c (strneq): Likewise.

include/ChangeLog:

	* opcode/cr16.h (strneq): Remove strneq and use startswith.

ld/ChangeLog:

	* ldbuildid.c (strneq): Remove strneq and use startswith.
	(validate_build_id_style): Likewise.
	(compute_build_id_size): Likewise.

opcodes/ChangeLog:

	* arm-dis.c (strneq): Remove strneq and use startswith.
	* cr16-dis.c (print_insn_cr16): Likewise.
	* score-dis.c (streq): Likewise.
	(strneq): Likewise.
	* score7-dis.c (strneq): Likewise.
2021-04-01 15:00:56 +02:00
Alan Modra
1cb108e416 PR27675, PowerPC missing extended mnemonic mfummcr2
PR 27675
	* ppc-opc.c (powerpc_opcodes): Add mfummcr2 and mfmmcr2.
2021-04-01 09:17:04 +10:30
Alan Modra
78933a4ad9 Use bool in opcodes
cpu/
	* frv.opc: Replace bfd_boolean with bool, FALSE with false, and
	TRUE with true throughout.
opcodes/
	* sysdep.h (POISON_BFD_BOOLEAN): Define.
	* aarch64-asm-2.c, * aarch64-asm.c, * aarch64-asm.h,
	* aarch64-dis-2.c, * aarch64-dis.c, * aarch64-dis.h,
	* aarch64-gen.c, * aarch64-opc.c, * aarch64-opc.h, * arc-dis.c,
	* arc-dis.h, * arc-fxi.h, * arc-opc.c, * arm-dis.c, * bfin-dis.c,
	* cris-dis.c, * csky-dis.c, * csky-opc.h, * dis-buf.c,
	* disassemble.c, * frv-opc.c, * frv-opc.h, * h8300-dis.c,
	* i386-dis.c, * m68k-dis.c, * metag-dis.c, * microblaze-dis.c,
	* microblaze-dis.h, * micromips-opc.c, * mips-dis.c,
	* mips-formats.h, * mips-opc.c, * mips16-opc.c, * mmix-dis.c,
	* msp430-dis.c, * nds32-dis.c, * nfp-dis.c, * nios2-dis.c,
	* ppc-dis.c, * riscv-dis.c, * score-dis.c, * score7-dis.c,
	* tic6x-dis.c, * v850-dis.c, * vax-dis.c, * wasm32-dis.c,
	* xtensa-dis.c: Replace bfd_boolean with bool, FALSE with false,
	and TRUE with true throughout.
2021-03-31 10:49:23 +10:30
Alan Modra
3dfb1b6d34 Remove bfd_stdint.h
If we require C99 for binutils then stdint.h is available.

bfd/
	* .gitignore: Delete bfd_stdint.h entry.
	* Makefile.am (bfdinclude_HEADERS): Delete bfd_stdint.h.
	(BUILD_HFILES, LOCAL_H_DEPS): Likewise.
	* bfd-in.h: Include stdint.h in place of bfd_stdint.h.
	* configure.ac: Don't invoke GCC_HEADER_STDINT.
	* configure.com: Don't create bfd_stdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* bfd-in2.h: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
binutils/
	* coffdump.c: Include stdint.h in place of bfd_stdint.h.
	* dwarf.c: Likewise.
gas/
	* config/tc-aarch64.c: Include stdint.h in place of bfd_stdint.h.
	* config/tc-crx.c: Likewise.
	* config/tc-nds32.h: Likewise.
include/
	* cgen/basic-modes.h: Include stdint.h in place of bfd_stdint.h.
	* elf/nfp.h: Likewise.
	* opcode/aarch64.h: Likewise.
	* opcode/cgen.h: Likewise.
	* opcode/nfp.h: Likewise.
	* opcode/ppc.h: Likewise.
ld/
	* elf-hints-local.h: Include stdint.h in place of bfd_stdint.h.
	* emultempl/nds32elf.em: Likewise.
	* testsuite/ld-elf/mbind2b.c: Likewise.
	* testsuite/ld-elf/pr18718.c: Likewise.
	* testsuite/ld-elf/pr18720a.c: Likewise.
	* testsuite/ld-elf/pr25749-1.c: Likewise.
	* testsuite/ld-elf/pr25749-1a.c: Likewise.
	* testsuite/ld-elf/pr25749-1b.c: Likewise.
	* testsuite/ld-elf/pr25749-1c.c: Likewise.
	* testsuite/ld-elf/pr25749-1d.c: Likewise.
	* testsuite/ld-elf/pr25749-2.c: Likewise.
	* testsuite/ld-elf/pr25754-1a.c: Likewise.
	* testsuite/ld-elf/pr25754-2a.c: Likewise.
	* testsuite/ld-elf/pr25754-3a.c: Likewise.
	* testsuite/ld-elf/pr25754-4a.c: Likewise.
	* testsuite/ld-elf/pr25754-5a.c: Likewise.
	* testsuite/ld-elf/pr25754-6a.c: Likewise.
opcodes/
	* aarch64-dis.c: Include stdint.h in place of bfd_stdint.h.
	* aarch64-dis.h: Likewise.
	* aarch64-opc.c: Likewise.
	* avr-dis.c: Likewise.
	* csky-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* nds32-dis.c: Likewise.
	* nfp-dis.c: Likewise.
	* riscv-dis.c: Likewise.
	* s12z-dis.c: Likewise.
	* wasm32-dis.c: Likewise.
2021-03-31 10:49:23 +10:30
Jan Beulich
5e0423804a x86: drop seg_entry
Use struct reg_entry instead for most purposes, with a separate array
holding just the respective opcode prefix bytes.
2021-03-30 14:09:41 +02:00
Jan Beulich
3468486226 x86: drop REGNAM_{AL,AX,EAX}
The former two are unused anyway. And having such constants isn't very
helpful either, when they live in a place where updating the register
table wouldn't even allow noticing the need to adjust these constants.
2021-03-30 14:08:48 +02:00
Jan Beulich
6288d05f11 x86: adjust st(<N>) parsing
st(1) ... st(7) will never be looked up in the hash table, so there's no
point inserting the entries. It's also not really necessary to do a 2nd
hash lookup after parsing the register number, nor is there a real
reason for having both st and st(0) entries. Plus we can easily do away
with the need for st to be first in the table.
2021-03-30 14:08:11 +02:00
Jan Beulich
bbe1eca622 x86: move some opcode table entries
For a long time there hasn't been a need anymore to keep together all
templates with identical mnemonics. Move the MOVQ and MOVABS ones next
to their MOV counterparts. Move the string forms of CMPSD and MOVSD next
to their CMPS / MOVS counterparts. Re-arrange what so fgar was the SSE3
section.

This makes reasonably obvious that MONITOR/MWAIT aren't suitable to
cover by CpuSSE3, but adjusting this is left for another time.
2021-03-29 12:06:43 +02:00
Jan Beulich
c8cad9d389 x86: VPSADBW's source operands are also commutative
In commit 79dec6b7ba ("x86-64: optimize certain commutative
VEX-encoded insns") I missed the fact that there being subtraction
involved here doesn't matter, as absolute differences get summed up.
2021-03-29 12:06:09 +02:00
Jan Beulich
5cdaf10025 x86: fold SSE2AVX and their base MMX/SSE templates
This way not only the overall (source) table size shrinks by quite a
bit and the risk of related templates going out of sync with one another
gets lowered, but also (dis)similarities between neighboring templates
become easier to spot.

Note that for certain SSE2AVX templates this results in benign attribute
changes:
- LDMXCSR and STMXCSR: NoAVX gets set,
- MOVMSKPS, PMOVMSKB, PEXTR{B,W} (register destination), and PINSR{B,W}
  (register source): IgnoreSize and NoRex64 get set,
- CVT{DQ,PS}2PD, CVTSD2SS, MOVMSKPD, MOVDDUP, PMOV{S,Z}X{BW,WD,DQ}, and
  ROUNDSD: NoRex64 gets set,
- CVTSS2SD, INSERTPS, PEXTRW (memory destination), PINSRW (memory
  source), and PMOV{S,Z}X{BD,WQ,BQ}: IgnoreSize gets set.
Similarly the "normal" (non-SSE2AVX)
- non-64-bit CVTS{I,S}2SD forms get NoRex64 set,
- CMP{EQ,ORD,NEQ,UNORD}{P,S}{S,D} forms get C set,
all again in a benign way.

The remaining differences in the generated table are due to re-ordering
of entries in the course of being folded into templates.
2021-03-29 12:05:25 +02:00
Jan Beulich
73e45eb208 x86: undo Prefix_0X<nn> use in opcode table
The table entries are more natural to read (and slightly shorter) when
the prefixes, like is the case for VEX/XOP/EVEX-encoded entries, are
specified as part of the opcode. This is particularly noticable for
side-by-side legacy and SSE2AVX entries.

An implication is that we now need to use "unsigned long long" for the
initially parsed opcode in i386-gen. I don't expect this to be an issue.
2021-03-29 12:04:03 +02:00
Jan Beulich
9df6f676c2 x86: shrink some struct insn_template fields
Now that all base opcodes are only at most 2 bytes in size, shrink its
template field to just as much. By also shrinking extension_opcode and
operands to just what they really need, we can free up an entire 32-bit
slot (plus 4 left bits past the bitfields themselves).

At present this alters sizeof(struct insn_template) only for 32-bit
builds. In 64-bit builds it instead leaves a padding hole that will
allow to buffer future growth of other fields (opcode_modifier,
cpu_flags, operand_types[]).
2021-03-29 12:03:31 +02:00
Jan Beulich
389d00a5e5 x86: derive opcode encoding space attribute from base opcode
Just like is already done for VEX/XOP/EVEX encoded insns, record the
encoding space information in the respective opcode modifier field. Do
this again without changing the source table, but rather by deriving the
values from their existing source representation.
2021-03-29 12:02:50 +02:00
Alan Modra
63b4cc53dc TRUE/FALSE simplification
There is really no need to write code like "foo != 0 ? TRUE : FALSE"
unless we had stupidly defined FALSE as something other than 0 or TRUE
as something other than 1.  The simpler "foo != 0" does just as well.
Similarly "(condition == TRUE)" or "(condition == FALSE) can be
simplified to "(condition)" and "(!condition)" respectively.

I'll note that there is reason to use "integer_expression != 0" when
assigning a bfd_boolean rather than the simpler "integer_expression",
if you expect the variable to have 0 or 1 value.  It's probably even a
good idea to not rely on implicit conversion if bfd_boolean were _Bool.

bfd/
	* aoutx.h (aout_link_write_symbols): Don't cast boolean expression
	to bfd_boolean.
	* elf32-or1k.c (or1k_set_got_and_rela_sizes): Dont compare booleans
	against FALSE.
	* elf32-arc.c (name_for_global_symbol): Don't compare boolean to TRUE.
	(is_reloc_PC_relative): Don't use "boolean_condition ? TRUE : FALSE".
	(is_reloc_SDA_relative, is_reloc_for_GOT): Likewise.
	(is_reloc_for_PLT, is_reloc_for_TLS): Likewise.
	* elf32-arm.c (stm32l4xx_need_create_replacing_stub): Likewise.
	* elf32-nds32.c (insert_nds32_elf_blank): Likewise.
	* elf32-rx.c (rx_set_section_contents): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): Likewise.
	* mach-o.c (bfd_mach_o_read_command): Likewise.
	* targets.c (bfd_get_target_info): Likewise.
binutils/
	* dlltool.c (main): Don't use "boolean_condition ? TRUE : FALSE".
	* dwarf.c (read_and_display_attr_value): Likewise.
	(display_debug_str_offsets): Likewise.
	* objdump.c (dump_bfd): Likewise.
	* readelf.c (dump_section_as_strings): Likewise.
	(dump_section_as_bytes): Likewise.
gas/
	* atof-generic.c (FALSE, TRUE): Don't define.
	* config/obj-elf.h (FALSE, TRUE): Don't define.
	* config/obj-som.h (FALSE, TRUE): Don't define.
	* config/tc-hppa.h (FALSE, TRUE): Don't define.
	* config/tc-pdp11.c (FALSE, TRUE): Don't define.
	* config/tc-iq2000.h (obj_fix_adjustable): Delete.
	* config/tc-m32r.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-mt.h (obj_fix_adjustable): Delete.
	* config/tc-nds32.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-arc.c (parse_opcode_flags): Simplify boolean expression.
	(relaxable_flag, relaxable_operand, assemble_insn): Likewise.
	(tokenize_extregister): Likewise.
	* config/tc-csky.c (parse_opcode, get_operand_value): Likewise.
	(parse_operands_op, parse_operands, md_assemble): Likewise.
	* config/tc-d10v.c (build_insn): Likewise.
	* config/tc-score.c (s3_gen_insn_frag): Likewise.
	* config/tc-score7.c (s7_gen_insn_frag, s7_relax_frag): Likewise.
	* config/tc-tic6x.c (tic6x_update_features, md_assemble): Likewise.
	* config/tc-z80.c (emit_byte): Likewise.
include/
	* opcode/aarch64.h (alias_opcode_p): Simplify boolean expression.
	(opcode_has_alias, pseudo_opcode_p, optional_operand_p): Likewise.
	(opcode_has_special_coder): Likewise.
ld/
	* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Simplify
	boolean expression.
	* lexsup.c (parse_args): Likewise.
	* pe-dll.c (pe_dll_id_target): Likewise.
opcodes/
	* aarch64-opc.c (vector_qualifier_p): Simplify boolean expression.
	(fp_qualifier_p, get_data_pattern): Likewise.
	(aarch64_get_operand_modifier_from_value): Likewise.
	(aarch64_extend_operator_p, aarch64_shift_operator_p): Likewise.
	(operand_variant_qualifier_p): Likewise.
	(qualifier_value_in_range_constraint_p): Likewise.
	(aarch64_get_qualifier_esize): Likewise.
	(aarch64_get_qualifier_nelem): Likewise.
	(aarch64_get_qualifier_standard_value): Likewise.
	(get_lower_bound, get_upper_bound): Likewise.
	(aarch64_find_best_match, match_operands_qualifier): Likewise.
	(aarch64_print_operand): Likewise.
	* aarch64-opc.h (operand_has_inserter, operand_has_extractor): Likewise.
	(operand_need_sign_extension, operand_need_shift_by_two): Likewise.
	(operand_need_shift_by_four, operand_maybe_stack_pointer): Likewise.
	* arm-dis.c (print_insn_mve, print_insn_thumb32): Likewise.
	* tic6x-dis.c (tic6x_check_fetch_packet_header): Likewise.
	(print_insn_tic6x): Likewise.
2021-03-29 11:22:22 +10:30
Alan Modra
3d7d6c1b50 opcodes int vs bfd_boolean fixes
cpu/
	* frv.opc (frv_is_branch_major, frv_is_float_major),
	(frv_is_media_major, frv_is_branch_insn, frv_is_float_insn),
	(frv_is_media_insn, spr_valid): Correct prototypes.
include/
	* opcode/aarch64.h (aarch64_opcode_encode): Correct prototype.
opcodes/
	* arc-dis.c (extract_operand_value): Correct NULL cast.
	* frv-opc.h: Regenerate.
2021-03-29 11:22:21 +10:30
Jan Beulich
c3344b626d x86-64: don't accept supposedly disabled MOVQ forms
While all of MMX, SSE, and SSE2 are included in "generic64", they can be
individually disabled. There are two MOVQ forms lacking respective
attributes. While the MMX one would get refused anyway (due to MMX
registers not recognized with .nommx), the assembler did happily accept
the SSE2 form. Add respective CPU settings to both, paralleling what the
MOVD counterparts have.
2021-03-26 11:43:19 +01:00
Hafiz Abid Qadeer
efa30ac3c5 [NIOS2] Fix disassembly of br.n instruction.
The code was checking wrong bit for sign extension. It caused it
to zero-extend instead of sign-extend the immediate value.

2021-03-25  Abid Qadeer  <abidh@codesourcery.com>

	opcodes/
	* nios2-dis.c (nios2_print_insn_arg): Fix sign extension of
	immediate in br.n instruction.

	gas/
	* testsuite/gas/nios2/brn.s: New.
	* testsuite/gas/nios2/brn.d: New.
2021-03-25 10:52:14 +00:00
Jan Beulich
596a02ff55 x86: flag bad S/G insn operand combinations
For VEX-encoded ones, all three involved vector registers have to be
distinct. For EVEX-encoded ones an actual mask register has to be in use
and zeroing-masking cannot be used (violation of either will #UD).
Additionally both involved vector registers have to be distinct for
EVEX-encoded gathers.
2021-03-25 08:20:19 +01:00
Jan Beulich
5364285240 x86: flag as bad AVX512 insns with EVEX.z set but EVEX.aaa clear
This combination makes no sense and is documented to cause #UD.
2021-03-25 08:19:21 +01:00
Jan Beulich
c0e54661f7 x86: fix AMD Zen3 insns
For INVLPGB the operand count was wrong (besides %edx there's also %ecx
which is an input to the insn). In this case I see little sense in
retaining the bogus 2-operand template. Plus swapping of the operands
wasn't properly suppressed for Intel syntax.

For PVALIDATE, RMPADJUST, and RMPUPDATE bogus single operand templates
were specified. These get retained, as the address operand is the only
one really needed to expressed non-default address size, but only for
compatibility reasons. Proper multi-operand insn get introduced and the
testcases get adjusted / extended accordingly.

While at it also drop the redundant definition of __amd64__ - we already
have x86_64 defined (or not) to distinguish 64-bit and non-64-bit cases.
2021-03-25 08:18:41 +01:00
Alan Modra
5a4037661b PR27647 PowerPC extended conditional branch mnemonics
opcodes/
	PR 27647
	* ppc-opc.c (XLOCB_MASK): Delete.
	(XLBOBB_MASK, XLBOBIBB_MASK, XLBOCBBB_MASK): Define using
	XLBH_MASK.
	(powerpc_opcodes): Accept a BH field on all extended forms of
	bclr, bclrl, bcctr, bcctrl, bctar, bctarl.
gas/
	PR 27647
	* testsuite/gas/ppc/a2.d: Update expected output.
	* testsuite/gas/ppc/power8.d: Likewise.
2021-03-25 11:31:53 +10:30
Jan Beulich
9a182d0461 x86: derive opcode length from opcode value
In the majority of cases we can easily determine the length from the
encoding, irrespective of whether a prefix is specified there as well.
We further don't even need to record the value in the table entries, as
it's easy enough to determine it (without any guesswork, unless an insn
with major opcode 00 appeared that requires a 2nd opcode byte to be
specified explicitly) when installing the chosen template for further
processing.

Should an encoding appear which
- has a major opcode byte of 66, F3, or F2,
- requires a 2nd opcode byte to be specified explicitly,
- doesn't have a mandatory prefix
we'd need to convert all templates presently encoding a mandatory prefix
this way to the Prefix_0X<nn> model to eliminate the respective guessing
i386-gen does.
2021-03-24 08:33:33 +01:00
Jan Beulich
3564871692 x86: derive mandatory prefix attribute from base opcode
Just like is already done for legacy encoded insns, record the mandatory
prefix information in the respective opcode modifier field. Do this
without changing the source table, but rather by deriving the values from
their existing source representation.
2021-03-24 08:32:32 +01:00
Jan Beulich
311845694b x86: don't use opcode_length to identify pseudo prefixes
This is in preparation of opcode_length going away as a field in the
templates. Identify pseudo prefixes by a base opcode of zero instead:
No real prefix has an opcode of zero. This at the same time allows
dropping a curious special case from i386-gen.

Since most attributes are identical for all pseudo prefixes, take the
opportunity and also template them.
2021-03-24 08:31:41 +01:00
Jan Beulich
b933fa4b5d x86: re-number PREFIX_0X<nn>
In preparation to use PREFIX_0X<nn> attributes also in VEX/XOP/EVEX
encoding templates, renumber the pseudo-enumerators such that their
values can then also be used directly in the respective prefix bit
fields.
2021-03-23 17:09:53 +01:00
Jan Beulich
dac10fb0d1 x86: re-order two fields of struct insn_template
To facilitate a subsequent table parser change, re-order CPU flags and
opcode modifier fields. No functional change intended.
2021-03-23 17:09:11 +01:00
Jan Beulich
441f6aca39 x86: split opcode prefix and opcode space representation
Commit 8b65b8953a ("x86: Remove the prefix byte from non-VEX/EVEX
base_opcode") used the opcodeprefix field for two distinct purposes. In
preparation of having VEX/XOP/EVEX and non-VEX templates become similar
in the representatioon of both encoding space and opcode prefixes, split
the field to have a separate one holding an insn's opcode space.
2021-03-23 17:08:39 +01:00
Martin Liska
08dedd6631 Add startswith function and use it instead of CONST_STRNEQ.
bfd/ChangeLog:

	* bfd-in.h (startswith): Add startswith function.
	(CONST_STRNEQ): Remove.
	* bfd-in2.h (startswith): Regenerate with make headers.
	* archive.c (bfd_slurp_armap): Replace usage of CONST_STRNEQ with startswith.
	(_bfd_slurp_extended_name_table): Likewise.
	* archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise.
	* bfd.c (bfd_get_sign_extend_vma): Likewise.
	(bfd_convert_section_size): Likewise.
	(bfd_convert_section_contents): Likewise.
	* coff-stgo32.c (go32exe_create_stub): Likewise.
	(go32exe_check_format): Likewise.
	* coffcode.h (styp_to_sec_flags): Likewise.
	(GNU_DEBUGALTLINK): Likewise.
	* coffgen.c (_bfd_coff_section_already_linked): Likewise.
	(coff_gc_sweep): Likewise.
	(bfd_coff_gc_sections): Likewise.
	* cofflink.c (coff_link_add_symbols): Likewise.
	(process_embedded_commands): Likewise.
	* compress.c (bfd_is_section_compressed_with_header): Likewise.
	(bfd_init_section_decompress_status): Likewise.
	* dwarf2.c (find_debug_info): Likewise.
	(place_sections): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_armap): Likewise.
	* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
	(assign_section_numbers): Likewise.
	(elfcore_grok_win32pstatus): Likewise.
	* elf32-arm.c (cmse_scan): Likewise.
	(elf32_arm_gc_mark_extra_sections): Likewise.
	(elf32_arm_size_dynamic_sections): Likewise.
	(is_arm_elf_unwind_section_name): Likewise.
	* elf32-bfin.c (bfin_size_dynamic_sections): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
	* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
	* elf32-csky.c (csky_elf_size_dynamic_sections): Likewise.
	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
	* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
	* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
	* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
	* elf32-msp430.c (msp430_elf_relax_delete_bytes): Likewise.
	* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
	* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
	* elf32-tic6x.c (is_tic6x_elf_unwind_section_name): Likewise.
	(elf32_tic6x_size_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
	* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
	(xtensa_is_insntable_section): Likewise.
	(xtensa_is_littable_section): Likewise.
	(xtensa_is_proptable_section): Likewise.
	(xtensa_property_section_name): Likewise.
	(xtensa_callback_required_dependence): Likewise.
	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
	* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
	* elf64-ia64-vms.c (is_unwind_section_name): Likewise.
	(get_reloc_section): Likewise.
	(elf64_ia64_size_dynamic_sections): Likewise.
	(elf64_ia64_object_p): Likewise.
	* elf64-mmix.c (mmix_elf_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	(_bfd_elf_gc_mark_extra_sections): Likewise.
	(bfd_elf_parse_eh_frame_entries): Likewise.
	(_bfd_elf_section_already_linked): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
	* elfnn-ia64.c (is_unwind_section_name): Likewise.
	(elfNN_ia64_size_dynamic_sections): Likewise.
	(elfNN_ia64_object_p): Likewise.
	* elfxx-mips.c (FN_STUB_P): Likewise.
	(CALL_STUB_P): Likewise.
	(CALL_FP_STUB_P): Likewise.
	(_bfd_mips_elf_section_from_shdr): Likewise.
	(_bfd_mips_elf_fake_sections): Likewise.
	(_bfd_mips_elf_size_dynamic_sections): Likewise.
	(_bfd_mips_final_write_processing): Likewise.
	(_bfd_mips_elf_final_link): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
	* elfxx-x86.c (elf_i386_is_reloc_section): Likewise.
	(elf_x86_64_is_reloc_section): Likewise.
	* hpux-core.c (thread_section_p): Likewise.
	* libcoff.h (bfd_pei_p): Likewise.
	* linker.c (REAL): Likewise.
	(unwrap_hash_lookup): Likewise.
	(_bfd_generic_link_add_one_symbol): Likewise.
	* mmo.c (mmo_internal_write_section): Likewise.
	* osf-core.c (osf_core_core_file_p): Likewise.
	* pef.c (bfd_pef_print_symbol): Likewise.
	* pei-x86_64.c (pex64_print_all_pdata_sections): Likewise.
	* som.c (som_slurp_symbol_table): Likewise.
	(som_slurp_armap): Likewise.
	* wasm-module.c (wasm_compute_custom_section_file_position): Likewise.

binutils/ChangeLog:

	* dlltool.c (scan_drectve_symbols): Replace usage of CONST_STRNEQ with startswith.
	* emul_aix.c (ar_emul_aix_parse_arg): Likewise.
	* objcopy.c (is_mergeable_note_section): Likewise.
	* objdump.c (dump_dwarf_section): Likewise.
	* prdbg.c (pr_method_type): Likewise.
	(pr_class_baseclass): Likewise.
	(tg_class_baseclass): Likewise.
	* readelf.c (process_lto_symbol_tables): Likewise.
	* stabs.c (ULLHIGH): Likewise.
	(parse_stab_argtypes): Likewise.
	(stab_demangle_function_name): Likewise.

gas/ChangeLog:

	* config/tc-i386.c (md_parse_option): Replace usage of CONST_STRNEQ with startswith.
	(x86_64_section_word): Likewise.
	* config/tc-sparc.c (md_parse_option): Likewise.

gdb/ChangeLog:

	* arm-tdep.c (show_disassembly_style_sfunc): Replace usage of CONST_STRNEQ with startswith.
	(_initialize_arm_tdep): Likewise.

ld/ChangeLog:

	* emultempl/aix.em: Replace usage of CONST_STRNEQ with startswith.
	* emultempl/beos.em: Likewise.
	* emultempl/elf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/xtensaelf.em: Likewise.
	* ldctor.c (ctor_prio): Likewise.
	* ldelf.c (ldelf_try_needed): Likewise.
	(ldelf_parse_ld_so_conf): Likewise.
	(ldelf_after_open): Likewise.
	(output_rel_find): Likewise.
	(ldelf_place_orphan): Likewise.
	* ldfile.c (ldfile_add_library_path): Likewise.
	* ldlang.c (lang_add_input_file): Likewise.
	* ldmain.c (get_sysroot): Likewise.
	(get_emulation): Likewise.
	(add_archive_element): Likewise.
	* ldwrite.c (unsplittable_name): Likewise.
	(clone_section): Likewise.
	* lexsup.c (parse_args): Likewise.
	* pe-dll.c (is_import): Likewise.
	(pe_implied_import_dll): Likewise.

opcodes/ChangeLog:

	* aarch64-dis.c (parse_aarch64_dis_option): Replace usage of CONST_STRNEQ with startswith.
	* arc-dis.c (parse_option): Likewise.
	* arm-dis.c (parse_arm_disassembler_options): Likewise.
	* cris-dis.c (print_with_operands): Likewise.
	* h8300-dis.c (bfd_h8_disassemble): Likewise.
	* i386-dis.c (print_insn): Likewise.
	* ia64-gen.c (fetch_insn_class): Likewise.
	(parse_resource_users): Likewise.
	(in_iclass): Likewise.
	(lookup_specifier): Likewise.
	(insert_opcode_dependencies): Likewise.
	* mips-dis.c (parse_mips_ase_option): Likewise.
	(parse_mips_dis_option): Likewise.
	* s390-dis.c (disassemble_init_s390): Likewise.
	* wasm32-dis.c (parse_wasm32_disassembler_options): Likewise.
2021-03-22 11:01:43 +01:00
Kuan-Lin Chen
80d49d6a1b RISC-V : Support bitmanip-0.93 ZBA/ZBB/ZBC instructions
bfd/
	* elfxx-riscv.c (riscv_std_z_ext_strtab): Add zba, zbb and zbc.

gas/
	* config/tc-riscv.c (ext_version_table): Add b, zba, zbb and zbc.
	(riscv_multi_subset_supports): Add INSN_CLASS_ZB*.
	* testsuite/gas/riscv/b-ext-64.s: Bitmanip test case.
	* testsuite/gas/riscv/b-ext-64.d: Likewise.
	* testsuite/gas/riscv/b-ext.s: Likewise.
	* testsuite/gas/riscv/b-ext.d: Likewise.

include/
	* opcode/riscv-opc.h: Support zba, zbb and zbc extensions.
	* opcode/riscv.h (riscv_insn_class): Add INSN_CLASS_ZB*.

opcodes/
	* riscv-opc.c (riscv_opcodes): Add zba, zbb and zbc instructions.
2021-03-16 14:38:19 +08:00
Przemyslaw Wirkus
7fce7ea986 aarch64: Add few missing system registers
This patch adds few missing system registers to GAS: LORC_EL1,
LOREA_EL1, LORN_EL1, LORSA_EL1, ICC_CTLR_EL3, ICC_SRE_ELX, ICH_VTR_EL2.

gas/ChangeLog:

2021-03-02  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* testsuite/gas/aarch64/illegal-sysreg-7.d: New test.
	* testsuite/gas/aarch64/illegal-sysreg-7.l: New test.
	* testsuite/gas/aarch64/illegal-sysreg-7.s: New test.
	* testsuite/gas/aarch64/sysreg-7.d: New test.
	* testsuite/gas/aarch64/sysreg-7.s: New test.

opcodes/ChangeLog:

2021-03-02  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c: Add lorc_el1, lorea_el1, lorn_el1, lorsa_el1,
	icc_ctlr_el3, icc_sre_elx, ich_vtr_el2 system registers.
2021-03-12 14:20:46 +00:00
Alan Modra
78c84bf926 Re: x86: correct decoding of nop/reserved space (0f18 ... 0x1f)
* i386-dis.c (print_insn <PREFIX_IGNORED>): Correct typo.
2021-03-12 10:41:34 +10:30
Jan Beulich
fd1fd06186 x86: re-order logic in OP_XMM()
Instead of excluding an increasing number of modes in the initial if(),
check the special modes first.
2021-03-11 16:21:48 +01:00
Jan Beulich
ac7a231133 x86: drop a few redundant EVEX-related checks
vex.b can only be set when vex.evex is also set. Similarly vex.evex can
only be set when need_vex is also set.
2021-03-11 16:21:19 +01:00
Jan Beulich
da944c8a70 x86: remove stray uses of xmmq_mode
xmmq_mode is documented to not allow for broadcast - don't include it in
respective checks in OP_E_memory().
2021-03-11 16:20:37 +01:00
Jan Beulich
b763d508db x86/Intel: correct AVX512 S/G disassembly
Commit 6ff00b5e12 ("x86/Intel: correct permitted operand sizes for
AVX512 scatter/gather") brought the assembler side of AVX512 S/G insn
handling in line with AVX2's, but the disassembler side was forgotten.
This has the benefit of
- allowing to fold a number of table entries,
- rendering a few #define-s and enumerators unused.
2021-03-10 08:20:29 +01:00
Jan Beulich
32e31ad7da x86: re-arrange enumerator and table entry order
Some of the enumerators have ended up misplaced under the general
current ordering scheme. Move them (and their table entries) around
accordingly. Add a couple of blank lines as separators when close to
code being touched anyway. Also drop the odd 0F from 0FXOP (there's no
"0f" involved there anywhere) infixes where the respective enum gets
played with anyway.
2021-03-10 08:19:43 +01:00
Jan Beulich
85ba7507f6 x86: reuse further VEX entries for EVEX
When the VEX.L=1 decode matches that of both EVEX.L'L=1 and EVEX.L'L=2
(typically when all three are invalid) the (smaller) VEX table entry can
be reused by EVEX, instead of duplicating data. (Note that XM and XMM as
well as EXxmm_md and EXd are equivalent at least for the purposes here.)
2021-03-10 08:19:11 +01:00
Jan Beulich
066f82b96a x86: reuse VEX entries for EVEX vperm{q,pd}
By matching VEX decode order (L before W), some EVEX entries can refer
back to VEX ones instead of carrying duplicates.
2021-03-10 08:18:24 +01:00
Jan Beulich
fc681dd6a1 x86: re-arrange order of decode for various EVEX opcodes
The order of decodes influences the overall number of table entries.
Reduce table size quite a bit by first decoding few-alternatives
attributes common to all valid leaves.

This also adds a PREFIX_DATA 7531c61332 ("x86: simplify decode of
opcodes valid with (embedded) 66 prefix only") missed to apply to
vbroadcastf64x4.
2021-03-10 08:16:54 +01:00
Jan Beulich
13954a3119 x86: re-arrange order of decode for various mask reg opcodes
The order of decodes influences the overall number of table entries.
Reduce table size quite a bit by first decoding few-alternatives
attributes common to all valid leaves.
2021-03-10 08:16:24 +01:00
Jan Beulich
14d10c6ccc x86: re-arrange order of decode for various VEX opcodes
The order of decodes influences the overall number of table entries.
Reduce table size quite a bit by first decoding few-alternatives
attributes common to all valid leaves.
2021-03-10 08:15:46 +01:00
Jan Beulich
00ec187565 x86: re-arrange order of decode for various legacy opcodes
The order of decodes influences the overall number of table entries.
Reduce table size quite a bit by first decoding few-alternatives
attributes common to all valid leaves.
2021-03-10 08:15:10 +01:00
Jan Beulich
319419837c x86: correct decoding of nop/reserved space (0f18 ... 0x1f)
All encodings not used in this range are (reserved) NOPs. Hence their
decoding should be fully consistent. For this to work the PREFIX_IGNORED
logic needs slightly extending, such that the attribute will also
- have an effect when used inside prefix_table[], yet without always
  falling back to using slot 0,
- cause prefixes marked as ignored while decoding through prefix_table[]
  to no longer be considered decoded, when encountered in a subsequent
  decoding step.

In adjacent code also drop meaningless PREFIX_OPCODE.
2021-03-10 08:14:11 +01:00
Jan Beulich
742732c7f0 x86: fold some prefix related attributes into a single one
RepPrefixOk, HLEPrefixOk, and NoTrackPrefixOk can't be specified
together, so can share an enum-like field. IsLockable can be inferred
from HLE setting and hence only needs specifying when neither of them
is present.
2021-03-09 08:54:32 +01:00
Jan Beulich
e93a3b27b2 x86-64: make SYSEXIT handling similar to SYSRET's
Despite SYSEXIT being an Intel-only insn in long mode, its behavior
there is similar to SYSRET's: Depending on REX.W execution continues in
either 64-bit or compatibility mode. Hence distinguishing by suffix is
as necessary here as it is there.
2021-03-09 08:53:38 +01:00
Jan Beulich
75363b6d60 x86: infer operand count of templates
Having this count explicitly in the table is redundant and (even if just
slightly) disturbs clarity. Infer the count from the number of operands
actually found.

Also convert the "no operands" indicator from "{ 0 }" to just "{}", as
that (now) ends up being easier to parse.
2021-03-03 12:57:08 +01:00
Nelson Chu
5a9f5403c7 RISC-V: PR27158, fixed UJ/SB types and added CSS/CL/CS types for .insn.
* Renamed obsolete UJ/SB types and RVC types, also added CSS/CL(CS) types,

[VALID/EXTRACT/ENCODE macros]
BTYPE_IMM:            Renamed from SBTYPE_IMM.
JTYPE_IMM:            Renamed from UJTYPE_IMM.
CITYPE_IMM:           Renamed from RVC_IMM.
CITYPE_LUI_IMM:       Renamed from RVC_LUI_IMM.
CITYPE_ADDI16SP_IMM:  Renamed from RVC_ADDI16SP_IMM.
CITYPE_LWSP_IMM:      Renamed from RVC_LWSP_IMM.
CITYPE_LDSP_IMM:      Renamed from RVC_LDSP_IMM.
CIWTYPE_IMM:          Renamed from RVC_UIMM8.
CIWTYPE_ADDI4SPN_IMM: Renamed from RVC_ADDI4SPN_IMM.
CSSTYPE_IMM:          Added for .insn without special encoding.
CSSTYPE_SWSP_IMM:     Renamed from RVC_SWSP_IMM.
CSSTYPE_SDSP_IMM:     Renamed from RVC_SDSP_IMM.
CLTYPE_IMM:           Added for .insn without special encoding.
CLTYPE_LW_IMM:        Renamed from RVC_LW_IMM.
CLTYPE_LD_IMM:        Renamed from RVC_LD_IMM.
RVC_SIMM3:            Unused and removed.
CBTYPE_IMM:           Renamed from RVC_B_IMM.
CJTYPE_IMM:           Renamed from RVC_J_IMM.

* Added new operands and removed the unused ones,

C5: Unsigned CL(CS) immediate, added for .insn directive.
C6: Unsigned CSS immediate, added for .insn directive.
Ci: Unused and removed.
C<: Unused and removed.

bfd/
    PR 27158
    * elfnn-riscv.c (perform_relocation): Updated encoding macros.
    (_bfd_riscv_relax_call): Likewise.
    (_bfd_riscv_relax_lui): Likewise.
    * elfxx-riscv.c (howto_table): Likewise.
gas/
    PR 27158
    * config/tc-riscv.c (riscv_ip): Updated encoding macros.
    (md_apply_fix): Likewise.
    (md_convert_frag_branch): Likewise.
    (validate_riscv_insn): Likewise.  Also arranged operands, including
    added C5 and C6 operands, and removed unused Ci and C< operands.
    * doc/c-riscv.texi: Updated and added CSS/CL/CS types.
    * testsuite/gas/riscv/insn.d: Added CSS/CL/CS instructions.
    * testsuite/gas/riscv/insn.s: Likewise.
gdb/
    PR 27158
    * riscv-tdep.c (decode_ci_type_insn): Updated encoding macros.
    (decode_j_type_insn): Likewise.
    (decode_cj_type_insn): Likewise.
    (decode_b_type_insn): Likewise.
    (decode): Likewise.
include/
    PR 27158
    * opcode/riscv.h: Updated encoding macros.
opcodes/
    PR 27158
    * riscv-dis.c (print_insn_args): Updated encoding macros.
    * riscv-opc.c (MASK_RVC_IMM): defined to ENCODE_CITYPE_IMM.
    (match_c_addi16sp): Updated encoding macros.
    (match_c_lui): Likewise.
    (match_c_lui_with_hint): Likewise.
    (match_c_addi4spn): Likewise.
    (match_c_slli): Likewise.
    (match_slli_as_c_slli): Likewise.
    (match_c_slli64): Likewise.
    (match_srxi_as_c_srxi): Likewise.
    (riscv_insn_types): Added .insn css/cl/cs.
sim/
    PR 27158
    * riscv/sim-main.c (execute_i): Updated encoding macros.
2021-02-19 11:44:49 +08:00
Nelson Chu
3d73d29e4e RISC-V: Add bfd/cpu-riscv.h to support all spec versions controlling.
Make the opcode/riscv-opc.c and include/opcode/riscv.h tidy, move the
spec versions stuff to bfd/cpu-riscv.h.  Also move the csr stuff and
ext_version_table to gas/config/tc-riscv.c for internal use.  To avoid
too many repeated code, define general RISCV_GET_SPEC_NAME/SPEC_CLASS
macros.  Therefore, assembler/dis-assembler/linker/gdb can get all spec
versions related stuff from cpu-riscv.h and cpu-riscv.c, since the stuff
are defined there uniformly.

bfd/
    * Makefile.am: Added cpu-riscv.h.
    * Makefile.in: Regenerated.
    * po/SRC-POTFILES.in: Regenerated.
    * cpu-riscv.h: Added to support spec versions controlling.
    Also added extern arrays and functions for cpu-riscv.c.
    (enum riscv_spec_class): Define all spec classes here uniformly.
    (struct riscv_spec): Added for all specs.
    (RISCV_GET_SPEC_CLASS): Added to reduce repeated code.
    (RISCV_GET_SPEC_NAME): Likewise.
    (RISCV_GET_ISA_SPEC_CLASS): Added to get ISA spec class.
    (RISCV_GET_PRIV_SPEC_CLASS): Added to get privileged spec class.
    (RISCV_GET_PRIV_SPEC_NAME): Added to get privileged spec name.
    * cpu-riscv.c (struct priv_spec_t): Replaced with struct riscv_spec.
    (riscv_get_priv_spec_class): Replaced with RISCV_GET_PRIV_SPEC_CLASS.
    (riscv_get_priv_spec_name): Replaced with RISCV_GET_PRIV_SPEC_NAME.
    (riscv_priv_specs): Moved below.
    (riscv_get_priv_spec_class_from_numbers): Likewise, updated.
    (riscv_isa_specs): Moved from include/opcode/riscv.h.
    * elfnn-riscv.c: Included cpu-riscv.h.
    (riscv_merge_attributes): Initialize in_priv_spec and out_priv_spec.
    * elfxx-riscv.c: Included cpu-riscv.h and opcode/riscv.h.
    (RISCV_UNKNOWN_VERSION): Moved from include/opcode/riscv.h.
    * elfxx-riscv.h: Removed extern functions to cpu-riscv.h.
gas/
    * config/tc-riscv.c: Included cpu-riscv.h.
    (enum riscv_csr_clas): Moved from include/opcode/riscv.h.
    (struct riscv_csr_extra): Likewise.
    (struct riscv_ext_version): Likewise.
    (ext_version_table): Moved from opcodes/riscv-opc.c.
    (default_isa_spec): Updated type to riscv_spec_class.
    (default_priv_spec): Likewise.
    (riscv_set_default_isa_spec): Updated.
    (init_ext_version_hash): Likewise.
    (riscv_init_csr_hash): Likewise, also fixed indent.
include/
    * opcode/riscv.h: Moved stuff and make the file tidy.
opcodes/
    * riscv-dis.c: Included cpu-riscv.h, and removed elfxx-riscv.h.
    (default_priv_spec): Updated type to riscv_spec_class.
    (parse_riscv_dis_option): Updated.
    * riscv-opc.c: Moved stuff and make the file tidy.
2021-02-18 15:09:16 +08:00
Alan Modra
b9b204b311 read_leb128 overflow checking
There is a tiny error left in dwarf.c:read_leb128 after Nick fixed the
signed overflow problem in code I wrote.  It's to do with sleb128
values that have unnecessary excess bytes.  For example, -1 is
represented as 0x7f, the most efficient encoding, but also as
0xff,0x7f or 0xff,0xff,0x7f and so on.  None of these sequences
overflow any size signed value, but read_leb128 will report an
overflow given enough excess bytes.  This patch fixes that problem,
and since the proper test for signed values with excess bytes can
easily be adapted to also test a sleb byte with just some bits that
overflow the result, I changed the code to not use signed right
shifts.  (The C standard ISO/IEC 9899:1999 6.5.7 says signed right
shifts of negative values have an implementation defined value.  A
long time ago I even used a C compiler for a certain microprocessor
that always did unsigned right shifts.  Mind you, it is very unlikely
to be compiling binutils with such a compiler.)

bfd/
	* wasm-module.c: Guard include of limits.h.
	(CHAR_BIT): Provide backup define.
	(wasm_read_leb128): Use CHAR_BIT to size "result" in bits.
	Correct signed overflow checking.
opcodes/
	* wasm32-dis.c: Include limits.h.
	(CHAR_BIT): Provide backup define.
	(wasm_read_leb128): Use CHAR_BIT to size "result" in bits.
	Correct signed overflow checking.
binutils/
	* dwarf.c: Include limits.h.
	(CHAR_BIT): Provide backup define.
	(read_leb128): Use CHAR_BIT to size "result" in bits.  Correct
	signed overflow checking.
	* testsuite/binutils-all/pr26548.s,
	* testsuite/binutils-all/pr26548.d,
	* testsuite/binutils-all/pr26548e.d: New tests.
	* testsuite/binutils-all/readelf.exp: Run them.
	(readelf_test): Drop unused "xfails" parameter.  Update all uses.
2021-02-17 16:57:59 +10:30
Jan Beulich
394ae71f02 x86: CVTPI2PD has special behavior
CVTPI2PD with a memory operand, unlike CVTPI2PS, doesn't engage MMX
logic. Therefore it
- has a proper AVX equivalent (CVTDQ2PD) and hence can be subject to
  SSE2AVX translation and SSE checking,
- should not record MMX use in the respective ELF note.
2021-02-16 11:34:25 +01:00
Jan Beulich
b818b220e4 x86: have preprocessor expand macros
There's no point having i386-gen's set_bitfield() to handle any aliases,
now that we pass the opcode table through the C preprocessor anyway.
2021-02-16 11:27:40 +01:00
Andreas Krebbel
ba2b480f10 IBM Z: Implement instruction set extensions
opcodes/

        * s390-mkopc.c (main): Accept arch14 as cpu string.
        * s390-opc.txt: Add new arch14 instructions.

include/

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

gas/

        * config/tc-s390.c (s390_parse_cpu): New entry for arch14.
        * doc/c-s390.texi: Document arch14 march option.
        * testsuite/gas/s390/s390.exp: Run the arch14 related tests.
        * testsuite/gas/s390/zarch-arch14.d: New test.
        * testsuite/gas/s390/zarch-arch14.s: New test.
2021-02-15 14:32:17 +01:00
Nick Alcock
9514861402 bfd, opcodes, libctf: support --with-included-gettext
Right now, these libraries hardwire -L../intl -lintl on a few fixed
platforms, which works fine on those platforms but on other platforms
leads to shared libraries that lack libintl_* symbols when configured
--with-included-gettext, and/or static libraries that contain libintl as
*another* static library.  If we instead use the LIBINTL variable
defined in ../intl/config.intl, this gives us the right thing on all
three classes of platform (gettext in libc, gettext in system libintl,
gettext in ../intl/libintl.a)..  This also means we can rip out some
Darwin-specific machinery from configure.ac and also simplify the Cygwin
side.

This also means that the libctf testsuite (and other places that include
libbfd, libopcodes or libctf) don't need to grow libintl dependencies
just on account of those libraries (though they still need such
dependencies if they themselves use gettext machinery).

bfd/ChangeLog
2021-02-03  Nick Alcock  <nick.alcock@oracle.com>

	* configure.ac (SHARED_LIBADD): Remove explicit -lintl population in
	favour of LIBINTL.
	* configure: Regenerated.

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

	* configure.ac (CTF_LIBADD): Remove explicit -lintl population in
	favour of LIBINTL.
	* Makefile.am (libctf_nobfd_la_LIBADD): No longer explicitly
	include $(LIBINTL).
	(check-DEJAGNU): Pass down to tests as well.
	* configure: Regenerated.
	* Makefile.in: Likewise.

opcodes/ChangeLog
2021-02-04  Nick Alcock  <nick.alcock@oracle.com>

	* configure.ac (SHARED_LIBADD): Remove explicit -lintl population in
	favour of LIBINTL.
	* configure: Regenerated.
2021-02-10 15:26:57 +00:00
Mike Frysinger
bfd428bc12 opcodes: tic54x: namespace exported variables
The tic54x exports some fairly generic variable names that can
conflict with programs that use them, so put proper tic54x_
prefixes on all of them.
2021-02-08 18:26:08 -05:00
Nelson Chu
24075dcc85 RISC-V: Removed the v0.93 bitmanip ZBA/ZBB/ZBC instructions.
bfd/
    * elfxx-riscv.c (riscv_parse_prefixed_ext): Removed zb*.
gas/
    * config/tc-riscv.c (riscv_multi_subset_supports): Removed
    INSN_CLASS_ZB*.
    * testsuite/gas/riscv/bitmanip-insns-32.d: Removed.
    * testsuite/gas/riscv/bitmanip-insns-64.d: Removed.
    * testsuite/gas/riscv/bitmanip-insns.s: Removed.
include/
    * opcode/riscv-opc.h: Removed macros for zb* extensions.
    * opcode/riscv.h (riscv_insn_class): Removed INSN_CLASS_ZB*.
opcodes/
    * riscv-opc.c (MASK_RVB_IMM): Removed.
    (riscv_opcodes): Removed zb* instructions.
    (riscv_ext_version_table): Removed versions for zb*.
2021-02-04 16:52:13 +08:00
Alan Modra
c3ffb8f340 Segmentation fault i386-gen
A case of inst->next being uninitialised.

	* i386-gen.c (parse_template): Ensure entire template_instance
	is initialised.
2021-01-26 20:54:43 +10:30
Nelson Chu
1942a04836 RISC-V: Indent and GNU coding standards tidy, also aligned the code.
bfd/
    * elfnn-riscv.c: Indent, labels and GNU coding standards tidy,
    also aligned the code.
gas/
    * config/tc-riscv.c: Indent and GNU coding standards tidy,
    also aligned the code.
    * config/tc-riscv.h: Likewise.
include/
    * opcode/riscv.h: Indent and GNU coding standards tidy,
    also aligned the code.
opcodes/
    * riscv-opc.c (riscv_gpr_names_abi): Aligned the code.
    (riscv_fpr_names_abi): Likewise.
    (riscv_opcodes): Likewise.
    (riscv_insn_types): Likewise.
2021-01-15 17:41:18 +08:00
Nelson Chu
b800637e76 RISC-V: Error and warning messages tidy.
Error and warning messages usually starting with lower case letter,
and without the period at the end.  Besides, add the prefixed "internel:"
at the beginning of the messages when they are caused internally.
Also fix indents and typos.

bfd/
    * elfnn-riscv.c (riscv_merge_attributes): Fix typos of messages.
gas/
    * config/tc-riscv.c: Error and warning messages tidy.
    * testsuite/gas/riscv/priv-reg-fail-fext.l: Updated.
    * testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-read-only-02.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
    * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
ld/
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
    * testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
opcodes/
    * riscv-dis.c (parse_riscv_dis_option): Fix typos of message.
2021-01-15 17:33:59 +08:00
Nelson Chu
dcd709e056 RISC-V: Comments tidy and improvement.
The GNU coding standards said the comments should be complete sentences
and end with a period and two spaces.  But sometimes it should be more
cleaner when the comments only include a word or codes.  Therefore, I made
the following changes after referring to other target/generic codes,

* Try to write sentences in comments, must end with a period and two spaces.
* End with two spaces without a period for codes/instructions only.
* End with one space without a period for a single word/variable only.

Besids, also rewrite/remove some comments which are obsolete or too long,
and fix indents for comments.

bfd/
    * elfnn-riscv.c: Comments tidy and improvement.
    * elfxx-riscv.c: Likewise.
    * elfxx-riscv.h: Likewise.
gas/
    * config/tc-riscv.c: Comments tidy and improvement.  Also update
    comment "fallthru" to "Fall through" that end with a period and
    two spaces.
include/
    * elf/riscv.h: Comments tidy and improvement.
    * opcode/riscv-opc.h: Likewise.
    * opcode/riscv.h: Likewise.
opcodes/
    * riscv-dis.c: Comments tidy and improvement.
    * riscv-opc.c: Likewise.
2021-01-15 17:28:07 +08:00
Alan Modra
5347ed60c5 Regen Makefile.in for jobserver.m4 aclocal.m4 dependency
bfd/
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
binutils/
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
gas/
	* Makefile.in: Regenerate.
	* Makefile.in: Regenerate.
gprof/
	* Makefile.in: Regenerate.
ld/
	* Makefile.in: Regenerate.
libctf/
	* Makefile.in: Regenerate.
opcodes/
	* Makefile.in: Regenerate.
2021-01-13 22:06:02 +10:30
H.J. Lu
d546b61084 Implement a workaround for GNU mak jobserver
Compiling binutils using -flto=jobserver with GCC 11 leads to

libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Wwrite-strings -I../../gas/../zlib -g -O2 -fprofile-generate -flto=jobserver -o as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o config/tc-i386.o config/obj-elf.o config/atof-ieee.o  ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a -L/tmp/binutils-gdb/objdir/zlib -lz ../libiberty/libiberty.a -ldl
lto-wrapper: warning: jobserver is not available: '--jobserver-auth=' is not present in 'MAKEFLAGS'

since the '+' is missing on the recipe line in Makefiles generated by
automake.  Add the '+' to the recipe line by hand.

bfd/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

binutils/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

config/

	PR binutils/26792
	* jobserver.m4: New file.

gas/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

gprof/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

ld/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

libctf/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

opcodes/

	PR binutils/26792
	* configure.ac: Use GNU_MAKE_JOBSERVER.
	* aclocal.m4: Regenerated.
	* configure: Likewise.
2021-01-12 05:45:44 -08:00
Nick Clifton
6d104cac0a Updated translations for some subdirectories 2021-01-12 13:18:50 +00:00
H.J. Lu
83b33c6cb9 Binutils: Check if AR works with --plugin and rc
Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

bfd/

	PR ld/27173

binutils/

	PR ld/27173
	* configure: Regenerated.

gas/

	PR ld/27173
	* configure: Regenerated.

gprof/

	PR ld/27173
	* configure: Regenerated.

ld/

	PR ld/27173
	* configure: Regenerated.

libctf/

	PR ld/27173
	* configure: Regenerated.

opcodes/

	PR ld/27173
	* configure: Regenerated.
2021-01-11 16:29:45 -08:00
Kyrylo Tkachov
82c70b08df aarch64: Remove support for CSRE
This patch removes support for the CSRE extension from aarch64
gas/objdump.
CSRE (FEAT_CSRE) is part of the Future Architecture Technologies program
and at this time Arm is withdrawing this particular feature.

The patch removes the system registers and the CSR PDEC instruction.

gas/ChangeLog
	* NEWS: Remove CSRE.
	* config/tc-aarch64.c (parse_csr_operand): Delete.
	(parse_operands): Delete handling of AARCH64_OPND_CSRE_CSR.
	(aarch64_features): Remove csre.
	* doc/c-aarch64.texi: Remove CSRE.
	* testsuite/gas/aarch64/csre.d: Delete.
	* testsuite/gas/aarch64/csre-invalid.s: Likewise.
	* testsuite/gas/aarch64/csre-invalid.d: Likewise.
	* testsuite/gas/aarch64/csre_csr.s: Likewise.
	* testsuite/gas/aarch64/csre_csr.d: Likewise.
	* testsuite/gas/aarch64/csre_csr-invalid.s: Likewise.
	* testsuite/gas/aarch64/csre_csr-invalid.l: Likewise.
	* testsuite/gas/aarch64/csre_csr-invalid.d: Likewise.

include/ChangeLog

	* opcode/aarch64.h (AARCH64_FEATURE_CSRE): Delete.
	(aarch64_opnd): Delete AARCH64_OPND_CSRE_CSR.

opcodes/ChangeLog

	* aarch64-asm-2.c: Regenerate.
	* aarch64-dis-2.c: Likewise.
	* aarch64-opc-2.c: Likewise.
	* aarch64-opc.c (aarch64_print_operand): Delete handling of
	AARCH64_OPND_CSRE_CSR.
	* aarch64-tbl.h (aarch64_feature_csre): Delete.
	(CSRE): Likewise.
	(_CSRE_INSN): Likewise.
	(aarch64_opcode_table): Delete csr.
2021-01-11 15:01:09 +00:00
Nick Clifton
a8aa72b913 Updated translations for multiple subdirectories 2021-01-11 12:55:33 +00:00
H.J. Lu
a4966cd965 Binutils: Pass --plugin to AR and RANLIB
Detect GCC LTO plugin.  Pass --plugin to AR and RANLIB to support LTO
build.

bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

libctf/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2021-01-09 06:51:51 -08:00
Nick Clifton
573fe3fbc1 Change version number to 2.36.50 and regenerate files 2021-01-09 11:01:01 +00:00
Nick Clifton
055bc77a80 Add Changelog entries and NEWS entries for 2.36 branch 2021-01-09 10:40:28 +00:00
Peter Bergner
aae7fcb8d7 POWER10: Add Return-Oriented Programming instructions
POWER10 adds some return-oriented programming (ROP) instructions and
this patch adds support for them.  You will notice that they are enabled
for POWER8 and later, not just POWER10 and later.  This is on purpose.
This allows the instructions to be added to POWER8 binaries that can be
run on POWER8, POWER9 and POWER10 cpus.  On POWER8 and POWER9, these
instructions just act as nop's.

opcodes/
	* ppc-opc.c (insert_dw, (extract_dw): New functions.
	(DW, (XRC_MASK): Define.
	(powerpc_opcodes) <hashchk, hashchkp, hashst, haststp>: New mnemonics.
gas/
	* testsuite/gas/ppc/rop-checks.d,
	* testsuite/gas/ppc/rop-checks.l,
	* testsuite/gas/ppc/rop-checks.s,
	* testsuite/gas/ppc/rop.d,
	* testsuite/gas/ppc/rop.s: New tests.
	* testsuite/gas/ppc/ppc.exp: Run them.
2021-01-09 15:16:13 +10:30
Alan Modra
6430704567 configure regen
commit f478212851 did the regen by hand, missed a change in
ld/configure and didn't update line numbers.  Fix that, and an old
regen of ld/Makefile.in with the wrong automake.

bfd/
	* configure: Regenerate.
binutils/
	* configure: Regenerate.
gas/
	* configure: Regenerate.
gprof/
	* configure: Regenerate.
ld/
	* Makefile.in: Regenerate.
	* configure: Regenerate.
libctf/
	* configure: Regenerate.
opcodes/
	* configure: Regenerate.
zlib/
	* configure: Regenerate.
2021-01-09 15:12:44 +10:30
Nick Clifton
ed20522215 Updated Swedish translation for the opcodes/ subdirectory 2021-01-08 11:56:01 +00:00
Nick Clifton
e84c871648 Fix places in the AArch64 opcodes library code where a call to assert() has side effects.
PR 27129
	* aarch64-dis.c (determine_disassembling_preference): Move call to
	aarch64_match_operands_constraint outside of the assertion.
	* aarch64-asm.c (aarch64_ins_limm_1): Remove call to assert.
	Replace with a return of FALSE.
2021-01-08 11:51:50 +00:00
Nick Clifton
fb932b57cb Treat the AArch64 register id_aa64mmfr2_el1 as a core system register.
PR 27139
	* aarch64-opc.c (aarch64_sys_regs): Treat id_aa64mmfr2_el1 as a
	core system register.
2021-01-08 11:29:43 +00:00
Samuel Thibault
f478212851 libtool.m4: update GNU/Hurd test from upstream. In upstream libtool, 47a889a4ca20 ("Improve GNU/Hurd support.") fixed detection of shlibpath_overrides_runpath, thus avoiding unnecessary relink. This backports it.
.	* libtool.m4: Match gnu* along other GNU systems.

*/ChangeLog:

	* configure: Re-generate.
2021-01-07 16:47:36 +00:00
Nick Clifton
1b0927db3c Updated French translation for the opcodes/ subdirectory. 2021-01-07 14:47:49 +00:00
Fredrik Noring
3b288c8e2e m68k: Require m68020up rather than m68000up for CHK.L instruction.
* m68k-opc.c (chkl): Change minimum architecture requirement to
	m68020.
2021-01-07 14:45:10 +00:00
Philipp Tomsich
aa881ecde4 RISC-V: Add pause hint instruction.
Add support for the pause hint instruction, as specified in the
Zihintpause extension.  The pause instruction is encoded as a
special form of a memory fence (which is available as part of the
base instruction set).  The chosen encoding does not mandate any
particular memory ordering and therefore is a true hint.

bfd/
    * elfxx-riscv.c (riscv_std_z_ext_strtab): Added zihintpause.
gas/
    * config/tc-riscv.c (riscv_multi_subset_supports): Added
    INSN_CLASS_ZIHINTPAUSE.
    * testsuite/gas/riscv/pause.d: New testcase.  Adding coverage for
    the pause hint instruction.
    * testsuite/gas/riscv/pause.s: Likewise.
include/
    * opcode/riscv-opc.h: Added MATCH_PAUSE, MASK_PAUSE and DECLARE_INSN
    for pause hint instruction.
    * opcode/riscv.h (enum riscv_insn_class): Added INSN_CLASS_ZIHINTPAUSE.
opcodes/
    * riscv-opc.c (riscv_opcodes): Add pause hint instruction.
2021-01-07 16:45:43 +08:00
Claire Xenia Wolf
2652cfad8d RISC-V: Support riscv bitmanip frozen ZBA/ZBB/ZBC instructions (v0.93).
In fact rev8/orc.b/zext.h are the aliases of grevi/gorci/pack[w], so we
should update them to INSN_ALIAS when we have supported their true instruction
in the future.  Though we still use the [MATCH|MAKS]_[GREVI|GORCI|PACK|PACKW]
to encode them.  Besides, the orc.b has the same encoding both in rv32 and
rv64, so we just keep one of them in the opcode table.

This patch is implemented according to the following link,
https://github.com/riscv/riscv-bitmanip/pull/101

2021-01-07  Claire Xenia Wolf  <claire@symbioticeda.com>
            Jim Wilson  <jimw@sifive.com>
            Andrew Waterman  <andrew@sifive.com>
            Maxim Blinov  <maxim.blinov@embecosm.com>
            Kito Cheng  <kito.cheng@sifive.com>
            Nelson Chu  <nelson.chu@sifive.com>

bfd/
    * elfxx-riscv.c (riscv_std_z_ext_strtab): Added zba, zbb and zbc.
gas/
    * config/tc-riscv.c (riscv_multi_subset_supports): Handle INSN_CLASS_ZB*.
    (riscv_get_default_ext_version): Do not check the default_isa_spec when
    the version defined in the riscv_opcodes table is ISA_SPEC_CLASS_DRAFT.
    * testsuite/gas/riscv/bitmanip-insns-32.d: New testcase.
    * testsuite/gas/riscv/bitmanip-insns-64.d: Likewise.
    * testsuite/gas/riscv/bitmanip-insns.s: Likewise.
include/
    * opcode/riscv-opc.h: Added MASK/MATCH/DECLARE_INSN for ZBA/ZBB/ZBC.
    * opcode/riscv.h (riscv_insn_class): Added INSN_CLASS_ZB*.
    (enum riscv_isa_spec_class): Added ISA_SPEC_CLASS_DRAFT for the
    frozen extensions.
opcodes/
    * riscv-opc.c (riscv_opcodes): Add ZBA/ZBB/ZBC instructions.
    (MASK_RVB_IMM): Used for rev8 and orc.b encoding.
2021-01-07 11:44:54 +08:00
Alan Modra
f9a6a8f09d PR27116, Spelling errors found by Debian style checker
PR 27116
bfd/
	* xcofflink.c: Correct spelling in comments.
binutils/
	* coffgrok.c (do_type): Correct spelling of auxiliary in errors.
	* doc/binutils.texi: Correct grammar.
	* readelf.c (process_version_sections): Correct spelling of auxiliary
	in warning.
	* testsuite/binutils-all/vax/objdump.exp: Comment grammar fix.
config/
	* override.m4: Correct comment grammar.
gas/
	* config/tc-i386.c: Correct comment spelling.
	* config/tc-riscv.c: Likewise.
	* config/tc-s390.c: Correct comment grammar.
	* doc/c-i386.texi: Correct spelling.
	* doc/c-s390.texi: Correct grammar.
gold/
	* tilegx.cc: Correct comment spelling.
gprof/
	* README: Correct grammar.
	* gprof.texi: Likewise.
include/
	* coff/internal.h: Correct comment spelling.
	* coff/sym.h: Likewise.
	* opcode/aarch64.h: Likewise.
ld/
	* configure.tgt: Correct comment grammar.
	* emultempl/m68hc1xelf.em: Likewise.
	* ld.texi: Correct grammar.
2021-01-01 14:36:35 +10:30
Alan Modra
250d07de5c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
Alan Modra
c2795844e6 ChangeLog rotation 2021-01-01 10:31:02 +10:30
Nelson Chu
c2137f55ad RISC-V: Add sext.[bh] and zext.[bhw] pseudo instructions.
https://github.com/riscv/riscv-asm-manual/pull/61

We aleady have sext.w, so just add sext.b, sext.h, zext.b, zext.h
and zext.w.  In a certain sense, zext.b is not a pseudo - It is an
alias of andi.  Similarly, sext.b and sext.h are aliases of other
rvb instructions, when we enable b extension; But they are pseudos
when we just enable rvi.  However, this patch does not consider the
rvb cases.  Besides, zext.w is only valid in rv64.

gas/
    * config/tc-riscv.c (riscv_ext): New function.  Use md_assemblef
    to expand the zext and sext pseudos, to give them a chance to be
    expanded into c-ext instructions.
    (macro): Handle M_ZEXTH, M_ZEXTW, M_SEXTB and M_SEXTH.
    * testsuite/gas/riscv/ext.s: New testcase.
    * testsuite/gas/riscv/ext-32.d: Likewise.
    * testsuite/gas/riscv/ext-64.d: Likewise.
include/
    * opcode/riscv.h (M_ZEXTH, M_ZEXTW, M_SEXTB, M_SEXTH.): Added.
opcodes/
    * riscv-opc.c (riscv_opcodes): Add sext.[bh] and zext.[bhw].
2020-12-10 10:50:44 +08:00
Nelson Chu
8152e0407c RISC-V: Dump CSR according to the elf privileged spec attributes.
opcodes/
    * disassemble.h (riscv_get_disassembler): Declare.
    * disassemble.c (disassembler): Changed to riscv_get_disassembler.
    * riscv-dis.c (riscv_get_disassembler): Check the elf privileged spec
    attributes before calling print_insn_riscv.
    (parse_riscv_dis_option): Same as the assembler, the priority of elf
    attributes are higher than the options.  If we find the privileged
    attributes, but the -Mpriv-spec= is different, then output error/warning
    and still use the elf attributes set.
2020-12-10 10:43:18 +08:00
Nelson Chu
729a53530e RISC-V: Control fence.i and csr instructions by zifencei and zicsr.
bfd/
    * elfxx-riscv.c (riscv_ext_dont_care_version): New function.  Return
    TRUE if we don't care the versions of the extensions.  These extensions
    are added to the subset list for special purposes, with the explicit
    versions or the RISCV_UNKNOWN_VERSION versions.
    (riscv_parse_add_subset): If we do care the versions of the extension,
    and the versions are unknown, then report errors for the non-implicit
    extensions, and return directly for the implicit one.
    (riscv_arch_str1): Do not output i extension after e, and the extensions
    which versions are unknown.
gas/
    * config/tc-riscv.c (riscv_multi_subset_supports): Handle INSN_CLASS_ZICSR
    and INSN_CLASS_ZIFENCEI.
    * testsuite/gas/riscv/march-imply-i.s: New testcase.
    * testsuite/gas/riscv/march-imply-i2p0-01.d: New testcase.  The version
    of i is less than 2.1, and zi* are supported in the chosen spec, so
    enable the fence.i and csr instructions, also output the implicit zi* to
    the arch string.
    * testsuite/gas/riscv/march-imply-i2p0-02.d: Likewise, but the zi* are
    not supported in the spec 2.2.  Enable the related instructions since
    i's version is less than 2.1, but do not output them.
    * testsuite/gas/riscv/march-imply-i2p1-01.d: New testcase.  The version
    of i is 2.1, so don't add it's implicit zi*, and disable the related
    instructions.
    * testsuite/gas/riscv/march-imply-i2p1-01.l: Likewise.
    * testsuite/gas/riscv/march-imply-i2p1-02.d: Likewise, and set the zi*
    explicitly, so enable the related instructions.
    * testsuite/gas/riscv/march-imply-i2p0.d: Removed.
    * testsuite/gas/riscv/march-imply-i2p1.d: Removed.
include/
    * opcode/riscv.h: Add INSN_CLASS_ZICSR and INSN_CLASS_ZIFENCEI.
opcodes/
    * riscv-opc.c (riscv_opcodes): Control fence.i and csr instructions by
    zifencei and zicsr.
2020-12-10 10:37:43 +08:00
Andreas Krebbel
c524d11e50 IBM Z: Add risbgz and risbgnz extended mnemonics
These two extended mnemonics are documented in the Principles of
Operations manual but currently not supported by Binutils. They
provide aliases for already supported instructions with the zero flag
being set.  The flag otherwise is mingled into one of the immediate
operands what makes asm code much harder to read.

opcodes/

	* s390-opc.txt: Add risbgz and risbgnz.
	* s390-opc.c (U6_26): New operand type.
	(INSTR_RIE_RRUUU2, MASK_RIE_RRUUU2): New instruction format and
	mask.

gas/

	* testsuite/gas/s390/zarch-z10.s: Add tests for risbgz.
	* testsuite/gas/s390/zarch-z10.d: Add regexp for risbgz.
	* testsuite/gas/s390/zarch-zEC12.s: Add tests for risbgnz.
	* testsuite/gas/s390/zarch-zEC12.d: Add regexp for risbgnz.
2020-12-04 09:14:02 +01:00
Andreas Krebbel
b10b530a45 IBM Z: Add support for HLASM extended mnemonics
Add extended mnemonics used in the HLASM assembler.  All of them are
just aliases for instructions we already support and help when
assembling code which was written for the HLASM assembler.

The HLASM mnemonics are documented here:
https://www.ibm.com/support/knowledgecenter/SSENW6_1.6.0/com.ibm.hlasm.v1r6.asm/asmr1023.pdf

See the 'Branching with extended mnemonic codes' chapter.

objdump will still print the existing mnemonics with the exception of
relative nop branches (i.e. conditional branches with an empty
condition code mask).  Now we have jnop and jgnop which will be used
by objdump when possible.

The same change have been applied to the LLVM assembler:
https://reviews.llvm.org/D92185

opcodes/

	* s390-opc.txt: Add extended mnemonics.

gas/

	* testsuite/gas/s390/esa-g5.s: Test new extended mnemonics.
	* testsuite/gas/s390/esa-g5.d: Likewise.
	* testsuite/gas/s390/esa-z900.s: Likewise.
	* testsuite/gas/s390/esa-z900.d: Likewise.
	* testsuite/gas/s390/zarch-z900.s: Likewise.
	* testsuite/gas/s390/zarch-z900.d: Likewise.

ld/

	* testsuite/ld-s390/tlsbin_64.dd: The newly added jgnop mnemonic
	replaces long relative branches with empty condition code mask.
2020-12-03 16:51:12 +01:00
Nelson Chu
27a46348cb RISC-V: Remove the unimplemented extensions.
Although spec had defined and ratified p, v and n extensions,
but we don't have any related implementaitons so far, so keep
them in the supported extension table looks weird.  Remove them
until we have the related implementations.

	opcodes/
	* riscv-opc.c (riscv_ext_version_table): Remove the p, v, n
	and their versions.
2020-12-01 15:13:06 +08:00
Nelson Chu
5a1b31e1e1 RISC-V: Add zifencei and prefixed h class extensions.
bfd/
	* elfxx-riscv.c (riscv_parse_std_ext): Stop parsing standard
	extensions when parsed h keyword.
	(riscv_get_prefix_class): Support prefixed h class.
	(riscv_std_h_ext_strtab): Likewise.
	(riscv_ext_h_valid_p): Likewise.
	(parse_config): Likewise.
	(riscv_std_z_ext_strtab): Add zifencei.
	* elfxx-riscv.h (riscv_isa_ext_class): Add RV_ISA_CLASS_H.

	gas/
	* testsuite/gas/riscv/march-fail-order-z.d: New testcase, check
	orders of prefixed z extensions.
	* testsuite/gas/riscv/march-fail-order-z.l: Likewise.
	* testsuite/gas/riscv/march-fail-single-char-h.d: New testcase.
	* testsuite/gas/riscv/march-fail-single-char.l: Updated.
	* testsuite/gas/riscv/march-fail-unknown-h.d: New testcase.
	* testsuite/gas/riscv/march-fail-unknown.l: Updated.

	opcodes/
	* riscv-opc.c (riscv_ext_version_table): Add zifencei.
2020-12-01 15:11:30 +08:00
Borislav Petkov
632ee6fd82 x86: Do not dump DS/CS segment overrides for branch hints
The previous change

  "x86: Ignore CS/DS/ES/SS segment-override prefixes in 64-bit mode"

to ignore segment override prefixes in 64-bit mode lead to dumping
branch hints as excessive prefixes:

  ffffffff8109d5a0 <vmx_get_rflags>:
  ...
  ffffffff8109d601:       3e 77 0a                ds ja,pt ffffffff8109d60e <vmx_get_rflags+0x6e>
  						^^^^^

In this particular case, those prefixes are not excessive but are used
to provide branch hints - taken/not-taken - to the CPU.

Assign active_seg_prefix in that particular case to consume them.

gas/

2002-11-29  Borislav Petkov  <bp@suse.de>

        * testsuite/gas/i386/branch.d: Add new branch insns test.
        * testsuite/gas/i386/branch.s: Likewise.
        * testsuite/gas/i386/i386.exp: Insert the new branch test.
        * testsuite/gas/i386/x86-64-branch.d: Test for branch hints insns.
        * testsuite/gas/i386/x86-64-branch.s: Likewise.
        * testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise.

opcodes/

2020-11-28 Borislav Petkov  <bp@suse.de>

        * i386-dis.c (print_insn): Set active_seg_prefix for branch hint insns
        to not dump branch hint prefixes 0x2E and 0x3E as unused prefixes.
2020-11-29 09:08:56 -08:00
Przemyslaw Wirkus
e64441b14c aarch64: Extract Condition flag manipulation feature from Armv8.4-A
Extract FLAGM (Condition flag manipulation) feature from Armv8.4-A.
Please note that FLAGM stays a Armv8.4-A feature but now can be
assigned to other architectures or CPUs.

New -march option +flagm is added to enable independently this
feature.
2020-11-16 21:07:17 +00:00
Borislav Petkov
0fa0fc8539 x86: Ignore CS/DS/ES/SS segment-override prefixes in 64-bit mode
"In 64-bit mode, the CS, DS, ES, and SS segment-override prefixes have
no effect. These four prefixes are not treated as segment-override
prefixes for the purposes of multiple-prefix rules. Instead, they are
treated as null prefixes." (AMD APM v2).

However, objdump disassembles instructions containing those ignored
prefixes by still generating that segment override:

  66 66 2e 0f 1f 84 00 	data16 nopw %cs:0x0(%rax,%rax,1)
  00 00 00 00

Print those segment override prefixes as excessive ones:

  66 66 2e 0f 1f 84 00    data16 cs nopw 0x0(%rax,%rax,1)
  00 00 00 00

which is what they actually are - they have no effect and the decoding
hardware ignores them.

gas/

2020-11-14  Borislav Petkov  <bp@suse.de>

	* testsuite/gas/i386/x86-64-segovr.d: Adjust regexes.
	* testsuite/gas/i386/x86-64-nops.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-1.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-1-g64.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-1-core2.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-1-k8.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-2.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-3.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-4.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-4-k8.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-5.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-5-k8.d: Likewise.
	* testsuite/gas/i386/x86-64-nops-7.d: Likewise.
	* testsuite/gas/i386/x86-64-nop-1.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1a.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1b.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1c.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1d.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-1g.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-2c.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-6.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-7.d: Likewise.
	* testsuite/gas/i386/x86-64-align-branch-8.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-1-k8.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-1.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-2.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-3.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-4-k8.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-4.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-5-k8.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops-5.d: Likewise.
	* testsuite/gas/i386/ilp32/x86-64-nops.d:: Likewise.

ld/

2020-11-14  Borislav Petkov  <bp@suse.de>

	* testsuite/ld-x86-64/pe-x86-64-4.od: Adjust regexes.
	* testsuite/ld-x86-64/tlsld3.dd: Likewise.
	* testsuite/ld-x86-64/tlsld4.dd: Likewise.

opcodes/

2020-11-14  Borislav Petkov  <bp@suse.de>

	* i386-dis.c (ckprefix): Do not assign active_seg_prefix in
	64-bit addressing mode.
	(NOTRACK_Fixup): Test prefixes for PREFIX_DS, instead of
	active_seg_prefix.
2020-11-14 06:20:33 -08:00
Przemyslaw Wirkus
f27c0b449f aarch64: Allow LS64 feature with Armv8.6
Allow users to use LS64 extension with Armv8.6 architecture.
2020-11-11 15:30:21 +00:00
Spencer E. Olson
9372689d72 Add support for the LMBD (left-most bit detect) instruction to the PRU assembler.
include	* opcode/pru.h: Add LMBD (left-most bit detect) opcode index
opcodes * pru-opc.c: Add opcode description for LMBD (left-most bit detect)
gas 	* testsuite/gas/pru/misc.s: Add tests for lmbd (left-most bit detect)
 	* testsuite/gas/pru/misc.d: Add tests for lmbd (left-most bit
2020-11-09 12:41:09 +00:00
Przemyslaw Wirkus
4a3e3e2282 aarch64: Update LS64 feature with system register
This patch:
+ Adds new ACCDATA_EL1 (Accelerator Data) system register, see [0].
+ Adds LS64 instruction tests.
+ Update LS64 feature test with new register.
+ Fix comment for AARCH64_OPND_Rt_LS64.

    [0] https://developer.arm.com/docs/ddi0595/i/aarch64-system-registers/accdata_el1

Note: as this is register only extension we do not want to hide these
registers behind -march flag going forward (they should be enabled by
default).
2020-11-09 11:37:32 +00:00
Przemyslaw Wirkus
8edca81ece aarch64: Limit Rt register number for LS64 load/store instructions
Atomic 64-byte load/store instructions limit Rt register number to
values matching below condition (register <Xt> number must be even
and <= 22):

    if Rt<4:3> == '11' || Rt<0> == '1' then UNDEFINED;

This patch adds check if Rt fulfills above requirement.

For more details regarding atomic 64-byte load/store instruction for
Armv8.7 please refer to Arm A64 Instruction set documentation for
Armv8-A architecture profile, see document page 157 for load
instruction, and pages 414-418 for store instructions of [0].

    [0]: https://developer.arm.com/docs/ddi0596/i
2020-11-09 11:19:44 +00:00
Przemyslaw Wirkus
af1bd771fc aarch64: Extract Pointer Authentication feature from Armv8.3-A
Extract PAC (Pointer Authentication) feature from Armv8.3-A.
Please note that PAC stays a Armv8.3-A feature but now can be
assigned to other architectures or CPUs.
2020-11-06 13:14:14 +00:00
Przemyslaw Wirkus
55cc012834 aarch64: Update feature RAS system registers
This patch:
+ updates RAS feature system registers with new RAS 1.1 regs.
+ extends RAS/RAS 1.1 support for all architecture levels of Armv8-A.

Please note that early Armv8-A architectures do not officially support RAS
extension.

Rationale of the patch:
To ease development so that user-friendly RAS system registers operands can be
used. Certain use cases require developers to enable only more generic
architecture (e.g. -march=armv8-a) during system development. Users must use
RAS extension registers bearing in mind that system they use must support it.

The RAS (Reliability, Availability, Serviceability) extension is a
system-level extension that defines a number of system registers.

RAS 1.1 (FEAT_RASv1p1) introduces five new system registers:
ERXPFGCTL_EL1, ERXPFGCDN_EL1, ERXMISC2_EL1, ERXMISC3_EL1 and
ERXPFGF_EL1.

For details see [0].

[0] https://developer.arm.com/docs/ddi0595/i/
2020-11-04 20:54:13 +00:00
Przemyslaw Wirkus
fd65497db4 [PATCH][GAS] aarch64: Add atomic 64-byte load/store instructions for Armv8.7
Armv8.7 architecture introduces the "accelerator extension", aka
load/store of 64 bytes. New atomic load/store instructions are: LD64B,
ST64B, ST64BV and ST64BV0.

This patch adds:
+ New feature +ls64 to -march command line.
+ New atomic load/store instructions associated with above feature.

For more details regarding atomic 64-byte load/store instruction for
Armv8.7 please refer to Arm A64 Instruction set documentation for
Armv8-A architecture profile, see document page 157 for load
instruction, and pages 414-418 for store instructions of [0].

    [0]: https://developer.arm.com/docs/ddi0596/i
2020-11-03 14:29:31 +00:00
Przemyslaw Wirkus
3a959875ea [PATCH] aarch64: Update missing ChangeLog for AArch64 commits
Patch with missing ChangeLog entries for GAS AArch64 files.
2020-11-03 11:55:14 +00:00
Przemyslaw Wirkus
a984d94aab [PATCH][GAS] aarch64: Add WFIT instruction for Armv8.7-a
This patch adds new to Armv8.7 WFIT instruction which take one operand:

    WFIT <Xt>

Where:
    <Xt> is 64-bit name of the general-purpose source register, encoded in the
         "Rd" field.

For more details regarding WFIT (Wait For Interrupt with Timeout) instruction for
Armv8.7-a please refer to Arm A64 Instruction set documentation for Armv8-A
architecture profile, see document pages 570 of [0].

	[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Update docs.
	* testsuite/gas/aarch64/system-5.d: Update test with WFIT insn.
	* testsuite/gas/aarch64/system-5.s: Update test with WFIT insn.

opcodes/ChangeLog:

2020-10-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-tbl.h (struct aarch64_opcode): New instruction WFIT.
	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Regenerated.
	* aarch64-opc-2.c: Regenerated.
2020-10-30 10:31:38 +00:00
Przemyslaw Wirkus
dd4a72c859 aarch64: Add CSR PDEC instruction
This patch adds:
+ New feature +csre to -march command line.
+ New instruction CSR PDEC associated with CSRE feature.

Please note that CSRE system registers were already upstreamed. This patch
should finalize CSRE feature implementation.

CSRE feature adds CSR PDEC (Decrements Call stack pointer by the size of
a Call stack record) instruction. Although this instruction has operand
(PDEC) it's instruction's only operand. PDEC forces instruction field Rt
to be set to 0b1111. This results in fixed opcode of the instruction.

gas/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Update docs.
	* config/tc-aarch64.c (parse_csr_operand): New operand parser.
	(parse_operands): Call to CSR operand parser.
	* testsuite/gas/aarch64/csre_csr-invalid.d: New test.
	* testsuite/gas/aarch64/csre_csr-invalid.l: New test.
	* testsuite/gas/aarch64/csre_csr-invalid.s: New test.
	* testsuite/gas/aarch64/csre_csr.d: New test.
	* testsuite/gas/aarch64/csre_csr.s: New test.

include/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* opcode/aarch64.h (AARCH64_FEATURE_CSRE): New -march feature.
	(enum aarch64_opnd): New CSR instruction field AARCH64_OPND_CSRE_CSR.

opcodes/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c (aarch64_print_operand): CSR PDEC operand print-out.
	* aarch64-tbl.h (CSRE): New CSRE feature handler.
	(_CSRE_INSN): New CSRE instruction type.
	(struct aarch64_opcode): New 'csre' entry for a CSRE CLI feature.
	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Regenerated.
	* aarch64-opc-2.c: Regenerated.
2020-10-28 14:19:42 +00:00
Przemyslaw Wirkus
82503ca7ed aarch64: Add WFET instruction for Armv8.7-a
This patch adds new to Armv8.7 WFET instruction which take one operand:

    WFET <Xt>

Where:
    <Xt> is 64-bit name of the general-purpose source register, encoded in the
         "Rd" field.

For more details regarding WFET (Wait For Event with Timeout) instruction for
Armv8.7-a please refer to Arm A64 Instruction set documentation for Armv8-A
architecture profile, see document pages 565 of [0].

	[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Update docs.
	* testsuite/gas/aarch64/system-5.d: New test.
	* testsuite/gas/aarch64/system-5.s: New test.

opcodes/ChangeLog:

2020-10-27  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-tbl.h (struct aarch64_opcode): Add new WFET instruction encoding
	and operand description.
	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Regenerated.
	* aarch64-opc-2.c: Regenerated.
2020-10-28 14:12:37 +00:00
Przemyslaw Wirkus
fd195909ce aarch64: Add DSB instruction Armv8.7-a variant
This patch adds new variant (nXS) of DSB memory barrier instruction
available in Armv8.7-a. New nXS variant has different encoding in
comparison with pre Armv8.7-a DSB memory barrier variant thus new
instruction and new operand was added.

DSB memory nXS barrier variant specifies the limitation on the barrier
operation. Allowed values are:

	DSB SYnXS|#28
	DSB ISHnXS|#24
	DSB NSHnXS|#20
	DSB OSHnXS|#16

Please note that till now,  for barriers, barrier operation was encoded in
4-bit unsigned immediate CRm field (in the range 0 to 15).
For DSB memory nXS barrier variant, barrier operation is a 5-bit unsigned
assembly instruction immediate, encoded in instruction in two bits CRm<3:2>:

		CRm<3:2>  #imm
		  00       16
		  01       20
		  10       24
		  11       28

This patch extends current AArch64 barrier instructions with above mapping.

Notable patch changes include:
+ New DSB memory barrier variant encoding for Armv8.7-a.
+ New operand BARRIER_DSB_NXS for above instruction in order to
distinguish between existing and new DSB instruction flavour.
+ New set of DSB nXS barrier options.
+ New instruction inserter and extractor map between instruction
immediate 5-bit value and 2-bit CRm field of the instruction itself (see
FLD_CRm_dsb_nxs).
+ Regeneration of aarch64-[asm|dis|opc]-2.c files.
+ Test cases to cover new instruction assembling and disassembling.

For more details regarding DSB memory barrier instruction and its
Armv8.7-a flavour please refer to Arm A64 Instruction set documentation
for Armv8-A architecture profile, see document pages 132-133 of [0].

	[0]: https://developer.arm.com/docs/ddi0596/i

gas/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Docs update.
	* config/tc-aarch64.c (parse_operands): Add
	AARCH64_OPND_BARRIER_DSB_NXS handler.
	(md_begin): Add content of aarch64_barrier_dsb_nxs_options to
	aarch64_barrier_opt_hsh hash.
	* testsuite/gas/aarch64/system-4-invalid.d: New test.
	* testsuite/gas/aarch64/system-4-invalid.l: New test.
	* testsuite/gas/aarch64/system-4-invalid.s: New test.
	* testsuite/gas/aarch64/system-4.d: New test.
	* testsuite/gas/aarch64/system-4.s: New test.

include/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* opcode/aarch64.h (enum aarch64_opnd): New operand
	AARCH64_OPND_BARRIER_DSB_NXS.
	(aarch64_barrier_dsb_nxs_options): Declare DSB nXS options.

opcodes/ChangeLog:

2020-10-23  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-asm.c (aarch64_ins_barrier_dsb_nxs): New inserter.
	* aarch64-asm.h (AARCH64_DECL_OPD_INSERTER): New inserter
	ins_barrier_dsb_nx.
	* aarch64-dis.c (aarch64_ext_barrier_dsb_nxs): New extractor.
	* aarch64-dis.h (AARCH64_DECL_OPD_EXTRACTOR): New extractor
	ext_barrier_dsb_nx.
	* aarch64-opc.c (aarch64_print_operand): New options table
	aarch64_barrier_dsb_nxs_options.
	* aarch64-opc.h (enum aarch64_field_kind): New field name FLD_CRm_dsb_nxs.
	* aarch64-tbl.h (struct aarch64_opcode): Define DSB nXS barrier
	Armv8.7-a instruction.
	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Regenerated.
	* aarch64-opc-2.c: Regenerated.
2020-10-28 14:05:05 +00:00
Przemyslaw Wirkus
8926e54e3a aarch64: Add basic support for armv8.7-a architecture
This patch adds support for AArch64 -march=armv8.7-a command line option
in GAS.

Please note that this change ONLY extends -march= command line interface
with a new "armv8.7-a" option. Architectural changes like new instructions
will be added in following patches.

gas/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* NEWS: Docs update.
	* config/tc-aarch64.c (armv8.7-a): New arch.
	* doc/c-aarch64.texi (-march=armv8.7-a): Update docs.

include/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* opcode/aarch64.h (AARCH64_FEATURE_V8_7): New feature bitmask.
	(AARCH64_ARCH_V8_7): New arch feature set.

opcodes/ChangeLog:

2020-10-16  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-tbl.h (ARMV8_7): New macro.
2020-10-28 13:58:17 +00:00