From patchwork Tue Apr 30 14:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 793325 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp306111wrf; Tue, 30 Apr 2024 07:57:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTN1VWqrSDh8icrNYnfruiTDmSVRNBA2bCPVolSZgoJBsK0uV8jClTFV18C71nN4/gnMqSdRVMRxdV57ybA0GN X-Google-Smtp-Source: AGHT+IHkcvIJQs04NmFlnrfAnG2kEfdMnaGDbVeJB9DJ9Dn78UOW362mTvVX0l2ywCfHlhkQSeS1 X-Received: by 2002:a05:6214:409:b0:69b:5576:49e7 with SMTP id z9-20020a056214040900b0069b557649e7mr15063529qvx.45.1714489020838; Tue, 30 Apr 2024 07:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714489020; cv=none; d=google.com; s=arc-20160816; b=ZfYhEVAVmtOx892WghDpIHv8knya0BS4UbwMbXyuy+MtdJ0RvBHTYcaDYjYRIL8fwt gic8rFqORplYCy27znAXXXA3Bnsqe7PRpF73ViGQqbAccJEfzZO7QV2jWyBHiwpSiVdk zUletKVqpV8BJmorCPbdLufOGPJkDObV+Ge6J883puMo6iadLkWM24yzKqsPve3FabWt EmqrokQGfldJaUqFCmGZO85a2oL1mz514r/o858B1JeFJ+KhJwRA5atR+MhmZXrxYiMt ZhiiMNRjcDomdCa91bVb9akoTo5EV5CNW5Ar3O3mz2QTFAiB9NiL6u2SK+ywSDwyy0oP 3t3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e0X80mS9yZh3HbIdA8l9s4NtXPfqvlI+J4uan4HO+FY=; fh=45NLiQg4EMU6ZaU2NF2rceaXURtE7z0ozrvxeA9ySDM=; b=hQTr7uVDkb8ENuenwTSBwFYdsYqlyAqq/xydAIWOWDU66bi2bdUNMfooDiFgZqqfWT d5nSBGGMIYpBB2MMrQoYvJmVxX7k7naYtbctcwiGkS/aAcCOOXP3/xRHIlZZv15QmGmI pIGdQc0XRR/KQFeuM/IEZg5kgaBlxOa2u1q/KEjtEf3L4WpTzHZXs7F6JkRMhP+Xf7cv 4S3rvGc7Z8G/zy1g8SjdvV606pN5lrQ244t1uQ40gbebwjg8XKcp6+HOEWi4HxoUU/CT PszzVXOqFUw5e4CTYdyJN7lRGGfFyYvMHOIYR8hOTxQM2JEr+caRcp/0gnwyoSEigDlj qfdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cljq54H6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q7-20020ad45ca7000000b006a0ca91d5e6si5764882qvh.238.2024.04.30.07.57.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 07:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cljq54H6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1ouB-0002yP-MI; Tue, 30 Apr 2024 10:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1ouA-0002y2-Ok for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:26 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1ou8-0006dn-AN for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:26 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-51acb95b892so7186752e87.2 for ; Tue, 30 Apr 2024 07:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714488982; x=1715093782; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e0X80mS9yZh3HbIdA8l9s4NtXPfqvlI+J4uan4HO+FY=; b=Cljq54H6VZ+OsZ+Bfl5IGDso0eqP3uE0EvEU6dfHQQY9Yd2mbAFV6lvC7t7xo0YErJ 2G3PekTUnpQglaDBnC2RPUy8cDi7s98rAYx+0kk1pmBwwcuC8NVYFXo8Crjg9NKWYzRt 9hLWoxvDyv0W9yp7xFivZ1PWji/utqg898288sxZVd86m5AHb9esNlRZgUyQLrKlnxeO P2NfGchPu9gvzvm9Utf57JfOEGQrL6kaP5wL8IrzZTIBPC3VEv11GE0BdTcNdAFugeSJ AHtQ+bEhq5QVL6HNdTTQUqDLODfsZ8Ga4vFWlUXtIq1gZOs1+X1Lzj6q0EVa9NWpPB2n uWsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714488982; x=1715093782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e0X80mS9yZh3HbIdA8l9s4NtXPfqvlI+J4uan4HO+FY=; b=oqX0loldzYgHxOsp64sq+ye8R1cPRGMnW9Qk79SPhSWKITWuXeFNOxpFJ2fX0nKeBM 3mF/RDlkxAGLWTr9yf3oF5l6uX6JmoKVjPFgmajODMc3hiQkj5pPeqjsupXjAP684/Zp LQDQkpc020peaboLEpVElUWt2U6Yshj80G1l61Dh9XSIfT8w32hRO7J4Oyhcjh5Egw+5 T4KlrdOJpeZ4lU/oG9ZkanbbmAZMyVg1YndsFPwS9EOnB879KLZ/zrsa44Q5HtgSdykN O6r8WfAE/5Fum5RXhEc8Y+jLmGTYum0q0WxbxyKIh2llu29E8NRWUTWmL2PR7lCULgaM 9fhQ== X-Gm-Message-State: AOJu0YxXCJhRiCJGjpUma3PnlNEGhPA7UtCQnqLrnz73KawEcH9ZOfkl 6eguvj+tGbRq3v7UgcpLaiZH7hw6W5mseWCc+/Mn4l+s4nRI6kD0Mi21kF5aURx/9Kwvv+HB/U+ c X-Received: by 2002:a05:6512:1592:b0:51d:5ffd:efe4 with SMTP id bp18-20020a056512159200b0051d5ffdefe4mr8042664lfb.1.1714488982217; Tue, 30 Apr 2024 07:56:22 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id w5-20020a5d6805000000b0034c8b0354a6sm9626938wru.106.2024.04.30.07.56.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 07:56:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , Paul Cercueil , John Paul Adrian Glaubitz , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v3 1/4] target/sh4: Fix ADDV opcode Date: Tue, 30 Apr 2024 16:56:11 +0200 Message-ID: <20240430145614.76475-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430145614.76475-1-philmd@linaro.org> References: <20240430145614.76475-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The documentation says: ADDV Rm, Rn Rn + Rm -> Rn, overflow -> T But QEMU implementation was: ADDV Rm, Rn Rn + Rm -> Rm, overflow -> T Fix by filling the correct Rm register. Add tests provided by Paul Cercueil. Cc: qemu-stable@nongnu.org Fixes: ad8d25a11f ("target-sh4: implement addv and subv using TCG") Reported-by: Paul Cercueil Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2317 Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/translate.c | 2 +- tests/tcg/sh4/test-addv.c | 23 +++++++++++++++++++++++ tests/tcg/sh4/Makefile.target | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/sh4/test-addv.c diff --git a/target/sh4/translate.c b/target/sh4/translate.c index ebb6c901bf..4a1dd0d1f4 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -714,7 +714,7 @@ static void _decode_opc(DisasContext * ctx) tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8)); tcg_gen_andc_i32(cpu_sr_t, t1, t2); tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31); - tcg_gen_mov_i32(REG(B7_4), t0); + tcg_gen_mov_i32(REG(B11_8), t0); } return; case 0x2009: /* and Rm,Rn */ diff --git a/tests/tcg/sh4/test-addv.c b/tests/tcg/sh4/test-addv.c new file mode 100644 index 0000000000..54ac77b867 --- /dev/null +++ b/tests/tcg/sh4/test-addv.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include + +static void addv(int a, int b, int res, int carry) +{ + unsigned int c; + + asm volatile("addv %2,%0\n" + "movt %1\n" + : "+r"(a), "=r"(c) : "r"(b) :); + + assert(c == carry && a == res); +} + +int main(void) +{ + addv(INT_MAX, 1, INT_MIN, 1); + addv(INT_MAX - 1, 1, INT_MAX, 0); + + return 0; +} diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 4d09291c0c..521b8b0a76 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -17,3 +17,6 @@ TESTS += test-macl test-macw: CFLAGS += -O -g TESTS += test-macw + +test-addv: CFLAGS += -O -g +TESTS += test-addv From patchwork Tue Apr 30 14:56:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 793328 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp306393wrf; Tue, 30 Apr 2024 07:57:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8xjfqDRFxZ7TegvAyNViBlnsoSquXpN4U1S8N6IsNGPYCDLz/nDphxUTqFFb0lUiYQEPqaZ6VPelaDF2dYqF7 X-Google-Smtp-Source: AGHT+IFfeF8eYMnvm+FmKOBUra5Jqcf1PyudGIOsoClUrOyNsHnIwZzS4IfezfX18/aVEb//A5dH X-Received: by 2002:a05:690c:690f:b0:615:1413:95c1 with SMTP id if15-20020a05690c690f00b00615141395c1mr13350645ywb.19.1714489060961; Tue, 30 Apr 2024 07:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714489060; cv=none; d=google.com; s=arc-20160816; b=M715FooZRwOSLx7Gj3fLsXYzZMMI1laIwuT3cNmDLcOmjYTBW6OlsBeNGvWPk+qV38 3sgDQkby/5Alhu8FxatO13AQhEyQGvxc8X2J1M4l6i66mdh6CGlWQss8dXtIPApHIbNh 9pjwMlAMKLNs9PCe+7GJYOFwf7DXUXOiAq8DGHeAkxcVk8+q1kYc/yCdRK2MQJzdj+Cw mxTbYcI7I2xqq2VLyi6asybTWw5ej1ncmS85YEtFDq/wQmhh+9UUjrw5m4fgVWVFx6nY yawIM8F6AIDsLH+lzHEGQmrViqu0JMkchJKIhtPu5EHiGs8cW9n/hw4dhtCWk0XYy9yS cPrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U5GYC8zc5JQkgTrRsykKZZUmjjs/NibwLlEPBMjg85Y=; fh=45NLiQg4EMU6ZaU2NF2rceaXURtE7z0ozrvxeA9ySDM=; b=Rxje0mC7o7jDDklSwbRM5E0OyZr8L6krxV0j3rQUDq4Wg9fOVigkIT48NMqZMeNHMG x2HLFmnLXvwGdoGDXJyKDj5iPH+AYdnqPcXVfZCei2MdV29guN2Nfjm6KWtS9WCpNBG4 UCLAT7SfWah4K8xrDfk5c2JIihVZY0T8rvnfeKszHdlCQCrboVopouXcKE1Frg9UDeT6 9WSTn1uBTdesTVoVGboREqaRwpT4XbpXl2kOwqsoqSSa5dxQhzRmsqOwGDEGnM1+IBRw nY7+I5WvgYSqgRXKFFKcauwmwbN3wfm7YU37W/fkq3h8On238qMgIEQgCiindE3g5W2D 1UKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SE/hrI6k"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ep16-20020a05622a549000b0043692c64f7esi25435474qtb.552.2024.04.30.07.57.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 07:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SE/hrI6k"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1ouI-00030J-FP; Tue, 30 Apr 2024 10:56:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1ouG-0002z4-L4 for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:32 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1ouE-0006gY-PR for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:32 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-34c1fff534fso4313795f8f.1 for ; Tue, 30 Apr 2024 07:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714488989; x=1715093789; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U5GYC8zc5JQkgTrRsykKZZUmjjs/NibwLlEPBMjg85Y=; b=SE/hrI6kGgtTAw+1wizBXRubyo89gx6YmSG+xto29c9fsghWH6KHXqZodoWKKX0msA tuxRKMLX39AETAT3PSn+nqog12/JDQPMDlbP4LPJzksHhtBaP1Gaut+5cTU9CzwpP7oa c/pgGlwP6ekMz++uanxKBql6sJ/rozaAL6mjaaBhUoCwMgyFzlqSItVFD2/A5hfp6tXd PVy4QGBNRRj4O3QVV0O6iugPULpwLJnNSqUkpa25oBvZbGg7i5oaHPMey915/sMwkEfx 6W4U9SCCg76/M/COLgwpJkP+X1496RXRE2Sv6oDzYWPC5UmL++igIRPXpWs4XBs7NDU1 6RxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714488989; x=1715093789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U5GYC8zc5JQkgTrRsykKZZUmjjs/NibwLlEPBMjg85Y=; b=SdizMR9FpB+Z2j9s0/JlIuNBsRdzzgKjq0GxABFEbbscgwD62buXDWRdRDCEnbaOV5 6S8GcRZDvSebGJaZBRdizEdRM3WazfeoDXOxID5DCH2AqD8cp3RwTSjG7Y5+HcePzEpt tAsPuyXs5Rim/BI7zuuw/6mHYHD/msWfWhi8n0O3K0GneHVcwKm2Q7kZgJYb/0UVyBuB 3St0saMIImiqEthuSMezWMC31jsOAiGLp9AB1IcxYKf9L3WYYt6Gfp/K0IdERZ4eijWG hVV+DQgNWIcgcIPHoxJseSWcNvl4pG/Ryj6SzS2dqDDzsDFR7YJcO9qGey+H7QwLodN6 A4yg== X-Gm-Message-State: AOJu0YxL1ShwGS9JkG86sUUiV3LrDi7U/cHVCVKXkqwjGG2S7hq2JVh0 niS6E65uwsBK0ym9ASWlle0Z7kDM7hhcLghf4BT8k1TxiXTjLKfXVgKydHQRemaohgN3rVe/PP7 0 X-Received: by 2002:adf:e58b:0:b0:34c:6677:b7de with SMTP id l11-20020adfe58b000000b0034c6677b7demr8337614wrm.2.1714488987605; Tue, 30 Apr 2024 07:56:27 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id d1-20020adfef81000000b0034a7a95c8cfsm28542875wro.9.2024.04.30.07.56.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 07:56:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , Paul Cercueil , John Paul Adrian Glaubitz , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v3 2/4] target/sh4: Fix SUBV opcode Date: Tue, 30 Apr 2024 16:56:12 +0200 Message-ID: <20240430145614.76475-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430145614.76475-1-philmd@linaro.org> References: <20240430145614.76475-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The documentation says: SUBV Rm, Rn Rn - Rm -> Rn, underflow -> T The overflow / underflow can be calculated as: T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31 However we were using the incorrect: T = ((Rn ^ Rm) & (Result ^ Rm)) >> 31 Fix by using the Rn register instead of Rm. Add tests provided by Paul Cercueil. Cc: qemu-stable@nongnu.org Fixes: ad8d25a11f ("target-sh4: implement addv and subv using TCG") Reported-by: Paul Cercueil Suggested-by: Paul Cercueil Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2318 Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/translate.c | 2 +- tests/tcg/sh4/test-subv.c | 26 ++++++++++++++++++++++++++ tests/tcg/sh4/Makefile.target | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/sh4/test-subv.c diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 4a1dd0d1f4..3e013b7c7c 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -933,7 +933,7 @@ static void _decode_opc(DisasContext * ctx) t0 = tcg_temp_new(); tcg_gen_sub_i32(t0, REG(B11_8), REG(B7_4)); t1 = tcg_temp_new(); - tcg_gen_xor_i32(t1, t0, REG(B7_4)); + tcg_gen_xor_i32(t1, t0, REG(B11_8)); t2 = tcg_temp_new(); tcg_gen_xor_i32(t2, REG(B11_8), REG(B7_4)); tcg_gen_and_i32(t1, t1, t2); diff --git a/tests/tcg/sh4/test-subv.c b/tests/tcg/sh4/test-subv.c new file mode 100644 index 0000000000..d28a9f8f89 --- /dev/null +++ b/tests/tcg/sh4/test-subv.c @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include + +static void subv(int a, int b, int res, int carry) +{ + unsigned int c; + + asm volatile("subv %2,%0\n" + "movt %1\n" + : "+r"(a), "=r"(c) : "r"(b) :); + + assert(c == carry && a == res); +} + +int main(void) +{ + subv(INT_MIN, 1, INT_MAX, 1); + subv(INT_MAX, -1, INT_MIN, 1); + subv(INT_MAX, 1, INT_MAX - 1, 0); + subv(0, 1, -1, 0); + subv(-1, -1, 0, 0); + + return 0; +} diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 521b8b0a76..7852fa62d8 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -20,3 +20,6 @@ TESTS += test-macw test-addv: CFLAGS += -O -g TESTS += test-addv + +test-subv: CFLAGS += -O -g +TESTS += test-subv From patchwork Tue Apr 30 14:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 793327 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp306284wrf; Tue, 30 Apr 2024 07:57:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6g8nbOmjSiBUsR5x3Q7SXJ+P8ZLIwsZZaIlMtt7daBlgxB2ndE45VrgfV6bH7TxZfrMFPvciR4TU8QFAD3R5H X-Google-Smtp-Source: AGHT+IHc13uhZGPZFOMKIldysfmK56IlD9J5bT3VGDJavjPPu3KUH0hgJFBfl2bBTwTcQhOGM+At X-Received: by 2002:a25:db4d:0:b0:dcd:63f8:ba41 with SMTP id g74-20020a25db4d000000b00dcd63f8ba41mr13941539ybf.42.1714489043898; Tue, 30 Apr 2024 07:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714489043; cv=none; d=google.com; s=arc-20160816; b=0id38bC9Gl8Tj5hFYW5n4yr7zDuknvQ9oKx4Q4QV4Kky06LuK7cEhAsxPMgkhnRHLT cMsb+Bm2ebkJt4VEXU2J9OYtLHyCajevpbA82WZsbRr3Kf4A5XHevSppmBSVkY1UgOiS jqKROLm0GqqyuqF4+EimXAIIlWHRzP5iq1QDAiHsJTe9UDw0hR5cjp2ZzZu0nueM7r62 6ww43CVZ8yF9+O1QdxwGBd7k1ZsAdHaDcyGl38IxKZeabadwu3ua42BhdYyougSfeqIp E0tiwCbacP7O3lhrQgiyyE3GTPk43K0eO9U85k+wbQGvdSOVjc3vnVN+zGxf/AzYoNbY OMuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=upYrT6zRZ258RQvIX6lEsJRlpAaxzaJODGSB0NJY3bM=; fh=uRf7T4SxSIhPjlqxdbaMu5vBmOTepLiQXsiyphgx+Jk=; b=k+d6cP5g7Qpvo8XsPcAiReGladjmwGfkGi7a+haVCjJ3QFC3Vy/EllVBo5VhAULzQk s6xcAGjjAudFI+BxqYwwdlWkrDmF2KIsLFaT4zrEF0QhwSBWVNhA7JeYMmloHgtOyo3O lhd/i+6wkcMeHMeef9CCdza++ZlMOeK9l9a6L/2ZnO+w31RxYwnNzXpwTprwzqnoZezf rHxaXejuOkaIhc683aDk+AFLFcANMb1Q2wRQOMjniEgZIfNuqzhoG6PFlbozEpzA6sTd EBgvqUWljvx5CiNdwzvnXsHE2yNE0dEvYWqzqcKGSbYmbgAvklzBa6toPiusHH/Bt275 jmTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GIbI9qfv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a13-20020a05622a064d00b0043b0af83927si3238512qtb.321.2024.04.30.07.57.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 07:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GIbI9qfv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1ouP-00030x-PK; Tue, 30 Apr 2024 10:56:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1ouN-00030f-EC for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:39 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1ouK-0006hC-Eh for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:39 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2def8e5ae60so66840251fa.2 for ; Tue, 30 Apr 2024 07:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714488994; x=1715093794; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=upYrT6zRZ258RQvIX6lEsJRlpAaxzaJODGSB0NJY3bM=; b=GIbI9qfvPi+zIAZSMiFHLV9uZhgsbJ+Jrb79uf9hRCsc2x9NnZmu7d+xxwHucfauWJ snjnB8mODWHHlwkueSs164IUu88rUm8CEhY0rdrNIctYqrYL7CJW1MbhVrB7pB0QFX4h N6EZLTt8Rim9RyieBSBiXper77vazQnCtbLWnetiRPR3vqda1Do2JcspdECRYM6bkhmd 3NiUZKbYG+QYR5+EcX4p7yf8htTKSk/4S0rJGinWs8qFyRXKbHhImLiVlRoFbxZVwQSo T0P391NwUO6i/Ug7OfP2vGitLseJTfNV+kKeuFmJ9L7tBu8g23zOA2wJLFJN5jgUIM0S MwKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714488994; x=1715093794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=upYrT6zRZ258RQvIX6lEsJRlpAaxzaJODGSB0NJY3bM=; b=Pu4uigBIjI70T/YS3GKxEsDszM9Zia1kDqaSK4opH/f7KKLCqI7PMmke1FMEf3TASX KEQth61DtlIZewMKk3rU4bVsNYG5veMW4VqwlqN3u7yHivL4x1GWrTFt4omDshBGEosM xB31i6e1UnFk92f1hXmn7YSXUf7qH73dWuCrqwpdScC6ClP3mpSGGZxSnWGxmThVE05V zGI3V35tpuHhnHDgzzQ+2qNsJAvNfiq8MQJDTfIrwY20Mt9PKhZ7r8ow8dwqMTPZbGXP sMHy2GPCXxbgHw64UcOnLuBoTwygg76jPK29f3SiwRGNnNVSj60ad/zDWRuu9UaE7O/X 8rjQ== X-Gm-Message-State: AOJu0Yyrs4mnhs2pvVzmvsEBL4Mz9J94azmfBdZQk9yXVC5TkqD4Em8P DM51DGP99qzdmXdM3iy3QeFApFK+FV83uraeqVzgwA0QLgzO3572p2J0pPAXynK9MFe1wuEsecG 1 X-Received: by 2002:a2e:8552:0:b0:2df:d2a4:4360 with SMTP id u18-20020a2e8552000000b002dfd2a44360mr5766930ljj.49.1714488994368; Tue, 30 Apr 2024 07:56:34 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id g9-20020a05600c310900b0041aa79f27a0sm28419086wmo.38.2024.04.30.07.56.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 07:56:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , Paul Cercueil , John Paul Adrian Glaubitz , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 3/4] target/sh4: Rename TCGv variables as manual for ADDV opcode Date: Tue, 30 Apr 2024 16:56:13 +0200 Message-ID: <20240430145614.76475-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430145614.76475-1-philmd@linaro.org> References: <20240430145614.76475-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org To easily compare with the SH4 manual, rename: REG(B11_8) -> Rn REG(B7_4) -> Rm t0 -> result Mention how overflow is calculated. Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/translate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 3e013b7c7c..47c0f3404e 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -705,16 +705,20 @@ static void _decode_opc(DisasContext * ctx) return; case 0x300f: /* addv Rm,Rn */ { - TCGv t0, t1, t2; - t0 = tcg_temp_new(); - tcg_gen_add_i32(t0, REG(B7_4), REG(B11_8)); + TCGv Rn = REG(B11_8); + TCGv Rm = REG(B7_4); + TCGv result, t1, t2; + + result = tcg_temp_new(); t1 = tcg_temp_new(); - tcg_gen_xor_i32(t1, t0, REG(B11_8)); t2 = tcg_temp_new(); - tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8)); + tcg_gen_add_i32(result, Rm, Rn); + /* T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31 */ + tcg_gen_xor_i32(t1, result, Rn); + tcg_gen_xor_i32(t2, Rm, Rn); tcg_gen_andc_i32(cpu_sr_t, t1, t2); tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31); - tcg_gen_mov_i32(REG(B11_8), t0); + tcg_gen_mov_i32(Rn, result); } return; case 0x2009: /* and Rm,Rn */ From patchwork Tue Apr 30 14:56:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 793326 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp306213wrf; Tue, 30 Apr 2024 07:57:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQOXnFrjlL9jHZ9YrJ10z5p2HICXgveHTB2IUQUsu3iKBan0iRn+yK/zimN0uju9TFyPwTxniRVkyrjhDPZFlt X-Google-Smtp-Source: AGHT+IGnY7zwBNaDuO1ZdsQ0rRYSWMLJ+ElNdMu9JlW1BBTLi+hYV6xLU5j48q9UV9C7elccrF2C X-Received: by 2002:a05:620a:9d3:b0:790:edce:3640 with SMTP id y19-20020a05620a09d300b00790edce3640mr7917921qky.13.1714489034403; Tue, 30 Apr 2024 07:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714489034; cv=none; d=google.com; s=arc-20160816; b=tYXhbiKpWIASezs/dXaSQ9g8tVeER6i9ZB9fuS81pM9j2VUW2k0ZZbyHJsyH8QHqYD hXCe2+tU/Im7pxL6bWzvjrCej5RybUkcVS5k59l4a7wF+52HHPZ59UpzLoL8giYWg5Nm f9TweEhe16byFFEKhfXcmwY8x0MiE8PmftITtZHilpNOxe6SBmOJqgbN4+b0o64CdtVk GR/CkPHA//S30c6UllJf76ZFWqSM4ir64H0D0XUn62nodGTh/44uB7DLnINR1x77RkxJ eBm6rwcXhxSpYB3NTgeXHJw8qJWlVVJIZQ7wwbfbiDy7+BFFgQ08HmzU0kHUCtTsweat y22w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W369Umf1RT7Ps9NkjMV9ydFMc4wa5Y+lFfUmRoyXGho=; fh=uRf7T4SxSIhPjlqxdbaMu5vBmOTepLiQXsiyphgx+Jk=; b=kwUJPiXUr0oWu/UhTlC4SII2UdSe1m/cEg1oyNoDkUqsr4YBMVHq27Uq5T5P8pkhWb n/FCO36S2+m33e9gBqgCDI3fUarQXUJeN9DPvJWfKrjlhbAcyB++7T02Ra3CtqWsvtoA DwAqkukxzxVhElZZtkF01zkOg/TnRVpejvwijAeAliL/XkeVfQLaI5rhAhGpXILiRdUJ wBpAkM5TVxooBmhn1dV0TW9Jr5VmoRC7e35HPVNak1d584tjcGvvMlUTQn2HnuIxymha 01OwOTxauJvJhHjSQnqTtH/M7Zohtkc7Na7umHqb74cvPsGdLlzei37xMt1ks1KTEqUU 75kw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=de4a+7qa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id xy18-20020a05620a5dd200b0078f12b1596fsi28412149qkn.388.2024.04.30.07.57.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 07:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=de4a+7qa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1ouS-00031y-W3; Tue, 30 Apr 2024 10:56:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1ouR-00031I-AN for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:43 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1ouP-0006hd-NP for qemu-devel@nongnu.org; Tue, 30 Apr 2024 10:56:43 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2de232989aaso69944021fa.1 for ; Tue, 30 Apr 2024 07:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714488999; x=1715093799; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W369Umf1RT7Ps9NkjMV9ydFMc4wa5Y+lFfUmRoyXGho=; b=de4a+7qaBArknf0P9503JJtLfLYVic5qIdJHmd9k1Sc42DKDzZcXQN/qHNzlLhQNPn BGwgXnTYhg69Q+DFfX7Pf+gZrNShzKktL/rNJA3nqm5rmEXvjeViFV0oFWr2ZbF/CSz5 /nUNUZQkARoAfwrczJFZaJmkCpyeyWsJhLm3LBzsPDCXnT0Bx6/IPRMqNrXOfCVZhm+3 KmB4im78nOAo8JSlsf88qorsOyh4jsQ1nIMaUe0NyANDuw6Q1S6dSOYExvV2CjSm1VEU UvBAC/zXPaAcRD/5eozMP/lphqvIp+ioB7thnr4r9fetBBvOC/Q4Q6YTJMhx7eB3yFTw dIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714489000; x=1715093800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W369Umf1RT7Ps9NkjMV9ydFMc4wa5Y+lFfUmRoyXGho=; b=Gzn7c2u6hF792B4oRDSKQLfATD7Tp427Fa/PwMn++HpM3E8H3XG/FHY6DJRdKYQ1eo r5tzKSj7L8VHjbswj/BsDdKn9I2jioZ+b6990o48lfwB9kbpi9E68SBO9yLGlGvXfDjO bYzMyFXTuuA71vMpouORTJlyoBcN/WyMALPUKWZXn7dhG2zLu86Rzl0dzly0/iTvgWtP oH9RJ+QULoDjaOpDJBxyx4iE6BEqEhE99dp6KNRXXtX+gNs4ldxjC3NKIskAcvw+xJby dXqeo4RdAH4hfXyJQ+YvUNOBudLt1MFDeY1ZI6svO8gapWebpx2hU2eTgjnKilnK9BHW NiuQ== X-Gm-Message-State: AOJu0YyUOuGMpeuera99qQUIvwiB6DCoqhbIMRRgueB7cFjFaYG+PPup +ac/HWwZR+s4e3dB2SCl409+ja2fRDdZjbDhY/dCT6kmzJ3w/HEpQydecrsPHiNQJBCi+UGD7h3 z X-Received: by 2002:a2e:88c7:0:b0:2df:65ed:2c34 with SMTP id a7-20020a2e88c7000000b002df65ed2c34mr8661757ljk.14.1714488999571; Tue, 30 Apr 2024 07:56:39 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id n7-20020a05600c500700b0041bc412899fsm14017132wmr.42.2024.04.30.07.56.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 07:56:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , Paul Cercueil , John Paul Adrian Glaubitz , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 4/4] target/sh4: Rename TCGv variables as manual for SUBV opcode Date: Tue, 30 Apr 2024 16:56:14 +0200 Message-ID: <20240430145614.76475-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430145614.76475-1-philmd@linaro.org> References: <20240430145614.76475-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philmd@linaro.org; helo=mail-lj1-x22d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org To easily compare with the SH4 manual, rename: REG(B11_8) -> Rn REG(B7_4) -> Rm t0 -> result Mention how underflow is calculated. Signed-off-by: Philippe Mathieu-Daudé --- target/sh4/translate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 47c0f3404e..b0ac631859 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -933,16 +933,20 @@ static void _decode_opc(DisasContext * ctx) return; case 0x300b: /* subv Rm,Rn */ { - TCGv t0, t1, t2; - t0 = tcg_temp_new(); - tcg_gen_sub_i32(t0, REG(B11_8), REG(B7_4)); + TCGv Rn = REG(B11_8); + TCGv Rm = REG(B7_4); + TCGv result, t1, t2; + + result = tcg_temp_new(); t1 = tcg_temp_new(); - tcg_gen_xor_i32(t1, t0, REG(B11_8)); t2 = tcg_temp_new(); - tcg_gen_xor_i32(t2, REG(B11_8), REG(B7_4)); + tcg_gen_add_i32(result, Rn, Rm); + /* T = ((Rn ^ Rm) & (Result ^ Rn)) >> 31 */ + tcg_gen_xor_i32(t1, result, Rn); + tcg_gen_xor_i32(t2, Rn, Rm); tcg_gen_and_i32(t1, t1, t2); tcg_gen_shri_i32(cpu_sr_t, t1, 31); - tcg_gen_mov_i32(REG(B11_8), t0); + tcg_gen_mov_i32(Rm, result); } return; case 0x2008: /* tst Rm,Rn */