From patchwork Thu Mar 2 01:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 63167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3984354wrd; Wed, 1 Mar 2023 17:53:00 -0800 (PST) X-Google-Smtp-Source: AK7set/pCyXSEoOivYuQElh0tjP3VAqXPhqGreadDUyL/GzP+qPZblwUMgkiwYyfPeSJTVxAihZ3 X-Received: by 2002:a05:6402:128c:b0:4af:6e95:72b4 with SMTP id w12-20020a056402128c00b004af6e9572b4mr9461182edv.15.1677721980014; Wed, 01 Mar 2023 17:53:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677721980; cv=pass; d=google.com; s=arc-20160816; b=cRIWbb0Zrxc5B+2S7g5OF74uqq7zT5ZTAqhS35RBzUYCy0wBxC5njkpADFzRmOL2ik vxpOgZJqmBFNWVkQUmcz7HLteZkhw4l7YVABjA2P1zjGDU69I5iu90s7fvLnp2nn6V/S je7E9qrdX1RjE6G9JlGSLyS42hI5XxGI2gIf6PxCbu/N2UCI1/aNJd8kndQH7L2wA9fW SgrJVQOc1R5WKBpO+7Us94/Z2qE1zaqXQDITFOhLRXWAZ11UbWfJ4AeZjVsHY/KSyQ4r 1LR/4iyPCJJ6WK/V0Qytv9/5apqkGvBlKBD9HijkdRQBQDFQw/Z3DHF+kCw0IFjMdulY 2eTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dmarc-filter:delivered-to; bh=BJCSed/bpQW3otjytXWQ12E+3Pj9uXf/OL19vJPMPAQ=; b=ZmEE+u340sxQIqwYnaiWlHWczOrEF9b6fHHHYzWkc9kcuInhjVt0cjz9hgpw2gPpMY FHGJJmvsEI5CnGHMX4fF/jKL2Uzb60ZTDWpqYHzP/r6kwmjT7W18eZNjYsQooIk8XZUo uL8zP6LWK1diNBkGp4GkIWF+6ozu0In2GEVO1pL6/qzvOE5y3heAGuOObqaVlhtE6fCW 7milDwGj9NQ62KIYAHrJvkg5VmWFiVABBaoc9LlLXyYvxCX+nBNIo6frxYtcpk2HtSnk tjbdrwhlby/vprq5Ak8GDzVk6Y3FDyuRE1TBbkoxqP3lA+0VJRWiwXh0JbPrmMMCYz+2 fKRw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=p+3Ryzsm; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m12-20020aa7d34c000000b004af7265c69csi2272963edr.0.2023.03.01.17.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 17:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=p+3Ryzsm; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC763385841C for ; Thu, 2 Mar 2023 01:52:58 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2097.outbound.protection.outlook.com [40.107.255.97]) by sourceware.org (Postfix) with ESMTPS id 4D0D23858D33 for ; Thu, 2 Mar 2023 01:52:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D0D23858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nSrEjRmfzGY6oYdQQ2IyJFS/6YJ4HaECoPhElVXEAF4Ykgbo23Q/9hVZjseWWX3lg+Sy5qzaWZlKFhDE/7nAX1SrevRhiv001C8n58PLzR5A37gkJjGJJq/uLa3nL5DILYnmA+VTS3LV1+rCb4zhPgvwaezduZ1NTrO2QQlJo65lT1Zi8HV+RTgV0o0O9IaUDZi/7sJHmMaD2xGePSSJeiJhW9ScyF79+utCHa7EMvBR287hivwQ1kOEjR5mgsBkXODyolx8aewAYk38IisVoHfmQ/L50+1Sb5rl/qKKCpB41kv7OVPodPOOvj/RbKLc0UmJJtVXkBL9AEPV63p3ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BJCSed/bpQW3otjytXWQ12E+3Pj9uXf/OL19vJPMPAQ=; b=MZDzFgb9B5o8L6ce/w9ukuqIffio9FNOjmcP8hqnMcf0e215r1NCSD6YQGLrSeXgGQyaK4WoVvbZuEESbOvB9z6rpgg0RQ59R9JzjHkSoJDBg1WMZCQ9g1IXw16a35CnfKiLRZf6WOz36kTBLeqh+Z7L8DG4Gsd8/4qSJmUjVd3tcirPTp38qqGAsCbSEAUzhq6sp/7m/J840/t8lWp86my1hJ4K6VDab7F6H3sRIJ83jQdmmNtBJaVLO7B9rKlmsHDVoJ83pIHBOQ5HUm3Q9NcwVHZZxTZfilJcF5BpZhh2QcqTYsqtl9z4jjsy5OJhewrq4tUVKWO39EGix0zTog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BJCSed/bpQW3otjytXWQ12E+3Pj9uXf/OL19vJPMPAQ=; b=p+3Ryzsm/jneQOgZPhybREILKyklshcKf6uI0cXQQI59gYwGOduV5e9eamHmeFQ+e6wXCQLGj3JFzquu9Iv8IHWvxkhgHEIO4ZG61ZjrKqJaXHeK/d5prSie/30iGskq7H25m3KPDc1cKK9UiXDccL4KGhzdHX0Ad0T+Z8D8w7A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) by TY2PR04MB4062.apcprd04.prod.outlook.com (2603:1096:404:800f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18; Thu, 2 Mar 2023 01:52:39 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::b2cb:a598:3a7e:367a%2]) with mapi id 15.20.6156.018; Thu, 2 Mar 2023 01:52:39 +0000 From: YunQiang Su To: binutils@sourceware.org Cc: syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, richard.sandiford@arm.com, jiaxun.yang@flygoat.com, YunQiang Su Subject: [PATCH v2] MIPS: make mipsisa32 and mipsisa64 link more systematic Date: Thu, 2 Mar 2023 09:52:22 +0800 Message-Id: <20230302015222.291088-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230221040650.2337395-1-yunqiang.su@cipunited.com> References: <20230221040650.2337395-1-yunqiang.su@cipunited.com> X-ClientProxiedBy: TYWPR01CA0009.jpnprd01.prod.outlook.com (2603:1096:400:a9::14) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|TY2PR04MB4062:EE_ X-MS-Office365-Filtering-Correlation-Id: 54d3c012-7d4e-472f-5063-08db1ac0cdcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iiJZWi+kP0c9uBRagakQAmporP4JpkiBhcDxeTL/ippZmVZgV2u28OrvGE1fwOJYTIeZ3VrKpep3ZmSJj77Nmyl6jo0xnygB3NYfruOJCVhQ6EghQJ2vzhwsZyf+i1jagFociDDKYpzmRNUVvhcjKhB1lQu3g+ETKBt0E/MOVedmNOzkDeOHeYYYp7PZPhzGpyRlzYDn0Bw+5+T2cE/B83mxFAtEntCfxtqKDzokEVp4BQY0jeUAhWS2TH50RVK4unGdFdnPNRwq+ULZxB1ZqLlPDmrPLzE3PeOoF5PIaOnrNYo2DFoaKaOZgkUNsZnz7RfGuV42dEa2f5uvKWJG0yt88oYTIu3KhVOuYT3tTU2csMmm/s9HsTUzcoXgRKkdUZKFRp/c/WmtseqbEz+METp1r/whZQsC6Z2Zk+nf/oKf6OUsa4qO7z0U4VbaxrhHs5oBO+Xa9EBfTPICGk2ivsE1R1EvFP139/o1ntEBhBchhnFyIATlOkhK+lAzNhvq93UTwykz5vE6teBPm3dfzlo9xMy+jisWE81jNvLEn8hRVojuCAQRqwhoZMuFQb50xA85n1/Rw0Wa0e33i+HycYYQaTR54EX4n0TA4af3fwxiuBiEnLXHFmxJ9Cdb36lVJbVppBCyU6tAcFuyyrpXP48U5Dlx0olj0+7jvR+0SJK802v+3W4f6sbUkP/a3LNFv4q65fxew+AcHdvfLGqKpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB6117.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(366004)(39830400003)(346002)(376002)(396003)(136003)(451199018)(36756003)(86362001)(66556008)(41300700001)(66476007)(8936002)(5660300002)(6916009)(4326008)(66946007)(2906002)(8676002)(38350700002)(38100700002)(52116002)(107886003)(6486002)(478600001)(6666004)(316002)(83380400001)(2616005)(1076003)(186003)(6506007)(6512007)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yZ8fdrxptR6Nrxk/90UF0jGGlqFMo+1zi2a5mAIuRjgNIdvsjXU5XTGv2bWMV4BKFBL9NRf45Q+Gu/8pvX5uL2jRGsRQq3hhkHJ4nMWZzCV2YnDRbSOMNgi0DLmCGELbrnUATvMv9TEEAOK4lCfK2+l5OGf+s3TMUME/x/3pvM0uIvUp4fgyKllJDhjTQHUdM8GcHQn9CRTk7Rkmo8wRQGbgu8hl2HDp05PNPhn4FNJavoCTxqy6ngjFJmCUbJBUrYkXSMWY+Tb8W8pv7RQPLWPA8bWbQp970qj304w6Dn89vBvW4St/LaMg49OPjFMV3hPjWCErhlhZ7k8+0WSchd5Y/ofCkW9AmVG/mKLzaiYdTntsMqoaEse0UX9h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iV0X4Gy8UbolNtnJD6r5PMLvKXtEhFrqP5eMsketahPaVCaJ56GRiie6c43YEqkM1yfyyliLTFdbQFeh1YP+7ggz6vAWlvWifa8mew/VFbnP0nvd2/NYHz/fcsxv35QwuY5SvEdeAVi0MMLQI1bq+LaC4CD0/veqg== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54d3c012-7d4e-472f-5063-08db1ac0cdcf X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 01:52:39.5296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aJ7kIVC33Zvl/Fx0qA+h9oL1nD6d+8SEBe/v5ArE+LDhBUJbfVZHWPsdh3Er79u020a0cpmhZIp7s6illGjZOy4t6BJYv1HLWlhMicpiC20= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY2PR04MB4062 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758412088143109859?= X-GMAIL-MSGID: =?utf-8?q?1759219002940856993?= Introduce `static const struct mips_mach_extension mips_mach_32_64[]` and `mips_mach_extends_32_64 (unsigned long base, unsigned long extension)`, to make mipsisa32 and mipsisa64 interlink more systemtic. Normally, the ISA mipsisa64rN has two subset: mipsisa64r(N-1) and mipsisa32rN. `mips_mach_extensions` can hold only mipsisa64r(N-1), so we need to introduce a new instruction `mips_mach_32_64`, which holds the pair 32vs64. Note: R6 is not compatible with pre-R6. bfd/ChangeLog: * elfxx-mips.c (mips_mach_extends_p): make mipsisa32 and mipsisa64 interlink more systematic. (mips_mach_32_64): new struct added. (mips_mach_extends_32_64): new function added. --- bfd/elfxx-mips.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 35bbd86044b..21e6396609b 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -14524,6 +14524,16 @@ struct mips_mach_extension unsigned long extension, base; }; +/* An array that maps 64-bit architectures to the corresponding 32-bit + architectures. */ +static const struct mips_mach_extension mips_mach_32_64[] = +{ + { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 }, + { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 }, + { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 }, + { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 }, + { bfd_mach_mipsisa64, bfd_mach_mipsisa32 } +}; /* An array describing how BFD machines relate to one another. The entries are ordered topologically with MIPS I extensions listed last. */ @@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] = { bfd_mach_mips3900, bfd_mach_mips3000 } }; -/* Return true if bfd machine EXTENSION is an extension of machine BASE. */ +/* Return true if bfd machine EXTENSION is the same as BASE, or if + EXTENSION is the 64-bit equivalent of a 32-bit BASE. */ + +static bool +mips_mach_extends_32_64 (unsigned long base, unsigned long extension) +{ + size_t i; + + if (extension == base) + return true; + + for (i = 0; i < ARRAY_SIZE (mips_mach_64_32); i++) + if (extension == mips_mach_32_64[i].extension) + return base == mips_mach_32_64[i].base; + + return false; +} static bool mips_mach_extends_p (unsigned long base, unsigned long extension) { size_t i; - if (extension == base) - return true; - - if (base == bfd_mach_mipsisa32 - && mips_mach_extends_p (bfd_mach_mipsisa64, extension)) - return true; - - if (base == bfd_mach_mipsisa32r2 - && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension)) + if (mips_mach_extends_32_64 (base, extension)) return true; for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++) if (extension == mips_mach_extensions[i].extension) { extension = mips_mach_extensions[i].base; - if (extension == base) + if (mips_mach_extends_32_64 (base, extension)) return true; }