From patchwork Wed Oct 16 12:10:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1997988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Cwyv9IZs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XT8vr6729z1xvV for ; Wed, 16 Oct 2024 23:11:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0DB5385772E for ; Wed, 16 Oct 2024 12:11:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nyc.source.kernel.org (nyc.source.kernel.org [IPv6:2604:1380:45d1:ec00::3]) by sourceware.org (Postfix) with ESMTPS id 4CCB53858D20; Wed, 16 Oct 2024 12:11:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CCB53858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4CCB53858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:45d1:ec00::3 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729080668; cv=none; b=GxhLdsZz3DG3nw8ogodIrYZqNtT9vWFcHJnA2hiM6mj1wp4Kf+034A7mAVW+iCE29PYypuioUqByUE00Nv+FpicNrnLzo0Ug8nut6RGBAuhpIDRqtwlk0YrEMZUsxvrSJI0HZTLJogQWLADkoB+a9G++awWC3G9cvLKth5u1d+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729080668; c=relaxed/simple; bh=8NOGJ7oLp1B1Q5ffn6L/6NtSJvWJBPFiO30eZaSyNZs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VPKkTugjOGo0s2suPgNwNQsQQHpQYrmVg9ogYQmk7wJD/5AbJIw7wyH5xYXDD+1viIDJICP3sBKNdIHwGiiGFJ/RtgFHQjaEmX5sdQrLQYZ43i4meVbdUQ+p9evR7diffts40YTseTRqIvHcpceOxIdDslyoiNr8wedLuReL64M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 6A2C6A43C7D; Wed, 16 Oct 2024 12:10:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8168C4CEC5; Wed, 16 Oct 2024 12:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729080659; bh=8NOGJ7oLp1B1Q5ffn6L/6NtSJvWJBPFiO30eZaSyNZs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cwyv9IZs+IkiKFLiWVttmlAklwMccXbwCkFUWIjUEsvhy8sukx58VbvthcSbP/JJt 2Ws1h3IIBsJpf1LEjHLdstuoa9w2dXROoEI3zyZguacowOmnt+hixqKZlytmsR3Bil 4fgtTJ98rrVN6rn2aopji8lkeYE8QWp9cICG3N6CkkrYEAKxEOegpAYvgX3qQCjf84 vLXnFMFnH9LOf8oa54pmyn4uHwDM0m6bhahLQ0BemipdNq2r9FIRITk2uG47IqeFar bXmzhpgU9GC1MHdjXs1I/PhwgWEkfHPSikr3u1Eo2oPajsBZe/9+x6ZH1qAowmx/W2 xNjgx87gFanrw== Date: Wed, 16 Oct 2024 14:10:48 +0200 From: Alejandro Colomar To: gcc-patches@gcc.gnu.org, Joseph Myers Cc: Alejandro Colomar , Gabriel Ravier , Jakub Jelinek , Kees Cook , Qing Zhao , David Brown , Florian Weimer , Andreas Schwab , Timm Baeder , Daniel Plakosh , "A. Jiang" , Eugene Zelenko , Aaron Ballman , Paul Koning , Daniel Lundin , Nikolaos Strimpas , JeanHeyd Meneide , Fernando Borretti , Jonathan Protzenko , Chris Bazley , Ville Voutilainen , Alex Celeste , Jakub =?utf-8?q?=C5=81ukasiewicz?= , Douglas McIlroy , Jason Merrill , Siddhesh Poyarekar , DJ Delorie , Carlos O'Donell , Martin Uecker , "Gustavo A. R. Silva" , Patrizia Kaye , Ori Bernstein , Robert Seacord , "James K. Lowden" , Marek Polacek , Sam James , corentinjabot@gmail.com, Richard Biener Subject: [PATCH v16b 3/4] gcc/: Merge definitions of array_type_nelts_top Message-ID: <0cfae0598b3de33f5ae62e48c5e488494bf2e911.1729080460.git.alx@kernel.org> X-Mailer: git-send-email 2.45.2 References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: 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~incoming=patchwork.ozlabs.org@gcc.gnu.org There were two identical definitions, and none of them are available where they are needed for implementing __nelementsof__. Merge them, and provide the single definition in gcc/tree.{h,cc}, where it's available for __nelementsof__, which will be added in the following commit. gcc/ChangeLog: * tree.h (array_type_nelts_top) * tree.cc (array_type_nelts_top): Define function (moved from gcc/cp/). gcc/cp/ChangeLog: * cp-tree.h (array_type_nelts_top) * tree.cc (array_type_nelts_top): Remove function (move to gcc/). gcc/rust/ChangeLog: * backend/rust-tree.h (array_type_nelts_top) * backend/rust-tree.cc (array_type_nelts_top): Remove function. Signed-off-by: Alejandro Colomar --- gcc/cp/cp-tree.h | 1 - gcc/cp/tree.cc | 13 ------------- gcc/rust/backend/rust-tree.cc | 13 ------------- gcc/rust/backend/rust-tree.h | 2 -- gcc/tree.cc | 13 +++++++++++++ gcc/tree.h | 1 + 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 94ee550bd9c..a44100a2bc4 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8121,7 +8121,6 @@ extern tree build_exception_variant (tree, tree); extern void fixup_deferred_exception_variants (tree, tree); extern tree bind_template_template_parm (tree, tree); extern tree array_type_nelts_total (tree); -extern tree array_type_nelts_top (tree); extern bool array_of_unknown_bound_p (const_tree); extern tree break_out_target_exprs (tree, bool = false); extern tree build_ctor_subob_ref (tree, tree, tree); diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 3cac8ac4df1..c80ee068958 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -3076,19 +3076,6 @@ cxx_print_statistics (void) depth_reached); } -/* Return, as an INTEGER_CST node, the number of elements for TYPE - (which is an ARRAY_TYPE). This counts only elements of the top - array. */ - -tree -array_type_nelts_top (tree type) -{ - return fold_build2_loc (input_location, - PLUS_EXPR, sizetype, - array_type_nelts_minus_one (type), - size_one_node); -} - /* Return, as an INTEGER_CST node, the number of elements for TYPE (which is an ARRAY_TYPE). This one is a recursive count of all ARRAY_TYPEs that are clumped together. */ diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index 8d32e5203ae..3dc6b076711 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -859,19 +859,6 @@ is_empty_class (tree type) return CLASSTYPE_EMPTY_P (type); } -// forked from gcc/cp/tree.cc array_type_nelts_top - -/* Return, as an INTEGER_CST node, the number of elements for TYPE - (which is an ARRAY_TYPE). This counts only elements of the top - array. */ - -tree -array_type_nelts_top (tree type) -{ - return fold_build2_loc (input_location, PLUS_EXPR, sizetype, - array_type_nelts_minus_one (type), size_one_node); -} - // forked from gcc/cp/tree.cc builtin_valid_in_constant_expr_p /* Test whether DECL is a builtin that may appear in a diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h index 26c8b653ac6..e597c3ab81d 100644 --- a/gcc/rust/backend/rust-tree.h +++ b/gcc/rust/backend/rust-tree.h @@ -2993,8 +2993,6 @@ extern location_t rs_expr_location (const_tree); extern int is_empty_class (tree type); -extern tree array_type_nelts_top (tree); - extern bool is_really_empty_class (tree, bool); diff --git a/gcc/tree.cc b/gcc/tree.cc index 94c6d086bd7..b40f4d31b2f 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -3732,6 +3732,19 @@ array_type_nelts_minus_one (const_tree type) ? max : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min)); } + +/* Return, as an INTEGER_CST node, the number of elements for TYPE + (which is an ARRAY_TYPE). This counts only elements of the top + array. */ + +tree +array_type_nelts_top (tree type) +{ + return fold_build2_loc (input_location, + PLUS_EXPR, sizetype, + array_type_nelts_minus_one (type), + size_one_node); +} /* If arg is static -- a reference to an object in static storage -- then return the object. This is not the same as the C meaning of `static'. diff --git a/gcc/tree.h b/gcc/tree.h index c996821c953..f4c89f5477c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4930,6 +4930,7 @@ extern tree build_method_type (tree, tree); extern tree build_offset_type (tree, tree); extern tree build_complex_type (tree, bool named = false); extern tree array_type_nelts_minus_one (const_tree); +extern tree array_type_nelts_top (tree); extern tree value_member (tree, tree); extern tree purpose_member (const_tree, tree);