From: Sagar Patel <sagarmp@cs.unc.edu>
To: Maciej Rozycki <macro@orcam.me.uk>
Cc: binutils@sourceware.org, Sagar Patel <sagarmp@cs.unc.edu>
Subject: [PATCH v2] MIPS/opcodes: Fix alias annotation for negate instructions
Date: Thu, 10 Mar 2022 11:32:40 -0500 [thread overview]
Message-ID: <20220310163238.26296-1-sagarmp@cs.unc.edu> (raw)
On both regular MIPS and microMIPS 32-bit, the NEG and NEGU assembly
instructions are idioms for SUB and SUBU respectively with the `rs'
operand equal to $0.
Add missing annotation to NEG and NEGU instructions, and create
corresponding test cases.
This fixes `objdump -d -M no-aliases'.
binutils/
* testsuite/binutils-all/mips/micromips-neg-alias.d: New test.
* testsuite/binutils-all/mips/micromips-neg-alias.s: New test
source.
* testsuite/binutils-all/mips/micromips-neg-noalias.d: New test.
* testsuite/binutils-all/mips/mips-neg-alias.d: New test.
* testsuite/binutils-all/mips/mips-neg-alias.s: New test source.
* testsuite/binutils-all/mips/mips-neg-noalias.d: New test.
* testsuite/binutils-all/mips/mips.exp: Run the new tests.
opcodes/
* mips-opc.c (mips_builtin_opcodes): Fix INSN2_ALIAS annotation
for "neg" and "negu" instructions.
* micromips-opc.c (micromips_opcodes): Likewise.
Signed-off-by: Sagar Patel <sagarmp@cs.unc.edu>
---
Hey,
Changes since v1:
- Remove `.set noreorder' from both new tests.
- Remove `.set mips2' from mips-neg-alias.s.
- Remove additions to both ChangeLogs.
I'm still waiting for hear back on the paperwork.
---Sagar Patel
---
.../binutils-all/mips/micromips-neg-alias.d | 13 +++++++++++++
.../binutils-all/mips/micromips-neg-alias.s | 13 +++++++++++++
.../binutils-all/mips/micromips-neg-noalias.d | 13 +++++++++++++
.../testsuite/binutils-all/mips/mips-neg-alias.d | 13 +++++++++++++
.../testsuite/binutils-all/mips/mips-neg-alias.s | 11 +++++++++++
.../testsuite/binutils-all/mips/mips-neg-noalias.d | 13 +++++++++++++
binutils/testsuite/binutils-all/mips/mips.exp | 4 ++++
opcodes/micromips-opc.c | 4 ++--
opcodes/mips-opc.c | 4 ++--
9 files changed, 84 insertions(+), 4 deletions(-)
create mode 100644 binutils/testsuite/binutils-all/mips/micromips-neg-alias.d
create mode 100644 binutils/testsuite/binutils-all/mips/micromips-neg-alias.s
create mode 100644 binutils/testsuite/binutils-all/mips/micromips-neg-noalias.d
create mode 100644 binutils/testsuite/binutils-all/mips/mips-neg-alias.d
create mode 100644 binutils/testsuite/binutils-all/mips/mips-neg-alias.s
create mode 100644 binutils/testsuite/binutils-all/mips/mips-neg-noalias.d
diff --git a/binutils/testsuite/binutils-all/mips/micromips-neg-alias.d b/binutils/testsuite/binutils-all/mips/micromips-neg-alias.d
new file mode 100644
index 00000000000..d2bbc00c503
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/micromips-neg-alias.d
@@ -0,0 +1,13 @@
+#PROG: objcopy
+#objdump: -d --prefix-addresses --show-raw-insn
+#name: microMIPS negate instruction alias disassembly
+#source: micromips-neg-alias.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 0020 0990 neg at,at
+[0-9a-f]+ <[^>]*> 0040 11d0 negu v0,v0
+[0-9a-f]+ <[^>]*> 0080 1990 neg v1,a0
+[0-9a-f]+ <[^>]*> 00a0 31d0 negu a2,a1
+ \.\.\.
diff --git a/binutils/testsuite/binutils-all/mips/micromips-neg-alias.s b/binutils/testsuite/binutils-all/mips/micromips-neg-alias.s
new file mode 100644
index 00000000000..b59ff9c57a5
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/micromips-neg-alias.s
@@ -0,0 +1,13 @@
+ .text
+ .set mips32r3
+ .set noat
+ .set micromips
+foo:
+ neg $1
+ negu $2
+ neg $3, $4
+ negu $6, $5
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
diff --git a/binutils/testsuite/binutils-all/mips/micromips-neg-noalias.d b/binutils/testsuite/binutils-all/mips/micromips-neg-noalias.d
new file mode 100644
index 00000000000..37f4bbd38de
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/micromips-neg-noalias.d
@@ -0,0 +1,13 @@
+#PROG: objcopy
+#objdump: -M no-aliases -d --prefix-addresses --show-raw-insn
+#name: microMIPS negate canonical alias disassembly
+#source: micromips-neg-alias.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 0020 0990 sub at,zero,at
+[0-9a-f]+ <[^>]*> 0040 11d0 subu v0,zero,v0
+[0-9a-f]+ <[^>]*> 0080 1990 sub v1,zero,a0
+[0-9a-f]+ <[^>]*> 00a0 31d0 subu a2,zero,a1
+ \.\.\.
diff --git a/binutils/testsuite/binutils-all/mips/mips-neg-alias.d b/binutils/testsuite/binutils-all/mips/mips-neg-alias.d
new file mode 100644
index 00000000000..d3da9343e8d
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/mips-neg-alias.d
@@ -0,0 +1,13 @@
+#PROG: objcopy
+#objdump: -m mips:3000 -d --prefix-addresses --show-raw-insn
+#name: MIPS1 negate instruction alias disassembly
+#source: mips-neg-alias.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 00010822 neg at,at
+[0-9a-f]+ <[^>]*> 00021023 negu v0,v0
+[0-9a-f]+ <[^>]*> 00041822 neg v1,a0
+[0-9a-f]+ <[^>]*> 00053023 negu a2,a1
+ \.\.\.
diff --git a/binutils/testsuite/binutils-all/mips/mips-neg-alias.s b/binutils/testsuite/binutils-all/mips/mips-neg-alias.s
new file mode 100644
index 00000000000..91167003324
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/mips-neg-alias.s
@@ -0,0 +1,11 @@
+ .text
+ .set noat
+foo:
+ neg $1
+ negu $2
+ neg $3, $4
+ negu $6, $5
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
diff --git a/binutils/testsuite/binutils-all/mips/mips-neg-noalias.d b/binutils/testsuite/binutils-all/mips/mips-neg-noalias.d
new file mode 100644
index 00000000000..02d993229c6
--- /dev/null
+++ b/binutils/testsuite/binutils-all/mips/mips-neg-noalias.d
@@ -0,0 +1,13 @@
+#PROG: objcopy
+#objdump: -M no-aliases -m mips:3000 -d --prefix-addresses --show-raw-insn
+#name: MIPS1 negate canonical alias disassembly
+#source: mips-neg-alias.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 00010822 sub at,zero,at
+[0-9a-f]+ <[^>]*> 00021023 subu v0,zero,v0
+[0-9a-f]+ <[^>]*> 00041822 sub v1,zero,a0
+[0-9a-f]+ <[^>]*> 00053023 subu a2,zero,a1
+ \.\.\.
diff --git a/binutils/testsuite/binutils-all/mips/mips.exp b/binutils/testsuite/binutils-all/mips/mips.exp
index b6fe11d85a5..c80d0ce819f 100644
--- a/binutils/testsuite/binutils-all/mips/mips.exp
+++ b/binutils/testsuite/binutils-all/mips/mips.exp
@@ -246,6 +246,10 @@ run_dump_test_o32 "mips32r6-branch-alias"
run_dump_test_o32 "mips32r6-branch-noalias"
run_dump_test_o32 "micromips-branch-alias"
run_dump_test_o32 "micromips-branch-noalias"
+run_dump_test_o32 "mips-neg-alias"
+run_dump_test_o32 "mips-neg-noalias"
+run_dump_test_o32 "micromips-neg-alias"
+run_dump_test_o32 "micromips-neg-noalias"
run_dump_test_o32 "mips-note-2"
run_dump_test_n32 "mips-note-2-n32"
diff --git a/opcodes/micromips-opc.c b/opcodes/micromips-opc.c
index 9393e22be5b..047b31e4cbb 100644
--- a/opcodes/micromips-opc.c
+++ b/opcodes/micromips-opc.c
@@ -914,8 +914,8 @@ const struct mips_opcode micromips_opcodes[] =
{"mult", "7,s,t", 0x00000cbc, 0xfc003fff, RD_2|RD_3|WR_a, 0, 0, D32, 0 },
{"multu", "s,t", 0x00009b3c, 0xfc00ffff, RD_1|RD_2|WR_HILO, 0, I1, 0, 0 },
{"multu", "7,s,t", 0x00001cbc, 0xfc003fff, RD_2|RD_3|WR_a, 0, 0, D32, 0 },
-{"neg", "d,w", 0x00000190, 0xfc1f07ff, WR_1|RD_2, 0, I1, 0, 0 }, /* sub 0 */
-{"negu", "d,w", 0x000001d0, 0xfc1f07ff, WR_1|RD_2, 0, I1, 0, 0 }, /* subu 0 */
+{"neg", "d,w", 0x00000190, 0xfc1f07ff, WR_1|RD_2, INSN2_ALIAS, I1, 0, 0 }, /* sub 0 */
+{"negu", "d,w", 0x000001d0, 0xfc1f07ff, WR_1|RD_2, INSN2_ALIAS, I1, 0, 0 }, /* subu 0 */
{"neg.d", "T,V", 0x54002b7b, 0xfc00ffff, WR_1|RD_2|FP_D, 0, I1, 0, 0 },
{"neg.s", "T,V", 0x54000b7b, 0xfc00ffff, WR_1|RD_2|FP_S, 0, I1, 0, 0 },
{"neg.ps", "T,V", 0x54004b7b, 0xfc00ffff, WR_1|RD_2|FP_D, 0, I1, 0, 0 },
diff --git a/opcodes/mips-opc.c b/opcodes/mips-opc.c
index 329bdc628cb..c351809cc1f 100644
--- a/opcodes/mips-opc.c
+++ b/opcodes/mips-opc.c
@@ -1620,8 +1620,8 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"multu1", "d,s,t", 0x70000019, 0xfc0007ff, WR_1|RD_2|RD_3|WR_HILO|IS_M, 0, EE, 0, 0 },
{"mulu", "d,v,t", 0x00000099, 0xfc0007ff, WR_1|RD_2|RD_3, 0, I37, 0, 0},
{"mulu", "d,s,t", 0x00000059, 0xfc0007ff, WR_1|RD_2|RD_3|WR_HILO, 0, N5, 0, 0 },
-{"neg", "d,w", 0x00000022, 0xffe007ff, WR_1|RD_2, 0, I1, 0, 0 }, /* sub 0 */
-{"negu", "d,w", 0x00000023, 0xffe007ff, WR_1|RD_2, 0, I1, 0, 0 }, /* subu 0 */
+{"neg", "d,w", 0x00000022, 0xffe007ff, WR_1|RD_2, INSN2_ALIAS, I1, 0, 0 }, /* sub 0 */
+{"negu", "d,w", 0x00000023, 0xffe007ff, WR_1|RD_2, INSN2_ALIAS, I1, 0, 0 }, /* subu 0 */
{"neg.d", "D,V", 0x46200007, 0xffff003f, WR_1|RD_2|FP_D, 0, I1, 0, SF },
{"neg.s", "D,V", 0x46000007, 0xffff003f, WR_1|RD_2|FP_S, 0, I1, 0, 0 },
{"neg.ps", "D,V", 0x46c00007, 0xffff003f, WR_1|RD_2|FP_D, 0, I5_33|IL2F, 0, I37 },
--
2.25.1
reply other threads:[~2022-03-10 16:33 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=20220310163238.26296-1-sagarmp@cs.unc.edu \
--to=sagarmp@cs.unc.edu \
--cc=binutils@sourceware.org \
--cc=macro@orcam.me.uk \
/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).