From: "Maciej W. Rozycki" <macro@imgtec.com>
To: <binutils@sourceware.org>
Subject: [committed] MIPS16/GAS: Fix forced size suffixes with argumentless instructions
Date: Fri, 23 Dec 2016 21:14:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.00.1612230358240.6743@tp.orcam.me.uk> (raw)
Correct the handling of `.e' and `.t' instruction size suffixes with
instruction mnemonics which are not followed by any text on the same
line, such as arguments or white space, e.g.:
$ cat test.s
.set mips16
foo:
entry.t # comment
entry.t
exit.t # comment
exit.t
nop.t # comment
nop.t
$ as -32 -o test.o test.s
test.s: Assembler messages:
test.s:4: Error: unrecognized opcode `entry.t'
test.s:6: Error: unrecognized opcode `exit.t'
test.s:8: Error: unrecognized opcode `nop.t'
$
gas/
* config/tc-mips.c (mips16_ip): Handle `.e' and `.t' instruction
suffixes followed by a null character rather than a space too.
* testsuite/gas/mips/mips16-insn-length-noargs.d: New test.
* testsuite/gas/mips/mips16-insn-length-noargs.s: New test
source.
* testsuite/gas/mips/mips.exp: Run the new test.
---
binutils-mips16-insn-length-noargs.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2016-12-23 03:13:06.674191846 +0000
+++ binutils/gas/config/tc-mips.c 2016-12-23 12:22:35.322349940 +0000
@@ -13859,13 +13859,14 @@ mips16_ip (char *str, struct mips_cl_ins
char *end, *s, c;
struct mips_opcode *first;
struct mips_operand_token *tokens;
-
- forced_insn_length = 0;
+ unsigned int l;
for (s = str; ISLOWER (*s); ++s)
;
end = s;
c = *end;
+
+ l = 0;
switch (c)
{
case '\0':
@@ -13876,23 +13877,27 @@ mips16_ip (char *str, struct mips_cl_ins
break;
case '.':
- if (s[1] == 't' && s[2] == ' ')
+ s++;
+ if (*s == 't')
{
- forced_insn_length = 2;
- s += 3;
- break;
+ l = 2;
+ s++;
}
- else if (s[1] == 'e' && s[2] == ' ')
+ else if (*s == 'e')
{
- forced_insn_length = 4;
- s += 3;
- break;
+ l = 4;
+ s++;
}
+ if (*s == '\0')
+ break;
+ else if (*s++ == ' ')
+ break;
/* Fall through. */
default:
set_insn_error (0, _("unrecognized opcode"));
return;
}
+ forced_insn_length = l;
*end = 0;
first = (struct mips_opcode *) hash_find (mips16_op_hash, str);
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2016-12-23 12:22:19.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips.exp 2016-12-23 12:22:41.734266518 +0000
@@ -1344,6 +1344,7 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "mips16-extend-swap"
run_dump_test "mips16-sprel-swap"
run_dump_test "mips16-sdrasp"
+ run_dump_test "mips16-insn-length-noargs"
run_dump_test "mips16-branch-unextended-1"
run_dump_test "mips16-branch-unextended-2"
Index: binutils/gas/testsuite/gas/mips/mips16-insn-length-noargs.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-insn-length-noargs.d 2016-12-23 12:22:41.765201649 +0000
@@ -0,0 +1,14 @@
+#objdump: -d --prefix-addresses --show-raw-insn
+#name: MIPS16 argumentless instruction size override
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> e809 entry
+[0-9a-f]+ <[^>]*> e809 entry
+[0-9a-f]+ <[^>]*> ef09 exit
+[0-9a-f]+ <[^>]*> ef09 exit
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
Index: binutils/gas/testsuite/gas/mips/mips16-insn-length-noargs.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-insn-length-noargs.s 2016-12-23 12:22:41.771640748 +0000
@@ -0,0 +1,12 @@
+ .set mips16
+foo:
+ entry.t # comment
+ entry.t
+ exit.t # comment
+ exit.t
+ nop.t # comment
+ nop.t
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
reply other threads:[~2016-12-23 21:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1612230358240.6743@tp.orcam.me.uk \
--to=macro@imgtec.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).