From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id 5152B3857352 for ; Sat, 12 Nov 2022 09:13:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5152B3857352 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wxmIXt2FQyYJUuzukHkX7QKSW6fJqFPPrklPsFRXf3o=; b=Ja10uFCbrF+eHeMY57P1aQM1RY 7i4XmXRh1/iYDo928ZEAx5bfhmzEQ5VFvZwBnR41WkqUCBDLRD+b6ninA93zdlBqrVwHY3BQV9pT9 C+ylDJSd0j6GkkxzxaH3MxuLJuW6EKvFvo29BleVVa00wDRF/5+xRoeKvsWTACa/GNAVRXLW2z5c0 6BwqFida+xSuV+2N+N+Yol3h4nQPSg9giGOTKl4fWzzeABKN/EBaBNUpw/fH34S+U8JGK0l7SZSaL zxFyKPzuo2YDlFCOYclwyC4hZdq+M00Rksr9SzS99yAj7ML9qQw7GT8N6bd0+lvgHBcXh7xyT5fS3 S6wtOM1Q==; Received: from [95.87.234.74] (port=58410 helo=kendros.lan) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1otma7-000C1a-LW; Sat, 12 Nov 2022 11:13:46 +0200 From: Dimitar Dimitrov To: gdb-patches@sourceware.org Cc: Dimitar Dimitrov Subject: [PATCH] sim: pru: Fix behaviour when loop count is zero Date: Sat, 12 Nov 2022 11:13:38 +0200 Message-Id: <20221112091338.558105-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_PASS,SPF_PASS,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 List-Id: If the counter for LOOP instruction is provided by a register with value zero, then the instruction must cause a PC jump directly to the loop end. But in that particular case simulator must not initialize its internal loop variables, because loop body will not be executed. Instead, simulator must obtain the loop's end address directly from the LOOP instruction. Ok for trunk? Signed-off-by: Dimitar Dimitrov --- sim/pru/pru.isa | 4 ++-- sim/testsuite/pru/loop-zero.s | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 sim/testsuite/pru/loop-zero.s diff --git a/sim/pru/pru.isa b/sim/pru/pru.isa index b7d8b4af8b9..be8cdfd27fb 100644 --- a/sim/pru/pru.isa +++ b/sim/pru/pru.isa @@ -222,7 +222,7 @@ INSTRUCTION (loop, OP2 = (IO ? IMM8 + 1 : RS2_w0); if (OP2 == 0) { - PC = LOOPEND; + PC = PC + LOOP_JMPOFFS; } else { @@ -237,7 +237,7 @@ INSTRUCTION (iloop, OP2 = (IO ? IMM8 + 1 : RS2_w0); if (OP2 == 0) { - PC = LOOPEND; + PC = PC + LOOP_JMPOFFS; } else { diff --git a/sim/testsuite/pru/loop-zero.s b/sim/testsuite/pru/loop-zero.s new file mode 100644 index 00000000000..65330f27beb --- /dev/null +++ b/sim/testsuite/pru/loop-zero.s @@ -0,0 +1,41 @@ +# Check that loop insn works if register value is zero. +# mach: pru + +# Copyright (C) 2022 Free Software Foundation, Inc. +# Contributed by Dimitar Dimitrov +# +# This file is part of the GNU simulators. +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +.include "testutils.inc" + + start + + ldi r25, 0 + ldi r27, 0 + ldi r28, 10 + + loop 1f, r25 + add r27, r27, 1 + add r28, r28, 1 +1: + + qbne F, r25, 0 + qbne F, r27, 0 + qbne F, r28, 10 + + pass + +F: fail -- 2.38.1