From patchwork Wed Dec 6 12:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Carlotti X-Patchwork-Id: 174562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4077123vqy; Wed, 6 Dec 2023 04:45:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtLA9Kv+fsflg82yU9QaF8smCGktdq1wK0Ix2wL7zcBcBy387eGEu3YA/EDYUpVk86Ukom X-Received: by 2002:a05:620a:2b9b:b0:77e:fba3:a79e with SMTP id dz27-20020a05620a2b9b00b0077efba3a79emr802675qkb.124.1701866711141; Wed, 06 Dec 2023 04:45:11 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1701866711; cv=pass; d=google.com; s=arc-20160816; b=miQ8Qd8aFEYI0N2aTYf64Saf0hfIZ+5uw96kWx24fcia4B96wgWHKmaEp7fUf4DApP LluHj9s8yhuN/3wpZtvry9y+AX5jDCU1uQfInIptKgsydc1dY7IA//bXnaNbUv/5hWvM w4ajQGRyc44/o+tTxVrTOxoOqJbszBHp2UqINzeNTXtVPhDeNTgYrPqOo8kVZ1BMNays 4J8e9ysAix4CULAb1OH3Wsg9irJ5rSQxqn019KHhNNuQ0eafXaA9V2E79H3q/bv5bmYc NN1iz4+BlhdewwNC1GDCR6oSaheDQcTMVdBZSflcd+sZIQ4nS9FLTUpzwoWVMIbLn7ml gN4A== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date :authentication-results-original:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=iDRExrwg/O1oUsa8Eq5Xg1M6afVp5FkdPU/BZIJHvoM=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=hKzLjSAZy677KLnFMF9tdxgomSOe1s7TXfP3Ee7cnxcfc+Vqi8KVqHWczG9Li5IVPB Dh/7Uxe+6n6rA+xpOhgON6/pSdtsIB0koJrIq6SKIuf+z2Di18Eox0efAPc+XpnlbPxE 0g02t4EYgY3JhrCr/zIG1x1shEA6I0bXONOTdF44y7KMYhRFu6rR3fjW/375KG1FN0O1 R38Tg++3qpsC+YI1APOHOy0k9g73kgFg7p8rE2IZYWTMHW1XlEXGdYQKzK5j4s9V0RPZ nlCNMqgQjXZPmxdmHhSEFKe16ELAqLCwtasqQygrK9Anx3FnKXUiKk/JRbv1wsm6VDG3 UR9Q== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=zSiUuXHT; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=zSiUuXHT; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a40-20020a05620a43a800b0077d59d88b35si14067739qkp.666.2023.12.06.04.45.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:45:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=zSiUuXHT; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=zSiUuXHT; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC5243858423 for ; Wed, 6 Dec 2023 12:45:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2041.outbound.protection.outlook.com [40.107.22.41]) by sourceware.org (Postfix) with ESMTPS id 62F52385840B for ; Wed, 6 Dec 2023 12:44:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62F52385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 62F52385840B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.22.41 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866686; cv=pass; b=mtOMkq+EKjcPRK+r27oEvoVyDNFpydNO3I9ha9tNPQtLV1wm4HMDKxtIO+X1UnJNWVAtDYFDKcmWKYWXCqohn29iCQXbvAJXFpY3d8Cs6B2zA5anPSxjP+HfqLjiN2r5ct42eaV3ntUgPykSpR6kfUznCpR43hY8T0elyf1F+L4= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866686; c=relaxed/simple; bh=dQlvnArCTucnw82CW88pXL8pRRBYldLtAvtFR9GugXQ=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=xfLpCEDooJLvab5PMtJGvDa1EcK0ghDuExBkZVC5AJpOe0gc5JhTK2oRUPRw7Biids4JpRVkws/p3WsKG0DZhpv5ytmtJ/k+zK5DYrlN/OlRebvsPWm2fukggNfjgAE0hA/lD6HVrvWZjvjKVh0V62kgcIb8Yj09xm61vePKDMQ= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Aszk1+ngO1lEPoU7rV0ZKij9JHDmNl16mD0hhXSNSJZkPapZnM8Bd/NgdM46fK7D/mChAnksjL9Zv7TH9024EUibBSCSxLkjVFLLUs12VBiqeSdJAx+LPf8k0zc8zhq1VYm2d4gOfAfe/cvbiOHGtKuVEmKud5sjCpJ1uTbVU8ZomkNr1yxn1LPSgJieYoYGBP/IcfuhCUBDszgsPBPj92Yiqqn1JinltxoBeP0xkMkirP4AR9nJZIKdtZrlUUXJadkDsebF0Vv/r39UEByNgjxgqiGnrCdSliIolbsyDJchZ9AGokcqcuA48Qb7d6w68/GhsvBjXzl1ozFU8t6Btg== 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=iDRExrwg/O1oUsa8Eq5Xg1M6afVp5FkdPU/BZIJHvoM=; b=gjZhKLFn4t8x1rn5KY4LNGkY94p/VxNtMuVQpFgBpt+zbiT28kdIH5JFIlLQ99kFutfamCHsQNi1BynLS+xilvV5ty93XzypCpmVIRlCxltjD1a2BN1xe8fgKTJle5QYJ7siVHpMDygf1hYGOIfRIp9IlEt8n3TN/ApH7zwP9f/dL0pJSUBOrNLEzbXU6KyN5hzjyQ916IjAqmpxSk0oJwzpGL2FZecHMeidvGJ1D339DZ+a9SNhgiWYAJ/qgCM7D06odNSNZWXpEUzV36YcQLeREooekYiL2vGPfEIa8pLjLDVCxYDKvLzqfi6JbAHJ4NaZcTQGDWxRjghNgBTt5A== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iDRExrwg/O1oUsa8Eq5Xg1M6afVp5FkdPU/BZIJHvoM=; b=zSiUuXHTtqMZ8KmrTPmYmXiRKHGG6NwVrMIXA9sc5B78U1YcZ0tcpd/Y1sdSBk5TziUYnoJvOuDZGH8l0NPg5bgoe8imQCDQM0n7RBFsq4znexj+AvWcbKNSj9fdfGYxiugdGDqyo9sa5XU3OrVwSCqEhxIbINnsrBgZumlf1KQ= Received: from AS9P194CA0020.EURP194.PROD.OUTLOOK.COM (2603:10a6:20b:46d::20) by DB3PR08MB9897.eurprd08.prod.outlook.com (2603:10a6:10:436::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 12:44:38 +0000 Received: from AM3PEPF0000A79C.eurprd04.prod.outlook.com (2603:10a6:20b:46d:cafe::7c) by AS9P194CA0020.outlook.office365.com (2603:10a6:20b:46d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29 via Frontend Transport; Wed, 6 Dec 2023 12:44:38 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM3PEPF0000A79C.mail.protection.outlook.com (10.167.16.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.24 via Frontend Transport; Wed, 6 Dec 2023 12:44:38 +0000 Received: ("Tessian outbound 385ad2f98d71:v228"); Wed, 06 Dec 2023 12:44:38 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dfe5d51c7ab5631c X-CR-MTA-TID: 64aa7808 Received: from ca13b0140954.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EF173670-1C11-45C0-B99B-57810E0FE8DD.1; Wed, 06 Dec 2023 12:44:32 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ca13b0140954.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Dec 2023 12:44:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ea8FKQdOf6takQraslT75rr/FyfuQBPzAVlnMG9diWfASdZxfhuLMzisoSBGFsfo4z8OvgjStvp+yyZPiOv4eHYsEzTpeMl2J0vnn0XWyY9LmbuX1hYkKHItW9RXeHikMISucHi4MKVhBZ2VTgfRz5RYmXaP1akH3ff7hIqzvfnnquEVw9h7f/eLTD6fV/i+A+DFGMlEbKq+D6aJ7qgAJrgM59HQFVhhQ4woeWfqt4YB8qVMeB585KzgcAEQ9CwgcRc5QL5NjDPgXomNaFhVebaukp0JsfLobiTbTpvIX2fbARURO6mvBXQ2B40WRbCn4ShyjYlt4ts5v0z6xd9XVw== 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=iDRExrwg/O1oUsa8Eq5Xg1M6afVp5FkdPU/BZIJHvoM=; b=X9FT4zCvEb+DZVsK3bqSCNHvndR86lVU7qiTl1UwvF/rOveVb/T2l9Uxil9osq/0GYfZDrvXtet4ZP8e3PgLVTImYoii7yvd4pQx0RT3vyA8vazyGdtbOkN17oqqwiCzuTVDkK/SY9rL6i36k4UGnqY5vLA86dVcjx5T5RE9HgVZN+PkBApFyyCtbcMLz3qMTPikE+JPwgTx4ma6xrRX/egmmvB4vO6bR+kDNRfYLpVd7nYwWGjFM+N5PyAXjUh1KWqJbpSWgDUTk4DowHCvHlrrCjzm+19EZG1c9pfkYQAgsyufvd/RRzMnOpCXkxVwpP8uE1DgRR7LZxI9+LvUUA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iDRExrwg/O1oUsa8Eq5Xg1M6afVp5FkdPU/BZIJHvoM=; b=zSiUuXHTtqMZ8KmrTPmYmXiRKHGG6NwVrMIXA9sc5B78U1YcZ0tcpd/Y1sdSBk5TziUYnoJvOuDZGH8l0NPg5bgoe8imQCDQM0n7RBFsq4znexj+AvWcbKNSj9fdfGYxiugdGDqyo9sa5XU3OrVwSCqEhxIbINnsrBgZumlf1KQ= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by AS8PR08MB5942.eurprd08.prod.outlook.com (2603:10a6:20b:29f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 12:44:30 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2%7]) with mapi id 15.20.7068.025; Wed, 6 Dec 2023 12:44:30 +0000 Date: Wed, 6 Dec 2023 12:44:26 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [1/5] aarch64: Add cpu feature detection to libgcc Message-ID: References: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> Content-Disposition: inline In-Reply-To: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> X-ClientProxiedBy: LNXP265CA0045.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::33) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS8PR08MB5942:EE_|AM3PEPF0000A79C:EE_|DB3PR08MB9897:EE_ X-MS-Office365-Filtering-Correlation-Id: f3d473c1-60df-4a71-356f-08dbf6591c01 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: +4MEz0ocwX1FnwmaNBCrOzbhBO80svPDx+pN082SGxfQ41ZxSwJAR6gHncnE9VldeR4yGrs4JPi4JAQpyQSUvgzgZ6UW7vIi2/f6XlnWm6iZXYzMXbX8fAQTYuYyjnf1oVvMSBnzXvHtO/ebzr/ISCm/tVYZLQVGFHfqjvQCJ6cJTAyWNWlO8GDCxSoQmqsCD/CfxiZaYeVWwjvKpLe5ztxVyUv5yzqYTSCbPUYoev0fwIpTwH4iMR4lVWF6b31kTpMxXmxPKbkV2m/ceLk9e/bV/jecG6kdZ+57A1trbbGifj99n2jl7YgQf9lpu+7cDXtnnyP/Gx5myKDanu1E2NeNfXjaDxA/C83mtgiOjoptHobtgBZnkmFo98ykU6eTgxSUu31fydNmk3dRdy7dyRM8npxTXH43WXW3sRl5GEQcMkX6PKbjAnn73A73VZJwGWos3sZOCXpMAOmBAIDxTgnaXruNHxXBYog79kpEOklwV2N/pgvJLmmODm8Nk1F1xS5kTvnZ5jLdJlBFcl1BfSiqWz50zD8GJVroRW4IQKFsZQJs3L7esyo0JKTLCtRhjAk2k91+j1MYhXLu4gST6mK/8VZFTHonMX0AV9VeXv8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39860400002)(346002)(376002)(366004)(396003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(5660300002)(44832011)(6506007)(6666004)(86362001)(8676002)(8936002)(4326008)(31696002)(41300700001)(38100700002)(31686004)(2906002)(30864003)(6512007)(26005)(83380400001)(478600001)(316002)(66556008)(66946007)(6916009)(66476007)(6486002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5942 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: AM3PEPF0000A79C.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0ac3ef26-2a76-4897-4c03-08dbf65916e2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dW0WPVem8bAVQeI9DU8UdJ9DquhHOj6aD5vX+CauS3m8KGy/IrEUnH0IhYnkJC6OMmoWF76mkeY/irMqt/7da2JMdHoC+HtwEEpq+TRs149NS9twQF9pwx5NdP10YfCUV+7TIQhTX53EZeI6iG+MiU0ceLI4oNqd2EX5vtGg24OkEpzCSPms4YgtTMDzul5ZIpnS9tLS5OSSRtjwwB1zSxJE8zVlmUn4gfKMF1lqMffz3MqMe4xAs7XeeeB2PNL8avTnhAv1iYIBRp9+HKg9dOn5k2SqCg1IW5Ka0HeSa/VS+wjvGZ1apsOuuAH4KdOIGyAWm+9AAGuRw17vkDPLoox8O8mDZTDn+bBNDpdLjiGZ/w+LX4PscFFxi13p/CumiyDfBHLYf8x6PdVkcUjzz03W+yapvt3NXEpbcNwhwte6Fv457NnEimYB90fB+0J2xSTiK+b7XF2vz8svhq8a1kB8JsGPy1C4XVOY5hfrEc9xnE56MiTyZL2wwEDTHE3hNTaFOsi1iPvTZzR6Rq9TTgp4RWJzzxb/trBWdwGlf0jKhAD/VvbTf69ec+87glRkl51kwYo3Q4EdZ8aBpPjt27v+tXYQZvrtsbfbor+MMeLtqogiGXcu10FilahgRdrjEDILYX4WbzMoFZsvCYVydD1pHRSVxR49W/0px8NnKz4Dx2S4RSA6hguDHv2MusPh+LnuXPjZ0sO4PmI+uyWxlQ== 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:(13230031)(4636009)(346002)(376002)(136003)(396003)(39850400004)(230922051799003)(1800799012)(451199024)(186009)(82310400011)(64100799003)(46966006)(36840700001)(31686004)(40480700001)(316002)(478600001)(8676002)(6486002)(47076005)(336012)(6506007)(6666004)(26005)(4326008)(70206006)(70586007)(6916009)(83380400001)(8936002)(82740400003)(5660300002)(30864003)(6512007)(81166007)(356005)(44832011)(2906002)(86362001)(36860700001)(31696002)(41300700001)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 12:44:38.4795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3d473c1-60df-4a71-356f-08dbf6591c01 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: AM3PEPF0000A79C.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB9897 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784536588902144576 X-GMAIL-MSGID: 1784536588902144576 This is added to enable function multiversioning, but can also be used directly. The interface is chosen to match that used in LLVM's compiler-rt, to facilitate cross-compiler compatibility. The content of the patch is derived almost entirely from Pavel's prior contributions to compiler-rt/lib/builtins/cpu_model.c. I have made minor changes to align more closely with GCC coding style, and to exclude any code from other LLVM contributors, and am adding this to GCC with Pavel's approval. libgcc/ChangeLog: * config/aarch64/t-aarch64: Include cpuinfo.c * config/aarch64/cpuinfo.c: New file (__init_cpu_features_constructor) New. (__init_cpu_features_resolver) New. (__init_cpu_features) New. Co-authored-by: Pavel Iliin diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c new file mode 100644 index 0000000000000000000000000000000000000000..634f591c194bc70048f714d7eb0ace1f2f4137ea --- /dev/null +++ b/libgcc/config/aarch64/cpuinfo.c @@ -0,0 +1,500 @@ +/* CPU feature detection for AArch64 architecture. + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GCC. + + This file is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3, or (at your option) any + later version. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#if __has_include() +#include + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif + +#if __has_include() +#include + +/* CPUFeatures must correspond to the same AArch64 features in aarch64.cc */ +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT, + FEAT_DPB, + FEAT_DPB2, + FEAT_JSCVT, + FEAT_FCMA, + FEAT_RCPC, + FEAT_RCPC2, + FEAT_FRINTTS, + FEAT_DGH, + FEAT_I8MM, + FEAT_BF16, + FEAT_EBF16, + FEAT_RPRES, + FEAT_SVE, + FEAT_SVE_BF16, + FEAT_SVE_EBF16, + FEAT_SVE_I8MM, + FEAT_SVE_F32MM, + FEAT_SVE_F64MM, + FEAT_SVE2, + FEAT_SVE_AES, + FEAT_SVE_PMULL128, + FEAT_SVE_BITPERM, + FEAT_SVE_SHA3, + FEAT_SVE_SM4, + FEAT_SME, + FEAT_MEMTAG, + FEAT_MEMTAG2, + FEAT_MEMTAG3, + FEAT_SB, + FEAT_PREDRES, + FEAT_SSBS, + FEAT_SSBS2, + FEAT_BTI, + FEAT_LS64, + FEAT_LS64_V, + FEAT_LS64_ACCDATA, + FEAT_WFXT, + FEAT_SME_F64, + FEAT_SME_I64, + FEAT_SME2, + FEAT_RCPC3, + FEAT_MAX, + FEAT_EXT = 62, /* Reserved to indicate presence of additional features field + in __aarch64_cpu_features. */ + FEAT_INIT /* Used as flag of features initialization completion. */ +}; + +/* Architecture features used in Function Multi Versioning. */ +struct { + unsigned long long features; + /* As features grows new fields could be added. */ +} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon)); + +#ifndef _IFUNC_ARG_HWCAP +#define _IFUNC_ARG_HWCAP (1ULL << 62) +#endif +#ifndef AT_HWCAP +#define AT_HWCAP 16 +#endif +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif +#ifndef HWCAP_FP +#define HWCAP_FP (1 << 0) +#endif +#ifndef HWCAP_ASIMD +#define HWCAP_ASIMD (1 << 1) +#endif +#ifndef HWCAP_AES +#define HWCAP_AES (1 << 3) +#endif +#ifndef HWCAP_PMULL +#define HWCAP_PMULL (1 << 4) +#endif +#ifndef HWCAP_SHA1 +#define HWCAP_SHA1 (1 << 5) +#endif +#ifndef HWCAP_SHA2 +#define HWCAP_SHA2 (1 << 6) +#endif +#ifndef HWCAP_ATOMICS +#define HWCAP_ATOMICS (1 << 8) +#endif +#ifndef HWCAP_FPHP +#define HWCAP_FPHP (1 << 9) +#endif +#ifndef HWCAP_ASIMDHP +#define HWCAP_ASIMDHP (1 << 10) +#endif +#ifndef HWCAP_ASIMDRDM +#define HWCAP_ASIMDRDM (1 << 12) +#endif +#ifndef HWCAP_JSCVT +#define HWCAP_JSCVT (1 << 13) +#endif +#ifndef HWCAP_FCMA +#define HWCAP_FCMA (1 << 14) +#endif +#ifndef HWCAP_LRCPC +#define HWCAP_LRCPC (1 << 15) +#endif +#ifndef HWCAP_DCPOP +#define HWCAP_DCPOP (1 << 16) +#endif +#ifndef HWCAP_SHA3 +#define HWCAP_SHA3 (1 << 17) +#endif +#ifndef HWCAP_SM3 +#define HWCAP_SM3 (1 << 18) +#endif +#ifndef HWCAP_SM4 +#define HWCAP_SM4 (1 << 19) +#endif +#ifndef HWCAP_ASIMDDP +#define HWCAP_ASIMDDP (1 << 20) +#endif +#ifndef HWCAP_SHA512 +#define HWCAP_SHA512 (1 << 21) +#endif +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif +#ifndef HWCAP_ASIMDFHM +#define HWCAP_ASIMDFHM (1 << 23) +#endif +#ifndef HWCAP_DIT +#define HWCAP_DIT (1 << 24) +#endif +#ifndef HWCAP_ILRCPC +#define HWCAP_ILRCPC (1 << 26) +#endif +#ifndef HWCAP_FLAGM +#define HWCAP_FLAGM (1 << 27) +#endif +#ifndef HWCAP_SSBS +#define HWCAP_SSBS (1 << 28) +#endif +#ifndef HWCAP_SB +#define HWCAP_SB (1 << 29) +#endif + +#ifndef HWCAP2_DCPODP +#define HWCAP2_DCPODP (1 << 0) +#endif +#ifndef HWCAP2_SVE2 +#define HWCAP2_SVE2 (1 << 1) +#endif +#ifndef HWCAP2_SVEAES +#define HWCAP2_SVEAES (1 << 2) +#endif +#ifndef HWCAP2_SVEPMULL +#define HWCAP2_SVEPMULL (1 << 3) +#endif +#ifndef HWCAP2_SVEBITPERM +#define HWCAP2_SVEBITPERM (1 << 4) +#endif +#ifndef HWCAP2_SVESHA3 +#define HWCAP2_SVESHA3 (1 << 5) +#endif +#ifndef HWCAP2_SVESM4 +#define HWCAP2_SVESM4 (1 << 6) +#endif +#ifndef HWCAP2_FLAGM2 +#define HWCAP2_FLAGM2 (1 << 7) +#endif +#ifndef HWCAP2_FRINT +#define HWCAP2_FRINT (1 << 8) +#endif +#ifndef HWCAP2_SVEI8MM +#define HWCAP2_SVEI8MM (1 << 9) +#endif +#ifndef HWCAP2_SVEF32MM +#define HWCAP2_SVEF32MM (1 << 10) +#endif +#ifndef HWCAP2_SVEF64MM +#define HWCAP2_SVEF64MM (1 << 11) +#endif +#ifndef HWCAP2_SVEBF16 +#define HWCAP2_SVEBF16 (1 << 12) +#endif +#ifndef HWCAP2_I8MM +#define HWCAP2_I8MM (1 << 13) +#endif +#ifndef HWCAP2_BF16 +#define HWCAP2_BF16 (1 << 14) +#endif +#ifndef HWCAP2_DGH +#define HWCAP2_DGH (1 << 15) +#endif +#ifndef HWCAP2_RNG +#define HWCAP2_RNG (1 << 16) +#endif +#ifndef HWCAP2_BTI +#define HWCAP2_BTI (1 << 17) +#endif +#ifndef HWCAP2_MTE +#define HWCAP2_MTE (1 << 18) +#endif +#ifndef HWCAP2_RPRES +#define HWCAP2_RPRES (1 << 21) +#endif +#ifndef HWCAP2_MTE3 +#define HWCAP2_MTE3 (1 << 22) +#endif +#ifndef HWCAP2_SME +#define HWCAP2_SME (1 << 23) +#endif +#ifndef HWCAP2_SME_I16I64 +#define HWCAP2_SME_I16I64 (1 << 24) +#endif +#ifndef HWCAP2_SME_F64F64 +#define HWCAP2_SME_F64F64 (1 << 25) +#endif +#ifndef HWCAP2_WFXT +#define HWCAP2_WFXT (1UL << 31) +#endif +#ifndef HWCAP2_EBF16 +#define HWCAP2_EBF16 (1UL << 32) +#endif +#ifndef HWCAP2_SVE_EBF16 +#define HWCAP2_SVE_EBF16 (1UL << 33) +#endif + +static void +__init_cpu_features_constructor(unsigned long hwcap, + const __ifunc_arg_t *arg) { +#define setCPUFeature(F) __aarch64_cpu_features.features |= 1ULL << F +#define getCPUFeature(id, ftr) __asm__("mrs %0, " #id : "=r"(ftr)) +#define extractBits(val, start, number) \ + (val & ((1ULL << number) - 1ULL) << start) >> start + unsigned long hwcap2 = 0; + if (hwcap & _IFUNC_ARG_HWCAP) + hwcap2 = arg->_hwcap2; + if (hwcap & HWCAP_CRC32) + setCPUFeature(FEAT_CRC); + if (hwcap & HWCAP_PMULL) + setCPUFeature(FEAT_PMULL); + if (hwcap & HWCAP_FLAGM) + setCPUFeature(FEAT_FLAGM); + if (hwcap2 & HWCAP2_FLAGM2) { + setCPUFeature(FEAT_FLAGM); + setCPUFeature(FEAT_FLAGM2); + } + if (hwcap & HWCAP_SM3 && hwcap & HWCAP_SM4) + setCPUFeature(FEAT_SM4); + if (hwcap & HWCAP_ASIMDDP) + setCPUFeature(FEAT_DOTPROD); + if (hwcap & HWCAP_ASIMDFHM) + setCPUFeature(FEAT_FP16FML); + if (hwcap & HWCAP_FPHP) { + setCPUFeature(FEAT_FP16); + setCPUFeature(FEAT_FP); + } + if (hwcap & HWCAP_DIT) + setCPUFeature(FEAT_DIT); + if (hwcap & HWCAP_ASIMDRDM) + setCPUFeature(FEAT_RDM); + if (hwcap & HWCAP_ILRCPC) + setCPUFeature(FEAT_RCPC2); + if (hwcap & HWCAP_AES) + setCPUFeature(FEAT_AES); + if (hwcap & HWCAP_SHA1) + setCPUFeature(FEAT_SHA1); + if (hwcap & HWCAP_SHA2) + setCPUFeature(FEAT_SHA2); + if (hwcap & HWCAP_JSCVT) + setCPUFeature(FEAT_JSCVT); + if (hwcap & HWCAP_FCMA) + setCPUFeature(FEAT_FCMA); + if (hwcap & HWCAP_SB) + setCPUFeature(FEAT_SB); + if (hwcap & HWCAP_SSBS) + setCPUFeature(FEAT_SSBS2); + if (hwcap2 & HWCAP2_MTE) { + setCPUFeature(FEAT_MEMTAG); + setCPUFeature(FEAT_MEMTAG2); + } + if (hwcap2 & HWCAP2_MTE3) { + setCPUFeature(FEAT_MEMTAG); + setCPUFeature(FEAT_MEMTAG2); + setCPUFeature(FEAT_MEMTAG3); + } + if (hwcap2 & HWCAP2_SVEAES) + setCPUFeature(FEAT_SVE_AES); + if (hwcap2 & HWCAP2_SVEPMULL) { + setCPUFeature(FEAT_SVE_AES); + setCPUFeature(FEAT_SVE_PMULL128); + } + if (hwcap2 & HWCAP2_SVEBITPERM) + setCPUFeature(FEAT_SVE_BITPERM); + if (hwcap2 & HWCAP2_SVESHA3) + setCPUFeature(FEAT_SVE_SHA3); + if (hwcap2 & HWCAP2_SVESM4) + setCPUFeature(FEAT_SVE_SM4); + if (hwcap2 & HWCAP2_DCPODP) + setCPUFeature(FEAT_DPB2); + if (hwcap & HWCAP_ATOMICS) + setCPUFeature(FEAT_LSE); + if (hwcap2 & HWCAP2_RNG) + setCPUFeature(FEAT_RNG); + if (hwcap2 & HWCAP2_I8MM) + setCPUFeature(FEAT_I8MM); + if (hwcap2 & HWCAP2_EBF16) + setCPUFeature(FEAT_EBF16); + if (hwcap2 & HWCAP2_SVE_EBF16) + setCPUFeature(FEAT_SVE_EBF16); + if (hwcap2 & HWCAP2_DGH) + setCPUFeature(FEAT_DGH); + if (hwcap2 & HWCAP2_FRINT) + setCPUFeature(FEAT_FRINTTS); + if (hwcap2 & HWCAP2_SVEI8MM) + setCPUFeature(FEAT_SVE_I8MM); + if (hwcap2 & HWCAP2_SVEF32MM) + setCPUFeature(FEAT_SVE_F32MM); + if (hwcap2 & HWCAP2_SVEF64MM) + setCPUFeature(FEAT_SVE_F64MM); + if (hwcap2 & HWCAP2_BTI) + setCPUFeature(FEAT_BTI); + if (hwcap2 & HWCAP2_RPRES) + setCPUFeature(FEAT_RPRES); + if (hwcap2 & HWCAP2_WFXT) + setCPUFeature(FEAT_WFXT); + if (hwcap2 & HWCAP2_SME) + setCPUFeature(FEAT_SME); + if (hwcap2 & HWCAP2_SME_I16I64) + setCPUFeature(FEAT_SME_I64); + if (hwcap2 & HWCAP2_SME_F64F64) + setCPUFeature(FEAT_SME_F64); + if (hwcap & HWCAP_CPUID) { + unsigned long ftr; + getCPUFeature(ID_AA64PFR1_EL1, ftr); + /* ID_AA64PFR1_EL1.MTE >= 0b0001 */ + if (extractBits(ftr, 8, 4) >= 0x1) + setCPUFeature(FEAT_MEMTAG); + /* ID_AA64PFR1_EL1.SSBS == 0b0001 */ + if (extractBits(ftr, 4, 4) == 0x1) + setCPUFeature(FEAT_SSBS); + /* ID_AA64PFR1_EL1.SME == 0b0010 */ + if (extractBits(ftr, 24, 4) == 0x2) + setCPUFeature(FEAT_SME2); + getCPUFeature(ID_AA64PFR0_EL1, ftr); + /* ID_AA64PFR0_EL1.FP != 0b1111 */ + if (extractBits(ftr, 16, 4) != 0xF) { + setCPUFeature(FEAT_FP); + /* ID_AA64PFR0_EL1.AdvSIMD has the same value as ID_AA64PFR0_EL1.FP */ + setCPUFeature(FEAT_SIMD); + } + /* ID_AA64PFR0_EL1.SVE != 0b0000 */ + if (extractBits(ftr, 32, 4) != 0x0) { + /* get ID_AA64ZFR0_EL1, that name supported if sve enabled only */ + getCPUFeature(S3_0_C0_C4_4, ftr); + /* ID_AA64ZFR0_EL1.SVEver == 0b0000 */ + if (extractBits(ftr, 0, 4) == 0x0) + setCPUFeature(FEAT_SVE); + /* ID_AA64ZFR0_EL1.SVEver == 0b0001 */ + if (extractBits(ftr, 0, 4) == 0x1) + setCPUFeature(FEAT_SVE2); + /* ID_AA64ZFR0_EL1.BF16 != 0b0000 */ + if (extractBits(ftr, 20, 4) != 0x0) + setCPUFeature(FEAT_SVE_BF16); + } + getCPUFeature(ID_AA64ISAR0_EL1, ftr); + /* ID_AA64ISAR0_EL1.SHA3 != 0b0000 */ + if (extractBits(ftr, 32, 4) != 0x0) + setCPUFeature(FEAT_SHA3); + getCPUFeature(ID_AA64ISAR1_EL1, ftr); + /* ID_AA64ISAR1_EL1.DPB >= 0b0001 */ + if (extractBits(ftr, 0, 4) >= 0x1) + setCPUFeature(FEAT_DPB); + /* ID_AA64ISAR1_EL1.LRCPC != 0b0000 */ + if (extractBits(ftr, 20, 4) != 0x0) + setCPUFeature(FEAT_RCPC); + /* ID_AA64ISAR1_EL1.LRCPC == 0b0011 */ + if (extractBits(ftr, 20, 4) == 0x3) + setCPUFeature(FEAT_RCPC3); + /* ID_AA64ISAR1_EL1.SPECRES == 0b0001 */ + if (extractBits(ftr, 40, 4) == 0x2) + setCPUFeature(FEAT_PREDRES); + /* ID_AA64ISAR1_EL1.BF16 != 0b0000 */ + if (extractBits(ftr, 44, 4) != 0x0) + setCPUFeature(FEAT_BF16); + /* ID_AA64ISAR1_EL1.LS64 >= 0b0001 */ + if (extractBits(ftr, 60, 4) >= 0x1) + setCPUFeature(FEAT_LS64); + /* ID_AA64ISAR1_EL1.LS64 >= 0b0010 */ + if (extractBits(ftr, 60, 4) >= 0x2) + setCPUFeature(FEAT_LS64_V); + /* ID_AA64ISAR1_EL1.LS64 >= 0b0011 */ + if (extractBits(ftr, 60, 4) >= 0x3) + setCPUFeature(FEAT_LS64_ACCDATA); + } else { + /* Set some features in case of no CPUID support. */ + if (hwcap & (HWCAP_FP | HWCAP_FPHP)) { + setCPUFeature(FEAT_FP); + /* FP and AdvSIMD fields have the same value. */ + setCPUFeature(FEAT_SIMD); + } + if (hwcap & HWCAP_DCPOP || hwcap2 & HWCAP2_DCPODP) + setCPUFeature(FEAT_DPB); + if (hwcap & HWCAP_LRCPC || hwcap & HWCAP_ILRCPC) + setCPUFeature(FEAT_RCPC); + if (hwcap2 & HWCAP2_BF16 || hwcap2 & HWCAP2_EBF16) + setCPUFeature(FEAT_BF16); + if (hwcap2 & HWCAP2_SVEBF16) + setCPUFeature(FEAT_SVE_BF16); + if (hwcap2 & HWCAP2_SVE2 && hwcap & HWCAP_SVE) + setCPUFeature(FEAT_SVE2); + if (hwcap & HWCAP_SHA3) + setCPUFeature(FEAT_SHA3); + } + setCPUFeature(FEAT_INIT); +} + +void +__init_cpu_features_resolver(unsigned long hwcap, const __ifunc_arg_t *arg) { + if (__aarch64_cpu_features.features) + return; + __init_cpu_features_constructor(hwcap, arg); +} + +void __attribute__ ((constructor)) +__init_cpu_features(void) { + unsigned long hwcap; + unsigned long hwcap2; + /* CPU features already initialized. */ + if (__aarch64_cpu_features.features) + return; + hwcap = getauxval(AT_HWCAP); + hwcap2 = getauxval(AT_HWCAP2); + __ifunc_arg_t arg; + arg._size = sizeof(__ifunc_arg_t); + arg._hwcap = hwcap; + arg._hwcap2 = hwcap2; + __init_cpu_features_constructor(hwcap | _IFUNC_ARG_HWCAP, &arg); +#undef extractBits +#undef getCPUFeature +#undef setCPUFeature +} +#endif /* __has_include() */ +#endif /* __has_include() */ diff --git a/libgcc/config/aarch64/t-aarch64 b/libgcc/config/aarch64/t-aarch64 index a40b6241c86ecc4007b5cfd28aa989ee894aa410..8bc1a4ca0c2eb75c17e62a25aa45a875bfd472f8 100644 --- a/libgcc/config/aarch64/t-aarch64 +++ b/libgcc/config/aarch64/t-aarch64 @@ -19,3 +19,4 @@ # . LIB2ADD += $(srcdir)/config/aarch64/sync-cache.c +LIB2ADD += $(srcdir)/config/aarch64/cpuinfo.c From patchwork Wed Dec 6 12:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Carlotti X-Patchwork-Id: 174563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4077523vqy; Wed, 6 Dec 2023 04:45:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIt8pnqsC7FgDP5675Ji6AYXw+85UUaCrDu00ZC0VvHwb3T5bCpQSafBTj0OPnETWlsBWY X-Received: by 2002:a05:6214:192b:b0:67a:e1e6:236c with SMTP id es11-20020a056214192b00b0067ae1e6236cmr857520qvb.124.1701866750250; Wed, 06 Dec 2023 04:45:50 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1701866750; cv=pass; d=google.com; s=arc-20160816; b=CZXQYrVfd/MJxI9nStOtdTik2I9GWEhtSxCfCqo5G3Lwyn/gfHQrKQNdzxUVfQK3qv mjE+/c63b/TjR+GGoD6yd3/fDFFqswtTbifCYRT3j2IQyqQvIDdmZfdfUbXj3ZLZjyVX rH2lX/ghwZpmrxif9c1zUDQS5HGQ2npdtCsyihD30QMDY1xhxU7bzwJEk0A1/zM3wQ63 QdxiA6f9L1Fzmv6EDBx2OjxwziPqedMiu65BuqO5iRGGV97B0uV0DqoUmad2i+p1IsUG MIPqk7zJ1xZKKSI0tCqB8YD/JfwrzZmt8FSKQ8bWfRDLCDMe7oAxdSTLUqjGkLOg+gaU Pwew== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:in-reply-to:content-disposition :references:message-id:subject:to:from:date :authentication-results-original:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=372xekdVKg0hXJjPrYd5F8hY/YlswwvtaljyHAaQAhE=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=xZVDn8B5GFl9jGfaX7ufQK30oX9qFI6bcf+JYaCLP40OZaITkQ82nPQ/CyH2gK8kQ3 Qt5YZcIxBCbSWRox9BsRdt0t7OEaa9Rrz84/YevThBvl6Ee4tqiSK1E43z0ESOe+913s 8I7rw5CO48G4R8GJHPskyfJ1ExxUZsesW3VGYtj1duPPt994xf89v04aOHjPLXi97kdh itpDVmS4TVgl6RSMCf2MEFCaSRKfiIjsknaTOV72Cb24AyBrmg6HTkNg4jmZh6DmORJy 8tGv7FwBbuS40uIkUQMGdyAfpc9tOi1tG1ALQHto/a4KRVh0v9n53++CZhihANk1BlMZ UY3w== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="F+Ax/tko"; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="F+Ax/tko"; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o6-20020ad45c86000000b0067a90d3023esi14366507qvh.279.2023.12.06.04.45.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:45:50 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="F+Ax/tko"; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="F+Ax/tko"; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0883D3858023 for ; Wed, 6 Dec 2023 12:45:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2080.outbound.protection.outlook.com [40.107.15.80]) by sourceware.org (Postfix) with ESMTPS id 56B463857C5E for ; Wed, 6 Dec 2023 12:45:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56B463857C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 56B463857C5E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.80 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866725; cv=pass; b=os/yJNr+KAhjsFYI0IBb07gml7r2MtE0hpPq7JwbcZRX0A+cNfmtr0h3pV0NS0zclrZNpY2UfcTuz5rawc19M/N1HgXo/ZA0K6alZukTvMBJ/NWY4PSfp8K7tOlZO1RgUy0f1OWAn9SZZJFcmejA0VCPFPaC0rFx5boVZUa2vgU= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866725; c=relaxed/simple; bh=TGBh48yzgpLWabHDh0b9zBC4NshgG8QHo2N3ZYz2aEc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=LFUl6PS4/W3DdfwAQKP5IOK7PcHQYkRZTKIaXasnI6QibEI8em+6++ev21U1lkJSE88pOIASb7n+fkv1melzp0sfL1S2CLz1OIQKQmzYhdITz5uSBT26VfmCEPK9Kta/uRwFa2+h4k95/a1LTTsr6i1iMiMtB9iu7KN+kcuaAGI= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=KYWhkUCGHLBgO5QQ58nG2U4orpRLUe4lui3tdmQTB0KAl7SFubCoxSQZ87dkQ8NxudF2uXSxv7w9LBzmQ6vdjLn3H8cq/k8Ur6pHaEqroUBW6CqM4H5j4ZCZVGkRr9ENOl4n1ApFBQlbS5+3vCFHHaWrgcAW1ZeZhLs9hEPXL4ZKo9NSjwMPGbsVZ4YcBc5JAyeaYV8DUrbqgn+YkVrNUictXExs5CWNpkr+gEnwZHHsca6DLjxXXuyxmm/IvTgUWUxJ7lBFiUp4I5ZtgdtsdMsXycpLK15JHodDEhgV4KYO+POKWOj4FDp3t67tHmSo4IkISMER679ibN0He89sXw== 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=372xekdVKg0hXJjPrYd5F8hY/YlswwvtaljyHAaQAhE=; b=CUVLjTgnhIkqqMB5pQ/nrFkosKOK5Dadb6lgitpAocgqbJxw8mA5iBbYd7wGjWoIeKssFNlU8SuKJys70CeqBhW44NJ8zhcMD0OToTESEhGrTXlY3WnR4Z37fVM/tlosu74GQ+WiP2sbr9SAgHDBfbD7wBoB3GBNZ6ngbB5ygw0TfYi7mQXG2txWozg1d0DfvFc7yZ81+BTE/JC1qvchZkxKsrvpU6u9GGcu9wB/FdKP/YVBrAwMSGOYnvaDHqWyqSGZfyJJ50Zp2ux9hy3SdSgFbagkawCW4sVN36pns29z6e8dc0tguAdAEtHxhzcD/hN/MddXOL4380W4AIHIbA== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=372xekdVKg0hXJjPrYd5F8hY/YlswwvtaljyHAaQAhE=; b=F+Ax/tkofmcjzTWPhehAfTPVAJnguEz199PXDXHe8J1cDU2w9+Dm7Fq1LDRdzrWzncHMxzLBwpwOkrLI85JDZYEtlMcpVJCN6FbXFUWgehCRgX5KZ1CXvvSvE6J8OpJll8+0z2n1z6tXCr0FGCxP4R9T5yDx2pLcUIRS3DItkQ8= Received: from AM5PR1001CA0010.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::23) by AS2PR08MB8455.eurprd08.prod.outlook.com (2603:10a6:20b:55b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 12:45:20 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:206:2:cafe::c) by AM5PR1001CA0010.outlook.office365.com (2603:10a6:206:2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 12:45:20 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 12:45:20 +0000 Received: ("Tessian outbound 7671e7ddc218:v228"); Wed, 06 Dec 2023 12:45:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6507c72961bcd3b1 X-CR-MTA-TID: 64aa7808 Received: from 4fdeac60adff.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 390E9E7B-34F6-457F-BB25-DEDFBB10C551.1; Wed, 06 Dec 2023 12:45:13 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4fdeac60adff.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Dec 2023 12:45:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihTjTvMQjSGtimbNJOU73zUkq5GWf+nYVcgCRDXz272ljHI+7kAiuJEyGKpJKuH/egbO9VvqoYbcZ2D6wOV4wOI5hdZq51gQ6nAwp1J3jNgXc0XLcGsQLcrJDGzQ92UL+c9PLQUR6VX5qarzuJJ905nqiMGAG3QKjZN2XJm+qJoRj6JICj4YduuDpmikpBoedasV5DTKwGlXjMKOJPCW5gnzt6CbXW71hQwye2/pJb6i/MxQg8vx+1QbOJCZa/nlio0fqcjpadXi1/iSGRly18BP4ddleOPSrujLeMNKqxRQqIGJHa9tOs+m1mVan48n+QFbyi9Vo0/5LCSgLQRLXQ== 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=372xekdVKg0hXJjPrYd5F8hY/YlswwvtaljyHAaQAhE=; b=ijexhr8GIqe2lKqnN5TtE9CpZjpYzEkfg+QOKw8gRYcrzCpauBkz+KaaAi+5wRq9fEm3xtG0T/86FhqkAwUpRmzQfQ0gaC5v9SkJEe3NcetmSELNzFvyT5TKf3Aq7llI/LJ/9iQUN2WTIVTXUs/M0BYdyAsciNxGPhG56v87QlZfs949Lz9hpj0BP7TbwiNMdpkaczuZCJkQr4BwUaNB46Oxp4UPoW4I+QV0DIudm3nUr1jSo1u41MYpXO1MMo69hLiALCSXJEjUe+7IOWNZkjwAocfToeRuN1NSqWYxBISJyfHJ0b/NTVSwOhC/0JfLfQDRyNScx5UjUUkn/Bl2Jw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=372xekdVKg0hXJjPrYd5F8hY/YlswwvtaljyHAaQAhE=; b=F+Ax/tkofmcjzTWPhehAfTPVAJnguEz199PXDXHe8J1cDU2w9+Dm7Fq1LDRdzrWzncHMxzLBwpwOkrLI85JDZYEtlMcpVJCN6FbXFUWgehCRgX5KZ1CXvvSvE6J8OpJll8+0z2n1z6tXCr0FGCxP4R9T5yDx2pLcUIRS3DItkQ8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by AS8PR08MB5942.eurprd08.prod.outlook.com (2603:10a6:20b:29f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 12:45:11 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2%7]) with mapi id 15.20.7068.025; Wed, 6 Dec 2023 12:45:11 +0000 Date: Wed, 6 Dec 2023 12:45:08 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 2/5] c-family: Simplify attribute exclusion handling Message-ID: <53309896-3cb3-e114-7471-a2f320464bef@e124511.cambridge.arm.com> References: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> Content-Disposition: inline In-Reply-To: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> X-ClientProxiedBy: LO2P265CA0169.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::13) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS8PR08MB5942:EE_|AMS1EPF0000004A:EE_|AS2PR08MB8455:EE_ X-MS-Office365-Filtering-Correlation-Id: 1af40304-c072-4e86-8c30-08dbf6593506 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: TgUgVBsoM24TdwOPDLfXvByoyJ4nzfG9nNhHIsC88t2d5qQBlvS7orZVGVopJA768ljz429+bjbXRwT9s6h3NgFivEani2f1QQoDrDbss9pAC6sVEXJxIdL6byCnaZEXrfrH5bMQufaBcWSQBEGqXjX5dacdn8eWPzveTCy4E/9ivMEjPB5g2MbuVndJoZmXw3YRDfd1bi7Kl+XyBsIRSQWozaof7CmiadX+j1ZuUTNuxWsAY1NfVS5lmwTRMQbj1ClHOIZ4l5G8I4uZ7MZeK3ZdneYpds0UJd35suWjlwyQ/fU742pIJNwAy9yNOJMPcDmURz7ZTQypmYK6XAS5k9sNc0XazB1Ejl8TB9vxXeRJCJGKeghV1pjupY3A6phQUlAyxflidvwpMoD9LE83Dm3EVX7lFWuXLE/9/3ImZ1ZAtGliR62fGNfR0mR1EtRLJoyPVehs5/bSJ4odss+FiCJXDWPZ7t7x52T0VFX0dvQbYlO85qqxkZyszVmRgLHEFeHe+5//sFJR8WQL88V9swsI2Cwtc6vvYJQlZBwEGaMo0W1pxp9QxEnqm1BokhTFor/whxcvhAilE15DYDw3qL+/z3t0XkqJw4pArZlXPdmKxy9JtlyzrB43Y0p81+Ze X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39860400002)(346002)(376002)(366004)(396003)(230273577357003)(230173577357003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(5660300002)(44832011)(6506007)(6666004)(86362001)(8676002)(8936002)(31696002)(41300700001)(38100700002)(31686004)(2906002)(6512007)(26005)(83380400001)(478600001)(316002)(66556008)(66946007)(6916009)(66476007)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5942 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: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6666a8ab-a24c-468d-cd16-08dbf6592f6c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pat/PAfLOk3Xi9j9Xfy8oKumcTKLPvzHRcRi0tumcvmCKeSRHAn9+J6OXCC/PrFDCwBnq2k0y+s65dUYJHlG1Nmh+jd52gPrBTtNBBWCw169Kcq3zZFoJANVF7KFUN0gg81HhTEuH3JtkAi8IYSrRkq9KKh1crb5SqdOqajC9z2RWI0K/MZwMitj0UmPqCIXgGjHraLkn83G3K3hiQzmrfQIAKTe3DrVw3QeHpF2QoxNmCFrVF0ud7nlSIk+BfAc49Xkc+edouahK70Tw1SaEXnZk+7cri3q8zH6ohoriC88I071g9d6AUGFgO1pRatQC1aJxXqON6fCM7gQEzzfrXZwoqqj5IA0lCOssSiqSJSt1LJmdFGgmxEjO2FDpVQru2TzOOjPlR+FlsYFH5YcshyNI9kaQ8Bv+KreJZHsxLkyDySHYJ8RWDgUs4YyE0aIOB8h1LsDdIjR0K1qSgAVYE2+yOM2Yq9HM8aUeA488uwwyZJMcD/XEJ2gW6xeha15wY5HNAGWcbpOBvcEAmWGSy/K6S6Z/ktm7GYPWLPKUCq/ljEKCejxbrpNv9wPo/0JNHchQrDjg5WO4NOCCiyEhIhQiuuPYpk0EdqSiFJ4onRMCj4jsEQtMGL/SQ3RF3T0CeDnvkb4FFAhTSNIqYy0E5EO0Cdcj4HSiGUMogVo63hzajxbPxHGX5MMr0q9MABqdD6wUr51nDvTLCXyJA0+wpH7nFjeIkjQtc6bPF1B6IJynTknCCatRZcFbHPtIiCR0wv20rRCfOiXzCSbSrfHVK7CXjnBcnwVYRsLwAEiMj0= 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:(13230031)(4636009)(376002)(396003)(39860400002)(346002)(136003)(230922051799003)(230273577357003)(230173577357003)(451199024)(64100799003)(82310400011)(1800799012)(186009)(40470700004)(36840700001)(46966006)(478600001)(356005)(31686004)(81166007)(82740400003)(6666004)(6486002)(40480700001)(36860700001)(47076005)(83380400001)(40460700003)(6506007)(6512007)(8676002)(8936002)(2906002)(5660300002)(31696002)(86362001)(41300700001)(44832011)(6916009)(70206006)(70586007)(316002)(336012)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 12:45:20.4575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1af40304-c072-4e86-8c30-08dbf6593506 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: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8455 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784536629680504508 X-GMAIL-MSGID: 1784536629680504508 This patch changes the handling of mutual exclusions involving the target and target_clones attributes to use the generic attribute exclusion lists. Additionally, the duplicate handling for the always_inline and noinline attribute exclusion is removed. The only change in functionality is the choice of warning message displayed - due to either a change in the wording for mutual exclusion warnings, or a change in the order in which different checks occur. gcc/c-family/ChangeLog: * c-attribs.cc (attr_always_inline_exclusions): New. (attr_target_exclusions): Ditto. (attr_target_clones_exclusions): Ditto. (c_common_attribute_table): Add new exclusion lists. (handle_noinline_attribute): Remove custom exclusion handling. (handle_always_inline_attribute): Ditto. (handle_target_attribute): Ditto. (handle_target_clones_attribute): Ditto. gcc/testsuite/ChangeLog: * g++.target/i386/mvc2.C: * g++.target/i386/mvc3.C: diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index 461732f60f7c4031cc6692000fbdddb9f726a035..b3b41ef123a0f171f57acb1b7f7fdde716428c00 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -214,6 +214,13 @@ static const struct attribute_spec::exclusions attr_inline_exclusions[] = ATTR_EXCL (NULL, false, false, false), }; +static const struct attribute_spec::exclusions attr_always_inline_exclusions[] = +{ + ATTR_EXCL ("noinline", true, true, true), + ATTR_EXCL ("target_clones", true, true, true), + ATTR_EXCL (NULL, false, false, false), +}; + static const struct attribute_spec::exclusions attr_noinline_exclusions[] = { ATTR_EXCL ("always_inline", true, true, true), @@ -221,6 +228,19 @@ static const struct attribute_spec::exclusions attr_noinline_exclusions[] = ATTR_EXCL (NULL, false, false, false), }; +static const struct attribute_spec::exclusions attr_target_exclusions[] = +{ + ATTR_EXCL ("target_clones", true, true, true), + ATTR_EXCL (NULL, false, false, false), +}; + +static const struct attribute_spec::exclusions attr_target_clones_exclusions[] = +{ + ATTR_EXCL ("always_inline", true, true, true), + ATTR_EXCL ("target", true, true, true), + ATTR_EXCL (NULL, false, false, false), +}; + extern const struct attribute_spec::exclusions attr_noreturn_exclusions[] = { ATTR_EXCL ("alloc_align", true, true, true), @@ -332,7 +352,7 @@ const struct attribute_spec c_common_attribute_table[] = handle_leaf_attribute, NULL }, { "always_inline", 0, 0, true, false, false, false, handle_always_inline_attribute, - attr_inline_exclusions }, + attr_always_inline_exclusions }, { "gnu_inline", 0, 0, true, false, false, false, handle_gnu_inline_attribute, attr_inline_exclusions }, @@ -483,9 +503,11 @@ const struct attribute_spec c_common_attribute_table[] = { "error", 1, 1, true, false, false, false, handle_error_attribute, NULL }, { "target", 1, -1, true, false, false, false, - handle_target_attribute, NULL }, + handle_target_attribute, + attr_target_exclusions }, { "target_clones", 1, -1, true, false, false, false, - handle_target_clones_attribute, NULL }, + handle_target_clones_attribute, + attr_target_clones_exclusions }, { "optimize", 1, -1, true, false, false, false, handle_optimize_attribute, NULL }, /* For internal use only. The leading '*' both prevents its usage in @@ -1397,16 +1419,7 @@ handle_noinline_attribute (tree *node, tree name, int ARG_UNUSED (flags), bool *no_add_attrs) { if (TREE_CODE (*node) == FUNCTION_DECL) - { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with attribute %qs", name, "always_inline"); - *no_add_attrs = true; - } - else - DECL_UNINLINABLE (*node) = 1; - } + DECL_UNINLINABLE (*node) = 1; else { warning (OPT_Wattributes, "%qE attribute ignored", name); @@ -1487,22 +1500,9 @@ handle_always_inline_attribute (tree *node, tree name, { if (TREE_CODE (*node) == FUNCTION_DECL) { - if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "noinline"); - *no_add_attrs = true; - } - else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "target_clones"); - *no_add_attrs = true; - } - else - /* Set the attribute and mark it for disregarding inline - limits. */ - DECL_DISREGARD_INLINE_LIMITS (*node) = 1; + /* Set the attribute and mark it for disregarding inline + limits. */ + DECL_DISREGARD_INLINE_LIMITS (*node) = 1; } else { @@ -5650,12 +5650,6 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, warning (OPT_Wattributes, "%qE attribute ignored", name); *no_add_attrs = true; } - else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "target_clones"); - *no_add_attrs = true; - } else if (! targetm.target_option.valid_attribute_p (*node, name, args, flags)) *no_add_attrs = true; @@ -5696,19 +5690,7 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args), } } - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "always_inline"); - *no_add_attrs = true; - } - else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "target"); - *no_add_attrs = true; - } - else if (get_target_clone_attr_len (args) == -1) + if (get_target_clone_attr_len (args) == -1) { warning (OPT_Wattributes, "single % attribute is ignored"); diff --git a/gcc/testsuite/g++.target/i386/mvc2.C b/gcc/testsuite/g++.target/i386/mvc2.C index 7c1fb6518d04f404123086660c32853dcd9f65ba..04ee0573d607f6de2e7ea382e891f62884c18ea7 100644 --- a/gcc/testsuite/g++.target/i386/mvc2.C +++ b/gcc/testsuite/g++.target/i386/mvc2.C @@ -3,7 +3,7 @@ __attribute__((target_clones("avx","arch=slm","default"))) __attribute__((target("avx"))) -int foo (); /* { dg-warning "'target' attribute ignored due to conflict with 'target_clones' attribute" } */ +int foo (); /* { dg-warning "ignoring attribute 'target' because it conflicts with attribute 'target_clones'" } */ __attribute__((target_clones("avx","arch=slm","default"),always_inline)) -int bar (); /* { dg-warning "'always_inline' attribute ignored due to conflict with 'target_clones' attribute" } */ +int bar (); /* { dg-warning "ignoring attribute 'always_inline' because it conflicts with attribute 'target_clones'" } */ diff --git a/gcc/testsuite/g++.target/i386/mvc3.C b/gcc/testsuite/g++.target/i386/mvc3.C index 5d634fd7ea68b905a0e93ca1c25f6907bc9d2858..5ad1f88fd2d7da74fafcafcff24b77cb2d12a5a0 100644 --- a/gcc/testsuite/g++.target/i386/mvc3.C +++ b/gcc/testsuite/g++.target/i386/mvc3.C @@ -3,7 +3,7 @@ __attribute__((target("avx"))) __attribute__((target_clones("avx","arch=slm","default"))) -int foo (); /* { dg-warning "'target_clones' attribute ignored due to conflict with 'target' attribute" } */ +int foo (); /* { dg-warning "ignoring attribute 'target_clones' because it conflicts with attribute 'target'" } */ __attribute__((always_inline,target_clones("avx","arch=slm","default"))) -int bar (); /* { dg-warning "'target_clones' attribute ignored due to conflict with 'always_inline' attribute" } */ +int bar (); /* { dg-warning "ignoring attribute 'target_clones' because it conflicts with attribute 'always_inline'" } */ From patchwork Wed Dec 6 12:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Carlotti X-Patchwork-Id: 174564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4077903vqy; Wed, 6 Dec 2023 04:46:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IED9lZyduLb/aMSb6tOFB+dUY+0V1Ednso2y7vUIyfhI79XZjQQ8I3LJzrkIk4d09mTwghb X-Received: by 2002:a05:622a:1909:b0:421:c349:73f6 with SMTP id w9-20020a05622a190900b00421c34973f6mr1240923qtc.22.1701866798707; Wed, 06 Dec 2023 04:46:38 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1701866798; cv=pass; d=google.com; s=arc-20160816; b=Nnk+MgttfQ94Hdfe1aDdFs7/wAqY12jJpfNxOpm8nC7T/KPeqyuiJJfSttgQ11nGUl e2er4Y5/V7N7iUg7lqBE8f/bXXoh5r7e9IgK1oUbeWsimkbcaeODnQnMk8fCAnfLvoTX 4BBs0bRBtPX8Fo9umxXXwaq/rsmXYQGysXQ5AUsYGiZiLpZtp3xBftE+A/pSEuSwLWdw XdernqpHBc2poxRH3nZAyE1S246I3Ne7tZyVwCfHSzPIMDrWS4TAsmFwgPlsIc9Ak+1E 0oglSVh0dObK4oW+xpA5fJzc4swXczATGHleDqlf1yZUihrwyI7ISVIZtiPYpq7H0PB3 o87w== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:in-reply-to:content-disposition :references:message-id:subject:to:from:date :authentication-results-original:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ky5Mkguy4A915nrYUOq7d34wWWVu6F4poyK5/rq/7cU=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=dTjkAC6Blk+qeS2ZYQB9WCPWxByGMBD/D1r2etYE9j31sNmgaUYPQr5c+2SXA65YKk Lh/WW2P8HdhKPF4F4ZREyDJPF/hnNQC0GZkwH3j+odsXq/1RBvV/5Xp0de69+lYA5D34 Gd04rA7wzd0PosB+vSIGV1U/zmeRvtBgbaBghBUTpkkdB8HaldqJfrG9pwKmOj/xSJNS UmlHvO8csIUAfDV5vzAZedRF/pDYSahXIS9OAdQw8uooOCxUSrmjP+ZbYaHxvgWpdyEV MNtkCiFSAkJMCHtrjVpfrtIShYZ7D1G8DHplz23ZI5Z/4dRjZQ+0jIVFv6hcV0viO48b LiKg== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7I1i4SlE; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7I1i4SlE; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bc11-20020a05622a1ccb00b0042385a0d221si15009203qtb.203.2023.12.06.04.46.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7I1i4SlE; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7I1i4SlE; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D15D2385842A for ; Wed, 6 Dec 2023 12:46:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2048.outbound.protection.outlook.com [40.107.7.48]) by sourceware.org (Postfix) with ESMTPS id 1ABC03858C20 for ; Wed, 6 Dec 2023 12:46:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1ABC03858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1ABC03858C20 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.7.48 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866774; cv=pass; b=A9VTc1vu8EV2Prt397upRXcHx2U1fWvIzpyZZB4lj7dQKW0IE/Eq042Q/veFYD9+ViWbi5PH807tVJBxT5VVlwYYWiFcwrrqHXWVP4QLBQOfP6T7FYGYcRlF122Szvar2b+ZxOsbcJFl+uBp+GOlH7KA8UsvwgqxCBbeh6vl7Wk= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866774; c=relaxed/simple; bh=3UlA2bjaYHjKXry8I+A+D9yzkmELZToTil6WnaWX2E0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=pncEl4E4XNDDb9OFsOyE71AmEEx6RQY6wATZR48xy+HsjWIv+Sdkabuwqu56mHTJ0oXp4nkBQrOmS1/1SbfA5kf+f6DNFsGUaA51VIZZgquIzQAruSv7IW0c9aFchLRB/7lsuw835Yt4UNj0vYDHcv6lfABje2Lw3oqPwrHR4Yg= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=UxoSwc52Z219k4AV6p60ZQNG9BW1TPoW52hu+E6zIMIUH9eaN4Vg1/Nb+VxXET/iUG9QHoYktm4bEddsjqUgUY7i1AcIYkDuxdEbppTwvegZe8zLTeQsPtpIgoBr+4R9+H5Nv8Mowoz/Qg7WbCcf2TrgxRFo/E5AF1534EHfqr3ZOxv89q03iyO01BVBvzzRdDRu48cXajhil+2MwwrixAGh7D7ZWKnJFHRamdwgThMpmsgiJy0KFA/Vg3aqlZE7Ph4MV0x9Le5c9bSOiikrxsqQdDe5m79RvC68cr3jgAVZnwpE4kP4ljMLmKtMW5Z06X8FM4EMZ7jNntzW/Z69Pw== 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=ky5Mkguy4A915nrYUOq7d34wWWVu6F4poyK5/rq/7cU=; b=ANGNP0X30XhT8v6oAs3iBBq1bBiZrr4GLFh6AoIoN2KFYLxKuRXsbYA5gYuuEh3q/Co06KTRAbo7FYHJqi3bWfnS08GDPXtjBkLB1nwSOIGumbAqMb+EBfwephj8gA/+SHOHLodqAatOvDDacwLGzSOP5KThK60VZBYtB8PeQ4+PC79sVhSxfDKTQdHn4+fZYSIA60HjhhB0lqH2qD83gRAa1/6vf0q6JIsxZF2beRDhFMGP9n6NXn+5o0/jx6boQxjpXj+vOKhAxL/7LbYBDw2O/XCShWTfvxQ5WEAqJDCSaZTvHkWwPDAHBRFw2XC84gg3kGR81e50XnMVehxSog== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ky5Mkguy4A915nrYUOq7d34wWWVu6F4poyK5/rq/7cU=; b=7I1i4SlEiHk/NpxS4f+lLfqdD427XTsZUSiEbOAJmov6ArOqWVnt9CpRpbmDaq9OHAF4HJdy2TJKYa7709siYrnOYSxqmj5ydTz7+cgZ87RDMpFuxIf9b1v8z9OyDyK1mhGWjY2pcVb+UbG+Y1NLFMeAr7G+ESePI827qotfj4E= Received: from AS9PR05CA0286.eurprd05.prod.outlook.com (2603:10a6:20b:492::33) by PA4PR08MB6205.eurprd08.prod.outlook.com (2603:10a6:102:e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 12:46:05 +0000 Received: from AMS0EPF000001A0.eurprd05.prod.outlook.com (2603:10a6:20b:492:cafe::39) by AS9PR05CA0286.outlook.office365.com (2603:10a6:20b:492::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 12:46:05 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS0EPF000001A0.mail.protection.outlook.com (10.167.16.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 12:46:05 +0000 Received: ("Tessian outbound 20615a7e7970:v228"); Wed, 06 Dec 2023 12:46:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 62872b1306276c54 X-CR-MTA-TID: 64aa7808 Received: from c9aacbf40c1c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 80DFA8EC-97D8-47E8-A6D1-F84085A1FBB7.1; Wed, 06 Dec 2023 12:45:59 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c9aacbf40c1c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Dec 2023 12:45:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z73wsU7WGSyxJb4RsNTvUOCdAMnutks3DCtj1sqdbiF9b6J4KJzeQ+xnOMMBVSOF3HL6xdl9xZ/ltvhlGpJY9caViOhRMWKMP/gRr1i3k3o5ipKQjrMhNdKHlcfAwauhwNmLXwW72gy9GAocRBwv0mPN9Ql+c+4D8NLZPv+nIH9IXS+e8E9VkSxStD6s0q8WAtv9gcN6Gq3vkqwMTc3VVsbVkO6iUHOKM88gaIC+HHWzANvQNrNAhxBeRqFBpYApb5rgYKuKAXxCo8pGkegmyiqYXdXrmteHSEO+Z2e7H3nCXEGrZEjdNmkW+o961UF8SnuYPn8ib8krOfMyHum/Xw== 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=ky5Mkguy4A915nrYUOq7d34wWWVu6F4poyK5/rq/7cU=; b=DbjLz4A71YYkbTLmKTwiQE3Q7oRkOLTDvtG67SG1ugwcbK481R7Yr+/ZS1bbzKuHD5llBrv28LrfAmAtboJIt7MgRvghRlk3A821gYcGGRVI+MQlzaccD4Nxl5qC8Fwpr0j+dXsFJkhheJ0ZnFfaAqS+BLYQdNqHBXVw1UE2taAaxIfXL61jpQGzo8e48/S2Qk+rDAhBErF6+Uagd5BRgdfN+DeeUMwfryWBQPXKnD2rJdHXlGN4xHjXwpLE2im6i0P3bQ0i0akq3oVKeotr99OzoHxhBv/zLN9G/5UarLEuMxduLWF8ieGMyLvF0rzUfSYMK+y09cc1VgUB4R8vKw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ky5Mkguy4A915nrYUOq7d34wWWVu6F4poyK5/rq/7cU=; b=7I1i4SlEiHk/NpxS4f+lLfqdD427XTsZUSiEbOAJmov6ArOqWVnt9CpRpbmDaq9OHAF4HJdy2TJKYa7709siYrnOYSxqmj5ydTz7+cgZ87RDMpFuxIf9b1v8z9OyDyK1mhGWjY2pcVb+UbG+Y1NLFMeAr7G+ESePI827qotfj4E= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by AS8PR08MB10171.eurprd08.prod.outlook.com (2603:10a6:20b:62a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 12:45:56 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2%7]) with mapi id 15.20.7068.025; Wed, 6 Dec 2023 12:45:56 +0000 Date: Wed, 6 Dec 2023 12:45:53 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Subject: [PATCH v3 3/5] ada: Improve attribute exclusion handling Message-ID: References: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> Content-Disposition: inline In-Reply-To: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> X-ClientProxiedBy: LO2P265CA0054.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::18) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS8PR08MB10171:EE_|AMS0EPF000001A0:EE_|PA4PR08MB6205:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a92db6c-0f88-4153-000f-08dbf6594ff6 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: USfJswLqMOJM4JBMiiwa/5SFMfh6ksnce6+n6ZJRFdxMrMkMC+RbmLbz35H2Eqheho6Njl97dqtIHwcEmR0/Vs+0z56D3fScBUhvRa8ACd0aWi3L648yla9p2XJjxyuSszt4fldtYVMwIAoM5+YuqH3KWVmLA+jT3FcJr9eB5OKIPvvDg5p/DfqUKwAWDDmz8cy3xGA85HgGVPgGLNdnmgnLi/KwIdvd/WrXDilXnyCnGB9zgZhOehOiofhcvdZr15Llb7PZT9uRP/KvWorA4YlPungTFGwSgRmNJMz5MP1haTb8k+qR8vdt15aP3NquZxr7RlS0cT+E6iQXbxHy1JOuEhp8xNhzm/ezpGCYq5hjNFZU+DdbpAMBOtDjMjQ5MoYDAUUTsTA92mpumS5q9RYSc3k7adCG1My5Ntwp9FMDDErqBDuVU83YzMTmwshhnhv82CdYhU9/EZtwvMTcENpmPRAVn1iZ81fvsuDCjeU2zvpMmasmSEqsCc4m6E0AcR2PsJoR4f4KgPWjc77dVV69aphZhg563gJkcwuteiexd9jJKbcolJT66FHVVohewwA8tA2iMhyQ3sKDzWrDJJrFELFvCKqt0XrGLepSEh96uMNGPzxDu7WGNFwxEae0 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(376002)(346002)(136003)(39860400002)(230273577357003)(230173577357003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(6486002)(31696002)(86362001)(83380400001)(6916009)(316002)(6666004)(66476007)(66946007)(66556008)(44832011)(6506007)(8676002)(8936002)(31686004)(6512007)(478600001)(26005)(5660300002)(38100700002)(41300700001)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10171 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: AMS0EPF000001A0.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dccdfcfa-6227-420d-2c68-08dbf6594a95 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pT6eJRy91dNSwZYevNBUtVH8727TRdmZJfw/iFdTD8tFut9q7gJPhzN1RZ9s9bfwc7VAe8dbbbVbTndSVrAhcJoyaMlyNCh9o3d+etvx9PIpCbPMTt3u4nfqBoWkI07xZeNZlNzP9pdCOwWfGh9caFYeqbecg8FDwstPfpOPYjp9W8ftORTfzv/MVogPOIsWfx+VHT+Dae8KDiWidx9xpj4JmEH3o4D/F0T5ePd+XoBCRTi7eNNHiaiK/DoFZygrojJI/RTTs9QjFsnNjIlKkMr+whS1CpOBZWbTQz53vMGZkD5uORn6dzkGsEV5HScDVuaMARGC69hVjrb7WPO6jcQwHVc5joJ7K2L4EuyLbSg+aljN/RWt26WUYzeVsPPny4pYUWPBuYRuhlV/vS7avvByAIkkNJsvuYnp5JLqtLaxp44dh3k0N7hiG9F1k1rw3cYoe+PSTNpk1TRW0kJqr8g/Glcn59tFxouYK63Yp2ws4kMyTC5YrBTruVnsDTjRWLr2cRjmN7hO0OfcYT33QF6m+4iMIPZ1w52pb6Fnx6Q0EXr6yGHh2B6xslOa79LSFaP985qNbp7amHqO+/fj/ZQn2aHvJwnW1Okp4IO2hHhog9kWARapfCgALIlIB2QVvqkmTCgmu1EfsTiOTd0kNxSVI/qp5ewH0ZYB2ZLa8xmZlP3wPHF8GohHpWG+blbPlHHAGkn3glXlYin01hCjn2+vHLCNCw/7JFQ1RwURiVrPcQXhsCdb/tD8Jy4mRr9i5lWwK4Qtzy7gNOAihushZyzQgrh51mvMTkaZrWXP2sM= 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:(13230031)(4636009)(396003)(39860400002)(376002)(346002)(136003)(230173577357003)(230922051799003)(230273577357003)(64100799003)(451199024)(82310400011)(1800799012)(186009)(40470700004)(46966006)(36840700001)(31686004)(40480700001)(40460700003)(356005)(81166007)(47076005)(2906002)(5660300002)(82740400003)(83380400001)(6512007)(336012)(6666004)(6506007)(36860700001)(26005)(41300700001)(478600001)(6486002)(70206006)(6916009)(316002)(70586007)(8676002)(44832011)(8936002)(31696002)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 12:46:05.6476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a92db6c-0f88-4153-000f-08dbf6594ff6 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: AMS0EPF000001A0.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6205 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784536680456271975 X-GMAIL-MSGID: 1784536680456271975 Change the handling of some attribute mutual exclusions to use the generic attribute exclusion lists, and fix some asymmetric exclusions by adding the exclusions for always_inline after noinline or target_clones. Aside from the new always_inline exclusions, the only change is functionality is the choice of warning message displayed. All warnings about attribute mutual exclusions now use the same message. gcc/ada/ChangeLog: * gcc-interface/utils.cc (attr_noinline_exclusions): New. (attr_always_inline_exclusions): Ditto. (attr_target_exclusions): Ditto. (attr_target_clones_exclusions): Ditto. (gnat_internal_attribute_table): Add new exclusion lists. (handle_noinline_attribute): Remove custom exclusion handling. (handle_target_attribute): Ditto. (handle_target_clones_attribute): Ditto. diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index e7b5c7783b1f1c702130c8879c79b7e329764b09..f2c504ddf8d3df11abe81aec695c9eea0b39da6c 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -130,6 +130,32 @@ static const struct attribute_spec::exclusions attr_stack_protect_exclusions[] = { NULL, false, false, false }, }; +static const struct attribute_spec::exclusions attr_always_inline_exclusions[] = +{ + { "noinline", true, true, true }, + { "target_clones", true, true, true }, + { NULL, false, false, false }, +}; + +static const struct attribute_spec::exclusions attr_noinline_exclusions[] = +{ + { "always_inline", true, true, true }, + { NULL, false, false, false }, +}; + +static const struct attribute_spec::exclusions attr_target_exclusions[] = +{ + { "target_clones", true, true, true }, + { NULL, false, false, false }, +}; + +static const struct attribute_spec::exclusions attr_target_clones_exclusions[] = +{ + { "always_inline", true, true, true }, + { "target", true, true, true }, + { NULL, false, false, false }, +}; + /* Fake handler for attributes we don't properly support, typically because they'd require dragging a lot of the common-c front-end circuitry. */ static tree fake_attribute_handler (tree *, tree, tree, int, bool *); @@ -165,7 +191,7 @@ const struct attribute_spec gnat_internal_attribute_table[] = { "strub", 0, 1, false, true, false, true, handle_strub_attribute, NULL }, { "noinline", 0, 0, true, false, false, false, - handle_noinline_attribute, NULL }, + handle_noinline_attribute, attr_noinline_exclusions }, { "noclone", 0, 0, true, false, false, false, handle_noclone_attribute, NULL }, { "no_icf", 0, 0, true, false, false, false, @@ -175,7 +201,7 @@ const struct attribute_spec gnat_internal_attribute_table[] = { "leaf", 0, 0, true, false, false, false, handle_leaf_attribute, NULL }, { "always_inline",0, 0, true, false, false, false, - handle_always_inline_attribute, NULL }, + handle_always_inline_attribute, attr_always_inline_exclusions }, { "malloc", 0, 0, true, false, false, false, handle_malloc_attribute, NULL }, { "type generic", 0, 0, false, true, true, false, @@ -192,9 +218,9 @@ const struct attribute_spec gnat_internal_attribute_table[] = { "simd", 0, 1, true, false, false, false, handle_simd_attribute, NULL }, { "target", 1, -1, true, false, false, false, - handle_target_attribute, NULL }, + handle_target_attribute, attr_target_exclusions }, { "target_clones",1, -1, true, false, false, false, - handle_target_clones_attribute, NULL }, + handle_target_clones_attribute, attr_target_clones_exclusions }, { "vector_size", 1, 1, false, true, false, false, handle_vector_size_attribute, NULL }, @@ -6755,16 +6781,7 @@ handle_noinline_attribute (tree *node, tree name, int ARG_UNUSED (flags), bool *no_add_attrs) { if (TREE_CODE (*node) == FUNCTION_DECL) - { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with attribute %qs", name, "always_inline"); - *no_add_attrs = true; - } - else - DECL_UNINLINABLE (*node) = 1; - } + DECL_UNINLINABLE (*node) = 1; else { warning (OPT_Wattributes, "%qE attribute ignored", name); @@ -7063,12 +7080,6 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, warning (OPT_Wattributes, "%qE attribute ignored", name); *no_add_attrs = true; } - else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "target_clones"); - *no_add_attrs = true; - } else if (!targetm.target_option.valid_attribute_p (*node, name, args, flags)) *no_add_attrs = true; @@ -7096,23 +7107,8 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args), { /* Ensure we have a function type. */ if (TREE_CODE (*node) == FUNCTION_DECL) - { - if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "always_inline"); - *no_add_attrs = true; - } - else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node))) - { - warning (OPT_Wattributes, "%qE attribute ignored due to conflict " - "with %qs attribute", name, "target"); - *no_add_attrs = true; - } - else - /* Do not inline functions with multiple clone targets. */ - DECL_UNINLINABLE (*node) = 1; - } + /* Do not inline functions with multiple clone targets. */ + DECL_UNINLINABLE (*node) = 1; else { warning (OPT_Wattributes, "%qE attribute ignored", name); From patchwork Wed Dec 6 12:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Carlotti X-Patchwork-Id: 174565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4078760vqy; Wed, 6 Dec 2023 04:48:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2QtUm5P5RV0SA+yCUdC5OoQHESe4cyjv4V1bGxSlH3GZRs6Z9GTmmLuh72iUji6HyqPQw X-Received: by 2002:ad4:5de2:0:b0:67a:8954:a735 with SMTP id jn2-20020ad45de2000000b0067a8954a735mr1421083qvb.1.1701866905990; Wed, 06 Dec 2023 04:48:25 -0800 (PST) ARC-Seal: i=4; a=rsa-sha256; t=1701866905; cv=pass; d=google.com; s=arc-20160816; b=yHdgvLCZ0551XTUS5ubN/m9r4e+dT1SFewrHTvXrAT9lgDZevEqxxNARgOZAMiGLYu s1X1t0QqPWHyiq1w8DVBgK6lSOoxmLZBtquX3Kh+Oaf1z/z4gY27Vec9LhlnEos22lMp myBjtitmStdmiI3RxEn5HDnJNy+SGkxBuX707LHRUlhgNh6UYOR5o8N5XSRPrt47tqPa qGkNMItrjL+1RYo8xIkwuqO895LdK/5Upuhm47QZ+PffC3ZZXg57z+xjiVB6VIgFeB0H Gj+nm7ZaXd9MezCnGawi3O+mWR57vVOAe1zBtMgkmCXo6ySysq9Sk6if6SIJPDMHZQny DL6Q== ARC-Message-Signature: i=4; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:original-authentication-results :nodisclaimer:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date :authentication-results-original:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ungsJt5BUstY3HUqpKm4jkKpBcasvhJC1G+3NVP8zZE=; fh=B6eSN5jfGy32/zQNoZmUbNOuIMBFSM+k7Ot/R/Qnehw=; b=Al/0BTJZClWF5GbKxN8g7Vy3S0CQd5nXTxCyfYSbigD8fwPdZUmrdWhUgF4639ah0N GLg0Dd3XC7Jn3dSb24t4f/VS16BrXIdWTymY+tvpE1CHPnKp/TJchVzoYiVyIOEWXmne ami44XAAuOv4zIidWjH+nNMz7NyPAjbz+aAyzn2veZ3Iqbf88X5MCyWQEvvZJiynlies q1Qc0BZ0VKcrxm8JMlHJfyzZxWFuwIjbBoeWs0jOxakDU+x4FLqSXaZnnrTP+Hb4dMH8 QuMXCnjitcQS0JneLfGHexDRnx2HBzwFPl5P4Wz5EoN7jJ0UrThrYa1+RMR54OWFeimv jMVA== ARC-Authentication-Results: i=4; mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=2Yel7k3K; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=2Yel7k3K; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j5-20020a056214022500b0067a2b079e32si13741658qvt.591.2023.12.06.04.48.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:48:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.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=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=2Yel7k3K; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=2Yel7k3K; arc=pass (i=3); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B9903857C41 for ; Wed, 6 Dec 2023 12:48:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2071.outbound.protection.outlook.com [40.107.13.71]) by sourceware.org (Postfix) with ESMTPS id 9B6033858C2A for ; Wed, 6 Dec 2023 12:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B6033858C2A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9B6033858C2A Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.13.71 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866868; cv=pass; b=ta9up3mkBzsP4pVmecDyW4DTfEFOJs5TMHf8Mi2ryKM+SxG7Ouchwxy1TeLliu/9BpYUwUY2zIUbURgjV9h2VdbrGUCnD59bf20K8aiPzKoKPyEXZ9F7rhUZmTJcsIWNLrrfJwT1W0hIdRxrptQVzVR79SjHB9SBKO/JRYaHQQg= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1701866868; c=relaxed/simple; bh=szbbu5AVicN5b6jyJLLxlEM8zfgRY077GJxe6HoqGwM=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=igJ0pjHZnUFQnhyJ3uuXuzX87txox8XGeCSV4IyjSF8+7Xq+ZI2R51zrw/Ui+DmWT/yBf468Qf+QC7OmzfcNdibNfEQIqo3FGZ4W0X0H/tTPIZ2urwQK83ec4TcSOJ2/yU+mbUC4dsGUbsv9gO1GqSys4xX06Lb6N3EM6FexVpQ= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=SgZdILiF8O1WrkgMIrZHCAgFSXQV6Lz7swycsySBEER3DtedoZto9iwq39ue9twdz7eguzXNpoy8YlAjtw0DHtFIKdz5oGskmbznyG7fvPuCkCQvntqOxmtyJ139z1GdTEYR+Uc5YFdq0IWrbtIKDNFmAaUgCuq2i0AQ/pVOu1n39Dw12lvhYVH57HCxODqyI/GQOCIgxUlWBVHSlctT3pNbUu+wFzprDHPAaXLnKnNRxebdj31ZmY3ah24gq9JBCDbpnXa+u4Vds7Z6ulGqlSHT7wrFhUhLNofY5ON0JCARlL5ac0cz3uVLpikFiB9S4Vp+I2ZrdasktwIrnIwEfA== 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=ungsJt5BUstY3HUqpKm4jkKpBcasvhJC1G+3NVP8zZE=; b=Hp8wvzRJA7k9XOetEa/4YOyht8vZPJdETxXdV7ICQ8S3MOfWQa0KeR/XWFpoU/xRscSJDHReYuh/jWNspKJA2K8ORcbhxl0SGM0ZNK4IFdClVZqauNbhYRSQT0fMGzFPRejtSKT2XBMfTVxoEVp3zNRU8me5Lfvn5nIamSTHaIfU8L2suNcfyhKCUQEIHXxstkSrgvtg9h4DWXIouto+JvyzSUzBQ8p/DFzCIOpxikUV4HdbcAOBybRnYavekIcUtwgKhdfcBXj0bg0L3nOkk0H5crA0xC/hDv/3Ndkt2FnC1X/3uYnGu1qLsco3EWmi4VaJ0FWYwhVHmotDw5Wnpg== 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]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ungsJt5BUstY3HUqpKm4jkKpBcasvhJC1G+3NVP8zZE=; b=2Yel7k3KLwupkn9W7oHoMMGsY97FIGh5gTs+DaNaEVPUvM6UOcyx15mEpZWYgEHs3Kf5OVcmdKa+Mwg12eHcWA7R/qwtAEHN97zMSNcP8UsdMfEztC9ZTSKbYv9B7/Rji16gQ/kXgc4SZwO7GoPO0bxHeugXwIYLTYdg3qiVbb4= Received: from DUZPR01CA0249.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::10) by DBAPR08MB5591.eurprd08.prod.outlook.com (2603:10a6:10:1ae::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 12:47:31 +0000 Received: from DB5PEPF00014B96.eurprd02.prod.outlook.com (2603:10a6:10:4b5:cafe::ba) by DUZPR01CA0249.outlook.office365.com (2603:10a6:10:4b5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 12:47:31 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5PEPF00014B96.mail.protection.outlook.com (10.167.8.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 12:47:31 +0000 Received: ("Tessian outbound 7671e7ddc218:v228"); Wed, 06 Dec 2023 12:47:31 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6abc6bad6e9855d0 X-CR-MTA-TID: 64aa7808 Received: from 2933c74e096a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1FF6F544-364F-4253-8EE9-0B18BA965234.1; Wed, 06 Dec 2023 12:47:21 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2933c74e096a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Dec 2023 12:47:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SyuHK2rPdu97sGDsV1/ynRWlHRwQg9JvqMk54YUdqWEMs+G6WgJHHB5cbWGQoJa4rTP6nbC1j5Y2c6DDS3G6JAgWNgy2SLRHBzVzABq6XNtT205xswOUsSr9atVD7SF7k6T06PFuP+iFeEc2OHlABIzWpBnoEOiW2rO9zZyEwAhRUYt/NsbDbHiSar1rS/1jDBrJcjRmtyyxwwTPKW58dj47S7w8yh0xoQMSi7cOvdl2dckJ6vhRpOn0B0HPF6NoaEMI95lqnUtxs8bfMhOv/piS6ZAw/w33THIjDlO2HJMNx2guyeQ85aK4npeaTSH9BciTQinw+k3dwvyqFgcvEQ== 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=ungsJt5BUstY3HUqpKm4jkKpBcasvhJC1G+3NVP8zZE=; b=dvamkQif9103EeKYzEAtHHqj6zV+D7znwG6tVaqSeehprw9KaPJwYn/WLlMbBTzEwSDimT2tzrtzVwlSIa3UcDm8ZXc3jK5Z1TfgeIk3wPwGuSssBlJ4HQddnRlwVhctf2hHjjPjAeDXPEQ7XN8jYdrv3/YO4Z8HbbE3XDfl762AxiUv5HkC4sK5NWO4BLBX1Glg+9fZNVx7cF0M2kIRIvHfVGcfjiTTP2zucQRIE6lXFLulg4suzlmpTmXug20z5up94tAOfJLZluY3MGjXqUzb9nhsyt7cJHQjXmjzmupfgNcFND0zxjICsAr0PcmWd7RfCpGrjfNf7Fvg21nmkw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ungsJt5BUstY3HUqpKm4jkKpBcasvhJC1G+3NVP8zZE=; b=2Yel7k3KLwupkn9W7oHoMMGsY97FIGh5gTs+DaNaEVPUvM6UOcyx15mEpZWYgEHs3Kf5OVcmdKa+Mwg12eHcWA7R/qwtAEHN97zMSNcP8UsdMfEztC9ZTSKbYv9B7/Rji16gQ/kXgc4SZwO7GoPO0bxHeugXwIYLTYdg3qiVbb4= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by AS8PR08MB10171.eurprd08.prod.outlook.com (2603:10a6:20b:62a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 12:47:17 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::af15:c9d7:cd8c:6da2%7]) with mapi id 15.20.7068.025; Wed, 6 Dec 2023 12:47:17 +0000 Date: Wed, 6 Dec 2023 12:47:15 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Cc: Richard Biener , Richard Sandiford Subject: [PATCH v3 5/5] aarch64: Add function multiversioning support Message-ID: <2224863c-2f8b-3c82-4c3b-8dfee7a974b7@e124511.cambridge.arm.com> References: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> Content-Disposition: inline In-Reply-To: <4cdd7089-edd4-96b9-5c0e-120d5357f01b@e124511.cambridge.arm.com> X-ClientProxiedBy: LO2P265CA0462.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::18) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS8PR08MB10171:EE_|DB5PEPF00014B96:EE_|DBAPR08MB5591:EE_ X-MS-Office365-Filtering-Correlation-Id: ae418232-fcec-43f4-5744-08dbf6598319 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: WgexV5Prx76X5jfBXlEv4bhyhdHVM2zi60xB1ZJXtfpWnJmWCSCLTSEhs26HY+V0AMW3lSdwNegsshlLljvvSwI+y8EQm0BhttBNvy+eXzLgsCZZ08lXo0OWf4WmvWw0weF1j/bIJ3lpMeupZ2SEjEAxkg6J2fr1WFLMbeD87W/sf1IgLZ0PLHTZctnOgesvSfD+Zy6NdAO9WeR6XtB7j3NKsQIWQdVDDySjURXT67XEcMI9y1uV5ycUVp7Sf1cKZLPWX7OXLPT4UIoWYtyS4uGLLvuRK4qJfLZgoDBxYJ5zug8GpMrBvfrWd2YROe1D4iwqwSlHHTZgMFxRVPc1AxwvLTk6FaFVHJpPvBJxVpN8AvvvcDTOPr+YAozhlEpq+INW5gtnS1eBL/IhV5p3uKWL2QcJaHKp9L89xyyv7j8ahF4F4oeFuLQHIGG2YOXBoEmcqAvmhV2wCUWMFfHJ4dz7Z0hbDXVE65IREqhd0bB9pc6lHbtM5UFI/YFFrYNnFzgEX6iyw1wspKIRyMrx4G9Goy3nmB/2ZD9UVi62McWfykkR9UJIXJZeVM4NsuALZVhbz9PuqVsjDhGgG6aTmYbF3nvV0aKLWoEYlireBQIEgpq5AP/mJTGsaoRjXA4dNHPWU28EaqVsAiXzHgF+iqM+IEABBAnNwS9lkU3YKyHAyaeSJF0blx/dP200sJU6 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(376002)(346002)(136003)(39860400002)(230273577357003)(230173577357003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(6486002)(966005)(31696002)(86362001)(83380400001)(6916009)(316002)(84970400001)(54906003)(66476007)(66946007)(66556008)(44832011)(6506007)(4326008)(8676002)(8936002)(31686004)(6512007)(478600001)(26005)(5660300002)(38100700002)(30864003)(41300700001)(2906002)(2004002)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10171 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: DB5PEPF00014B96.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2a580bd4-0ac1-427f-26c2-08dbf6597ae4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Lt4+wOvKW2ENhsgHsKQbfihVqLu+rZOX1H/+Z+6sLb8TPywaF6N2ELSrW66qDU0lvYWngeLZq3CccyJ0UFwzuahPMNT68i5QHscTiUmqzQHUQLtfLkWHdE9AsbENBP6LTf/x2jAVoLhJKa0PKTKOAZ3PAgwaL9a97TC+uZzRsvHICnjdcxvJQ7Y/XhGErIl//vkpAOfGKNAKzWmaglEEH2gYAGZ4z6qKUNm7M6B+4RhhDq9qQlm8qx6h4eiWOIWTAPwAMmC/ki/ArjnvRWHBiu9YD/LyfH+EHTR9qTgQE/i2iAXfKzzcsMXW+duRjCNfmBCPnHH3SCBoaGNMT+NI8zrBXfmBBuTSn/TJ4KrnkgsyNWWIOCJ7zfW49w6zSDpBpik2pwHB6yWI4LNK+LxZs0EkMHR175f/TekiTeCAZ4m2IZerVLvph3teXRkR0IQe+Ym1RX5QXHB+Hp6heDfKKaSTe+4kRorYSmy1rFz2W+8tPiQ9USrBV+Ov9faKOWyJV1dlOSiygkM2TjjJSdlO4mEoySnaINpEsvqLgsstRZdUiWVhaSGjk+P/dCXlFORgWmZy9q7rv55ljSmaVb2NeBgk1KwH+FimkXXj4jNTxyGIAhXw9SDmghip9M44PFyMxFmnhHy0mizzZODzsn5oeyv6YiLBJV5RHOKSmFZWXKD2aXVuyOJI1fNHBq71BQqURBm/UoDyn0dUX8KSQ1dP9Eu5cYEnwyN1BzEqYPJuITU4zTk3GBA4w7+DCgYSkELMmPMgqoKf3DyWd2Tnzf7aSxdabxbWgvuvivxEkaI4R8= 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:(13230031)(4636009)(136003)(346002)(396003)(39850400004)(376002)(230173577357003)(230273577357003)(230922051799003)(186009)(64100799003)(82310400011)(1800799012)(451199024)(46966006)(36840700001)(30864003)(40480700001)(84970400001)(36860700001)(44832011)(31696002)(2906002)(316002)(6916009)(54906003)(70206006)(70586007)(4326008)(8676002)(86362001)(8936002)(41300700001)(47076005)(31686004)(5660300002)(82740400003)(81166007)(356005)(6486002)(83380400001)(478600001)(26005)(966005)(336012)(6512007)(6506007)(2004002)(559001)(579004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 12:47:31.5055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae418232-fcec-43f4-5744-08dbf6598319 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: DB5PEPF00014B96.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5591 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784536792477639957 X-GMAIL-MSGID: 1784536792477639957 This adds initial support for function multiversioning on aarch64 using the target_version and target_clones attributes. This loosely follows the Beta specification in the ACLE [1], although with some differences that still need to be resolved (possibly as follow-up patches). Existing function multiversioning implementations are broken in various ways when used across translation units. This includes placing resolvers in the wrong translation units, and using symbol mangling that callers to unintentionally bypass the resolver in some circumstances. Fixing these issues for aarch64 will require modifications to our ACLE specification. It will also require further adjustments to existing middle end code, to facilitate different mangling and resolver placement while preserving existing target behaviours. The list of function multiversioning features specified in the ACLE is also inconsistent with the list of features supported in target option extensions. I intend to resolve some or all of these inconsistencies at a later stage. The target_version attribute is currently only supported in C++, since this is the only frontend with existing support for multiversioning using the target attribute. On the other hand, this patch happens to enable multiversioning with the target_clones attribute in Ada and D, as well as the entire C family, using their existing frontend support. This patch also does not support the following aspects of the Beta specification: - The target_clones attribute should allow an implicit unlisted "default" version. - There should be an option to disable function multiversioning at compile time. - Unrecognised target names in a target_clones attribute should be ignored (with an optional warning). This current patch raises an error instead. [1] https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning --- I believe the support present in this patch correctly handles function multiversioning within a single translation unit for all features in the ACLE specification with option extension support. Is it ok to push this patch in its current state? I'd then continue working on incremental improvements to the supported feature extensions and the ABI issues in followup patches, along with corresponding changes and improvements to the ACLE specification. gcc/ChangeLog: * config/aarch64/aarch64-feature-deps.h (fmv_deps_): Define aarch64_feature_flags mask foreach FMV feature. * config/aarch64/aarch64-option-extensions.def: Use new macros to define FMV feature extensions. * config/aarch64/aarch64.cc (aarch64_option_valid_attribute_p): Check for target_version attribute after processing target attribute. (aarch64_fmv_feature_data): New. (aarch64_parse_fmv_features): New. (aarch64_process_target_version_attr): New. (aarch64_option_valid_version_attribute_p): New. (get_feature_mask_for_version): New. (compare_feature_masks): New. (aarch64_compare_version_priority): New. (build_ifunc_arg_type): New. (make_resolver_func): New. (add_condition_to_bb): New. (dispatch_function_versions): New. (aarch64_generate_version_dispatcher_body): New. (aarch64_get_function_versions_dispatcher): New. (aarch64_common_function_versions): New. (aarch64_mangle_decl_assembler_name): New. (TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P): New implementation. (TARGET_OPTION_EXPANDED_CLONES_ATTRIBUTE): New implementation. (TARGET_OPTION_FUNCTION_VERSIONS): New implementation. (TARGET_COMPARE_VERSION_PRIORITY): New implementation. (TARGET_GENERATE_VERSION_DISPATCHER_BODY): New implementation. (TARGET_GET_FUNCTION_VERSIONS_DISPATCHER): New implementation. (TARGET_MANGLE_DECL_ASSEMBLER_NAME): New implementation. * config/aarch64/aarch64.h (TARGET_HAS_FMV_TARGET_ATTRIBUTE): Set target macro. * config/arm/aarch-common.h (enum aarch_parse_opt_result): Add new value to report duplicate FMV feature. * common/config/aarch64/cpuinfo.h: New file. libgcc/ChangeLog: * config/aarch64/cpuinfo.c (enum CPUFeatures): Move to shared copy in gcc/common gcc/testsuite/ChangeLog: * gcc.target/aarch64/options_set_17.c: Reorder expected flags. * gcc.target/aarch64/cpunative/native_cpu_0.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_13.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_16.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_17.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_18.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_19.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_20.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_21.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_22.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_6.c: Ditto. * gcc.target/aarch64/cpunative/native_cpu_7.c: Ditto. diff --git a/gcc/common/config/aarch64/cpuinfo.h b/gcc/common/config/aarch64/cpuinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..1690b6eee48e960d0ae675f8e8b05e6f182b56a3 --- /dev/null +++ b/gcc/common/config/aarch64/cpuinfo.h @@ -0,0 +1,94 @@ +/* CPU feature detection for AArch64 architecture. + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GCC. + + This file is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3, or (at your option) any + later version. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This enum is used in libgcc feature detection, and in the function + multiversioning implementation in aarch64.cc. The enum should use the same + values as the corresponding enum in LLVM's compiler-rt, to faciliate + compatibility between compilers. */ + +enum CPUFeatures { + FEAT_RNG, + FEAT_FLAGM, + FEAT_FLAGM2, + FEAT_FP16FML, + FEAT_DOTPROD, + FEAT_SM4, + FEAT_RDM, + FEAT_LSE, + FEAT_FP, + FEAT_SIMD, + FEAT_CRC, + FEAT_SHA1, + FEAT_SHA2, + FEAT_SHA3, + FEAT_AES, + FEAT_PMULL, + FEAT_FP16, + FEAT_DIT, + FEAT_DPB, + FEAT_DPB2, + FEAT_JSCVT, + FEAT_FCMA, + FEAT_RCPC, + FEAT_RCPC2, + FEAT_FRINTTS, + FEAT_DGH, + FEAT_I8MM, + FEAT_BF16, + FEAT_EBF16, + FEAT_RPRES, + FEAT_SVE, + FEAT_SVE_BF16, + FEAT_SVE_EBF16, + FEAT_SVE_I8MM, + FEAT_SVE_F32MM, + FEAT_SVE_F64MM, + FEAT_SVE2, + FEAT_SVE_AES, + FEAT_SVE_PMULL128, + FEAT_SVE_BITPERM, + FEAT_SVE_SHA3, + FEAT_SVE_SM4, + FEAT_SME, + FEAT_MEMTAG, + FEAT_MEMTAG2, + FEAT_MEMTAG3, + FEAT_SB, + FEAT_PREDRES, + FEAT_SSBS, + FEAT_SSBS2, + FEAT_BTI, + FEAT_LS64, + FEAT_LS64_V, + FEAT_LS64_ACCDATA, + FEAT_WFXT, + FEAT_SME_F64, + FEAT_SME_I64, + FEAT_SME2, + FEAT_RCPC3, + FEAT_MAX, + FEAT_EXT = 62, /* Reserved to indicate presence of additional features field + in __aarch64_cpu_features. */ + FEAT_INIT /* Used as flag of features initialization completion. */ +}; diff --git a/gcc/config/aarch64/aarch64-feature-deps.h b/gcc/config/aarch64/aarch64-feature-deps.h index 7b85a8860de57f6727644c03296cef192ad0990c..8f20582e1efdd4817138480bee8cdb27fa7f3dfe 100644 --- a/gcc/config/aarch64/aarch64-feature-deps.h +++ b/gcc/config/aarch64/aarch64-feature-deps.h @@ -115,6 +115,13 @@ get_flags_off (aarch64_feature_flags mask) constexpr auto cpu_##CORE_IDENT = ARCH_IDENT ().enable | get_enable FEATURES; #include "config/aarch64/aarch64-cores.def" +/* Define fmv_deps_ variables for each FMV feature, giving the transitive + closure of all the features that the FMV feature enables. */ +#define AARCH64_FMV_FEATURE(A, FEAT_NAME, OPT_FLAGS) \ + constexpr auto fmv_deps_##FEAT_NAME = get_enable OPT_FLAGS; +#include "config/aarch64/aarch64-option-extensions.def" + + } } diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def index 825f3bf775899e2e5cffb1867b82766d632c8708..29f542a183380b61a26b302816584d3c0990be55 100644 --- a/gcc/config/aarch64/aarch64-option-extensions.def +++ b/gcc/config/aarch64/aarch64-option-extensions.def @@ -17,17 +17,22 @@ along with GCC; see the file COPYING3. If not see . */ -/* This is a list of ISA extentsions in AArch64. +/* This is a list of ISA extensions in AArch64. - Before using #include to read this file, define a macro: + Before using #include to read this file, define one of the following + macros: AARCH64_OPT_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, EXPLICIT_OFF, FEATURE_STRING) + AARCH64_FMV_FEATURE(NAME, FEAT_NAME, IDENT) + - NAME is the name of the extension, represented as a string constant. - IDENT is the canonical internal name for this flag. + - FEAT_NAME is the unprefixed name used in the CPUFeatures enum. + - REQUIRES is a list of features that must be enabled whenever this feature is enabled. The relationship is implicitly transitive: if A appears in B's REQUIRES and B appears in C's REQUIRES then @@ -58,45 +63,96 @@ that are required. Their order is not important. An empty string means do not detect this feature during auto detection. - The list of features must follow topological order wrt REQUIRES - and EXPLICIT_ON. For example, if A is in B's REQUIRES list, A must - come before B. This is enforced by aarch64-feature-deps.h. + - OPT_FLAGS is a list of feature IDENTS that should be enabled (along with + their transitive dependencies) when the specified FMV feature is present. + + Where a feature is present as both an extension and a function + multiversioning feature, and IDENT matches the FEAT_NAME suffix, then these + can be listed here simultaneously using the macro: + + AARCH64_OPT_FMV_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, + EXPLICIT_OFF, FEATURE_STRING) + + The list of features extensions must follow topological order wrt REQUIRES + and EXPLICIT_ON. For example, if A is in B's REQUIRES list, A must come + before B. This is enforced by aarch64-feature-deps.h. + + The list of multiversioning features must be ordered by increasing priority, + as defined in https://github.com/ARM-software/acle/blob/main/main/acle.md NOTE: Any changes to the AARCH64_OPT_EXTENSION macro need to be mirrored in config.gcc. */ +#ifndef AARCH64_OPT_EXTENSION +#define AARCH64_OPT_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, \ + EXPLICIT_OFF, FEATURE_STRING) +#endif + +#ifndef AARCH64_FMV_FEATURE +#define AARCH64_FMV_FEATURE(NAME, FEAT_NAME, OPT_FLAGS) +#endif + +#define AARCH64_OPT_FMV_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, \ + EXPLICIT_OFF, FEATURE_STRING) \ +AARCH64_OPT_EXTENSION(NAME, IDENT, REQUIRES, EXPLICIT_ON, EXPLICIT_OFF, \ + FEATURE_STRING) \ +AARCH64_FMV_FEATURE(NAME, IDENT, (IDENT)) + + AARCH64_OPT_EXTENSION("fp", FP, (), (), (), "fp") AARCH64_OPT_EXTENSION("simd", SIMD, (FP), (), (), "asimd") -AARCH64_OPT_EXTENSION("crc", CRC, (), (), (), "crc32") +AARCH64_OPT_FMV_EXTENSION("rng", RNG, (), (), (), "rng") -AARCH64_OPT_EXTENSION("lse", LSE, (), (), (), "atomics") +AARCH64_OPT_FMV_EXTENSION("flagm", FLAGM, (), (), (), "flagm") -/* +nofp16 disables an implicit F16FML, even though an implicit F16FML - does not imply F16. See F16FML for more details. */ -AARCH64_OPT_EXTENSION("fp16", F16, (FP), (), (F16FML), "fphp asimdhp") +AARCH64_FMV_FEATURE("flagm2", FLAGM2, (FLAGM)) + +AARCH64_FMV_FEATURE("fp16fml", FP16FML, (F16FML)) + +AARCH64_OPT_FMV_EXTENSION("dotprod", DOTPROD, (SIMD), (), (), "asimddp") -AARCH64_OPT_EXTENSION("rcpc", RCPC, (), (), (), "lrcpc") +AARCH64_OPT_FMV_EXTENSION("sm4", SM4, (SIMD), (), (), "sm3 sm4") /* An explicit +rdma implies +simd, but +rdma+nosimd still enables scalar RDMA instructions. */ AARCH64_OPT_EXTENSION("rdma", RDMA, (), (SIMD), (), "asimdrdm") -AARCH64_OPT_EXTENSION("dotprod", DOTPROD, (SIMD), (), (), "asimddp") +AARCH64_FMV_FEATURE("rmd", RDM, (RDMA)) + +AARCH64_OPT_FMV_EXTENSION("lse", LSE, (), (), (), "atomics") + +AARCH64_FMV_FEATURE("fp", FP, (FP)) + +AARCH64_FMV_FEATURE("simd", SIMD, (SIMD)) + +AARCH64_OPT_FMV_EXTENSION("crc", CRC, (), (), (), "crc32") -AARCH64_OPT_EXTENSION("aes", AES, (SIMD), (), (), "aes") +AARCH64_FMV_FEATURE("sha1", SHA1, ()) -AARCH64_OPT_EXTENSION("sha2", SHA2, (SIMD), (), (), "sha1 sha2") +AARCH64_OPT_FMV_EXTENSION("sha2", SHA2, (SIMD), (), (), "sha1 sha2") + +AARCH64_FMV_FEATURE("sha3", SHA3, (SHA3)) + +AARCH64_OPT_FMV_EXTENSION("aes", AES, (SIMD), (), (), "aes") + +AARCH64_FMV_FEATURE("pmull", PMULL, ()) /* +nocrypto disables AES, SHA2 and SM4, and anything that depends on them (such as SHA3 and the SVE2 crypto extensions). */ AARCH64_OPT_EXTENSION("crypto", CRYPTO, (AES, SHA2), (), (AES, SHA2, SM4), "aes pmull sha1 sha2") +/* Listing sha3 after crypto means we pass "+aes+sha3" to the assembler + instead of "+sha3+crypto". */ AARCH64_OPT_EXTENSION("sha3", SHA3, (SHA2), (), (), "sha3 sha512") -AARCH64_OPT_EXTENSION("sm4", SM4, (SIMD), (), (), "sm3 sm4") +/* +nofp16 disables an implicit F16FML, even though an implicit F16FML + does not imply F16. See F16FML for more details. */ +AARCH64_OPT_EXTENSION("fp16", F16, (FP), (), (F16FML), "fphp asimdhp") + +AARCH64_FMV_FEATURE("fp16", FP16, (F16)) /* An explicit +fp16fml implies +fp16, but a dependence on it does not. Thus -march=armv8.4-a implies F16FML but not F16. -march=armv8.4-a+fp16 @@ -104,51 +160,117 @@ AARCH64_OPT_EXTENSION("sm4", SM4, (SIMD), (), (), "sm3 sm4") -march=armv8.4-a+nofp16+fp16 enables F16 but not F16FML. */ AARCH64_OPT_EXTENSION("fp16fml", F16FML, (), (F16), (), "asimdfhm") -AARCH64_OPT_EXTENSION("sve", SVE, (SIMD, F16), (), (), "sve") +AARCH64_FMV_FEATURE("dit", DIT, ()) -AARCH64_OPT_EXTENSION("profile", PROFILE, (), (), (), "") +AARCH64_FMV_FEATURE("dpb", DPB, ()) -AARCH64_OPT_EXTENSION("rng", RNG, (), (), (), "rng") +AARCH64_FMV_FEATURE("dpb2", DPB2, ()) -AARCH64_OPT_EXTENSION("memtag", MEMTAG, (), (), (), "") +AARCH64_FMV_FEATURE("jscvt", JSCVT, ()) -AARCH64_OPT_EXTENSION("sb", SB, (), (), (), "sb") +AARCH64_FMV_FEATURE("fcma", FCMA, (SIMD)) -AARCH64_OPT_EXTENSION("ssbs", SSBS, (), (), (), "ssbs") +AARCH64_OPT_FMV_EXTENSION("rcpc", RCPC, (), (), (), "lrcpc") -AARCH64_OPT_EXTENSION("predres", PREDRES, (), (), (), "") +AARCH64_FMV_FEATURE("rcpc2", RCPC2, (RCPC)) -AARCH64_OPT_EXTENSION("sve2", SVE2, (SVE), (), (), "sve2") +AARCH64_FMV_FEATURE("rcpc3", RCPC3, (RCPC)) -AARCH64_OPT_EXTENSION("sve2-sm4", SVE2_SM4, (SVE2, SM4), (), (), "svesm4") +AARCH64_FMV_FEATURE("frintts", FRINTTS, ()) + +AARCH64_FMV_FEATURE("dgh", DGH, ()) + +AARCH64_OPT_FMV_EXTENSION("i8mm", I8MM, (SIMD), (), (), "i8mm") + +/* An explicit +bf16 implies +simd, but +bf16+nosimd still enables scalar BF16 + instructions. */ +AARCH64_OPT_FMV_EXTENSION("bf16", BF16, (FP), (SIMD), (), "bf16") + +AARCH64_FMV_FEATURE("ebf16", EBF16, (BF16)) + +AARCH64_FMV_FEATURE("rpres", RPRES, ()) + +AARCH64_OPT_FMV_EXTENSION("sve", SVE, (SIMD, F16), (), (), "sve") + +AARCH64_FMV_FEATURE("sve-bf16", SVE_BF16, (SVE, BF16)) + +AARCH64_FMV_FEATURE("sve-ebf16", SVE_EBF16, (SVE, BF16)) + +AARCH64_FMV_FEATURE("sve-i8mm", SVE_I8MM, (SVE, I8MM)) + +AARCH64_OPT_EXTENSION("f32mm", F32MM, (SVE), (), (), "f32mm") + +AARCH64_FMV_FEATURE("f32mm", SVE_F32MM, (F32MM)) + +AARCH64_OPT_EXTENSION("f64mm", F64MM, (SVE), (), (), "f64mm") + +AARCH64_FMV_FEATURE("f64mm", SVE_F64MM, (F64MM)) + +AARCH64_OPT_FMV_EXTENSION("sve2", SVE2, (SVE), (), (), "sve2") AARCH64_OPT_EXTENSION("sve2-aes", SVE2_AES, (SVE2, AES), (), (), "sveaes") -AARCH64_OPT_EXTENSION("sve2-sha3", SVE2_SHA3, (SVE2, SHA3), (), (), "svesha3") +AARCH64_FMV_FEATURE("sve2-aes", SVE_AES, (SVE2_AES)) + +AARCH64_FMV_FEATURE("sve2-pmull128", SVE_PMULL128, (SVE2)) AARCH64_OPT_EXTENSION("sve2-bitperm", SVE2_BITPERM, (SVE2), (), (), "svebitperm") -AARCH64_OPT_EXTENSION("tme", TME, (), (), (), "") +AARCH64_FMV_FEATURE("sve2-bitperm", SVE_BITPERM, (SVE2_BITPERM)) -AARCH64_OPT_EXTENSION("i8mm", I8MM, (SIMD), (), (), "i8mm") +AARCH64_OPT_EXTENSION("sve2-sha3", SVE2_SHA3, (SVE2, SHA3), (), (), "svesha3") -AARCH64_OPT_EXTENSION("f32mm", F32MM, (SVE), (), (), "f32mm") +AARCH64_FMV_FEATURE("sve2-sha3", SVE_SHA3, (SVE2_SHA3)) -AARCH64_OPT_EXTENSION("f64mm", F64MM, (SVE), (), (), "f64mm") +AARCH64_OPT_EXTENSION("sve2-sm4", SVE2_SM4, (SVE2, SM4), (), (), "svesm4") -/* An explicit +bf16 implies +simd, but +bf16+nosimd still enables scalar BF16 - instructions. */ -AARCH64_OPT_EXTENSION("bf16", BF16, (FP), (SIMD), (), "bf16") +AARCH64_FMV_FEATURE("sve2-sm4", SVE_SM4, (SVE2_SM4)) + +AARCH64_FMV_FEATURE("sme", SME, ()) -AARCH64_OPT_EXTENSION("flagm", FLAGM, (), (), (), "flagm") +AARCH64_OPT_FMV_EXTENSION("memtag", MEMTAG, (), (), (), "") + +AARCH64_FMV_FEATURE("memtag2", MEMTAG2, (MEMTAG)) + +AARCH64_FMV_FEATURE("memtag3", MEMTAG3, (MEMTAG)) + +AARCH64_OPT_FMV_EXTENSION("sb", SB, (), (), (), "sb") + +AARCH64_OPT_FMV_EXTENSION("predres", PREDRES, (), (), (), "") + +AARCH64_OPT_FMV_EXTENSION("ssbs", SSBS, (), (), (), "ssbs") + +AARCH64_FMV_FEATURE("ssbs2", SSBS2, (SSBS)) + +AARCH64_FMV_FEATURE("bti", BTI, ()) + +AARCH64_OPT_EXTENSION("profile", PROFILE, (), (), (), "") + +AARCH64_OPT_EXTENSION("tme", TME, (), (), (), "") AARCH64_OPT_EXTENSION("pauth", PAUTH, (), (), (), "paca pacg") AARCH64_OPT_EXTENSION("ls64", LS64, (), (), (), "") +AARCH64_FMV_FEATURE("ls64", LS64, ()) + +AARCH64_FMV_FEATURE("ls64_v", LS64_V, ()) + +AARCH64_FMV_FEATURE("ls64_accdata", LS64_ACCDATA, (LS64)) + +AARCH64_FMV_FEATURE("wfxt", WFXT, ()) + +AARCH64_FMV_FEATURE("sme-f64f64", SME_F64, ()) + +AARCH64_FMV_FEATURE("sme-i64i64", SME_I64, ()) + +AARCH64_FMV_FEATURE("sme2", SME2, ()) + AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "") AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc") +#undef AARCH64_OPT_FMV_EXTENSION #undef AARCH64_OPT_EXTENSION +#undef AARCH64_FMV_FEATURE diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index d3613a0a42b7b6d2c4452739841b133014909a39..ea49ef6cfa6df35465a111f120cf0db19da8e5e6 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -1181,6 +1181,8 @@ extern enum aarch64_code_model aarch64_cmodel; (aarch64_cmodel == AARCH64_CMODEL_TINY \ || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC) +#define TARGET_HAS_FMV_TARGET_ATTRIBUTE 0 + #define TARGET_SUPPORTS_WIDE_INT 1 /* Modes valid for AdvSIMD D registers, i.e. that fit in half a Q register. */ diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f6f6f94bf431e59f90fceb94483b29cb755c7fda..431fd81b03ba7f1d59d1ece13e327b2d74881a90 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -84,6 +84,7 @@ #include "aarch64-feature-deps.h" #include "config/arm/aarch-common.h" #include "config/arm/aarch-common-protos.h" +#include "common/config/aarch64/cpuinfo.h" #include "ssa.h" /* This file should be included last. */ @@ -17163,6 +17164,8 @@ aarch64_process_target_attr (tree args) return true; } +static bool aarch64_process_target_version_attr (tree args); + /* Implement TARGET_OPTION_VALID_ATTRIBUTE_P. This is used to process attribute ((target ("..."))). */ @@ -17218,6 +17221,19 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int) TREE_TARGET_OPTION (target_option_current_node)); ret = aarch64_process_target_attr (args); + if (ret) + { + tree version_attr = lookup_attribute ("target_version", + DECL_ATTRIBUTES (fndecl)); + if (version_attr != NULL_TREE) + { + /* Reapply any target_version attribute after target attribute. + This should be equivalent to applying the target_version once + after processing all target attributes. */ + tree version_args = TREE_VALUE (version_attr); + ret = aarch64_process_target_version_attr (version_args); + } + } /* Set up any additional state. */ if (ret) @@ -17248,6 +17264,831 @@ aarch64_option_valid_attribute_p (tree fndecl, tree, tree args, int) return ret; } +typedef unsigned long long aarch64_fmv_feature_mask; + +typedef struct +{ + const char *name; + aarch64_fmv_feature_mask feature_mask; + aarch64_feature_flags opt_flags; +} aarch64_fmv_feature_datum; + +#define AARCH64_FMV_FEATURE(NAME, FEAT_NAME, C) \ + {NAME, 1ULL << FEAT_##FEAT_NAME, ::feature_deps::fmv_deps_##FEAT_NAME}, + +/* FMV features are listed in priority order, to make it easier to sort target + strings. */ +static aarch64_fmv_feature_datum aarch64_fmv_feature_data[] = { +#include "config/aarch64/aarch64-option-extensions.def" +}; + +/* Parse a function multiversioning feature string STR, as found in a + target_version or target_clones attribute. + + If ISA_FLAGS is nonnull, then update it with the specified architecture + features turned on. If FEATURE_MASK is nonnull, then assign to it a bitmask + representing the set of features explicitly specified in the feature string. + Return an aarch_parse_opt_result describing the result. + + When the STR string contains an invalid or duplicate extension, a copy of + the extension string is created and stored to INVALID_EXTENSION. */ + +static enum aarch_parse_opt_result +aarch64_parse_fmv_features (const char *str, aarch64_feature_flags *isa_flags, + aarch64_fmv_feature_mask *feature_mask, + std::string *invalid_extension) +{ + if (feature_mask) + *feature_mask = 0ULL; + + if (strcmp (str, "default") == 0) + return AARCH_PARSE_OK; + + while (str != NULL && *str != 0) + { + const char *ext; + size_t len; + + ext = strchr (str, '+'); + + if (ext != NULL) + len = ext - str; + else + len = strlen (str); + + if (len == 0) + return AARCH_PARSE_MISSING_ARG; + + static const int num_features = ARRAY_SIZE (aarch64_fmv_feature_data); + int i; + for (i = 0; i < num_features; i++) + { + if (strlen (aarch64_fmv_feature_data[i].name) == len + && strncmp (aarch64_fmv_feature_data[i].name, str, len) == 0) + { + if (isa_flags) + *isa_flags |= aarch64_fmv_feature_data[i].opt_flags; + if (feature_mask) + { + auto old_feature_mask = *feature_mask; + *feature_mask |= aarch64_fmv_feature_data[i].feature_mask; + if (*feature_mask == old_feature_mask) + { + /* Duplicate feature. */ + if (invalid_extension) + *invalid_extension = std::string (str, len); + return AARCH_PARSE_DUPLICATE_FEATURE; + } + } + break; + } + } + + if (i == num_features) + { + /* Feature not found in list. */ + if (invalid_extension) + *invalid_extension = std::string (str, len); + return AARCH_PARSE_INVALID_FEATURE; + } + + str = ext; + if (str) + /* Skip over the next '+'. */ + str++; + } + + return AARCH_PARSE_OK; +} + +/* Parse the tree in ARGS that contains the target_version attribute + information and update the global target options space. */ + +static bool +aarch64_process_target_version_attr (tree args) +{ + if (TREE_CODE (args) == TREE_LIST) + { + if (TREE_CHAIN (args)) + { + error ("attribute % has multiple values"); + return false; + } + args = TREE_VALUE (args); + } + + if (!args || TREE_CODE (args) != STRING_CST) + { + error ("attribute % argument not a string"); + return false; + } + + const char *str = TREE_STRING_POINTER (args); + + enum aarch_parse_opt_result parse_res; + auto isa_flags = aarch64_asm_isa_flags; + + std::string invalid_extension; + parse_res = aarch64_parse_fmv_features (str, &isa_flags, NULL, + &invalid_extension); + + if (parse_res == AARCH_PARSE_OK) + { + aarch64_set_asm_isa_flags (isa_flags); + return true; + } + + switch (parse_res) + { + case AARCH_PARSE_MISSING_ARG: + error ("missing value in % attribute"); + break; + + case AARCH_PARSE_INVALID_FEATURE: + error ("invalid feature modifier %qs of value %qs in " + "% attribute", invalid_extension.c_str (), + str); + break; + + case AARCH_PARSE_DUPLICATE_FEATURE: + error ("duplicate feature modifier %qs of value %qs in " + "% attribute", invalid_extension.c_str (), + str); + break; + + default: + gcc_unreachable (); + } + + return false; +} + +/* Implement TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P. This is used to + process attribute ((target_version ("..."))). */ + +static bool +aarch64_option_valid_version_attribute_p (tree fndecl, tree, tree args, int) +{ + struct cl_target_option cur_target; + bool ret; + tree new_target; + tree existing_target = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); + + /* Save the current target options to restore at the end. */ + cl_target_option_save (&cur_target, &global_options, &global_options_set); + + /* If fndecl already has some target attributes applied to it, unpack + them so that we add this attribute on top of them, rather than + overwriting them. */ + if (existing_target) + { + struct cl_target_option *existing_options + = TREE_TARGET_OPTION (existing_target); + + if (existing_options) + cl_target_option_restore (&global_options, &global_options_set, + existing_options); + } + else + cl_target_option_restore (&global_options, &global_options_set, + TREE_TARGET_OPTION (target_option_current_node)); + + ret = aarch64_process_target_version_attr (args); + + /* Set up any additional state. */ + if (ret) + { + aarch64_override_options_internal (&global_options); + new_target = build_target_option_node (&global_options, + &global_options_set); + } + else + new_target = NULL; + + if (fndecl && ret) + { + DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_target; + } + + cl_target_option_restore (&global_options, &global_options_set, &cur_target); + + return ret; +} + +/* This parses the attribute arguments to target_version in DECL and the + feature mask required to select those targets. No adjustments are made to + add or remove redundant feature requirements. */ + +static aarch64_fmv_feature_mask +get_feature_mask_for_version (tree decl) +{ + tree version_attr = lookup_attribute ("target_version", + DECL_ATTRIBUTES (decl)); + if (version_attr == NULL) + return 0; + + const char *version_string = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE + (version_attr))); + enum aarch_parse_opt_result parse_res; + aarch64_fmv_feature_mask feature_mask; + + parse_res = aarch64_parse_fmv_features (version_string, NULL, &feature_mask, + NULL); + + /* We should have detected any errors before getting here. */ + gcc_assert (parse_res == AARCH_PARSE_OK); + + return feature_mask; +} + +/* Compare priorities of two feature masks. Return: + 1: mask1 is higher priority + -1: mask2 is higher priority + 0: masks are equal. */ + +static int +compare_feature_masks (aarch64_fmv_feature_mask mask1, + aarch64_fmv_feature_mask mask2) +{ + int pop1 = popcount_hwi (mask1); + int pop2 = popcount_hwi (mask2); + if (pop1 > pop2) + return 1; + if (pop2 > pop1) + return -1; + + auto diff_mask = mask1 ^ mask2; + if (diff_mask == 0ULL) + return 0; + for (int i = FEAT_MAX - 1; i > 0; i--) + { + auto bit_mask = aarch64_fmv_feature_data[i].feature_mask; + if (diff_mask & bit_mask) + return (mask1 & bit_mask) ? 1 : -1; + } + gcc_unreachable(); +} + +/* Compare priorities of two version decls. */ + +int +aarch64_compare_version_priority (tree decl1, tree decl2) +{ + auto mask1 = get_feature_mask_for_version (decl1); + auto mask2 = get_feature_mask_for_version (decl2); + + return compare_feature_masks (mask1, mask2); +} + +/* Build the struct __ifunc_arg_t type: + + struct __ifunc_arg_t + { + unsigned long _size; // Size of the struct, so it can grow. + unsigned long _hwcap; + unsigned long _hwcap2; + } + */ + +static tree +build_ifunc_arg_type () +{ + tree ifunc_arg_type = lang_hooks.types.make_type (RECORD_TYPE); + tree field1 = build_decl (UNKNOWN_LOCATION, FIELD_DECL, + get_identifier ("_size"), + long_unsigned_type_node); + tree field2 = build_decl (UNKNOWN_LOCATION, FIELD_DECL, + get_identifier ("_hwcap"), + long_unsigned_type_node); + tree field3 = build_decl (UNKNOWN_LOCATION, FIELD_DECL, + get_identifier ("_hwcap2"), + long_unsigned_type_node); + + DECL_FIELD_CONTEXT (field1) = ifunc_arg_type; + DECL_FIELD_CONTEXT (field2) = ifunc_arg_type; + DECL_FIELD_CONTEXT (field3) = ifunc_arg_type; + + TYPE_FIELDS (ifunc_arg_type) = field1; + DECL_CHAIN (field1) = field2; + DECL_CHAIN (field2) = field3; + + layout_type (ifunc_arg_type); + + tree const_type = build_qualified_type (ifunc_arg_type, TYPE_QUAL_CONST); + tree pointer_type = build_pointer_type (const_type); + + return pointer_type; +} + +/* Make the resolver function decl to dispatch the versions of + a multi-versioned function, DEFAULT_DECL. IFUNC_ALIAS_DECL is + ifunc alias that will point to the created resolver. Create an + empty basic block in the resolver and store the pointer in + EMPTY_BB. Return the decl of the resolver function. */ + +static tree +make_resolver_func (const tree default_decl, + const tree ifunc_alias_decl, + basic_block *empty_bb) +{ + tree decl, type, t; + + /* Create resolver function name based on default_decl. */ + tree decl_name = clone_function_name (default_decl, "resolver"); + const char *resolver_name = IDENTIFIER_POINTER (decl_name); + + /* The resolver function should have signature + (void *) resolver (uint64_t, const __ifunc_arg_t *) */ + type = build_function_type_list (ptr_type_node, + uint64_type_node, + build_ifunc_arg_type (), + NULL_TREE); + + decl = build_fn_decl (resolver_name, type); + SET_DECL_ASSEMBLER_NAME (decl, decl_name); + + DECL_NAME (decl) = decl_name; + TREE_USED (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + DECL_IGNORED_P (decl) = 1; + TREE_PUBLIC (decl) = 0; + DECL_UNINLINABLE (decl) = 1; + + /* Resolver is not external, body is generated. */ + DECL_EXTERNAL (decl) = 0; + DECL_EXTERNAL (ifunc_alias_decl) = 0; + + DECL_CONTEXT (decl) = NULL_TREE; + DECL_INITIAL (decl) = make_node (BLOCK); + DECL_STATIC_CONSTRUCTOR (decl) = 0; + + if (DECL_COMDAT_GROUP (default_decl) + || TREE_PUBLIC (default_decl)) + { + /* In this case, each translation unit with a call to this + versioned function will put out a resolver. Ensure it + is comdat to keep just one copy. */ + DECL_COMDAT (decl) = 1; + make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); + } + else + TREE_PUBLIC (ifunc_alias_decl) = 0; + + /* Build result decl and add to function_decl. */ + t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node); + DECL_CONTEXT (t) = decl; + DECL_ARTIFICIAL (t) = 1; + DECL_IGNORED_P (t) = 1; + DECL_RESULT (decl) = t; + + /* Build parameter decls and add to function_decl. */ + tree arg1 = build_decl (UNKNOWN_LOCATION, PARM_DECL, + get_identifier ("hwcap"), + uint64_type_node); + tree arg2 = build_decl (UNKNOWN_LOCATION, PARM_DECL, + get_identifier ("arg"), + build_ifunc_arg_type()); + DECL_CONTEXT (arg1) = decl; + DECL_CONTEXT (arg2) = decl; + DECL_ARTIFICIAL (arg1) = 1; + DECL_ARTIFICIAL (arg2) = 1; + DECL_IGNORED_P (arg1) = 1; + DECL_IGNORED_P (arg2) = 1; + DECL_ARG_TYPE (arg1) = uint64_type_node; + DECL_ARG_TYPE (arg2) = build_ifunc_arg_type (); + DECL_ARGUMENTS (decl) = arg1; + TREE_CHAIN (arg1) = arg2; + + gimplify_function_tree (decl); + push_cfun (DECL_STRUCT_FUNCTION (decl)); + *empty_bb = init_lowered_empty_function (decl, false, + profile_count::uninitialized ()); + + cgraph_node::add_new_function (decl, true); + symtab->call_cgraph_insertion_hooks (cgraph_node::get_create (decl)); + + pop_cfun (); + + gcc_assert (ifunc_alias_decl != NULL); + /* Mark ifunc_alias_decl as "ifunc" with resolver as resolver_name. */ + DECL_ATTRIBUTES (ifunc_alias_decl) + = make_attribute ("ifunc", resolver_name, + DECL_ATTRIBUTES (ifunc_alias_decl)); + + /* Create the alias for dispatch to resolver here. */ + cgraph_node::create_same_body_alias (ifunc_alias_decl, decl); + return decl; +} + +/* This adds a condition to the basic_block NEW_BB in function FUNCTION_DECL + to return a pointer to VERSION_DECL if all feature bits specified in + FEATURE_MASK are not set in MASK_VAR. This function will be called during + version dispatch to decide which function version to execute. It returns + the basic block at the end, to which more conditions can be added. */ +static basic_block +add_condition_to_bb (tree function_decl, tree version_decl, + aarch64_fmv_feature_mask feature_mask, + tree mask_var, basic_block new_bb) +{ + gimple *return_stmt; + tree convert_expr, result_var; + gimple *convert_stmt; + gimple *if_else_stmt; + + basic_block bb1, bb2, bb3; + edge e12, e23; + + gimple_seq gseq; + + push_cfun (DECL_STRUCT_FUNCTION (function_decl)); + + gcc_assert (new_bb != NULL); + gseq = bb_seq (new_bb); + + convert_expr = build1 (CONVERT_EXPR, ptr_type_node, + build_fold_addr_expr (version_decl)); + result_var = create_tmp_var (ptr_type_node); + convert_stmt = gimple_build_assign (result_var, convert_expr); + return_stmt = gimple_build_return (result_var); + + if (feature_mask == 0ULL) + { + /* Default version. */ + gimple_seq_add_stmt (&gseq, convert_stmt); + gimple_seq_add_stmt (&gseq, return_stmt); + set_bb_seq (new_bb, gseq); + gimple_set_bb (convert_stmt, new_bb); + gimple_set_bb (return_stmt, new_bb); + pop_cfun (); + return new_bb; + } + + tree and_expr_var = create_tmp_var (long_long_unsigned_type_node); + tree and_expr = build2 (BIT_AND_EXPR, + long_long_unsigned_type_node, + mask_var, + build_int_cst (long_long_unsigned_type_node, + feature_mask)); + gimple *and_stmt = gimple_build_assign (and_expr_var, and_expr); + gimple_set_block (and_stmt, DECL_INITIAL (function_decl)); + gimple_set_bb (and_stmt, new_bb); + gimple_seq_add_stmt (&gseq, and_stmt); + + tree zero_llu = build_int_cst (long_long_unsigned_type_node, 0); + if_else_stmt = gimple_build_cond (EQ_EXPR, and_expr_var, zero_llu, + NULL_TREE, NULL_TREE); + gimple_set_block (if_else_stmt, DECL_INITIAL (function_decl)); + gimple_set_bb (if_else_stmt, new_bb); + gimple_seq_add_stmt (&gseq, if_else_stmt); + + gimple_seq_add_stmt (&gseq, convert_stmt); + gimple_seq_add_stmt (&gseq, return_stmt); + set_bb_seq (new_bb, gseq); + + bb1 = new_bb; + e12 = split_block (bb1, if_else_stmt); + bb2 = e12->dest; + e12->flags &= ~EDGE_FALLTHRU; + e12->flags |= EDGE_TRUE_VALUE; + + e23 = split_block (bb2, return_stmt); + + gimple_set_bb (convert_stmt, bb2); + gimple_set_bb (return_stmt, bb2); + + bb3 = e23->dest; + make_edge (bb1, bb3, EDGE_FALSE_VALUE); + + remove_edge (e23); + make_edge (bb2, EXIT_BLOCK_PTR_FOR_FN (cfun), 0); + + pop_cfun (); + + return bb3; +} + +/* This function generates the dispatch function for + multi-versioned functions. DISPATCH_DECL is the function which will + contain the dispatch logic. FNDECLS are the function choices for + dispatch, and is a tree chain. EMPTY_BB is the basic block pointer + in DISPATCH_DECL in which the dispatch code is generated. */ + +static int +dispatch_function_versions (tree dispatch_decl, + void *fndecls_p, + basic_block *empty_bb) +{ + gimple *ifunc_cpu_init_stmt; + gimple_seq gseq; + vec *fndecls; + + gcc_assert (dispatch_decl != NULL + && fndecls_p != NULL + && empty_bb != NULL); + + push_cfun (DECL_STRUCT_FUNCTION (dispatch_decl)); + + gseq = bb_seq (*empty_bb); + /* Function version dispatch is via IFUNC. IFUNC resolvers fire before + constructors, so explicity call __init_cpu_features_resolver here. */ + tree init_fn_type = build_function_type_list (void_type_node, + long_unsigned_type_node, + build_ifunc_arg_type(), + NULL); + tree init_fn_id = get_identifier ("__init_cpu_features_resolver"); + tree init_fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, + init_fn_id, init_fn_type); + tree arg1 = DECL_ARGUMENTS (dispatch_decl); + tree arg2 = TREE_CHAIN (arg1); + ifunc_cpu_init_stmt = gimple_build_call (init_fn_decl, 2, arg1, arg2); + gimple_seq_add_stmt (&gseq, ifunc_cpu_init_stmt); + gimple_set_bb (ifunc_cpu_init_stmt, *empty_bb); + + /* Build the struct type for __aarch64_cpu_features. */ + tree global_type = lang_hooks.types.make_type (RECORD_TYPE); + tree field1 = build_decl (UNKNOWN_LOCATION, FIELD_DECL, + get_identifier ("features"), + long_long_unsigned_type_node); + DECL_FIELD_CONTEXT (field1) = global_type; + TYPE_FIELDS (global_type) = field1; + layout_type (global_type); + + tree global_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, + get_identifier ("__aarch64_cpu_features"), + global_type); + DECL_EXTERNAL (global_var) = 1; + tree mask_var = create_tmp_var (long_long_unsigned_type_node); + + tree component_expr = build3 (COMPONENT_REF, long_long_unsigned_type_node, + global_var, field1, NULL_TREE); + gimple *component_stmt = gimple_build_assign (mask_var, component_expr); + gimple_set_block (component_stmt, DECL_INITIAL (dispatch_decl)); + gimple_set_bb (component_stmt, *empty_bb); + gimple_seq_add_stmt (&gseq, component_stmt); + + tree not_expr = build1 (BIT_NOT_EXPR, long_long_unsigned_type_node, mask_var); + gimple *not_stmt = gimple_build_assign (mask_var, not_expr); + gimple_set_block (not_stmt, DECL_INITIAL (dispatch_decl)); + gimple_set_bb (not_stmt, *empty_bb); + gimple_seq_add_stmt (&gseq, not_stmt); + + set_bb_seq (*empty_bb, gseq); + + pop_cfun (); + + /* fndecls_p is actually a vector. */ + fndecls = static_cast *> (fndecls_p); + + /* At least one more version other than the default. */ + unsigned int num_versions = fndecls->length (); + gcc_assert (num_versions >= 2); + + struct function_version_info + { + tree version_decl; + aarch64_fmv_feature_mask feature_mask; + } *function_versions; + + function_versions = (struct function_version_info *) + XNEWVEC (struct function_version_info, (num_versions)); + + unsigned int actual_versions = 0; + + for (tree version_decl : *fndecls) + { + aarch64_fmv_feature_mask feature_mask; + /* Get attribute string, parse it and find the right features. */ + feature_mask = get_feature_mask_for_version (version_decl); + function_versions [actual_versions].version_decl = version_decl; + function_versions [actual_versions].feature_mask = feature_mask; + actual_versions++; + } + + auto compare_feature_version_info = [](const void *p1, const void *p2) { + const function_version_info v1 = *(const function_version_info *)p1; + const function_version_info v2 = *(const function_version_info *)p2; + return - compare_feature_masks (v1.feature_mask, v2.feature_mask); + }; + + /* Sort the versions according to descending order of dispatch priority. */ + qsort (function_versions, actual_versions, + sizeof (struct function_version_info), compare_feature_version_info); + + for (unsigned int i = 0; i < actual_versions; ++i) + *empty_bb = add_condition_to_bb (dispatch_decl, + function_versions[i].version_decl, + function_versions[i].feature_mask, + mask_var, + *empty_bb); + + free (function_versions); + return 0; +} + +/* Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY. */ + +tree +aarch64_generate_version_dispatcher_body (void *node_p) +{ + tree resolver_decl; + basic_block empty_bb; + tree default_ver_decl; + struct cgraph_node *versn; + struct cgraph_node *node; + + struct cgraph_function_version_info *node_version_info = NULL; + struct cgraph_function_version_info *versn_info = NULL; + + node = (cgraph_node *)node_p; + + node_version_info = node->function_version (); + gcc_assert (node->dispatcher_function + && node_version_info != NULL); + + if (node_version_info->dispatcher_resolver) + return node_version_info->dispatcher_resolver; + + /* The first version in the chain corresponds to the default version. */ + default_ver_decl = node_version_info->next->this_node->decl; + + /* node is going to be an alias, so remove the finalized bit. */ + node->definition = false; + + resolver_decl = make_resolver_func (default_ver_decl, + node->decl, &empty_bb); + + node_version_info->dispatcher_resolver = resolver_decl; + + push_cfun (DECL_STRUCT_FUNCTION (resolver_decl)); + + auto_vec fn_ver_vec; + + for (versn_info = node_version_info->next; versn_info; + versn_info = versn_info->next) + { + versn = versn_info->this_node; + /* Check for virtual functions here again, as by this time it should + have been determined if this function needs a vtable index or + not. This happens for methods in derived classes that override + virtual methods in base classes but are not explicitly marked as + virtual. */ + if (DECL_VINDEX (versn->decl)) + sorry ("virtual function multiversioning not supported"); + + fn_ver_vec.safe_push (versn->decl); + } + + dispatch_function_versions (resolver_decl, &fn_ver_vec, &empty_bb); + cgraph_edge::rebuild_edges (); + pop_cfun (); + return resolver_decl; +} + +/* Make a dispatcher declaration for the multi-versioned function DECL. + Calls to DECL function will be replaced with calls to the dispatcher + by the front-end. Returns the decl of the dispatcher function. */ + +tree +aarch64_get_function_versions_dispatcher (void *decl) +{ + tree fn = (tree) decl; + struct cgraph_node *node = NULL; + struct cgraph_node *default_node = NULL; + struct cgraph_function_version_info *node_v = NULL; + struct cgraph_function_version_info *first_v = NULL; + + tree dispatch_decl = NULL; + + struct cgraph_function_version_info *default_version_info = NULL; + + gcc_assert (fn != NULL && DECL_FUNCTION_VERSIONED (fn)); + + node = cgraph_node::get (fn); + gcc_assert (node != NULL); + + node_v = node->function_version (); + gcc_assert (node_v != NULL); + + if (node_v->dispatcher_resolver != NULL) + return node_v->dispatcher_resolver; + + /* Find the default version and make it the first node. */ + first_v = node_v; + /* Go to the beginning of the chain. */ + while (first_v->prev != NULL) + first_v = first_v->prev; + default_version_info = first_v; + while (default_version_info != NULL) + { + if (get_feature_mask_for_version + (default_version_info->this_node->decl) == 0ULL) + break; + default_version_info = default_version_info->next; + } + + /* If there is no default node, just return NULL. */ + if (default_version_info == NULL) + return NULL; + + /* Make default info the first node. */ + if (first_v != default_version_info) + { + default_version_info->prev->next = default_version_info->next; + if (default_version_info->next) + default_version_info->next->prev = default_version_info->prev; + first_v->prev = default_version_info; + default_version_info->next = first_v; + default_version_info->prev = NULL; + } + + default_node = default_version_info->this_node; + + if (targetm.has_ifunc_p ()) + { + struct cgraph_function_version_info *it_v = NULL; + struct cgraph_node *dispatcher_node = NULL; + struct cgraph_function_version_info *dispatcher_version_info = NULL; + + /* Right now, the dispatching is done via ifunc. */ + dispatch_decl = make_dispatcher_decl (default_node->decl); + TREE_NOTHROW (dispatch_decl) = TREE_NOTHROW (fn); + + dispatcher_node = cgraph_node::get_create (dispatch_decl); + gcc_assert (dispatcher_node != NULL); + dispatcher_node->dispatcher_function = 1; + dispatcher_version_info + = dispatcher_node->insert_new_function_version (); + dispatcher_version_info->next = default_version_info; + dispatcher_node->definition = 1; + + /* Set the dispatcher for all the versions. */ + it_v = default_version_info; + while (it_v != NULL) + { + it_v->dispatcher_resolver = dispatch_decl; + it_v = it_v->next; + } + } + else + { + error_at (DECL_SOURCE_LOCATION (default_node->decl), + "multiversioning needs % which is not supported " + "on this target"); + } + + return dispatch_decl; +} + +/* This function returns true if FN1 and FN2 are versions of the same function, + that is, the target_version attributes of the function decls are different. + This assumes that FN1 and FN2 have the same signature. */ + +bool +aarch64_common_function_versions (tree fn1, tree fn2) +{ + if (TREE_CODE (fn1) != FUNCTION_DECL + || TREE_CODE (fn2) != FUNCTION_DECL) + return false; + + return (aarch64_compare_version_priority (fn1, fn2) != 0); +} + +/* Implement TARGET_MANGLE_DECL_ASSEMBLER_NAME, to add function multiversioning + suffixes. */ + +tree +aarch64_mangle_decl_assembler_name (tree decl, tree id) +{ + /* For function version, add the target suffix to the assembler name. */ + if (TREE_CODE (decl) == FUNCTION_DECL + && DECL_FUNCTION_VERSIONED (decl)) + { + aarch64_fmv_feature_mask feature_mask = get_feature_mask_for_version (decl); + + /* No suffix for the default version. */ + if (feature_mask == 0ULL) + return id; + + std::string name = IDENTIFIER_POINTER (id); + name += "._"; + + for (int i = 0; i < FEAT_MAX; i++) + { + if (feature_mask & aarch64_fmv_feature_data[i].feature_mask) + { + name += "M"; + name += aarch64_fmv_feature_data[i].name; + } + } + + if (DECL_ASSEMBLER_NAME_SET_P (decl)) + SET_DECL_RTL (decl, NULL); + + id = get_identifier (name.c_str()); + } + return id; +} + /* Helper for aarch64_can_inline_p. In the case where CALLER and CALLEE are tri-bool options (yes, no, don't care) and the default value is DEF, determine whether to reject inlining. */ @@ -26095,6 +26936,10 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_OPTION_VALID_ATTRIBUTE_P #define TARGET_OPTION_VALID_ATTRIBUTE_P aarch64_option_valid_attribute_p +#undef TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P +#define TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P \ + aarch64_option_valid_version_attribute_p + #undef TARGET_SET_CURRENT_FUNCTION #define TARGET_SET_CURRENT_FUNCTION aarch64_set_current_function @@ -26425,6 +27270,24 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_CONST_ANCHOR #define TARGET_CONST_ANCHOR 0x1000000 +#undef TARGET_OPTION_FUNCTION_VERSIONS +#define TARGET_OPTION_FUNCTION_VERSIONS aarch64_common_function_versions + +#undef TARGET_COMPARE_VERSION_PRIORITY +#define TARGET_COMPARE_VERSION_PRIORITY aarch64_compare_version_priority + +#undef TARGET_GENERATE_VERSION_DISPATCHER_BODY +#define TARGET_GENERATE_VERSION_DISPATCHER_BODY \ + aarch64_generate_version_dispatcher_body + +#undef TARGET_GET_FUNCTION_VERSIONS_DISPATCHER +#define TARGET_GET_FUNCTION_VERSIONS_DISPATCHER \ + aarch64_get_function_versions_dispatcher + +#undef TARGET_MANGLE_DECL_ASSEMBLER_NAME +#define TARGET_MANGLE_DECL_ASSEMBLER_NAME aarch64_mangle_decl_assembler_name + + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-aarch64.h" diff --git a/gcc/config/arm/aarch-common.h b/gcc/config/arm/aarch-common.h index c6a67f0d05cc75d85d019e1cc910c37173884c03..70f01fd3da6919dd98cfe92bfc4c54b7d2cba72c 100644 --- a/gcc/config/arm/aarch-common.h +++ b/gcc/config/arm/aarch-common.h @@ -23,7 +23,7 @@ #define GCC_AARCH_COMMON_H /* Enum describing the various ways that the - aarch*_parse_{arch,tune,cpu,extension} functions can fail. + aarch*_parse_{arch,tune,cpu,extension,fmv_extension} functions can fail. This way their callers can choose what kind of error to give. */ enum aarch_parse_opt_result @@ -31,7 +31,8 @@ enum aarch_parse_opt_result AARCH_PARSE_OK, /* Parsing was successful. */ AARCH_PARSE_MISSING_ARG, /* Missing argument. */ AARCH_PARSE_INVALID_FEATURE, /* Invalid feature modifier. */ - AARCH_PARSE_INVALID_ARG /* Invalid arch, tune, cpu arg. */ + AARCH_PARSE_INVALID_ARG, /* Invalid arch, tune, cpu arg. */ + AARCH_PARSE_DUPLICATE_FEATURE /* Duplicate feature modifier. */ }; /* Function types -msign-return-address should sign. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_0.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_0.c index fb5a7a18ad1a2d09ac4b231150a1bd9e72d6fab6..c175e22f88fd5165d42866eb989de8af3ee5f6c6 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_0.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_0.c @@ -7,6 +7,6 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+dotprod\+crypto\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\n} } } */ /* Test a normal looking procinfo. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_13.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_13.c index b29d50e1f79f92e45add1627904a695c511aec75..0264a4737103ce093741d4f0b161f78cd18a0d6a 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_13.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_13.c @@ -7,6 +7,6 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+dotprod\+crypto\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\n} } } */ /* Test one with mixed order of feature bits. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_16.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_16.c index b3613165a05bf2fd1e93e6d89361ae9969ed62ba..649e48e7e0b727cef573ff12f1e3efb90bbb5e7f 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_16.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_16.c @@ -7,6 +7,6 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+dotprod\+crypto\+sve2\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} } } */ /* Test a normal looking procinfo. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_17.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_17.c index a9dde5ffab1405488d15d58c6420890a1b16e16a..078d7bc899ccd01c70369fe985268949c351da0b 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_17.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_17.c @@ -7,6 +7,6 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+dotprod\+crypto\+sve2\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} } } */ /* Test a normal looking procinfo. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c index 10325df4497227a80297a140c9e1d689fccf96ef..57eedb463091f051c19533c054204f9352b6446e 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8.6-a\+crc\+fp16\+aes\+sha3\+rng\+nopauth\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8.6-a\+rng\+crc\+aes\+sha3\+fp16\+nopauth\n} } } */ /* Test one where the boundary of buffer size would overwrite the last character read when stitching the fgets-calls together. With the diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_19.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_19.c index 980d3f79dfb03b0d8eb68f691bf2dedf80aed87d..a5b4b4d3442c6522a8cdadf4eebd3b5460e37213 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_19.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_19.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv9-a\+crc\+profile\+memtag\+sve2-sm4\+sve2-aes\+sve2-sha3\+sve2-bitperm\+i8mm\+bf16\+nopauth\n} } } */ +/* { dg-final { scan-assembler {\.arch armv9-a\+crc\+i8mm\+bf16\+sve2-aes\+sve2-bitperm\+sve2-sha3\+sve2-sm4\+memtag\+profile\+nopauth\n} } } */ /* Test one that if the kernel doesn't report the availability of a mandatory feature that it has turned it off for whatever reason. As such compilers diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_20.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_20.c index 117df2b0b6cd5751d9f5175b4343aad9825a6c43..e12aa543d02924f268729f96fe1f17181287f097 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_20.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_20.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv9-a\+crc\+profile\+memtag\+sve2-sm4\+sve2-aes\+sve2-sha3\+sve2-bitperm\+i8mm\+bf16\n} } } */ +/* { dg-final { scan-assembler {\.arch armv9-a\+crc\+i8mm\+bf16\+sve2-aes\+sve2-bitperm\+sve2-sha3\+sve2-sm4\+memtag\+profile\n} } } */ /* Check whether features that don't have a midr name during detection are correctly ignored. These features shouldn't affect the native detection. diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_21.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_21.c index efbd02cbdc0638db85e776f1e79043709c11df21..920e1d65711cbcb77b07441597180c0159ccabf9 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_21.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_21.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+lse\+rcpc\+rdma\+dotprod\+fp16fml\+sb\+ssbs\+sve2-sm4\+sve2-aes\+sve2-sha3\+sve2-bitperm\+i8mm\+bf16\+flagm\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+flagm\+dotprod\+rdma\+lse\+crc\+fp16fml\+rcpc\+i8mm\+bf16\+sve2-aes\+sve2-bitperm\+sve2-sha3\+sve2-sm4\+sb\+ssbs\n} } } */ /* Check that an Armv8-A core doesn't fall apart on extensions without midr values. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_22.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_22.c index d431d4938265d024891b464ac3d069607b21d8e7..416a29b514ab7599a7092e26e3716ec8a50cc895 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_22.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_22.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+crc\+lse\+rcpc\+rdma\+dotprod\+fp16fml\+sb\+ssbs\+sve2-sm4\+sve2-aes\+sve2-sha3\+sve2-bitperm\+i8mm\+bf16\+flagm\+pauth\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+flagm\+dotprod\+rdma\+lse\+crc\+fp16fml\+rcpc\+i8mm\+bf16\+sve2-aes\+sve2-bitperm\+sve2-sha3\+sve2-sm4\+sb\+ssbs\+pauth\n} } } */ /* Check that an Armv8-A core doesn't fall apart on extensions without midr values and that it enables optional features. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_6.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_6.c index 20012beff7b85c14817e38437650d412ab7bb137..5d39a2d8c4da5de6ed7ec832db90ae7f625d997d 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_6.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_6.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+fp16\+crypto\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+crypto\+fp16\n} } } */ -/* Test one where the feature bits for crypto and fp16 are given in - same order as declared in options file. */ +/* Test one where the crypto and fp16 options are specified in different + order from what is in the options file. */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_7.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_7.c index 70a7e62fdffc4a908df083505c03a5fde70ce883..67c4bc2b9ea446201666c9810c779d1823a5cb9b 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_7.c +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_7.c @@ -7,7 +7,7 @@ int main() return 0; } -/* { dg-final { scan-assembler {\.arch armv8-a\+fp16\+crypto\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8-a\+crypto\+fp16\n} } } */ -/* Test one where the crypto and fp16 options are specified in different - order from what is in the options file. */ +/* Test one where the feature bits for crypto and fp16 are given in + same order as declared in options file. */ diff --git a/gcc/testsuite/gcc.target/aarch64/options_set_17.c b/gcc/testsuite/gcc.target/aarch64/options_set_17.c index 8b21e2e1a0a0d4c7daa13fc6c3e4968786474a74..b1603fbcf2a1b27c00fe2b47a8a65af551a3d726 100644 --- a/gcc/testsuite/gcc.target/aarch64/options_set_17.c +++ b/gcc/testsuite/gcc.target/aarch64/options_set_17.c @@ -6,6 +6,6 @@ int main () return 0; } -/* { dg-final { scan-assembler {\.arch armv8\.2-a\+crc\+dotprod\n} } } */ +/* { dg-final { scan-assembler {\.arch armv8\.2-a\+dotprod\+crc\n} } } */ /* dotprod needs to be emitted pre armv8.4. */ diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c index 634f591c194bc70048f714d7eb0ace1f2f4137ea..72185bee7cdd062e20a3e9f6f627f4120d1b2fb5 100644 --- a/libgcc/config/aarch64/cpuinfo.c +++ b/libgcc/config/aarch64/cpuinfo.c @@ -22,6 +22,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ +#include "common/config/aarch64/cpuinfo.h" + #if __has_include() #include @@ -38,73 +40,6 @@ typedef struct __ifunc_arg_t { #if __has_include() #include -/* CPUFeatures must correspond to the same AArch64 features in aarch64.cc */ -enum CPUFeatures { - FEAT_RNG, - FEAT_FLAGM, - FEAT_FLAGM2, - FEAT_FP16FML, - FEAT_DOTPROD, - FEAT_SM4, - FEAT_RDM, - FEAT_LSE, - FEAT_FP, - FEAT_SIMD, - FEAT_CRC, - FEAT_SHA1, - FEAT_SHA2, - FEAT_SHA3, - FEAT_AES, - FEAT_PMULL, - FEAT_FP16, - FEAT_DIT, - FEAT_DPB, - FEAT_DPB2, - FEAT_JSCVT, - FEAT_FCMA, - FEAT_RCPC, - FEAT_RCPC2, - FEAT_FRINTTS, - FEAT_DGH, - FEAT_I8MM, - FEAT_BF16, - FEAT_EBF16, - FEAT_RPRES, - FEAT_SVE, - FEAT_SVE_BF16, - FEAT_SVE_EBF16, - FEAT_SVE_I8MM, - FEAT_SVE_F32MM, - FEAT_SVE_F64MM, - FEAT_SVE2, - FEAT_SVE_AES, - FEAT_SVE_PMULL128, - FEAT_SVE_BITPERM, - FEAT_SVE_SHA3, - FEAT_SVE_SM4, - FEAT_SME, - FEAT_MEMTAG, - FEAT_MEMTAG2, - FEAT_MEMTAG3, - FEAT_SB, - FEAT_PREDRES, - FEAT_SSBS, - FEAT_SSBS2, - FEAT_BTI, - FEAT_LS64, - FEAT_LS64_V, - FEAT_LS64_ACCDATA, - FEAT_WFXT, - FEAT_SME_F64, - FEAT_SME_I64, - FEAT_SME2, - FEAT_RCPC3, - FEAT_MAX, - FEAT_EXT = 62, /* Reserved to indicate presence of additional features field - in __aarch64_cpu_features. */ - FEAT_INIT /* Used as flag of features initialization completion. */ -}; - /* Architecture features used in Function Multi Versioning. */ struct { unsigned long long features;