From patchwork Wed Oct 18 17:03:57 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: 154982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4936689vqb; Wed, 18 Oct 2023 10:04:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcY8fGY6vvc9WJeJAXWYsqv49EuV0eC3Ino+YeJpTzw1GxPS7uBsQ2QuroEun1eBGT3YAO X-Received: by 2002:ac8:5f48:0:b0:41c:b790:2fbf with SMTP id y8-20020ac85f48000000b0041cb7902fbfmr4308269qta.67.1697648671376; Wed, 18 Oct 2023 10:04:31 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1697648671; cv=pass; d=google.com; s=arc-20160816; b=msaZ9E4kLioAl76QOW7ZAqYdceu6ObFv5gNed1x7nD9gFKyZA0AsG/EU1MTSPownOg y+gGzxU+PCCu+v1/qPxvouctGajW6vLaguEpJ6c0G+waPRqjEWF7HpdTHwLhNpKLP9T5 JAboK4I/WyVdkQLeUBD8pJHYzGnJIW8Ck2VzL1Dx3SCxna32EDomS2eOrS6PLAirSLwp ZGJpg51lPz2YVmKt8WsIdGFsAgwaCTfdlGZNQq6/kCN7p6kvOHdbOcd7hfs3hxSPtNOc CazvW2s8pz0O5TZydJkb13PDbB/eRK8pmKNAf4pc+1mkbbNhty3rIU58g/goK8rBhzBx 9A1A== 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=m6dzTPG62aIwnNVdLTjQOu815fvU/rmmuConKzigNZs=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=VjYmaSSESmvcONNt4ZWB12sBO1t/Smm1TcQgAfuhTb09GpfK3T+GHbQIB0H6hw7L4u W8kyXE+Au3IU1vtfAZ4bIMFmW6rLi3aj75vgoaq7CsHSzmTPXCfd36PPPDLB5ZNQpEr8 EN99zDN01M53JMuTcbxntVY4bIg1864Y8/Ybi5oQEF+NxxKtmc3ZdU58w0pCi8YAO99C vQ2xAkXoL6+aZqfC8AD6TWvEKORa+By6VhIf0ZOb+MDMXj5XrabNXTbZxGy2BT1LrTWb 2HiVi57JLGSNSrSKYsXTLjWhGbjSydYDNPljgDcHYqJ2nxwfZck+ElYu55dXWzT5Uog0 XSHg== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@gjlay.de header.s=strato-dkim-0002 header.b=ZmxrLtFU; 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 g10-20020ac87f4a000000b00417dd658ebesi219182qtk.686.2023.10.18.10.04.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:04:31 -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=ZmxrLtFU; 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 063603858023 for ; Wed, 18 Oct 2023 17:04:31 +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 [85.215.255.20]) by sourceware.org (Postfix) with ESMTPS id DFADA3858D33 for ; Wed, 18 Oct 2023 17:03:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFADA3858D33 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 DFADA3858D33 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=85.215.255.20 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697648643; cv=pass; b=fOI08RW2eeGdQ+0oPs4whFqge/CRm2pI2zQinLtcgUwWIOxtjHUhHbxT0c80OlpBe5ClrCyqw4CsCBLDbjHE4E9R8UMToQkadQALYXX4gv1/nA6fRCLGMve6i7pJuSd4kc5RH6CgYfLzoob8firrtwHrjE85/Wzws4247mEzAlA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697648643; c=relaxed/simple; bh=BHBH5r8GKAKystEusWUXXYrFRyMsLowXfI9p0zfwga8=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version:To: From:Subject; b=IhVb7YubwL2q1qiy+gcTQrGkcF3mQi/oaFdSVLBvnvfNBWwGUD9j3oXjJunBkPU0dzkMeZs0YtWv4UdUMazLp3JNkQ/sOFf5JCLGZfT/pPlgbagnWoFhGvwtkLIxa/wMFon+WPEfmceqGH/AZxQWNVEgVGKLsVv+IwhAyW7+Hkg= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1697648638; cv=none; d=strato.com; s=strato-dkim-0002; b=QQzlYjpz0xvebKJQpWRXdLZhfdqfZNYfYfBq38Q6hMugDVdptuJQYA8BvlapS5dHjy FUMyBz/VLUGfiHMqGGD0mP96r7bgcYFeYc+JjHT6vosmd3pAdK4yNFYtVKYd1nDfwKjC OjA2XUxmWknuz2nlQyl++V4eSTx5zMc230uEoFa8UNVYghsOqtWPTYlRh4KB4VrQPh2w jz+fSqrz7pTrhdNf887ah5MGpO6jvpoXpuUhFCVHhiiFai4RBL8qCzsbS29aJ7+hSYJX bFLdplTNwYYIpDmr5opQMfkY/yDBeR3vDWo1rmrHhikt1jFlN+gW+G2MQ0Vnp6laKHsh mUnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1697648638; s=strato-dkim-0002; d=strato.com; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=m6dzTPG62aIwnNVdLTjQOu815fvU/rmmuConKzigNZs=; b=KfRXEOKOYw98ap11DFZm7eXdlUbWi2d/AsmpfKnfCYuuQWoz/2bicu8r6V5ti7OcwY JgPNoDAyd+arTL4vVHFHq/SuPxH7XIfcjx/AegsC8YZmtQZUJEiYjTSfPGVyBkNOUZZL JMyCFGUvsv6OkI0eDyrKpYQ3naJhwoE6NC6/0/2elxc22ROaW0RFLtClYcVkMSFlUFDh CDLLRDdy7JV5uRQwV+xnAvTZH2ON5Niyc66NNKjsj3oyHo7DwONBo2408rwKLvKlfnAw nGRcoKc9fhIz/jFDXwSadyOmknD0Atd1bULEqKpWwSAfULa53Ehc4jViK65gUzLkZyIh 1W4Q== 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=1697648638; s=strato-dkim-0002; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=m6dzTPG62aIwnNVdLTjQOu815fvU/rmmuConKzigNZs=; b=ZmxrLtFUmwTfT6Rc6EVen6r+An0RH36rPXccT9GAiX9cf4EBkuG1p9qO4u+WfdEdTx d2r2vZx8cYTy+L+wnljaZV/ko2MDdJbDsqULfF6or0TxD1IRn3ulJv7FSJxfj8BiWR5p bp48AJI5tyUxKShGXL9WD33O2vFZtHZET2rnD8vGXr7XvYuV56p4+GSq/ihipFmUPwOA q1MVAy8/vIpA83CxKPilD8R5X6ECmacZCJ8UU/elXsEANc7vD9IFyPy1xF4Rnm79gir8 dfluPUHV1KJ0cvY0I/qzrjKusea1zXR26I9y0lWQK/cCbgYZeBOmZVwDG+ggq2a/NzKZ Muig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1697648638; s=strato-dkim-0003; d=gjlay.de; h=Subject:From:To:Date:Message-ID:Cc:Date:From:Subject:Sender; bh=m6dzTPG62aIwnNVdLTjQOu815fvU/rmmuConKzigNZs=; b=jmije2/z5LRZmDqBHucAKRcuWfdIheu4dMVZ/um7FDS3XoTZDm5mEuxLIX7R7u/vdP 4FYhgBJAVUcX3GLJklCQ== 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 e316f3z9IH3wGxU (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Wed, 18 Oct 2023 19:03:58 +0200 (CEST) Message-ID: <4c64ce1d-790e-6c66-9824-5b31b9a4b662@gjlay.de> Date: Wed, 18 Oct 2023 19:03:57 +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] LibF7: Implement a function that was missing for devices without MUL. X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SCC_5_SHORT_WORD_LINES, 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: 1780113653557593364 X-GMAIL-MSGID: 1780113653557593364 This implements the worker function for double multiplication for devices without MUL instruction. Johann --- LibF7: Implement mul_mant for devices without MUL instruction. libgcc/config/avr/libf7/ * libf7-asm.sx (mul_mant): Implement for devices without MUL. * asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation. * t-libf7 (F7_ASM_FLAGS): Add -g0. diff --git a/libgcc/config/avr/libf7/asm-defs.h b/libgcc/config/avr/libf7/asm-defs.h index 4cfd3e61cbb..a50260a162f 100644 --- a/libgcc/config/avr/libf7/asm-defs.h +++ b/libgcc/config/avr/libf7/asm-defs.h @@ -134,14 +134,14 @@ ..regno = 0 .irp reg, \ - X, x, XL, xl, Xl, xL, x, x \ + X, x, XL, xl, Xl, xL, x, x, \ Y, y, YL, yl, Yl, yL, y, y, \ Z, z, ZL, zl, Zl, zL, z, z .ifc \reg,\dst - ..dst = (..regno / 8) + 26 + ..dst = 2 * (..regno / 8) + 26 .endif .ifc \reg,\src - ..src = (..regno / 8) + 26 + ..src = 2 * (..regno / 8) + 26 .endif ..regno = ..regno + 1 .endr diff --git a/libgcc/config/avr/libf7/libf7-asm.sx b/libgcc/config/avr/libf7/libf7-asm.sx index 5df167fe73c..4505764c126 100644 --- a/libgcc/config/avr/libf7/libf7-asm.sx +++ b/libgcc/config/avr/libf7/libf7-asm.sx @@ -1067,6 +1067,100 @@ DEFUN mul_mant ENDF mul_mant #endif /* F7MOD_mul_mant_ && MUL */ +#if defined F7MOD_mul_mant_ && ! defined (__AVR_HAVE_MUL__) + #define AA TMP + #define A0 13 + #define A1 A0+1 + #define A2 A0+2 + #define A3 A0+3 + #define A4 A0+4 + #define A5 r26 + #define A6 r27 + #define BB ZERO + #define Bits r29 + #define Bytes r28 + +DEFUN mul_mant + do_prologue_saves 7 + bst r18, 0 ; T = 1: Don't round. + ;; Save result address for later. + push r25 + push r24 + ;; Load 1st operand mantissa. + wmov r30, r22 + clr AA + LDD A0, Z+0+Off + LDD A1, Z+1+Off + LDD A2, Z+2+Off + LDD A3, Z+3+Off + LDD A4, Z+4+Off + LDD A5, Z+5+Off + LDD A6, Z+6+Off + ;; Let Z point one past .mant of the 2nd input operand. + wmov r30, r20 + adiw r30, Expo + + ;; Clear the result mantissa. + .global __clr_8 + XCALL __clr_8 + + ;; Loop over the bytes of B's mantissa from highest to lowest. + ;; "+1" because we jump into the loop. + ldi Bytes, 1 + F7_MANT_BYTES + + ;; Divide one operand by 2 so that the result mantissa won't overflow. + ;; This is accounted for by "Carry = 1" below. + ldi Bits, 1 + rjmp .Loop_entry + +.Loop_bytes: + ld BB, -Z + ;; Loop over the bits of B's mantissa from highest to lowest. + ldi Bits, 8 +.Loop_bits: + lsl BB + brcc .Lnext_bit + + ADD CA, AA + adc C0, A0 + adc C1, A1 + adc C2, A2 + adc C3, A3 + adc C4, A4 + adc C5, A5 + adc C6, A6 + +.Lnext_bit: +.Loop_entry: + LSR A6 + ror A5 + ror A4 + ror A3 + ror A2 + ror A1 + ror A0 + ror AA + + dec Bits + brne .Loop_bits + + dec Bytes + brne .Loop_bytes + + ;; Finally... + + pop ZL + pop ZH + + ;; The result has to be left-shifted by one (multiplied by 2) in order + ;; to undo the division by 2 of the 1st operand. + ldi Carry, 1 + F7call normalize.maybe_round.store_with_flags + + do_epilogue_restores 7 +ENDF mul_mant +#endif /* F7MOD_mul_mant_ && ! MUL */ + #if defined (F7MOD_div_) diff --git a/libgcc/config/avr/libf7/t-libf7 b/libgcc/config/avr/libf7/t-libf7 index 30aa280d11e..f17e67e8523 100644 --- a/libgcc/config/avr/libf7/t-libf7 +++ b/libgcc/config/avr/libf7/t-libf7 @@ -86,7 +86,7 @@ F7_C_FLAGS += $(F7_FLAGS) \ -fno-tree-loop-optimize \ -fno-tree-loop-im -fno-move-loop-invariants -F7_ASM_FLAGS += $(F7_FLAGS) +F7_ASM_FLAGS += $(F7_FLAGS) -g0 $(patsubst %, f7_c_%.o, $(CALL_PROLOGUES)) \ : F7_C_FLAGS += -mcall-prologues