Message ID | DB6PR0801MB1879929B1E237C0B8C4CC41D83C69@DB6PR0801MB1879.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 325C93856DE0 for <patchwork@sourceware.org>; Mon, 9 May 2022 16:37:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 325C93856DE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652114234; bh=8QSXQNhKvlOg2E0zKnpFrYY8ETT3ytIg9+YZ5Y/bG6w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OCbQnCDO+FLwlx1tOXTYZ5gG76U6xxaEHzM/SX7X2nHTozg1OxRxBLILwc8aoMW69 qpK+OPpLbIghBnpIq5D2ufJtAfl5M1f1SHOo9k8LYvxzqIZRsTKgo4wNfqFEoLqoB5 DfWKTEMAwPI00vadEoZJeV6dXDJTzXlQxUwzCAdc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by sourceware.org (Postfix) with ESMTPS id C0EE53858C2C for <gcc-patches@gcc.gnu.org>; Mon, 9 May 2022 16:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C0EE53858C2C ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ZfLSHWH1aNyBCu9Gsboar9XfblrwkvJ/S2I0n0wePDZMAJjZPSzoRxz6ExKjJdlAJaOWxgsUuYSjlqqAgIbE8gMNn2d1FPAPxFvloZZo8v1NChOIMu6y/7efwRWikSo4xHWWU+YyGzYQL1BHvlsIQvcuXvSTW/nqK04qZrOCWo3Nz0YOGx7yqQdzdIapYJIMJ8VQidXNoGU0kOK/ZZTlvNXjtiy4l838HU6USNFpbtWkmwV/JYxYqinnwFSAPQzlM5IxT6/aabCg5W3OIgxMfZE5ITMvBhSUO2tQRIxUaamvxBGkJFJP9ORwbhN3MsnA41r/+BbddWe58XzoE+lpfQ== ARC-Message-Signature: i=2; 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=8QSXQNhKvlOg2E0zKnpFrYY8ETT3ytIg9+YZ5Y/bG6w=; b=Fbbje5bglfocj65yFT6kISvJHFf8yTirJC9oo13AnAB5gWFW5N4dS/mtBUF2LlmWD+fIaihWrP4EPoi0e/n2tcY5l1+wvu7PsxB5BYdnJPq0N/jRG9OJfkl4HVUayA7BGYWqRQon+R4DkvA5dBKHZd3vQhrpTorvpGiCg7Us+avYGX1kMxmdKNddKt5Xg9ao767YF69MT0boaBsadF+GwZw9pf+brUnG65Q9h5HiZdOe75fU2Sczqc7h/QzeKXaX0EerigUyewZAUniB+SKOJ11WJIjqwnXbXT0zdOusC5cyrg/e02z7F56DQfDTrSeBUXa1gp4HDIbY36hwTFuaKw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DB6P191CA0021.EURP191.PROD.OUTLOOK.COM (2603:10a6:6:28::31) by VE1PR08MB4766.eurprd08.prod.outlook.com (2603:10a6:802:a9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Mon, 9 May 2022 16:36:36 +0000 Received: from DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:28:cafe::4f) by DB6P191CA0021.outlook.office365.com (2603:10a6:6:28::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20 via Frontend Transport; Mon, 9 May 2022 16:36:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT032.mail.protection.outlook.com (10.152.20.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 16:36:36 +0000 Received: ("Tessian outbound facaf1373bbd:v118"); Mon, 09 May 2022 16:36:36 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dd02c44147b8f8d3 X-CR-MTA-TID: 64aa7808 Received: from 5460b38c59a5.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7B95D880-38B2-4342-A24A-47DC4F432DBE.1; Mon, 09 May 2022 16:36:29 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5460b38c59a5.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 09 May 2022 16:36:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbStLiy4weGXQ7B0DWcXGq6C5dCNI0QvevARvmjCqiP/z4TvlUv8+BikE1X7cq8LxQSlItDWrdJDOacV4EcYdu6BMBiTUj33rFZWKZSI/mqItLldJvy6t+97xxHAYKEjPcRBN0Bf3bpLtVQ1yC+xmODalhdmBo1wiRfbKcAWr7Ev+1MnnGDfmiot+xFOQYYxOs6aQHCdwWyjGFkXi4vaTubLs0tXY2GB2JzL8n1ToBtPun/Z8igYqaF1tOcXqMrf0XdFKCBzaGwR36p185ae1Es08K2hXGV0RN6LEPaRX4fuEdN1dymnPRk1y6rPcjZHzGQRk3Q1qlD3RZNJdPrzPw== 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=8QSXQNhKvlOg2E0zKnpFrYY8ETT3ytIg9+YZ5Y/bG6w=; b=mCYMw4W0gaRiIz8anQrzCRD4GQfT4LNjbc1iDSl4OxiuPPN9MRGFPJrcZQ9JGhs2WdKovLU9G8iL8jniqG97CqHB/Zp4a8FZFaVHoj+qwu+7Bb8zN6tZ7EPFrxfkGRXFMPxE5BPJ5kJF0m8dr7F2jlsB1j22n5TDvOaLsDbwWW6nlxI7xu96UvRpYkmf6+x/wsGc/JimrhsKTXg75NS1kqAqsgLVd52/AIAOpEgQO4auhoH3Rkt6o46xMqE/3XIl+Sbyi3BEqpk8ruEiFR8CSc/wuc6ko/oBG4BW8VbaGky7bTwuBdFwFyzKwKJf7yMqkbzpfnVrBpslFg1LQE+GmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from DB6PR0801MB1879.eurprd08.prod.outlook.com (2603:10a6:4:73::9) by VE1PR08MB5149.eurprd08.prod.outlook.com (2603:10a6:803:107::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Mon, 9 May 2022 16:36:27 +0000 Received: from DB6PR0801MB1879.eurprd08.prod.outlook.com ([fe80::4c79:5ff3:ff33:7ee1]) by DB6PR0801MB1879.eurprd08.prod.outlook.com ([fe80::4c79:5ff3:ff33:7ee1%11]) with mapi id 15.20.5227.021; Mon, 9 May 2022 16:36:27 +0000 To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>, Richard Sandiford <Richard.Sandiford@arm.com> Subject: [PATCH] AArch64: Cleanup CPU option processing code Thread-Topic: [PATCH] AArch64: Cleanup CPU option processing code Thread-Index: AQHYY8Gh/lbbrTnOQEiZ4oBveV1goQ== Date: Mon, 9 May 2022 16:36:27 +0000 Message-ID: <DB6PR0801MB1879929B1E237C0B8C4CC41D83C69@DB6PR0801MB1879.eurprd08.prod.outlook.com> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 253a788c-cc14-4788-9aad-08da31da15b2 x-ms-traffictypediagnostic: VE1PR08MB5149:EE_|DB5EUR03FT032:EE_|VE1PR08MB4766:EE_ X-Microsoft-Antispam-PRVS: <VE1PR08MB47660412D8C39D12776E0FDD83C69@VE1PR08MB4766.eurprd08.prod.outlook.com> x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Ep0bBLZjFLwkHaMGHA6dIhirJisSxqPVOzrJ3M6kErtEqUNBrkD/l2tihoHQ//ue24jQ5hIaW2BMiNT9plWJNqlo8frcEvULObLvxvPEQjsJJL7zculvHLTri+r6SJco/VElNaHg9qtKrWWKldb3z6bLpo0DcuPTMnB/gcA2ltsaUQPu/ozQuhtBQiw0wrKoSvk976fuupJg675FZzThnAlH/bwPrjRKBQMBAzWQfrYGIpTRDEcupm7PIHOuhTytYEOFECmcu4JWBORyBbqRpptVrXeftnomZbEf2CAoxawoHt21tDmSrn0NIS/wNp1R7DGnDu4L1yWM+54vB1iH5xPQkC+AOL6KcjMM0Eh14+ajiyt35gGgZTEoxUYqKnROQx6Vd68r7bbT3YGor6EZuUvEESYDClS/PepNCNLQbOrkV38XarB3c0PcRFuw32s6sI33jRtojoqvtG40XjHni/ovAb7acg1Y5UHjcQMzRHKK0dQXp3RTMoiTg+vS0LngK9oMsOgsExGbpwm51KjyVBsyeTFyLeJFcbIH1LbpTZOwZLCnLJGT1bpv0JE4S3elUiPHC0olZOs27TEnWGN2vAfOIuNlobAwe1SW2C/faXk6y2jLpTi+3XlzJLU61xxWIIeJWGPxEvRpSS+NZPEYjop5eM7LfD99DqCHWO7fGfHHZ7Q1E+xwV0tSWQ01b5xIYZveAFNWwWq+cn0+ewOl7A== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0801MB1879.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(9686003)(122000001)(26005)(52536014)(6636002)(76116006)(66476007)(64756008)(66446008)(8676002)(4326008)(66556008)(66946007)(186003)(110136005)(91956017)(316002)(38100700002)(6506007)(2906002)(7696005)(30864003)(86362001)(71200400001)(83380400001)(38070700005)(33656002)(5660300002)(8936002)(508600001)(55016003); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5149 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 60532e6b-0124-481b-e0c2-08da31da1051 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ALiv0RJHQCH2MpqbZ50ddUQiQHuia+L5Lw169ydw1Wq3SS6zMO6PGUhHq0rOrGIjrMMA4xi+BFFYf457QU/7k6XDUCgny42Ah/XUZM9wB30bQrzBC/xEavoMs5k+LRKghu0ltNY25Fkv2t6BR6qno2THgFkKch6bd762sBlPdGSzdNwG0+RXSBmrp2lk7PXVkUJ/ZFk6qM3N//6iBsYSZKNZ/XULXxn4hZ0EZusys1JX3Es4iCksZoTE/durJhJL63y+WtUuZzt7mGEwNpDoOuxL6HFMiRkNlktG/pYixeCyhF2Cflngxd0Z1IZL/lNe9hY0CuA9qMzHmbeh+tpQol+C6vlqBBWMk4W2wqKpBWC6HRAuf5PIf2IR3dR+ZgjpmyXaosUtOPLEoY0pnaqFPDcywxo8VLuIC5dYnE38Er4ckoAwLyuWeeShK+v3HoGl2kOQINSia7k99gPzEpTt1JfKFAnHkLdIvYmZQQL9waTnaKPL+SOXUc18X2C0M3QW6BDiPefQUwpick4pr1PfBQcvO+csppoPU4cWmhfVPdEEJgE5Nw2wTmTyVEk2P4+pxSuOd0ffqvOJ3QNOWN3Op7PQXG8xyUHD2eTEWHUNdpnGFFjo/Wm0kN2OfKsK+lmvG2OA4oDIjPidccfVvs0+G4btelQ3qwC55gAIk0BwcdyX4hTeXFvPPhoP40h6//20 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(36860700001)(26005)(9686003)(40460700003)(8676002)(6636002)(4326008)(82310400005)(47076005)(186003)(336012)(110136005)(70586007)(316002)(70206006)(2906002)(5660300002)(55016003)(508600001)(6506007)(86362001)(33656002)(52536014)(7696005)(8936002)(81166007)(83380400001)(356005)(30864003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 16:36:36.3004 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 253a788c-cc14-4788-9aad-08da31da15b2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4766 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Wilco Dijkstra via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Wilco Dijkstra <Wilco.Dijkstra@arm.com> Cc: GCC Patches <gcc-patches@gcc.gnu.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
AArch64: Cleanup CPU option processing code
|
|
Commit Message
Wilco Dijkstra
May 9, 2022, 4:36 p.m. UTC
The --with-cpu/--with-arch configure option processing not only checks valid arguments but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used however since a --with-cpu is translated into a -mcpu option which is processed as if written on the command-line (so TARGET_CPU_DEFAULT is never accessed). So remove all the complex processing and bitmask, and just validate the option. Fix a bug that always reports valid architecture extensions as invalid. As a result the CPU processing in aarch64.cc can be simplified. Bootstrap OK, regress pass, OK for commit? ChangeLog: 2022-04-19 Wilco Dijkstra <wdijkstr@arm.com> * config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch processing. Add support for architectural extensions. * config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove AARCH64_CPU_DEFAULT_FLAGS. (TARGET_CPU_NBITS): Remove. (TARGET_CPU_MASK): Remove. * config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define. (get_tune_cpu): Assert CPU is always valid. (get_arch): Assert architecture is always valid. (aarch64_override_options): Cleanup CPU selection code and simplify logic. ---
Comments
Wilco Dijkstra via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > The --with-cpu/--with-arch configure option processing not only checks valid arguments > but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used > however since a --with-cpu is translated into a -mcpu option which is processed as if > written on the command-line (so TARGET_CPU_DEFAULT is never accessed). > > So remove all the complex processing and bitmask, and just validate the option. > Fix a bug that always reports valid architecture extensions as invalid. As a result > the CPU processing in aarch64.cc can be simplified. > > Bootstrap OK, regress pass, OK for commit? Although invoking ./cc1 directly only half-works with --with-arch, it half-works well-enough that I'd still like to keep it working. But I agree we should apply your change first, then I can follow up with a patch to make --with-* work with ./cc1 later. (I have a version locally and the net result is much simpler than the status quo, as well as hopefully actually working properly.) My main question about the patch itself is: > + explicit_arch = selected_arch->arch; > if (!selected_tune) > selected_tune = selected_cpu; > + explicit_tune_core = selected_tune->ident; > + > + gcc_assert (explicit_tune_core != aarch64_none); > + gcc_assert (explicit_arch != aarch64_no_arch); Do we still need both selected_arch and explicit_arch? explicit_arch seems a misnomer now, since it includes implicit as well as explicit choices. Same for selected_tune and explicit_tune_core. aarch64_option_restore has: if (opts->x_explicit_tune_core == aarch64_none && opts->x_explicit_arch != aarch64_no_arch) selected_tune = &all_cores[selected_arch->ident]; else selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); Is the “if” condition ever true, or can we now restore the tune info unconditionally? Thanks, Richard
Hi Richard, > Although invoking ./cc1 directly only half-works with --with-arch, > it half-works well-enough that I'd still like to keep it working. > But I agree we should apply your change first, then I can follow up > with a patch to make --with-* work with ./cc1 later. (I have a version > locally and the net result is much simpler than the status quo, as well > as hopefully actually working properly.) That sounds good indeed. Is that changing TARGET_CPU_DEFAULT into a string can could just be parsed like a -mcpu option? > Do we still need both selected_arch and explicit_arch? explicit_arch > seems a misnomer now, since it includes implicit as well as explicit > choices. Same for selected_tune and explicit_tune_core. At the moment we do since these are settings that must be saved/restored since they can be overridden. However it may be possible to do further cleanups to remove some of this. I also wonder whether we can remove the internal override feature (override_tune_string) since that further complicates the tunings, and I'm not convinced that it is either useful or being used at all. > aarch64_option_restore has: > > if (opts->x_explicit_tune_core == aarch64_none > && opts->x_explicit_arch != aarch64_no_arch) > selected_tune = &all_cores[selected_arch->ident]; > else > selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); > > Is the “if” condition ever true, or can we now restore the tune > info unconditionally? Yes that was added a year or so after I created this patch, so this is now redundant. I've removed it in v2: The --with-cpu/--with-arch configure option processing not only checks valid arguments but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used however since a --with-cpu is translated into a -mcpu option which is processed as if written on the command-line (so TARGET_CPU_DEFAULT is never accessed). So remove all the complex processing and bitmask, and just validate the option. Fix a bug that always reports valid architecture extensions as invalid. As a result the CPU processing in aarch64.c can be simplified. Bootstrap OK, regress pass, OK for commit? ChangeLog: 2022-04-19 Wilco Dijkstra <wdijkstr@arm.com> * config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch processing. Add support for architectural extensions. * config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove AARCH64_CPU_DEFAULT_FLAGS. (TARGET_CPU_NBITS): Remove. (TARGET_CPU_MASK): Remove. * config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define. (get_tune_cpu): Assert CPU is always valid. (get_arch): Assert architecture is always valid. (aarch64_override_options): Cleanup CPU selection code and simplify logic. (aarch64_option_restore): Remove unnecessary checks on tune. --- diff --git a/gcc/config.gcc b/gcc/config.gcc index c5064dd376660c192d5573997b4fc86b6b3e3838..b48d5451e8027c93fb1f614812589183d0a88c4b 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4178,8 +4178,6 @@ case "${target}" in pattern=AARCH64_CORE fi - ext_mask=AARCH64_CPU_DEFAULT_FLAGS - # Find the base CPU or ARCH id in aarch64-cores.def or # aarch64-arches.def if [ x"$base_val" = x ] \ @@ -4187,23 +4185,6 @@ case "${target}" in ${srcdir}/config/aarch64/$def \ > /dev/null; then - if [ $which = arch ]; then - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - # Extract the architecture flags from aarch64-arches.def - ext_mask=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/)$//' | \ - sed -e 's/^.*,//'` - else - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - fi - # Disallow extensions in --with-tune=cortex-a53+crc. if [ $which = tune ] && [ x"$ext_val" != x ]; then echo "Architecture extensions not supported in --with-$which=$val" 1>&2 @@ -4234,25 +4215,7 @@ case "${target}" in grep "^\"$base_ext\""` if [ x"$base_ext" = x ] \ - || [[ -n $opt_line ]]; then - - # These regexp extract the elements based on - # their group match index in the regexp. - ext_canon=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\2/"` - ext_on=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\3/"` - ext_off=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\4/"` - - if [ $ext = $base_ext ]; then - # Adding extension - ext_mask="("$ext_mask") | ("$ext_on" | "$ext_canon")" - else - # Removing extension - ext_mask="("$ext_mask") & ~("$ext_off" | "$ext_canon")" - fi - + || [ x"$opt_line" != x ]; then true else echo "Unknown extension used in --with-$which=$val" 1>&2 @@ -4261,10 +4224,6 @@ case "${target}" in ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` done - ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)" - if [ x"$base_id" != x ]; then - target_cpu_cname="TARGET_CPU_$base_id | $ext_mask" - fi true else # Allow --with-$which=native. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 359b6e8561faa38f53a806b8c114c83ae37e7e17..f835da33b72f36bbf25a0e1328135411bd8ab4f6 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -813,16 +813,9 @@ enum target_cpus TARGET_CPU_generic }; -/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT. - This needs to be big enough to fit the value of TARGET_CPU_generic. - All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */ -#define TARGET_CPU_NBITS 8 -#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1) - /* If there is no CPU defined at configure, use generic as default. */ #ifndef TARGET_CPU_DEFAULT -#define TARGET_CPU_DEFAULT \ - (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS)) +# define TARGET_CPU_DEFAULT TARGET_CPU_generic #endif /* If inserting NOP before a mult-accumulate insn remember to adjust the diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f650abbc4ce49cf0947049931f86bad1130c3428..43d87d1b9c4ef1a85094e51f81745f98f1ef27fb 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2760,8 +2760,6 @@ static const struct attribute_spec aarch64_attribute_table[] = { NULL, 0, 0, false, false, false, false, NULL, NULL } }; -#define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) - /* An ISA extension in the co-processor and main instruction set space. */ struct aarch64_option_extension { @@ -18057,39 +18055,24 @@ aarch64_validate_mtune (const char *str, const struct processor **res) return false; } -static_assert (TARGET_CPU_generic < TARGET_CPU_MASK, - "TARGET_CPU_NBITS is big enough"); - -/* Return the CPU corresponding to the enum CPU. - If it doesn't specify a cpu, return the default. */ +/* Return the CPU corresponding to the enum CPU. */ static const struct processor * aarch64_get_tune_cpu (enum aarch64_processor cpu) { - if (cpu != aarch64_none) - return &all_cores[cpu]; + gcc_assert (cpu != aarch64_none); - /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that - encode the default cpu as selected by the --with-cpu GCC configure option - in config.gcc. - ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS - flags mechanism should be reworked to make it more sane. */ - return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + return &all_cores[cpu]; } -/* Return the architecture corresponding to the enum ARCH. - If it doesn't specify a valid architecture, return the default. */ +/* Return the architecture corresponding to the enum ARCH. */ static const struct processor * aarch64_get_arch (enum aarch64_arch arch) { - if (arch != aarch64_no_arch) - return &all_architectures[arch]; - - const struct processor *cpu - = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + gcc_assert (arch != aarch64_no_arch); - return &all_architectures[cpu->arch]; + return &all_architectures[arch]; } /* Return the VG value associated with -msve-vector-bits= value VALUE. */ @@ -18127,10 +18110,6 @@ aarch64_override_options (void) uint64_t arch_isa = 0; aarch64_isa_flags = 0; - bool valid_cpu = true; - bool valid_tune = true; - bool valid_arch = true; - selected_cpu = NULL; selected_arch = NULL; selected_tune = NULL; @@ -18145,77 +18124,56 @@ aarch64_override_options (void) If either of -march or -mtune is given, they override their respective component of -mcpu. */ if (aarch64_cpu_string) - valid_cpu = aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, - &cpu_isa); + aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, &cpu_isa); if (aarch64_arch_string) - valid_arch = aarch64_validate_march (aarch64_arch_string, &selected_arch, - &arch_isa); + aarch64_validate_march (aarch64_arch_string, &selected_arch, &arch_isa); if (aarch64_tune_string) - valid_tune = aarch64_validate_mtune (aarch64_tune_string, &selected_tune); + aarch64_validate_mtune (aarch64_tune_string, &selected_tune); #ifdef SUBTARGET_OVERRIDE_OPTIONS SUBTARGET_OVERRIDE_OPTIONS; #endif - /* If the user did not specify a processor, choose the default - one for them. This will be the CPU set during configuration using - --with-cpu, otherwise it is "generic". */ - if (!selected_cpu) - { - if (selected_arch) - { - selected_cpu = &all_cores[selected_arch->ident]; - aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - } - else - { - /* Get default configure-time CPU. */ - selected_cpu = aarch64_get_tune_cpu (aarch64_none); - aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS; - } - - if (selected_tune) - explicit_tune_core = selected_tune->ident; - } - /* If both -mcpu and -march are specified check that they are architecturally - compatible, warn if they're not and prefer the -march ISA flags. */ - else if (selected_arch) + if (selected_cpu && selected_arch) { + /* If both -mcpu and -march are specified, warn if they are not + architecturally compatible and prefer the -march ISA flags. */ if (selected_arch->arch != selected_cpu->arch) { warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch", aarch64_cpu_string, aarch64_arch_string); } + aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; } - else + else if (selected_cpu) { - /* -mcpu but no -march. */ - aarch64_isa_flags = cpu_isa; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; - gcc_assert (selected_cpu); selected_arch = &all_architectures[selected_cpu->arch]; - explicit_arch = selected_arch->arch; + aarch64_isa_flags = cpu_isa; } - - /* Set the arch as well as we will need it when outputing - the .arch directive in assembly. */ - if (!selected_arch) + else if (selected_arch) { - gcc_assert (selected_cpu); + selected_cpu = &all_cores[selected_arch->ident]; + aarch64_isa_flags = arch_isa; + } + else + { + /* No -mcpu or -march specified, so use the default CPU. */ + selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; selected_arch = &all_architectures[selected_cpu->arch]; + aarch64_isa_flags = selected_cpu->flags; } + explicit_arch = selected_arch->arch; if (!selected_tune) selected_tune = selected_cpu; + explicit_tune_core = selected_tune->ident; + + gcc_assert (explicit_tune_core != aarch64_none); + gcc_assert (explicit_arch != aarch64_no_arch); if (aarch64_enable_bti == 2) { @@ -18251,15 +18209,6 @@ aarch64_override_options (void) if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) sorry ("return address signing is only supported for %<-mabi=lp64%>"); - /* Make sure we properly set up the explicit options. */ - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_tune_string && valid_tune)) - gcc_assert (explicit_tune_core != aarch64_none); - - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_arch_string && valid_arch)) - gcc_assert (explicit_arch != aarch64_no_arch); - /* The pass to insert speculation tracking runs before shrink-wrapping and the latter does not know how to update the tracking status. So disable it in this case. */
Wilco Dijkstra via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > Hi Richard, > >> Although invoking ./cc1 directly only half-works with --with-arch, >> it half-works well-enough that I'd still like to keep it working. >> But I agree we should apply your change first, then I can follow up >> with a patch to make --with-* work with ./cc1 later. (I have a version >> locally and the net result is much simpler than the status quo, as well >> as hopefully actually working properly.) > > That sounds good indeed. Is that changing TARGET_CPU_DEFAULT into > a string can could just be parsed like a -mcpu option? Yeah, it emulates the DRIVER_SELF_SPECS stuff using string macros. >> Do we still need both selected_arch and explicit_arch? explicit_arch >> seems a misnomer now, since it includes implicit as well as explicit >> choices. Same for selected_tune and explicit_tune_core. > > At the moment we do since these are settings that must be saved/restored > since they can be overridden. Right, but I was wondering if we could save/restore them based on the selected_* values instead. However… > However it may be possible to do further cleanups to remove some of this. …I agree that might as well be a separate clean-up. > I also wonder whether we can remove the internal override feature > (override_tune_string) since that further complicates the tunings, and > I'm not convinced that it is either useful or being used at all. It's a developer option rather than a user-facing thing. I found it really useful when doing the Neoverse V1 tuning, and there are some tests that rely on it. I'd prefer to keep it if possible. >> aarch64_option_restore has: >> >> if (opts->x_explicit_tune_core == aarch64_none >> && opts->x_explicit_arch != aarch64_no_arch) >> selected_tune = &all_cores[selected_arch->ident]; >> else >> selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); >> >> Is the “if” condition ever true, or can we now restore the tune >> info unconditionally? > > Yes that was added a year or so after I created this patch, so this > is now redundant. I've removed it in v2: > > > The --with-cpu/--with-arch configure option processing not only checks valid arguments > but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used > however since a --with-cpu is translated into a -mcpu option which is processed as if > written on the command-line (so TARGET_CPU_DEFAULT is never accessed). > > So remove all the complex processing and bitmask, and just validate the option. > Fix a bug that always reports valid architecture extensions as invalid. As a result > the CPU processing in aarch64.c can be simplified. > > Bootstrap OK, regress pass, OK for commit? > > ChangeLog: > 2022-04-19 Wilco Dijkstra <wdijkstr@arm.com> > > * config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch > processing. Add support for architectural extensions. > * config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove > AARCH64_CPU_DEFAULT_FLAGS. > (TARGET_CPU_NBITS): Remove. > (TARGET_CPU_MASK): Remove. > * config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define. > (get_tune_cpu): Assert CPU is always valid. > (get_arch): Assert architecture is always valid. > (aarch64_override_options): Cleanup CPU selection code and simplify logic. > (aarch64_option_restore): Remove unnecessary checks on tune. Looks like you might have attached the old patch. The aarch64_option_restore change is mentioned in the changelog but doesn't appear in the patch itself. Thanks, Richard > > --- > > diff --git a/gcc/config.gcc b/gcc/config.gcc > index c5064dd376660c192d5573997b4fc86b6b3e3838..b48d5451e8027c93fb1f614812589183d0a88c4b 100644 > --- a/gcc/config.gcc > +++ b/gcc/config.gcc > @@ -4178,8 +4178,6 @@ case "${target}" in > pattern=AARCH64_CORE > fi > > - ext_mask=AARCH64_CPU_DEFAULT_FLAGS > - > # Find the base CPU or ARCH id in aarch64-cores.def or > # aarch64-arches.def > if [ x"$base_val" = x ] \ > @@ -4187,23 +4185,6 @@ case "${target}" in > ${srcdir}/config/aarch64/$def \ > > /dev/null; then > > - if [ $which = arch ]; then > - base_id=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/^[^,]*,[ ]*//' | \ > - sed -e 's/,.*$//'` > - # Extract the architecture flags from aarch64-arches.def > - ext_mask=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/)$//' | \ > - sed -e 's/^.*,//'` > - else > - base_id=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/^[^,]*,[ ]*//' | \ > - sed -e 's/,.*$//'` > - fi > - > # Disallow extensions in --with-tune=cortex-a53+crc. > if [ $which = tune ] && [ x"$ext_val" != x ]; then > echo "Architecture extensions not supported in --with-$which=$val" 1>&2 > @@ -4234,25 +4215,7 @@ case "${target}" in > grep "^\"$base_ext\""` > > if [ x"$base_ext" = x ] \ > - || [[ -n $opt_line ]]; then > - > - # These regexp extract the elements based on > - # their group match index in the regexp. > - ext_canon=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\2/"` > - ext_on=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\3/"` > - ext_off=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\4/"` > - > - if [ $ext = $base_ext ]; then > - # Adding extension > - ext_mask="("$ext_mask") | ("$ext_on" | "$ext_canon")" > - else > - # Removing extension > - ext_mask="("$ext_mask") & ~("$ext_off" | "$ext_canon")" > - fi > - > + || [ x"$opt_line" != x ]; then > true > else > echo "Unknown extension used in --with-$which=$val" 1>&2 > @@ -4261,10 +4224,6 @@ case "${target}" in > ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` > done > > - ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)" > - if [ x"$base_id" != x ]; then > - target_cpu_cname="TARGET_CPU_$base_id | $ext_mask" > - fi > true > else > # Allow --with-$which=native. > diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h > index 359b6e8561faa38f53a806b8c114c83ae37e7e17..f835da33b72f36bbf25a0e1328135411bd8ab4f6 100644 > --- a/gcc/config/aarch64/aarch64.h > +++ b/gcc/config/aarch64/aarch64.h > @@ -813,16 +813,9 @@ enum target_cpus > TARGET_CPU_generic > }; > > -/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT. > - This needs to be big enough to fit the value of TARGET_CPU_generic. > - All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */ > -#define TARGET_CPU_NBITS 8 > -#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1) > - > /* If there is no CPU defined at configure, use generic as default. */ > #ifndef TARGET_CPU_DEFAULT > -#define TARGET_CPU_DEFAULT \ > - (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS)) > +# define TARGET_CPU_DEFAULT TARGET_CPU_generic > #endif > > /* If inserting NOP before a mult-accumulate insn remember to adjust the > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index f650abbc4ce49cf0947049931f86bad1130c3428..43d87d1b9c4ef1a85094e51f81745f98f1ef27fb 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -2760,8 +2760,6 @@ static const struct attribute_spec aarch64_attribute_table[] = > { NULL, 0, 0, false, false, false, false, NULL, NULL } > }; > > -#define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) > - > /* An ISA extension in the co-processor and main instruction set space. */ > struct aarch64_option_extension > { > @@ -18057,39 +18055,24 @@ aarch64_validate_mtune (const char *str, const struct processor **res) > return false; > } > > -static_assert (TARGET_CPU_generic < TARGET_CPU_MASK, > - "TARGET_CPU_NBITS is big enough"); > - > -/* Return the CPU corresponding to the enum CPU. > - If it doesn't specify a cpu, return the default. */ > +/* Return the CPU corresponding to the enum CPU. */ > > static const struct processor * > aarch64_get_tune_cpu (enum aarch64_processor cpu) > { > - if (cpu != aarch64_none) > - return &all_cores[cpu]; > + gcc_assert (cpu != aarch64_none); > > - /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that > - encode the default cpu as selected by the --with-cpu GCC configure option > - in config.gcc. > - ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS > - flags mechanism should be reworked to make it more sane. */ > - return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; > + return &all_cores[cpu]; > } > > -/* Return the architecture corresponding to the enum ARCH. > - If it doesn't specify a valid architecture, return the default. */ > +/* Return the architecture corresponding to the enum ARCH. */ > > static const struct processor * > aarch64_get_arch (enum aarch64_arch arch) > { > - if (arch != aarch64_no_arch) > - return &all_architectures[arch]; > - > - const struct processor *cpu > - = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; > + gcc_assert (arch != aarch64_no_arch); > > - return &all_architectures[cpu->arch]; > + return &all_architectures[arch]; > } > > /* Return the VG value associated with -msve-vector-bits= value VALUE. */ > @@ -18127,10 +18110,6 @@ aarch64_override_options (void) > uint64_t arch_isa = 0; > aarch64_isa_flags = 0; > > - bool valid_cpu = true; > - bool valid_tune = true; > - bool valid_arch = true; > - > selected_cpu = NULL; > selected_arch = NULL; > selected_tune = NULL; > @@ -18145,77 +18124,56 @@ aarch64_override_options (void) > If either of -march or -mtune is given, they override their > respective component of -mcpu. */ > if (aarch64_cpu_string) > - valid_cpu = aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, > - &cpu_isa); > + aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, &cpu_isa); > > if (aarch64_arch_string) > - valid_arch = aarch64_validate_march (aarch64_arch_string, &selected_arch, > - &arch_isa); > + aarch64_validate_march (aarch64_arch_string, &selected_arch, &arch_isa); > > if (aarch64_tune_string) > - valid_tune = aarch64_validate_mtune (aarch64_tune_string, &selected_tune); > + aarch64_validate_mtune (aarch64_tune_string, &selected_tune); > > #ifdef SUBTARGET_OVERRIDE_OPTIONS > SUBTARGET_OVERRIDE_OPTIONS; > #endif > > - /* If the user did not specify a processor, choose the default > - one for them. This will be the CPU set during configuration using > - --with-cpu, otherwise it is "generic". */ > - if (!selected_cpu) > - { > - if (selected_arch) > - { > - selected_cpu = &all_cores[selected_arch->ident]; > - aarch64_isa_flags = arch_isa; > - explicit_arch = selected_arch->arch; > - } > - else > - { > - /* Get default configure-time CPU. */ > - selected_cpu = aarch64_get_tune_cpu (aarch64_none); > - aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS; > - } > - > - if (selected_tune) > - explicit_tune_core = selected_tune->ident; > - } > - /* If both -mcpu and -march are specified check that they are architecturally > - compatible, warn if they're not and prefer the -march ISA flags. */ > - else if (selected_arch) > + if (selected_cpu && selected_arch) > { > + /* If both -mcpu and -march are specified, warn if they are not > + architecturally compatible and prefer the -march ISA flags. */ > if (selected_arch->arch != selected_cpu->arch) > { > warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch", > aarch64_cpu_string, > aarch64_arch_string); > } > + > aarch64_isa_flags = arch_isa; > - explicit_arch = selected_arch->arch; > - explicit_tune_core = selected_tune ? selected_tune->ident > - : selected_cpu->ident; > } > - else > + else if (selected_cpu) > { > - /* -mcpu but no -march. */ > - aarch64_isa_flags = cpu_isa; > - explicit_tune_core = selected_tune ? selected_tune->ident > - : selected_cpu->ident; > - gcc_assert (selected_cpu); > selected_arch = &all_architectures[selected_cpu->arch]; > - explicit_arch = selected_arch->arch; > + aarch64_isa_flags = cpu_isa; > } > - > - /* Set the arch as well as we will need it when outputing > - the .arch directive in assembly. */ > - if (!selected_arch) > + else if (selected_arch) > { > - gcc_assert (selected_cpu); > + selected_cpu = &all_cores[selected_arch->ident]; > + aarch64_isa_flags = arch_isa; > + } > + else > + { > + /* No -mcpu or -march specified, so use the default CPU. */ > + selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; > selected_arch = &all_architectures[selected_cpu->arch]; > + aarch64_isa_flags = selected_cpu->flags; > } > > + explicit_arch = selected_arch->arch; > if (!selected_tune) > selected_tune = selected_cpu; > + explicit_tune_core = selected_tune->ident; > + > + gcc_assert (explicit_tune_core != aarch64_none); > + gcc_assert (explicit_arch != aarch64_no_arch); > > if (aarch64_enable_bti == 2) > { > @@ -18251,15 +18209,6 @@ aarch64_override_options (void) > if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) > sorry ("return address signing is only supported for %<-mabi=lp64%>"); > > - /* Make sure we properly set up the explicit options. */ > - if ((aarch64_cpu_string && valid_cpu) > - || (aarch64_tune_string && valid_tune)) > - gcc_assert (explicit_tune_core != aarch64_none); > - > - if ((aarch64_cpu_string && valid_cpu) > - || (aarch64_arch_string && valid_arch)) > - gcc_assert (explicit_arch != aarch64_no_arch); > - > /* The pass to insert speculation tracking runs before > shrink-wrapping and the latter does not know how to update the > tracking status. So disable it in this case. */
Hi Richard, > Looks like you might have attached the old patch. The aarch64_option_restore > change is mentioned in the changelog but doesn't appear in the patch itself. Indeed, not sure how that happened. Here is the correct v2 anyway. Wilco The --with-cpu/--with-arch configure option processing not only checks valid arguments but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used however since a --with-cpu is translated into a -mcpu option which is processed as if written on the command-line (so TARGET_CPU_DEFAULT is never accessed). So remove all the complex processing and bitmask, and just validate the option. Fix a bug that always reports valid architecture extensions as invalid. As a result the CPU processing in aarch64.c can be simplified. Bootstrap OK, regress pass, OK for commit? ChangeLog: 2022-04-19 Wilco Dijkstra <wdijkstr@arm.com> * config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch processing. Add support for architectural extensions. * config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove AARCH64_CPU_DEFAULT_FLAGS. (TARGET_CPU_NBITS): Remove. (TARGET_CPU_MASK): Remove. * config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define. (get_tune_cpu): Assert CPU is always valid. (get_arch): Assert architecture is always valid. (aarch64_override_options): Cleanup CPU selection code and simplify logic. (aarch64_option_restore): Remove unnecessary checks on tune. --- diff --git a/gcc/config.gcc b/gcc/config.gcc index c5064dd376660c192d5573997b4fc86b6b3e3838..b48d5451e8027c93fb1f614812589183d0a88c4b 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4178,8 +4178,6 @@ case "${target}" in pattern=AARCH64_CORE fi - ext_mask=AARCH64_CPU_DEFAULT_FLAGS - # Find the base CPU or ARCH id in aarch64-cores.def or # aarch64-arches.def if [ x"$base_val" = x ] \ @@ -4187,23 +4185,6 @@ case "${target}" in ${srcdir}/config/aarch64/$def \ > /dev/null; then - if [ $which = arch ]; then - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - # Extract the architecture flags from aarch64-arches.def - ext_mask=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/)$//' | \ - sed -e 's/^.*,//'` - else - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - fi - # Disallow extensions in --with-tune=cortex-a53+crc. if [ $which = tune ] && [ x"$ext_val" != x ]; then echo "Architecture extensions not supported in --with-$which=$val" 1>&2 @@ -4234,25 +4215,7 @@ case "${target}" in grep "^\"$base_ext\""` if [ x"$base_ext" = x ] \ - || [[ -n $opt_line ]]; then - - # These regexp extract the elements based on - # their group match index in the regexp. - ext_canon=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\2/"` - ext_on=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\3/"` - ext_off=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\4/"` - - if [ $ext = $base_ext ]; then - # Adding extension - ext_mask="("$ext_mask") | ("$ext_on" | "$ext_canon")" - else - # Removing extension - ext_mask="("$ext_mask") & ~("$ext_off" | "$ext_canon")" - fi - + || [ x"$opt_line" != x ]; then true else echo "Unknown extension used in --with-$which=$val" 1>&2 @@ -4261,10 +4224,6 @@ case "${target}" in ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` done - ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)" - if [ x"$base_id" != x ]; then - target_cpu_cname="TARGET_CPU_$base_id | $ext_mask" - fi true else # Allow --with-$which=native. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 359b6e8561faa38f53a806b8c114c83ae37e7e17..f835da33b72f36bbf25a0e1328135411bd8ab4f6 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -813,16 +813,9 @@ enum target_cpus TARGET_CPU_generic }; -/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT. - This needs to be big enough to fit the value of TARGET_CPU_generic. - All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */ -#define TARGET_CPU_NBITS 8 -#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1) - /* If there is no CPU defined at configure, use generic as default. */ #ifndef TARGET_CPU_DEFAULT -#define TARGET_CPU_DEFAULT \ - (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS)) +# define TARGET_CPU_DEFAULT TARGET_CPU_generic #endif /* If inserting NOP before a mult-accumulate insn remember to adjust the diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 1ec15741a4dba055b02732985d5a92a9252b166b..9294de799461f7f94c563f56b02e6e485ab7f1e6 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2760,8 +2760,6 @@ static const struct attribute_spec aarch64_attribute_table[] = { NULL, 0, 0, false, false, false, false, NULL, NULL } }; -#define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) - /* An ISA extension in the co-processor and main instruction set space. */ struct aarch64_option_extension { @@ -18040,39 +18038,24 @@ aarch64_validate_mtune (const char *str, const struct processor **res) return false; } -static_assert (TARGET_CPU_generic < TARGET_CPU_MASK, - "TARGET_CPU_NBITS is big enough"); - -/* Return the CPU corresponding to the enum CPU. - If it doesn't specify a cpu, return the default. */ +/* Return the CPU corresponding to the enum CPU. */ static const struct processor * aarch64_get_tune_cpu (enum aarch64_processor cpu) { - if (cpu != aarch64_none) - return &all_cores[cpu]; + gcc_assert (cpu != aarch64_none); - /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that - encode the default cpu as selected by the --with-cpu GCC configure option - in config.gcc. - ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS - flags mechanism should be reworked to make it more sane. */ - return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + return &all_cores[cpu]; } -/* Return the architecture corresponding to the enum ARCH. - If it doesn't specify a valid architecture, return the default. */ +/* Return the architecture corresponding to the enum ARCH. */ static const struct processor * aarch64_get_arch (enum aarch64_arch arch) { - if (arch != aarch64_no_arch) - return &all_architectures[arch]; - - const struct processor *cpu - = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + gcc_assert (arch != aarch64_no_arch); - return &all_architectures[cpu->arch]; + return &all_architectures[arch]; } /* Return the VG value associated with -msve-vector-bits= value VALUE. */ @@ -18110,10 +18093,6 @@ aarch64_override_options (void) uint64_t arch_isa = 0; aarch64_isa_flags = 0; - bool valid_cpu = true; - bool valid_tune = true; - bool valid_arch = true; - selected_cpu = NULL; selected_arch = NULL; selected_tune = NULL; @@ -18128,77 +18107,56 @@ aarch64_override_options (void) If either of -march or -mtune is given, they override their respective component of -mcpu. */ if (aarch64_cpu_string) - valid_cpu = aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, - &cpu_isa); + aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, &cpu_isa); if (aarch64_arch_string) - valid_arch = aarch64_validate_march (aarch64_arch_string, &selected_arch, - &arch_isa); + aarch64_validate_march (aarch64_arch_string, &selected_arch, &arch_isa); if (aarch64_tune_string) - valid_tune = aarch64_validate_mtune (aarch64_tune_string, &selected_tune); + aarch64_validate_mtune (aarch64_tune_string, &selected_tune); #ifdef SUBTARGET_OVERRIDE_OPTIONS SUBTARGET_OVERRIDE_OPTIONS; #endif - /* If the user did not specify a processor, choose the default - one for them. This will be the CPU set during configuration using - --with-cpu, otherwise it is "generic". */ - if (!selected_cpu) - { - if (selected_arch) - { - selected_cpu = &all_cores[selected_arch->ident]; - aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - } - else - { - /* Get default configure-time CPU. */ - selected_cpu = aarch64_get_tune_cpu (aarch64_none); - aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS; - } - - if (selected_tune) - explicit_tune_core = selected_tune->ident; - } - /* If both -mcpu and -march are specified check that they are architecturally - compatible, warn if they're not and prefer the -march ISA flags. */ - else if (selected_arch) + if (selected_cpu && selected_arch) { + /* If both -mcpu and -march are specified, warn if they are not + architecturally compatible and prefer the -march ISA flags. */ if (selected_arch->arch != selected_cpu->arch) { warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch", aarch64_cpu_string, aarch64_arch_string); } + aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; } - else + else if (selected_cpu) { - /* -mcpu but no -march. */ - aarch64_isa_flags = cpu_isa; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; - gcc_assert (selected_cpu); selected_arch = &all_architectures[selected_cpu->arch]; - explicit_arch = selected_arch->arch; + aarch64_isa_flags = cpu_isa; } - - /* Set the arch as well as we will need it when outputing - the .arch directive in assembly. */ - if (!selected_arch) + else if (selected_arch) { - gcc_assert (selected_cpu); + selected_cpu = &all_cores[selected_arch->ident]; + aarch64_isa_flags = arch_isa; + } + else + { + /* No -mcpu or -march specified, so use the default CPU. */ + selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; selected_arch = &all_architectures[selected_cpu->arch]; + aarch64_isa_flags = selected_cpu->flags; } + explicit_arch = selected_arch->arch; if (!selected_tune) selected_tune = selected_cpu; + explicit_tune_core = selected_tune->ident; + + gcc_assert (explicit_tune_core != aarch64_none); + gcc_assert (explicit_arch != aarch64_no_arch); if (aarch64_enable_bti == 2) { @@ -18234,15 +18192,6 @@ aarch64_override_options (void) if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) sorry ("return address signing is only supported for %<-mabi=lp64%>"); - /* Make sure we properly set up the explicit options. */ - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_tune_string && valid_tune)) - gcc_assert (explicit_tune_core != aarch64_none); - - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_arch_string && valid_arch)) - gcc_assert (explicit_arch != aarch64_no_arch); - /* The pass to insert speculation tracking runs before shrink-wrapping and the latter does not know how to update the tracking status. So disable it in this case. */ @@ -18348,11 +18297,7 @@ aarch64_option_restore (struct gcc_options *opts, opts->x_explicit_arch = ptr->x_explicit_arch; selected_arch = aarch64_get_arch (ptr->x_explicit_arch); opts->x_explicit_tune_core = ptr->x_explicit_tune_core; - if (opts->x_explicit_tune_core == aarch64_none - && opts->x_explicit_arch != aarch64_no_arch) - selected_tune = &all_cores[selected_arch->ident]; - else - selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); + selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); opts->x_aarch64_override_tune_string = ptr->x_aarch64_override_tune_string; opts->x_aarch64_branch_protection_string = ptr->x_aarch64_branch_protection_string;
Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes: > Hi Richard, > >> Looks like you might have attached the old patch. The aarch64_option_restore >> change is mentioned in the changelog but doesn't appear in the patch itself. > > Indeed, not sure how that happened. Here is the correct v2 anyway. > > Wilco > > > The --with-cpu/--with-arch configure option processing not only checks valid arguments > but also sets TARGET_CPU_DEFAULT with a CPU and extension bitmask. This isn't used > however since a --with-cpu is translated into a -mcpu option which is processed as if > written on the command-line (so TARGET_CPU_DEFAULT is never accessed). > > So remove all the complex processing and bitmask, and just validate the option. > Fix a bug that always reports valid architecture extensions as invalid. As a result > the CPU processing in aarch64.c can be simplified. > > Bootstrap OK, regress pass, OK for commit? > > ChangeLog: > 2022-04-19 Wilco Dijkstra <wdijkstr@arm.com> > > * config.gcc (aarch64*-*-*): Simplify --with-cpu and --with-arch > processing. Add support for architectural extensions. > * config/aarch64/aarch64.h (TARGET_CPU_DEFAULT): Remove > AARCH64_CPU_DEFAULT_FLAGS. > (TARGET_CPU_NBITS): Remove. > (TARGET_CPU_MASK): Remove. > * config/aarch64/aarch64.cc (AARCH64_CPU_DEFAULT_FLAGS): Remove define. > (get_tune_cpu): Assert CPU is always valid. > (get_arch): Assert architecture is always valid. > (aarch64_override_options): Cleanup CPU selection code and simplify logic. > (aarch64_option_restore): Remove unnecessary checks on tune. OK, thanks. Richard > --- > > diff --git a/gcc/config.gcc b/gcc/config.gcc > index c5064dd376660c192d5573997b4fc86b6b3e3838..b48d5451e8027c93fb1f614812589183d0a88c4b 100644 > --- a/gcc/config.gcc > +++ b/gcc/config.gcc > @@ -4178,8 +4178,6 @@ case "${target}" in > pattern=AARCH64_CORE > fi > > - ext_mask=AARCH64_CPU_DEFAULT_FLAGS > - > # Find the base CPU or ARCH id in aarch64-cores.def or > # aarch64-arches.def > if [ x"$base_val" = x ] \ > @@ -4187,23 +4185,6 @@ case "${target}" in > ${srcdir}/config/aarch64/$def \ > > /dev/null; then > > - if [ $which = arch ]; then > - base_id=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/^[^,]*,[ ]*//' | \ > - sed -e 's/,.*$//'` > - # Extract the architecture flags from aarch64-arches.def > - ext_mask=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/)$//' | \ > - sed -e 's/^.*,//'` > - else > - base_id=`grep "^$pattern(\"$base_val\"," \ > - ${srcdir}/config/aarch64/$def | \ > - sed -e 's/^[^,]*,[ ]*//' | \ > - sed -e 's/,.*$//'` > - fi > - > # Disallow extensions in --with-tune=cortex-a53+crc. > if [ $which = tune ] && [ x"$ext_val" != x ]; then > echo "Architecture extensions not supported in --with-$which=$val" 1>&2 > @@ -4234,25 +4215,7 @@ case "${target}" in > grep "^\"$base_ext\""` > > if [ x"$base_ext" = x ] \ > - || [[ -n $opt_line ]]; then > - > - # These regexp extract the elements based on > - # their group match index in the regexp. > - ext_canon=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\2/"` > - ext_on=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\3/"` > - ext_off=`echo -e "$opt_line" | \ > - sed -e "s/$sed_patt/\4/"` > - > - if [ $ext = $base_ext ]; then > - # Adding extension > - ext_mask="("$ext_mask") | ("$ext_on" | "$ext_canon")" > - else > - # Removing extension > - ext_mask="("$ext_mask") & ~("$ext_off" | "$ext_canon")" > - fi > - > + || [ x"$opt_line" != x ]; then > true > else > echo "Unknown extension used in --with-$which=$val" 1>&2 > @@ -4261,10 +4224,6 @@ case "${target}" in > ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` > done > > - ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)" > - if [ x"$base_id" != x ]; then > - target_cpu_cname="TARGET_CPU_$base_id | $ext_mask" > - fi > true > else > # Allow --with-$which=native. > diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h > index 359b6e8561faa38f53a806b8c114c83ae37e7e17..f835da33b72f36bbf25a0e1328135411bd8ab4f6 100644 > --- a/gcc/config/aarch64/aarch64.h > +++ b/gcc/config/aarch64/aarch64.h > @@ -813,16 +813,9 @@ enum target_cpus > TARGET_CPU_generic > }; > > -/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT. > - This needs to be big enough to fit the value of TARGET_CPU_generic. > - All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */ > -#define TARGET_CPU_NBITS 8 > -#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1) > - > /* If there is no CPU defined at configure, use generic as default. */ > #ifndef TARGET_CPU_DEFAULT > -#define TARGET_CPU_DEFAULT \ > - (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS)) > +# define TARGET_CPU_DEFAULT TARGET_CPU_generic > #endif > > /* If inserting NOP before a mult-accumulate insn remember to adjust the > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index 1ec15741a4dba055b02732985d5a92a9252b166b..9294de799461f7f94c563f56b02e6e485ab7f1e6 100644 > --- a/gcc/config/aarch64/aarch64.cc > +++ b/gcc/config/aarch64/aarch64.cc > @@ -2760,8 +2760,6 @@ static const struct attribute_spec aarch64_attribute_table[] = > { NULL, 0, 0, false, false, false, false, NULL, NULL } > }; > > -#define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) > - > /* An ISA extension in the co-processor and main instruction set space. */ > struct aarch64_option_extension > { > @@ -18040,39 +18038,24 @@ aarch64_validate_mtune (const char *str, const struct processor **res) > return false; > } > > -static_assert (TARGET_CPU_generic < TARGET_CPU_MASK, > - "TARGET_CPU_NBITS is big enough"); > - > -/* Return the CPU corresponding to the enum CPU. > - If it doesn't specify a cpu, return the default. */ > +/* Return the CPU corresponding to the enum CPU. */ > > static const struct processor * > aarch64_get_tune_cpu (enum aarch64_processor cpu) > { > - if (cpu != aarch64_none) > - return &all_cores[cpu]; > + gcc_assert (cpu != aarch64_none); > > - /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that > - encode the default cpu as selected by the --with-cpu GCC configure option > - in config.gcc. > - ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS > - flags mechanism should be reworked to make it more sane. */ > - return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; > + return &all_cores[cpu]; > } > > -/* Return the architecture corresponding to the enum ARCH. > - If it doesn't specify a valid architecture, return the default. */ > +/* Return the architecture corresponding to the enum ARCH. */ > > static const struct processor * > aarch64_get_arch (enum aarch64_arch arch) > { > - if (arch != aarch64_no_arch) > - return &all_architectures[arch]; > - > - const struct processor *cpu > - = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; > + gcc_assert (arch != aarch64_no_arch); > > - return &all_architectures[cpu->arch]; > + return &all_architectures[arch]; > } > > /* Return the VG value associated with -msve-vector-bits= value VALUE. */ > @@ -18110,10 +18093,6 @@ aarch64_override_options (void) > uint64_t arch_isa = 0; > aarch64_isa_flags = 0; > > - bool valid_cpu = true; > - bool valid_tune = true; > - bool valid_arch = true; > - > selected_cpu = NULL; > selected_arch = NULL; > selected_tune = NULL; > @@ -18128,77 +18107,56 @@ aarch64_override_options (void) > If either of -march or -mtune is given, they override their > respective component of -mcpu. */ > if (aarch64_cpu_string) > - valid_cpu = aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, > - &cpu_isa); > + aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, &cpu_isa); > > if (aarch64_arch_string) > - valid_arch = aarch64_validate_march (aarch64_arch_string, &selected_arch, > - &arch_isa); > + aarch64_validate_march (aarch64_arch_string, &selected_arch, &arch_isa); > > if (aarch64_tune_string) > - valid_tune = aarch64_validate_mtune (aarch64_tune_string, &selected_tune); > + aarch64_validate_mtune (aarch64_tune_string, &selected_tune); > > #ifdef SUBTARGET_OVERRIDE_OPTIONS > SUBTARGET_OVERRIDE_OPTIONS; > #endif > > - /* If the user did not specify a processor, choose the default > - one for them. This will be the CPU set during configuration using > - --with-cpu, otherwise it is "generic". */ > - if (!selected_cpu) > - { > - if (selected_arch) > - { > - selected_cpu = &all_cores[selected_arch->ident]; > - aarch64_isa_flags = arch_isa; > - explicit_arch = selected_arch->arch; > - } > - else > - { > - /* Get default configure-time CPU. */ > - selected_cpu = aarch64_get_tune_cpu (aarch64_none); > - aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS; > - } > - > - if (selected_tune) > - explicit_tune_core = selected_tune->ident; > - } > - /* If both -mcpu and -march are specified check that they are architecturally > - compatible, warn if they're not and prefer the -march ISA flags. */ > - else if (selected_arch) > + if (selected_cpu && selected_arch) > { > + /* If both -mcpu and -march are specified, warn if they are not > + architecturally compatible and prefer the -march ISA flags. */ > if (selected_arch->arch != selected_cpu->arch) > { > warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch", > aarch64_cpu_string, > aarch64_arch_string); > } > + > aarch64_isa_flags = arch_isa; > - explicit_arch = selected_arch->arch; > - explicit_tune_core = selected_tune ? selected_tune->ident > - : selected_cpu->ident; > } > - else > + else if (selected_cpu) > { > - /* -mcpu but no -march. */ > - aarch64_isa_flags = cpu_isa; > - explicit_tune_core = selected_tune ? selected_tune->ident > - : selected_cpu->ident; > - gcc_assert (selected_cpu); > selected_arch = &all_architectures[selected_cpu->arch]; > - explicit_arch = selected_arch->arch; > + aarch64_isa_flags = cpu_isa; > } > - > - /* Set the arch as well as we will need it when outputing > - the .arch directive in assembly. */ > - if (!selected_arch) > + else if (selected_arch) > { > - gcc_assert (selected_cpu); > + selected_cpu = &all_cores[selected_arch->ident]; > + aarch64_isa_flags = arch_isa; > + } > + else > + { > + /* No -mcpu or -march specified, so use the default CPU. */ > + selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; > selected_arch = &all_architectures[selected_cpu->arch]; > + aarch64_isa_flags = selected_cpu->flags; > } > > + explicit_arch = selected_arch->arch; > if (!selected_tune) > selected_tune = selected_cpu; > + explicit_tune_core = selected_tune->ident; > + > + gcc_assert (explicit_tune_core != aarch64_none); > + gcc_assert (explicit_arch != aarch64_no_arch); > > if (aarch64_enable_bti == 2) > { > @@ -18234,15 +18192,6 @@ aarch64_override_options (void) > if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) > sorry ("return address signing is only supported for %<-mabi=lp64%>"); > > - /* Make sure we properly set up the explicit options. */ > - if ((aarch64_cpu_string && valid_cpu) > - || (aarch64_tune_string && valid_tune)) > - gcc_assert (explicit_tune_core != aarch64_none); > - > - if ((aarch64_cpu_string && valid_cpu) > - || (aarch64_arch_string && valid_arch)) > - gcc_assert (explicit_arch != aarch64_no_arch); > - > /* The pass to insert speculation tracking runs before > shrink-wrapping and the latter does not know how to update the > tracking status. So disable it in this case. */ > @@ -18348,11 +18297,7 @@ aarch64_option_restore (struct gcc_options *opts, > opts->x_explicit_arch = ptr->x_explicit_arch; > selected_arch = aarch64_get_arch (ptr->x_explicit_arch); > opts->x_explicit_tune_core = ptr->x_explicit_tune_core; > - if (opts->x_explicit_tune_core == aarch64_none > - && opts->x_explicit_arch != aarch64_no_arch) > - selected_tune = &all_cores[selected_arch->ident]; > - else > - selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); > + selected_tune = aarch64_get_tune_cpu (ptr->x_explicit_tune_core); > opts->x_aarch64_override_tune_string = ptr->x_aarch64_override_tune_string; > opts->x_aarch64_branch_protection_string > = ptr->x_aarch64_branch_protection_string;
diff --git a/gcc/config.gcc b/gcc/config.gcc index c5064dd376660c192d5573997b4fc86b6b3e3838..b48d5451e8027c93fb1f614812589183d0a88c4b 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4178,8 +4178,6 @@ case "${target}" in pattern=AARCH64_CORE fi - ext_mask=AARCH64_CPU_DEFAULT_FLAGS - # Find the base CPU or ARCH id in aarch64-cores.def or # aarch64-arches.def if [ x"$base_val" = x ] \ @@ -4187,23 +4185,6 @@ case "${target}" in ${srcdir}/config/aarch64/$def \ > /dev/null; then - if [ $which = arch ]; then - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - # Extract the architecture flags from aarch64-arches.def - ext_mask=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/)$//' | \ - sed -e 's/^.*,//'` - else - base_id=`grep "^$pattern(\"$base_val\"," \ - ${srcdir}/config/aarch64/$def | \ - sed -e 's/^[^,]*,[ ]*//' | \ - sed -e 's/,.*$//'` - fi - # Disallow extensions in --with-tune=cortex-a53+crc. if [ $which = tune ] && [ x"$ext_val" != x ]; then echo "Architecture extensions not supported in --with-$which=$val" 1>&2 @@ -4234,25 +4215,7 @@ case "${target}" in grep "^\"$base_ext\""` if [ x"$base_ext" = x ] \ - || [[ -n $opt_line ]]; then - - # These regexp extract the elements based on - # their group match index in the regexp. - ext_canon=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\2/"` - ext_on=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\3/"` - ext_off=`echo -e "$opt_line" | \ - sed -e "s/$sed_patt/\4/"` - - if [ $ext = $base_ext ]; then - # Adding extension - ext_mask="("$ext_mask") | ("$ext_on" | "$ext_canon")" - else - # Removing extension - ext_mask="("$ext_mask") & ~("$ext_off" | "$ext_canon")" - fi - + || [ x"$opt_line" != x ]; then true else echo "Unknown extension used in --with-$which=$val" 1>&2 @@ -4261,10 +4224,6 @@ case "${target}" in ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` done - ext_mask="(("$ext_mask") << TARGET_CPU_NBITS)" - if [ x"$base_id" != x ]; then - target_cpu_cname="TARGET_CPU_$base_id | $ext_mask" - fi true else # Allow --with-$which=native. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 359b6e8561faa38f53a806b8c114c83ae37e7e17..f835da33b72f36bbf25a0e1328135411bd8ab4f6 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -813,16 +813,9 @@ enum target_cpus TARGET_CPU_generic }; -/* Define how many bits are used to represent the CPU in TARGET_CPU_DEFAULT. - This needs to be big enough to fit the value of TARGET_CPU_generic. - All bits after this are used to represent the AARCH64_CPU_DEFAULT_FLAGS. */ -#define TARGET_CPU_NBITS 8 -#define TARGET_CPU_MASK ((1 << TARGET_CPU_NBITS) - 1) - /* If there is no CPU defined at configure, use generic as default. */ #ifndef TARGET_CPU_DEFAULT -#define TARGET_CPU_DEFAULT \ - (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << TARGET_CPU_NBITS)) +# define TARGET_CPU_DEFAULT TARGET_CPU_generic #endif /* If inserting NOP before a mult-accumulate insn remember to adjust the diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f650abbc4ce49cf0947049931f86bad1130c3428..43d87d1b9c4ef1a85094e51f81745f98f1ef27fb 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -2760,8 +2760,6 @@ static const struct attribute_spec aarch64_attribute_table[] = { NULL, 0, 0, false, false, false, false, NULL, NULL } }; -#define AARCH64_CPU_DEFAULT_FLAGS ((selected_cpu) ? selected_cpu->flags : 0) - /* An ISA extension in the co-processor and main instruction set space. */ struct aarch64_option_extension { @@ -18057,39 +18055,24 @@ aarch64_validate_mtune (const char *str, const struct processor **res) return false; } -static_assert (TARGET_CPU_generic < TARGET_CPU_MASK, - "TARGET_CPU_NBITS is big enough"); - -/* Return the CPU corresponding to the enum CPU. - If it doesn't specify a cpu, return the default. */ +/* Return the CPU corresponding to the enum CPU. */ static const struct processor * aarch64_get_tune_cpu (enum aarch64_processor cpu) { - if (cpu != aarch64_none) - return &all_cores[cpu]; + gcc_assert (cpu != aarch64_none); - /* The & TARGET_CPU_MASK is to extract the bottom TARGET_CPU_NBITS bits that - encode the default cpu as selected by the --with-cpu GCC configure option - in config.gcc. - ???: The whole TARGET_CPU_DEFAULT and AARCH64_CPU_DEFAULT_FLAGS - flags mechanism should be reworked to make it more sane. */ - return &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + return &all_cores[cpu]; } -/* Return the architecture corresponding to the enum ARCH. - If it doesn't specify a valid architecture, return the default. */ +/* Return the architecture corresponding to the enum ARCH. */ static const struct processor * aarch64_get_arch (enum aarch64_arch arch) { - if (arch != aarch64_no_arch) - return &all_architectures[arch]; - - const struct processor *cpu - = &all_cores[TARGET_CPU_DEFAULT & TARGET_CPU_MASK]; + gcc_assert (arch != aarch64_no_arch); - return &all_architectures[cpu->arch]; + return &all_architectures[arch]; } /* Return the VG value associated with -msve-vector-bits= value VALUE. */ @@ -18127,10 +18110,6 @@ aarch64_override_options (void) uint64_t arch_isa = 0; aarch64_isa_flags = 0; - bool valid_cpu = true; - bool valid_tune = true; - bool valid_arch = true; - selected_cpu = NULL; selected_arch = NULL; selected_tune = NULL; @@ -18145,77 +18124,56 @@ aarch64_override_options (void) If either of -march or -mtune is given, they override their respective component of -mcpu. */ if (aarch64_cpu_string) - valid_cpu = aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, - &cpu_isa); + aarch64_validate_mcpu (aarch64_cpu_string, &selected_cpu, &cpu_isa); if (aarch64_arch_string) - valid_arch = aarch64_validate_march (aarch64_arch_string, &selected_arch, - &arch_isa); + aarch64_validate_march (aarch64_arch_string, &selected_arch, &arch_isa); if (aarch64_tune_string) - valid_tune = aarch64_validate_mtune (aarch64_tune_string, &selected_tune); + aarch64_validate_mtune (aarch64_tune_string, &selected_tune); #ifdef SUBTARGET_OVERRIDE_OPTIONS SUBTARGET_OVERRIDE_OPTIONS; #endif - /* If the user did not specify a processor, choose the default - one for them. This will be the CPU set during configuration using - --with-cpu, otherwise it is "generic". */ - if (!selected_cpu) - { - if (selected_arch) - { - selected_cpu = &all_cores[selected_arch->ident]; - aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - } - else - { - /* Get default configure-time CPU. */ - selected_cpu = aarch64_get_tune_cpu (aarch64_none); - aarch64_isa_flags = TARGET_CPU_DEFAULT >> TARGET_CPU_NBITS; - } - - if (selected_tune) - explicit_tune_core = selected_tune->ident; - } - /* If both -mcpu and -march are specified check that they are architecturally - compatible, warn if they're not and prefer the -march ISA flags. */ - else if (selected_arch) + if (selected_cpu && selected_arch) { + /* If both -mcpu and -march are specified, warn if they are not + architecturally compatible and prefer the -march ISA flags. */ if (selected_arch->arch != selected_cpu->arch) { warning (0, "switch %<-mcpu=%s%> conflicts with %<-march=%s%> switch", aarch64_cpu_string, aarch64_arch_string); } + aarch64_isa_flags = arch_isa; - explicit_arch = selected_arch->arch; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; } - else + else if (selected_cpu) { - /* -mcpu but no -march. */ - aarch64_isa_flags = cpu_isa; - explicit_tune_core = selected_tune ? selected_tune->ident - : selected_cpu->ident; - gcc_assert (selected_cpu); selected_arch = &all_architectures[selected_cpu->arch]; - explicit_arch = selected_arch->arch; + aarch64_isa_flags = cpu_isa; } - - /* Set the arch as well as we will need it when outputing - the .arch directive in assembly. */ - if (!selected_arch) + else if (selected_arch) { - gcc_assert (selected_cpu); + selected_cpu = &all_cores[selected_arch->ident]; + aarch64_isa_flags = arch_isa; + } + else + { + /* No -mcpu or -march specified, so use the default CPU. */ + selected_cpu = &all_cores[TARGET_CPU_DEFAULT]; selected_arch = &all_architectures[selected_cpu->arch]; + aarch64_isa_flags = selected_cpu->flags; } + explicit_arch = selected_arch->arch; if (!selected_tune) selected_tune = selected_cpu; + explicit_tune_core = selected_tune->ident; + + gcc_assert (explicit_tune_core != aarch64_none); + gcc_assert (explicit_arch != aarch64_no_arch); if (aarch64_enable_bti == 2) { @@ -18251,15 +18209,6 @@ aarch64_override_options (void) if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) sorry ("return address signing is only supported for %<-mabi=lp64%>"); - /* Make sure we properly set up the explicit options. */ - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_tune_string && valid_tune)) - gcc_assert (explicit_tune_core != aarch64_none); - - if ((aarch64_cpu_string && valid_cpu) - || (aarch64_arch_string && valid_arch)) - gcc_assert (explicit_arch != aarch64_no_arch); - /* The pass to insert speculation tracking runs before shrink-wrapping and the latter does not know how to update the tracking status. So disable it in this case. */