* [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements
@ 2017-05-15 13:29 Maciej W. Rozycki
2017-05-15 13:30 ` [committed 1/5] MIPS16/GAS: Improve disallowed relocation operand error diagnostics Maciej W. Rozycki
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:29 UTC (permalink / raw)
To: binutils
Hi,
I have committed this small series of immediate operand error diagnostics
improvements for some cases of invalid MIPS assembly code, replacing terse
`invalid operands' or `bignum invalid' error messages produced with ones
providing more detailed information. See individual patch descriptions
for the details of changes made.
Maciej
^ permalink raw reply [flat|nested] 6+ messages in thread
* [committed 1/5] MIPS16/GAS: Improve disallowed relocation operand error diagnostics
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
@ 2017-05-15 13:30 ` Maciej W. Rozycki
2017-05-15 13:32 ` [committed 2/5] MIPS16/GAS: Improve non-immediate " Maciej W. Rozycki
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:30 UTC (permalink / raw)
To: binutils
Improve disallowed relocation operand error diagnostics for MIPS16 code
and make it match corresponding regular MIPS and microMIPS handling,
e.g:
$ cat sltu.s
sltu $2, %lo(foo)
$ as -o sltu.o sltu.s
sltu.s: Assembler messages:
sltu.s:1: Error: operand 2 must be constant `sltu $2,%lo(foo)'
$ as -mips16 -o sltu.o sltu.s
sltu.s: Assembler messages:
sltu.s:1: Error: invalid operands `sltu $2,%lo(foo)'
$
To do so call `match_not_constant' from `match_mips16_insn' whenever a
disallowed relocation operation has been noticed, like `match_const_int'
does, making reporting consistent:
$ as -mips16 -o sltu.o sltu.s
sltu.s: Assembler messages:
sltu.s:1: Error: operand 2 must be constant `sltu $2,%lo(foo)'
$
gas/
* config/tc-mips.c (match_mips16_insn): Call
`match_not_constant' for a disallowed relocation operation.
* testsuite/gas/mips/mips16-reloc-error.d: New test.
* testsuite/gas/mips/mips16-reloc-error.l: New stderr output.
* testsuite/gas/mips/mips16-reloc-error.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new test.
---
binutils-mips16-gas-not-const-err.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2017-05-12 08:47:14.978493693 +0100
+++ binutils/gas/config/tc-mips.c 2017-05-12 13:21:55.457157986 +0100
@@ -8259,7 +8259,10 @@ match_mips16_insn (struct mips_cl_insn *
been allowed to take relocation operators. */
if (offset_reloc[0] != BFD_RELOC_UNUSED
&& (ext_operand->size != 16 || c == '8'))
- return FALSE;
+ {
+ match_not_constant (&arg);
+ return FALSE;
+ }
relax_char = c;
continue;
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2017-05-12 08:45:42.614003991 +0100
+++ binutils/gas/testsuite/gas/mips/mips.exp 2017-05-12 13:21:55.470317153 +0100
@@ -967,6 +967,8 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "mips16-hilo-n32"
}
run_dump_test "mips16-hilo-match"
+ run_dump_test "mips16-reloc-error"
+
run_dump_test "delay"
run_dump_test "nodelay"
run_dump_test "mips4010"
Index: binutils/gas/testsuite/gas/mips/mips16-reloc-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reloc-error.d 2017-05-12 10:44:47.552787860 +0100
@@ -0,0 +1,3 @@
+#name: MIPS16 relocation errors
+#as: -32 -mips64r2
+#error-output: mips16-reloc-error.l
Index: binutils/gas/testsuite/gas/mips/mips16-reloc-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reloc-error.l 2017-05-12 08:50:06.106927914 +0100
@@ -0,0 +1,28 @@
+.*: Assembler messages:
+.*:11: Error: operand 3 must be constant `addiu \$3,\$2,%lo\(bar\)'
+.*:12: Error: operand 3 must be constant `daddiu \$3,\$2,%lo\(bar\)'
+.*:14: Error: operand 2 must be constant `slti \$3,%lo\(bar\)'
+.*:15: Error: operand 2 must be constant `sltiu \$3,%lo\(bar\)'
+.*:17: Error: operand 3 must be constant `sll \$3,\$2,%lo\(bar\)'
+.*:18: Error: operand 3 must be constant `sra \$3,\$2,%lo\(bar\)'
+.*:19: Error: operand 3 must be constant `srl \$3,\$2,%lo\(bar\)'
+.*:20: Error: operand 3 must be constant `dsll \$3,\$2,%lo\(bar\)'
+.*:21: Error: operand 2 must be constant `dsra \$3,%lo\(bar\)'
+.*:22: Error: operand 2 must be constant `dsrl \$3,%lo\(bar\)'
+.*:24: Error: operand 1 must be constant `break %lo\(bar\)'
+.*:25: Error: operand 1 must be constant `sdbbp %lo\(bar\)'
+.*:27: Error: invalid operands `b %lo\(bar\)'
+.*:28: Error: invalid operands `beqz \$3,%lo\(bar\)'
+.*:29: Error: invalid operands `bnez \$3,%lo\(bar\)'
+.*:30: Error: invalid operands `bteqz %lo\(bar\)'
+.*:31: Error: invalid operands `btnez %lo\(bar\)'
+.*:33: Error: invalid operands `jal %lo\(bar\)'
+.*:34: Error: invalid operands `jalx %lo\(bar\)'
+.*:36: Error: operand 3 must be constant `save \$31,\$16,%lo\(bar\)'
+.*:37: Error: operand 3 must be constant `restore \$31,\$16,%lo\(bar\)'
+.*:39: Error: operand 6 must be constant `asmacro 0,0,0,0,0,%lo\(bar\)'
+.*:40: Error: operand 5 must be constant `asmacro 0,0,0,0,%lo\(bar\),0'
+.*:41: Error: operand 4 must be constant `asmacro 0,0,0,%lo\(bar\),0,0'
+.*:42: Error: operand 3 must be constant `asmacro 0,0,%lo\(bar\),0,0,0'
+.*:43: Error: operand 2 must be constant `asmacro 0,%lo\(bar\),0,0,0,0'
+.*:44: Error: operand 1 must be constant `asmacro %lo\(bar\),0,0,0,0,0'
Index: binutils/gas/testsuite/gas/mips/mips16-reloc-error.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reloc-error.s 2017-05-12 08:50:06.127143451 +0100
@@ -0,0 +1,52 @@
+ .text
+
+ .set bar, 8
+
+ .ent foo
+ .set mips16
+foo:
+ li $2, %hi(bar)
+ sll $2, $2, 16
+
+ addiu $3, $2, %lo(bar)
+ daddiu $3, $2, %lo(bar)
+
+ slti $3, %lo(bar)
+ sltiu $3, %lo(bar)
+
+ sll $3, $2, %lo(bar)
+ sra $3, $2, %lo(bar)
+ srl $3, $2, %lo(bar)
+ dsll $3, $2, %lo(bar)
+ dsra $3, %lo(bar)
+ dsrl $3, %lo(bar)
+
+ break %lo(bar)
+ sdbbp %lo(bar)
+
+ b %lo(bar)
+ beqz $3, %lo(bar)
+ bnez $3, %lo(bar)
+ bteqz %lo(bar)
+ btnez %lo(bar)
+
+ jal %lo(bar)
+ jalx %lo(bar)
+
+ save $31, $16, %lo(bar)
+ restore $31, $16, %lo(bar)
+
+ asmacro 0, 0, 0, 0, 0, %lo(bar)
+ asmacro 0, 0, 0, 0, %lo(bar), 0
+ asmacro 0, 0, 0, %lo(bar), 0, 0
+ asmacro 0, 0, %lo(bar), 0, 0, 0
+ asmacro 0, %lo(bar), 0, 0, 0, 0
+ asmacro %lo(bar), 0, 0, 0, 0, 0
+
+ nop
+ .set nomips16
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
^ permalink raw reply [flat|nested] 6+ messages in thread
* [committed 2/5] MIPS16/GAS: Improve non-immediate operand error diagnostics
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
2017-05-15 13:30 ` [committed 1/5] MIPS16/GAS: Improve disallowed relocation operand error diagnostics Maciej W. Rozycki
@ 2017-05-15 13:32 ` Maciej W. Rozycki
2017-05-15 13:33 ` [committed 3/5] MIPS/GAS: Improve bignum " Maciej W. Rozycki
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:32 UTC (permalink / raw)
To: binutils
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.
---
binutils-mips16-gas-imm-expr-err.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2017-05-12 08:50:06.011338998 +0100
+++ binutils/gas/config/tc-mips.c 2017-05-12 13:21:38.503021351 +0100
@@ -8249,10 +8249,7 @@ match_mips16_insn (struct mips_cl_insn *
continue;
}
- /* We need the OT_INTEGER check because some MIPS16
- immediate variants are listed before the register ones. */
- if (arg.token->type != OT_INTEGER
- || !match_expression (&arg, &offset_expr, offset_reloc))
+ if (!match_expression (&arg, &offset_expr, offset_reloc))
return FALSE;
/* '8' is used for SLTI(U) and has traditionally not
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2017-05-12 08:50:06.052014835 +0100
+++ binutils/gas/testsuite/gas/mips/mips.exp 2017-05-12 12:30:41.601402566 +0100
@@ -968,6 +968,7 @@ if { [istarget mips*-*-vxworks*] } {
}
run_dump_test "mips16-hilo-match"
run_dump_test "mips16-reloc-error"
+ run_dump_test "mips16-reg-error"
run_dump_test "delay"
run_dump_test "nodelay"
Index: binutils/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l 2017-05-12 08:45:42.165299850 +0100
+++ binutils/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l 2017-05-12 08:50:14.629848395 +0100
@@ -45,7 +45,7 @@
.*:86: Warning: extended operand requested but not required
.*:88: Warning: extended operand requested but not required
.*:90: Error: opcode not supported on this processor: mips1 \(mips1\) `daddu\.e \$16,\$16,\$16'
-.*:91: Error: invalid operands `addu\.e \$16,\$16,\$16'
+.*:91: Error: operand 3 must be an immediate expression `addu\.e \$16,\$16,\$16'
.*:92: Error: opcode not supported on this processor: mips1 \(mips1\) `dsubu\.e \$16,\$16,\$16'
.*:93: Error: unrecognized extended version of MIPS16 opcode `subu\.e \$16,\$16,\$16'
.*:95: Error: unrecognized extended version of MIPS16 opcode `jr\.e \$16'
@@ -61,21 +61,21 @@
.*:113: Error: opcode not supported on this processor: mips1 \(mips1\) `jalrc\.e \$16'
.*:114: Error: opcode not supported on this processor: mips1 \(mips1\) `jalrc\.e \$31,\$16'
.*:115: Error: opcode not supported on this processor: mips1 \(mips1\) `sdbbp\.e 0'
-.*:116: Error: invalid operands `slt\.e \$16,\$16'
-.*:117: Error: invalid operands `sltu\.e \$16,\$16'
+.*:116: Error: operand 2 must be an immediate expression `slt\.e \$16,\$16'
+.*:117: Error: operand 2 must be an immediate expression `sltu\.e \$16,\$16'
.*:118: Error: unrecognized extended version of MIPS16 opcode `sllv\.e \$16,\$16'
-.*:119: Error: invalid operands `sll\.e \$16,\$16'
+.*:119: Error: operand 2 must be an immediate expression `sll\.e \$16,\$16'
.*:120: Error: unrecognized extended version of MIPS16 opcode `break\.e 0'
.*:121: Error: unrecognized extended version of MIPS16 opcode `srlv\.e \$16,\$16'
-.*:122: Error: invalid operands `srl\.e \$16,\$16'
+.*:122: Error: operand 2 must be an immediate expression `srl\.e \$16,\$16'
.*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16'
-.*:124: Error: invalid operands `sra\.e \$16,\$16'
+.*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16'
.*:125: Error: opcode not supported on this processor: mips1 \(mips1\) `dsrl\.e \$16,8'
.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e '
.*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31'
.*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0'
.*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e'
-.*:130: Error: invalid operands `cmp\.e \$16,\$16'
+.*:130: Error: operand 2 must be an immediate expression `cmp\.e \$16,\$16'
.*:131: Error: unrecognized extended version of MIPS16 opcode `neg\.e \$16,\$16'
.*:132: Error: unrecognized extended version of MIPS16 opcode `and\.e \$16,\$16'
.*:133: Error: unrecognized extended version of MIPS16 opcode `or\.e \$16,\$16'
Index: binutils/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l 2017-05-12 08:45:42.196014391 +0100
+++ binutils/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l 2017-05-12 08:50:14.637427052 +0100
@@ -44,8 +44,8 @@
.*:84: Warning: extended operand requested but not required
.*:86: Warning: extended operand requested but not required
.*:88: Warning: extended operand requested but not required
-.*:90: Error: invalid operands `daddu\.e \$16,\$16,\$16'
-.*:91: Error: invalid operands `addu\.e \$16,\$16,\$16'
+.*:90: Error: operand 3 must be an immediate expression `daddu\.e \$16,\$16,\$16'
+.*:91: Error: operand 3 must be an immediate expression `addu\.e \$16,\$16,\$16'
.*:92: Error: unrecognized extended version of MIPS16 opcode `dsubu\.e \$16,\$16,\$16'
.*:93: Error: unrecognized extended version of MIPS16 opcode `subu\.e \$16,\$16,\$16'
.*:95: Error: unrecognized extended version of MIPS16 opcode `jr\.e \$16'
@@ -61,21 +61,21 @@
.*:113: Error: opcode not supported on this processor: mips3 \(mips3\) `jalrc\.e \$16'
.*:114: Error: opcode not supported on this processor: mips3 \(mips3\) `jalrc\.e \$31,\$16'
.*:115: Error: opcode not supported on this processor: mips3 \(mips3\) `sdbbp\.e 0'
-.*:116: Error: invalid operands `slt\.e \$16,\$16'
-.*:117: Error: invalid operands `sltu\.e \$16,\$16'
+.*:116: Error: operand 2 must be an immediate expression `slt\.e \$16,\$16'
+.*:117: Error: operand 2 must be an immediate expression `sltu\.e \$16,\$16'
.*:118: Error: unrecognized extended version of MIPS16 opcode `sllv\.e \$16,\$16'
-.*:119: Error: invalid operands `sll\.e \$16,\$16'
+.*:119: Error: operand 2 must be an immediate expression `sll\.e \$16,\$16'
.*:120: Error: unrecognized extended version of MIPS16 opcode `break\.e 0'
.*:121: Error: unrecognized extended version of MIPS16 opcode `srlv\.e \$16,\$16'
-.*:122: Error: invalid operands `srl\.e \$16,\$16'
+.*:122: Error: operand 2 must be an immediate expression `srl\.e \$16,\$16'
.*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16'
-.*:124: Error: invalid operands `sra\.e \$16,\$16'
+.*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16'
.*:125: Warning: extended operand requested but not required
.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e '
.*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31'
.*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0'
.*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e'
-.*:130: Error: invalid operands `cmp\.e \$16,\$16'
+.*:130: Error: operand 2 must be an immediate expression `cmp\.e \$16,\$16'
.*:131: Error: unrecognized extended version of MIPS16 opcode `neg\.e \$16,\$16'
.*:132: Error: unrecognized extended version of MIPS16 opcode `and\.e \$16,\$16'
.*:133: Error: unrecognized extended version of MIPS16 opcode `or\.e \$16,\$16'
@@ -91,11 +91,11 @@
.*:143: Error: unrecognized extended version of MIPS16 opcode `mflo\.e \$16'
.*:144: Warning: extended operand requested but not required
.*:145: Error: unrecognized extended version of MIPS16 opcode `dsllv\.e \$16,\$16'
-.*:146: Error: invalid operands `dsll\.e \$16,\$16'
+.*:146: Error: operand 2 must be an immediate expression `dsll\.e \$16,\$16'
.*:147: Error: unrecognized extended version of MIPS16 opcode `dsrlv\.e \$16,\$16'
-.*:148: Error: invalid operands `dsrl\.e \$16,\$16'
+.*:148: Error: operand 2 must be an immediate expression `dsrl\.e \$16,\$16'
.*:149: Error: unrecognized extended version of MIPS16 opcode `dsrav\.e \$16,\$16'
-.*:150: Error: invalid operands `dsra\.e \$16,\$16'
+.*:150: Error: operand 2 must be an immediate expression `dsra\.e \$16,\$16'
.*:151: Error: unrecognized extended version of MIPS16 opcode `mult\.e \$16,\$16'
.*:152: Error: unrecognized extended version of MIPS16 opcode `multu\.e \$16,\$16'
.*:153: Error: unrecognized extended version of MIPS16 opcode `div\.e \$0,\$16,\$16'
Index: binutils/gas/testsuite/gas/mips/mips16-insn-e.l
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips16-insn-e.l 2017-05-12 08:45:42.216542188 +0100
+++ binutils/gas/testsuite/gas/mips/mips16-insn-e.l 2017-05-12 08:50:14.649753075 +0100
@@ -42,8 +42,8 @@
.*:84: Warning: extended operand requested but not required
.*:86: Warning: extended operand requested but not required
.*:88: Warning: extended operand requested but not required
-.*:90: Error: invalid operands `daddu\.e \$16,\$16,\$16'
-.*:91: Error: invalid operands `addu\.e \$16,\$16,\$16'
+.*:90: Error: operand 3 must be an immediate expression `daddu\.e \$16,\$16,\$16'
+.*:91: Error: operand 3 must be an immediate expression `addu\.e \$16,\$16,\$16'
.*:92: Error: unrecognized extended version of MIPS16 opcode `dsubu\.e \$16,\$16,\$16'
.*:93: Error: unrecognized extended version of MIPS16 opcode `subu\.e \$16,\$16,\$16'
.*:95: Error: unrecognized extended version of MIPS16 opcode `jr\.e \$16'
@@ -59,21 +59,21 @@
.*:113: Error: unrecognized extended version of MIPS16 opcode `jalrc\.e \$16'
.*:114: Error: unrecognized extended version of MIPS16 opcode `jalrc\.e \$31,\$16'
.*:115: Error: unrecognized extended version of MIPS16 opcode `sdbbp\.e 0'
-.*:116: Error: invalid operands `slt\.e \$16,\$16'
-.*:117: Error: invalid operands `sltu\.e \$16,\$16'
+.*:116: Error: operand 2 must be an immediate expression `slt\.e \$16,\$16'
+.*:117: Error: operand 2 must be an immediate expression `sltu\.e \$16,\$16'
.*:118: Error: unrecognized extended version of MIPS16 opcode `sllv\.e \$16,\$16'
-.*:119: Error: invalid operands `sll\.e \$16,\$16'
+.*:119: Error: operand 2 must be an immediate expression `sll\.e \$16,\$16'
.*:120: Error: unrecognized extended version of MIPS16 opcode `break\.e 0'
.*:121: Error: unrecognized extended version of MIPS16 opcode `srlv\.e \$16,\$16'
-.*:122: Error: invalid operands `srl\.e \$16,\$16'
+.*:122: Error: operand 2 must be an immediate expression `srl\.e \$16,\$16'
.*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16'
-.*:124: Error: invalid operands `sra\.e \$16,\$16'
+.*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16'
.*:125: Warning: extended operand requested but not required
.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e '
.*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31'
.*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0'
.*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e'
-.*:130: Error: invalid operands `cmp\.e \$16,\$16'
+.*:130: Error: operand 2 must be an immediate expression `cmp\.e \$16,\$16'
.*:131: Error: unrecognized extended version of MIPS16 opcode `neg\.e \$16,\$16'
.*:132: Error: unrecognized extended version of MIPS16 opcode `and\.e \$16,\$16'
.*:133: Error: unrecognized extended version of MIPS16 opcode `or\.e \$16,\$16'
@@ -89,11 +89,11 @@
.*:143: Error: unrecognized extended version of MIPS16 opcode `mflo\.e \$16'
.*:144: Warning: extended operand requested but not required
.*:145: Error: unrecognized extended version of MIPS16 opcode `dsllv\.e \$16,\$16'
-.*:146: Error: invalid operands `dsll\.e \$16,\$16'
+.*:146: Error: operand 2 must be an immediate expression `dsll\.e \$16,\$16'
.*:147: Error: unrecognized extended version of MIPS16 opcode `dsrlv\.e \$16,\$16'
-.*:148: Error: invalid operands `dsrl\.e \$16,\$16'
+.*:148: Error: operand 2 must be an immediate expression `dsrl\.e \$16,\$16'
.*:149: Error: unrecognized extended version of MIPS16 opcode `dsrav\.e \$16,\$16'
-.*:150: Error: invalid operands `dsra\.e \$16,\$16'
+.*:150: Error: operand 2 must be an immediate expression `dsra\.e \$16,\$16'
.*:151: Error: unrecognized extended version of MIPS16 opcode `mult\.e \$16,\$16'
.*:152: Error: unrecognized extended version of MIPS16 opcode `multu\.e \$16,\$16'
.*:153: Error: unrecognized extended version of MIPS16 opcode `div\.e \$0,\$16,\$16'
Index: binutils/gas/testsuite/gas/mips/mips16-reg-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reg-error.d 2017-05-12 10:44:40.893450740 +0100
@@ -0,0 +1,3 @@
+#name: MIPS16 register errors
+#as: -32 -mips64r2
+#error-output: mips16-reg-error.l
Index: binutils/gas/testsuite/gas/mips/mips16-reg-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reg-error.l 2017-05-12 08:50:14.676559595 +0100
@@ -0,0 +1,54 @@
+.*: Assembler messages:
+.*:6: Error: operand 2 must be an immediate expression `ld \$4,\$3\(\$2\)'
+.*:7: Error: operand 2 must be an immediate expression `ld \$4,\$3\(\$pc\)'
+.*:8: Error: operand 2 must be an immediate expression `ld \$4,\$3\(\$sp\)'
+.*:9: Error: operand 2 must be an immediate expression `lw \$4,\$3\(\$2\)'
+.*:10: Error: operand 2 must be an immediate expression `lw \$4,\$3\(\$pc\)'
+.*:11: Error: operand 2 must be an immediate expression `lw \$4,\$3\(\$sp\)'
+.*:12: Error: operand 2 must be an immediate expression `lwu \$4,\$3\(\$2\)'
+.*:13: Error: operand 2 must be an immediate expression `lh \$4,\$3\(\$2\)'
+.*:14: Error: operand 2 must be an immediate expression `lhu \$4,\$3\(\$2\)'
+.*:15: Error: operand 2 must be an immediate expression `lb \$4,\$3\(\$2\)'
+.*:16: Error: operand 2 must be an immediate expression `lbu \$4,\$3\(\$2\)'
+.*:18: Error: operand 2 must be an immediate expression `sd \$4,\$3\(\$2\)'
+.*:19: Error: operand 2 must be an immediate expression `sd \$4,\$3\(\$sp\)'
+.*:20: Error: operand 2 must be an immediate expression `sd \$ra,\$3\(\$sp\)'
+.*:21: Error: operand 2 must be an immediate expression `sw \$4,\$3\(\$2\)'
+.*:22: Error: operand 2 must be an immediate expression `sw \$4,\$3\(\$sp\)'
+.*:23: Error: operand 2 must be an immediate expression `sw \$ra,\$3\(\$sp\)'
+.*:24: Error: operand 2 must be an immediate expression `sh \$4,\$3\(\$2\)'
+.*:25: Error: operand 2 must be an immediate expression `sb \$4,\$3\(\$2\)'
+.*:27: Error: operand 2 must be an immediate expression `addiu \$3,\$2'
+.*:28: Error: operand 3 must be an immediate expression `addiu \$4,\$3,\$2'
+.*:29: Error: operand 3 must be an immediate expression `addiu \$3,\$pc,\$2'
+.*:30: Error: operand 2 must be an immediate expression `addiu \$sp,\$2'
+.*:31: Error: operand 3 must be an immediate expression `addiu \$3,\$sp,\$2'
+.*:33: Error: operand 2 must be an immediate expression `daddiu \$3,\$2'
+.*:34: Error: operand 3 must be an immediate expression `daddiu \$4,\$3,\$2'
+.*:35: Error: operand 3 must be an immediate expression `daddiu \$3,\$pc,\$2'
+.*:36: Error: operand 2 must be an immediate expression `daddiu \$sp,\$2'
+.*:37: Error: operand 3 must be an immediate expression `daddiu \$3,\$sp,\$2'
+.*:39: Error: operand 2 must be an immediate expression `slti \$3,\$2'
+.*:40: Error: operand 2 must be an immediate expression `sltiu \$3,\$2'
+.*:42: Error: operand 2 must be an immediate expression `cmpi \$3,\$2'
+.*:44: Error: operand 2 must be an immediate expression `li \$3,\$2'
+.*:46: Error: operand 3 must be an immediate expression `sll \$3,\$2,\$2'
+.*:47: Error: operand 3 must be an immediate expression `sra \$3,\$2,\$2'
+.*:48: Error: operand 3 must be an immediate expression `srl \$3,\$2,\$2'
+.*:49: Error: operand 3 must be an immediate expression `dsll \$3,\$2,\$2'
+.*:53: Error: operand 1 must be an immediate expression `break \$2'
+.*:54: Error: operand 1 must be an immediate expression `sdbbp \$2'
+.*:56: Error: operand 1 must be an immediate expression `b \$2'
+.*:57: Error: operand 2 must be an immediate expression `beqz \$3,\$2'
+.*:58: Error: operand 2 must be an immediate expression `bnez \$3,\$2'
+.*:59: Error: operand 1 must be an immediate expression `bteqz \$2'
+.*:60: Error: operand 1 must be an immediate expression `btnez \$2'
+.*:63: Error: operand 1 must be an immediate expression `jalx \$2'
+.*:65: Error: invalid operands `save \$31,\$16,\$2'
+.*:66: Error: invalid operands `restore \$31,\$16,\$2'
+.*:68: Error: operand 6 must be an immediate expression `asmacro 0,0,0,0,0,\$2'
+.*:69: Error: operand 5 must be an immediate expression `asmacro 0,0,0,0,\$2,0'
+.*:70: Error: operand 4 must be an immediate expression `asmacro 0,0,0,\$2,0,0'
+.*:71: Error: operand 3 must be an immediate expression `asmacro 0,0,\$2,0,0,0'
+.*:72: Error: operand 2 must be an immediate expression `asmacro 0,\$2,0,0,0,0'
+.*:73: Error: operand 1 must be an immediate expression `asmacro \$2,0,0,0,0,0'
Index: binutils/gas/testsuite/gas/mips/mips16-reg-error.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-reg-error.s 2017-05-12 08:50:14.700370220 +0100
@@ -0,0 +1,81 @@
+ .text
+
+ .ent foo
+ .set mips16
+foo:
+ ld $4, $3($2)
+ ld $4, $3($pc)
+ ld $4, $3($sp)
+ lw $4, $3($2)
+ lw $4, $3($pc)
+ lw $4, $3($sp)
+ lwu $4, $3($2)
+ lh $4, $3($2)
+ lhu $4, $3($2)
+ lb $4, $3($2)
+ lbu $4, $3($2)
+
+ sd $4, $3($2)
+ sd $4, $3($sp)
+ sd $ra, $3($sp)
+ sw $4, $3($2)
+ sw $4, $3($sp)
+ sw $ra, $3($sp)
+ sh $4, $3($2)
+ sb $4, $3($2)
+
+ addiu $3, $2
+ addiu $4, $3, $2
+ addiu $3, $pc, $2
+ addiu $sp, $2
+ addiu $3, $sp, $2
+
+ daddiu $3, $2
+ daddiu $4, $3, $2
+ daddiu $3, $pc, $2
+ daddiu $sp, $2
+ daddiu $3, $sp, $2
+
+ slti $3, $2
+ sltiu $3, $2
+
+ cmpi $3, $2
+ cmp $3, $2
+ li $3, $2
+
+ sll $3, $2, $2
+ sra $3, $2, $2
+ srl $3, $2, $2
+ dsll $3, $2, $2
+ dsra $3, $2
+ dsrl $3, $2
+
+ break $2
+ sdbbp $2
+
+ b $2
+ beqz $3, $2
+ bnez $3, $2
+ bteqz $2
+ btnez $2
+
+ jal $2
+ jalx $2
+
+ save $31, $16, $2
+ restore $31, $16, $2
+
+ asmacro 0, 0, 0, 0, 0, $2
+ asmacro 0, 0, 0, 0, $2, 0
+ asmacro 0, 0, 0, $2, 0, 0
+ asmacro 0, 0, $2, 0, 0, 0
+ asmacro 0, $2, 0, 0, 0, 0
+ asmacro $2, 0, 0, 0, 0, 0
+
+ nop
+ .set nomips16
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
Index: binutils/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l 2017-05-12 08:45:42.339522045 +0100
+++ binutils/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l 2017-05-12 08:50:14.710619402 +0100
@@ -43,7 +43,7 @@
.*:86: Warning: extended operand requested but not required
.*:88: Warning: extended operand requested but not required
.*:90: Error: opcode not supported on this processor: mips32 \(mips32\) `daddu\.e \$16,\$16,\$16'
-.*:91: Error: invalid operands `addu\.e \$16,\$16,\$16'
+.*:91: Error: operand 3 must be an immediate expression `addu\.e \$16,\$16,\$16'
.*:92: Error: opcode not supported on this processor: mips32 \(mips32\) `dsubu\.e \$16,\$16,\$16'
.*:93: Error: unrecognized extended version of MIPS16 opcode `subu\.e \$16,\$16,\$16'
.*:95: Error: unrecognized extended version of MIPS16 opcode `jr\.e \$16'
@@ -59,21 +59,21 @@
.*:113: Error: unrecognized extended version of MIPS16 opcode `jalrc\.e \$16'
.*:114: Error: unrecognized extended version of MIPS16 opcode `jalrc\.e \$31,\$16'
.*:115: Error: unrecognized extended version of MIPS16 opcode `sdbbp\.e 0'
-.*:116: Error: invalid operands `slt\.e \$16,\$16'
-.*:117: Error: invalid operands `sltu\.e \$16,\$16'
+.*:116: Error: operand 2 must be an immediate expression `slt\.e \$16,\$16'
+.*:117: Error: operand 2 must be an immediate expression `sltu\.e \$16,\$16'
.*:118: Error: unrecognized extended version of MIPS16 opcode `sllv\.e \$16,\$16'
-.*:119: Error: invalid operands `sll\.e \$16,\$16'
+.*:119: Error: operand 2 must be an immediate expression `sll\.e \$16,\$16'
.*:120: Error: unrecognized extended version of MIPS16 opcode `break\.e 0'
.*:121: Error: unrecognized extended version of MIPS16 opcode `srlv\.e \$16,\$16'
-.*:122: Error: invalid operands `srl\.e \$16,\$16'
+.*:122: Error: operand 2 must be an immediate expression `srl\.e \$16,\$16'
.*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16'
-.*:124: Error: invalid operands `sra\.e \$16,\$16'
+.*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16'
.*:125: Error: opcode not supported on this processor: mips32 \(mips32\) `dsrl\.e \$16,8'
.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e '
.*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31'
.*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0'
.*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e'
-.*:130: Error: invalid operands `cmp\.e \$16,\$16'
+.*:130: Error: operand 2 must be an immediate expression `cmp\.e \$16,\$16'
.*:131: Error: unrecognized extended version of MIPS16 opcode `neg\.e \$16,\$16'
.*:132: Error: unrecognized extended version of MIPS16 opcode `and\.e \$16,\$16'
.*:133: Error: unrecognized extended version of MIPS16 opcode `or\.e \$16,\$16'
^ permalink raw reply [flat|nested] 6+ messages in thread
* [committed 3/5] MIPS/GAS: Improve bignum operand error diagnostics
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
2017-05-15 13:30 ` [committed 1/5] MIPS16/GAS: Improve disallowed relocation operand error diagnostics Maciej W. Rozycki
2017-05-15 13:32 ` [committed 2/5] MIPS16/GAS: Improve non-immediate " Maciej W. Rozycki
@ 2017-05-15 13:33 ` Maciej W. Rozycki
2017-05-15 13:34 ` [committed 4/5] MIPS16/GAS: Improve non-constant " Maciej W. Rozycki
2017-05-15 13:35 ` [committed 5/5] MIPS16/GAS: Improve [32768,65535] out-of-range " Maciej W. Rozycki
4 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:33 UTC (permalink / raw)
To: binutils
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.
---
NB the "operand 2 out of range `addiu $2,($3)'" message seen in one of
the listings for microMIPS ADDIU is misleading and refers to an elided
base expression's offset matching the `mB' operand code. A generic
"invalid operands `addiu $2,($3)'" message would be better, like with
regular MIPS and MIPS16 assembly, as would better yet "operand 2 must be
an immediate expression `addiu $2,($3)'". However with the way base
expressions are handled this is somewhat tricky to achieve, so I'm leaving
it to a future change.
Maciej
binutils-mips-gas-bignum-range-err.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2017-05-12 18:53:29.000000000 +0100
+++ binutils/gas/config/tc-mips.c 2017-05-12 18:54:12.666693817 +0100
@@ -4856,7 +4856,10 @@ match_const_int (struct mips_arg_info *a
*value = ex.X_add_number;
else
{
- match_not_constant (arg);
+ if (r[0] == BFD_RELOC_UNUSED && ex.X_op == O_big)
+ match_out_of_range (arg);
+ else
+ match_not_constant (arg);
return FALSE;
}
return TRUE;
@@ -5062,6 +5065,12 @@ match_int_operand (struct mips_arg_info
if (!match_expression (arg, &offset_expr, offset_reloc))
return FALSE;
+ if (offset_expr.X_op == O_big)
+ {
+ match_out_of_range (arg);
+ return FALSE;
+ }
+
if (offset_reloc[0] != BFD_RELOC_UNUSED)
/* Relocation operators were used. Accept the argument and
leave the relocation value in offset_expr and offset_relocs
@@ -8261,6 +8270,12 @@ match_mips16_insn (struct mips_cl_insn *
return FALSE;
}
+ if (offset_expr.X_op == O_big)
+ {
+ match_out_of_range (&arg);
+ return FALSE;
+ }
+
relax_char = c;
continue;
}
Index: binutils/gas/testsuite/gas/mips/addiu-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/addiu-error.d 2017-05-12 18:54:13.064769532 +0100
@@ -0,0 +1,3 @@
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: addiu-error.l
Index: binutils/gas/testsuite/gas/mips/addiu-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/addiu-error.l 2017-05-12 18:54:13.220134489 +0100
@@ -0,0 +1,8 @@
+.*: Assembler messages:
+.*:5: Error: operand 2 out of range `addiu \$2,-32769'
+.*:6: Error: operand 2 out of range `addiu \$2,65536'
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
Index: binutils/gas/testsuite/gas/mips/addiu-error.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/addiu-error.s 2017-05-12 18:54:13.317226907 +0100
@@ -0,0 +1,11 @@
+# Source code used to test error diagnostics with the ADDIU instruction.
+
+ .text
+foo:
+ addiu $2, -32769
+ addiu $2, 65536
+ addiu $2, 0x10000000000000000
+ addiu $2, $3
+ addiu $2, ($3)
+ addiu $2, 0+$3
+ addiu $2, (($3))
Index: binutils/gas/testsuite/gas/mips/break-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/break-error.d 2017-05-12 18:54:13.780902075 +0100
@@ -0,0 +1,3 @@
+#name: MIPS BREAK errors
+#as: -32
+#error-output: break-error.l
Index: binutils/gas/testsuite/gas/mips/break-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/break-error.l 2017-05-12 18:54:13.844984679 +0100
@@ -0,0 +1,8 @@
+.*: Assembler messages:
+.*:5: Error: operand 1 out of range `break -1'
+.*:6: Error: operand 1 out of range `break 65536'
+.*:7: Error: operand 1 out of range `break 0x10000000000000000'
+.*:8: Error: operand 1 must be an immediate expression `break \$3'
+.*:9: Error: invalid operands `break \(\$3\)'
+.*:10: Error: register value used as expression `break 0\+\$3'
+.*:11: Error: register value used as expression `break \(\(\$3\)\)'
Index: binutils/gas/testsuite/gas/mips/break-error.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/break-error.s 2017-05-12 18:54:13.859235503 +0100
@@ -0,0 +1,11 @@
+# Source code used to test error diagnostics with the BREAK instruction.
+
+ .text
+foo:
+ break -1
+ break 65536
+ break 0x10000000000000000
+ break $3
+ break ($3)
+ break 0+$3
+ break (($3))
Index: binutils/gas/testsuite/gas/mips/lui-1.l
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/lui-1.l 2017-05-12 18:30:27.000000000 +0100
+++ binutils/gas/testsuite/gas/mips/lui-1.l 2017-05-12 18:54:13.889662562 +0100
@@ -1,7 +1,7 @@
.*\.s: Assembler messages:
.*\.s:5: Error: operand 2 out of range `lui \$2,-1'
.*\.s:6: Error: operand 2 out of range `lui \$2,65536'
-.*\.s:7: Error: bignum invalid
+.*\.s:7: Error: operand 2 out of range `lui \$2,0x10000000000000000'
.*\.s:8: Error: operand 2 must be an immediate expression `lui \$2,\$3'
.*\.s:9: Error: invalid operands `lui \$2,\(\$3\)'
.*\.s:10: Error: register value used as expression `lui \$2,0\+\$3'
Index: binutils/gas/testsuite/gas/mips/micromips@addiu-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/micromips@addiu-error.d 2017-05-12 18:54:13.978843752 +0100
@@ -0,0 +1,4 @@
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: micromips@addiu-error.l
+#source: addiu-error.s
Index: binutils/gas/testsuite/gas/mips/micromips@addiu-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/micromips@addiu-error.l 2017-05-12 18:54:14.000595979 +0100
@@ -0,0 +1,8 @@
+.*: Assembler messages:
+.*:5: Error: operand 2 out of range `addiu \$2,-32769'
+.*:6: Error: operand 2 out of range `addiu \$2,65536'
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: operand 2 out of range `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2017-05-12 18:53:29.000000000 +0100
+++ binutils/gas/testsuite/gas/mips/mips.exp 2017-05-12 18:54:14.026108362 +0100
@@ -1466,6 +1466,8 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test_arches "lui" [mips_arch_list_matching mips1]
run_dump_test_arches "lui-1" [mips_arch_list_matching mips1]
run_dump_test_arches "lui-2" [mips_arch_list_matching mips1]
+ run_dump_test_arches "addiu-error" [mips_arch_list_all]
+ run_dump_test_arches "break-error" [mips_arch_list_all]
run_dump_test "r5900"
run_dump_test "r5900-full"
Index: binutils/gas/testsuite/gas/mips/mips16@addiu-error.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16@addiu-error.d 2017-05-12 18:54:14.191127725 +0100
@@ -0,0 +1,4 @@
+#name: MIPS ADDIU errors
+#as: -32
+#error-output: mips16@addiu-error.l
+#source: addiu-error.s
Index: binutils/gas/testsuite/gas/mips/mips16@addiu-error.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16@addiu-error.l 2017-05-12 18:54:14.222948364 +0100
@@ -0,0 +1,8 @@
+.*: Assembler messages:
+.*:5: Error: operand value out of range for instruction
+.*:6: Error: operand value out of range for instruction
+.*:7: Error: operand 2 out of range `addiu \$2,0x10000000000000000'
+.*:8: Error: operand 2 must be an immediate expression `addiu \$2,\$3'
+.*:9: Error: invalid operands `addiu \$2,\(\$3\)'
+.*:10: Error: register value used as expression `addiu \$2,0\+\$3'
+.*:11: Error: register value used as expression `addiu \$2,\(\(\$3\)\)'
^ permalink raw reply [flat|nested] 6+ messages in thread
* [committed 4/5] MIPS16/GAS: Improve non-constant operand error diagnostics
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
` (2 preceding siblings ...)
2017-05-15 13:33 ` [committed 3/5] MIPS/GAS: Improve bignum " Maciej W. Rozycki
@ 2017-05-15 13:34 ` Maciej W. Rozycki
2017-05-15 13:35 ` [committed 5/5] MIPS16/GAS: Improve [32768,65535] out-of-range " Maciej W. Rozycki
4 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:34 UTC (permalink / raw)
To: binutils
Improve operand error diagnostics for non-constant expressions used for
a 16-bit immediate, making the message more descriptive and indicating
the offending operand, e.g.:
foo.s:1: Error: invalid operands `lui $2,foo-bar'
will show as:
foo.s:1: Error: operand 2 must be constant `lui $2,foo-bar'
This case does not currently trigger however, for two reasons.
First, for regular MIPS and microMIPS assembly in the case of no match
caused by `match_int_operand' here, the function is always called again
from `mips_ip' via `match_insns', `match_insn' and then `match_operand'
for the same opcode table's entry with `lax_match' set to TRUE, in which
case the attempt to match succeeds and no error is issued.
Second, in the case of MIPS16 assembly no call to `match_int_operand' is
made at all for 16-bit immediates, because such immediates are currently
only matched with extensible instructions, and these are handled in
`match_mips16_insn' via `match_expression' directly rather than via
`match_operand'.
This will change for MIPS16 code with MIPS16e2 support introduced, where
non-extensible instructions accepting 16-bit immediates will be added,
so make the case work well right from the start.
gas/
* config/tc-mips.c (match_int_operand): Call
`match_not_constant' before returning failure for a non-constant
16-bit immediate conditionally allowed.
---
binutils-mips-gas-int-not-const-err.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2017-05-12 13:49:05.778390286 +0100
+++ binutils/gas/config/tc-mips.c 2017-05-12 17:01:44.141609779 +0100
@@ -5082,7 +5082,10 @@ match_int_operand (struct mips_arg_info
/* Accept non-constant operands if no later alternative matches,
leaving it for the caller to process. */
if (!arg->lax_match)
- return FALSE;
+ {
+ match_not_constant (arg);
+ return FALSE;
+ }
offset_reloc[0] = BFD_RELOC_LO16;
return TRUE;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [committed 5/5] MIPS16/GAS: Improve [32768,65535] out-of-range operand error diagnostics
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
` (3 preceding siblings ...)
2017-05-15 13:34 ` [committed 4/5] MIPS16/GAS: Improve non-constant " Maciej W. Rozycki
@ 2017-05-15 13:35 ` Maciej W. Rozycki
4 siblings, 0 replies; 6+ messages in thread
From: Maciej W. Rozycki @ 2017-05-15 13:35 UTC (permalink / raw)
To: binutils
Improve out-of-range operand error diagnostics for invalid values in the
[32768,65535] range used for a signed 16-bit immediate, making the
message consistent with that used for other invalid values, e.g.:
foo.s:1: Error: operand 2 must be an immediate expression `addiu $2,$gp,32768'
foo.s:2: Error: invalid operands `lw $2,32768($gp)'
vs:
foo.s:3: Error: operand 3 out of range `addiu $2,$gp,-32769'
foo.s:4: Error: operand 2 out of range `lw $2,-32769($gp)'
This case does not currently trigger however, for two reasons.
First, for regular MIPS and microMIPS assembly in the case of no match
caused by `match_int_operand' here, the function is always called again
from `mips_ip' via `match_insns', `match_insn' and then `match_operand'
for the same opcode table's entry with `lax_match' set to TRUE, in which
case the attempt to match succeeds and no error is issued.
Second, in the case of MIPS16 assembly no call to `match_int_operand' is
made at all for signed 16-bit immediates, because such immediates are
currently only matched with extensible instructions, and these are
handled in `match_mips16_insn' via `match_expression' directly rather
than via `match_operand'.
This will change for MIPS16 code with MIPS16e2 support introduced, where
non-extensible instructions accepting signed 16-bit immediates will be
added, so make the case work well right from the start:
foo.s:1: Error: operand 3 out of range `addiu $2,$gp,32768'
foo.s:2: Error: operand 2 out of range `lw $2,32768($gp)'
gas/
* config/tc-mips.c (match_int_operand): Call
`match_out_of_range' before returning failure for 0x8000-0xffff
values conditionally allowed.
---
binutils-mips-gas-int-signed-err.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2017-05-09 00:23:40.200600956 +0100
+++ binutils/gas/config/tc-mips.c 2017-05-09 00:24:00.464924585 +0100
@@ -5091,7 +5091,10 @@ match_int_operand (struct mips_arg_info
{
max_val = ((1 << operand_base->size) - 1) << operand->shift;
if (!arg->lax_match && sval <= max_val)
- return FALSE;
+ {
+ match_out_of_range (arg);
+ return FALSE;
+ }
}
}
else
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-15 13:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 13:29 [committed 0/5] MIPS/GAS: Immediate operand error diagnostics improvements Maciej W. Rozycki
2017-05-15 13:30 ` [committed 1/5] MIPS16/GAS: Improve disallowed relocation operand error diagnostics Maciej W. Rozycki
2017-05-15 13:32 ` [committed 2/5] MIPS16/GAS: Improve non-immediate " Maciej W. Rozycki
2017-05-15 13:33 ` [committed 3/5] MIPS/GAS: Improve bignum " Maciej W. Rozycki
2017-05-15 13:34 ` [committed 4/5] MIPS16/GAS: Improve non-constant " Maciej W. Rozycki
2017-05-15 13:35 ` [committed 5/5] MIPS16/GAS: Improve [32768,65535] out-of-range " Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).