From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by sourceware.org (Postfix) with ESMTPS id 78E98385842F for ; Mon, 7 Mar 2022 15:18:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 78E98385842F 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-x830.google.com with SMTP id bt3so13534192qtb.0 for ; Mon, 07 Mar 2022 07:18:59 -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; bh=fVWU9Z6FylEpJ5udG7H6vqClMxwrWUFCxvIJEt39lAU=; b=Rj4kjhK8acu0EtcAPLpW1uHjudRonkBKTLIYdW/mMWneudipnA1hFp8IifZ5E0ZeUY S4F0inZLcvYFRhdcPIJeR48cmXlj+aBdxbAvChONMQgwU3DIOVzPOV/6/Ya54u2Wbj9C hbxzEg3lbJHY9Puy1RilIXCdGWpXS1OSBqT6E18BniFNQBpbZBxa8uVjYoSrxZ5SiDWv 0Bnt8B3j8zKxDJGjqrMtSIlAhZAfvkzW4AUi15zMbZdEOg9AcRV1noN8Hsw5jxDRXer/ NAy9zO/6plb2N/iVNBtAC3mgM3KqSoOjdOzh9yv3inzcc2Zvc+GtOHy1qzSa4bTH1du/ X2Kg== 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; bh=fVWU9Z6FylEpJ5udG7H6vqClMxwrWUFCxvIJEt39lAU=; b=bER0EzAOYgsSN1aECp57m2WwTYPWvEy14kuRkfjeXzOc+rrWdLNjpwY0olnxtAi2zp LiXOT0/6H29feI7WfdySoryQwg3gHro1o5j0Y9Ifjq2l4OrCOpd2cwXVbdJRYPlD2tCf rb8jUphWs/XAk9aWUc5PthzD4MZOD2dEU7TQHUJ9KfuK32d5zLcRRcNZvH/NHP0Mb2h2 lE9bnNMqC/JEK887oGXV2T0FV6PmFu7uxVujlVg8XB66Ybcj2hNII8ofeGpaU2m3uCH+ PXwDke5GYcMjSvzt7iTqo1dthQ3a0Rikr7O77XWXtKjInqPhSv5ibPM86+e5YC6lpTAR eVEg== X-Gm-Message-State: AOAM5332RS5CnA7Xp6ECobIi69NrtlO5bXFHs/QtvZCNUp/toz6qbW7H U6t8zBA34ZVGiXsVeADJHlfYU0fxGFH8VQ== X-Google-Smtp-Source: ABdhPJwD7XMoKboBNCSMAb0IpHpNoFE4jTu1Yo8msN6AsKNbfnNhkQLluKl/5PNkhheQMvGLaYjNKg== X-Received: by 2002:ac8:5dce:0:b0:2e0:67f8:132d with SMTP id e14-20020ac85dce000000b002e067f8132dmr4049661qtx.417.1646666338902; Mon, 07 Mar 2022 07:18:58 -0800 (PST) Received: from bunsen12.telenet.unc.edu (bunsen12.telenet.unc.edu. [204.85.191.56]) by smtp.gmail.com with ESMTPSA id z21-20020a05620a261500b0067b520a01a9sm279255qko.107.2022.03.07.07.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 07:18:58 -0800 (PST) From: Sagar Patel To: "Maciej W. Rozycki" Cc: binutils@sourceware.org, Sagar Patel Subject: [PATCH] MIPS/opcodes: Fix alias annotation for negate instructions Date: Mon, 7 Mar 2022 10:18:33 -0500 Message-Id: <20220307151833.22389-1-sagarmp@cs.unc.edu> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, 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: Mon, 07 Mar 2022 15:19:10 -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 --- binutils/ChangeLog | 11 +++++++++++ .../binutils-all/mips/micromips-neg-alias.d | 13 +++++++++++++ .../binutils-all/mips/micromips-neg-alias.s | 14 ++++++++++++++ .../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 | 13 +++++++++++++ .../testsuite/binutils-all/mips/mips-neg-noalias.d | 13 +++++++++++++ binutils/testsuite/binutils-all/mips/mips.exp | 4 ++++ opcodes/ChangeLog | 6 ++++++ opcodes/micromips-opc.c | 4 ++-- opcodes/mips-opc.c | 4 ++-- 11 files changed, 104 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/ChangeLog b/binutils/ChangeLog index a355e18de74..1f134dbe87f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2022-03-07 Sagar Patel + + * 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. + 2021-03-06 Maciej W. Rozycki * testsuite/binutils-all/mips/mips1-branch-alias.d: New test. 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..f5122d3b2dc --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/micromips-neg-alias.s @@ -0,0 +1,14 @@ + .text + .set mips32r3 + .set noat + .set noreorder + .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..bb7b3c5ac3a --- /dev/null +++ b/binutils/testsuite/binutils-all/mips/mips-neg-alias.s @@ -0,0 +1,13 @@ + .text + .set noat + .set noreorder + .set mips2 +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/ChangeLog b/opcodes/ChangeLog index 98ad3084e43..c7c8ce18835 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,9 @@ +2022-03-07 Sagar Patel + + * mips-opc.c (mips_builtin_opcodes): Fix INSN2_ALIAS annotation + for "neg" and "negu" instructions. + * micromips-opc.c (micromips_opcodes): Likewise. + 2022-03-06 Sagar Patel Maciej W. Rozycki 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.17.1