From patchwork Thu Jul 1 15:40:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44070 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 956ED396EC94 for ; Thu, 1 Jul 2021 15:41:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 956ED396EC94 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625154088; bh=2TuKyrg5836LS4Fh8wevLtJmVcFWoM2P8WXz9ZSow5w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VoOs5686uFgjEDYaVwFsh28XDjY+CAcVtGLUDTYj6NlUo8MutvLvgTb2DJxjoVEuo b/pUEXarqwoQbXfU1wjTy4MAqDrOHr933yiKAZU2v39ViAgykXoYuoIyT7Ez1n6gnT wG3sltE4OozMrMt3zsw6pHBQBXd8USgiGArb5X3Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id B0BD6396EC8B for ; Thu, 1 Jul 2021 15:40:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0BD6396EC8B Received: by mail-pg1-x52a.google.com with SMTP id u14so6426113pga.11 for ; Thu, 01 Jul 2021 08:40:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=2TuKyrg5836LS4Fh8wevLtJmVcFWoM2P8WXz9ZSow5w=; b=aXIG8pROE4r+u86TYwscPlLAE33ltM5I/Djq9Tpk3b2z/WDPVysq7TAOtq8LP5XlHk CR+N2VFyp90B9Zc88atXtDRTa8OLytAqhrHFWjOKv6oaRah536aeZE3Q+LgrzCDLYgXV jlezGTQMPcvzuAUdiHHTFAatM4/iqomxoIKopQStyqcvxk2yiWnAj5VKISsH6hzg+z3A z3Xzo0Te5Nnwy9MrG07cN5xCHh5y6Dc7tDIHXkEv2QQy6uWGCCq0qVKxwKrXJdA+8OPO /Vmo1FizXo7I4D1Gj+qxJPudhMVGQp2bbGhJq+SgF6Gbz68WAD3BfwjMIK1T4qa9IGOv 4Kyg== X-Gm-Message-State: AOAM53338n6MXxHaLrbzo8ea2Q48Z7D/5Vib2BoiWDBKXh7OhTq5Tci7 Mv/aSLVQU3PqtKmgUHIYZjNgoWieY9w= X-Google-Smtp-Source: ABdhPJzvmze7zIFBe/Ij7uHz6Zv2WwfXW+8NBFfo+wzaKK7vzUFj1KuzlmxQq7WJcUs0QWl5s5jnow== X-Received: by 2002:a65:63ce:: with SMTP id n14mr199998pgv.273.1625154017730; Thu, 01 Jul 2021 08:40:17 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.39.115]) by smtp.gmail.com with ESMTPSA id fu23sm3850261pjb.15.2021.07.01.08.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 08:40:17 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 0F2F8C00A0 for ; Thu, 1 Jul 2021 08:40:16 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] soft-fp: Add __extendhfxf2 and __truncxfhf2 Date: Thu, 1 Jul 2021 08:40:16 -0700 Message-Id: <20210701154016.333268-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3032.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 1. Add __extendhfxf2 to return an IEEE half converted to IEEE extended. 2. Add __extendhfxf2 to truncate IEEE extended into IEEE half. These are needed by x86 _Float16: https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html support in GCC. --- soft-fp/extendhfxf2.c | 53 +++++++++++++++++++++++++++++++++++++++++++ soft-fp/truncxfhf2.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 soft-fp/extendhfxf2.c create mode 100644 soft-fp/truncxfhf2.c diff --git a/soft-fp/extendhfxf2.c b/soft-fp/extendhfxf2.c new file mode 100644 index 0000000000..1cb5fef947 --- /dev/null +++ b/soft-fp/extendhfxf2.c @@ -0,0 +1,53 @@ +/* Software floating-point emulation. + Return an IEEE half converted to IEEE extended. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define FP_NO_EXACT_UNDERFLOW +#include "soft-fp.h" +#include "half.h" +#include "extended.h" + +XFtype +__extendhfxf2 (HFtype a) +{ + FP_DECL_EX; + FP_DECL_H (A); + FP_DECL_E (R); + XFtype r; + + FP_INIT_EXCEPTIONS; + FP_UNPACK_RAW_H (A, a); +#if _FP_W_TYPE_SIZE < 64 + FP_EXTEND (E, H, 4, 1, R, A); +#else + FP_EXTEND (E, H, 2, 1, R, A); +#endif + FP_PACK_RAW_E (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/truncxfhf2.c b/soft-fp/truncxfhf2.c new file mode 100644 index 0000000000..688ad24523 --- /dev/null +++ b/soft-fp/truncxfhf2.c @@ -0,0 +1,52 @@ +/* Software floating-point emulation. + Truncate IEEE extended into IEEE half. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "soft-fp.h" +#include "half.h" +#include "extended.h" + +HFtype +__truncxfhf2 (XFtype a) +{ + FP_DECL_EX; + FP_DECL_E (A); + FP_DECL_H (R); + HFtype r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_SEMIRAW_E (A, a); +#if _FP_W_TYPE_SIZE < 64 + FP_TRUNC (H, E, 1, 4, R, A); +#else + FP_TRUNC (H, E, 1, 2, R, A); +#endif + FP_PACK_SEMIRAW_H (r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +}