From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6WflDqo0jGoL/jsAWB0awg (envelope-from ) for ; Mon, 24 Aug 2026 08:10:18 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eFpoDyfC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 282C61E0A3; Mon, 24 Aug 2026 08:10:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 269451E033 for ; Mon, 24 Aug 2026 08:10:17 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D19F54BA2E32 for ; Mon, 24 Aug 2026 12:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D19F54BA2E32 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eFpoDyfC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 7F91A4BA2E1D for ; Mon, 24 Aug 2026 12:09:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F91A4BA2E1D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F91A4BA2E1D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787573391; cv=none; b=VvrotVs0XOY5EUGRYTcDLF64YMlXotEiJmE4Ko5c+OIGYm7K3bxZ1KD+L8tuDL7ZMyV7Brwi5lZE+eM3suQGPNY8yIiTq7xgUWqEEAaKhlkFkKgBnlvqarlPlvn9fhxp+3ESKI3+SK2BmmcTTUV5QihooNFl2xtMSdQnRY+BjNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787573391; c=relaxed/simple; bh=V5NuSvMZ1LPlxRx7MkZHLMfvB6oJwoIkhiDDxLn7RiY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RKIiDGPi7qRGrMaDtm6hG6AGNFJ/GcRoObTeGaT/O+eLWf9IX2p+VCv8q3wqoylnTlD+g9999GbIOOGiSrPfsMfD2xp8M9+4kXSfthrCp9WgFotSimsi93FIb/eTfgOBrLazudjfdhZ0oTujXRLCM1TcjP+BlM19oEGva/mu640= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eFpoDyfC DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F91A4BA2E1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787573391; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xA46UnlTX/i0wK0a2uYhYGRppOmrUmjcqqU6dBEIZQU=; b=eFpoDyfCkcBkAgvE6lpJnfuFpx3DfjdkJ4SO+QpG1gxJYZiSHwprtY+Uts23wl3srslc87 AJOdD5AH40JufJO9FI4bAFi+XRtXyLh2+5CTAwcn/zLn6fIhn2L+ktkekME2AMtMLHn7S9 Ul8XmHZvKTNJ2oiBH75VdWclMFdeD+M= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-kLWOcCbXNeaC73sovcT-6w-1; Mon, 24 Aug 2026 08:09:50 -0400 X-MC-Unique: kLWOcCbXNeaC73sovcT-6w-1 X-Mimecast-MFC-AGG-ID: kLWOcCbXNeaC73sovcT-6w_1787573389 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-482c58a8555so2300149f8f.1 for ; Mon, 24 Aug 2026 05:09:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787573389; x=1788178189; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xA46UnlTX/i0wK0a2uYhYGRppOmrUmjcqqU6dBEIZQU=; b=B7ncoDli/qik686kDQC9gYmWxaZkSdGKvYTWkkmR4vWQPa8h30dTIY2U6Lgd5p641q bqo80jY1UoLRGjFXAXJMdn12dyvwO14UN9TxZ2qKtuXYd3bs7BKljBeIfDxRWYFyLLLf 7OYUFkooyNvi2p9MVgEqBlZiuH9AqYw+4E6y3H/EuxNYeUl1va/UPNexy1Iu8lY8TC8P kJXlitnb33dr2aMDVk7RXr7XeZN/x+zitZeWxUp3GRddvV7GF81yq9VES85DQ2dqMFAv usdHeCKyLbhHrTcZuytHxHlJ0EsMspyprm74XMeisgsPmf/OtZy+/ns9XURGnaDkrklW SVMw== X-Forwarded-Encrypted: i=1; AHgh+RpjA9/twehsGI+kq/jHB7EaWiUCCGNM4i0mKyTu1nanW9GInOHN60taZS5yUef8bIiMWWkNYe6AH2gE5Q==@sourceware.org X-Gm-Message-State: AFuF++n5PLmbi6Jn4Vv8bQLG+WLnnlBYRVwzzATHo35pmThilam5539d FGh9fsKwBD/VV8HfO+EF0cTGnX/BURS4H80qq6QyCXW3DSXMW6zp5InNPJUvjTy+4v8BLUDF4xz EhhDGDPA7RQlYi8xx+Mii40ALkpoaa5+smrb9iehOU0oQ9PB5bNbK4jSsN1kgWB0= X-Gm-Gg: AR+sD12yabj/sg2Ohay+lnMz3lLTD8iy3YV6GM9IxiR3mJiaBNtb3V3IasVUEqs0zXh zcwyG4eTgsraPX1HSyGKhhI/Lthd2+Eiks3rvJkv+NCYk5vueNbj3/VsGKWwyYg7qHUPTbngwXf bUExZvLpX1aejLCQemWP/eRpN25/ap/a6DeZAc+aQyfVDsbU0X7D2zP6IiyziEzX20Sngaxl4sc RmH2Y38wY259KX+1YhcMMQjFjJylRWiFfkoPBu7RCcxIVksCiJlj5RyR6LJ6rxndb2WEFRGhby1 7sxpogtWasWM+rUDZ2h7TR0kb3GY1c8S06N6p13EeVQ9ZYGOen0n9tOyIrL2tYkWaBiAwQJzNaF 5U5ISbyQrlob9JX0EV7JxWnoitxU= X-Received: by 2002:a05:6000:4305:b0:47d:eedb:ee62 with SMTP id ffacd0b85a97d-482c81b6719mr17891501f8f.14.1787573388753; Mon, 24 Aug 2026 05:09:48 -0700 (PDT) X-Received: by 2002:a05:6000:4305:b0:47d:eedb:ee62 with SMTP id ffacd0b85a97d-482c81b6719mr17891426f8f.14.1787573388343; Mon, 24 Aug 2026 05:09:48 -0700 (PDT) Received: from localhost (128.223.159.143.dyn.plus.net. [143.159.223.128]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482c9c0ad06sm8265537f8f.27.2026.08.24.05.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 05:09:47 -0700 (PDT) From: Andrew Burgess To: Oleg Endo , gdb-patches@sourceware.org Subject: Re: [SH] Fix mac.w insn simulation for SH2 and above In-Reply-To: References: Date: Mon, 24 Aug 2026 13:09:47 +0100 Message-ID: <871pbnvhx0.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: UOH-syQLAvS1bCBMRHwtAUMtCI5bPhBSRsByVKcyWjQ_1787573389 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Oleg Endo writes: > Hi, > > The simulator currently implements only the SH1 version of the mac.w > instruction. On SH1 the MACH:MACL accumulator register is only 42-bit. It > was extended to 64-bit on SH2 and every variant that followed after. > > The issue probably never showed up because GCC hasn't been able to emit the > SH integer mac instructions. I ran into this because I was trying to do > exactly that and while running some tests on sh-sim. > > The attached patch uses the bfd_mach field to distinguish between SH1 and > not-SH1 in the simulation of the mac.w instruction, in a similar way as it's > already been done for some SH2A instructions. > > > OK to commit & push? > > Best regards, > Oleg Endo > From 6b07e3daa73acac1d1800c94cdfae0b83509f2d1 Mon Sep 17 00:00:00 2001 > From: Oleg Endo > Date: Sun, 2 Aug 2026 19:37:21 +0900 > Subject: [PATCH] sim/sh: fix mac.w insn for SH2+ > > On SH1 the MACH:MACL accumulator is only 42 bits wide. On SH2 and above it's 64 > bits wide. Emulate the corresponding behavior based on the bfd_mach field. > --- > sim/sh/interp.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/sim/sh/interp.c b/sim/sh/interp.c > index c8c2a74..cc4ae2c 100644 > --- a/sim/sh/interp.c > +++ b/sim/sh/interp.c > @@ -1197,8 +1197,11 @@ macw (int *regs, unsigned char *memory, int n, int m, int endianw) > long mach; > /* Add to MACH the sign extended product, and carry from low sum. */ > mach = MACH + (-(prod < 0)) + ((unsigned long) sum < prod); > - /* Sign extend at 10:th bit in MACH. */ > - MACH = (mach & 0x1ff) | -(mach & 0x200); > + /* SH1: MACH:MACL is 42 bits wide, sign extend at the 10:th bit in MACH. Could you fix '10:th' to '10th' please. > + SH2+: MACH:MACL is 64 bits wide. */ This line should be indented with TAB. > + if (saved_state.asregs.bfd_mach == bfd_mach_sh) > + mach = (mach & 0x1ff) | -(mach & 0x200); > + MACH = mach; > } Is it possible to write a test for this change? I know simulator testing is very patchy, but if we add tests for things that are fixed we'll slowly start to build up some decent test coverage. Thanks, Andrew > MACL = sum; > } > -- > libgit2 1.9.0