Commit Graph

3938 Commits

Author SHA1 Message Date
Cui,Lili
0cc7872125 [PATCH 1/2] Enable Intel AVX512_FP16 instructions
Intel AVX512 FP16 instructions use maps 3, 5 and 6. Maps 5 and 6 use 3 bits
in the EVEX.mmm field (0b101, 0b110). Map 5 is for instructions that were FP32
in map 1 (0Fxx). Map 6 is for instructions that were FP32 in map 2 (0F38xx).
There are some exceptions to this rule. Some things in map 1 (0Fxx) with imm8
operands predated our current conventions; those instructions moved to map 3.
FP32 things in map 3 (0F3Axx) found new opcodes in map3 for FP16 because map3
is very sparsely populated. Most of the FP16 instructions share opcodes and
prefix (EVEX.pp) bits with the related FP32 operations.

Intel AVX512 FP16 instructions has new displacements scaling rules, please refer
to the public software developer manual for detail information.

gas/

2021-08-05  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>
            Wei Xiao <wei3.xiao@intel.com>
            Lili Cui  <lili.cui@intel.com>

	* config/tc-i386.c (struct Broadcast_Operation): Adjust comment.
	(cpu_arch): Add .avx512_fp16.
	(cpu_noarch): Add noavx512_fp16.
	(pte): Add evexmap5 and evexmap6.
	(build_evex_prefix): Handle EVEXMAP5 and EVEXMAP6.
	(check_VecOperations): Handle {1to32}.
	(check_VecOperands): Handle CheckRegNumb.
	(check_word_reg): Handle Toqword.
	(i386_error): Add invalid_dest_and_src_register_set.
	(match_template): Handle invalid_dest_and_src_register_set.
	* doc/c-i386.texi: Document avx512_fp16, noavx512_fp16.

opcodes/

2021-08-05  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>
            Wei Xiao <wei3.xiao@intel.com>
            Lili Cui  <lili.cui@intel.com>

	* i386-dis.c (EXwScalarS): New.
	(EXxh): Ditto.
	(EXxhc): Ditto.
	(EXxmmqh): Ditto.
	(EXxmmqdh): Ditto.
	(EXEvexXwb): Ditto.
	(DistinctDest_Fixup): Ditto.
	(enum): Add xh_mode, evex_half_bcst_xmmqh_mode, evex_half_bcst_xmmqdh_mode
	and w_swap_mode.
	(enum): Add PREFIX_EVEX_0F3A08_W_0, PREFIX_EVEX_0F3A0A_W_0,
	PREFIX_EVEX_0F3A26, PREFIX_EVEX_0F3A27, PREFIX_EVEX_0F3A56,
	PREFIX_EVEX_0F3A57, PREFIX_EVEX_0F3A66, PREFIX_EVEX_0F3A67,
	PREFIX_EVEX_0F3AC2, PREFIX_EVEX_MAP5_10, PREFIX_EVEX_MAP5_11,
	PREFIX_EVEX_MAP5_1D, PREFIX_EVEX_MAP5_2A, PREFIX_EVEX_MAP5_2C,
	PREFIX_EVEX_MAP5_2D, PREFIX_EVEX_MAP5_2E, PREFIX_EVEX_MAP5_2F,
	PREFIX_EVEX_MAP5_51, PREFIX_EVEX_MAP5_58, PREFIX_EVEX_MAP5_59,
	PREFIX_EVEX_MAP5_5A_W_0, PREFIX_EVEX_MAP5_5A_W_1,
	PREFIX_EVEX_MAP5_5B_W_0, PREFIX_EVEX_MAP5_5B_W_1,
	PREFIX_EVEX_MAP5_5C, PREFIX_EVEX_MAP5_5D, PREFIX_EVEX_MAP5_5E,
	PREFIX_EVEX_MAP5_5F, PREFIX_EVEX_MAP5_78, PREFIX_EVEX_MAP5_79,
	PREFIX_EVEX_MAP5_7A, PREFIX_EVEX_MAP5_7B, PREFIX_EVEX_MAP5_7C,
	PREFIX_EVEX_MAP5_7D_W_0, PREFIX_EVEX_MAP6_13, PREFIX_EVEX_MAP6_56,
	PREFIX_EVEX_MAP6_57, PREFIX_EVEX_MAP6_D6, PREFIX_EVEX_MAP6_D7
	(enum): Add EVEX_MAP5 and EVEX_MAP6.
	(enum): Add EVEX_W_MAP5_5A, EVEX_W_MAP5_5B,
	EVEX_W_MAP5_78_P_0, EVEX_W_MAP5_78_P_2, EVEX_W_MAP5_79_P_0,
	EVEX_W_MAP5_79_P_2, EVEX_W_MAP5_7A_P_2, EVEX_W_MAP5_7A_P_3,
	EVEX_W_MAP5_7B_P_2, EVEX_W_MAP5_7C_P_0, EVEX_W_MAP5_7C_P_2,
	EVEX_W_MAP5_7D, EVEX_W_MAP6_13_P_0, EVEX_W_MAP6_13_P_2,
	(get_valid_dis386): Properly handle new instructions.
	(intel_operand_size): Handle new modes.
	(OP_E_memory): Ditto.
	(OP_EX): Ditto.
	* i386-dis-evex.h: Updated for AVX512_FP16.
	* i386-dis-evex-mod.h: Updated for AVX512_FP16.
	* i386-dis-evex-prefix.h: Updated for AVX512_FP16.
	* i386-dis-evex-reg.h : Updated for AVX512_FP16.
	* i386-dis-evex-w.h : Updated for AVX512_FP16.
	* i386-gen.c (cpu_flag_init): Add CPU_AVX512_FP16_FLAGS,
	and CPU_ANY_AVX512_FP16_FLAGS. Update CPU_ANY_AVX512F_FLAGS
	and CPU_ANY_AVX512BW_FLAGS.
	(cpu_flags): Add CpuAVX512_FP16.
	(opcode_modifiers): Add DistinctDest.
	* i386-opc.h (enum): (AVX512_FP16): New.
	(i386_opcode_modifier): Add reqdistinctreg.
	(i386_cpu_flags): Add cpuavx512_fp16.
	(EVEXMAP5): Defined as a macro.
	(EVEXMAP6): Ditto.
	* i386-opc.tbl: Add Intel AVX512_FP16 instructions.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Ditto.
2021-08-05 21:03:41 +08:00
Andreas Krebbel
a164bbda30 IBM Z: Remove lpswey parameter
opcodes/
	* s390-opc.c (INSTR_SIY_RD): New instruction format.
	(MASK_SIY_RD): New instruction mask.
	* s390-opc.txt: Change instruction format of lpswey to SIY_RD.

gas/
	* testsuite/gas/s390/zarch-arch14.d: Remove last operand of
	lpswey.
	* testsuite/gas/s390/zarch-arch14.s: Likewise.
2021-08-04 16:51:50 +02:00
Chenghua Xu
8d56b9fcf3 Correct gs264e bfd_mach in mips_arch_choices.
opcodes/
    * mips-dis.c (mips_arch_choices): Correct gs264e bfd_mach.
2021-07-27 09:18:27 +08:00
Andrea Corallo
5c43020d83 PATCH [9/10] arm: add 'pacg' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (T16_32_TAB): Add '_pacg'.
	(do_t_pacbti_pacg): New function.
	(insns): Define 'pacg' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Add 'pacg' test.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'pacg'.
2021-07-26 14:18:24 +02:00
Andrea Corallo
be05908c0c PATCH [8/10] arm: add 'autg' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (T16_32_TAB): Add '_autg'.
	(insns): Define 'autg' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Add autg test.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'autg'.
2021-07-26 14:18:24 +02:00
Andrea Corallo
e07352fa4f PATCH [7/10] arm: add 'bxaut' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (T16_32_TAB): Add '_bxaut'.
	(do_t_pacbti_nonop): New function.
	(insns): Define 'bxaut' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Add 'bxaut' test.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'bxaut'.
2021-07-26 14:18:24 +02:00
Andrea Corallo
ce537a7db7 PATCH [4/10] arm: add 'pac' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (T16_32_TAB): Add '_pac'.
	(insns): Add 'pac' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.l: Add pac tests.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.s: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'pac'.
2021-07-26 14:18:24 +02:00
Andrea Corallo
e43ca2cbae PATCH [3/10] arm: add 'aut' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (insns): Add 'aut.'
	(T16_32_TAB): Add '_aut'.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.l: Add 'aut' tests.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.s: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'aut'.
2021-07-26 14:18:24 +02:00
Andrea Corallo
f1e1d7f305 PATCH [2/10] arm: add 'pacbti' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c
	(enum operand_parse_code): Add OP_SP and OP_R12.
	(parse_operands): Add switch cases for OP_SP and OP_R12.
	(T16_32_TAB): Add '_pacbti'.
	(do_t_pacbti): New function.
	(insns): Add 'pacbti'.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.d: New file.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.l: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti-bad.s: Likewise.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: Add 'pacbti' to testcase.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add 'pacbti' instruction.
2021-07-26 14:18:24 +02:00
Andrea Corallo
3751264cdd PATCH [1/10] arm: add 'bti' instruction for Armv8.1-M pacbti extension
gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (insns): Add 'bti' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: New file.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add bti instruction.
2021-07-26 14:18:24 +02:00
Jan Beulich
0e4cc77316 x86: express unduly set rounding control bits in disassembly
While EVEX.L'L are indeed ignored when EVEX.b stands for just SAE,
EVEX.b itself is not ignored when an insn permits neither rounding
control nor SAE.

While changing this aspect of EVEX.b handling, also alter unduly set
embedded broadcast: Don't call BadOp(), screwing up subsequent
disassembly, but emit "{bad}" instead.
2021-07-23 08:03:21 +02:00
Jan Beulich
5fbe0f28ae x86: drop dq{b,d}_mode
Their sole use is for {,V}EXTRACTPS / {,V}P{EXT,INS}RB respectively; for
consistency also limit use of dqw_mode to Jdqw. 64-bit disassembly
reflecting REX.W / VEX.W is not in line with the assembler's opcode
table having NoRex64 / VexWIG in all respective templates, i.e. assembly
input isn't being honored there either. Obviously the 0FC5 encodings of
{,V}PEXTRW then also need adjustment for consistency reasons.
2021-07-22 13:09:21 +02:00
Jan Beulich
eb34d29be8 x86: drop vex_scalar_w_dq_mode
It has only a single use and can easily be represented by dq_mode
instead. Plus its handling in intel_operand_size() was duplicating
that of vex_vsib_{d,q}_w_dq_mode anyway.
2021-07-22 13:09:03 +02:00
Jan Beulich
c1d66d5f24 x86: drop xmm_m{b,w,d,q}_mode
They're effectively redundant with {b,w,d,q}_mode.
2021-07-22 13:08:39 +02:00
Jan Beulich
b0556968af x86: fold duplicate vector register printing code
The bulk of OP_XMM() can be easily reused also for OP_EX(). Break the
shared logic out of the function, and invoke the new helper from both
places.
2021-07-22 13:08:05 +02:00
Jan Beulich
605228fcaf x86: drop vex_mode and vex_scalar_mode
These are fully redundant with, respectively, x_mode and scalar_mode.
2021-07-22 13:07:42 +02:00
Jan Beulich
54ca11a48e x86: correct EVEX.V' handling outside of 64-bit mode
Unlike the high bit of VEX.vvvv / EVEX.vvvv, EVEX.V' is not ignored
outside of 64-bit mode. Oddly enough there already are tests for these
cases, but their expectations were wrong. (This may have been based on
an old SDM version, where the restriction wasn't properly spelled out.)
2021-07-22 13:07:27 +02:00
Jan Beulich
4454883ff0 x86: fold duplicate code in MOVSXD_Fixup()
There's no need to have two paths printing the "xd" mnemonic suffix.
2021-07-22 13:03:53 +02:00
Jan Beulich
5f6b8397a4 x86: fold duplicate register printing code
What so far was OP_E_register() can be easily reused also for OP_G().
Add suitable parameters to the function and move the invocation of
swap_operand() to OP_E(). Adjust MOVSXD's first operand: There never was
a need to use movsxd_mode there, and its use gets in the way of the code
folding.
2021-07-22 13:03:37 +02:00
Jan Beulich
bac11f2cfe x86-64: properly bounds-check %bnd<N> in OP_G()
The restriction to %bnd0-%bnd3 requires to also check REX.R is clear,
just like OP_E_Register() also includes REX.B in its check.
2021-07-22 13:03:16 +02:00
Jan Beulich
3fa77affb0 x86-64: generalize OP_G()'s EVEX.R' handling
EVEX.R' is invalid to be clear not only for mask registers, but also for
GPRs - IOW everything handled in this function.
2021-07-22 13:02:54 +02:00
Jan Beulich
be2f8fcd9d x86: correct VCVT{,U}SI2SD rounding mode handling
With EVEX.W clear the instruction doesn't ignore the rounding mode, but
(like for other insns without rounding semantics) EVEX.b set causes #UD.
Hence the handling of EVEX.W needs to be done when processing
evex_rounding_64_mode, not at the decode stages.

Derive a new 64-bit testcase from the 32-bit one to cover the different
EVEX.W treatment in both cases.
2021-07-22 13:02:08 +02:00
Jan Beulich
d0579d4d1c x86: drop OP_Mask()
By moving its vex.r check there it becomes fully redundant with OP_G().
2021-07-22 13:01:09 +02:00
H.J. Lu
154b353f68 x86: Add int1 as one byte opcode 0xf1
Also change the x86 disassembler to disassemble 0xf1 as int1, instead of
icebp.

gas/

	PR gas/28088
	* testsuite/gas/i386/opcode.s: Add int1.
	* testsuite/gas/i386/x86-64-opcode.s: Add int1, int3 and int.
	* testsuite/gas/i386/opcode-intel.d: Updated.
	* testsuite/gas/i386/opcode-suffix.d: Likewise.
	* testsuite/gas/i386/opcode.d: Likewise.
	* testsuite/gas/i386/x86-64-opcode.d: Likewise.

opcodes/

	PR gas/28088
	* i386-dis.c (dis386): Replace icebp with int1.
	* i386-opc.tbl: Add int1.
	* i386-tbl.h: Regenerate.
2021-07-14 14:29:02 -07:00
Andreas Krebbel
b180e8298b Add changelog entries for last commit 2021-07-07 14:17:05 +02:00
Andreas Krebbel
e4cc3b47ec IBM Z: Add another arch14 instruction
opcodes/

	* opcodes/s390-opc.txt: Add qpaci.

gas/

	* testsuite/gas/s390/zarch-arch14.d: Add qpaci.
	* testsuite/gas/s390/zarch-arch14.s: Add qpaci.
2021-07-07 14:11:43 +02:00
Nick Clifton
6e0dfbf420 Updated translations (mainly Ukranian and French) triggered by creation of 2.37 branch. 2021-07-05 15:54:35 +01:00
Nick Clifton
346d80ef33 Update version number and regenerate files 2021-07-03 15:16:48 +01:00
Nick Clifton
514192487e Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
Alan Modra
62194b631d Re: Fix minor NDS32 renaming snafu
Some extern declarations differ in constnes to their definitions too.
Let's make sure this sort of thing doesn't happen again, but putting
the externs in a header where they belong.

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

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

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

opcodes/ChangeLog:

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

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

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

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

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

The changes in this patch can be divided into:

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

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

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

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

include/ChangeLog:

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

opcodes/ChangeLog:

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

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

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

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

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

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

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

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

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

Update the testsuite accordingly.

References:

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

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

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

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

[5]  same

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

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

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

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

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

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

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

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

References:

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

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

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

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

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

  00:	42000010 	c0	0x10

to be produced rather than:

  00:	42000010 	rfe

even for ISA levels that do include the RFE instruction.

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

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

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

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

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

	cfc0	v0,c0_random

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

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

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

References:

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

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

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

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

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

	binutils/
	* testsuite/binutils-all/mips/mips-xpa-virt-1.d: Correct CFC0
	operand disassembly.
	* testsuite/binutils-all/mips/mips-xpa-virt-3.d: Likewise.
2021-05-29 03:26:32 +02:00