From patchwork Wed Aug 8 23:20:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 28804 Received: (qmail 40593 invoked by alias); 8 Aug 2018 23:20:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40406 invoked by uid 89); 8 Aug 2018 23:20:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.196.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Aug 2018 23:20:28 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway30.websitewelcome.com (Postfix) with ESMTP id C8C6C4D73 for ; Wed, 8 Aug 2018 18:20:26 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id nXkafQDAbbXuJnXkdfp5Eq; Wed, 08 Aug 2018 18:20:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2hk5DY6L7MFKkgTx5Oj4KP80GOCnMgIRLUPdG24Q5n4=; b=V4CzjJWDHZlOGWsUhgT1Qvhm4a tLQvBf9hSb54ukFOBk8f16uYdoCTxwwplFtHAKEEP+INYIoel7+UIMnw1T6RMI/AYilYUmJLtjQUF h4hzyB1WoOCOvhCQTITKG9all; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:57736 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fnXka-0023IS-Fh; Wed, 08 Aug 2018 18:20:20 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/7] Avoid -Wnarrowing warnings in ppc64-tdep.c Date: Wed, 8 Aug 2018 17:20:14 -0600 Message-Id: <20180808232016.12777-6-tom@tromey.com> In-Reply-To: <20180808232016.12777-1-tom@tromey.com> References: <20180808232016.12777-1-tom@tromey.com> This avoids -Wnarrowing warnings in ppc64-tdep.c, by adding a few casts to unsigned. gdb/ChangeLog 2018-08-08 Tom Tromey * ppc64-tdep.c (insn_d, insn_ds, insn_xfx): Add casts to unsigned. (ppc64_standard_linkage1, ppc64_standard_linkage2) (ppc64_standard_linkage3, ppc64_standard_linkage4) (ppc64_standard_linkage5, ppc64_standard_linkage6) (ppc64_standard_linkage7, ppc64_standard_linkage8): Add casts to unsigned. --- gdb/ChangeLog | 10 +++++++ gdb/ppc64-tdep.c | 86 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c index 5d8ccb48d4..4b8dd3fe3f 100644 --- a/gdb/ppc64-tdep.c +++ b/gdb/ppc64-tdep.c @@ -30,24 +30,24 @@ you can use -1 to make masks. */ #define insn_d(opcd, rts, ra, d) \ - ((((opcd) & 0x3f) << 26) \ - | (((rts) & 0x1f) << 21) \ - | (((ra) & 0x1f) << 16) \ - | ((d) & 0xffff)) + ((((unsigned (opcd)) & 0x3f) << 26) \ + | (((unsigned (rts)) & 0x1f) << 21) \ + | (((unsigned (ra)) & 0x1f) << 16) \ + | ((unsigned (d)) & 0xffff)) #define insn_ds(opcd, rts, ra, d, xo) \ - ((((opcd) & 0x3f) << 26) \ - | (((rts) & 0x1f) << 21) \ - | (((ra) & 0x1f) << 16) \ - | ((d) & 0xfffc) \ - | ((xo) & 0x3)) + ((((unsigned (opcd)) & 0x3f) << 26) \ + | (((unsigned (rts)) & 0x1f) << 21) \ + | (((unsigned (ra)) & 0x1f) << 16) \ + | ((unsigned (d)) & 0xfffc) \ + | ((unsigned (xo)) & 0x3)) #define insn_xfx(opcd, rts, spr, xo) \ - ((((opcd) & 0x3f) << 26) \ - | (((rts) & 0x1f) << 21) \ - | (((spr) & 0x1f) << 16) \ - | (((spr) & 0x3e0) << 6) \ - | (((xo) & 0x3ff) << 1)) + ((((unsigned (opcd)) & 0x3f) << 26) \ + | (((unsigned (rts)) & 0x1f) << 21) \ + | (((unsigned (spr)) & 0x1f) << 16) \ + | (((unsigned (spr)) & 0x3e0) << 6) \ + | (((unsigned (xo)) & 0x3ff) << 1)) /* PLT_OFF is the TOC-relative offset of a 64-bit PowerPC PLT entry. Return the function's entry point. */ @@ -86,7 +86,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage1[] = { insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 }, /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 0 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 0 }, /* ld r11, (r12) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 0 }, @@ -107,7 +107,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage1[] = { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 1 }, /* bctr */ - { -1, 0x4e800420, 0 }, + { (unsigned) -1, 0x4e800420, 0 }, { 0, 0, 0 } }; @@ -122,13 +122,13 @@ static const struct ppc_insn_pattern ppc64_standard_linkage1[] = static const struct ppc_insn_pattern ppc64_standard_linkage2[] = { /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 1 }, /* addis r12, r2, */ { insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 }, /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 1 }, /* ld r11, (r12) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 0 }, @@ -140,10 +140,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage2[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 11, 9, 467), 0 }, /* xor r11, r11, r11 */ - { -1, 0x7d6b5a78, 1 }, + { (unsigned) -1, 0x7d6b5a78, 1 }, /* add r12, r12, r11 */ - { -1, 0x7d8c5a14, 1 }, + { (unsigned) -1, 0x7d8c5a14, 1 }, /* ld r2, (r12) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 2, 12, 0, 0), 0 }, @@ -152,10 +152,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage2[] = { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 1 }, /* bctr */ - { -1, 0x4e800420, 1 }, + { (unsigned) -1, 0x4e800420, 1 }, /* cmpldi r2, 0 */ - { -1, 0x28220000, 1 }, + { (unsigned) -1, 0x28220000, 1 }, { 0, 0, 0 } }; @@ -165,7 +165,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage2[] = static const struct ppc_insn_pattern ppc64_standard_linkage3[] = { /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 1 }, /* ld r11, (r2) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 2, 0, 0), 0 }, @@ -177,10 +177,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage3[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 11, 9, 467), 0 }, /* xor r11, r11, r11 */ - { -1, 0x7d6b5a78, 1 }, + { (unsigned) -1, 0x7d6b5a78, 1 }, /* add r2, r2, r11 */ - { -1, 0x7c425a14, 1 }, + { (unsigned) -1, 0x7c425a14, 1 }, /* ld r11, (r2) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 2, 0, 0), 1 }, @@ -189,10 +189,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage3[] = { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 2, 2, 0, 0), 0 }, /* bctr */ - { -1, 0x4e800420, 1 }, + { (unsigned) -1, 0x4e800420, 1 }, /* cmpldi r2, 0 */ - { -1, 0x28220000, 1 }, + { (unsigned) -1, 0x28220000, 1 }, { 0, 0, 0 } }; @@ -204,7 +204,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage3[] = static const struct ppc_insn_pattern ppc64_standard_linkage4[] = { /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 1 }, /* addis r11, r2, */ { insn_d (-1, -1, -1, 0), insn_d (15, 11, 2, 0), 0 }, @@ -219,10 +219,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage4[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 }, /* xor r2, r12, r12 */ - { -1, 0x7d826278, 1 }, + { (unsigned) -1, 0x7d826278, 1 }, /* add r11, r11, r2 */ - { -1, 0x7d6b1214, 1 }, + { (unsigned) -1, 0x7d6b1214, 1 }, /* ld r2, (r11) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 2, 11, 0, 0), 0 }, @@ -231,10 +231,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage4[] = { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 11, 0, 0), 1 }, /* bctr */ - { -1, 0x4e800420, 1 }, + { (unsigned) -1, 0x4e800420, 1 }, /* cmpldi r2, 0 */ - { -1, 0x28220000, 1 }, + { (unsigned) -1, 0x28220000, 1 }, { 0, 0, 0 } }; @@ -246,7 +246,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage4[] = static const struct ppc_insn_pattern ppc64_standard_linkage5[] = { /* std r2, 40(r1) */ - { -1, insn_ds (62, 2, 1, 40, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 40, 0), 1 }, /* ld r12, (r2) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 12, 2, 0, 0), 0 }, @@ -258,10 +258,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage5[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 }, /* xor r11, r12, r12 */ - { -1, 0x7d8b6278, 1 }, + { (unsigned) -1, 0x7d8b6278, 1 }, /* add r2, r2, r11 */ - { -1, 0x7c425a14, 1 }, + { (unsigned) -1, 0x7c425a14, 1 }, /* ld r11, (r2) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 2, 0, 0), 1 }, @@ -270,10 +270,10 @@ static const struct ppc_insn_pattern ppc64_standard_linkage5[] = { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 2, 2, 0, 0), 0 }, /* bctr */ - { -1, 0x4e800420, 1 }, + { (unsigned) -1, 0x4e800420, 1 }, /* cmpldi r2, 0 */ - { -1, 0x28220000, 1 }, + { (unsigned) -1, 0x28220000, 1 }, { 0, 0, 0 } }; @@ -283,7 +283,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage5[] = static const struct ppc_insn_pattern ppc64_standard_linkage6[] = { /* std r2, 24(r1) */ - { -1, insn_ds (62, 2, 1, 24, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 24, 0), 1 }, /* addis r11, r2, */ { insn_d (-1, -1, -1, 0), insn_d (15, 11, 2, 0), 0 }, @@ -295,7 +295,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage6[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 }, /* bctr */ - { -1, 0x4e800420, 0 }, + { (unsigned) -1, 0x4e800420, 0 }, { 0, 0, 0 } }; @@ -305,7 +305,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage6[] = static const struct ppc_insn_pattern ppc64_standard_linkage7[] = { /* std r2, 24(r1) */ - { -1, insn_ds (62, 2, 1, 24, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 24, 0), 1 }, /* ld r12, (r2) */ { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 12, 2, 0, 0), 0 }, @@ -314,7 +314,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage7[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 }, /* bctr */ - { -1, 0x4e800420, 0 }, + { (unsigned) -1, 0x4e800420, 0 }, { 0, 0, 0 } }; @@ -325,7 +325,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage7[] = static const struct ppc_insn_pattern ppc64_standard_linkage8[] = { /* std r2, 24(r1) */ - { -1, insn_ds (62, 2, 1, 24, 0), 1 }, + { (unsigned) -1, insn_ds (62, 2, 1, 24, 0), 1 }, /* addis r12, r2, */ { insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 }, @@ -337,7 +337,7 @@ static const struct ppc_insn_pattern ppc64_standard_linkage8[] = { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 }, /* bctr */ - { -1, 0x4e800420, 0 }, + { (unsigned) -1, 0x4e800420, 0 }, { 0, 0, 0 } };