From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2058.outbound.protection.outlook.com [40.107.15.58]) by sourceware.org (Postfix) with ESMTPS id 912223858D35 for ; Fri, 17 Nov 2023 02:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 912223858D35 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 912223858D35 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.58 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1700189731; cv=pass; b=hass8QOblsYy3KJrr2tjSsdIweZYrAG8AfFhIwpbOnuy0toS9P3DEwa1XLwPUW26Fcx0KT9qAOpvc7bPakGcfByn0JL1LcnERcYKXBkK8hyBr8/t2B1hF8rP3nYoZJjK2mnqmnvajcn36Umw6zpX19T17ATZUn9Ur3PX+rhsYtI= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1700189731; c=relaxed/simple; bh=8bcrrhK8qYkQ2tO1Rb8gwmteTuLCchMgW5NkpjqQhtc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=abpG6f0SNrkOt+J7iZs1F+5XsX/qfgfEzk9e1p++HDD23005sDWqwX653slK9JxHYTnPuexH3ShflKzBxmbud3Tw65EPUFGs79YDbxNwZPqOQEcFWDIgEDyNiXLI2FHt/5d64/Voj6JQvBwH0yZeIsWy6P8yPyS6RB/0xL17Ehg= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=lvEK1NYvJtqiuybYwubkcWWNuYHgovfPE9ktVL1so5amtlgWf/oY2ri2Rqshe/s+7Xe+vQgLd2sHzlsWwZgCulSaZ65xJgPiU1b/5wTWHFba17vOP7bv+JCvEUl74W0ZQEmQh9ZQrvvN+/PvTSxSQvZJibY7ncVHCEI9bFrTf3q6oLpfKlgi1+kQDIyWAYGhTXEgOldADi2Pnt3buV8PaVrQe/OnHx+E2FQbEhuK3c0Op1AbFGiKJ3tjED1lfLV8deNLqXiPhwIuu7GVco/aLYiXNAcR4Q9XFE00XNd3/GbYiAjPRJVBygpFaIRDu2jVf67W/dWD6k1d8InAZYYiYg== 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=5fB87p7g30Nar8kmcOAFLyR2Bn0+/KgYCgRoGs9ceaY=; b=K+512azainrQ2IREd61t9baA590I+UROoIkOh4uMuvmk/u9az7CxGy/L9a35pW6EtfOVnJisP5YXL2XPax5+0iVwyy+WAsimw46aBEwNi415oNqOxszEBv17carFyY3PrGqbeDoHTLECcphJwnktvFVNJpXqjjdht4sLaQo09H3F85/+ZJDq6VI1Fq3tE8KJkCxp3Oz+WNMWZF9xg2q715NnbY6IMNWvM8RSZ1l3YGDCcoJJEsrakJzjyRFAgwDwqBQLMRCdiZBTfzqCDltSy2/+ZRFvBpatxqBlf5r+1tGuDy8bDoQqy0LGrTlFQvfHLhO29SKEZRuUtGShd3a5kA== 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=5fB87p7g30Nar8kmcOAFLyR2Bn0+/KgYCgRoGs9ceaY=; b=H7rSxDBWXf7rg5gGrY8ZnqSUeU7H3ExJezGoWu6lnsHsc2qt3KU5u6dxgZ0+9s/LX9/jfYZwDlC+e6toRHg+8suc4jo2EwVbOxPoJK3PjYOHZMu4KqlbMh21wDNmxRXYIDRE7F+45FwOJW3HHxB4UYC8lhqUbZbEckEajGB+qBI= Received: from DU2P250CA0007.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:231::12) by GV1PR08MB8306.eurprd08.prod.outlook.com (2603:10a6:150:a3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.21; Fri, 17 Nov 2023 02:55:19 +0000 Received: from DB5PEPF00014B9D.eurprd02.prod.outlook.com (2603:10a6:10:231:cafe::78) by DU2P250CA0007.outlook.office365.com (2603:10a6:10:231::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.23 via Frontend Transport; Fri, 17 Nov 2023 02:55:19 +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 DB5PEPF00014B9D.mail.protection.outlook.com (10.167.8.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.20 via Frontend Transport; Fri, 17 Nov 2023 02:55:19 +0000 Received: ("Tessian outbound e243565b0037:v228"); Fri, 17 Nov 2023 02:55:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5b43df8affc501dc X-CR-MTA-TID: 64aa7808 Received: from b659487f8eff.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 21189AC8-51A7-4C87-BFB7-678C6A9AADA7.1; Fri, 17 Nov 2023 02:55:09 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b659487f8eff.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 17 Nov 2023 02:55:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GC4fOogNXhvD1g3b0u09GWEIkMaOeEimyA1UTfF9dACPc+GrMfuLcOorK9ivYgyY9b3sP0hVZeX8J+uIuBHkoiQ+9TST4ebwGlQV5Klh/kQstEzkcE3wliSPPEy1WFk2bI/oW8XdZ71FcjfP3k1DaVy3dXVafFYxAx2cMRqCjC2RU2XY17CC28QZLK5NOvCTvMxm3X9OqvpPjx1xKbJUpmkNF43Xn/ftkPj4WIu52N/jS9AJM+byap/kwoktZAiXRqdmCqOVIazbh66+0qEosvxX5P8BQgpNHi/66PansETzrev5OFIB2EDxi9AlRzL7Lra+UghkdBSEC9B1C5Af2w== 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=5fB87p7g30Nar8kmcOAFLyR2Bn0+/KgYCgRoGs9ceaY=; b=OVlk8apeFdcLGdb/iW5+1v9cw/OFXj7cjGgtul+FUokKdAzXAC42iGhC6tZW9j2s+ZZKxdAG/Tl4d91nKhVFjYW124/LySL9KxXJtSIsW0l/5SRWykxIXoVUIBxQX/kO2v0Ix6FylbolTy5p+qLyy5e7xg7IoDSzdGq3tboxXRvlao33SWmPFFK8urjWQafCSVAiY/HZf8iLbAqCddow3L6iHBqxbt2qyw47rpOO0nC+cH6tjVJ2Nn1ymkhcplULeStKwHGoqizh0/RIqOSj5txq+EuqCJUSVKuD+tJ4i99SrDthw+xwgdeBUDEqa5gZrYYASprbbBj0WjOcKGjvIw== 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=5fB87p7g30Nar8kmcOAFLyR2Bn0+/KgYCgRoGs9ceaY=; b=H7rSxDBWXf7rg5gGrY8ZnqSUeU7H3ExJezGoWu6lnsHsc2qt3KU5u6dxgZ0+9s/LX9/jfYZwDlC+e6toRHg+8suc4jo2EwVbOxPoJK3PjYOHZMu4KqlbMh21wDNmxRXYIDRE7F+45FwOJW3HHxB4UYC8lhqUbZbEckEajGB+qBI= 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 AS4PR08MB7904.eurprd08.prod.outlook.com (2603:10a6:20b:51f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.18; Fri, 17 Nov 2023 02:55:04 +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.7002.022; Fri, 17 Nov 2023 02:55:04 +0000 Date: Fri, 17 Nov 2023 02:55:02 +0000 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Cc: ebotcazou@libertysurf.fr, poulhies@adacore.com, ibuclaw@gdcproject.org, jason@redhat.com, nathan@acm.org, rguenther@suse.de, richard.sandiford@arm.com, richard.earnshaw@arm.com Subject: [PATCH v2 4/5] Add support for target_version attribute Message-ID: <372e1dfb-af4f-e92b-09aa-952b7b52f195@e124511.cambridge.arm.com> References: <88dc78af-82a3-9a9f-4b8e-461c41d296cc@e124511.cambridge.arm.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <88dc78af-82a3-9a9f-4b8e-461c41d296cc@e124511.cambridge.arm.com> X-ClientProxiedBy: LO4P123CA0342.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18c::23) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS4PR08MB7904:EE_|DB5PEPF00014B9D:EE_|GV1PR08MB8306:EE_ X-MS-Office365-Filtering-Correlation-Id: d72d2085-f63d-4064-8165-08dbe718a24e 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: XD0HD3hi/5LaeJxJpsZnl2Ka+UXWZ0OY5yyziV42cA37Y9Vi0tizr0cfYQ5OggABcq0RDRcnedP+862GuRXKhI3iUCC/XvouLdcCt8kmzBnzeLQSqFwUekgskniK7HlVnFGLqwlTAoWNoP4i9tO2mUt6VRcK+OxekJxip1g+T6cOSIPVIKCOCAu63NcAIEBJiW16rDfTBAJJ85M97HS5MnZ0GFmKiCOW8s9UVAIHvMn+P7veTTt4vYvxwc+neIK3iwNTIRjvUixToj4FHL1f21Mc2e28fXYtkt3wj/Qj+XFGfJH9AADEb+9KLJmSF5K/7HUmoMUJl9qlOvOXWpFXA9fQGap+oRI9r5T16Vv9v/LnSfAt2nY7muKc6w+UZXzdWUCAFtHW56mhQBScffSm/+gVtT6OOhRT+MLAzWyYv3MlQ8woWRJvmYcYqH5tsQexGP/BoJpC5NJw5Kp+yN0B+gqhVziOnYfNgTZ6K2qhfxJ+dNLE5DjS3Oly4QyYHmdCoaPDaXWy66yC4ojHjvdeFsESfX664ribNVF1odEemwh9cbZmd5JH4xdxMyxYDTONTD7vE9UDCMpXYPNldv78wq1gVeGMwyYYo3skj/ygP2fRmUh6l7EuUPA4WCSIlSThVOsDwq8Z/dG5oHCdannO5Y/m/uxlnszFCwghVVLfjPg= 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)(346002)(396003)(366004)(376002)(39860400002)(230273577357003)(230922051799003)(230173577357003)(451199024)(1800799009)(64100799003)(186009)(38100700002)(6506007)(83380400001)(31686004)(6512007)(30864003)(44832011)(41300700001)(5660300002)(2906002)(316002)(8936002)(31696002)(4326008)(8676002)(66556008)(86362001)(6916009)(66476007)(6486002)(66946007)(478600001)(26005)(41080700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7904 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: DB5PEPF00014B9D.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9dbb7c3f-7ef7-49c7-d078-08dbe71899a9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uqlFxHnpQfWKnMpGSmCIdPoPbMSxUhAi6ZufLZ+owwKc/B6JLo5qTKJnZOpa+RZac+Ud129URfprdlG8K7K+8FSS8YaIhLloy1EsQWYPfKOYVed70ky9Ukwvu6fz+gRrff9oq+pHWZmtKN+/6ox/AclCChor2j/Y0rDmFZvWM11rr96Q1hu8+vN46Qtax6gaIYnojPrvqEU5wnJUOgYkLLPJlmzfvYdxu2//yxVoRF1HE1SdHuTTKVSDo+WMlbb45cgp0z7EokNHV7zUPUYV+LpMzaWfpyamcx+6GjdQ21Zc3ygKqf+GcPvE3+8+pSuX6Z3dnsoR9Zg6JYorCKrsVJvbuoOtcr9DNiyo6eVPi7SwnRbTy6FgeFqjqoEWdNl66TV5F3yLyUdPpUMGPaeTZfdvNzCna++UrMNdTepUFUU5Uody6ypQO/G0UVvAaFDT8TWulzf8ppv2eNwN3RDSApHIHa1MXH3tCdkkS9XwOysCJ/t6fxAjTPiNAH3qU2xjP1E7In5JdDT0vIHvN2SkmD1xyPdyalkc/yIs7RSlOfJTNefpTWE8Br+JUgFyqsOl6DcTKfYqOVUjiVhl2sxBLNR3qgB/8W/8P4UYFWUM5zS/N86sxWI63TzyOvd+xh1Sndjq48qqWzfaZ0lHYsxGD0QmhJutozRYkAa9tPa2zYFGPFu2LuPg/haf/wZf2QMtmVQhhjNL3uZl3rLNUqSkmG4nwXK1jOELK+/90bn+4OTVt/Umc+ls8VSKCK5zMWoqjF9dpqJwPNv0V8pxDqd4PA== 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)(136003)(39860400002)(346002)(376002)(230273577357003)(230173577357003)(230922051799003)(451199024)(82310400011)(186009)(64100799003)(1800799009)(46966006)(40470700004)(36840700001)(31686004)(40480700001)(40460700003)(36860700001)(81166007)(70586007)(70206006)(6916009)(356005)(6506007)(86362001)(82740400003)(31696002)(83380400001)(26005)(336012)(6512007)(2906002)(30864003)(316002)(6486002)(8676002)(8936002)(44832011)(5660300002)(47076005)(41300700001)(4326008)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2023 02:55:19.1186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d72d2085-f63d-4064-8165-08dbe718a24e 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: DB5PEPF00014B9D.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8306 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 List-Id: This patch adds support for the "target_version" attribute to the middle end and the C++ frontend, which will be used to implement function multiversioning in the aarch64 backend. On targets that don't use the "target" attribute for multiversioning, there is no conflict between the "target" and "target_clones" attributes. This patch therefore makes the mutual exclusion in C-family, D and Ada conditonal upon the value of the expanded_clones_attribute target hook. The "target_version" attribute is only added to C++ in this patch, because this is currently the only frontend which supports multiversioning using the "target" attribute. Support for the "target_version" attribute will be extended to C at a later date. Targets that currently use the "target" attribute for function multiversioning (i.e. i386 and rs6000) are not affected by this patch. Ok for master? gcc/ChangeLog: * attribs.cc (decl_attributes): Pass attribute name to target. (is_function_default_version): Update comment to specify incompatibility with target_version attributes. * cgraphclones.cc (cgraph_node::create_version_clone_with_body): Call valid_version_attribute_p for target_version attributes. * target.def (valid_version_attribute_p): New hook. (expanded_clones_attribute): New hook. * doc/tm.texi.in: Add new hooks. * doc/tm.texi: Regenerate. * multiple_target.cc (create_dispatcher_calls): Remove redundant is_function_default_version check. (expand_target_clones): Use target hook for attribute name. * targhooks.cc (default_target_option_valid_version_attribute_p): New. * targhooks.h (default_target_option_valid_version_attribute_p): New. * tree.h (DECL_FUNCTION_VERSIONED): Update comment to include target_version attributes. gcc/c-family/ChangeLog: * c-attribs.cc (CLONES_USES_TARGET): New macro. (attr_target_exclusions): Use new macro. (attr_target_clones_exclusions): Ditto, and add target_version. (attr_target_version_exclusions): New. (c_common_attribute_table): Add target_version. (handle_target_version_attribute): New. gcc/ada/ChangeLog: * gcc-interface/utils.cc (CLONES_USES_TARGET): New macro. (attr_target_exclusions): Use new macro. (attr_target_clones_exclusions): Ditto. gcc/d/ChangeLog: * d-attribs.cc (CLONES_USES_TARGET): New macro. (attr_target_exclusions): Use new macro. (attr_target_clones_exclusions): Ditto. gcc/cp/ChangeLog: * decl2.cc (check_classfn): Update comment to include target_version attributes. diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index e33a63948cebdeafc3abcdd539a35141969ad978..8850943cb3326568b4679a73405f50487aa1b7c6 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -143,16 +143,21 @@ static const struct attribute_spec::exclusions attr_noinline_exclusions[] = { NULL, false, false, false }, }; +#define CLONES_USES_TARGET \ + (strcmp (targetm.target_option.expanded_clones_attribute, \ + "target") == 0) + static const struct attribute_spec::exclusions attr_target_exclusions[] = { - { "target_clones", true, true, true }, + { "target_clones", CLONES_USES_TARGET, CLONES_USES_TARGET, + CLONES_USES_TARGET }, { NULL, false, false, false }, }; static const struct attribute_spec::exclusions attr_target_clones_exclusions[] = { { "always_inline", true, true, true }, - { "target", true, true, true }, + { "target", CLONES_USES_TARGET, CLONES_USES_TARGET, CLONES_USES_TARGET }, { NULL, false, false, false }, }; diff --git a/gcc/attribs.cc b/gcc/attribs.cc index f9fd258598914ce2112ecaaeaad6c63cd69a44e2..27533023ef5c481ba085c2f0c605dfb992987b3e 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -657,7 +657,8 @@ decl_attributes (tree *node, tree attributes, int flags, options to the attribute((target(...))) list. */ if (TREE_CODE (*node) == FUNCTION_DECL && current_target_pragma - && targetm.target_option.valid_attribute_p (*node, NULL_TREE, + && targetm.target_option.valid_attribute_p (*node, + get_identifier("target"), current_target_pragma, 0)) { tree cur_attr = lookup_attribute ("target", attributes); @@ -1241,8 +1242,9 @@ make_dispatcher_decl (const tree decl) return func_decl; } -/* Returns true if decl is multi-versioned and DECL is the default function, - that is it is not tagged with target specific optimization. */ +/* Returns true if DECL is multi-versioned using the target attribute, and this + is the default version. This function can only be used for targets that do + not support the "target_version" attribute. */ bool is_function_default_version (const tree decl) diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index b3b41ef123a0f171f57acb1b7f7fdde716428c00..8e33b7c3f4a9e7dcaa299eeff0eea92240f7ef0a 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -149,6 +149,7 @@ static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *); static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool *); static tree handle_assume_attribute (tree *, tree, tree, int, bool *); static tree handle_target_attribute (tree *, tree, tree, int, bool *); +static tree handle_target_version_attribute (tree *, tree, tree, int, bool *); static tree handle_target_clones_attribute (tree *, tree, tree, int, bool *); static tree handle_optimize_attribute (tree *, tree, tree, int, bool *); static tree ignore_attribute (tree *, tree, tree, int, bool *); @@ -228,16 +229,29 @@ static const struct attribute_spec::exclusions attr_noinline_exclusions[] = ATTR_EXCL (NULL, false, false, false), }; +#define CLONES_USES_TARGET \ + (strcmp (targetm.target_option.expanded_clones_attribute, \ + "target") == 0) + static const struct attribute_spec::exclusions attr_target_exclusions[] = { - ATTR_EXCL ("target_clones", true, true, true), + ATTR_EXCL ("target_clones", CLONES_USES_TARGET, CLONES_USES_TARGET, + CLONES_USES_TARGET), 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 ("target", CLONES_USES_TARGET, CLONES_USES_TARGET, + CLONES_USES_TARGET), + ATTR_EXCL ("target_version", true, true, true), + ATTR_EXCL (NULL, false, false, false), +}; + +static const struct attribute_spec::exclusions attr_target_version_exclusions[] = +{ + ATTR_EXCL ("target_clones", true, true, true), ATTR_EXCL (NULL, false, false, false), }; @@ -505,6 +519,9 @@ const struct attribute_spec c_common_attribute_table[] = { "target", 1, -1, true, false, false, false, handle_target_attribute, attr_target_exclusions }, + { "target_version", 1, 1, true, false, false, false, + handle_target_version_attribute, + attr_target_version_exclusions }, { "target_clones", 1, -1, true, false, false, false, handle_target_clones_attribute, attr_target_clones_exclusions }, @@ -5670,6 +5687,25 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, return NULL_TREE; } +/* Handle a "target_version" attribute. */ + +static tree +handle_target_version_attribute (tree *node, tree name, tree args, int flags, + bool *no_add_attrs) +{ + /* Ensure we have a function type. */ + if (TREE_CODE (*node) != FUNCTION_DECL) + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + else if (!targetm.target_option.valid_version_attribute_p (*node, name, args, + flags)) + *no_add_attrs = true; + + return NULL_TREE; +} + /* Handle a "target_clones" attribute. */ static tree diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc index 29d28ef895a73a223695cbb86aafbc845bbe7688..8af6b23d8c0306920e0fdcb3559ef047a16689f4 100644 --- a/gcc/cgraphclones.cc +++ b/gcc/cgraphclones.cc @@ -78,6 +78,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-eh.h" #include "tree-cfg.h" #include "tree-inline.h" +#include "attribs.h" #include "dumpfile.h" #include "gimple-pretty-print.h" #include "alloc-pool.h" @@ -1048,7 +1049,17 @@ cgraph_node::create_version_clone_with_body location_t saved_loc = input_location; tree v = TREE_VALUE (target_attributes); input_location = DECL_SOURCE_LOCATION (new_decl); - bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 1); + bool r; + tree name_id = get_attribute_name (target_attributes); + const char* name_str = IDENTIFIER_POINTER (name_id); + if (strcmp (name_str, "target") == 0) + r = targetm.target_option.valid_attribute_p (new_decl, name_id, v, 1); + else if (strcmp (name_str, "target_version") == 0) + r = targetm.target_option.valid_version_attribute_p (new_decl, name_id, + v, 1); + else + gcc_assert(false); + input_location = saved_loc; if (!r) return NULL; diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 9e666e5eecee07ae7c742c3a2b27e85899945c4e..e607aa14d284d545d122e04b0eae1247fd301882 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -832,8 +832,8 @@ check_classfn (tree ctype, tree function, tree template_parms) tree c2 = get_constraints (fndecl); /* While finding a match, same types and params are not enough - if the function is versioned. Also check version ("target") - attributes. */ + if the function is versioned. Also check for different target + specific attributes. */ if (same_type_p (TREE_TYPE (TREE_TYPE (function)), TREE_TYPE (TREE_TYPE (fndecl))) && compparms (p1, p2) diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc index c0dc0e24ded871c136e54e5527e901d16cfa5ceb..7fe68565e70dd1124aac63601416dad68600a34e 100644 --- a/gcc/d/d-attribs.cc +++ b/gcc/d/d-attribs.cc @@ -126,16 +126,22 @@ static const struct attribute_spec::exclusions attr_noinline_exclusions[] = ATTR_EXCL (NULL, false, false, false), }; +#define CLONES_USES_TARGET \ + (strcmp (targetm.target_option.expanded_clones_attribute, \ + "target") == 0) + static const struct attribute_spec::exclusions attr_target_exclusions[] = { - ATTR_EXCL ("target_clones", true, true, true), + ATTR_EXCL ("target_clones", CLONES_USES_TARGET, CLONES_USES_TARGET, + CLONES_USES_TARGET), 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 ("target", CLONES_USES_TARGET, CLONES_USES_TARGET, + CLONES_USES_TARGET), ATTR_EXCL (NULL, false, false, false), }; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index d83ca73b1aff90d3c181436afedc162b977a4158..6f6b133803f4574fcf0112b1385eec861112ddd5 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -10644,6 +10644,23 @@ the function declaration to hold a pointer to a target-specific @code{struct cl_target_option} structure. @end deftypefn +@deftypefn {Target Hook} bool TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P (tree @var{fndecl}, tree @var{name}, tree @var{args}, int @var{flags}) +This hook is called to parse @code{attribute(target_version("..."))}, +which allows setting target-specific options on individual function versions. +These function-specific options may differ +from the options specified on the command line. The hook should return +@code{true} if the options are valid. + +The hook should set the @code{DECL_FUNCTION_SPECIFIC_TARGET} field in +the function declaration to hold a pointer to a target-specific +@code{struct cl_target_option} structure. +@end deftypefn + +@deftypevr {Target Hook} {const char *} TARGET_OPTION_EXPANDED_CLONES_ATTRIBUTE +Contains the name of the attribute used for the version description string +when expanding clones for a function with the target_clones attribute. +@end deftypevr + @deftypefn {Target Hook} void TARGET_OPTION_SAVE (struct cl_target_option *@var{ptr}, struct gcc_options *@var{opts}, struct gcc_options *@var{opts_set}) This hook is called to save any additional target-specific information in the @code{struct cl_target_option} structure for function-specific diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 3d3ae12cc2ff62025b1138430de501a33961fd90..149c88f627be20a9a35ead2eaebdb704e51927fa 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7028,6 +7028,10 @@ on this implementation detail. @hook TARGET_OPTION_VALID_ATTRIBUTE_P +@hook TARGET_OPTION_VALID_VERSION_ATTRIBUTE_P + +@hook TARGET_OPTION_EXPANDED_CLONES_ATTRIBUTE + @hook TARGET_OPTION_SAVE @hook TARGET_OPTION_RESTORE diff --git a/gcc/multiple_target.cc b/gcc/multiple_target.cc index a2ed048d7dd28ec470953fcd8a0dc86817e4b7dc..3db57c2b13d612a37240d9dcf58ad21b2286633c 100644 --- a/gcc/multiple_target.cc +++ b/gcc/multiple_target.cc @@ -66,10 +66,6 @@ create_dispatcher_calls (struct cgraph_node *node) { ipa_ref *ref; - if (!DECL_FUNCTION_VERSIONED (node->decl) - || !is_function_default_version (node->decl)) - return; - if (!targetm.has_ifunc_p ()) { error_at (DECL_SOURCE_LOCATION (node->decl), @@ -377,6 +373,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) return false; } + const char *new_attr_name = targetm.target_option.expanded_clones_attribute; cgraph_function_version_info *decl1_v = NULL; cgraph_function_version_info *decl2_v = NULL; cgraph_function_version_info *before = NULL; @@ -392,7 +389,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) char *attr = attrs[i]; /* Create new target clone. */ - tree attributes = make_attribute ("target", attr, + tree attributes = make_attribute (new_attr_name, attr, DECL_ATTRIBUTES (node->decl)); char *suffix = XNEWVEC (char, strlen (attr) + 1); @@ -430,7 +427,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) XDELETEVEC (attr_str); /* Setting new attribute to initial function. */ - tree attributes = make_attribute ("target", "default", + tree attributes = make_attribute (new_attr_name, "default", DECL_ATTRIBUTES (node->decl)); DECL_ATTRIBUTES (node->decl) = attributes; node->local = false; diff --git a/gcc/target.def b/gcc/target.def index 0996da0f71a85f8217a41ceb08de8b21087e4ed9..1d2e0d8bf03a8b949ec636e6a78a111308d3dd71 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -6533,6 +6533,31 @@ the function declaration to hold a pointer to a target-specific\n\ bool, (tree fndecl, tree name, tree args, int flags), default_target_option_valid_attribute_p) +/* Function to validate the attribute((target_version(...))) strings. If + the option is validated, the hook should also fill in + DECL_FUNCTION_SPECIFIC_TARGET in the function decl node. */ +DEFHOOK +(valid_version_attribute_p, + "This hook is called to parse @code{attribute(target_version(\"...\"))},\n\ +which allows setting target-specific options on individual function versions.\n\ +These function-specific options may differ\n\ +from the options specified on the command line. The hook should return\n\ +@code{true} if the options are valid.\n\ +\n\ +The hook should set the @code{DECL_FUNCTION_SPECIFIC_TARGET} field in\n\ +the function declaration to hold a pointer to a target-specific\n\ +@code{struct cl_target_option} structure.", + bool, (tree fndecl, tree name, tree args, int flags), + default_target_option_valid_version_attribute_p) + +/* Attribute to be used when expanding clones for functions with + target_clones attribute. */ +DEFHOOKPOD +(expanded_clones_attribute, + "Contains the name of the attribute used for the version description string\n\ +when expanding clones for a function with the target_clones attribute.", + const char *, "target") + /* Function to save any extra target state in the target options structure. */ DEFHOOK (save, diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 189549cb1c742c37c17623141989b492a7c2b2f8..ff2957fd9fd8389e23992281b35e8e5467072f7d 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -192,6 +192,7 @@ extern bool default_hard_regno_scratch_ok (unsigned int); extern bool default_mode_dependent_address_p (const_rtx, addr_space_t); extern bool default_new_address_profitable_p (rtx, rtx_insn *, rtx); extern bool default_target_option_valid_attribute_p (tree, tree, tree, int); +extern bool default_target_option_valid_version_attribute_p (tree, tree, tree, int); extern bool default_target_option_pragma_parse (tree, tree); extern bool default_target_can_inline_p (tree, tree); extern bool default_update_ipa_fn_target_info (unsigned int &, const gimple *); diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc index 4f5b240f8d65eeeaf73418c9f1e2c2684b257cfa..b693352d7eae555912477b6e431dd9c016105007 100644 --- a/gcc/targhooks.cc +++ b/gcc/targhooks.cc @@ -1789,7 +1789,19 @@ default_target_option_valid_attribute_p (tree ARG_UNUSED (fndecl), int ARG_UNUSED (flags)) { warning (OPT_Wattributes, - "target attribute is not supported on this machine"); + "% attribute is not supported on this machine"); + + return false; +} + +bool +default_target_option_valid_version_attribute_p (tree ARG_UNUSED (fndecl), + tree ARG_UNUSED (name), + tree ARG_UNUSED (args), + int ARG_UNUSED (flags)) +{ + warning (OPT_Wattributes, + "% attribute is not supported on this machine"); return false; } diff --git a/gcc/tree.h b/gcc/tree.h index 086b55f0375435d53a1604b6659da4f19fce3d17..d7841af19b20b0dc0ae28b433d5150e9c4763eff 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3500,8 +3500,8 @@ extern vec **decl_debug_args_insert (tree); (FUNCTION_DECL_CHECK (NODE)->function_decl.function_specific_optimization) /* In FUNCTION_DECL, this is set if this function has other versions generated - using "target" attributes. The default version is the one which does not - have any "target" attribute set. */ + to support different architecture feature sets, e.g. using "target" or + "target_version" attributes. */ #define DECL_FUNCTION_VERSIONED(NODE)\ (FUNCTION_DECL_CHECK (NODE)->function_decl.versioned_function)