From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id 1C4A23858D39 for ; Thu, 10 Mar 2022 16:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C4A23858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.unc.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.unc.edu Received: by mail-qt1-x829.google.com with SMTP id h5so5050687qtb.7 for ; Thu, 10 Mar 2022 08:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.unc.edu; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/kFEYp+lrF+hBB+lDZQ0SvMwMw9oXOIZBHAPYCNqBLw=; b=b3ckxVr/nN/Wtw35Se4b8OkJE3JWgYRmmotUDHiHhxq0oW5nzxNl42MjhVEKZq7Air sRHsZs5pcUE/s2c1ITHWGZl1VbbOkaCbnkSleubPEI4g2xUPYKgcn8RpWKpkExVvYYgg oIxNAU0mzaM//YBtsmys1ZrqLDzbM4OeVN0V9CcAkRe53wpsb/J+lcrKCzRX9tJw9ySZ F7+RGPrrqsRelVTbz49owOWpi4kKdLcWeSqCAD8Sn3Iimt5LEAI5afOAJnRrCyUyrMYS 4cKu8WxctfcGc167ZjNubJSi3hf5E2aublayq0TjtyLiiEfI0gs3WhwbrhFAJo4wFEvn Sg8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/kFEYp+lrF+hBB+lDZQ0SvMwMw9oXOIZBHAPYCNqBLw=; b=VDmHOBviRITHhi+pSPEKaKOrLjnVgUaRM+WxXsK+nBQxLEi561K76t4tC2tmwrKWHc L725OzXs0Avc2rJZyKrLGMCQJeKTb1p8m9gBgfwmY+rgnhmf6NYafPmvwRBRIKwAR/Vl aGBvNDCcJnEWLcPj9Y145HmO9FVdpqcF/+QAq6PnHpW5xuZOhjd+lH/2YGLxk2nu6tjb 11UnGrzEOzEwz1ov9npMt2HRSV/a+dysh1PwlKh903vcqcfi8XZykkxDz6FkEKA9znaZ 8fv9ydOhVmFxKkehp84+bOxG+1RkpLB70JLBv2zOjz76u0K1/Oo+Wh3KwSsqErksaPks pbPw== X-Gm-Message-State: AOAM530eSYzkdhQxKjaWOgMRnGyj61LCxLHR6irD6LUbagyCCPqfWdQn XTJwgq1Vq/dMIAoctGPSCcMif7F80a9NvecX X-Google-Smtp-Source: ABdhPJyIaRLcqnTYjoKvo1hqOQjUNdeUKuuC4isE6CGffJ1X6q5IpwQozdZovCTzo6RuBgL6zyDT7A== X-Received: by 2002:a05:622a:8:b0:2e0:6694:e130 with SMTP id x8-20020a05622a000800b002e06694e130mr4548838qtw.620.1646929992316; Thu, 10 Mar 2022 08:33:12 -0800 (PST) Received: from localhost.localdomain (rrcs-96-10-115-230.se.biz.rr.com. [96.10.115.230]) by smtp.gmail.com with ESMTPSA id m10-20020a05622a054a00b002e049ff99f2sm3528812qtx.7.2022.03.10.08.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 08:33:11 -0800 (PST) From: Sagar Patel To: Maciej Rozycki Cc: binutils@sourceware.org, Sagar Patel Subject: [PATCH v2] MIPS/opcodes: Fix alias annotation for negate instructions Date: Thu, 10 Mar 2022 11:32:40 -0500 Message-Id: <20220310163238.26296-1-sagarmp@cs.unc.edu> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2022 16:33:15 -0000 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 --- 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