aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-05-15 13:13:41 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-05-15 13:57:08 +0100
commit1a7bf198b67c4b99e9adeaeba38c6874ec354c12 (patch)
tree6a0b0020d9a10360bae76f9328bf253eac8e7fdd /gas
parente295202f606accec7623c961997a295a8e680247 (diff)
downloadfsf-binutils-gdb-1a7bf198b67c4b99e9adeaeba38c6874ec354c12.zip
fsf-binutils-gdb-1a7bf198b67c4b99e9adeaeba38c6874ec354c12.tar.gz
fsf-binutils-gdb-1a7bf198b67c4b99e9adeaeba38c6874ec354c12.tar.bz2
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.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog13
-rw-r--r--gas/config/tc-mips.c5
-rw-r--r--gas/testsuite/gas/mips/mips.exp1
-rw-r--r--gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l14
-rw-r--r--gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l22
-rw-r--r--gas/testsuite/gas/mips/mips16-insn-e.l22
-rw-r--r--gas/testsuite/gas/mips/mips16-reg-error.d3
-rw-r--r--gas/testsuite/gas/mips/mips16-reg-error.l54
-rw-r--r--gas/testsuite/gas/mips/mips16-reg-error.s81
-rw-r--r--gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l14
10 files changed, 189 insertions, 40 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 65a4577..544ff7a 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,18 @@
2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
+ * 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.
+
+2017-05-15 Maciej W. Rozycki <macro@imgtec.com>
+
* 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.
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 0932cea..ac4fefd 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -8249,10 +8249,7 @@ match_mips16_insn (struct mips_cl_insn *insn, const struct mips_opcode *opcode,
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
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index c0bdd77..de38a1c 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -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"
diff --git a/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l
index 0d43204..d0a305d 100644
--- a/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l
+++ b/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l
@@ -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'
diff --git a/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l
index 3cf4de7..62f3979 100644
--- a/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l
+++ b/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l
@@ -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'
diff --git a/gas/testsuite/gas/mips/mips16-insn-e.l b/gas/testsuite/gas/mips/mips16-insn-e.l
index 3ac944e..0527389 100644
--- a/gas/testsuite/gas/mips/mips16-insn-e.l
+++ b/gas/testsuite/gas/mips/mips16-insn-e.l
@@ -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'
diff --git a/gas/testsuite/gas/mips/mips16-reg-error.d b/gas/testsuite/gas/mips/mips16-reg-error.d
new file mode 100644
index 0000000..9ef6064
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-reg-error.d
@@ -0,0 +1,3 @@
+#name: MIPS16 register errors
+#as: -32 -mips64r2
+#error-output: mips16-reg-error.l
diff --git a/gas/testsuite/gas/mips/mips16-reg-error.l b/gas/testsuite/gas/mips/mips16-reg-error.l
new file mode 100644
index 0000000..357cd8c
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-reg-error.l
@@ -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'
diff --git a/gas/testsuite/gas/mips/mips16-reg-error.s b/gas/testsuite/gas/mips/mips16-reg-error.s
new file mode 100644
index 0000000..cb24e51
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16-reg-error.s
@@ -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
diff --git a/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l b/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l
index 2c53785..4ec4797 100644
--- a/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l
+++ b/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l
@@ -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'