* [committed] MIPS16/GAS: Clean up invalid unextended operand handling
@ 2016-12-23 22:46 Maciej W. Rozycki
0 siblings, 0 replies; only message in thread
From: Maciej W. Rozycki @ 2016-12-23 22:46 UTC (permalink / raw)
To: binutils
Bail out right away when an unextended instruction encoding is required
either with the use of a `.t' suffix or by means of `.set noautoextend',
however an operand supplied requires the extended instruction form to be
used.
This is to avoid messing up with the internal state of the assembler,
even though no actual failures are known to happen as a result. Add
test cases for the situation concerned.
gas/
* config/tc-mips.c (match_mips16_insn): Don't update
`forced_insn_length' or the instruction opcode if an operand
requires an extended instruction form, but an unextended one
has been requested.
* testsuite/gas/mips/mips16-relax-unextended-1.d: New test.
* testsuite/gas/mips/mips16-relax-unextended-2.d: New test.
* testsuite/gas/mips/mips16-relax-unextended-1.l: New stderr
output.
* testsuite/gas/mips/mips16-relax-unextended-2.l: New stderr
output.
* testsuite/gas/mips/mips16-relax-unextended-1.s: New test
source.
* testsuite/gas/mips/mips16-relax-unextended-2.s: New test
source.
* testsuite/gas/mips/mips.exp: Run the new tests.
---
binutils-mips16-gas-relax-unextended.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2016-12-23 12:23:18.325142980 +0000
+++ binutils/gas/config/tc-mips.c 2016-12-23 17:19:29.089239522 +0000
@@ -8138,8 +8138,11 @@ match_mips16_insn (struct mips_cl_insn *
{
if (required_insn_length == 2)
set_insn_error (0, _("invalid unextended operand value"));
- forced_insn_length = 4;
- insn->insn_opcode |= MIPS16_EXTEND;
+ else
+ {
+ forced_insn_length = 4;
+ insn->insn_opcode |= MIPS16_EXTEND;
+ }
}
else if (relax_char)
*offset_reloc = (int) BFD_RELOC_UNUSED + relax_char;
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2016-12-23 12:23:06.686260444 +0000
+++ binutils/gas/testsuite/gas/mips/mips.exp 2016-12-23 17:18:19.023806802 +0000
@@ -1352,6 +1352,8 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "mips16-branch-unextended-1"
run_dump_test "mips16-branch-unextended-2"
+ run_dump_test "mips16-relax-unextended-1"
+ run_dump_test "mips16-relax-unextended-2"
run_dump_test "mips16-jal-t"
run_dump_test "mips16-jal-e"
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.d 2016-12-23 12:23:21.363786910 +0000
@@ -0,0 +1,3 @@
+#name: MIPS16 relaxation with unextended instructions forced 1
+#as: -32
+#error-output: mips16-relax-unextended-1.l
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.l 2016-12-23 12:23:21.376208110 +0000
@@ -0,0 +1,49 @@
+.*: Assembler messages:
+.*:6: Error: invalid unextended operand value
+.*:8: Error: invalid unextended operand value
+.*:10: Error: invalid unextended operand value
+.*:13: Error: invalid unextended operand value
+.*:15: Error: invalid unextended operand value `lb\.t \$4,%hi\(baz\)\(\$5\)'
+.*:16: Error: invalid unextended operand value
+.*:23: Error: invalid unextended operand value
+.*:25: Error: invalid unextended operand value `sd\.t \$31,%lo\(baz\)\(\$29\)'
+.*:26: Error: invalid unextended operand value
+.*:28: Error: invalid unextended operand value `sd\.t \$4,%lo\(baz\)\(\$29\)'
+.*:31: Error: invalid unextended operand value
+.*:33: Error: invalid unextended operand value
+.*:35: Error: invalid unextended operand value `lh\.t \$6,%lo\(baz\)\(\$7\)'
+.*:36: Error: invalid unextended operand value
+.*:38: Error: invalid unextended operand value `addiu\.t \$29,%lo\(baz\)'
+.*:39: Error: invalid unextended operand value
+.*:41: Error: invalid unextended operand value `cmpi\.t \$2,%hi\(baz\)'
+.*:42: Error: invalid unextended operand value
+.*:44: Error: invalid unextended operand value `addiu\.t \$3,\$pc,%lo\(baz\)'
+.*:45: Error: invalid unextended operand value
+.*:47: Error: invalid unextended operand value `daddiu\.t \$4,\$pc,%lo\(baz\)'
+.*:49: Error: invalid unextended operand value
+.*:51: Error: invalid unextended operand value `daddiu\.t \$5,%lo\(baz\)'
+.*:52: Error: invalid unextended operand value
+.*:54: Error: invalid unextended operand value `addiu\.t \$2,%lo\(baz\)'
+.*:7: Error: invalid unextended operand value
+.*:9: Error: invalid unextended operand value
+.*:11: Error: invalid unextended operand value
+.*:14: Error: invalid unextended operand value
+.*:17: Error: invalid unextended operand value
+.*:19: Error: invalid unextended operand value
+.*:20: Error: invalid unextended operand value
+.*:21: Error: invalid unextended operand value
+.*:22: Error: invalid unextended operand value
+.*:24: Error: invalid unextended operand value
+.*:27: Error: invalid unextended operand value
+.*:29: Error: invalid unextended operand value
+.*:30: Error: invalid unextended operand value
+.*:32: Error: invalid unextended operand value
+.*:34: Error: invalid unextended operand value
+.*:37: Error: invalid unextended operand value
+.*:40: Error: invalid unextended operand value
+.*:43: Error: invalid unextended operand value
+.*:46: Error: invalid unextended operand value
+.*:50: Error: invalid unextended operand value
+.*:53: Error: invalid unextended operand value
+.*:55: Error: invalid unextended operand value
+.*:56: Error: invalid unextended operand value
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-1.s 2016-12-23 12:23:21.396873304 +0000
@@ -0,0 +1,58 @@
+ .module mips3
+ .set mips16
+ .set autoextend
+foo:
+ # Operand code:
+ sll.t $2, $3, 17 # <
+ sll.t $2, $3, bar
+ dsll.t $4, $5, 17 # [
+ dsll.t $4, $5, bar
+ dsrl.t $6, 17 # ]
+ dsrl.t $6, bar
+
+ lb.t $4, 0x1234($5) # 5
+ lb.t $4, bar($5)
+ lb.t $4, %hi(baz)($5)
+ slti.t $6, 0x5678 # 8
+ slti.t $6, bar
+
+ la.t $2, . + 0x1234 # A
+ la.t $2, . + bar
+ ld.t $3, . + 0x5678 # B
+ ld.t $3, . + bar
+ sd.t $31, 0x5678($29) # C
+ sd.t $31, bar($29)
+ sd.t $31, %lo(baz)($29)
+ sd.t $4, 0x5678($29) # D
+ sd.t $4, bar($29)
+ sd.t $4, %lo(baz)($29)
+ dla.t $5, . + 0x5678 # E
+ dla.t $5, . + bar
+ daddiu.t $2, $3, 0x5678 # F
+ daddiu.t $2, $3, bar
+ lh.t $6, 0x1234($7) # H
+ lh.t $6, bar($7)
+ lh.t $6, %lo(baz)($7)
+ addiu.t $29, 0x5678 # K
+ addiu.t $29, bar
+ addiu.t $29, %lo(baz)
+ cmpi.t $2, 0x1234 # U
+ cmpi.t $2, bar
+ cmpi.t $2, %hi(baz)
+ addiu.t $3, $pc, 0x5678 # V
+ addiu.t $3, $pc, bar
+ addiu.t $3, $pc, %lo(baz)
+ daddiu.t $4, $pc, 0x5678 # W
+ daddiu.t $4, $pc, bar
+ daddiu.t $4, $pc, %lo(baz)
+
+ daddiu.t $5, 0x5678 # j
+ daddiu.t $5, bar
+ daddiu.t $5, %lo(baz)
+ addiu.t $6, 0x1234 # k
+ addiu.t $6, bar
+ addiu.t $2, %lo(baz)
+ beqz.t $7, . + 0x5678 # p
+ b.t . + 0x1234 # q
+
+ .set bar, 0x5678
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.d 2016-12-23 12:23:21.414481241 +0000
@@ -0,0 +1,3 @@
+#name: MIPS16 relaxation with unextended instructions forced 2
+#as: -32
+#error-output: mips16-relax-unextended-2.l
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.l
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.l 2016-12-23 12:23:21.427077930 +0000
@@ -0,0 +1,49 @@
+.*: Assembler messages:
+.*:6: Error: invalid unextended operand value
+.*:8: Error: invalid unextended operand value
+.*:10: Error: invalid unextended operand value
+.*:13: Error: invalid unextended operand value
+.*:15: Error: invalid unextended operand value `lb \$4,%hi\(baz\)\(\$5\)'
+.*:16: Error: invalid unextended operand value
+.*:23: Error: invalid unextended operand value
+.*:25: Error: invalid unextended operand value `sd \$31,%lo\(baz\)\(\$29\)'
+.*:26: Error: invalid unextended operand value
+.*:28: Error: invalid unextended operand value `sd \$4,%lo\(baz\)\(\$29\)'
+.*:31: Error: invalid unextended operand value
+.*:33: Error: invalid unextended operand value
+.*:35: Error: invalid unextended operand value `lh \$6,%lo\(baz\)\(\$7\)'
+.*:36: Error: invalid unextended operand value
+.*:38: Error: invalid unextended operand value `addiu \$29,%lo\(baz\)'
+.*:39: Error: invalid unextended operand value
+.*:41: Error: invalid unextended operand value `cmpi \$2,%hi\(baz\)'
+.*:42: Error: invalid unextended operand value
+.*:44: Error: invalid unextended operand value `addiu \$3,\$pc,%lo\(baz\)'
+.*:45: Error: invalid unextended operand value
+.*:47: Error: invalid unextended operand value `daddiu \$4,\$pc,%lo\(baz\)'
+.*:49: Error: invalid unextended operand value
+.*:51: Error: invalid unextended operand value `daddiu \$5,%lo\(baz\)'
+.*:52: Error: invalid unextended operand value
+.*:54: Error: invalid unextended operand value `addiu \$2,%lo\(baz\)'
+.*:7: Error: invalid unextended operand value
+.*:9: Error: invalid unextended operand value
+.*:11: Error: invalid unextended operand value
+.*:14: Error: invalid unextended operand value
+.*:17: Error: invalid unextended operand value
+.*:19: Error: invalid unextended operand value
+.*:20: Error: invalid unextended operand value
+.*:21: Error: invalid unextended operand value
+.*:22: Error: invalid unextended operand value
+.*:24: Error: invalid unextended operand value
+.*:27: Error: invalid unextended operand value
+.*:29: Error: invalid unextended operand value
+.*:30: Error: invalid unextended operand value
+.*:32: Error: invalid unextended operand value
+.*:34: Error: invalid unextended operand value
+.*:37: Error: invalid unextended operand value
+.*:40: Error: invalid unextended operand value
+.*:43: Error: invalid unextended operand value
+.*:46: Error: invalid unextended operand value
+.*:50: Error: invalid unextended operand value
+.*:53: Error: invalid unextended operand value
+.*:55: Error: invalid unextended operand value
+.*:56: Error: invalid unextended operand value
Index: binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-relax-unextended-2.s 2016-12-23 12:23:21.442566453 +0000
@@ -0,0 +1,58 @@
+ .module mips3
+ .set mips16
+ .set noautoextend
+foo:
+ # Operand code:
+ sll $2, $3, 17 # <
+ sll $2, $3, bar
+ dsll $4, $5, 17 # [
+ dsll $4, $5, bar
+ dsrl $6, 17 # ]
+ dsrl $6, bar
+
+ lb $4, 0x1234($5) # 5
+ lb $4, bar($5)
+ lb $4, %hi(baz)($5)
+ slti $6, 0x5678 # 8
+ slti $6, bar
+
+ la $2, . + 0x1234 # A
+ la $2, . + bar
+ ld $3, . + 0x5678 # B
+ ld $3, . + bar
+ sd $31, 0x5678($29) # C
+ sd $31, bar($29)
+ sd $31, %lo(baz)($29)
+ sd $4, 0x5678($29) # D
+ sd $4, bar($29)
+ sd $4, %lo(baz)($29)
+ dla $5, . + 0x5678 # E
+ dla $5, . + bar
+ daddiu $2, $3, 0x5678 # F
+ daddiu $2, $3, bar
+ lh $6, 0x1234($7) # H
+ lh $6, bar($7)
+ lh $6, %lo(baz)($7)
+ addiu $29, 0x5678 # K
+ addiu $29, bar
+ addiu $29, %lo(baz)
+ cmpi $2, 0x1234 # U
+ cmpi $2, bar
+ cmpi $2, %hi(baz)
+ addiu $3, $pc, 0x5678 # V
+ addiu $3, $pc, bar
+ addiu $3, $pc, %lo(baz)
+ daddiu $4, $pc, 0x5678 # W
+ daddiu $4, $pc, bar
+ daddiu $4, $pc, %lo(baz)
+
+ daddiu $5, 0x5678 # j
+ daddiu $5, bar
+ daddiu $5, %lo(baz)
+ addiu $6, 0x1234 # k
+ addiu $6, bar
+ addiu $2, %lo(baz)
+ beqz $7, . + 0x5678 # p
+ b . + 0x1234 # q
+
+ .set bar, 0x5678
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-12-23 22:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-23 22:46 [committed] MIPS16/GAS: Clean up invalid unextended operand handling 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).