From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2071.outbound.protection.outlook.com [40.107.20.71]) by sourceware.org (Postfix) with ESMTPS id 6FE50396D823 for ; Fri, 13 May 2022 17:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6FE50396D823 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=G5ZGV8jab2nV39i8e0gPwCSE23MeD4nx4nDuM7SQkOBvPTUgmoHQKrNJvL84scT+I0xfJJxGYKu0AnPX443jsTKmvPJPK71vpjwSEm3VtE/dqtkkk7oZ73j22gs6gAPQxzSpEXZrBovaUSCbYIWaODxCaJYVPLnWnOKVM+99owlVKMsrLnaHPr43HlcWuxyVXR8vcJtTPgYOOl/Xd/XcxjzJg/nW3eV+BibC7YqC2eHaRV/plusE57iItyzr+nCPPt3T4baQtxoI1cpmgzH7BNQHmCPgCNEWX6UaHdqY3CqEDmO2n3J8kjCv2cIafdzWJlSl+yitem9+R3FO0KsU2A== 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=9yfUquxKTMoM7+lu/J6ewZT6LxjBK9zLrlj+LzaSQq4=; b=dVW5JYGi87GHMTS8mSMrRn+DUh/dv+xawn6axmUnmDCvDUbICOuiFylrjqWIQT+zimhKC+6V4tNEtlsedRetYlULr7joQ1MygWsbBLP0iewstHQ+V7P8Q/cT4dgZyUd+FI+RSSp0h2lQuStqsYA2fbF6mLxNJOldSyCWJ3z0jvTv0TSSJgt7F83H09fHo/j32LWUPTRuKTX2jMJmkLk8S1KS0zHbYRGhkwChjAqK1e8DdXC6SUrJkNoQbLV7Ll99/j9cI0Q2M1M7ssMkvv5PSPOYjPqPGlCEuTFBOEzruK5pAC0rEAEvtI5fHA0RVwXuQSwCYVoru7qG34ple3s1mw== 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 AM6PR05CA0021.eurprd05.prod.outlook.com (2603:10a6:20b:2e::34) by AM0PR08MB5154.eurprd08.prod.outlook.com (2603:10a6:208:15d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14; Fri, 13 May 2022 17:53:01 +0000 Received: from AM5EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::69) by AM6PR05CA0021.outlook.office365.com (2603:10a6:20b:2e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.16 via Frontend Transport; Fri, 13 May 2022 17:53:01 +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 AM5EUR03FT055.mail.protection.outlook.com (10.152.17.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 17:53:00 +0000 Received: ("Tessian outbound 07c1c99345b0:v119"); Fri, 13 May 2022 17:53:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d33c27852da1eb0e X-CR-MTA-TID: 64aa7808 Received: from 9d93ac98699b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8A0676A6-F607-4A39-AB67-A7EFF8A693E8.1; Fri, 13 May 2022 17:52:53 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9d93ac98699b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 13 May 2022 17:52:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AfVHIVrOTViBLeLHfs2RZh1SpbTiocCSvieCVfN1BRVzyXCPQtzTOZ5EfOY7QM8hQLeGP6jRiMT5k4N2nEht4NbyUvHuocMsZcvv9RGa8rc1t9nlKcQdeUuAyG8QPJjDuWPKNUOgPuQEELaDFWnjZ/u1fYI2wxCR2aZHiwjVWhg4wGvQvV9+n+OIwMCE3VZCLpMPrwXeP6ZqamW8+v7ZRv9sN5/OU4de5///1YS7EFdLgjb53uzeFilPJCLkf1HjhJkQHqvQGdB7xsw6zaJcyveDxlkrO/TluY4PdCmefC8Gl6Lxuw9E+RLOsVpZ4+yqtYmLSuzpoEtY0TBs+vc2BQ== 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=9yfUquxKTMoM7+lu/J6ewZT6LxjBK9zLrlj+LzaSQq4=; b=EvdMYUao0mBrK0n9JzXDRCz7YCWCbJAlWcoWWLZcj2/cdiM+YJODp/l1x3vli9DeMyAEuXwVeJVrOqASvTt5GOD8wTZ4BHHY/g5WbhwXxAnXRULzt/ZeFg9geIf5y6rj3zvG9vJ+83bO31JPmv9/5twIQNoF6r5D3bV6/cx76mf9XSc7Eu+eJLK9rw8QnJN9hmdbjvgJsZHpPQFA3lyeiswrZFe1qSYfeh+aubblcMY4AyarYcibaus4eGlWkR67DHbcBudPalNT1APBN0vnr0+UuT8SeuD8hIwrh8ynl+si1yXvExxBV8xticnhKJs+MWFl8sBWpqoWODrxoHyOxw== 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 AM6PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:20b:6e::29) by PAXPR08MB7261.eurprd08.prod.outlook.com (2603:10a6:102:210::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Fri, 13 May 2022 17:52:51 +0000 Received: from AM5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:6e:cafe::1f) by AM6PR02CA0016.outlook.office365.com (2603:10a6:20b:6e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14 via Frontend Transport; Fri, 13 May 2022 17:52:51 +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 AM5EUR03FT016.mail.protection.outlook.com (10.152.16.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 17:52:51 +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; Fri, 13 May 2022 17:52:56 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Fri, 13 May 2022 17:52:50 +0000 Received: from e129018.arm.com (10.57.33.200) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.27 via Frontend Transport; Fri, 13 May 2022 17:52:56 +0000 From: Christophe Lyon To: Subject: [PATCH v2 09/10] libgcc: Add support for HF mode (aka __fp16) in libbid Date: Fri, 13 May 2022 19:52:53 +0200 Message-ID: <20220513175253.356875-1-christophe.lyon@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509143507.239804-10-christophe.lyon@arm.com> References: <20220509143507.239804-10-christophe.lyon@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 43346df7-24a1-4d62-c0ec-08da35096bf5 X-MS-TrafficTypeDiagnostic: PAXPR08MB7261:EE_|AM5EUR03FT055:EE_|AM0PR08MB5154: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: D+ugIPs1OU3bLCXp7LmLgDhsFc0mhje3roEF8rEuCcrIlkDZHvObO/QjWjcmq931+OSjfT/GnIy4qJSgiHpgdyx/1NfEHD51YVXIiBIgo7GC4C78RNEsI+CCLCS4L6fdG92NLv/jYnnD8oIsHRxV903gPzhQSh2jR8jLPMH3LBY0GvfXFcPNPx4Mp4MhLljL74BfKMmbuGudRM5bLHHqFLap9eSY+l/OrSPlkteEGkHbJm6IQXTXiTmfsVIV5gWQ40hjRO4RT7Zzc76CcxQrTuGJrbFAEzcfG8/aXktYj19X/lTqoXjXFCT/SJ6JclUgRYK0wWI4Bu9w3ENpBmuFzu9+wnXz3+ccHBTFxntgTfahrJYzO87FN4KEFhgq/YT2ftdYpebtMM6+LVNJHx537NRuhcO4Yb+9NnhUAvScuC0RTqn25OyggHvMEX57m8cGwVVQP7ngwlwqRDj+VFdPh1aESJDR4D+VPKiVf+48G6OrkAQwy4D9lhsN3F0/rUvHql8q1EW+H1y6F5aj3dkWMAwHIG4o6NieRHBAnXzcUhVSn1pVXXAtfKlmtPaiPjY/yJApNiTbK0zU+3Q5hy3+GTMjx5DK68VvlVyRRBOX4QtmcgTtOeirhn8Ksnk+DD556dhmYtjeeM7MTkfS7Y92ju0BhXz8oE9jQL4c7kXsLsfAoner0ZPLOssOlakQTGW6Ellx5Ver9JG19QZH104TQhPyeD87sq5g26dZ8SUAfwqHJAjKaHj5AsjmovwCUkhWCdPo6dMfFjuz1oRduQmvGuznf10W1YhxtV8izmL6/mkb0G/QjKEtsfQ3LfnDzApM2NJ6TIBuyv8RThpaqDFvV1lJ1W3r23Uzaah6cGDB6sY= 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)(40470700004)(46966006)(36840700001)(83380400001)(4326008)(8676002)(36756003)(70586007)(5660300002)(70206006)(36860700001)(44832011)(6916009)(316002)(8936002)(30864003)(508600001)(2616005)(2906002)(47076005)(84970400001)(6666004)(426003)(336012)(186003)(26005)(7696005)(1076003)(40460700003)(86362001)(356005)(82310400005)(81166007)(2004002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7261 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 60bcd917-79e3-4716-35da-08da3509662e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ux+0T1Y6zaFkuj9HhCgYyatH3h12gg58rBSlDvBq7hsq0MoWSJ27dxLlAlPZrZOFPPZr5Mk0PkmEcthC6zDQoq09eTWMs2d96rJjyxYa5SKr+Fz9X2VJ9iZVG7qkcEa7fXtvKaZHG9BCFBeZ9ddW3sp14ZpWeKz2Hx0i4hosKk7hdGEsnLCOvyp0mYKR/4z/wmbVRBy+0Dy2x02z7Jz74lgE9L7Bh9j8bjqYNav6093cq7A5SuwdVe3yf4XKRXEcYQ4Uj47HFc5UTcgpzF8A4VWDaMcV3d4rHUNHTl1iACIzb7jkRX1GOCd5r50/HaQVHDgYSbSOF/2lX5nhj+tXHx2c3nKmG5PYPTw/o5Pt6zGccepIsYVD4V2MRRk9f0VbxI3PShKXYYgb0oRk1ayYKiQ16VGGXLlFUgqEPQGm94PnMZFsxy+PL9Hd9Sf37+jeAAGo6vkAW11FSjvQhILQN9Y1PBUGXZN3fo+Oj9agI3vAoXcoB2okG94LuFgx0EGq7bmgtyWQ8CxeowBhS7YtBwnELdEqoBnDzv0cjPquBcvpSv961KNw+SdvAi+5FIjm2l6XXke1jWf6GPANHs3KuAJZJxQcrN+4Q/897Ae82WaZdEruELcK4WDkpaTU35s/TcZQnfSSizrnOniVTetW+/jcZhKQU66NtHNrBrUbJk//WnRV/DhyCIn5F0GSqe/5zPbhO3jI4Ri5Muc2x6Cxfl/Nw35PjpnL56I/PaJn5Z0Rn3co52NXWK1f074zyWB5LXA4wJjnsp1WvQw+yGtOnqgQuQ5NPJmOf4jJb4NHM0mCl/U5Kb6rvoK2ctVWThuG 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)(40470700004)(36840700001)(46966006)(2906002)(1076003)(426003)(81166007)(86362001)(2616005)(8676002)(84970400001)(83380400001)(70206006)(70586007)(82310400005)(40460700003)(186003)(316002)(4326008)(336012)(47076005)(6916009)(44832011)(7696005)(30864003)(8936002)(6666004)(36860700001)(5660300002)(508600001)(36756003)(26005)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 17:53:00.7793 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43346df7-24a1-4d62-c0ec-08da35096bf5 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: AM5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5154 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-List-Received-Date: Fri, 13 May 2022 17:53:06 -0000 This patch adds support for trunc and extend operations between HF mode (__fp16) 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 __fp16 and _Decimal* formats. The patch also adds two executable tests for AArch64, to make sure the right functions are used, available (link phase) and functional. 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.target/aarch64/convert-dfp-2.c: New test. * gcc.target/aarch64/convert-dfp.c: New test. --- .../gcc.target/aarch64/convert-dfp-2.c | 42 +++++++++++++ .../gcc.target/aarch64/convert-dfp.c | 60 +++++++++++++++++++ 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, 358 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/convert-dfp-2.c create mode 100644 gcc/testsuite/gcc.target/aarch64/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.target/aarch64/convert-dfp-2.c b/gcc/testsuite/gcc.target/aarch64/convert-dfp-2.c new file mode 100644 index 00000000000..ebbbc649455 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/convert-dfp-2.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-options "-save-temps" } */ + +/* Test conversions from DFP to smaller types. */ + +_Decimal32 var32; +_Decimal64 var64; +_Decimal128 var128; +__fp16 var16; + +void foo32 (_Decimal32 param32) +{ + var16 = param32; +} + +void foo64 (_Decimal64 param64) +{ + var16 = param64; + var32 = param64; +} + +void foo128 (_Decimal128 param128) +{ + var16 = param128; + var32 = param128; + var64 = param128; +} + +int main () +{ + foo32 (var32); + foo64 (var64); + foo128 (var128); + return 0; +} + +/* { dg-final { scan-assembler-times {\tbl\t__bid_truncsdhf} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_truncddhf} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_truncddsd2} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_trunctdhf} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_trunctdsd2} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_trunctddd2} 1 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/convert-dfp.c b/gcc/testsuite/gcc.target/aarch64/convert-dfp.c new file mode 100644 index 00000000000..cd5ada46e3d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/convert-dfp.c @@ -0,0 +1,60 @@ +/* { dg-do run } */ +/* { dg-options "-save-temps" } */ + +/* Test conversions to/from DFP values. */ + +extern void abort (); + +_Decimal32 var32 = 1.2df; + +int foo32 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, __fp16 param16) +{ + return (param32 == var32) + + (param64 == var32) + + (param128 == var32) + /* Small enough relative difference? */ + + ((((_Decimal32)param16 - var32) / var32) < 0.002df); +} + +_Decimal64 var64 = 1.2dd; + +int foo64 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, __fp16 param16) +{ + return (param32 == var64) + + (param64 == var64) + + (param128 == var64) + /* Small enough relative difference? */ + + ((((_Decimal64)param16 - var64) / var64) < 0.002dd); +} + +_Decimal128 var128 = 1.2dl; + +int foo128 (_Decimal32 param32, _Decimal64 param64, _Decimal128 param128, __fp16 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, (__fp16)1.2) != 4) + abort (); + + if (foo64 (1.2df, 1.2dd, 1.2dl, (__fp16)1.2) != 4) + abort (); + + if (foo128 (1.2df, 1.2dd, 1.2dl, (__fp16)1.2) != 4) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendsddd2} 2 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendsdtd2} 2 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendddtd2} 2 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendhfsd} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendhfdd} 1 } } */ +/* { dg-final { scan-assembler-times {\tbl\t__bid_extendhftd} 1 } } */ 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); -- 2.25.1