From patchwork Sat Aug 3 23:17:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1968760 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=qjNaKwcX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WbzBr1h8Rz1yYD for ; Sun, 4 Aug 2024 09:17:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79745385842D for ; Sat, 3 Aug 2024 23:17:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id 942583858C78 for ; Sat, 3 Aug 2024 23:17:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 942583858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 942583858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722727041; cv=none; b=JO3u4R90NAYBkRhp85JhtVU4JcsgBRUpKKNpBUHTu++H2SxQRlQODmp+V1Vlum3qIi+Ig8MZQ7HuwBuI/hd1YOAAtdinuJvo6EmwwbzCpunvWl2QNPZCidEJKwhR+f7GNjyYP/qXT0vBcAjOkMFHrEm5QdDM6j4PJ1y+xvJ3yA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722727041; c=relaxed/simple; bh=3w6mpIfqnEwD2Rm0BXRvnnXbNP1evb4T0SQu2W2CfrU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=O4bTtrddOwpp7/QH2HwNgtyKS0pbWsoLqXYPNZw2AcpiY5P17VW2iRItspzwesc4salpS7CG8TyP/Fv71PfyhZhM7xkwN+kf0POiy9TpUqa22xbsOJgi4vvlGT982Pe1GB1dJVxnI3vO1+68DBp37z3SorsM2MDgmbgl0DV01PA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3FA6E60BC7; Sat, 3 Aug 2024 23:17:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B0DBC116B1; Sat, 3 Aug 2024 23:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722727037; bh=3w6mpIfqnEwD2Rm0BXRvnnXbNP1evb4T0SQu2W2CfrU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qjNaKwcX0a8r+zRev6G8gIdZdVEORm950JFHbnkIgAUlhQ0HSXcqMTaFXzQkxlyTH pN4Ugap9vSiWjwy2JG1DGr1emQq31Zs4wn18Uw3xY0tjn1aXswul25NsNhEHZQXXr2 00T0VOr3HfzTSMAeT0f0TLysBrLsq/7EVsW14pDyXrZnDI11qr9I4TU8BKsPpr8BY+ eK5Ad+fgbZ92DB2SIUIH48sJTEyB+CCP7KtWi8lk9JbsQU5VMnlkDeZzQez5XTWniW O69YzJTcAxqMrtFQnniad1I+jPh9HeQEV9N/CkRsn8NxAewdUcJ9aTL/2iPOPuU8OT 9Qg90pSLcXGOQ== Date: Sun, 4 Aug 2024 01:17:14 +0200 From: Alejandro Colomar To: gcc-patches@gcc.gnu.org Cc: Alejandro Colomar , Xavier Del Campo Romero , Gabriel Ravier , Martin Uecker , Joseph Myers , Jakub Jelinek Subject: [RFC v3 2/3] Merge definitions of array_type_nelts_top() Message-ID: <20240803231702.89150-3-alx@kernel.org> X-Mailer: git-send-email 2.45.2 References: <20240728141547.302478-1-alx@kernel.org> <20240803231702.89150-1-alx@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240803231702.89150-1-alx@kernel.org> X-Spam-Status: No, score=-9.9 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 __lengthof__(). Merge them, and provide the single definition in gcc/tree.{h,cc}, where it's available for __lengthof__(). 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 c1a371bc721..e6c1c63f872 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8099,7 +8099,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 3baeb8fa252..1f3ecff1a21 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -3071,19 +3071,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 a2c12204667..dd8eda84f9b 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 dcaccc4c362..cbbc7627ad6 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -3729,6 +3729,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 fdddbcf408e..a6c46440b1a 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4922,6 +4922,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);