MIPS16/GAS: Improve non-immediate operand error diagnostics
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 15 May 2017 12:13:41 +0000 (13:13 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Mon, 15 May 2017 12:57:08 +0000 (13:57 +0100)
commit1a7bf198b67c4b99e9adeaeba38c6874ec354c12
tree6a0b0020d9a10360bae76f9328bf253eac8e7fdd
parente295202f606accec7623c961997a295a8e680247
MIPS16/GAS: Improve non-immediate operand error diagnostics

Improve non-immediate operand error diagnostics for extensible MIPS16
instructions and make it match corresponding regular MIPS and microMIPS
handling, e.g:

$ cat addiu.s
        addiu    $4, $3, $2
$ as -o addiu.o addiu.s
addiu.s: Assembler messages:
addiu.s:1: Error: operand 3 must be an immediate expression `addiu $4,$3,$2'
$ as -mips16 -o addiu.o addiu.s
addiu.s: Assembler messages:
addiu.s:1: Error: invalid operands `addiu $4,$3,$2'
$

To do so observe that for extensible MIPS16 instructions and a non-PC
relative operand this case is handled by an explicit OT_INTEGER check in
`match_mips16_insn' returning a failure right away and consequently
preventing a call to `match_expression' from being made.  As from commit
d436c1c2e889 ("Improve error reporting for register expressions"),
<https://sourceware.org/ml/binutils/2013-08/msg00134.html>, however the
check has become redundant as `match_expression' now only ever returns
success for OT_INTEGER argument tokens, and a special case of an OT_CHAR
`(' token already handled by `match_mips16_insn' just ahead of the
`match_expression' call.  Previously it also returned success for OT_REG
argument tokens.

Let the call to `match_expression' always happen then, yielding the same
failure for the affected cases, however with more accurate diagnostics
provided by the call making reporting consistent:

$ as -mips16 -o addiu.o addiu.s
addiu.s: Assembler messages:
addiu.s:1: Error: operand 3 must be an immediate expression `addiu $4,$3,$2'
$

gas/
* config/tc-mips.c (match_mips16_insn): Remove the explicit
OT_INTEGER check before the `match_expression' call.
* testsuite/gas/mips/mips16-insn-e.l: Adjust messages.
* testsuite/gas/mips/mips16-32@mips16-insn-e.l: Likewise.
* testsuite/gas/mips/mips16-64@mips16-insn-e.l: Likewise.
* testsuite/gas/mips/mips16e-32@mips16-insn-e.l: Likewise.
* testsuite/gas/mips/mips16-reg-error.d: New test.
* testsuite/gas/mips/mips16-reg-error.l: New stderr output.
* testsuite/gas/mips/mips16-reg-error.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new test.
gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l
gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l
gas/testsuite/gas/mips/mips16-insn-e.l
gas/testsuite/gas/mips/mips16-reg-error.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-reg-error.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-reg-error.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l
This page took 0.026323 seconds and 4 git commands to generate.