MIPS/GAS: Improve bignum operand error diagnostics
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 15 May 2017 12:17:18 +0000 (13:17 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Mon, 15 May 2017 12:57:09 +0000 (13:57 +0100)
commitc96425c560d640df9c416ff4e6a8c49c1f3b1119
tree88912e125b86687f549c886d5042bf262463a635
parent1a7bf198b67c4b99e9adeaeba38c6874ec354c12
MIPS/GAS: Improve bignum operand error diagnostics

Improve bignum operand error diagnostics for cases where a constant
would be accepted and report them as range errors, also indicating the
offending operand and instruction, e.g.:

$ cat bignum.s
addiu $2, 0x10000000000000000
break 0x10000000000000000
$ as -o bignum.o bignum.s
bignum.s:1: Error: bignum invalid
bignum.s:2: Error: operand 1 must be constant `break 0x10000000000000000'
$

now show as:

$ as -o bignum.o bignum.s
bignum.s:1: Error: operand 2 out of range `addiu $2,0x10000000000000000'
bignum.s:2: Error: operand 1 out of range `break 0x10000000000000000'
$

gas/
* config/tc-mips.c (match_const_int): Call `match_out_of_range'
rather than `match_not_constant' for unrelocated operands
retrieved as an `O_big' expression.
(match_int_operand): Call `match_out_of_range' for relocatable
operands retrieved as an `O_big' expression.
(match_mips16_insn): Call `match_out_of_range' for relaxable
operands retrieved as an `O_big' expression.
* testsuite/gas/mips/addiu-error.d: New test.
* testsuite/gas/mips/mips16@addiu-error.d: New test.
* testsuite/gas/mips/micromips@addiu-error.d: New test.
* testsuite/gas/mips/break-error.d: New test.
* testsuite/gas/mips/lui-1.l: Adjust error message.
* testsuite/gas/mips/addiu-error.l: New stderr output.
* testsuite/gas/mips/mips16@addiu-error.l: New stderr output.
* testsuite/gas/mips/micromips@addiu-error.l: New stderr output.
* testsuite/gas/mips/break-error.l: New stderr output.
* testsuite/gas/mips/addiu-error.s: New test source.
* testsuite/gas/mips/break-error.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
14 files changed:
gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/addiu-error.d [new file with mode: 0644]
gas/testsuite/gas/mips/addiu-error.l [new file with mode: 0644]
gas/testsuite/gas/mips/addiu-error.s [new file with mode: 0644]
gas/testsuite/gas/mips/break-error.d [new file with mode: 0644]
gas/testsuite/gas/mips/break-error.l [new file with mode: 0644]
gas/testsuite/gas/mips/break-error.s [new file with mode: 0644]
gas/testsuite/gas/mips/lui-1.l
gas/testsuite/gas/mips/micromips@addiu-error.d [new file with mode: 0644]
gas/testsuite/gas/mips/micromips@addiu-error.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16@addiu-error.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16@addiu-error.l [new file with mode: 0644]