From patchwork Mon May 16 13:47:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 54035 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7BCA384B12A for ; Mon, 16 May 2022 13:48:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7BCA384B12A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652708932; bh=kLUBSYWVww99BHQa6FKsA03hqlvvrqA+MeTd/UBjQ5k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jaZd4cKYZFHxzAwC5QgO6KxDt8sqAAeZ67ZvgjcTnE6JvV21824mz8kCnsQmtY7ZQ B8d0+DShW6mFKRuTF7LxhzeR+FEQJGtw7b8W+BnaTRnUneywTTCYRY1oOEyUrfoQIR 7l51gfHzODz+WPpvxDjRBD8SEfgr3cubhCnRe9pk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by sourceware.org (Postfix) with ESMTPS id 3FC6E385734B for ; Mon, 16 May 2022 13:48:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3FC6E385734B ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HzQYhegbfU2WyIR7l+zJl5PXFz3bUQuX3p8Prjg5bv2MKthLK18arYiY2GsxzvVfyw1b7otn19fMxE5RLLM4grmi17KOdgb0KXQ9++nPi42ywHBPmSKnFlWGrWFgLx5tLg1dRFb2jvlWQO6nOEuryaKqEVEI3fHSwdqfqHyZGKLVsMkJ2Lq5T098CHia4O+41hXsG2MMNnck22ur/UNR7+TBfEQRMDyhKSnHPPR3cedbrC/yUqTIvwSNC5Dic0sPEGYvGCftHTiGBvpuk46gdxR4TuJVhhIUDjmFZFT+y9G7IuRU5NhmufveTSaS88m59As/zmZhwer4JifV7WklMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kLUBSYWVww99BHQa6FKsA03hqlvvrqA+MeTd/UBjQ5k=; b=He3KoIc77j+rEQ+MmOCvk2+JO0f/pbxWlfh7hhded4mxlh952LKXI87h/Eqzua5drLQwiv+uwc62SD6ffb6y2v6Ny+Kj2ta74DdvO6Q7ghcIbUazhzAqdiiDZ92dl2k0428Of+JocNvAVRmopT0z+y550NBRAZjS3AfaANwLVHDcPfyyJvNIwC8dTftthj5O/ZCg+MR79qAKzgqmnMLa8ahjy5XtS++Q0XioYeo0higLh1WfADe+me9wKuvdemjPDQ7Pok7tTBQ7ZKV1AlHXJROQMPVDRWO4H+alaSTGMXuoZniPPhT1+/VuMpOBmVE3z2mUDL/bHv4mJsytN8XvXA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8P189CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::24) by VI1PR0802MB2414.eurprd08.prod.outlook.com (2603:10a6:800:b2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Mon, 16 May 2022 13:48:12 +0000 Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::dd) by AS8P189CA0011.outlook.office365.com (2603:10a6:20b:31f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Mon, 16 May 2022 13:48:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Mon, 16 May 2022 13:48:11 +0000 Received: ("Tessian outbound 6580ae46f51e:v119"); Mon, 16 May 2022 13:48:11 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c06da6248457676 X-CR-MTA-TID: 64aa7808 Received: from 9d57a30b46df.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2694BBD3-9D25-4786-8A7F-ED5C968482A7.1; Mon, 16 May 2022 13:48:04 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9d57a30b46df.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 16 May 2022 13:48:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OgfOzxOdsyhBQO9IqWNAiLxKr6Uos2jPXT6+bZAB5QA/EIltcDUS2cS1onQUJXdMpR1g+cibvxmEZOgvWP0rUcb0qzX6jvS89br459UWVsn1u2PbANl3o09qfJV1dBzo5VNwDXd+uRWlBiXcHkiPG4zJfvYfd0SEUpGbfcXe5b9Ld2kfbbIMx99Lr0kbKPIYhCQx2ZgvlesR4pv5baIfREqf8/jvuuic6BYKBYiyDlEzAWCPKy4SgZAmtw61pLDWOal1IAeFPd/RjgN//FGt4WvES3ype9KkjqTXWEBshsvsatu8OS+XeiCN0WM4WO7QpkmFjHa9yaYscm0Bfp2ygg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kLUBSYWVww99BHQa6FKsA03hqlvvrqA+MeTd/UBjQ5k=; b=l1YkGFRRfWgkED4J0HX0HmTJsaXqY4rhpbfDagVrYRZpash8JIsWNPspb5dcH1hQTA0n5pnJpeWyxW/InzCLgnZlM/VxlqBmLfJjART3EdG6lNoBaNKO6qsOw1sr3vxQp64gUjziG5QL4mrccKhTWQJUUEnW+7QybixqJVEkFTeKMlujAg6FGzr08eJOmg66mfidCg5YJgodYZ4HpANElXXVv4Gg43ez/oOp9InS+z9Cnz9Lx4sR1lM9+AwPJoOVGf/tviY9zGk1QP9QIHsUSeCVtMZna1RpxUhsNR3eSLifaBsN/2+RrHlhPlhX3hV6SNzbPw9+Zp+aohwXuB01Hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from AS9PR0301CA0017.eurprd03.prod.outlook.com (2603:10a6:20b:468::33) by AM5PR0801MB1780.eurprd08.prod.outlook.com (2603:10a6:203:39::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Mon, 16 May 2022 13:48:02 +0000 Received: from VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:468:cafe::5d) by AS9PR0301CA0017.outlook.office365.com (2603:10a6:20b:468::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18 via Frontend Transport; Mon, 16 May 2022 13:48:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT051.mail.protection.outlook.com (10.152.19.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Mon, 16 May 2022 13:48:01 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.27; Mon, 16 May 2022 13:48:03 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.27; Mon, 16 May 2022 13:47:56 +0000 Received: from e129018.arm.com (10.57.33.73) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Mon, 16 May 2022 13:48:03 +0000 To: Subject: [PATCH v3 09/10] libgcc: Add support for HF mode (aka _Float16) in libbid Date: Mon, 16 May 2022 15:47:53 +0200 Message-ID: <20220516134753.152672-1-christophe.lyon@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: b4a74263-330e-4808-0fee-08da3742b7c0 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1780:EE_|VE1EUR03FT029:EE_|VI1PR0802MB2414:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: udqQPtCVg5UHS7wky4jpvKzaE5QJB03B9g3g+6OFndjDTH0MTiiLxomzVuqfYFVtBjl/u78c1utuAw1L8luYJtWmZifrmMqpRIZt/tg1whFyXYjmbHrs7JLoHJNXff/M3IiaVFCVlzJ6h/jqu0uZ41/mnC6mknFKak4KMIKIJvX3cEvS2tNEU64lhreolI3Totfrug92FJigDCz1+6hp5/6XMLFzSrVK6VnYOhhpATOwXlWlUcXN21wRIekm9gDV18iJ3nSBNt532FWcBD9cD3hR9q1KYeQlWH0/LjJoy3bgEoecVZFMn7BZZLKCz6kPkRP/V6PjwjKTIDlAmF3XUHBP7E3EOtBUkro4w8QpxKha3E8xKny5a1EcslIj+quiu7KK+iui+dVAmIAbqjoabOJ+VjQ3Wdv8wWvXEm+M/LsRzOG1xo7bagZiVSkA05gXcLyWkgtytFphOC9OFrbmh9WQ/n6tXWtsz+XB9A7eqUkt33sxskBu5pVcejuSijubaanY/pf7FP2PK0L1WgVG2JUSGMRCS0uOxV+1smR6vHYvLv7PG5GmbwQthg7AOPsl+eY0oK7UiTFt5ljQ/maN6aUahtkHiqSLHkk7j+DMkjWCA9YSrBvFAQMTi4Zej0FML+ZUptAA6ASHaeNGk/20PUETVoe8d73mcmO0VgsG4JO2R3Sy1PfBXr4w9sgbMg0ovJ5JOsKSwWi9dePG0T8jc9vqgGstVVUW73HTF0ZtDlKCzgAqGTQAfYd9ubulWi5nbIRckktyunZF5k/KNdtCzTj9acazIrXNwhbsEaceugYtt+b8TiwluZmm2f7Yc4qOQ3Y/hKSj93RmicM6VtKX9fME07wX8pEQ+XQK0wmqCMSLh2ALFCMy/pTHETK4oLuR X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(44832011)(70206006)(4326008)(70586007)(8676002)(508600001)(5660300002)(8936002)(30864003)(186003)(1076003)(40460700003)(36756003)(2616005)(26005)(86362001)(356005)(336012)(47076005)(426003)(7696005)(6666004)(81166007)(2906002)(83380400001)(36860700001)(82310400005)(84970400001)(6916009)(316002)(2004002)(21314003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1780 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 30528903-76ee-4d22-bf65-08da3742b1a4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CurW8azW7Q6KnLeCx94MHelWgSLIcI/Suw6hAfnaRkgm9KdH0qh6ZYgi+fH3j2j2cp27eZ24pa2/W+U4yxP8KJbBjejHk/llDC8unBpu12G0gqZVB8Wg9ID+kM9PtlZ6uHr2f/obofDYmVKWt/kpFU5ybWZ3K0V1cUYIHUdfKnx5tUL7O6aETBd3L+ccbumT+NN4684RR144rG5xuNkq8hY0eOEgKuCxLCbsLYvwp9zOlnwqGm+007VqYh8+LLwu5Wkx3dOGVC/2pNoz2aIgeTOrm0KkhzGulJkA58yWAtf67F8cI2t6NTLx8cPuo4ULctHvby+ktSXsPZcIEA2LtTlOM8xMyil/MHQKjeK1jHZySdJ5deK25l/1bsNU7o3ogqah6xly2OUvt/JzqeEzF/tcE6hZPwUNjYRwDM++N+ofS40uKlQJxgk8wOMO/GKy3Hgcpmrp9jRX2BhAKl9LB+GQfwsMhZz0ma076I2DSwohW54ey/g3W+FjFcdBuQoeGr35Tn8TUhqlg1nB0ZMr457CAtsz/0kTst3PrpD+tFcdfy2sP0BNOzwTFxF184ES6J2p1DmFs6ziWZwZh/TgWzLz8YB0m77+Xm5LuxTYZJ7h7pfwS4A+/CycZFwrxfTJRENbD9rFYmUhzuFVP8jWrPZNZhHY+3/afG/yDncAMGpiWy5InHvGvKSZPIapj7dlYsLnrUfMussDstqA38bCITJSZ1EeQmfBDT0UsZLRaEmtEGasxJuaeU8q7aDter7uxcSyU7cwDPN1R0TNdzhGnCfzoaa/SRNGDE0ejsSLcyyfnND1Kyhk/yA6NIHUbk1Y1sHLr5E4CyttzWsL3N3WOuEjik5Wq2X98eu7vKijCqk= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(81166007)(6666004)(2906002)(7696005)(47076005)(426003)(336012)(84970400001)(82310400005)(316002)(6916009)(36860700001)(83380400001)(186003)(1076003)(40460700003)(70206006)(4326008)(8676002)(70586007)(44832011)(30864003)(5660300002)(508600001)(8936002)(26005)(36756003)(86362001)(2616005)(21314003)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2022 13:48:11.5127 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4a74263-330e-4808-0fee-08da3742b7c0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2414 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christophe Lyon via Gcc-patches From: Christophe Lyon Reply-To: Christophe Lyon Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds support for trunc and extend operations between HF mode (_Float16) and Decimal Floating Point formats (_Decimal32, _Decimal64 and _Decimal128). For simplicity we rely on the implicit conversions inserted by the compiler between HF and SD/DF/TF modes. The existing bid*_to_binary* and binary*_to_bid* functions are non-trivial and at this stage it is not clear if there is a performance-critical use case involving _Float16 and _Decimal* formats. The patch also adds two executable tests, to make sure the right functions are called, available (link phase) and functional. Tested on aarch64 and x86_86. The number of symbol matches in the testcases includes the .global XXX to avoid having to match different call instructions for different targets. 2022-05-04 Christophe Lyon libgcc/ChangeLog: * Makefile.in (D32PBIT_FUNCS): Add _hf_to_sd and _sd_to_hf. (D64PBIT_FUNCS): Add _hf_to_dd and _dd_to_hf. (D128PBIT_FUNCS): Add _hf_to_td _td_to_hf. libgcc/config/libbid/ChangeLog: * bid_gcc_intrinsics.h (LIBGCC2_HAS_HF_MODE): Define according to __LIBGCC_HAS_HF_MODE__. (BID_HAS_HF_MODE): Define. (HFtype): Define. (__bid_extendhfsd): New prototype. (__bid_extendhfdd): Likewise. (__bid_extendhftd): Likewise. (__bid_truncsdhf): Likewise. (__bid_truncddhf): Likewise. (__bid_trunctdhf): Likewise. * _dd_to_hf.c: New file. * _hf_to_dd.c: New file. * _hf_to_sd.c: New file. * _hf_to_td.c: New file. * _sd_to_hf.c: New file. * _td_to_hf.c: New file. gcc/testsuite/ChangeLog: * gcc.dg/torture/convert-dfp-2.c: New test. * gcc.dg/torture/convert-dfp.c: New test. --- gcc/testsuite/gcc.dg/torture/convert-dfp-2.c | 45 ++++++++++++++ gcc/testsuite/gcc.dg/torture/convert-dfp.c | 63 ++++++++++++++++++++ libgcc/Makefile.in | 9 ++- libgcc/config/libbid/_dd_to_hf.c | 38 ++++++++++++ libgcc/config/libbid/_hf_to_dd.c | 36 +++++++++++ libgcc/config/libbid/_hf_to_sd.c | 36 +++++++++++ libgcc/config/libbid/_hf_to_td.c | 36 +++++++++++ libgcc/config/libbid/_sd_to_hf.c | 38 ++++++++++++ libgcc/config/libbid/_td_to_hf.c | 38 ++++++++++++ libgcc/config/libbid/bid_gcc_intrinsics.h | 30 +++++++++- 10 files changed, 364 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/convert-dfp-2.c create mode 100644 gcc/testsuite/gcc.dg/torture/convert-dfp.c create mode 100644 libgcc/config/libbid/_dd_to_hf.c create mode 100644 libgcc/config/libbid/_hf_to_dd.c create mode 100644 libgcc/config/libbid/_hf_to_sd.c create mode 100644 libgcc/config/libbid/_hf_to_td.c create mode 100644 libgcc/config/libbid/_sd_to_hf.c create mode 100644 libgcc/config/libbid/_td_to_hf.c diff --git a/gcc/testsuite/gcc.dg/torture/convert-dfp-2.c b/gcc/testsuite/gcc.dg/torture/convert-dfp-2.c new file mode 100644 index 00000000000..3e4ecb57ba6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/convert-dfp-2.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-require-effective-target float16_runtime } */ +/* { dg-require-effective-target dfprt } */ +/* { dg-options "-save-temps" } */ +/* { dg-add-options float16 } */ + +/* Test conversions from DFP to smaller types. */ + +_Decimal32 var32; +_Decimal64 var64; +_Decimal128 var128; +_Float16 var16; + +void __attribute__ ((__noinline__)) foo32 (_Decimal32 param32) +{ + var16 = param32; +} + +void __attribute__ ((__noinline__)) foo64 (_Decimal64 param64) +{ + var16 = param64; + var32 = param64; +} + +void __attribute__ ((__noinline__)) foo128 (_Decimal128 param128) +{ + var16 = param128; + var32 = param128; + var64 = param128; +} + +int main () +{ + foo32 (var32); + foo64 (var64); + foo128 (var128); + return 0; +} + +/* { dg-final { scan-assembler-times {\t__bid_truncsdhf} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_truncddhf} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_truncddsd2} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_trunctdhf} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_trunctdsd2} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_trunctddd2} 2 { target { dfp_bid } } } } */ diff --git a/gcc/testsuite/gcc.dg/torture/convert-dfp.c b/gcc/testsuite/gcc.dg/torture/convert-dfp.c new file mode 100644 index 00000000000..ec136896ca7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/convert-dfp.c @@ -0,0 +1,63 @@ +/* { dg-do run } */ +/* { dg-require-effective-target float16_runtime } */ +/* { dg-require-effective-target dfprt } */ +/* { dg-options "-save-temps" } */ +/* { dg-add-options float16 } */ + +/* Test conversions to/from DFP values. */ + +extern void abort (); + +_Decimal32 var32 = 1.2df; + +int __attribute__ ((__noinline__)) foo32 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, _Float16 param16) +{ + return (param32 == var32) + + (param64 == var32) + + (param128 == var32) + /* Small enough relative difference? */ + + ((((_Decimal32)param16 - var32) / var32) < 0.002df); +} + +_Decimal64 var64 = 1.2dd; + +int __attribute__ ((__noinline__)) foo64 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, _Float16 param16) +{ + return (param32 == var64) + + (param64 == var64) + + (param128 == var64) + /* Small enough relative difference? */ + + ((((_Decimal64)param16 - var64) / var64) < 0.002dd); +} + +_Decimal128 var128 = 1.2dl; + +int __attribute__ ((__noinline__)) foo128 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, _Float16 param16) +{ + return (param32 == var128) + + (param64 == var128) + + (param128 == var128) + /* Small enough relative difference? */ + + ((((_Decimal128)param16 - var128) / var128) < 0.002dl); +} + +int main() +{ + if (foo32 (1.2df, 1.2dd, 1.2dl, (_Float16)1.2) != 4) + abort (); + + if (foo64 (1.2df, 1.2dd, 1.2dl, (_Float16)1.2) != 4) + abort (); + + if (foo128 (1.2df, 1.2dd, 1.2dl, (_Float16)1.2) != 4) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-times {\t__bid_extendsddd2} 3 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_extendsdtd2} 3 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_extendddtd2} 3 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_extendhfsd} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_extendhfdd} 2 { target { dfp_bid } } } } */ +/* { dg-final { scan-assembler-times {\t__bid_extendhftd} 2 { target { dfp_bid } } } } */ diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 09b3ec8bc2e..1fe708a93f7 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -677,7 +677,8 @@ D32PBIT_FUNCS = _addsub_sd _div_sd _mul_sd _plus_sd _minus_sd \ _si_to_sd _di_to_sd _usi_to_sd _udi_to_sd \ _sd_to_sf _sd_to_df _sd_to_xf _sd_to_tf \ _sf_to_sd _df_to_sd _xf_to_sd _tf_to_sd \ - _sd_to_dd _sd_to_td _unord_sd _conv_sd + _sd_to_dd _sd_to_td _unord_sd _conv_sd \ + _hf_to_sd _sd_to_hf D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ _eq_dd _ne_dd _lt_dd _gt_dd _le_dd _ge_dd \ @@ -685,7 +686,8 @@ D64PBIT_FUNCS = _addsub_dd _div_dd _mul_dd _plus_dd _minus_dd \ _si_to_dd _di_to_dd _usi_to_dd _udi_to_dd \ _dd_to_sf _dd_to_df _dd_to_xf _dd_to_tf \ _sf_to_dd _df_to_dd _xf_to_dd _tf_to_dd \ - _dd_to_sd _dd_to_td _unord_dd _conv_dd + _dd_to_sd _dd_to_td _unord_dd _conv_dd \ + _hf_to_dd _dd_to_hf D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ _eq_td _ne_td _lt_td _gt_td _le_td _ge_td \ @@ -693,7 +695,8 @@ D128PBIT_FUNCS = _addsub_td _div_td _mul_td _plus_td _minus_td \ _si_to_td _di_to_td _usi_to_td _udi_to_td \ _td_to_sf _td_to_df _td_to_xf _td_to_tf \ _sf_to_td _df_to_td _xf_to_td _tf_to_td \ - _td_to_sd _td_to_dd _unord_td _conv_td + _td_to_sd _td_to_dd _unord_td _conv_td \ + _hf_to_td _td_to_hf ifeq ($(enable_decimal_float),bid) ifneq ($(D32PBIT),) diff --git a/libgcc/config/libbid/_dd_to_hf.c b/libgcc/config/libbid/_dd_to_hf.c new file mode 100644 index 00000000000..5e58288391e --- /dev/null +++ b/libgcc/config/libbid/_dd_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_truncddhf (_Decimal64 x) { + HFtype res; + union decimal64 ux; + + ux.d = x; + res = __bid64_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/_hf_to_dd.c b/libgcc/config/libbid/_hf_to_dd.c new file mode 100644 index 00000000000..f85100e24f8 --- /dev/null +++ b/libgcc/config/libbid/_hf_to_dd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal64 +__bid_extendhfdd (HFtype x) { + union decimal64 res; + SFtype xsf = x; + res.i = __binary32_to_bid64 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_hf_to_sd.c b/libgcc/config/libbid/_hf_to_sd.c new file mode 100644 index 00000000000..285b80c6e05 --- /dev/null +++ b/libgcc/config/libbid/_hf_to_sd.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal32 +__bid_extendhfsd (HFtype x) { + union decimal32 res; + SFtype xsf = x; + res.i = __binary32_to_bid32 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_hf_to_td.c b/libgcc/config/libbid/_hf_to_td.c new file mode 100644 index 00000000000..99b661ec727 --- /dev/null +++ b/libgcc/config/libbid/_hf_to_td.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +_Decimal128 +__bid_extendhftd (HFtype x) { + union decimal128 res; + SFtype xsf = x; + res.i = __binary32_to_bid128 (xsf); + return (res.d); +} +#endif diff --git a/libgcc/config/libbid/_sd_to_hf.c b/libgcc/config/libbid/_sd_to_hf.c new file mode 100644 index 00000000000..e4e3125d49b --- /dev/null +++ b/libgcc/config/libbid/_sd_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_truncsdhf (_Decimal32 x) { + HFtype res; + union decimal32 ux; + + ux.d = x; + res = __bid32_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/_td_to_hf.c b/libgcc/config/libbid/_td_to_hf.c new file mode 100644 index 00000000000..c4ebe586db0 --- /dev/null +++ b/libgcc/config/libbid/_td_to_hf.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#include "bid_conf.h" +#include "bid_functions.h" +#include "bid_gcc_intrinsics.h" + +#if LIBGCC2_HAS_HF_MODE || BID_HAS_HF_MODE +HFtype +__bid_trunctdhf (_Decimal128 x) { + HFtype res; + union decimal128 ux; + + ux.d = x; + res = __bid128_to_binary32 (ux.i); + return (res); +} +#endif diff --git a/libgcc/config/libbid/bid_gcc_intrinsics.h b/libgcc/config/libbid/bid_gcc_intrinsics.h index b0a23debc15..15c050764ac 100644 --- a/libgcc/config/libbid/bid_gcc_intrinsics.h +++ b/libgcc/config/libbid/bid_gcc_intrinsics.h @@ -31,6 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "tm.h" #include "libgcc_tm.h" +#ifdef __LIBGCC_HAS_HF_MODE__ +#define LIBGCC2_HAS_HF_MODE 1 +#else +#define LIBGCC2_HAS_HF_MODE 0 +#endif + #ifdef __LIBGCC_HAS_XF_MODE__ #define LIBGCC2_HAS_XF_MODE 1 #else @@ -43,6 +49,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LIBGCC2_HAS_TF_MODE 0 #endif +#ifndef BID_HAS_HF_MODE +#define BID_HAS_HF_MODE LIBGCC2_HAS_HF_MODE +#endif + #ifndef BID_HAS_XF_MODE #define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE #endif @@ -53,6 +63,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* Some handy typedefs. */ +#if LIBGCC2_HAS_HF_MODE +typedef float HFtype __attribute__ ((mode (HF))); +#endif /* LIBGCC2_HAS_HF_MODE */ typedef float SFtype __attribute__ ((mode (SF))); typedef float DFtype __attribute__ ((mode (DF))); #if LIBGCC2_HAS_XF_MODE @@ -98,6 +111,12 @@ typedef __attribute__ ((aligned(16))) struct #endif #endif +#if BID_HAS_HF_MODE +#ifndef HFtype +#define HFtype _Float16 +#endif +#endif + #ifndef SFtype #define SFtype float #endif @@ -110,8 +129,7 @@ typedef __attribute__ ((aligned(16))) struct #ifndef XFtype #define XFtype long double #endif - -#endif /* IN_LIBGCC2 */ +#endif #if BID_HAS_TF_MODE #ifndef TFtype @@ -249,6 +267,14 @@ extern _Decimal128 __bid_extendxftd (XFtype); extern int isinfd32 (_Decimal32); extern int isinfd64 (_Decimal64); extern int isinfd128 (_Decimal128); +#if BID_HAS_HF_MODE +extern _Decimal32 __bid_extendhfsd (HFtype); +extern _Decimal64 __bid_extendhfdd (HFtype); +extern _Decimal128 __bid_extendhftd (HFtype); +extern HFtype __bid_truncsdhf (_Decimal32); +extern HFtype __bid_truncddhf (_Decimal64); +extern HFtype __bid_trunctdhf (_Decimal128); +#endif #endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ extern void __dfp_set_round (int);