From patchwork Thu Jun 25 15:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1317020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=KkVsggqg; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49t44f6qPJz9sRW for ; Fri, 26 Jun 2020 01:41:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5790C388B01B; Thu, 25 Jun 2020 15:41:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5790C388B01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593099693; bh=swwOnLp3eUIOZkVUKIme2rxGujSBZFr1gZHosTt/gtU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KkVsggqgTNzWrHa/G/ZmGcvSWITgAAmPkCIlUn0NdY/tg/1kwKVhajskWM+XcHElL GKh4sxib5d2f2C7SH+jgaRYalKvh2nVcnhEpDZFodhvEjeHtdNVQPiGE8u8qZQ/wUd /NyE1SBcZRkNib/t2sqhK1jWJ5dULV8WVtcWVo8Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050::465:202]) by sourceware.org (Postfix) with ESMTPS id 7B8E4388A833 for ; Thu, 25 Jun 2020 15:41:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B8E4388A833 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 49t44R5DzQzQlK7; Thu, 25 Jun 2020 17:41:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id 9LMFD3RYyOHf; Thu, 25 Jun 2020 17:41:24 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Move d_signed_type and d_unsigned_type to types.cc Date: Thu, 25 Jun 2020 17:41:17 +0200 Message-Id: <20200625154117.2308161-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -0.91 / 15.00 / 15.00 X-Rspamd-Queue-Id: 866B417FE X-Rspamd-UID: 9977c9 X-Spam-Status: No, score=-16.5 required=5.0 tests=BAYES_00, 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch moves d_signed_type and d_unsigned_type to types.cc. These two functions are not tied to the language-specific part of the front-end in any way. Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards Iain. --- gcc/d/ChangeLog: * d-lang.cc (d_gimplify_expr_p): Make static. (d_parse_file): Likewise. (d_signed_or_unsigned_type): Move to types.cc. (d_unsigned_type): Likewise. (d_signed_type): Likewise. * d-tree.h (d_unsigned_type): Change the location in file. (d_signed_type): Likewise. * types.cc (d_signed_or_unsigned_type): Moved from d-lang.cc. (d_unsigned_type): Likewise. (d_signed_type): Likewise. --- gcc/d/d-lang.cc | 47 ++--------------------------------------------- gcc/d/d-tree.h | 4 ++-- gcc/d/types.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 2c474f8adea..6412c1c204c 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -880,7 +880,7 @@ empty_modify_p (tree type, tree op) /* Implements the lang_hooks.gimplify_expr routine for language D. Do gimplification of D specific expression trees in EXPR_P. */ -int +static int d_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p ATTRIBUTE_UNUSED) { @@ -1024,7 +1024,7 @@ d_add_entrypoint_module (Module *entry, Module *root) /* Implements the lang_hooks.parse_file routine for language D. */ -void +static void d_parse_file (void) { if (global.params.verbose) @@ -1507,49 +1507,6 @@ d_type_for_size (unsigned bits, int unsignedp) return 0; } -/* Return the signed or unsigned version of TYPE, an integral type, the - signedness being specified by UNSIGNEDP. */ - -static tree -d_signed_or_unsigned_type (int unsignedp, tree type) -{ - if (TYPE_UNSIGNED (type) == (unsigned) unsignedp) - return type; - - if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type)) - return unsignedp ? d_ucent_type : d_cent_type; - - if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type)) - return unsignedp ? d_ulong_type : d_long_type; - - if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type)) - return unsignedp ? d_uint_type : d_int_type; - - if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type)) - return unsignedp ? d_ushort_type : d_short_type; - - if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type)) - return unsignedp ? d_ubyte_type : d_byte_type; - - return signed_or_unsigned_type_for (unsignedp, type); -} - -/* Return the unsigned version of TYPE, an integral type. */ - -tree -d_unsigned_type (tree type) -{ - return d_signed_or_unsigned_type (1, type); -} - -/* Return the signed version of TYPE, an integral type. */ - -tree -d_signed_type (tree type) -{ - return d_signed_or_unsigned_type (0, type); -} - /* Implements the lang_hooks.types.type_promotes_to routine for language D. All promotions for variable arguments are handled by the D frontend. */ diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h index 4ae38d187d7..b4b832f9ad8 100644 --- a/gcc/d/d-tree.h +++ b/gcc/d/d-tree.h @@ -598,8 +598,6 @@ extern d_tree_node_structure_enum d_tree_node_structure (lang_tree_node *); extern struct lang_type *build_lang_type (Type *); extern struct lang_decl *build_lang_decl (Declaration *); extern tree d_pushdecl (tree); -extern tree d_unsigned_type (tree); -extern tree d_signed_type (tree); extern void d_keep (tree); /* In decl.cc. */ @@ -672,6 +670,8 @@ extern void add_stmt (tree); extern void build_function_body (FuncDeclaration *); /* In types.cc. */ +extern tree d_unsigned_type (tree); +extern tree d_signed_type (tree); extern bool valist_array_p (Type *); extern bool empty_aggregate_p (tree); extern bool same_type_p (Type *, Type *); diff --git a/gcc/d/types.cc b/gcc/d/types.cc index b8984a50ff0..0d05e4d82b3 100644 --- a/gcc/d/types.cc +++ b/gcc/d/types.cc @@ -42,6 +42,49 @@ along with GCC; see the file COPYING3. If not see #include "d-tree.h" +/* Return the signed or unsigned version of TYPE, an integral type, the + signedness being specified by UNSIGNEDP. */ + +static tree +d_signed_or_unsigned_type (int unsignedp, tree type) +{ + if (TYPE_UNSIGNED (type) == (unsigned) unsignedp) + return type; + + if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type)) + return unsignedp ? d_ucent_type : d_cent_type; + + if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type)) + return unsignedp ? d_ulong_type : d_long_type; + + if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type)) + return unsignedp ? d_uint_type : d_int_type; + + if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type)) + return unsignedp ? d_ushort_type : d_short_type; + + if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type)) + return unsignedp ? d_ubyte_type : d_byte_type; + + return signed_or_unsigned_type_for (unsignedp, type); +} + +/* Return the unsigned version of TYPE, an integral type. */ + +tree +d_unsigned_type (tree type) +{ + return d_signed_or_unsigned_type (1, type); +} + +/* Return the signed version of TYPE, an integral type. */ + +tree +d_signed_type (tree type) +{ + return d_signed_or_unsigned_type (0, type); +} + /* Return TRUE if TYPE is a static array va_list. This is for compatibility with the C ABI, where va_list static arrays are passed by reference. However for every other case in D, static arrays are passed by value. */