diff options
author | Maciej W. Rozycki <macro@orcam.me.uk> | 2021-05-29 03:26:32 +0200 |
---|---|---|
committer | Maciej W. Rozycki <macro@orcam.me.uk> | 2021-05-29 03:26:32 +0200 |
commit | 9204ccd4b136e01457f6dfd2d62aaa98530ce740 (patch) | |
tree | 1e0bb744bfe15b40a4fc368be826232eae55ad85 /include | |
parent | a3fb396f2dc57f585a49091e12ec6c588c45e681 (diff) | |
download | binutils-9204ccd4b136e01457f6dfd2d62aaa98530ce740.zip binutils-9204ccd4b136e01457f6dfd2d62aaa98530ce740.tar.gz binutils-9204ccd4b136e01457f6dfd2d62aaa98530ce740.tar.bz2 |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/ChangeLog | 6 | ||||
-rw-r--r-- | include/opcode/mips.h | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index b97775e..d0cc5c4 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,5 +1,11 @@ 2021-05-29 Maciej W. Rozycki <macro@orcam.me.uk> + * opcode/mips.h: Document `g' and `y' operand codes. + (mips_reg_operand_type): Add OP_REG_CONTROL enumeration + constant. + +2021-05-29 Maciej W. Rozycki <macro@orcam.me.uk> + * opcode/mips.h: Complement change made to opcodes and remove references to the `g' regular MIPS ISA operand code. diff --git a/include/opcode/mips.h b/include/opcode/mips.h index 9fa9fcb..e0a6447 100644 --- a/include/opcode/mips.h +++ b/include/opcode/mips.h @@ -461,6 +461,10 @@ enum mips_reg_operand_type { also be used in some contexts. */ OP_REG_COPRO, + /* Coprocessor control registers $0-$31. Mnemonic names like c1_fcsr can + also be used in some contexts. */ + OP_REG_CONTROL, + /* Hardware registers $0-$31. Mnemonic names like hwr_cpunum can also be used in some contexts. */ OP_REG_HW, @@ -841,6 +845,7 @@ mips_opcode_32bit_p (const struct mips_opcode *mo) "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL) "P" 5 bit performance-monitor register (OP_*_PERFREG) "e" 5 bit vector register byte specifier (OP_*_VECBYTE) + "g" 5 bit control destination register (OP_*_RD) "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN) Macro instructions: @@ -899,6 +904,7 @@ mips_opcode_32bit_p (const struct mips_opcode *mo) "$" 1 bit load high flag (OP_*_MT_H) "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T) "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D) + "y" 5 bit control target register (OP_*_RT) "+t" 5 bit coprocessor 0 destination register (OP_*_RT) MCU ASE usage: @@ -1000,7 +1006,7 @@ mips_opcode_32bit_p (const struct mips_opcode *mo) "1234567890" "%[]<>(),+-:'@!#$*&\~" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdef hijkl opqrstuvwx z" + "abcdef hijkl opqrstuvwxyz" Extension character sequences used so far ("+" followed by the following), for quick reference when adding more: @@ -2277,6 +2283,7 @@ extern const int bfd_mips16_num_opcodes; "E" 5-bit target register (MICROMIPSOP_*_RT) "G" 5-bit source register (MICROMIPSOP_*_RS) "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL) + "g" 5-bit control source register (MICROMIPSOP_*_RS) Macro instructions: "A" general 32 bit expression @@ -2338,7 +2345,7 @@ extern const int bfd_mips16_num_opcodes; "12345678 0" "<>(),+-.@\^|~" "ABCDEFGHI KLMN RST V " - "abcd f hijklmnopqrstuvw yz" + "abcd fghijklmnopqrstuvw yz" Extension character sequences used so far ("+" followed by the following), for quick reference when adding more: |