]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
MIPS16: Handle non-extensible instructions correctly
authorMaciej W. Rozycki <macro@imgtec.com>
Fri, 23 Dec 2016 16:49:42 +0000 (16:49 +0000)
committerMaciej W. Rozycki <macro@imgtec.com>
Fri, 23 Dec 2016 19:33:45 +0000 (19:33 +0000)
commit0674ee5dada21c8deec690ca66d5b2870f13ea49
tree2db467165d33ec3a9d2fb87e5caa63f292513171
parentb2805ed55456cea2694d31fc8627cca17120267b
MIPS16: Handle non-extensible instructions correctly

Identify non-extensible instructions in the MIPS16 opcode table and
disallow their use with the `.e' instruction size suffix in assembly and
do not interpret any EXTEND prefix present as a part of the instruction
in disassembly.

According to all versions of the MIPS16 ASE specifications the following
instructions encodings are not extensible [1][2][3][4][5][6]: I8/MOV32R,
I8/MOVR32, all RRR minor opcodes, all RR minor opcodes except from DSRA
and DSRL, and EXTEND itself, and as from revision 2.50 of the MIPS16e
ASE specifications it has been further clarified what was previously
implied, that non-extesiable instructions when preceded with an EXTEND
prefix must cause a Reserved Instruction exception [3][5].

Therefore in the presence of an EXTEND prefix none of these instructions
are supposed to be handled as extended instructions and supporting these
forms in disassembly causes confusion, and in the case of the RRR major
opcode it also clashes with the ASMACRO encoding.

References:

[1] "Product Description, MIPS16 Application-Specific Extension",
    Version 1.3, MIPS Technologies, Inc., 970130, Table 3. "MIPS16
    Instruction Set Summary", p. 5

[2] same, Table 5 "RR Minor Opcodes (RR-type instructions)", p.10

[3] "MIPS32 Architecture for Programmers, Volume IV-a: The MIPS16e
    Application-Specific Extension to the MIPS32 Architecture", MIPS
    Technologies, Inc., Document Number: MD00076, Revision 2.63, July
    16, 2013, Section 3.9 "MIPS16e Instruction Summaries", pp. 37-39

[4] same, Section 3.15 "Instruction Bit Encoding", pp. 46-49

[5] "MIPS64 Architecture for Programmers, Volume IV-a: The MIPS16e
    Application-Specific Extension to the MIPS64 Architecture", MIPS
    Technologies, Inc., Document Number: MD00077, Revision 2.60, June
    25, 2008, Section 1.9 "MIPS16e Instruction Summaries", pp. 38-41

[6] same, Section 1.15 "Instruction Bit Encoding", pp. 48-51

include/
* opcode/mips.h (INSN2_SHORT_ONLY): New macro.

gas/
* config/tc-mips.c (is_size_valid_16): Disallow a `.e' suffix
instruction size override for INSN2_SHORT_ONLY opcode table
entries.
* testsuite/gas/mips/mips16-extend-swap.d: Adjust output.
* testsuite/gas/mips/mips16-macro-e.l: Adjust error messages.
* testsuite/gas/mips/mips16-32@mips16-macro-e.l: Adjust error
messages.
* testsuite/gas/mips/mips16e-32@mips16-macro-e.l: Adjust error
messages.
* testsuite/gas/mips/mips16-insn-e.d: New test.
* testsuite/gas/mips/mips16-insn-t.d: New test.
* testsuite/gas/mips/mips16-32@mips16-insn-e.d: New test.
* testsuite/gas/mips/mips16-64@mips16-insn-e.d: New test.
* testsuite/gas/mips/mips16e-32@mips16-insn-e.d: New test.
* testsuite/gas/mips/mips16-32@mips16-insn-t.d: New test.
* testsuite/gas/mips/mips16-64@mips16-insn-t.d: New test.
* testsuite/gas/mips/mips16e-32@mips16-insn-t.d: New test.
* testsuite/gas/mips/mips16-insn-e.l: New stderr output.
* testsuite/gas/mips/mips16-insn-t.l: New stderr output.
* testsuite/gas/mips/mips16-32@mips16-insn-e.l: New stderr
output.
* testsuite/gas/mips/mips16-64@mips16-insn-e.l: New stderr
output.
* testsuite/gas/mips/mips16e-32@mips16-insn-e.l: New stderr
output.
* testsuite/gas/mips/mips16-32@mips16-insn-t.l: New stderr
output.
* testsuite/gas/mips/mips16-64@mips16-insn-t.l: New stderr
output.
* testsuite/gas/mips/mips16e-32@mips16-insn-t.l: New stderr
output.
* testsuite/gas/mips/mips16-insn-e.s: New test source.
* testsuite/gas/mips/mips16-insn-t.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

opcodes/
* mips-dis.c (print_insn_mips16): Disallow EXTEND prefix
matching for INSN2_SHORT_ONLY opcode table entries.
* mips16-opc.c (SH): New macro.
(mips16_opcodes): Set SH in `pinfo2' for non-extensible
instruction entries: "nop", "addu", "and", "break", "cmp",
"daddu", "ddiv", "ddivu", "div", "divu", "dmult", "dmultu",
"drem", "dremu", "dsllv", "dsll", "dsrav", "dsra", "dsrlv",
"dsrl", "dsubu", "exit", "entry", "jalr", "jal", "jr", "j",
"jalrc", "jrc", "mfhi", "mflo", "move", "mult", "multu", "neg",
"not", "or", "rem", "remu", "sllv", "sll", "slt", "sltu",
"srav", "sra", "srlv", "srl", "subu", "xor", "sdbbp", "seb",
"seh", "sew", "zeb", "zeh", "zew" and "extend".

binutils/
* testsuite/binutils-all/mips/mips16-extend-insn.d: New test.
* testsuite/binutils-all/mips/mips16-extend-insn.s: New test
source.
* testsuite/binutils-all/mips/mips.exp: Run the new tests.
34 files changed:
binutils/ChangeLog
binutils/testsuite/binutils-all/mips/mips.exp
binutils/testsuite/binutils-all/mips/mips16-extend-insn.d [new file with mode: 0644]
binutils/testsuite/binutils-all/mips/mips16-extend-insn.s [new file with mode: 0644]
gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-32@mips16-insn-e.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-32@mips16-insn-t.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-32@mips16-insn-t.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-32@mips16-macro-e.l
gas/testsuite/gas/mips/mips16-64@mips16-insn-e.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-64@mips16-insn-t.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-64@mips16-insn-t.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-extend-swap.d
gas/testsuite/gas/mips/mips16-insn-e.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-insn-e.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-insn-e.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-insn-t.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-insn-t.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-insn-t.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-macro-e.l
gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16e-32@mips16-insn-t.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16e-32@mips16-insn-t.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16e-32@mips16-macro-e.l
include/ChangeLog
include/opcode/mips.h
opcodes/ChangeLog
opcodes/mips-dis.c
opcodes/mips16-opc.c