From patchwork Mon Apr 10 06:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 81368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1713979vqo; Sun, 9 Apr 2023 23:51:37 -0700 (PDT) X-Google-Smtp-Source: AKy350YX4EMW6bRhqHZJlErDZTctTAbeQgqOV0xnHE+6+RpniBb5ZD1bFB3Z4MxYg5V47UYCz2+n X-Received: by 2002:a17:906:44e:b0:931:8e8c:2db5 with SMTP id e14-20020a170906044e00b009318e8c2db5mr6678692eja.69.1681109497634; Sun, 09 Apr 2023 23:51:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681109497; cv=pass; d=google.com; s=arc-20160816; b=soHRf2MB6TR3ibaTItMNQ2nSjHUAEpbFIJfRRPhCuMZX6RzLOMg7lG3R2kHorItrWY DbMWso3bYmujvDBRmK3Cp6n8GsD8VrAlZXBOevhw5gz4+SJ8glPNHcdcZzfuTu2ULXQV KxfZvztxts/O1pxdLD/vutshIj20mb2Z8VgpmD5tbvFBS2MYLVMCT1q73euFHRauS1OO PDMyveAjmha9papNXV3ec2A/PSle/SPTYkVDEITW/PId0Uqip7cLWpJRH5yn21DfaFVe zajrGgNPTfJ5A8jQUi5ys353jl61volgqtH4Pt7DyUceN1SWxifc4J0g3gl1loSHDje8 N1GA== 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=R0mQUTFF4S31UJ5tjBfgMUc5Ju575Ra33SJESUQ2k3E=; b=T5lvyZITgj5quEDeXOCRVUCIFqjJe32g0szahX+h73Gag4j5TnQ4IEn0BgcoyJaE99 OQHxT0ZyZ2544kyymhVu3uEFCO6xqIZmOWC7ey3nnCwnLLS9WNP0fZmnj2GLIxYxI4d3 Uj8YkN2KqNGIn30yCerF9sR0Y+nbmBCn866PagPI7H7xAgHqBSBT05O+HfsFQ7jNgZp2 OhimbsVNLO60og1dWH0eAHPA/Q6iHso1FOniahkc+iB6fG4CVmScpkxnKXW66w5pv69C 0uBuB/wi8OaKLPUHzyuuKUafIvgDfOlzIJBLvZWfhWfRQTW7Ci/nwKgXI7qDZ6G2CGMh ZIPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=Ujoux5iT; 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 j6-20020a170906104600b00949564ae82asi7820300ejj.265.2023.04.09.23.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Apr 2023 23:51:37 -0700 (PDT) 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=Ujoux5iT; 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 CFAFA385770A for ; Mon, 10 Apr 2023 06:51:34 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on20722.outbound.protection.outlook.com [IPv6:2a01:111:f400:feab::722]) by sourceware.org (Postfix) with ESMTPS id 83B303858C52 for ; Mon, 10 Apr 2023 06:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83B303858C52 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=IFotPly3VVebfSKWniRgW6oVjrl7V9MC20xMbNnUjfScrzBApkY4lIjhtHkOfPzDZcSZmZi+YwwS5Smdy9/NwnwZ2p5nQvABqrBN2wnZWaOEgUBBfLXqfcor2MJBZKiZIdu9Hz/OhdiKRX6/3Y7NktUxRoHOkvFjj+dPiOHGFfNCIemBnzwoGmPw8zyN2boSBhBFVXnoYXh7xEwc3hNhBnqiHQ16gAT7y9fqVL1DoBxQiInL9HRIMFGg5/nEcZ3hGw60BUWABZIXL7fBed8cwPm6aGBvKN8UvQmszTyScVTO1gc5y4UqTNA6dVCjueYWeN2+8qB+OfjLYbY1dtQxIA== 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=R0mQUTFF4S31UJ5tjBfgMUc5Ju575Ra33SJESUQ2k3E=; b=ZSCBuB9J3rSdwCNHrg3z+3Mae9sORaLtMFrimI2FYAE09tG+sgTpHsEDoqErQzocwdmYUXdAiMZwS0WUxrpbOoyjL1oGmmeznoBmsDcrdsCzPSZroPmPeGevntqR5VJqr8w2vA4MIxug0aBYZeATVuX82ZMJtmhlQ2VJ5c2VrfWQvP1XTyvpJdlId2V6ZHLlI5tu9nOAHHir6vWWClbkn6CasaRGPqU7MidM+LNP8zT9g4FsMj8qTXCwf2OaZcACzyd4Acs/9r8nwRkmxTN65evmgrTzu6BfGQAZ4S1ho34aRVGkLF5l7iGcWkHMIpXO2mUBLe9VqR/SypRNWpS6dA== 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=R0mQUTFF4S31UJ5tjBfgMUc5Ju575Ra33SJESUQ2k3E=; b=Ujoux5iThBw3qDXVz56tY1MElHZ9195WFDI1T8YXvpXistJSGJDxB2q34ulzSrOx4T5I/dIzK5GVzAYFlQN0N5ahsb3S8YG+Csk3w8vfBWwW6kzZiFQjdw/F1WvcLNCVlOuarQr+k+OFn291KJDX5KsUt7OcJ/6pcFf0L1bkuLY= 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 SEZPR04MB5827.apcprd04.prod.outlook.com (2603:1096:101:7b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Mon, 10 Apr 2023 06:51:21 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150%5]) with mapi id 15.20.6277.035; Mon, 10 Apr 2023 06:51:21 +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, amodra@gmail.com, YunQiang Su Subject: [PATCH v3] MIPS: make mipsisa32 and mipsisa64 link more systematic Date: Mon, 10 Apr 2023 14:51:01 +0800 Message-Id: <20230410065101.822124-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-ClientProxiedBy: TYCPR01CA0016.jpnprd01.prod.outlook.com (2603:1096:405::28) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|SEZPR04MB5827:EE_ X-MS-Office365-Filtering-Correlation-Id: 2411e29c-8cb8-4429-1cc8-08db398ffdca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2SM/qFqxwKYkZ7BmXrfeoD2oXujF2fq0xfCQCma6EbdF3Htlyl+C5QsCyrHIWAvG1nK08T/mCcAq9Wkh7ow9anSwhCJhhhdb/RMq7Ptgb30JWw2vZJk+5+qB1aUU2xKb9LB8ytNUnZbFIFEUL7wNffTUNaHa63S0N148JTpKj0UmzxPoxz9LVEL8xY/wnplbGmT21+PRfAOdA7bfAOayW+XXT9NIW+4CXjFZIqC42qZ25RJ0GoW+fgs6enU59m5GqQsxAd5hOop/kxrUl8kWEdn/bNdeI4WKu50g+0D7Uq2iavTZ5jbDxvzZMWpj3rpy5ypwCEedB7/xR5TLMoMiisdXnTfJU0ripTflDTLES/yvfS32aljOlYwYvPpuJrNr5/EVF4k2Ce6d1hKuBfBTe80lrQPoDyOuQbDC/GPcJpEJcFh5jqkY4/RX30b4WUgBmWf9QS1QOrCnYdPKRuMiT8PxbUh7yXLMCb2yWK8Qtk9m9sDI0JsSAfjBccUYTLhvcdvq6MsuZFgL8XgSx0H0C5qAFDjdic3ypVhuVF7hnycxdWK9AShrwmvRnTxBhDfJlZ3cIs6Rwnpy5L7ylELz2qdSKqrnQ9SDswRrcM8Q++DuTi0zmeuarpgbMsTfHvM3 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:(13230028)(396003)(346002)(39830400003)(366004)(136003)(376002)(451199021)(478600001)(52116002)(316002)(6512007)(1076003)(6506007)(26005)(186003)(107886003)(6666004)(6486002)(2906002)(5660300002)(4326008)(66946007)(6916009)(41300700001)(8936002)(8676002)(66476007)(66556008)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /qAmyf4bqSuR96GkW2BNEuD7BybhowW4ARoaobdlyl7afGRA04HSzzXIbLsEa8HnrBrqkHUkpWN7b99+s2+EyGYvY1C/c2Av0aDQWF2G7gQGsfC0txqkY6vhpLc/lhkRNBoAC2m0zt5McFe2+ZuHMZQf1tVC14Mg3HTnqJEjsvfrsfUt50TdqMT4ZqzA1JJLtLrKrU4vZna9pTxmbMJ6y0TU+le4Gb5GbYYJIy1yQNn/izDaoAfz79hzFLsCWY6bHI97T/6EemsNtxX/lLuoRrGINunKcQnhHd92cmE6b/+S55GYT0+cLkAtz/vwp/rcMg0kco4nLrd8fh+moQy8Owy81vr1Yt9I56zwH1+p28ma/yPkl+KM55pBOJ6FNnn529HLlA3R/sLgDj5CEblzfonw7TIu7fl5x74aMQIxZAB6ucUUtvYSamQl06gaJdLXgZIBSZEt1oVUFZ/Yj8MZLztTuswfYuaZzhpLGnzgv8L9sPphwosF+6KyQDWTO4wZZTc8wmkQm/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OC95b/L68rN2V1w== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2411e29c-8cb8-4429-1cc8-08db398ffdca X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2023 06:51:20.9028 (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: JQe846a2O5R3Wshwu4aDXT5GG3A+moc9w28nUBkhijPYh7B5J7sE2zQgTnZI9vyxAQVMeVqW/DweMyANz57+WyfnokE+CFnAoFjZ2I8CXPM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR04MB5827 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, 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?1762771072330861823?= 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 | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index d34a755807b..076538fbc53 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_p (unsigned long base, unsigned long extension) +mips_mach_extends_32_64 (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; + for (i = 0; i < ARRAY_SIZE (mips_mach_32_64); 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 (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; }