From patchwork Tue Oct 17 09:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 154021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4018834vqb; Tue, 17 Oct 2023 02:53:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwQejIH66hQunF2nv8sqIwk4ynvwRxehv4NJMUMDhZgOI0cvpoetyaFHvxQChM/D9fRrl0 X-Received: by 2002:a05:622a:1b91:b0:418:1aa2:6b1a with SMTP id bp17-20020a05622a1b9100b004181aa26b1amr1870488qtb.46.1697536382183; Tue, 17 Oct 2023 02:53:02 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1697536382; cv=pass; d=google.com; s=arc-20160816; b=sWE3lxwFKzMfwS7tbtcyWsiNWMAGnaMzz/o2E3N0un0P2lCyBg5xAYeLvJBtQx+Obj rMP8OsbeHOg27hwIo0UAgRIwMuja1zPqsJ3tvsuOd3Aw+i7Hemi5fYwtw54DtUqhtg/Q 7IZCzfLKuViz4n3TzhLJfCU7ozYac+PqT5jbrkFqt/bEvee5oem9VmvH7pHcyaA9jgYS ERbmM+HV80LYOpht7xhenvjeHUvzayHcAVHm9NWvG8tfyoI3knJ772owAqL9pritQHYB zcg8lCkNrNHIvQJz+whONmbkeBwEqUsVO7zLJj6iHfEpocfgQXdAjkLKvilr62+Rjai7 G2PQ== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=QrIk4cp3LhUrpMsm4vGZh+1IUQHHJd1EkTnXEm6wik0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=cA6iXDY5a7NbMveAcby/mZZ+lJhNhMF08sEM9B/vM7P3aFO/8twMS8Fi5vU5nFNVYo Gp6IPgsxX0MFVtwWZV48mUkvTxEDMV/+gn9HhSXck65VqMAR48vjxSNU65P0YOHmgVRb fgkEV8OqAys1tR4zrjoq0BgL/IxCVWd0mQ0ORn+u7t/OHLpI9POU9NgB0KiWniyDQ95p 4eAEoNRca2o+T698v/UYezIzUvHB2qe/oEPJ2mxq/qE/lPX05MtJhCequCrnnLQ+Fyb5 b4IQ5rmG7TsZ71rFm4x4ueHbSjupEe0q9rhpQMS1XdgraLOQgveTYRAvhsVhMSZWo33R iwHw== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@gjlay.de header.s=strato-dkim-0002 header.b=gbyRtDtU; dkim=neutral (no key) header.i=@gjlay.de header.s=strato-dkim-0003; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 17-20020ac85951000000b0041805eb94ffsi865632qtz.206.2023.10.17.02.53.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 02:53:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gjlay.de header.s=strato-dkim-0002 header.b=gbyRtDtU; dkim=neutral (no key) header.i=@gjlay.de header.s=strato-dkim-0003; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EAF043858C01 for ; Tue, 17 Oct 2023 09:53:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [81.169.146.216]) by sourceware.org (Postfix) with ESMTPS id 7289F3858C54 for ; Tue, 17 Oct 2023 09:52:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7289F3858C54 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gjlay.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7289F3858C54 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=81.169.146.216 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697536344; cv=pass; b=j7QrU0fpDAiNtaoZAbE7wAa/sFfJr46PHEbq6UYa+iAE/aX2IN23GoUTiV19/h6W0kHgCOHsoIcuX1/hmiCZNyq1X3tS3ozZV/iYfr17+XwKu1WJ1B1s2Peh4H9qM9w0MDM2BSQy857/n863DBum6zXDy+m3uTLXE2OWkNKI/GI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697536344; c=relaxed/simple; bh=5W/mSM7RSI4Xpk4hiweXbQ6n32rPWaQjlH09wy5i7gU=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To: From:Subject; b=KqaboZy01DD9wwhkdJXpgUv5suwDXNxZbZH842KoVpnALq4qN7ANfS7YV/PuxijoPv0lBJ9XdPozJ/sMPS3rhF0VY8STPBqdbi1VI8BGvmWwRQno1BMH1c+TEGqz0ZDmSYDfAdlkhE1Y7mdRkyGFNNbMJ1+YcRDSokrchNOMSp8= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1697536338; cv=none; d=strato.com; s=strato-dkim-0002; b=rORhanzQ11J3TTmXyhtCEP2+iqliykq2+G5B8HOpqQl0CuDwHK2dQr2hBVMnJzgo0y hVTQLd4npRddujTN3FVN6wMMkwgrftV+irt0yg3JTsOWrcfxsBze/Gkkf6BKvUDxlUSl QJ0P+7dlFo7Zm66LWMVnAOvoodZkZHTm7BTRuvFmC0u4Bq2ayBW2CpX+88mzcK5b92nq PE+EMG06z5Aq0R5yuBOPjezaC+mmKgG/AoBt0aINOi3ZnSv/YogkdohhqYvJDd8mJLjR 4FAMuHHmHkW57cPy6U0ZJTeGerYgauIvYoeFHaJDyS2Qq03FO1gwsSm/TlVMPNfgPQf+ dAfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1697536338; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=QrIk4cp3LhUrpMsm4vGZh+1IUQHHJd1EkTnXEm6wik0=; b=D9OpLkWXtD7tJgDU1GCJoWSFsRinxtA5ECwYQ+cyrq19MEV09yIG8oqOw9Bc78CEGU P8J0QhXjSkSoHSXTFgNyX2mbcES28TbIbv29yCcrr8DJXU4UCtxAlgsMmtbmcQtChEct wip7Gmyghjcj0c7paKH8YHmhiZxArg/XPwVK971NwfvPPXJ1vYpc6lNq7rU5+PNPKrIE 5BLLfDU/GrE8hyLq/IYURYrPAZaKCigSN6O4F/1Lr3loiWfKb7As1dSe0bxw4ET9wNWR cafahYVRrQMEdKNzTGlKeu6u+RDnpBxpyKxJ5I/3YuQpvoes1SCuNBXeRf2ie5GeyrVS UeFA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1697536338; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=QrIk4cp3LhUrpMsm4vGZh+1IUQHHJd1EkTnXEm6wik0=; b=gbyRtDtU3/9BqFjB4CvBaVPMG2LGCo4U18KWG7/Wpqv9MVrxWHmmhAd7KGD0skgntd DsdsA997kHnTAn6ojfi+WN8rKPVLGIloMYcsJ6HT161EzAGftWxzs4GAAPPwk5HVDoQs /zl2SeFKqupEFxfXf5SdjlNGBRAex3PRLakLmcWV7Ig7HWfeMP3BHnC0SfcYB+ypAXsC 6Syp1KXj1t+MzvrxUVk61/FyUKfQRohihkmNrUPG9cErmn1Ho3NYxAUzEpGGFBdxNNNG 2ryPRl5rQ1BtTjcpFFWezFzbpBKldiOyanVrK3M/fuv7flPS3/sOAfDgirybJEzDerw6 79dw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1697536338; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=QrIk4cp3LhUrpMsm4vGZh+1IUQHHJd1EkTnXEm6wik0=; b=1HdZbca5noqjt7LKX9m8X2XSpwESrXAXKEFyilc4MrrD7cLlNcJM7/LD4PE2EVqHwc 4tFQZN873lFV1DAj4FCQ== X-RZG-AUTH: ":LXoWVUeid/7A29J/hMvvT3koxZnKT7Qq0xotTetVnKkSjsSjo3O/MHXSzlaR/rBp" Received: from [192.168.2.102] by smtp.strato.de (RZmta 49.9.0 DYNA|AUTH) with ESMTPSA id e316f3z9H9qI813 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Tue, 17 Oct 2023 11:52:18 +0200 (CEST) Message-ID: <1eff6955-3ddf-7d83-eb49-c56d47aa6637@gjlay.de> Date: Tue, 17 Oct 2023 11:52:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: gcc-patches@gcc.gnu.org From: Georg-Johann Lay Subject: [avr,committed] Implement fma, fmal. X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779995909520094563 X-GMAIL-MSGID: 1779995909520094563 This commit implements fma and fmal which were missing from LibF7. Johann --- LibF7: Implement fma / fmal. libgcc/config/avr/libf7/ * libf7.h (F7_SIZEOF): New macro. * libf7-asm.sx: Use F7_SIZEOF instead of magic number "10". (F7MOD_D_fma_, __fma): New module and function. (fma) [-mdouble=64]: Define as alias for __fma. (fmal) [-mlong-double=64]: Define as alias for __fma. * libf7-common.mk (F7_ASM_PARTS): Add D_fma. diff --git a/libgcc/config/avr/libf7/libf7-asm.sx b/libgcc/config/avr/libf7/libf7-asm.sx index 8fbd66bd290..5df167fe73c 100644 --- a/libgcc/config/avr/libf7/libf7-asm.sx +++ b/libgcc/config/avr/libf7/libf7-asm.sx @@ -283,8 +283,8 @@ DEFUN copy cp XL, ZL cpc XH, ZH breq 9f - adiw XL, 10 - adiw ZL, 10 + adiw XL, F7_SIZEOF + adiw ZL, F7_SIZEOF set bld ZERO, 1 bld ZERO, 3 ; ZERO = 0b1010 = 10. @@ -312,8 +312,8 @@ DEFUN copy_P st X+, TMP dec ZERO brne .Loop - sbiw X, 10 - sbiw Z, 10 + sbiw X, F7_SIZEOF + sbiw Z, F7_SIZEOF ret ENDF copy_P #endif /* F7MOD_copy_P_ */ @@ -1328,6 +1328,58 @@ DEFUN sqrt_approx #undef Carry +#ifdef F7MOD_D_fma_ +_DEFUN __fma + DALIAS fma + LALIAS fmal + +#define n_pushed 4 +#define n_frame (2 * F7_SIZEOF) + + do_prologue_saves n_pushed, n_frame + ;; Y = FramePointer + 1 + adiw Y, 1 + + ;; FP + 1 = (f7_t) arg1 + wmov r16, Y + ;; The double argument arg1 is already in R18[]. + XCALL F7_NAME (set_double_impl) + + ;; The double argument arg2 is in R10[]. Move it to R18[]. + wmov r18, r10 + wmov r20, r12 + wmov r22, r14 + ;; R16, R17 are clobbered. Fetch them from where prologue_saves put them. + ldd r24, Y + n_frame + 3 ; Saved R16 + ldd r25, Y + n_frame + 2 ; Saved R17 + ;; FP + 1 + 10 = (f7_t) arg2 + subi r16, lo8 (-F7_SIZEOF) + sbci r17, hi8 (-F7_SIZEOF) + XCALL F7_NAME (set_double_impl) + + wmov r24, Y ; &arg1 + wmov r22, r16 ; &arg2 + XCALL F7_NAME (Imul) ; arg1 *= arg2 + + ;; The 3rd double argument arg3 was passed on the stack. Move it to R18[], + ;; Don't use f7_set_pdouble() because that function is unused (for now). + .irp n, 0, 1, 2, 3, 4, 5, 6, 7 + ldd 18+\n, Y + n_frame + n_pushed + PC_SIZE + \n + .endr + XCALL F7_NAME (set_double_impl) + + wmov r24, Y ; &arg1 + wmov r22, r16 ; &arg2 + XCALL F7_NAME (Iadd) ; arg1 += arg2 + + wmov r24, Y ; &arg1 + XCALL F7_NAME (get_double) + + do_epilogue_restores n_pushed, n_frame +_ENDF __fma +#endif /* F7MOD_D_fma_ */ + + #ifdef F7MOD_D_fabs_ _DEFUN __fabs DALIAS fabs @@ -1493,7 +1545,7 @@ DEFUN call_dd ; WHAT = R13 = 3 wmov r14, Z #define n_pushed 4 -#define n_frame 10 +#define n_frame F7_SIZEOF do_prologue_saves n_pushed, n_frame ;; Y = FramePointer + 1 @@ -1565,7 +1617,7 @@ DEFUN call_ddd ret #define n_pushed 4 -#define n_frame 20 +#define n_frame (2 * F7_SIZEOF) call.2: do_prologue_saves n_pushed, n_frame @@ -1576,9 +1628,8 @@ DEFUN call_ddd ;; First double argument is already in R18[]. XCALL F7_NAME (set_double_impl) ;; FP + 11 = (f7_t) arg2 - wmov r16, Y - subi r16, lo8 (-10) - sbci r17, hi8 (-10) + subi r16, lo8 (-F7_SIZEOF) + sbci r17, hi8 (-F7_SIZEOF) ;; Move second double argument to R18[]. wmov r18, r10 wmov r20, r12 diff --git a/libgcc/config/avr/libf7/libf7-common.mk b/libgcc/config/avr/libf7/libf7-common.mk index e417715a7e5..d541b48ff3c 100644 --- a/libgcc/config/avr/libf7/libf7-common.mk +++ b/libgcc/config/avr/libf7/libf7-common.mk @@ -22,7 +22,7 @@ F7_ASM_PARTS += addsub_mant_scaled store load F7_ASM_PARTS += to_integer to_unsigned clz normalize_with_carry normalize F7_ASM_PARTS += store_expo sqrt16 sqrt_approx div -F7_ASM_PARTS += D_class +F7_ASM_PARTS += D_class D_fma F7_ASM_PARTS += D_isnan D_isinf D_isfinite D_signbit D_copysign D_neg D_fabs F7_ASM_PARTS += call_dd call_ddd diff --git a/libgcc/config/avr/libf7/libf7.h b/libgcc/config/avr/libf7/libf7.h index b50e6e218ba..2b6beac0df8 100644 --- a/libgcc/config/avr/libf7/libf7.h +++ b/libgcc/config/avr/libf7/libf7.h @@ -29,6 +29,7 @@ #define F7_MANT_BYTES 7 #define F7_MANT_BITS (8 * F7_MANT_BYTES) +#define F7_SIZEOF (1 + F7_MANT_BYTES + 2) /* Using the following GCC features: -- Unnamed structs / unions (GNU-C)