From patchwork Sat Dec 23 22:02:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1882534dyi; Sat, 23 Dec 2023 14:05:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGi2eYzjWzJkctfBLZY+iV0F7vx0aCAZrFDxA4jA+kI3gY0feVvw6p4SZV0FK7O7+iRPrux X-Received: by 2002:ae9:f406:0:b0:781:2b78:32b9 with SMTP id y6-20020ae9f406000000b007812b7832b9mr4132838qkl.3.1703369159773; Sat, 23 Dec 2023 14:05:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369159; cv=pass; d=google.com; s=arc-20160816; b=oXC+xMnLfIHy8jvqHavCyRbfmEYoI0jbpvrtK4z0veji24eHCLg+V/ScvaHAQQXwXJ RVq+5g9qKzFMKSK8IOpPz5Zcb4yBqzI1VBfUi2xk0IGNrwuvzLnC3nS1/gafURLcHJy8 k6xjq0eF2WHECuTjs5ozx02XyZi/O1THLTqxK2kHr1nwID/LMA5qVs6fNFvsg3gWoW1n P6MT7z5Jh1OjZkroVIj32RFKiTenQ57ypa1VNJEChLOqg3DSzCZ812S8rQ4wu+1bLWY8 rAFkLCCYy5UY0L+7zN/Qehsic4KDdGDD+hvCXI9uV1gkzGG3n/bPafb7ZXIOOa6BQycN 8ihQ== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=FgrWC00zA8XCQ2DF3sPgRnGEAXf3EPQeq7sVTOnQe3Q=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=tlZEe/wFOVQdzU/PSjpEtzb3Vlg6wCGcKMXYSv9jJO8WtvQyVLf06FXVlBRmeMh+jo sjsn3lwK+ST87OlBi8snfiMjWiMSNSRRGScNyWXU1FwQKJ8ssKE7wn4o+HDeUT7z9l6i xpyEktDXQ2Kz1AMmXxWcWfEobaSLugDwN8N0IW52Q9iBib8F18w376eHpKMLtlOqUbBH QgAWYyL1jmcQm4rOwnISaOV05SvCMkguK2+uVWwdy/PjeaGxN/GRHLVAia2SNo+rimMj O6cwc+nHLjX8Wp+cF/nQhNynJ/v2iJ6qPka3pXeExU7i55TJci2j/n/Nk8R+jqEhqgxh geSQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QSAdM9SV; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c2-20020a05620a268200b0077d5e2457e6si7550786qkp.476.2023.12.23.14.05.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:05:59 -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=@gcc.gnu.org header.s=default header.b=QSAdM9SV; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 712D238654A1 for ; Sat, 23 Dec 2023 22:05:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 712D238654A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369159; bh=FgrWC00zA8XCQ2DF3sPgRnGEAXf3EPQeq7sVTOnQe3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QSAdM9SVx3RUVwkTYU3vzkBsPEUSFtRgbEPMowxSHgXJhDukOjt055lcQhupiBtnE ssPfdg2ieIO76hfrrRt1WSKMN5My2MOigjw7band65fXohZzd9JKgeMYq3SaWIUKrq HOAFviX1e9ckwEPIvowkQPuBuvTlN415RFO1h2XM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 4E90B3857BA1; Sat, 23 Dec 2023 22:05:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E90B3857BA1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E90B3857BA1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369119; cv=none; b=OC64evM4nAI0KPhBaEHGyPzJtbJo2q0CKspOG/5WEAJskb1fe9hv6MwePuSLJZW4+sA7wUDkzCkHkCydwUzKdCtMoC8FFtIqRsavtrwaf4/ighYsMhwh2NSoq+ZhtwfXrTvveBxN2f/0Euf1BDy80SGxx78zgY9ri3yNpy2Lmz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369119; c=relaxed/simple; bh=yivmxIbpHTtS+Del6PGLLQBNsQ5yCmq5zgRmLq2GKOY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ro6Vo2xzOjTuWXQEwbPnDIEzL+ka7Z1Plje8zSpwanYM4zobIyzdwBkEw46vzvySFOOq9ay64nCTxd9UFtw5oMLxH9cNcVdEf8/1LzMdXF9wvi5nOnaClFagHJFDVrTPPrYTkGAlc+MvuCiFNR4EVV0ZmVoa/24QbDkxN0c4/80= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247480.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNLx9Rt017696; Sat, 23 Dec 2023 22:05:18 GMT Received: from mxout24.cac.washington.edu (mxout24.cac.washington.edu [140.142.234.158]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5rnuk4hd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:05:17 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout24.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM5A3j028196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:05:11 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y24011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:05:10 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 1/8] c++: Implement __is_const built-in trait Date: Sat, 23 Dec 2023 14:02:42 -0800 Message-ID: <20231223220432.712093-2-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: 9wxExMLFntHGM527bGQtqva6gDNMs48i X-Proofpoint-ORIG-GUID: 9wxExMLFntHGM527bGQtqva6gDNMs48i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1034 impostorscore=0 mlxlogscore=605 priorityscore=1501 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112020272549532 X-GMAIL-MSGID: 1786112020272549532 This patch implements built-in trait for std::is_const. gcc/cp/ChangeLog: * cp-trait.def: Define __is_const. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_CONST. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_const. * g++.dg/ext/is_const.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 +++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 +++ gcc/testsuite/g++.dg/ext/is_const.C | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_const.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index eeacead52a5..f1b07aa2853 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3734,6 +3734,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_CLASS: inform (loc, " %qT is not a class", t1); break; + case CPTK_IS_CONST: + inform (loc, " %qT is not a const type", t1); + break; case CPTK_IS_CONSTRUCTIBLE: if (!t2) inform (loc, " %qT is not default constructible", t1); diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 394f006f20f..36faed9c0b3 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -64,6 +64,7 @@ DEFTRAIT_EXPR (IS_ASSIGNABLE, "__is_assignable", 2) DEFTRAIT_EXPR (IS_BASE_OF, "__is_base_of", 2) DEFTRAIT_EXPR (IS_BOUNDED_ARRAY, "__is_bounded_array", 1) DEFTRAIT_EXPR (IS_CLASS, "__is_class", 1) +DEFTRAIT_EXPR (IS_CONST, "__is_const", 1) DEFTRAIT_EXPR (IS_CONSTRUCTIBLE, "__is_constructible", -1) DEFTRAIT_EXPR (IS_CONVERTIBLE, "__is_convertible", 2) DEFTRAIT_EXPR (IS_EMPTY, "__is_empty", 1) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index e6dba29ee81..364d87ee34d 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12415,6 +12415,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CLASS: return NON_UNION_CLASS_TYPE_P (type1); + case CPTK_IS_CONST: + return CP_TYPE_CONST_P (type1); + case CPTK_IS_CONSTRUCTIBLE: return is_xible (INIT_EXPR, type1, type2); @@ -12657,6 +12660,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_ARRAY: case CPTK_IS_BOUNDED_ARRAY: case CPTK_IS_CLASS: + case CPTK_IS_CONST: case CPTK_IS_ENUM: case CPTK_IS_FUNCTION: case CPTK_IS_MEMBER_FUNCTION_POINTER: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index 02b4b4d745d..e3640faeb96 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -71,6 +71,9 @@ #if !__has_builtin (__is_class) # error "__has_builtin (__is_class) failed" #endif +#if !__has_builtin (__is_const) +# error "__has_builtin (__is_const) failed" +#endif #if !__has_builtin (__is_constructible) # error "__has_builtin (__is_constructible) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_const.C b/gcc/testsuite/g++.dg/ext/is_const.C new file mode 100644 index 00000000000..8a0e8df72a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_const.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +class ClassType { }; +using cClassType = const ClassType; +using vClassType = volatile ClassType; +using cvClassType = const volatile ClassType; + +// Positive tests. +SA(__is_const(const int)); +SA(__is_const(const volatile int)); +SA(__is_const(cClassType)); +SA(__is_const(cvClassType)); + +// Negative tests. +SA(!__is_const(int)); +SA(!__is_const(volatile int)); +SA(!__is_const(ClassType)); +SA(!__is_const(vClassType)); From patchwork Sat Dec 23 22:02:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1882728dyi; Sat, 23 Dec 2023 14:06:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDZ18Yj+SjgoYLbcbSYy55JFsBHN/tZpuromXudWAEquHCMDM+swv6wcbXVatm2HsNtHKO X-Received: by 2002:a05:6214:628:b0:67f:71a8:8889 with SMTP id a8-20020a056214062800b0067f71a88889mr4181098qvx.127.1703369198485; Sat, 23 Dec 2023 14:06:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369198; cv=pass; d=google.com; s=arc-20160816; b=I5gOf+xZToqDLqKXITulN296HcQHN7qkZgeqkfkRJJSHY01VhfKWpTgW+wRCBwY6sT swoJpv6R5ALZbIBEV5Mq4mA7gXbeR6XwRTh8TEoFyeYqr1ksgCjieaZBrXb9K2czSavS 6VT+YpOu1rZNi5GDD4qXO4FxkmoXXfmlyIv/Wma49PvQf3v2KkKVwYM6kj37lVnsFCcs wKQ8qmWnqoXfpp01nGHFvz0IdpJ4mpVLrcixguw9mqD62C7ZRj1X8u3SipoUcYnaWIEy 5pl0r2ECQcfKBsRLoEAI/B/ACutze7+iZbDW4N1/M/40xOpJqiEyEUbobbgg+ZhEwhY/ HBsQ== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=vThgwY2ku4ueloZCcQTK/u0jgM9lNPDhlWQFxm/BYSE=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=xP6rgEmg3Ki/cBeausUeNq1xKff6mqe5k9AsF6ERQKxaIgNNETjwh2WJB5CCNX83WV hUplDsifM3kjuBlzJ+Zb2mNs4E/IIRXaDrUzfM//FxqtO4z3sXS6kjTQpwPW8vh/dG80 8UV4fUogqBBCd63cXY3eAKVce8S5tcYrEBoPn1DCzzeBPFfRMxhS3ZWrgAcljvMddDnX XjCgXImvMXZmZMEf0YqiCmMU9+A+xFUOvsRjEcsacgzzPojlQEJ+QariLeU8tR04HsTQ PktAev4O74kIe4WLR/IXK3VT4v1XqpJAXvmW9Cc5TWZ9xlziZLGA0sByNMwTJmGGHuxD fTGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OoTtPO6Z; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id os18-20020a05620a811200b007811f9c4c4fsi6014569qkn.632.2023.12.23.14.06.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:06:38 -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=@gcc.gnu.org header.s=default header.b=OoTtPO6Z; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E5DE3864878 for ; Sat, 23 Dec 2023 22:06:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E5DE3864878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369198; bh=vThgwY2ku4ueloZCcQTK/u0jgM9lNPDhlWQFxm/BYSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OoTtPO6Z6+UeY6pOEUQGiSKF/jepTE0/E2NdIH1ciqYN3JylY9oddpiP0TOSF38BN BvVM9LpO+ZWJ1I4SB4avp02SHkBjsJ87Y80GTAaESQBieY0Lj6txTDpHg6n1pkuWVD fEM3YXd7ugKXyb2WV0qeG3okkw8Z6I+zPV7SE1+M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 56D573858C60; Sat, 23 Dec 2023 22:05:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56D573858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 56D573858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369154; cv=none; b=xr6k4zIxpqx0CgwJdaaOfXmIveW2dc7CI+gYALnmmOaQOOzb9VhU4k02k0ujmTmtjr/loHjuv1q+ozCdvih9iSCKeb+pADULU4NNaeOrhEKoo56jRTmstS5RwMZeDV46hCCGCn2gmBZtwiXSjd6gljLcmwbn7hl7I3Cj0e1zQEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369154; c=relaxed/simple; bh=ini9IOHj5y3BJCxYZN2sAhU9sw4ACWMfW9RNyr0rIGY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=CAxLaynw+jIs3+xbfixqFokMSZ9YDX808vRd0+aBToZDZdZC1mUo8xEmzGZ7xcOCvWM8NJMLf8dRZt5ZDyFa8CIS9jMmZEzdmII4YgsfVF3fZYsryut5C0nZvgAApQX2OGiP2jp9qK1zl5tEhjnocNH/NBcd8WzQozAkqkJPWnY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247476.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM5MmM021084; Sat, 23 Dec 2023 22:05:53 GMT Received: from mxout21.s.uw.edu (mxout21.s.uw.edu [140.142.32.139]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5r01k6vg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:05:52 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout21.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM5Xfx019615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:05:33 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y25011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:05:33 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 2/8] libstdc++: Optimize std::is_const compilation performance Date: Sat, 23 Dec 2023 14:02:43 -0800 Message-ID: <20231223220432.712093-3-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: ZvOrfqHn4gYlne0JrWDE6kXQjQN58Op7 X-Proofpoint-ORIG-GUID: ZvOrfqHn4gYlne0JrWDE6kXQjQN58Op7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=765 adultscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 clxscore=1034 lowpriorityscore=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112060520651610 X-GMAIL-MSGID: 1786112060520651610 This patch optimizes the compilation performance of std::is_const by dispatching to the new __is_const built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_const): Use __is_const built-in trait. (is_const_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f00c07f94f9..f40831de838 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -835,6 +835,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Type properties. /// is_const +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) + template + struct is_const + : public __bool_constant<__is_const(_Tp)> + { }; +#else template struct is_const : public false_type { }; @@ -842,6 +848,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_const<_Tp const> : public true_type { }; +#endif /// is_volatile template @@ -3315,10 +3322,15 @@ template inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_const) +template + inline constexpr bool is_const_v = __is_const(_Tp); +#else template inline constexpr bool is_const_v = false; template inline constexpr bool is_const_v = true; +#endif #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_function) template From patchwork Sat Dec 23 22:02:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1882958dyi; Sat, 23 Dec 2023 14:07:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNZcBhZHftLbFoCSJY8YqyBJ7gZiQNSuatO8iuVWfPhv6ZEBG5QSI6sGMWpTh+gyxhN8ZU X-Received: by 2002:a05:620a:2b47:b0:77b:bfc4:4e13 with SMTP id dp7-20020a05620a2b4700b0077bbfc44e13mr6002514qkb.18.1703369255329; Sat, 23 Dec 2023 14:07:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369255; cv=pass; d=google.com; s=arc-20160816; b=jRyDKlEAFQJnBCD1YwoLEi5r6nTK43nEe0eV4jEBAgE3U3rgGhntsE85XQkZHdYNnC /UfRkmK4jfHvyHB8Ik9OjahO6dz3Wyk9imartfHyKzA7nLFSD6w8GepghsP8UyLDemni qJEla4PgJleV9Nuhe0y5PFgXTeHBtRusFkxIyNn5KY2bvvJYwT/+RAvWswMje944uQzM ExwADIe0QA4ROhLp/xnj8lok9U2HJ4R70SRw6CQpU1mokEm9rcSZ7ZGmtZpkhbxH8qpv BxNUUWdpohXL2dDJnbsqiVv7dYonOhoqu1Y3ejQGSjM/QTdSz3G7/Qd9wO7G7AmRbw/1 MVzQ== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=oZLxNz14om/IdVP2lf5jVh/udtoAUWl/Ejwqy5LsNXw=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=L4E9Qqaet3hIuupkVuoXnca4ugqGbEn+qdP7hADp4jvT5Z3D9/Tf9Qcamn7r+vmP4P 98lKFr+f9CuwbEyfylnOX1yjgh/eTAwLAxzRInJJCNSorditbfqNWX6JDDVRX63LU30h 5I1t8UUzsV7QP9d5yngrJNillBNXrbiFMPOnb3ujQtFcfET0bGOUFo7U2I+S0p7ZLnev uAwSJVKv5t9XinkFHddH3PRhWojYVP/y2jYUoAC6bb5+qeFYsZ73E/P0lUsTDOEBsOvh Ei4x1vWuyE6msFspUhrlZ26ZAYFMQDwosjIX13GIKN2enIez5n74qHUNTdazTzFY+kPm isNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kXX9Yvh4; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j11-20020a05620a288b00b0077da5cf5797si7817830qkp.303.2023.12.23.14.07.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:07:35 -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=@gcc.gnu.org header.s=default header.b=kXX9Yvh4; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05A493847725 for ; Sat, 23 Dec 2023 22:07:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05A493847725 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369255; bh=oZLxNz14om/IdVP2lf5jVh/udtoAUWl/Ejwqy5LsNXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kXX9Yvh4t+1tVmYp8+ivYtppzBUkbS1uRVJj4PU12DVkUjD7Nk23Tr8t/BU1dJWOD zhzhKsKXzKHeF2MvGhor2thueAIvY2EMptWmSnNmHa0BvmcDw1I/r4e62Cs0pzCsOJ ECJk79Mk1JQ67eibhuxBYn+VGZzElrplfrw8wT7Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 6694A3858C60; Sat, 23 Dec 2023 22:06:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6694A3858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6694A3858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369183; cv=none; b=EkrM7SxvlHhvI8DYIdZGF+/t8tM+hGQcaLI6hxrlbGzbl2JR9z3X5wbRWpCu+c8tp1fxFZqmk1rV8/z6ePfoleKBU/nkud3MYVJwTFlB39CpY8YRb+7QMUVd5ufFgEQ04Q75WdTUZjF2w0t8lmHriviOG6OLl/QsZuYHaggeV3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369183; c=relaxed/simple; bh=ETAdeCk1hOmoF/1W76QmKFsPRdNbT2lwLpFp4A+RIdg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=F62JmkaelS1IUlGb8FmKcfcMUVk9EDm3KM+4ATr1eAXm09rARXE7+8VzcpR0SELp4X5eL2KGfdQQDmSYA2ZaCgPWJ1Ft8OeVf5YnYcaQJWV8yiyyyGT5Zkmv1jgdJXs9EA4uD+Xyj9SmUfl4zwk1REyPBa1U0Ek3wVv/GSDJai8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM3kqP001089; Sat, 23 Dec 2023 22:06:21 GMT Received: from mxout24.cac.washington.edu (mxout24.cac.washington.edu [140.142.234.158]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5n8t3s7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:06:21 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout24.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM64sH028332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:06:04 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y26011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:06:04 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 3/8] c++: Implement __is_volatile built-in trait Date: Sat, 23 Dec 2023 14:02:44 -0800 Message-ID: <20231223220432.712093-4-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: FmHw86E3sJFaa-4m78c8kN2fQevdgnPi X-Proofpoint-GUID: FmHw86E3sJFaa-4m78c8kN2fQevdgnPi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1034 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=698 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112119857678566 X-GMAIL-MSGID: 1786112119857678566 This patch implements built-in trait for std::is_volatile. gcc/cp/ChangeLog: * cp-trait.def: Define __is_volatile. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_VOLATILE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_volatile. * g++.dg/ext/is_volatile.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 +++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 +++ gcc/testsuite/g++.dg/ext/is_volatile.C | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_volatile.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index f1b07aa2853..d9ba62d443a 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3828,6 +3828,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_UNION: inform (loc, " %qT is not a union", t1); break; + case CPTK_IS_VOLATILE: + inform (loc, " %qT is not a volatile type", t1); + break; case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: inform (loc, " %qT is not a reference that binds to a temporary " "object of type %qT (direct-initialization)", t1, t2); diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 36faed9c0b3..e9347453829 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -92,6 +92,7 @@ DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2) DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1) DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) +DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2) DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 364d87ee34d..c7971c969ae 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12501,6 +12501,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_UNION: return type_code1 == UNION_TYPE; + case CPTK_IS_VOLATILE: + return CP_TYPE_VOLATILE_P (type1); + case CPTK_REF_CONSTRUCTS_FROM_TEMPORARY: return ref_xes_from_temporary (type1, type2, /*direct_init=*/true); @@ -12671,6 +12674,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: case CPTK_IS_UNION: + case CPTK_IS_VOLATILE: break; case CPTK_IS_LAYOUT_COMPATIBLE: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index e3640faeb96..b2e2f2f694d 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -158,6 +158,9 @@ #if !__has_builtin (__is_union) # error "__has_builtin (__is_union) failed" #endif +#if !__has_builtin (__is_volatile) +# error "__has_builtin (__is_volatile) failed" +#endif #if !__has_builtin (__reference_constructs_from_temporary) # error "__has_builtin (__reference_constructs_from_temporary) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_volatile.C b/gcc/testsuite/g++.dg/ext/is_volatile.C new file mode 100644 index 00000000000..80a1cfc880d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_volatile.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +class ClassType { }; +using cClassType = const ClassType; +using vClassType = volatile ClassType; +using cvClassType = const volatile ClassType; + +// Positive tests. +SA(__is_volatile(volatile int)); +SA(__is_volatile(const volatile int)); +SA(__is_volatile(vClassType)); +SA(__is_volatile(cvClassType)); + +// Negative tests. +SA(!__is_volatile(int)); +SA(!__is_volatile(const int)); +SA(!__is_volatile(ClassType)); +SA(!__is_volatile(cClassType)); From patchwork Sat Dec 23 22:02:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1882984dyi; Sat, 23 Dec 2023 14:07:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoa/fINt0zWQIAez53FCUAMA31IA/9Js2wQPJXeX8Eis+OqfqCJzT8JTawJyWsUAUbMy7J X-Received: by 2002:aca:2118:0:b0:3bb:6b22:9595 with SMTP id 24-20020aca2118000000b003bb6b229595mr2971426oiz.108.1703369261434; Sat, 23 Dec 2023 14:07:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369261; cv=pass; d=google.com; s=arc-20160816; b=BV5nBDCUvB3Sf+MqgD3oJyprGBlgy+2PdzXdLdhR50Fnd15Pn+DtIXDp5FdNmWgWg4 DxGqSgOLXPWt4YOBzvTFog/gMzljRNs1EPPvA1QCLqUsnxODJp+Ktrb5d+qJNa+CtPRC sMkLpZKmWMAtqaUOIAd1H2lGh0BxH4OnX/53dfZGvjMf/0vRg+yvK2FlrsrxTE1bRHsi 8Q7qUWm6GT629+02nx2qms/KLOKDExwP6FV4rwaD4G18ph7UMG3XnDODzrMJHFo1jaCT bCrYalfWkFzTXkySXJW0nhh03BGFCHQw+0oEyFs7g5hdk3FDvvikcJdOILN+0033NgQT lcBg== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=jPGj10E/uvmNemNXhPcqZvLNZlOIGR7M7P99NhqHrFc=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=q5Xn49JrLONZpumXbNpg69qGX/l8Nl59JdsJ5+4P+99HXm/yEFMGtHsWpn+F4WKA94 L7ZMRPfQc1EStEx/9cZ4T+hPQpAyImTI/7QHwr/mVupD3hIAI4MgfQH8pKUj31rIK+aG 245ESL0+Qq2cPwEoOXxxGqjFsBzc3D3WVkYmGndl1AtW7GT/CmFODHJ5SGiPdtBE5fyd mJw9GfhR5UPP9iOuAx498PXSVaz9Iumv0kw2AgSSk7LpJEjLwNNlYsExGGS/H8oZK7XP AhBj2yYKyu5YEFGd3DSbS0TRu63lHfZPxE9Cdr1We+ydpuifN1ZVnrcw320p5+OMUBwv 7TDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Yo2gLPlQ; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u1-20020a05620a0c4100b0076d8bb2e9f9si7921815qki.680.2023.12.23.14.07.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:07:41 -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=@gcc.gnu.org header.s=default header.b=Yo2gLPlQ; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1EF623865C24 for ; Sat, 23 Dec 2023 22:07:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EF623865C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369261; bh=jPGj10E/uvmNemNXhPcqZvLNZlOIGR7M7P99NhqHrFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Yo2gLPlQkvTMaxMH+gpGigQw2B4OE7NDjtBFVViPKZIF2UUvae7SnhMGEvpFdrw1T 7+PXzbd3nlVGJS3WY+RP6p9BDZhD2Aosu9+pOvWH3QdJGQFd+QUafGkuAkXGVLRf0Z y6EfPvTksSvq/YCRpZtNw2BZcVCBHZG9TwppCdxc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id 52D96386480A; Sat, 23 Dec 2023 22:06:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52D96386480A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 52D96386480A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369217; cv=none; b=rtLSQ1yX8k6B4FXgpN+0FqcrtiaK53930Tq/7gywgQvU2J4IoN/BjXyFFLsH0R7HDLriEAN2M8Cl90E/hIcv7xx62WTEhoPOBfJyPIJ1JS12uPsAvBmCgW+IoIkHrMLwuwmngO5RYz65m2ijABYMbTkMGIVeN+avxZ0XL+mAWhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369217; c=relaxed/simple; bh=9cdwRjV/xiTE1ek+rx8t6QJmRrfz93n0LsUukxj3HaY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=YzirElD5MPSz/RNuD2FAGvYxz1iTm6AKBD4wnBfyK+FTgLlWpg0heCz18IaJWq+1R31ls8GphycmoVo6F+OL6V1xqozOCdKNxWB79FIk8ViOCs+ymuRaVOw42UoLfdzkiKS4JcOYWhEBah80a18vQ7QxBZFKy0C4ZnIt7CebaX0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247478.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM6uNd015926; Sat, 23 Dec 2023 22:06:56 GMT Received: from mxout21.s.uw.edu (mxout21.s.uw.edu [140.142.32.139]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5rwru594-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:06:55 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout21.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM6YBP019745 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:06:34 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y27011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:06:34 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 4/8] libstdc++: Optimize std::is_volatile compilation performance Date: Sat, 23 Dec 2023 14:02:45 -0800 Message-ID: <20231223220432.712093-5-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: xJvdC1Gnq-mquQBBy66aE4zezPzFbEhO X-Proofpoint-GUID: xJvdC1Gnq-mquQBBy66aE4zezPzFbEhO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 mlxlogscore=721 priorityscore=1501 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1034 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112126491765165 X-GMAIL-MSGID: 1786112126491765165 This patch optimizes the compilation performance of std::is_volatile by dispatching to the new __is_volatile built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_volatile): Use __is_volatile built-in trait. (is_volatile_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f40831de838..30b0778e58a 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -851,6 +851,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// is_volatile +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) + template + struct is_volatile + : public __bool_constant<__is_volatile(_Tp)> + { }; +#else template struct is_volatile : public false_type { }; @@ -858,6 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_volatile<_Tp volatile> : public true_type { }; +#endif /// is_trivial template @@ -3344,10 +3351,15 @@ template inline constexpr bool is_function_v<_Tp&&> = false; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_volatile) +template + inline constexpr bool is_volatile_v = __is_volatile(_Tp); +#else template inline constexpr bool is_volatile_v = false; template inline constexpr bool is_volatile_v = true; +#endif template inline constexpr bool is_trivial_v = __is_trivial(_Tp); From patchwork Sat Dec 23 22:02:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1883272dyi; Sat, 23 Dec 2023 14:08:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IH90feaJW2ZqM8X85UaCPFhb/S8S0BiGqHwWibfqbf3CN/P62okbUwgTVG5k4iBQtf5Emh2 X-Received: by 2002:ad4:5aa4:0:b0:67a:a739:afb3 with SMTP id u4-20020ad45aa4000000b0067aa739afb3mr6348598qvg.27.1703369318041; Sat, 23 Dec 2023 14:08:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369318; cv=pass; d=google.com; s=arc-20160816; b=H9rZ0FrpbykQp7FDnBGupgXuhsybfe/DKbN+L7Qo1/VSOR594WovIK0ILEYR4kth5C cvgLjNdh1+2Sx4hDMGSwA1vaNwTXKPZMuv7UDTeU5ZC6PNqKVQVGiid+cm+xGdrYRPWf MHjjGon52RCpCOw5mUYpeRfri4OZiXMmbwizoAynXjKADR4X37CM7fWLkGk6TZ0RavA6 SZ7CGzWmfuVTlJ4cQ20YcjRfVAtXh9jCNU74/aSnZ4nQaUC9GF89uIKH0Z3f7LogVTck wLBjZVQixBPD/kOqRn+sVOZf3UrztwQV3RRhBv7FUkHYNMyTBr63dpjhEsdkPqoFv1gm E+lA== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=ca6pIfkJ5tucFrgVRrLH/ipKKekBiUx40TxscrDdt5w=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=IT9kfMYl0hsJi6WESflaEwpTJBfDaLn0Kj9dY5UJbxCCuuMQI6YvUqBZC1XvyevHcL gND6AnQH80jROVxuB81fV+JtaYHzygS7ctMz6s1cttpLoH4GqxNbxFlXeDhe0TLGD63/ i7jhlCJcsJeD8+jlvCzw6butfT/OZl8kRVtNEwI6nmHZW29zAEGS4oi+n9jE3ymuPiWV nchlauOoTpKYeu2HsoX8zY80wSQr1AbzGnKEwM/bd1LyQOggTb+16XESjmLZADSohUz2 QN27g+p0Lo0b6n4DdAFzWNc0KWyS7IFtuM1keGAX98I2WSRLbj7ygZYysbvSSJ3DoUAf kA/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vKisuxkp; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m10-20020a0cdb8a000000b0067a98673be5si3619384qvk.126.2023.12.23.14.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:08: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=@gcc.gnu.org header.s=default header.b=vKisuxkp; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B089386C5BE for ; Sat, 23 Dec 2023 22:08:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B089386C5BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369317; bh=ca6pIfkJ5tucFrgVRrLH/ipKKekBiUx40TxscrDdt5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vKisuxkpZqv0G5WXejSzBTeoMIbyx77twjXg+W9Si3QEirFQwuq7ympcQY1rIsanj 70wTWliQLT1IHN+Nf+gwVxcvWeGVjNpilT/9sOYlGrKThq4FJ4zt2vjYnN20BSsWVp iktEUnS9G54mERmAbY6rRebw4lXFBtrwj4I1wb3w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id F2C01384CB9E; Sat, 23 Dec 2023 22:07:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2C01384CB9E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F2C01384CB9E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369253; cv=none; b=NIyyyJrLO2Km9fuY5CZpfcJEHRj78zE//YMbfOBDc9aEDbvHh6kiQxi9trpCiOjQFT/Fmzj0UgXD39tGYQSUJtvyi0BT8nNrULSCSIOBu83Y64Qv88ihkHqtMC6QBpD/BePfRfPeTQqMPThQ/Q52NzG+kNvuQsROzXbuki0gn6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369253; c=relaxed/simple; bh=OFEy548AlD1JqjGCi5uLRspSV5TqVjF1fp+O5cOgS0w=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=TmPzdoHWsLpryFBYF8xZ3jTtT6Ne4ql5OBS4+bm4W3V4Wgm74+JoGcAJ4vjU6Rp53jCT1LJ8Ed3xrkFBIRx4P5CgDkG/eNNArtsJFNPXkR+UWR8hJXZ+Yz6GHYYRA9HKBdek2/P4ICK6a8EKguB0mvi+JLTYAniAIC2VFvZASv4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM46YI002253; Sat, 23 Dec 2023 22:07:31 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5n8t3sau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:07:31 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM76W6019946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:07:06 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y28011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:07:06 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 5/8] c++: Implement __is_pointer built-in trait Date: Sat, 23 Dec 2023 14:02:46 -0800 Message-ID: <20231223220432.712093-6-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 1xEra6ywG2CYYwwCFOWOvowAqClsncng X-Proofpoint-GUID: 1xEra6ywG2CYYwwCFOWOvowAqClsncng X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1034 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=747 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112185994066034 X-GMAIL-MSGID: 1786112185994066034 This patch implements built-in trait for std::is_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer. * g++.dg/ext/is_pointer.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 ++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ gcc/testsuite/g++.dg/ext/is_pointer.C | 51 ++++++++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index d9ba62d443a..44bf8dc5c5b 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3795,6 +3795,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_POD: inform (loc, " %qT is not a POD type", t1); break; + case CPTK_IS_POINTER: + inform (loc, " %qT is not a pointer", t1); + break; case CPTK_IS_POLYMORPHIC: inform (loc, " %qT is not a polymorphic type", t1); break; diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index e9347453829..18e2d0f3480 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -82,6 +82,7 @@ DEFTRAIT_EXPR (IS_NOTHROW_CONVERTIBLE, "__is_nothrow_convertible", 2) DEFTRAIT_EXPR (IS_OBJECT, "__is_object", 1) DEFTRAIT_EXPR (IS_POINTER_INTERCONVERTIBLE_BASE_OF, "__is_pointer_interconvertible_base_of", 2) DEFTRAIT_EXPR (IS_POD, "__is_pod", 1) +DEFTRAIT_EXPR (IS_POINTER, "__is_pointer", 1) DEFTRAIT_EXPR (IS_POLYMORPHIC, "__is_polymorphic", 1) DEFTRAIT_EXPR (IS_REFERENCE, "__is_reference", 1) DEFTRAIT_EXPR (IS_SAME, "__is_same", 2) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index c7971c969ae..01a7ccc5225 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12471,6 +12471,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_POD: return pod_type_p (type1); + case CPTK_IS_POINTER: + return TYPE_PTR_P (type1); + case CPTK_IS_POLYMORPHIC: return CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1); @@ -12670,6 +12673,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_MEMBER_OBJECT_POINTER: case CPTK_IS_MEMBER_POINTER: case CPTK_IS_OBJECT: + case CPTK_IS_POINTER: case CPTK_IS_REFERENCE: case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index b2e2f2f694d..96b7a89e4f1 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -125,6 +125,9 @@ #if !__has_builtin (__is_pod) # error "__has_builtin (__is_pod) failed" #endif +#if !__has_builtin (__is_pointer) +# error "__has_builtin (__is_pointer) failed" +#endif #if !__has_builtin (__is_polymorphic) # error "__has_builtin (__is_polymorphic) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_pointer.C b/gcc/testsuite/g++.dg/ext/is_pointer.C new file mode 100644 index 00000000000..d6e39565950 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_pointer.C @@ -0,0 +1,51 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +SA(!__is_pointer(int)); +SA(__is_pointer(int*)); +SA(__is_pointer(int**)); + +SA(__is_pointer(const int*)); +SA(__is_pointer(const int**)); +SA(__is_pointer(int* const)); +SA(__is_pointer(int** const)); +SA(__is_pointer(int* const* const)); + +SA(__is_pointer(volatile int*)); +SA(__is_pointer(volatile int**)); +SA(__is_pointer(int* volatile)); +SA(__is_pointer(int** volatile)); +SA(__is_pointer(int* volatile* volatile)); + +SA(__is_pointer(const volatile int*)); +SA(__is_pointer(const volatile int**)); +SA(__is_pointer(const int* volatile)); +SA(__is_pointer(volatile int* const)); +SA(__is_pointer(int* const volatile)); +SA(__is_pointer(const int** volatile)); +SA(__is_pointer(volatile int** const)); +SA(__is_pointer(int** const volatile)); +SA(__is_pointer(int* const* const volatile)); +SA(__is_pointer(int* volatile* const volatile)); +SA(__is_pointer(int* const volatile* const volatile)); + +SA(!__is_pointer(int&)); +SA(!__is_pointer(const int&)); +SA(!__is_pointer(volatile int&)); +SA(!__is_pointer(const volatile int&)); + +SA(!__is_pointer(int&&)); +SA(!__is_pointer(const int&&)); +SA(!__is_pointer(volatile int&&)); +SA(!__is_pointer(const volatile int&&)); + +SA(!__is_pointer(int[3])); +SA(!__is_pointer(const int[3])); +SA(!__is_pointer(volatile int[3])); +SA(!__is_pointer(const volatile int[3])); + +SA(!__is_pointer(int(int))); +SA(__is_pointer(int(*const)(int))); +SA(__is_pointer(int(*volatile)(int))); +SA(__is_pointer(int(*const volatile)(int))); From patchwork Sat Dec 23 22:02:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1883274dyi; Sat, 23 Dec 2023 14:08:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxdB3dBueTotT4Tdczy9uW2bLH2AcSLdM1IZgYOfhlnlY9AeDGNudC/6ApD8/f7Q3L2wGt X-Received: by 2002:a05:620a:1793:b0:76f:5b9:3f29 with SMTP id ay19-20020a05620a179300b0076f05b93f29mr6025728qkb.2.1703369318103; Sat, 23 Dec 2023 14:08:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369318; cv=pass; d=google.com; s=arc-20160816; b=FSbllKdzDNEb5RGSldlk15BvMLs9jbEW1MWO23or4KIhwOSpj2tckxydEzuda1fNxF 8I49OYvOOhlOjW6sI2v6lJHXX7GDxx+iZ6x4I5Ab3lA+RJX5KqNEHHHgNYDDC7SsBSxD OE/wCLrM0qpJIsLOPQxwGJQRS+R+d5gl7Rczr/uSVgoIsnBQbSXNvTxoR4gp2WExpqOu Y+7VZn3qCsl4Y8TFRZJ4gclEZxzQnfnjto/gbKOoVpey5DJALsbq4TXVdQuiYG2BzmNo qQMaS92K4KRUDgIf8picZRple+/1yNr9BS7ppnB0bA0U44pCzOfFNkWD2y3KzW+8cDqN TcWQ== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=g/bPEt3y2Nma8UUilmFK4yodHX/eLvTO0FvIwrh8FT0=; fh=2MU6VW487KDeEvI5/nTaFmO/pzM6rabW6FcP4yf4iBE=; b=zjPlTOKtaCDHeh9vtB5GKE1AZ5zgC/dGThCWPuM7qEwEm84blKEtgxgYknkrj1avft yU+lFtp/oWqblVsuZN8Quog189heYb2yrfK6BSV2v6PcmDQZkW5xOtO/nNCXaHv1Uypm Fn4SnDjXrkd5FDyo8AoRc/zmgZbCDkttomLsDnCazxCLcGIBeWDu8w7tV88qE2MUxsX1 hHvShrbE3Oz4+5ojS93obAyZMwopMB+TjwdicicSBGUP/WAEhGb8OQsESd5KDxktfd1X BjIZTiYryBwtkRtuMPaD+UQS7cB1no+TyYTHm+KUJ70KMjmjIeKTSjEoWjZWGqvSL7PM H+pw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Zg40zi7v; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g14-20020a05620a108e00b00781079909c2si7193417qkk.130.2023.12.23.14.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:08:38 -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=@gcc.gnu.org header.s=default header.b=Zg40zi7v; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BA0838449D5 for ; Sat, 23 Dec 2023 22:08:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BA0838449D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369317; bh=g/bPEt3y2Nma8UUilmFK4yodHX/eLvTO0FvIwrh8FT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Zg40zi7v1PBNsLjTgRA5llbQX9Bkg+AlkMLJizsBTpc48ilVel44COvsnFlunUxxo yfBiPkuRKgG9w0pLjtiKMBSBhfn2qntEyzz4s5XNp3mwNhjeLNYxD0ZFYYd/vvWkri WPG8IxOHZZDAy0Z1erPEA59jAPHV/49r0EKIlqJA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id E67DA3865C29; Sat, 23 Dec 2023 22:07:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E67DA3865C29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E67DA3865C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369275; cv=none; b=XjJjTWjYpnRVlR9KV0CXKb7mLG/VumpZxnTrFXXlLWmtdrE7gigSzFNR4h5u5LZVCNVAfFn6nzn2SR/GX//FmioVxwSxSWSWrdUAU8q5Ga/n0hliT17miqyLcaIug5MlmWry0tPdJ9EOfx6IH94Fymf1n2HOYbWQtle9o/Su+lU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369275; c=relaxed/simple; bh=8EqaUHzNjOEr/r1lsRiLYqeP/tZadEGKxF21bAR/KVY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=dooD9ZX42ngjFqPcl55o1CN1e5LHwQKKl+fsFEXlvmSdDIKx2Nmkz9MLxaWrQN5DMImVcbcuM/t4cPjqnNQWOU1d1VhVGk47z3Mc9yySdzTFucybkKBWTmVWs4x9A7PVpOhIn6QcZcyTQlxISW92KkQNztqI/56dcLiFMysTLow= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM7Z13007754; Sat, 23 Dec 2023 22:07:53 GMT Received: from mxout25.s.uw.edu (mxout25.s.uw.edu [140.142.234.175]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5n8t3sbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:07:53 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout25.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM7fW7014304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:07:41 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y29011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:07:41 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui , Jonathan Wakely Subject: [PATCH v2 6/8] libstdc++: Optimize std::is_pointer compilation performance Date: Sat, 23 Dec 2023 14:02:47 -0800 Message-ID: <20231223220432.712093-7-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dfdyV6uuj2Xak5hSwq2n6MWqmhZ4lNHe X-Proofpoint-GUID: dfdyV6uuj2Xak5hSwq2n6MWqmhZ4lNHe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1034 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=382 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112186161256731 X-GMAIL-MSGID: 1786112186161256731 This patch optimizes the compilation performance of std::is_pointer by dispatching to the new __is_pointer built-in trait. libstdc++-v3/ChangeLog: * include/bits/cpp_type_traits.h (__is_pointer): Use __is_pointer built-in trait. Optimize its implementation. * include/std/type_traits (is_pointer): Likewise. (is_pointer_v): Likewise. Co-authored-by: Jonathan Wakely Signed-off-by: Ken Matsui --- libstdc++-v3/include/bits/cpp_type_traits.h | 29 ++++++++++++++ libstdc++-v3/include/std/type_traits | 44 +++++++++++++++++---- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 4312f32a4e0..c348df97f72 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -363,6 +363,13 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) // // Pointer types // +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct __is_pointer : __truth_type<_IsPtr> + { + enum { __value = _IsPtr }; + }; +#else template struct __is_pointer { @@ -377,6 +384,28 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) typedef __true_type __type; }; + template + struct __is_pointer<_Tp* const> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template + struct __is_pointer<_Tp* volatile> + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template + struct __is_pointer<_Tp* const volatile> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + // // An arithmetic type is an integer type or a floating point type // diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 30b0778e58a..d53911b2fa0 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -542,19 +542,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public true_type { }; #endif - template - struct __is_pointer_helper + /// is_pointer +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) + template + struct is_pointer + : public __bool_constant<__is_pointer(_Tp)> + { }; +#else + template + struct is_pointer : public false_type { }; template - struct __is_pointer_helper<_Tp*> + struct is_pointer<_Tp*> : public true_type { }; - /// is_pointer template - struct is_pointer - : public __is_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + struct is_pointer<_Tp* const> + : public true_type { }; + + template + struct is_pointer<_Tp* volatile> + : public true_type { }; + + template + struct is_pointer<_Tp* const volatile> + : public true_type { }; +#endif /// is_lvalue_reference template @@ -3252,8 +3266,22 @@ template inline constexpr bool is_array_v<_Tp[_Num]> = true; #endif +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_pointer) +template + inline constexpr bool is_pointer_v = __is_pointer(_Tp); +#else template - inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; + inline constexpr bool is_pointer_v = false; +template + inline constexpr bool is_pointer_v<_Tp*> = true; +template + inline constexpr bool is_pointer_v<_Tp* const> = true; +template + inline constexpr bool is_pointer_v<_Tp* volatile> = true; +template + inline constexpr bool is_pointer_v<_Tp* const volatile> = true; +#endif + template inline constexpr bool is_lvalue_reference_v = false; template From patchwork Sat Dec 23 22:02:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1883432dyi; Sat, 23 Dec 2023 14:09:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkQQgRFzgMSvDDwInFyH7oaxtBr67bwzJCHOVzxBfLzOxQv9uedCxd1EIH3oWsNKe5Hy6a X-Received: by 2002:a05:622a:48b:b0:427:a2d0:cf49 with SMTP id p11-20020a05622a048b00b00427a2d0cf49mr5151900qtx.101.1703369349960; Sat, 23 Dec 2023 14:09:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369349; cv=pass; d=google.com; s=arc-20160816; b=C+cRDCBc0qtaYy+3RyMe7MfGaHdsEaldk2i7LOe3aruvDbHQHv/RWwc1OS5116hQ6d WUsX1PveDQ+NoH1tDShA3K4LQtkImoQ86Lpynl78z9o2PQ+sanymvPmM5wRouqtZD3oC 1cVVN0EVX96R2tVcS2oKU98cJRHkrFmKrwTHIqtwJO9m0s6dc25ajwwqFUWhCZBkPwlS mYmsNU1lYUWbgWixQm/2OSAJZjno3NukarRG3bWOb3u1su03hRN/LLzsysebBCGRuJyK d4G6EkOUH3k0Rb7YsXepMujotFppJIXcQUL5xGLCHGK5IRw/VpF7622fuehwoqHX3y6J vakw== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=un0XgupCR67pcPT+bELioVCkt7yfypDx7NHTwScI4Zk=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=faVfrjGK/h9gYb0dv9m5hBIfLC49qMeNrBPHx1ZYnPpVrIIdy0lprEE/oQA6uyjhvD od/pPX7MEEggHsH++/+UbdmJ1TA7ulmEntRPKjUUQCf17jtXNuz+6reD4j8H4jK/J3Ad GXMD3sNkjG8JJUo2PBUFyd4nkiXz5w1s0GPpOIzNKGor/ncVJEZytTVvAzsYv3TpxV1h aDz4EHZWpus2fH6oo8K6XP/C1SXwQ1K0CcnP6/6ajbQVHIe4zaGrzK08j0pyQ8JeJUVz Xk886cWnusO1Ea+ftFTv2NQF95IrORxrBVRycHpy9ZKDV58y4k3BWf4JQWAxNV8+eZ3W ZbnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lg30GArN; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b8-20020ac85bc8000000b0042553065f6csi7784950qtb.220.2023.12.23.14.09.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:09:09 -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=@gcc.gnu.org header.s=default header.b=lg30GArN; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9CCEF3865C29 for ; Sat, 23 Dec 2023 22:09:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CCEF3865C29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369349; bh=un0XgupCR67pcPT+bELioVCkt7yfypDx7NHTwScI4Zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lg30GArNdvgAYJh4+8xRDOONBjK0IkKWxYs1EL3txH+P/w6u2EhWqerA5FHU3OTIf Ctvg219evnDjGkz4h7+5B+RLn4e8jvy0juL6GRT9WZzKweUPupwjFaAjeWnBDlaeE/ uS9+86d5X3PoEiQmN8KlCKhXQwK0slvbe8krncgQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-00641c01.pphosted.com (mx0b-00641c01.pphosted.com [205.220.177.146]) by sourceware.org (Postfix) with ESMTPS id EEBDA3865C29; Sat, 23 Dec 2023 22:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEBDA3865C29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EEBDA3865C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.177.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369307; cv=none; b=bh4tzLXKBHMPkLpkdf/YkU1NPPJzjAGNjnMZh6hgWfKZ/xGE1yqVD/j5XtYv0YK0gQEuTY6JIi1WQPYapjGE7GYGrqO2mxzXEYnrebT3NBWoOEVz+v+woN+cSj6igku2M94dNgb6uAsA6d/mUZcYMU0Mf5PxsLhK7cQ9OaayoBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369307; c=relaxed/simple; bh=FPiIcBG0tFbup55J4uxi1/QOELSq8Oc+A2hSz10LKOM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=wfI0LQSNlOoUCpnxjJQTzaZuGXR2sGjlLgNCJb5423+MZ5Bm7U5hMNYCy0BH3JwMqBWFaTmvkos9mT1SCHwrMQRZ40Mdn7I5IVHp3kU5jeCm4LCX84bCIGc0xa91YT5taQs6SrdFDSQ7vFZawf0KFX1Bnt+ZrICXw6flm+Rz1f0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247477.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM8PgL008516; Sat, 23 Dec 2023 22:08:25 GMT Received: from mxout24.cac.washington.edu (mxout24.cac.washington.edu [140.142.234.158]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5n8t3sd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:08:25 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout24.cac.washington.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM8NIM028713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:08:23 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y2A011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:08:23 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 7/8] c++: Implement __is_unbounded_array built-in trait Date: Sat, 23 Dec 2023 14:02:48 -0800 Message-ID: <20231223220432.712093-8-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: vA2tepWq7M_J4qTn72VMVdJ94LcDZsE5 X-Proofpoint-GUID: vA2tepWq7M_J4qTn72VMVdJ94LcDZsE5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1034 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=503 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112219523462016 X-GMAIL-MSGID: 1786112219523462016 This patch implements built-in trait for std::is_unbounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_unbounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_UNBOUNDED_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_unbounded_array. * g++.dg/ext/is_unbounded_array.C: New test. Signed-off-by: Ken Matsui --- gcc/cp/constraint.cc | 3 ++ gcc/cp/cp-trait.def | 1 + gcc/cp/semantics.cc | 4 ++ gcc/testsuite/g++.dg/ext/has-builtin-1.C | 3 ++ gcc/testsuite/g++.dg/ext/is_unbounded_array.C | 37 +++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/is_unbounded_array.C diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 44bf8dc5c5b..defb2ac0ee8 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3828,6 +3828,9 @@ diagnose_trait_expr (tree expr, tree args) case CPTK_IS_TRIVIALLY_COPYABLE: inform (loc, " %qT is not trivially copyable", t1); break; + case CPTK_IS_UNBOUNDED_ARRAY: + inform (loc, " %qT is not an unbounded array", t1); + break; case CPTK_IS_UNION: inform (loc, " %qT is not a union", t1); break; diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def index 18e2d0f3480..05514a51c21 100644 --- a/gcc/cp/cp-trait.def +++ b/gcc/cp/cp-trait.def @@ -92,6 +92,7 @@ DEFTRAIT_EXPR (IS_TRIVIAL, "__is_trivial", 1) DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2) DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1) DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1) +DEFTRAIT_EXPR (IS_UNBOUNDED_ARRAY, "__is_unbounded_array", 1) DEFTRAIT_EXPR (IS_UNION, "__is_union", 1) DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1) DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 01a7ccc5225..176eda629ff 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12501,6 +12501,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_TRIVIALLY_COPYABLE: return trivially_copyable_p (type1); + case CPTK_IS_UNBOUNDED_ARRAY: + return array_of_unknown_bound_p (type1); + case CPTK_IS_UNION: return type_code1 == UNION_TYPE; @@ -12677,6 +12680,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_REFERENCE: case CPTK_IS_SAME: case CPTK_IS_SCOPED_ENUM: + case CPTK_IS_UNBOUNDED_ARRAY: case CPTK_IS_UNION: case CPTK_IS_VOLATILE: break; diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C index 96b7a89e4f1..b1430e9bd8b 100644 --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C @@ -158,6 +158,9 @@ #if !__has_builtin (__is_trivially_copyable) # error "__has_builtin (__is_trivially_copyable) failed" #endif +#if !__has_builtin (__is_unbounded_array) +# error "__has_builtin (__is_unbounded_array) failed" +#endif #if !__has_builtin (__is_union) # error "__has_builtin (__is_union) failed" #endif diff --git a/gcc/testsuite/g++.dg/ext/is_unbounded_array.C b/gcc/testsuite/g++.dg/ext/is_unbounded_array.C new file mode 100644 index 00000000000..283a74e1a0a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_unbounded_array.C @@ -0,0 +1,37 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert((X),#X) + +#define SA_TEST_CATEGORY(TRAIT, TYPE, EXPECT) \ + SA(TRAIT(TYPE) == EXPECT); \ + SA(TRAIT(const TYPE) == EXPECT); \ + SA(TRAIT(volatile TYPE) == EXPECT); \ + SA(TRAIT(const volatile TYPE) == EXPECT) + +class ClassType { }; +class IncompleteClass; +union IncompleteUnion; + +SA_TEST_CATEGORY(__is_unbounded_array, int[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int[], true); +SA_TEST_CATEGORY(__is_unbounded_array, int[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, int[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, float*[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, float*[], true); +SA_TEST_CATEGORY(__is_unbounded_array, float*[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, float*[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[], true); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, ClassType[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[2][3], false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass[][3], true); +SA_TEST_CATEGORY(__is_unbounded_array, int(*)[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(*)[], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(&)[2], false); +SA_TEST_CATEGORY(__is_unbounded_array, int(&)[], false); + +// Sanity check. +SA_TEST_CATEGORY(__is_unbounded_array, ClassType, false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteClass, false); +SA_TEST_CATEGORY(__is_unbounded_array, IncompleteUnion, false); From patchwork Sat Dec 23 22:02:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 183017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1883608dyi; Sat, 23 Dec 2023 14:09:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCDD4OfczUnerZogaZXrg5wumgQUJPZ39hVqLo0vVqgNgUXkGQFp63cAanDCs20Bo4XhLV X-Received: by 2002:a05:620a:148e:b0:77b:caa2:9a8c with SMTP id w14-20020a05620a148e00b0077bcaa29a8cmr4446713qkj.41.1703369385645; Sat, 23 Dec 2023 14:09:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703369385; cv=pass; d=google.com; s=arc-20160816; b=Y66iywn396sbiJovX2wRYTu7nqI/e0CgAsg1ij/+afJhbD8NrHRwqxeerXlNxPpAMO xfwLCaA0otZ8YVddA+P903a29ucpnScJqN6URL3PiE1ksHHnAT7C4mKhZZDnu/1CJvRB SdgInH8zkx2Q7rhNeLwVQp9mKdFCqA5Gnd14uRNQ726TWaXWiyyAmzkfivs//jxgp66v ET7uxExWz9za0TsQE01/gyxyFOg7qFmBJQLDW5n+0ojGF52UYdorxUYbs9FOnFpQCF5E jZlCQRuIuEvXtYAbzSffT6TWeZHEwrao7Mkso7xihyR+YJXudn4Py4XkSK0yNfLxkDS4 +khQ== ARC-Message-Signature: i=2; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=F3mlCG482sz2Vs0L39EPLnC+L4mgZB994dreAZIe7T8=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=Re83rNqWTasBzGdiH2Zc+wUaV+6BZJDCzBReLmMEI+iQRTFgAt/Un68jMlXID/2P5D sWkUdDfnWxsM4AIHTMzY7qA0Y35EP90nhN3ne/Ob1PTb+bziHX8pcNRtkhVJWmUMMmQa 9CnyWxrxokpfQ4wg6VXTIO9SKedW56GS0Og5MZigr9S27r8592xbYY4adqZJZdyDT0mm OnrUA19Zme8wm5kPdzYdH2cMjKp40wlsVkT4br8zzndgFEtD1/PAe+cev8Mgtnbdy7X4 Sz3+sENyy7HT670dWl7JZtqRAVki1CSdvTFBtQ1iNF3BMnetYaml3oWDEZi26xbq+uwR obeg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uYLngqlk; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o19-20020a05620a111300b00779d0a62e5fsi7278948qkk.660.2023.12.23.14.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 14:09:45 -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=@gcc.gnu.org header.s=default header.b=uYLngqlk; arc=pass (i=1); 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 521693858429 for ; Sat, 23 Dec 2023 22:09:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 521693858429 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703369385; bh=F3mlCG482sz2Vs0L39EPLnC+L4mgZB994dreAZIe7T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uYLngqlk1j8hEJ00s01wZMDCwPW1wHmUk5MDkngUJq/eNPh9UR9pE/v1mzYNeiDsu 3mciipuzq6Q+pdtksxtJZ+H4AzZFNQph27pyO8iVLc8SwubZ6AjqGQTAhT9Wty1Wxy i0lQaviFhZ9hOz4J7DR8sED/s2/563v1hzyZ0IO0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00641c01.pphosted.com (mx0a-00641c01.pphosted.com [205.220.165.146]) by sourceware.org (Postfix) with ESMTPS id CD0EA384CBBC; Sat, 23 Dec 2023 22:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD0EA384CBBC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gcc.gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD0EA384CBBC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.165.146 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369345; cv=none; b=jIrigIxf3NzDJKXprqh4hqeK5PbgcC0bLl7aWofcOkdrTFbDVlUGwWm583xULJp+udzQCEzmex3goZdey7Uj9LyLlKesBOv50ia8RPgr3N/AR31jjxYgPlMWp6EMW2vOp0LAxI0FiuO9upDxD9uJ2S04aOFhs1VbWLku8FmwmLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703369345; c=relaxed/simple; bh=GG2lrWegOwkmV8MxFmTHsx8otqTtOOhQr2HLD/0MFuo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=BLrlOpM2y12DeAgRGbPt33xGeCmyEkByMFJr8C3dA2czyj6hyIzFrZyYInBA40YL/e+YC0wOpNHpV3jHioDUQvFjVwOkq2ByofF0roMCZJvPC2Lg03uV/kh2Ber9CrfJOF9QU9SFScZO4dFw9rKMylbL3QQaw7mOtdvfLo78ptU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0247470.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BNM7fBR028225; Sat, 23 Dec 2023 22:09:02 GMT Received: from mxout22.s.uw.edu (mxout22.s.uw.edu [128.95.242.222]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3v5r5cb71c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 22:09:02 +0000 Received: from smtp.washington.edu (smtp.washington.edu [128.208.60.54]) by mxout22.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 3BNM8csn020155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2023 14:08:38 -0800 X-Auth-Received: from kmatsui-ThinkPad-X1-Carbon-Gen-9.dhcp4.washington.edu ([10.154.74.194]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 3BNM4Y2B011837 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 14:08:38 -0800 X-UW-Orig-Sender: kmatsui@smtp.washington.edu From: Ken Matsui To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v2 8/8] libstdc++: Optimize std::is_unbounded_array compilation performance Date: Sat, 23 Dec 2023 14:02:49 -0800 Message-ID: <20231223220432.712093-9-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231223220432.712093-1-kmatsui@gcc.gnu.org> References: <20231223220432.712093-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: -qaEqNGio8hNrJDoY_E44LCPqA6pQhaO X-Proofpoint-GUID: -qaEqNGio8hNrJDoY_E44LCPqA6pQhaO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-23_10,2023-12-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 spamscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=524 adultscore=0 clxscore=1034 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312230175 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE 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: 1786112256931161952 X-GMAIL-MSGID: 1786112256931161952 This patch optimizes the compilation performance of std::is_unbounded_array by dispatching to the new __is_unbounded_array built-in trait. libstdc++-v3/ChangeLog: * include/std/type_traits (is_unbounded_array_v): Use __is_unbounded_array built-in trait. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index d53911b2fa0..a548982236d 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3670,11 +3670,16 @@ template /// True for a type that is an array of unknown bound. /// @ingroup variable_templates /// @since C++20 +# if _GLIBCXX_USE_BUILTIN_TRAIT(__is_unbounded_array) + template + inline constexpr bool is_unbounded_array_v = __is_unbounded_array(_Tp); +# else template inline constexpr bool is_unbounded_array_v = false; template inline constexpr bool is_unbounded_array_v<_Tp[]> = true; +# endif /// True for a type that is an array of known bound. /// @since C++20