From patchwork Mon Jun 3 03:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1942597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=fAUwDimO; 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 4Vsz9n4xyrz20Pb for ; Mon, 3 Jun 2024 13:05:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02D6E3949096 for ; Mon, 3 Jun 2024 03:05:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 2A3043947438; Mon, 3 Jun 2024 03:01:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A3043947438 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2A3043947438 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717383717; cv=none; b=JtTatOWciDByLRLN/nyMNpPKX93froAp3m8XkSVkenPRtj7GrahGJobGt/IBjjQVDSjC/leIPNfpUpNRbry20PVU1IuSfSvJH6QGubKSzDjOFryW6E3g4D/wjD92Fy3gLOFO1Ix9lHhCvIRLC3mrOBwPaEwKNOe490SU7o26/6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717383717; c=relaxed/simple; bh=7Y3OWGEJkNi2mkZk2EkWs4id1MWk6pmPBckfnz3gnWY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=fowr6CWHKuz4kYqN9h9/hJ2abKvTY/IWTR7SjCF8W9C8wGns8CRnKNdkE5OEjLtcOzvky98yaAfwV7jIDTIwvK3RVKlbhVgtjWTEF0xUZv7ZbWzIggA3SKjfVlVOz8Ncp7U0t3+QKKD6F3PbMf+j+x7kXXf0HrsBFCVHBiL3FxI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 4532RXsd020572; Mon, 3 Jun 2024 03:01:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=k8gB16v9OH8HpJQkw9Q2NxK2Z1n0gSlGwEw0i2g59rE=; b=fAUwDimOYo7XheZm57zvrPvQlH+8cI/RKeRMEec/nfsAipbD4geK+h1C6jKPRYbnfz9u Klq9+//NP/591x8oC1BtZslcvnYwNVjNzmusXpGTxkhQBpcsymBJ3MNaiG7lZSxlzmSL 7TASPXj1238r0OVdXImEd+hZOXAbaio3Ma7RyQUd1kSKyIkhte6lDpwglKgf3RFWHy8n vq33IqqrJOddbekOX2zbN4Sv23KcLg99o/OVZfm6GmO17hIv0f1XIn1o4ix1jKtduspL Yaz8Azu5qD47qf8wAlFT4F2pPn/+R2fL5/DXJe54vitDevMv8UDnZHqqaMK+zjMTQCHS Lg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yh52d81tj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 03:01:54 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 45331rMI006461; Mon, 3 Jun 2024 03:01:53 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yh52d81td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 03:01:53 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4532pEmo026600; Mon, 3 Jun 2024 03:01:53 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffmn9qc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 03:01:53 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45331nvm36307406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Jun 2024 03:01:51 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 150C420043; Mon, 3 Jun 2024 03:01:49 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 261E920040; Mon, 3 Jun 2024 03:01:48 +0000 (GMT) Received: from trout.aus.stglabs.ibm.com (unknown [9.40.194.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Jun 2024 03:01:47 +0000 (GMT) From: Kewen Lin To: gcc-patches@gcc.gnu.org Cc: linkw@linux.ibm.com, fortran@gcc.gnu.org, mikael@gcc.gnu.org, anlauf@gmx.de Subject: [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE Date: Sun, 2 Jun 2024 22:00:53 -0500 Message-ID: <1866bf880d193a7ff86b4673fe17a5d3e9ab6a96.1717134752.git.linkw@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 3B7yRXIkJKHFybK5j70keQBQBrE0F0uQ X-Proofpoint-GUID: CR0itFyaBTVT-X4fq6igd1CPMnNwmO7K X-Proofpoint-UnRewURL: 1 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-06-02_15,2024-05-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 spamscore=0 clxscore=1011 phishscore=0 adultscore=0 mlxlogscore=600 bulkscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406030025 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Joseph pointed out "floating types should have their mode, not a poorly defined precision value" in the discussion[1], as he and Richi suggested, the existing macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a hook mode_for_floating_type. To be prepared for that, this patch is to replace use of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in fortran with TYPE_PRECISION of {float,{,long_}double}_type_node. [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html gcc/fortran/ChangeLog: * trans-intrinsic.cc (build_round_expr): Use TYPE_PRECISION of long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE. * trans-types.cc (gfc_build_real_type): Use TYPE_PRECISION of {float,double,long_double}_type_node to replace {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE. --- gcc/fortran/trans-intrinsic.cc | 3 ++- gcc/fortran/trans-types.cc | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 912c1000e18..96839705112 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -395,7 +395,8 @@ build_round_expr (tree arg, tree restype) don't have an appropriate function that converts directly to the integer type (such as kind == 16), just use ROUND, and then convert the result to an integer. We might also need to convert the result afterwards. */ - if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE) + if (resprec <= INT_TYPE_SIZE + && argprec <= TYPE_PRECISION (long_double_type_node)) fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec); else if (resprec <= LONG_TYPE_SIZE) fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec); diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 8466c595e06..0ef67723fcd 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -873,13 +873,15 @@ gfc_build_real_type (gfc_real_info *info) int mode_precision = info->mode_precision; tree new_type; - if (mode_precision == FLOAT_TYPE_SIZE) + if (mode_precision == TYPE_PRECISION (float_type_node)) info->c_float = 1; - if (mode_precision == DOUBLE_TYPE_SIZE) + if (mode_precision == TYPE_PRECISION (double_type_node)) info->c_double = 1; - if (mode_precision == LONG_DOUBLE_TYPE_SIZE && !info->c_float128) + if (mode_precision == TYPE_PRECISION (long_double_type_node) + && !info->c_float128) info->c_long_double = 1; - if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128) + if (mode_precision != TYPE_PRECISION (long_double_type_node) + && mode_precision == 128) { /* TODO: see PR101835. */ info->c_float128 = 1;