From patchwork Mon Jul 10 22:25:28 2023 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: 701074 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410287wrs; Mon, 10 Jul 2023 15:31:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlH3PqiOf0rVCuTWSs6vIZajtS7H0luzJbfNCoLC0PtG/lGQnGMx8cYYuJO5gWuc6zM2lA38 X-Received: by 2002:a0c:ac0e:0:b0:619:4232:aa87 with SMTP id l14-20020a0cac0e000000b006194232aa87mr10288858qvb.24.1689028270618; Mon, 10 Jul 2023 15:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028270; cv=none; d=google.com; s=arc-20160816; b=tC2zUiZo3TRs6DgFIOAJa5QKGf/sfpqwVPO57Cu2nLcKLwDd5VE5E3OhJdxiZPvHtU vV+Ded7ccbvKsyYdUl02iOf9lgE5N5b4Lvq+7lE+JxIETHp2Fau3piyAJt+KcAepG42U 7TeO0DXEEqLpDIgkEXBVpaozVlc83kWQl7EnOJXu0wcWwWU4lmu1Q3BBAspsYHp62eLv c8YaMopSHwGTCOBjr7mjGCRQvf5tDgEaIeH/xYmQW0MOudDLzK/rYv2C7pa9RUFTAgdw Ubh6uRTlfUoNzttqjtxVzCe7mtU9D13h2rujjANIunCno8vFQImOXGfOy+BCoNrwB6Rn H1wA== 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=U+boInrFMOouLAZH87rtNgQEAsi3AA1iZOyWyu8Hur4=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=t57zRkQiXJ9jrlgNXa1r9+/HdlGlJ/I+89Bb1+8HwSnKsb4HyOV20q0FI/bG4q4MAl caSIkvXk0h8JGsxjzosY/thFQS+UPsuEQiygH6YWvtLRD44T/B3h7DNTmLMu0DsVJ5rJ qEwEedYybpyC2VbR+kw7LH98ZJzzMdvOhtRkhLJCcN9etEhzqJKLspwOc1f1oI5dsJEu XBHFZKInYwAHCIdRrZDP2UsEocuvyoLedjdinIE1ovp7hqUCC9JUBvWkzJBG18RIrM2r 9xrkuJ9mwS15qmUK82f/QwRP67wTpDQAnqSh5/RZxA7NG/2zANzYcAGItTe3HG5GBpYU D/5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u29PcR6N; 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 e19-20020a0caa53000000b00636bb57776dsi253069qvb.222.2023.07.10.15.31.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:10 -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=u29PcR6N; 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 1qIzKs-0003Rk-Fh; Mon, 10 Jul 2023 18:26:26 -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 1qIzKq-0003RM-Qd for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:24 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzKo-0001g8-Ut for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:24 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso51882945e9.2 for ; Mon, 10 Jul 2023 15:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689027981; x=1691619981; 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=U+boInrFMOouLAZH87rtNgQEAsi3AA1iZOyWyu8Hur4=; b=u29PcR6NQxPtf5i4GoH84MvHmB/VdIvUGJKiGm0xmKIKTJOI/z9R7UmuLxCgBRjoeg 7CMbZKFrKIa9nZOL4tN16xzhm+sJNgvbraX1b8CKSoaYRCmxbuV4EL6kdMFHIX3HrCPc LefdiWsWIGPmZr3FObzvW9NIJMD1HWW21s/QSReuKgprfXZgvnhRtSPLzuTBfG2HvoDs 7w4kgfekclgDEZOZBmZ307qkVQKTPMyvdv3KBxdlF3/6abCGMihz9bhwDcgSU5oqx0oX ihoSi41Pqs+p2pSPHTW4PC0GEZzRbEp35+Ymi6d3WlOH+3QtCKTNs3YpVVCmh4yEaxum Yokw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027981; x=1691619981; 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=U+boInrFMOouLAZH87rtNgQEAsi3AA1iZOyWyu8Hur4=; b=BEfYgdOjnEmzMKg9DtB5wUBYe9g8CU1JK1tiHpJZyRSawqEQi0adZKveZ2IqXKJsgQ 0QyIxtAksqcFnKYTAuMBIX4NAgXqQcgMhgGYCocxL6hHJmbx3KZrbeYjzi6aa7Lq16B9 gVz00KEeME3veIQUgH9jM5Wuq6t1qt/cdMwh3MPCLUewg0gDBR0bQPMm/sT4OoKWk+ir 0KCYrqLu8r3xK5GNfRZj+p1ugl9IV/JPptvt71QG13xHvKDDBYUxIN794wRwSqZ2RsQR rGe9mrd3SOsjzoySJVUaNbszdbucOb7AR755mzP41W4nUH04EaNR4xG2tFSLh54QrO8a XjBQ== X-Gm-Message-State: ABy/qLaz9nrK3RtBmkgZyyo5IrppiEhsBeoT7wpj+RqjZjz6b4y94Aw9 vI6jz4kSGqdcBHebI8pzIqzzqE06yGZLOBifVYLaDA== X-Received: by 2002:a7b:c408:0:b0:3fb:bc4a:46ad with SMTP id k8-20020a7bc408000000b003fbbc4a46admr11258163wmi.9.1689027980505; Mon, 10 Jul 2023 15:26:20 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id hn32-20020a05600ca3a000b003fbdd5d0758sm889033wmb.22.2023.07.10.15.26.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 01/44] target/mips: Rework cp0_timer with clock API Date: Tue, 11 Jul 2023 00:25:28 +0200 Message-Id: <20230710222611.50978-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Jiaxun Yang Previous implementation of MIPS cp0_timer computes a cp0_count_ns based on input clock. However rounding error of cp0_count_ns can affect precision of cp0_timer. Using clock API and a divider for cp0_timer, so we can use clock_ns_to_ticks/clock_ns_to_ticks to avoid rounding issue. Also workaround the situation that in such handler flow: count = read_c0_count() write_c0_compare(count) If timer had not progressed when compare was written, the interrupt would trigger again. Signed-off-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230521110037.90049-1-jiaxun.yang@flygoat.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu.h | 3 ++- target/mips/cpu.c | 8 +++++--- target/mips/sysemu/cp0_timer.c | 35 ++++++++++++++++++---------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/target/mips/cpu.h b/target/mips/cpu.h index a3bc646976..d3ee874a18 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1160,8 +1160,8 @@ typedef struct CPUArchState { const mips_def_t *cpu_model; QEMUTimer *timer; /* Internal timer */ + Clock *count_clock; /* CP0_Count clock */ target_ulong exception_base; /* ExceptionBase input to the core */ - uint64_t cp0_count_ns; /* CP0_Count clock period (in nanoseconds) */ } CPUMIPSState; /** @@ -1178,6 +1178,7 @@ struct ArchCPU { /*< public >*/ Clock *clock; + Clock *count_div; /* Divider for CP0_Count clock */ CPUNegativeOffsetState neg; CPUMIPSState env; }; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 01e0fbe10d..b7119cbbb4 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -449,9 +449,9 @@ static void mips_cp0_period_set(MIPSCPU *cpu) { CPUMIPSState *env = &cpu->env; - env->cp0_count_ns = clock_ticks_to_ns(MIPS_CPU(cpu)->clock, - env->cpu_model->CCRes); - assert(env->cp0_count_ns); + clock_set_mul_div(cpu->count_div, env->cpu_model->CCRes, 1); + clock_set_source(cpu->count_div, cpu->clock); + clock_set_source(env->count_clock, cpu->count_div); } static void mips_cpu_realizefn(DeviceState *dev, Error **errp) @@ -504,6 +504,8 @@ static void mips_cpu_initfn(Object *obj) cpu_set_cpustate_pointers(cpu); cpu->clock = qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, cpu, 0); + cpu->count_div = clock_new(OBJECT(obj), "clk-div-count"); + env->count_clock = clock_new(OBJECT(obj), "clk-count"); env->cpu_model = mcc->cpu_def; } diff --git a/target/mips/sysemu/cp0_timer.c b/target/mips/sysemu/cp0_timer.c index 70de95d338..9d2bcb0dea 100644 --- a/target/mips/sysemu/cp0_timer.c +++ b/target/mips/sysemu/cp0_timer.c @@ -28,15 +28,26 @@ #include "internal.h" /* MIPS R4K timer */ +static uint32_t cpu_mips_get_count_val(CPUMIPSState *env) +{ + int64_t now_ns; + now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + return env->CP0_Count + + (uint32_t)clock_ns_to_ticks(env->count_clock, now_ns); +} + static void cpu_mips_timer_update(CPUMIPSState *env) { uint64_t now_ns, next_ns; uint32_t wait; now_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - wait = env->CP0_Compare - env->CP0_Count - - (uint32_t)(now_ns / env->cp0_count_ns); - next_ns = now_ns + (uint64_t)wait * env->cp0_count_ns; + wait = env->CP0_Compare - cpu_mips_get_count_val(env); + /* Clamp interval to overflow if virtual time had not progressed */ + if (!wait) { + wait = UINT32_MAX; + } + next_ns = now_ns + clock_ticks_to_ns(env->count_clock, wait); timer_mod(env->timer, next_ns); } @@ -64,7 +75,7 @@ uint32_t cpu_mips_get_count(CPUMIPSState *env) cpu_mips_timer_expire(env); } - return env->CP0_Count + (uint32_t)(now_ns / env->cp0_count_ns); + return cpu_mips_get_count_val(env); } } @@ -79,9 +90,8 @@ void cpu_mips_store_count(CPUMIPSState *env, uint32_t count) env->CP0_Count = count; } else { /* Store new count register */ - env->CP0_Count = count - - (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - env->cp0_count_ns); + env->CP0_Count = count - (uint32_t)clock_ns_to_ticks(env->count_clock, + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); /* Update timer timer */ cpu_mips_timer_update(env); } @@ -107,8 +117,8 @@ void cpu_mips_start_count(CPUMIPSState *env) void cpu_mips_stop_count(CPUMIPSState *env) { /* Store the current value */ - env->CP0_Count += (uint32_t)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / - env->cp0_count_ns); + env->CP0_Count += (uint32_t)clock_ns_to_ticks(env->count_clock, + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } static void mips_timer_cb(void *opaque) @@ -121,14 +131,7 @@ static void mips_timer_cb(void *opaque) return; } - /* - * ??? This callback should occur when the counter is exactly equal to - * the comparator value. Offset the count by one to avoid immediately - * retriggering the callback before any virtual time has passed. - */ - env->CP0_Count++; cpu_mips_timer_expire(env); - env->CP0_Count--; } void cpu_mips_clock_init(MIPSCPU *cpu) From patchwork Mon Jul 10 22:25:29 2023 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: 701064 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409126wrs; Mon, 10 Jul 2023 15:28:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlH936XfkmDI4LkyXPeNFVbEOCMHyR1huh/V+lWhyGjZgBPiAieyfEGHZuamGjYpG8oHSQvM X-Received: by 2002:a05:622a:138b:b0:403:b220:cede with SMTP id o11-20020a05622a138b00b00403b220cedemr3613577qtk.3.1689028100693; Mon, 10 Jul 2023 15:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028100; cv=none; d=google.com; s=arc-20160816; b=tST8oS2tx2S5ZLR3i9qDkA16tNWCd85fGeBbmNH6iVfsR4etcMUyDT9c+DtWwLwihH vQH6fJALm/YNTeZOi0Engi6JJHqpRgw+OQ9jzYKnBTirnpOVz+8IpNRuVDbRYcjPxDth Ew7ttB4K0dd044S2ZA1iYrSTjw72NFujIN9YfSzZqtXRX8ZCuCeV6Y0zp/ZIbA7SQkIM uCz6ttS6tcQnjTwGcFmYPjzm+xUQiKerH96j4a6QX+rFLMqJt/Ch6kAlMVbzFcXqr+H9 VG5FxaGnM185HasPFYa+D/BLz1JJ+/XIbA/0qRzvfy2YYd4kv5uEOTUK4qZzV/FVCGRJ ztNQ== 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=2a5apNottyWIlKCx3Fnb0NFRIHlNDNa485chSeE/FA8=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=AeHGYZcSSpfxPdqRX+WXvqQactGdQjRrwTMkfGz5O2YfRzl+J1Z7lHMhODcZFz7TOy 5hHiMILeLk7FpT4cgWvIchGS8m5UZPqoimvDB9/WYrPy60VS18EdaI8hVN+Tq0CdZKi5 V5a68kIxPNMI5oH5rJkQVf8PXA6Pi9WsSqftahp4IqPzdfxJZQiGoFljAd6vk8orK/S9 8H/soTMw1J61/6Nw3n129CXmRwKfjljlT4hFLESTw9X7iG1JrHAgynHHSADdXIgSNpN0 I09JrIjDVqdxGEGME3LWCBYYsPvvMEfwB8U1T3U8q1xO9cjCWhRmkNFEOGT4+cOrguZk fjhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vGYDwpyE; 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 a21-20020ac85b95000000b004009a10dcd0si321898qta.160.2023.07.10.15.28.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:28:20 -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=vGYDwpyE; 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 1qIzL1-0003SB-PK; Mon, 10 Jul 2023 18:26:35 -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 1qIzL0-0003S2-HW for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:34 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzKu-0001i3-Qo for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:34 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so51993565e9.0 for ; Mon, 10 Jul 2023 15:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689027986; x=1691619986; 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=2a5apNottyWIlKCx3Fnb0NFRIHlNDNa485chSeE/FA8=; b=vGYDwpyEiwT6bqyFHtEyNXsj55Be/8E149eTimaWEx9H42aYWc3qQWFXdqvEoK2Vqq hM3SeGUzNMTELYss0zGR4yZmiJxEuKpEAA+JiFuM6aU3waX0+507m3lGMvdIumUcr490 OhUcFjFY2BiB45njmj4n3+oxyifVEQsNq1pViTDuS9bVMjNa7zlJbKjN/W8ew4QZ//z0 V3yaJHeeyauJEzRTf8dGPQBXPeN2HnoeZQWEgsVOi4MLB0Kzhsp6elBuGW9NJBJKMwA/ 6gGrrb8ImJC2KtZVXI4PPkuqypGoBVDIOMRE4f4ig+L4w6R2nrarm7fbd5IhH4b4zsaq nDfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027986; x=1691619986; 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=2a5apNottyWIlKCx3Fnb0NFRIHlNDNa485chSeE/FA8=; b=RRasTNhlkr1VmZk5zxo4HFZWzEWMWmVi/+Not2dDHlBCUmFgIhu6r4xysenRl4nO5x 1Upnv8i6e2m9Ua6VY8iKNmNxiLv8o/mj6kvliS59+bAktuj/MxbKVXjP+lHknn2Gzw25 5RTIp0sH8H8zvtTUaI7oF3kD59gwI1QA+pfGteJgcN6Gh7VftYLIbo+/43KT4ae4eYWi cWYAToh5LUKtHrRqspeMG6kcrGLCoZ9SFNehAol7bKVbHB72EnW5ws77fDmAiAxvQCU6 zYkfkrJr48K32MBfPVaVga7EGLHWogio7ZKsaqgkUwGRLqcc2g3+r2A3BUxyFQm+uYxO iBtg== X-Gm-Message-State: ABy/qLYj1WtpZKcOW/1svbzNTeLvnIFhYecbKOwAxHU0U3IY0Qlfu2YO KKsD/XhXnrS3UqrlnaSLbl8lvxD44X1tlXrFCq2Y3Q== X-Received: by 2002:a1c:7914:0:b0:3f9:b1e7:8a4b with SMTP id l20-20020a1c7914000000b003f9b1e78a4bmr12269595wme.21.1689027985919; Mon, 10 Jul 2023 15:26:25 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id f11-20020a7bc8cb000000b003fa98908014sm11482716wml.8.2023.07.10.15.26.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 02/44] target/mips: Implement Loongson CSR instructions Date: Tue, 11 Jul 2023 00:25:29 +0200 Message-Id: <20230710222611.50978-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 From: Jiaxun Yang Loongson introduced CSR instructions since 3A4000, which looks similar to IOCSR and CPUCFG instructions we seen in LoongArch. Unfortunately we don't have much document about those instructions, bit fields of CPUCFG instructions and IOCSR registers can be found at 3A4000's user manual, while instruction encodings can be found at arch/mips/include/asm/mach-loongson64/loongson_regs.h from Linux Kernel. Our predefined CPUCFG bits are differ from actual 3A4000, since we can't emulate all CPUCFG features present in 3A4000 for now, we just enable bits for what we have in TCG. Signed-off-by: Jiaxun Yang Message-Id: <20230521214832.20145-2-jiaxun.yang@flygoat.com> [JY: Fixed typo in ase_lcsr_available(), retrict GEN_FALSE_TRANS] [PMD: Fix meson's mips_softmmu_ss -> mips_system_ss, restrict AddressSpace/MemoryRegion to SysEmu] Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu.h | 42 ++++++++++++++++ target/mips/helper.h | 4 ++ target/mips/internal.h | 2 + target/mips/tcg/translate.h | 1 + target/mips/tcg/sysemu_helper.h.inc | 8 +++ target/mips/tcg/lcsr.decode | 17 +++++++ target/mips/cpu.c | 10 ++++ target/mips/tcg/lcsr_translate.c | 75 ++++++++++++++++++++++++++++ target/mips/tcg/op_helper.c | 16 ++++++ target/mips/tcg/sysemu/lcsr_helper.c | 45 +++++++++++++++++ target/mips/tcg/translate.c | 3 ++ target/mips/cpu-defs.c.inc | 9 ++++ target/mips/tcg/meson.build | 2 + target/mips/tcg/sysemu/meson.build | 4 ++ 14 files changed, 238 insertions(+) create mode 100644 target/mips/tcg/lcsr.decode create mode 100644 target/mips/tcg/lcsr_translate.c create mode 100644 target/mips/tcg/sysemu/lcsr_helper.c diff --git a/target/mips/cpu.h b/target/mips/cpu.h index d3ee874a18..f81bd06f5e 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -3,6 +3,9 @@ #include "cpu-qom.h" #include "exec/cpu-defs.h" +#ifndef CONFIG_USER_ONLY +#include "exec/memory.h" +#endif #include "fpu/softfloat-types.h" #include "hw/clock.h" #include "mips-defs.h" @@ -1068,6 +1071,33 @@ typedef struct CPUArchState { */ int32_t CP0_DESAVE; target_ulong CP0_KScratch[MIPS_KSCRATCH_NUM]; +/* + * Loongson CSR CPUCFG registers + */ + uint32_t lcsr_cpucfg1; +#define CPUCFG1_FP 0 +#define CPUCFG1_FPREV 1 +#define CPUCFG1_MMI 4 +#define CPUCFG1_MSA1 5 +#define CPUCFG1_MSA2 6 +#define CPUCFG1_LSLDR0 16 +#define CPUCFG1_LSPERF 17 +#define CPUCFG1_LSPERFX 18 +#define CPUCFG1_LSSYNCI 19 +#define CPUCFG1_LLEXC 20 +#define CPUCFG1_SCRAND 21 +#define CPUCFG1_MUALP 25 +#define CPUCFG1_KMUALEN 26 +#define CPUCFG1_ITLBT 27 +#define CPUCFG1_SFBP 29 +#define CPUCFG1_CDMAP 30 + uint32_t lcsr_cpucfg2; +#define CPUCFG2_LEXT1 0 +#define CPUCFG2_LEXT2 1 +#define CPUCFG2_LEXT3 2 +#define CPUCFG2_LSPW 3 +#define CPUCFG2_LCSRP 27 +#define CPUCFG2_LDISBLIKELY 28 /* We waste some space so we can handle shadow registers like TCs. */ TCState tcs[MIPS_SHADOW_SET_MAX]; @@ -1156,6 +1186,12 @@ typedef struct CPUArchState { void *irq[8]; struct MIPSITUState *itu; MemoryRegion *itc_tag; /* ITC Configuration Tags */ + + /* Loongson IOCSR memory */ + struct { + AddressSpace as; + MemoryRegion mr; + } iocsr; #endif const mips_def_t *cpu_model; @@ -1281,6 +1317,12 @@ static inline bool ase_msa_available(CPUMIPSState *env) return env->CP0_Config3 & (1 << CP0C3_MSAP); } +/* Check presence of Loongson CSR instructions */ +static inline bool ase_lcsr_available(CPUMIPSState *env) +{ + return env->lcsr_cpucfg2 & (1 << CPUCFG2_LCSRP); +} + /* Check presence of multi-threading ASE implementation */ static inline bool ase_mt_available(CPUMIPSState *env) { diff --git a/target/mips/helper.h b/target/mips/helper.h index de32d82e98..0f8462febb 100644 --- a/target/mips/helper.h +++ b/target/mips/helper.h @@ -196,6 +196,10 @@ DEF_HELPER_1(rdhwr_xnp, tl, env) DEF_HELPER_2(pmon, void, env, int) DEF_HELPER_1(wait, void, env) +#ifdef TARGET_MIPS64 +DEF_HELPER_FLAGS_2(lcsr_cpucfg, TCG_CALL_NO_RWG_SE, tl, env, tl) +#endif + /* Loongson multimedia functions. */ DEF_HELPER_FLAGS_2(paddsh, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(paddush, TCG_CALL_NO_RWG_SE, i64, i64, i64) diff --git a/target/mips/internal.h b/target/mips/internal.h index 4b0031d10d..1d0c026c7d 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -79,6 +79,8 @@ struct mips_def_t { int32_t CP0_PageGrain_rw_bitmask; int32_t CP0_PageGrain; target_ulong CP0_EBaseWG_rw_bitmask; + uint32_t lcsr_cpucfg1; + uint32_t lcsr_cpucfg2; uint64_t insn_flags; enum mips_mmu_types mmu_type; int32_t SAARP; diff --git a/target/mips/tcg/translate.h b/target/mips/tcg/translate.h index 3b0498a47a..db3dc932c7 100644 --- a/target/mips/tcg/translate.h +++ b/target/mips/tcg/translate.h @@ -221,6 +221,7 @@ bool decode_isa_rel6(DisasContext *ctx, uint32_t insn); bool decode_ase_msa(DisasContext *ctx, uint32_t insn); bool decode_ext_txx9(DisasContext *ctx, uint32_t insn); #if defined(TARGET_MIPS64) +bool decode_ase_lcsr(DisasContext *ctx, uint32_t insn); bool decode_ext_tx79(DisasContext *ctx, uint32_t insn); bool decode_ext_octeon(DisasContext *ctx, uint32_t insn); #endif diff --git a/target/mips/tcg/sysemu_helper.h.inc b/target/mips/tcg/sysemu_helper.h.inc index af585b5d9c..f163af1eac 100644 --- a/target/mips/tcg/sysemu_helper.h.inc +++ b/target/mips/tcg/sysemu_helper.h.inc @@ -181,3 +181,11 @@ DEF_HELPER_1(eret, void, env) DEF_HELPER_1(eretnc, void, env) DEF_HELPER_1(deret, void, env) DEF_HELPER_3(cache, void, env, tl, i32) + +#ifdef TARGET_MIPS64 +/* Longson CSR */ +DEF_HELPER_2(lcsr_rdcsr, i64, env, tl) +DEF_HELPER_2(lcsr_drdcsr, i64, env, tl) +DEF_HELPER_3(lcsr_wrcsr, void, env, tl, tl) +DEF_HELPER_3(lcsr_dwrcsr, void, env, tl, tl) +#endif diff --git a/target/mips/tcg/lcsr.decode b/target/mips/tcg/lcsr.decode new file mode 100644 index 0000000000..960ef8b6f9 --- /dev/null +++ b/target/mips/tcg/lcsr.decode @@ -0,0 +1,17 @@ +# Loongson CSR instructions +# +# Copyright (C) 2023 Jiaxun Yang +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# + +&r rs rt rd sa + +@rs_rd ...... rs:5 ..... rd:5 ..... ...... &r rt=0 sa=0 + +CPUCFG 110010 ..... 01000 ..... 00100 011000 @rs_rd + +RDCSR 110010 ..... 00000 ..... 00100 011000 @rs_rd +WRCSR 110010 ..... 00001 ..... 00100 011000 @rs_rd +DRDCSR 110010 ..... 00010 ..... 00100 011000 @rs_rd +DWRCSR 110010 ..... 00011 ..... 00100 011000 @rs_rd diff --git a/target/mips/cpu.c b/target/mips/cpu.c index b7119cbbb4..63da1948fd 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -244,6 +244,8 @@ static void mips_cpu_reset_hold(Object *obj) env->CP0_PageGrain_rw_bitmask = env->cpu_model->CP0_PageGrain_rw_bitmask; env->CP0_PageGrain = env->cpu_model->CP0_PageGrain; env->CP0_EBaseWG_rw_bitmask = env->cpu_model->CP0_EBaseWG_rw_bitmask; + env->lcsr_cpucfg1 = env->cpu_model->lcsr_cpucfg1; + env->lcsr_cpucfg2 = env->cpu_model->lcsr_cpucfg2; env->active_fpu.fcr0 = env->cpu_model->CP1_fcr0; env->active_fpu.fcr31_rw_bitmask = env->cpu_model->CP1_fcr31_rw_bitmask; env->active_fpu.fcr31 = env->cpu_model->CP1_fcr31; @@ -507,6 +509,14 @@ static void mips_cpu_initfn(Object *obj) cpu->count_div = clock_new(OBJECT(obj), "clk-div-count"); env->count_clock = clock_new(OBJECT(obj), "clk-count"); env->cpu_model = mcc->cpu_def; +#ifndef CONFIG_USER_ONLY + if (mcc->cpu_def->lcsr_cpucfg2 & (1 << CPUCFG2_LCSRP)) { + memory_region_init_io(&env->iocsr.mr, OBJECT(cpu), NULL, + env, "iocsr", UINT64_MAX); + address_space_init(&env->iocsr.as, + &env->iocsr.mr, "IOCSR"); + } +#endif } static char *mips_cpu_type_name(const char *cpu_model) diff --git a/target/mips/tcg/lcsr_translate.c b/target/mips/tcg/lcsr_translate.c new file mode 100644 index 0000000000..9f2a5f4a37 --- /dev/null +++ b/target/mips/tcg/lcsr_translate.c @@ -0,0 +1,75 @@ +/* + * Loongson CSR instructions translation routines + * + * Copyright (c) 2023 Jiaxun Yang + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "tcg/tcg-op.h" +#include "tcg/tcg-op-gvec.h" +#include "exec/helper-gen.h" +#include "translate.h" + +/* Include the auto-generated decoder. */ +#include "decode-lcsr.c.inc" + +static bool trans_CPUCFG(DisasContext *ctx, arg_CPUCFG *a) +{ + TCGv dest = tcg_temp_new(); + TCGv src1 = tcg_temp_new(); + + gen_load_gpr(src1, a->rs); + gen_helper_lcsr_cpucfg(dest, cpu_env, src1); + gen_store_gpr(dest, a->rd); + + return true; +} + +#ifndef CONFIG_USER_ONLY +static bool gen_rdcsr(DisasContext *ctx, arg_r *a, + void (*func)(TCGv, TCGv_ptr, TCGv)) +{ + TCGv dest = tcg_temp_new(); + TCGv src1 = tcg_temp_new(); + + check_cp0_enabled(ctx); + gen_load_gpr(src1, a->rs); + func(dest, cpu_env, src1); + gen_store_gpr(dest, a->rd); + + return true; +} + +static bool gen_wrcsr(DisasContext *ctx, arg_r *a, + void (*func)(TCGv_ptr, TCGv, TCGv)) +{ + TCGv val = tcg_temp_new(); + TCGv addr = tcg_temp_new(); + + check_cp0_enabled(ctx); + gen_load_gpr(addr, a->rs); + gen_load_gpr(val, a->rd); + func(cpu_env, addr, val); + + return true; +} + +TRANS(RDCSR, gen_rdcsr, gen_helper_lcsr_rdcsr) +TRANS(DRDCSR, gen_rdcsr, gen_helper_lcsr_drdcsr) +TRANS(WRCSR, gen_wrcsr, gen_helper_lcsr_wrcsr) +TRANS(DWRCSR, gen_wrcsr, gen_helper_lcsr_dwrcsr) +#else +#define GEN_FALSE_TRANS(name) \ +static bool trans_##name(DisasContext *ctx, arg_##name * a) \ +{ \ + return false; \ +} + +GEN_FALSE_TRANS(RDCSR) +GEN_FALSE_TRANS(DRDCSR) +GEN_FALSE_TRANS(WRCSR) +GEN_FALSE_TRANS(DWRCSR) +#endif diff --git a/target/mips/tcg/op_helper.c b/target/mips/tcg/op_helper.c index ef3dafcbb3..98935b5e64 100644 --- a/target/mips/tcg/op_helper.c +++ b/target/mips/tcg/op_helper.c @@ -257,6 +257,22 @@ void helper_pmon(CPUMIPSState *env, int function) } } +#ifdef TARGET_MIPS64 +target_ulong helper_lcsr_cpucfg(CPUMIPSState *env, target_ulong rs) +{ + switch (rs) { + case 0: + return env->CP0_PRid; + case 1: + return env->lcsr_cpucfg1; + case 2: + return env->lcsr_cpucfg2; + default: + return 0; + } +} +#endif + #if !defined(CONFIG_USER_ONLY) void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr, diff --git a/target/mips/tcg/sysemu/lcsr_helper.c b/target/mips/tcg/sysemu/lcsr_helper.c new file mode 100644 index 0000000000..942143d209 --- /dev/null +++ b/target/mips/tcg/sysemu/lcsr_helper.c @@ -0,0 +1,45 @@ +/* + * Loongson CSR instructions translation routines + * + * Copyright (c) 2023 Jiaxun Yang + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "cpu.h" +#include "internal.h" +#include "qemu/host-utils.h" +#include "exec/helper-proto.h" +#include "exec/exec-all.h" +#include "exec/cpu_ldst.h" + +#define GET_MEMTXATTRS(cas) \ + ((MemTxAttrs){.requester_id = env_cpu(cas)->cpu_index}) + +uint64_t helper_lcsr_rdcsr(CPUMIPSState *env, target_ulong r_addr) +{ + return address_space_ldl(&env->iocsr.as, r_addr, + GET_MEMTXATTRS(env), NULL); +} + +uint64_t helper_lcsr_drdcsr(CPUMIPSState *env, target_ulong r_addr) +{ + return address_space_ldq(&env->iocsr.as, r_addr, + GET_MEMTXATTRS(env), NULL); +} + +void helper_lcsr_wrcsr(CPUMIPSState *env, target_ulong w_addr, + target_ulong val) +{ + address_space_stl(&env->iocsr.as, w_addr, + val, GET_MEMTXATTRS(env), NULL); +} + +void helper_lcsr_dwrcsr(CPUMIPSState *env, target_ulong w_addr, + target_ulong val) +{ + address_space_stq(&env->iocsr.as, w_addr, + val, GET_MEMTXATTRS(env), NULL); +} diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 74af91e4f5..7abbb0b5e2 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -15352,6 +15352,9 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx) return; } #if defined(TARGET_MIPS64) + if (ase_lcsr_available(env) && decode_ase_lcsr(ctx, ctx->opcode)) { + return; + } if (cpu_supports_isa(env, INSN_OCTEON) && decode_ext_octeon(ctx, ctx->opcode)) { return; } diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc index d45f245a67..167c96cb27 100644 --- a/target/mips/cpu-defs.c.inc +++ b/target/mips/cpu-defs.c.inc @@ -895,6 +895,15 @@ const mips_def_t mips_defs[] = .CP1_fcr31 = 0, .CP1_fcr31_rw_bitmask = 0xFF83FFFF, .MSAIR = (0x01 << MSAIR_ProcID) | (0x40 << MSAIR_Rev), + .lcsr_cpucfg1 = (1 << CPUCFG1_FP) | (2 << CPUCFG1_FPREV) | + (1 << CPUCFG1_MSA1) | (1 << CPUCFG1_LSLDR0) | + (1 << CPUCFG1_LSPERF) | (1 << CPUCFG1_LSPERFX) | + (1 << CPUCFG1_LSSYNCI) | (1 << CPUCFG1_LLEXC) | + (1 << CPUCFG1_SCRAND) | (1 << CPUCFG1_MUALP) | + (1 << CPUCFG1_KMUALEN) | (1 << CPUCFG1_ITLBT) | + (1 << CPUCFG1_SFBP) | (1 << CPUCFG1_CDMAP), + .lcsr_cpucfg2 = (1 << CPUCFG2_LEXT1) | (1 << CPUCFG2_LCSRP) | + (1 << CPUCFG2_LDISBLIKELY), .SEGBITS = 48, .PABITS = 48, .insn_flags = CPU_MIPS64R2 | INSN_LOONGSON3A | diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build index 7ee969ec8f..ea7fb582f2 100644 --- a/target/mips/tcg/meson.build +++ b/target/mips/tcg/meson.build @@ -4,6 +4,7 @@ gen = [ decodetree.process('tx79.decode', extra_args: '--static-decode=decode_tx79'), decodetree.process('vr54xx.decode', extra_args: '--decode=decode_ext_vr54xx'), decodetree.process('octeon.decode', extra_args: '--decode=decode_ext_octeon'), + decodetree.process('lcsr.decode', extra_args: '--decode=decode_ase_lcsr'), ] mips_ss.add(gen) @@ -26,6 +27,7 @@ mips_ss.add(files( mips_ss.add(when: 'TARGET_MIPS64', if_true: files( 'tx79_translate.c', 'octeon_translate.c', + 'lcsr_translate.c', ), if_false: files( 'mxu_translate.c', )) diff --git a/target/mips/tcg/sysemu/meson.build b/target/mips/tcg/sysemu/meson.build index 43b35b3803..ec665a4b1e 100644 --- a/target/mips/tcg/sysemu/meson.build +++ b/target/mips/tcg/sysemu/meson.build @@ -4,3 +4,7 @@ mips_system_ss.add(files( 'special_helper.c', 'tlb_helper.c', )) + +mips_system_ss.add(when: 'TARGET_MIPS64', if_true: files( + 'lcsr_helper.c', +)) From patchwork Mon Jul 10 22:25:30 2023 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: 701098 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411225wrs; Mon, 10 Jul 2023 15:33:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlGH61bRWhyxxKKMuzI85zPtlhriNUVTfx+N2WEAXIvgFVGmtIz6VgmEk2YPnC7/qQphrlh4 X-Received: by 2002:a05:622a:199a:b0:403:b1f4:2508 with SMTP id u26-20020a05622a199a00b00403b1f42508mr3089249qtc.27.1689028418723; Mon, 10 Jul 2023 15:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028418; cv=none; d=google.com; s=arc-20160816; b=rXgOkzQFSCN5IspuxVAaH54qPAJre9COZjdbnN778zj9+dhaNe1Hm9H09hcOmfTf8x GdWWJTf4O9NBZ6fzlWNhLASZs7Cbmvb83jqSRTR/Az1IjL3UOKtua1BkOIY5VJjYjmpv M1EZ6JyLYkTWdfeoNZsJhu+2J67e8I6TP7UNlG52zWDmmMdzVKTgrA1oQB/InFv2+Vnv heIw4CyopRZb9K8nJq+IqapNKaFT0zpbAUL12YYxhvHDfq7rCGqbqOeT0Hw3FammNVWm XmPe2UL3GoOeDyUjbf69iUuMJjKTFuzg3bkGC2GGePgw1xbwmpkGwrUDv5ko79OrA3Gd Kclw== 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=FQn1GjoC4A2rsKEvs+LWc6jELr6JbHXlZFPyo2gF2Rw=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=0p3707wprEpyD/jnzHnmyjoxHZyDpCZ/9ccFrUDBZu25aJpfwNofivb6omtPLLNbIr Ulx04CjNe34ZO4edZiRuJWIL1B01t1B5akPSYYdWYIloVXFUEABSwTsMxdapwi70pI1h +1TmyglN43pQWxs7XCog/Z2zFKg93Ryx4zmNl17UnYZ0bn7ZSd6hvjI8XrXlJUZbRQmI Rx3KB61oCGe8Jpiw6abyRgCAKG0If7NWK158Cb8SFTdsN/Kyu9w5UTw84cvkoQw43+oM Daf/K3bE5BLOlTPpMRxWakyRqts53L0WMsXHMIjUv9RXKSJ9PBxDuKydht5KXVhzzrwD CmgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SH3nekmR; 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 z14-20020ac87f8e000000b003fdeb6b4fd5si308163qtj.766.2023.07.10.15.33.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:38 -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=SH3nekmR; 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 1qIzL3-0003Sa-BS; Mon, 10 Jul 2023 18:26:37 -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 1qIzL1-0003SC-Sp for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:35 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzKy-0001iK-Q0 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:35 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fba8e2aa52so56054735e9.1 for ; Mon, 10 Jul 2023 15:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689027991; x=1691619991; 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=FQn1GjoC4A2rsKEvs+LWc6jELr6JbHXlZFPyo2gF2Rw=; b=SH3nekmRsrrP45NJiKYFzciJ0htGs7u1GTzBkcGtTNdr9BDOq1oEW6UlpkM4K7a0PD G2BLqpHb2GGVDgR3/T2l3xIhxrmn1tiltyrcgc+zLISf1QsokxK7tPttsf8+jJR51wXR QfMJ5vB4aAJLdENM9Y1LPh1HAFD9ATfPbZfHm6u0vod3BXrjIyEbNiDetxyOEDRC+HRX Owlscsl3uLnEwHaKok75VS1psTZypZhrFkkEzOfpB5nENvUVqxlJLVTGQ4/mwj08kwGI a1LMACpziopJ5IrWueW9h7TgsicJQbimrJN/eOXsI1VNNtcCxqMkaNH8+uqYIbJGqwgo S3GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027991; x=1691619991; 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=FQn1GjoC4A2rsKEvs+LWc6jELr6JbHXlZFPyo2gF2Rw=; b=P1DOz7XzfTIZlHmWI9TtWLj9KEIlQygF1lbIY53kzb219RIU/QGXSMbo+AakSCBtZM B2YkQnLvghtCgDs35m53Ly5K86liD5FVWjzmJUp3RXW+fbH3nqh1oOsg95TFuBYDEZQX QCX35VC2rW1XLlaZoL4pIxhHccr/Tq5vJhF2UTpDweTyX7YcvRcMZQfbYyqShdJpZD99 57vr9xhKzRLJF40dzIekgQ5Oa5sYpu3xjMdet5GDRolc+rGYVokwP5QnHkvLpw6Rny4S pZ+fsk8MfvmQCLM3KDccigLlGIFhinbVHprhOgBKKTNJJQP/UAcRYbyXAmqSmw9fLTvq hsyw== X-Gm-Message-State: ABy/qLbdn7plTdDfh5ASUtasUinrzdRukDoFeA1BcdR5IhpLNxZfnXh+ BzWP6TsUzRGP3ng3TpjQWAPVN6oXXgSZJuU76Gapmw== X-Received: by 2002:a5d:4d8e:0:b0:314:3e77:f210 with SMTP id b14-20020a5d4d8e000000b003143e77f210mr13084116wru.59.1689027991419; Mon, 10 Jul 2023 15:26:31 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id c7-20020a5d4147000000b003141a3c4353sm542731wrq.30.2023.07.10.15.26.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 03/44] hw/mips/loongson3_virt: Relax CPU restrictions for TCG Date: Tue, 11 Jul 2023 00:25:30 +0200 Message-Id: <20230710222611.50978-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Jiaxun Yang After implemented CPUCFG and CSR, we are now able to boot Linux kernel with Loongson-3A4000 CPU, so there is no point to restrict CPU type to 3A1000 only, instead we just check for presence of INSN_LOONGSON3A. Signed-off-by: Jiaxun Yang Message-Id: <20230521214832.20145-3-jiaxun.yang@flygoat.com> [JY: Check for cpu_type_supports_isa(INSN_LOONGSON3A)] Signed-off-by: Philippe Mathieu-Daudé --- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 3dd91da7a6..4018b8c1d3 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -481,8 +481,8 @@ static void mips_loongson3_virt_init(MachineState *machine) if (!machine->cpu_type) { machine->cpu_type = MIPS_CPU_TYPE_NAME("Loongson-3A1000"); } - if (!strstr(machine->cpu_type, "Loongson-3A1000")) { - error_report("Loongson-3/TCG needs cpu type Loongson-3A1000"); + if (!cpu_type_supports_isa(machine->cpu_type, INSN_LOONGSON3A)) { + error_report("Loongson-3/TCG needs a Loongson-3 series cpu"); exit(1); } } else { From patchwork Mon Jul 10 22:25:31 2023 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: 701056 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5408768wrs; Mon, 10 Jul 2023 15:27:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFYqGLlQsTTQA511MAif/B7oE09icMe1RiWVUXD8JX7ItPG1VlW5koKGER8jrXoRmkI3mcf X-Received: by 2002:a05:620a:44c5:b0:765:467e:133a with SMTP id y5-20020a05620a44c500b00765467e133amr16922299qkp.23.1689028038394; Mon, 10 Jul 2023 15:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028038; cv=none; d=google.com; s=arc-20160816; b=cz+R8KQ+Az+eZiF2YPL4NmefdWSgR47rzYDbyBwTpNfP9Hcz0WfwBIKNFmtP4CEaTy VsgsX+oUc3BQSuXbgv1urd1gYUveprUIGbW45preLENfNqbDs2JD9uuJqFH8oLJYGXra +kKoOxRvXONSwDeX2vvW5O+vvdYk048rvxgz9c31O1ix+xE3f+uJ4CzfvIQPdR/CbWhi WD/yLDLFzj3Q5kZFZz18LtNY03IZ976MuZXzh1zhywLSqBNMQ0xjkGGaV8dQg+d8ByYT XRKUnldZc/W1Lb8WzHl8BMDp9B0TXwyaFJ9U3yEK3L4mW+6ZNkD9CBhbzwG0jAMBCFXf jizg== 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=Q1Cdm2xOyXJHfXBEnkIgza905DyMgXBlOTeRkhn8G/g=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=uyb3r/Zd0aH12a4Fns7yXk4/Bblk2aAkX0qwLTJkXLDiEa+0DrL8y6mkqQj7Glo/tU aiRwtYirzzfVRNL23UljIuN+CqOq+NUBE2Sboh0Db8ebypSpDS8BJA3PbhZdMkXR5df7 yeUeRC4S9xuhOjCAMY3yzYvJxKZZePD8P32SEjzp3v940UEsau5eDVHJB3ThexyJNSim 0Qk+CFYha1yvZ3P55kE2nvAJc8JHewl+uwki1IstWSmVEdmfoCsoQUPlQKYJwdSgn4bJ LJGFrpwaNEBiS93xxaZomtUDMQm1znB108qgNtzEGzZjWCQUE12S0FmRIaRYf01rHIuw WUDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jhobM+aZ; 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 h22-20020a05620a401600b0075f0073cd2bsi281001qko.10.2023.07.10.15.27.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:18 -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=jhobM+aZ; 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 1qIzLB-0003Tr-Nn; Mon, 10 Jul 2023 18:26: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 1qIzLA-0003Th-BP for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:44 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzL4-0001jB-Sm for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:44 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso63863685e9.1 for ; Mon, 10 Jul 2023 15:26:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689027997; x=1691619997; 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=Q1Cdm2xOyXJHfXBEnkIgza905DyMgXBlOTeRkhn8G/g=; b=jhobM+aZOV9b5m6eBdJyouvAtUQbqt4IjIGDiydxb7x3JWiC8y5/4J5JZlV4ftgxJi dlfTfhAhyaKWjg8ae5lux7ERGCgiOWmeKhJ2Oxv2kSn9hFyZYeQihGafgRNYEEGEKD4F me4k+axfo3q0FgQrf2ZkxJWtyFrrUfGDgbKwsqq5tyiRyZkFVwfyxJyHYSl7RKLf1f7b nhGO8cWfza5lU+cY1OTx7RnT2u2avIeMB3TMLod19z1s7S1y0UPzK1jeGtEtKhfa2Wwt 41C7YRLeBa7pBJ9XDkoaFuQLSlSE6CKNGJmWx5WrDKg5SDol5LODwhU0GTqALHVBH2xw CxGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027997; x=1691619997; 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=Q1Cdm2xOyXJHfXBEnkIgza905DyMgXBlOTeRkhn8G/g=; b=ChKBvEd29lG5ef2SEES6hbEqhwKPARtX9Hr51wOy8eMLHoFk7/fPZUAHt16d7S5D7o Ie5AEH+ZtJQpOr36RpAys8Y4E+iIaZKtCCh8ahlHwDYf5z61JRYyBw6xTXEdFNpIgthj sBLpC+IbXkQsFSWVUAW/26r5fWrQLV+wyLxncpR6cRSrCZ0OYGSi6yAbL+7CVPZeMbOF rValNVKIDcP/wJ5T1frHRyb2wZsrJYjFPB7Bz7seii11uGPCJ9W/Z37Li66wK5NxAxjH J5hUgj5pxOIv9hRD5RQbN52JLRuWtqdY+0Sl4KJ/u8KivQQb0aAV5vO/nKNTipyW0HuP /dqg== X-Gm-Message-State: ABy/qLZQrLC6xwE363OSJFIEulVe1b7rEBR663jlyyVPILVgwfsUnbMG xuKOChxDUAR3040G1apbv8sYrhTH48Vq9QsgDRSrDw== X-Received: by 2002:a7b:c455:0:b0:3fa:85ad:6672 with SMTP id l21-20020a7bc455000000b003fa85ad6672mr16870801wmi.41.1689027997024; Mon, 10 Jul 2023 15:26:37 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id l22-20020a7bc456000000b003fbb5142c4bsm11321350wmi.18.2023.07.10.15.26.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 04/44] target/mips: Add emulation of MXU instructions for 32-bit load/store Date: Tue, 11 Jul 2023 00:25:31 +0200 Message-Id: <20230710222611.50978-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 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 From: Siarhei Volkau Add support for emulating: - S32LDDV and S32LDDVR - S32STD and S32STDR - S32STDV and S32STDVR MXU instructions. Add support for emulating MXU instructions with address register post-modify counterparts: - S32LDI and S32LDIR - S32LDIV and S32LDIVR - S32SDI and S32SDIR - S32SDIV and S32SDIVR Refactor support for emulating the S32LDD and S32LDDR instructions. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-2-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 306 +++++++++++++++++++++++++++++--- 1 file changed, 281 insertions(+), 25 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 39348b3a91..c69c5795c9 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -237,11 +237,11 @@ * ├─ 001100 ─ OPC_MXU_D16MADL * ├─ 001101 ─ OPC_MXU_S16MAD * ├─ 001110 ─ OPC_MXU_Q16ADD - * ├─ 001111 ─ OPC_MXU_D16MACE 23 + * ├─ 001111 ─ OPC_MXU_D16MACE 20 (13..10 don't care) * │ ┌─ 0 ─ OPC_MXU_S32LDD * ├─ 010000 ─ OPC_MXU__POOL04 ─┴─ 1 ─ OPC_MXU_S32LDDR * │ - * │ 23 + * │ 20 (13..10 don't care) * ├─ 010001 ─ OPC_MXU__POOL05 ─┬─ 0 ─ OPC_MXU_S32STD * │ └─ 1 ─ OPC_MXU_S32STDR * │ @@ -253,11 +253,11 @@ * ├─ 010011 ─ OPC_MXU__POOL07 ─┬─ 0000 ─ OPC_MXU_S32STDV * │ └─ 0001 ─ OPC_MXU_S32STDVR * │ - * │ 23 + * │ 20 (13..10 don't care) * ├─ 010100 ─ OPC_MXU__POOL08 ─┬─ 0 ─ OPC_MXU_S32LDI * │ └─ 1 ─ OPC_MXU_S32LDIR * │ - * │ 23 + * │ 20 (13..10 don't care) * ├─ 010101 ─ OPC_MXU__POOL09 ─┬─ 0 ─ OPC_MXU_S32SDI * │ └─ 1 ─ OPC_MXU_S32SDIR * │ @@ -357,6 +357,13 @@ enum { OPC_MXU_D16MUL = 0x08, OPC_MXU_D16MAC = 0x0A, OPC_MXU__POOL04 = 0x10, + OPC_MXU__POOL05 = 0x11, + OPC_MXU__POOL06 = 0x12, + OPC_MXU__POOL07 = 0x13, + OPC_MXU__POOL08 = 0x14, + OPC_MXU__POOL09 = 0x15, + OPC_MXU__POOL10 = 0x16, + OPC_MXU__POOL11 = 0x17, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, OPC_MXU_S32M2I = 0x2E, @@ -378,11 +385,11 @@ enum { }; /* - * MXU pool 04 + * MXU pool 04 05 06 07 08 09 10 11 */ enum { - OPC_MXU_S32LDD = 0x00, - OPC_MXU_S32LDDR = 0x01, + OPC_MXU_S32LDST = 0x00, + OPC_MXU_S32LDSTR = 0x01, }; /* @@ -806,35 +813,147 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx) /* * S32LDD XRa, Rb, S12 - Load a word from memory to XRF - * S32LDDR XRa, Rb, S12 - Load a word from memory to XRF, reversed byte seq. + * S32LDDR XRa, Rb, S12 - Load a word from memory to XRF + * in reversed byte seq. + * S32LDI XRa, Rb, S12 - Load a word from memory to XRF, + * post modify base address GPR. + * S32LDIR XRa, Rb, S12 - Load a word from memory to XRF, + * post modify base address GPR and load in reversed byte seq. */ -static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx) +static void gen_mxu_s32ldxx(DisasContext *ctx, bool reversed, bool postinc) { TCGv t0, t1; - uint32_t XRa, Rb, s12, sel; + uint32_t XRa, Rb, s12; t0 = tcg_temp_new(); t1 = tcg_temp_new(); XRa = extract32(ctx->opcode, 6, 4); - s12 = extract32(ctx->opcode, 10, 10); - sel = extract32(ctx->opcode, 20, 1); + s12 = sextract32(ctx->opcode, 10, 10); Rb = extract32(ctx->opcode, 21, 5); gen_load_gpr(t0, Rb); + tcg_gen_movi_tl(t1, s12 * 4); + tcg_gen_add_tl(t0, t0, t1); - tcg_gen_movi_tl(t1, s12); - tcg_gen_shli_tl(t1, t1, 2); - if (s12 & 0x200) { - tcg_gen_ori_tl(t1, t1, 0xFFFFF000); - } - tcg_gen_add_tl(t1, t0, t1); - tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, (MO_TESL ^ (sel * MO_BSWAP)) | - ctx->default_tcg_memop_mask); - + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, + (MO_TESL ^ (reversed ? MO_BSWAP : 0)) | + ctx->default_tcg_memop_mask); gen_store_mxu_gpr(t1, XRa); + + if (postinc) { + gen_store_gpr(t0, Rb); + } } +/* + * S32STD XRa, Rb, S12 - Store a word from XRF to memory + * S32STDR XRa, Rb, S12 - Store a word from XRF to memory + * in reversed byte seq. + * S32SDI XRa, Rb, S12 - Store a word from XRF to memory, + * post modify base address GPR. + * S32SDIR XRa, Rb, S12 - Store a word from XRF to memory, + * post modify base address GPR and store in reversed byte seq. + */ +static void gen_mxu_s32stxx(DisasContext *ctx, bool reversed, bool postinc) +{ + TCGv t0, t1; + uint32_t XRa, Rb, s12; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + s12 = sextract32(ctx->opcode, 10, 10); + Rb = extract32(ctx->opcode, 21, 5); + + gen_load_gpr(t0, Rb); + tcg_gen_movi_tl(t1, s12 * 4); + tcg_gen_add_tl(t0, t0, t1); + + gen_load_mxu_gpr(t1, XRa); + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, + (MO_TESL ^ (reversed ? MO_BSWAP : 0)) | + ctx->default_tcg_memop_mask); + + if (postinc) { + gen_store_gpr(t0, Rb); + } +} + +/* + * S32LDDV XRa, Rb, Rc, STRD2 - Load a word from memory to XRF + * S32LDDVR XRa, Rb, Rc, STRD2 - Load a word from memory to XRF + * in reversed byte seq. + * S32LDIV XRa, Rb, Rc, STRD2 - Load a word from memory to XRF, + * post modify base address GPR. + * S32LDIVR XRa, Rb, Rc, STRD2 - Load a word from memory to XRF, + * post modify base address GPR and load in reversed byte seq. + */ +static void gen_mxu_s32ldxvx(DisasContext *ctx, bool reversed, + bool postinc, uint32_t strd2) +{ + TCGv t0, t1; + uint32_t XRa, Rb, Rc; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + Rc = extract32(ctx->opcode, 16, 5); + Rb = extract32(ctx->opcode, 21, 5); + + gen_load_gpr(t0, Rb); + gen_load_gpr(t1, Rc); + tcg_gen_shli_tl(t1, t1, strd2); + tcg_gen_add_tl(t0, t0, t1); + + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, + (MO_TESL ^ (reversed ? MO_BSWAP : 0)) | + ctx->default_tcg_memop_mask); + gen_store_mxu_gpr(t1, XRa); + + if (postinc) { + gen_store_gpr(t0, Rb); + } +} + +/* + * S32STDV XRa, Rb, Rc, STRD2 - Load a word from memory to XRF + * S32STDVR XRa, Rb, Rc, STRD2 - Load a word from memory to XRF + * in reversed byte seq. + * S32SDIV XRa, Rb, Rc, STRD2 - Load a word from memory to XRF, + * post modify base address GPR. + * S32SDIVR XRa, Rb, Rc, STRD2 - Load a word from memory to XRF, + * post modify base address GPR and store in reversed byte seq. + */ +static void gen_mxu_s32stxvx(DisasContext *ctx, bool reversed, + bool postinc, uint32_t strd2) +{ + TCGv t0, t1; + uint32_t XRa, Rb, Rc; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + Rc = extract32(ctx->opcode, 16, 5); + Rb = extract32(ctx->opcode, 21, 5); + + gen_load_gpr(t0, Rb); + gen_load_gpr(t1, Rc); + tcg_gen_shli_tl(t1, t1, strd2); + tcg_gen_add_tl(t0, t0, t1); + + gen_load_mxu_gpr(t1, XRa); + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, + (MO_TESL ^ (reversed ? MO_BSWAP : 0)) | + ctx->default_tcg_memop_mask); + + if (postinc) { + gen_store_gpr(t0, Rb); + } +} /* * MXU instruction category: logic @@ -1440,13 +1559,129 @@ static void decode_opc_mxu__pool00(DisasContext *ctx) static void decode_opc_mxu__pool04(DisasContext *ctx) { - uint32_t opcode = extract32(ctx->opcode, 20, 1); + uint32_t reversed = extract32(ctx->opcode, 20, 1); + uint32_t opcode = extract32(ctx->opcode, 10, 4); + + /* Don't care about opcode bits as their meaning is unknown yet */ + switch (opcode) { + default: + gen_mxu_s32ldxx(ctx, reversed, false); + break; + } +} + +static void decode_opc_mxu__pool05(DisasContext *ctx) +{ + uint32_t reversed = extract32(ctx->opcode, 20, 1); + uint32_t opcode = extract32(ctx->opcode, 10, 4); + + /* Don't care about opcode bits as their meaning is unknown yet */ + switch (opcode) { + default: + gen_mxu_s32stxx(ctx, reversed, false); + break; + } +} + +static void decode_opc_mxu__pool06(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 10, 4); + uint32_t strd2 = extract32(ctx->opcode, 14, 2); switch (opcode) { - case OPC_MXU_S32LDD: - case OPC_MXU_S32LDDR: - gen_mxu_s32ldd_s32lddr(ctx); + case OPC_MXU_S32LDST: + case OPC_MXU_S32LDSTR: + if (strd2 <= 2) { + gen_mxu_s32ldxvx(ctx, opcode, false, strd2); + break; + } + /* fallthrough */ + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); break; + } +} + +static void decode_opc_mxu__pool07(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 10, 4); + uint32_t strd2 = extract32(ctx->opcode, 14, 2); + + switch (opcode) { + case OPC_MXU_S32LDST: + case OPC_MXU_S32LDSTR: + if (strd2 <= 2) { + gen_mxu_s32stxvx(ctx, opcode, false, strd2); + break; + } + /* fallthrough */ + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + +static void decode_opc_mxu__pool08(DisasContext *ctx) +{ + uint32_t reversed = extract32(ctx->opcode, 20, 1); + uint32_t opcode = extract32(ctx->opcode, 10, 4); + + /* Don't care about opcode bits as their meaning is unknown yet */ + switch (opcode) { + default: + gen_mxu_s32ldxx(ctx, reversed, true); + break; + } +} + +static void decode_opc_mxu__pool09(DisasContext *ctx) +{ + uint32_t reversed = extract32(ctx->opcode, 20, 1); + uint32_t opcode = extract32(ctx->opcode, 10, 4); + + /* Don't care about opcode bits as their meaning is unknown yet */ + switch (opcode) { + default: + gen_mxu_s32stxx(ctx, reversed, true); + break; + } +} + +static void decode_opc_mxu__pool10(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 10, 4); + uint32_t strd2 = extract32(ctx->opcode, 14, 2); + + switch (opcode) { + case OPC_MXU_S32LDST: + case OPC_MXU_S32LDSTR: + if (strd2 <= 2) { + gen_mxu_s32ldxvx(ctx, opcode, true, strd2); + break; + } + /* fallthrough */ + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + +static void decode_opc_mxu__pool11(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 10, 4); + uint32_t strd2 = extract32(ctx->opcode, 14, 2); + + switch (opcode) { + case OPC_MXU_S32LDST: + case OPC_MXU_S32LDSTR: + if (strd2 <= 2) { + gen_mxu_s32stxvx(ctx, opcode, true, strd2); + break; + } + /* fallthrough */ default: MIPS_INVAL("decode_opc_mxu"); gen_reserved_instruction(ctx); @@ -1532,6 +1767,27 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL04: decode_opc_mxu__pool04(ctx); break; + case OPC_MXU__POOL05: + decode_opc_mxu__pool05(ctx); + break; + case OPC_MXU__POOL06: + decode_opc_mxu__pool06(ctx); + break; + case OPC_MXU__POOL07: + decode_opc_mxu__pool07(ctx); + break; + case OPC_MXU__POOL08: + decode_opc_mxu__pool08(ctx); + break; + case OPC_MXU__POOL09: + decode_opc_mxu__pool09(ctx); + break; + case OPC_MXU__POOL10: + decode_opc_mxu__pool10(ctx); + break; + case OPC_MXU__POOL11: + decode_opc_mxu__pool11(ctx); + break; case OPC_MXU_S8LDD: gen_mxu_s8ldd(ctx); break; From patchwork Mon Jul 10 22:25:32 2023 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: 701055 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5408751wrs; Mon, 10 Jul 2023 15:27:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEszZZdjGWruk4pfp9GJr6TdNtYUjH23Pite99CWIuNr73C/bncohFGsyqQZskcU3f5GBsK X-Received: by 2002:a05:620a:4051:b0:767:64cc:21c1 with SMTP id i17-20020a05620a405100b0076764cc21c1mr15649467qko.16.1689028035130; Mon, 10 Jul 2023 15:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028035; cv=none; d=google.com; s=arc-20160816; b=v7GhYj6HsUx6rWzjPO0w8lccn+hPSdpBDuojo8rmGAiCPiEhbb8rmxl7yKASPLdjHY fwx1ZuSVR35hCeOdct31dLClXNMeDKjwx14tp16q5KHQ9Qt+lujOmcZrdInKkxHA3oJp PUXzXUY9IqwaZHTizEy0ozPv3fqcCL8OkQhBdVZYvw0WbKhOyY0kiukW/aWHbwCqlXpK TYwnRxAROMRtY2YjWBVsUTWMYa+0GPhCCGmiBfrkK4FjERohrZxwWr4jiHXWAwqIGHMo xcZgIZXff4dYeZGX49ZQMueZ6c7ZswAvQO1ibka4+RAJdTAbFxz46YIlwYqdBd3KlLPM zFIQ== 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=0DwXvgpuWa6bvmkF5jLlb53TLUXpVmhoMetGx+sUAQ8=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=HN1mx2e4pZBGy4Kom/6wxmM/PBQGW28PBBI5KLQ4o3hJyMjbqwewZT3txWZ5C2W/P+ L6WEXfumDZdSdu0TLoNYH14Eemuwsw2tfUrHEVFQ4dQgkxHxbh05/yQeYB/rPr2H4fWy z2+SB7RiVc1YIEHsY/odCVoQ+JvkiVk+EPNGPAcN9CqZQzTUGP2co5qepjueUBF3Kp6R CDx+Qx0fV+Ln780J4/9e6BHD29Cio24a8mb/3eca+nXxlQhRsf7QmV383s0J7UrC1tJQ 3YJbWIRkOJEIp5oktqv99wKFkui5AaZcFmrc2Nefk96nC5N+bsqghcNeDufCIKISKB7u r/fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnEHyMUU; 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 w26-20020a05620a0e9a00b007675745d82csi241428qkm.758.2023.07.10.15.27.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:15 -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=tnEHyMUU; 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 1qIzLD-0003UH-Bj; Mon, 10 Jul 2023 18:26:47 -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 1qIzLB-0003Ts-Oo for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:45 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLA-0001jK-3b for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:45 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fbef8ad9bbso56156615e9.0 for ; Mon, 10 Jul 2023 15:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028002; x=1691620002; 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=0DwXvgpuWa6bvmkF5jLlb53TLUXpVmhoMetGx+sUAQ8=; b=tnEHyMUU/0zJ1yEietluWgcXhnR+jpDQUWT/NeYoI9bgEfMs2lVB7tmOGXgkpaypPT 8onUReObkcCliZ2TU7XoYftV25F6mAToBr4M9uVz6l1yXqAoLHjuU3724PMjlx1i0gxX FMRdQK/thSk7DmQ4VM3q9uY2pcpY7O/BdZq0AW7KLDuBRBFFYkjdjBbBu2ZwDw4iwMQl /3lMVTmDWfQ7YiXQfS8mQHNzNxIynXUE/pgZyA5Zj50nJvftvKEr16YpM7gf6N71ceMK EBaaoeJQcfh6BxsgjFFUbQ8YpJpBuITxyiAkNCDb7nBvWObbFVIMyv8bh5i/qtU84yF6 UbqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028002; x=1691620002; 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=0DwXvgpuWa6bvmkF5jLlb53TLUXpVmhoMetGx+sUAQ8=; b=YereezTIrFwHf+RXXtlhKTQg5FLdDBO0TV/x1ECVPXW87Ece9ZAR7HtfSvZ605EbFC ZJfSOhDEtNNAU7COpjS/m6eV+DU1Ul4bnq2rQjpntA2ZYovxVSccFj3RRHcFT0in9Cc3 rup+Gm8wA0AC+PG0lFZuRM3gOKkwww/2L9+ZSO5127XglWNqmoFfLXyZaOHwIkuKryuj b0TGOZDhPIDmjqZzbdNOx6iwY+eAu7sj2RhRldnfQKSo7T/m5JcCEQyuUoIMFAX/a5by T4werMczb48S97iPz8X+R7wH6wN5wTSeIbXHyC9Sbhk3qDw+6HcCK5u7Vi5TD7XFgQlP 9oMA== X-Gm-Message-State: ABy/qLZe3Z3vF1Z9WwNGYKD3FBL9cr6yDSZYAV1G3mfuqPISlJSx4ydY ku+kbrzo/D9Q8xU/gzUznWCylpfBmA5pN+PAKg9xpQ== X-Received: by 2002:a1c:4b0a:0:b0:3fb:d1db:545b with SMTP id y10-20020a1c4b0a000000b003fbd1db545bmr13812827wma.20.1689028002431; Mon, 10 Jul 2023 15:26:42 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id x8-20020a05600c2a4800b003f9bd9e3226sm906042wme.7.2023.07.10.15.26.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 05/44] target/mips: Add support of two XBurst CPUs Date: Tue, 11 Jul 2023 00:25:32 +0200 Message-Id: <20230710222611.50978-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau XBurstR1 - is the MIPS32R1 CPU which aims to cover all Ingenic SoCs older than JZ4770 and some newer. XBurstR2 - is the MIPS32R2 CPU which aims to cover all Ingenic SoCs starting from to JZ4770. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-3-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu-defs.c.inc | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc index 167c96cb27..05d9ec7125 100644 --- a/target/mips/cpu-defs.c.inc +++ b/target/mips/cpu-defs.c.inc @@ -117,6 +117,26 @@ const mips_def_t mips_defs[] = .insn_flags = CPU_MIPS32R1, .mmu_type = MMU_TYPE_R4000, }, + { + .name = "XBurstR1", + .CP0_PRid = 0x1ed0024f, + .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | + (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | + (0 << CP0C1_CA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3, + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x1278FF17, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R1 | ASE_MXU, + .mmu_type = MMU_TYPE_R4000, + }, { .name = "4KEmR1", .CP0_PRid = 0x00018500, @@ -323,6 +343,32 @@ const mips_def_t mips_defs[] = .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSP_R2, .mmu_type = MMU_TYPE_R4000, }, + { + .name = "XBurstR2", + .CP0_PRid = 0x2ed1024f, + .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | + (MMU_TYPE_R4000 << CP0C0_MT), + .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | + (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | + (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | + (1 << CP0C1_CA), + .CP0_Config2 = MIPS_CONFIG2, + .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) | + (1 << CP0C3_VInt), + .CP0_LLAddr_rw_bitmask = 0, + .CP0_LLAddr_shift = 4, + .SYNCI_Step = 32, + .CCRes = 2, + .CP0_Status_rw_bitmask = 0x3778FF1F, + .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | + (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), + .CP1_fcr31 = 0, + .CP1_fcr31_rw_bitmask = 0xFF83FFFF, + .SEGBITS = 32, + .PABITS = 32, + .insn_flags = CPU_MIPS32R2 | ASE_MXU, + .mmu_type = MMU_TYPE_R4000, + }, { .name = "M14K", .CP0_PRid = 0x00019b00, From patchwork Mon Jul 10 22:25:33 2023 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: 701062 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409092wrs; Mon, 10 Jul 2023 15:28:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlHK7s7FbWIr9z3skOsogpPkOWtnT8xuM2iHtnc4HfQ4PqMAyX2l+9/palv+U/G48bjXn8Jt X-Received: by 2002:a05:622a:1a23:b0:3fd:dd80:52a6 with SMTP id f35-20020a05622a1a2300b003fddd8052a6mr16372619qtb.16.1689028095294; Mon, 10 Jul 2023 15:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028095; cv=none; d=google.com; s=arc-20160816; b=MBWwTRW/ITiXcY4PvhCGEuR6AalpQpguu9g7u2LUF+bf0PeS/fjMIN+ZmT6X/lViBX FicatWoBt3ZAUU676rBlyGKRv/oU2On/rZzW21qx2WUiFU6adPaSSiPiVBRD0cEoB1wf KcDrNUsnmUtD/Mx4vF4vpKqW9x+gz3hxnjnKYNo1eO91s04dE5oBXwaUIFbOMnV5J2cS ZkE8aQnxYISVaT+VPPYRuQWpJRGS39lvXQAyy++Sr1EK5tmOd9x3y2HvpzBDlGuz3ENm tlzNGRchV+qE/wB7W1rIyM3Z9lWRpyv1+Q181m4cXkmm+3jADbz9S9jOYMVpC7UbjfNL wpeg== 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=/lyTZUrhNR7uCF/B13kcUkqX1idFJLM+1E5/815pBHo=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=LImhFjgUJBwT8etR06d7fyMEvnTp4Q2JtLE9rBeQmkU09w9WgKjggLAvOj6+EA+KeM 6VPV4iV/iIlwRIPs2S77SPKd5aqbjchrDGeShRKLfci8l4ND9l01Hjvx8thfO4xdxUlk XHLvRdN7JDlx2eaz378In9oPh5uyJoprQi38Fq/DT7e0TqgW1VoB6hXGHrYzK8YhxLhM qohCmP/Efi0TdEqgMuVDZRa6n5hy9080k3IVVQ1NPrnWna7DdoWmPAfsZ7FhfWrwB5P0 XOyzMwDOnFHlh8SQbJn0rMao51PJlvohIEPBoPC+XKJ0jg8MOjcV0tsniKAQIqBjIqZs bBOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=khRRPQ33; 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 b7-20020ac85bc7000000b004031c028d2esi300590qtb.619.2023.07.10.15.28.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:28:15 -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=khRRPQ33; 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 1qIzLJ-0003VI-3z; Mon, 10 Jul 2023 18:26:53 -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 1qIzLH-0003Um-9h for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:51 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLF-0001k0-Fb for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:51 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso36854505e9.0 for ; Mon, 10 Jul 2023 15:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028008; x=1691620008; 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=/lyTZUrhNR7uCF/B13kcUkqX1idFJLM+1E5/815pBHo=; b=khRRPQ33ejItw3uSB2PfRll6ra5nmHQQaRT1f5IQ5pD6DvVuistWcwzM+aNqA6Ih5b UY7xb1yls7qy15/pssCvYnMefV1Klio3/VzZxT1RBKU8sYRJVrwUqTloplbwR22Pc9QZ XQqaJ8QXVO4IlgjIP0wrZuxXzRykkxG1bXvsoXiM5KlhGhy4HBkURg/6iHFl12T/lK/L EXRDpG5/7u1eh+O/fa/7z3oQApl+vxbN9J82Wh6CfaQxkVb8+rMo8x9so+qo6pPgmzwP lQ3UMuPYydjdWrmCwJLALwa5eBhl4KtomUVraHbOUrp9vw7SNH4FmrVn6Xe8tm2W/klP /h3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028008; x=1691620008; 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=/lyTZUrhNR7uCF/B13kcUkqX1idFJLM+1E5/815pBHo=; b=PaJBWbta1eFSKl+zkTg1X5fmnEPo0YjAwUETzQHr4pv5KwnUmrLaW5fbGtEor2X/fW 0BILpCZZ+WLlRiEkx8KuvhYuCEC5MlFW9K6mLyUB3W70zqiGZTVXqmtUvKNUVR4850wN mGvBXjcRGUZfnpkmgu1SRUEgJ3UoxR9XQ6Kq8GgWUnkyyjb/NPeB4LDtodUH7RFhStTT 7uIgzFUOQ28aA7SflBmJdd5Rgp6xX3ccB8b+VTGjEeLWQvau/4Kck37F4vQcNUqlh15D avIvY74uq9uHsn1w9jmKZVxwexF8cqsbQoLABsPhCf/ybkZqF0WwnpU8vB/fb4KGMsUJ pUGQ== X-Gm-Message-State: ABy/qLZqvV6FVo+ZfMDdxJQfsSrRCpATY0Q9DZDvJzqPDSNyHH/oGJ0u nidzirmeHx88yVBzNIGCzuyOBnZF4N9lxR4MNOKcNw== X-Received: by 2002:a05:600c:850a:b0:3fa:8c8b:716 with SMTP id gw10-20020a05600c850a00b003fa8c8b0716mr15550575wmb.1.1689028008065; Mon, 10 Jul 2023 15:26:48 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id p19-20020a1c7413000000b003fba137857esm898974wmc.14.2023.07.10.15.26.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 06/44] target/mips/mxu: Add LXW LXB LXH LXBU LXHU instructions Date: Tue, 11 Jul 2023 00:25:33 +0200 Message-Id: <20230710222611.50978-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions used to load from memory to GPR via indexed address divided by base and index parts in GPR registers. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-4-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 83 ++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index c69c5795c9..6703e8aca4 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -304,7 +304,7 @@ * │ ├─ 110 ─ OPC_MXU_S32OR * │ └─ 111 ─ OPC_MXU_S32XOR * │ - * │ 7..5 + * │ 8..6 * ├─ 101000 ─ OPC_MXU__POOL17 ─┬─ 000 ─ OPC_MXU_LXB * │ ├─ 001 ─ OPC_MXU_LXH * ├─ 101001 ─ ├─ 011 ─ OPC_MXU_LXW @@ -366,6 +366,7 @@ enum { OPC_MXU__POOL11 = 0x17, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, + OPC_MXU__POOL17 = 0x28, OPC_MXU_S32M2I = 0x2E, OPC_MXU_S32I2M = 0x2F, OPC_MXU__POOL19 = 0x38, @@ -403,6 +404,17 @@ enum { OPC_MXU_S32XOR = 0x07, }; +/* + * MXU pool 17 + */ +enum { + OPC_MXU_LXB = 0x00, + OPC_MXU_LXH = 0x01, + OPC_MXU_LXW = 0x03, + OPC_MXU_LXBU = 0x04, + OPC_MXU_LXHU = 0x05, +}; + /* * MXU pool 19 */ @@ -918,6 +930,38 @@ static void gen_mxu_s32ldxvx(DisasContext *ctx, bool reversed, } } +/* + * LXW Ra, Rb, Rc, STRD2 - Load a word from memory to GPR + * LXB Ra, Rb, Rc, STRD2 - Load a byte from memory to GPR, + * sign extending to GPR size. + * LXH Ra, Rb, Rc, STRD2 - Load a byte from memory to GPR, + * sign extending to GPR size. + * LXBU Ra, Rb, Rc, STRD2 - Load a halfword from memory to GPR, + * zero extending to GPR size. + * LXHU Ra, Rb, Rc, STRD2 - Load a halfword from memory to GPR, + * zero extending to GPR size. + */ +static void gen_mxu_lxx(DisasContext *ctx, uint32_t strd2, MemOp mop) +{ + TCGv t0, t1; + uint32_t Ra, Rb, Rc; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + Ra = extract32(ctx->opcode, 11, 5); + Rc = extract32(ctx->opcode, 16, 5); + Rb = extract32(ctx->opcode, 21, 5); + + gen_load_gpr(t0, Rb); + gen_load_gpr(t1, Rc); + tcg_gen_shli_tl(t1, t1, strd2); + tcg_gen_add_tl(t0, t0, t1); + + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, mop | ctx->default_tcg_memop_mask); + gen_store_gpr(t1, Ra); +} + /* * S32STDV XRa, Rb, Rc, STRD2 - Load a word from memory to XRF * S32STDVR XRa, Rb, Rc, STRD2 - Load a word from memory to XRF @@ -1716,6 +1760,40 @@ static void decode_opc_mxu__pool16(DisasContext *ctx) } } +static void decode_opc_mxu__pool17(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 6, 3); + uint32_t strd2 = extract32(ctx->opcode, 9, 2); + + if (strd2 > 2) { + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + return; + } + + switch (opcode) { + case OPC_MXU_LXW: + gen_mxu_lxx(ctx, strd2, MO_TE | MO_UL); + break; + case OPC_MXU_LXB: + gen_mxu_lxx(ctx, strd2, MO_TE | MO_SB); + break; + case OPC_MXU_LXH: + gen_mxu_lxx(ctx, strd2, MO_TE | MO_SW); + break; + case OPC_MXU_LXBU: + gen_mxu_lxx(ctx, strd2, MO_TE | MO_UB); + break; + case OPC_MXU_LXHU: + gen_mxu_lxx(ctx, strd2, MO_TE | MO_UW); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool19(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 22, 2); @@ -1794,6 +1872,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL16: decode_opc_mxu__pool16(ctx); break; + case OPC_MXU__POOL17: + decode_opc_mxu__pool17(ctx); + break; case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; From patchwork Mon Jul 10 22:25:34 2023 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: 701058 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5408946wrs; Mon, 10 Jul 2023 15:27:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlF3SJERLYSZ0iILBF6ela3FC531AH3Z6pyI231Kr1+wu4JMWCjQ6A0GulLTd5pcR8Na18dm X-Received: by 2002:a0c:f484:0:b0:636:afa1:344e with SMTP id i4-20020a0cf484000000b00636afa1344emr12518082qvm.31.1689028066710; Mon, 10 Jul 2023 15:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028066; cv=none; d=google.com; s=arc-20160816; b=xNIG7dA6rzh0B7NEWstkJIy8874p6zZNBkx2ruHFwTZfLxILiPQcQH73sDPyA6Gov8 4bQBT+QnyTjgMOI0fmROGWolP07UCnCh6m3wdHcIHzbVOnq6YzTrzA6LTLWyiJpTo7Az A17fU0Uy9S6m+jvv0PzlOE/z8ZJb1dxsJ910DfFG7Mm82QVF2Fm3WCEVEZzpnYWv8T0j WyhkTHWz7zHlB4cLL3w/MS6a5OISgxJuaQYWFvbzWneJeWX9r9vhkFVbAhupZHFF/Vi0 YDrFif0BiYbrW07SXHpG31bOQKN3Dwvq3AvBS/p8AGNSRBkpaXk0V3xQjxEjovkdQEE/ 0+cw== 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=5oVbsbU8jbT/CYyTr6Av4cwt8dIizvkvGiVKYMDBysA=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=O1tuIkqxZFtclYV6ERKZyBPAtGT6+KkZts7j0MlPnaDISRC73A3I2MTizzjfb/4UXo r29bY7NRO+Rg2r0uctrXCnV64QO95le5h8pnomePyTHmTID3IsrhS6TUGI4kUragYuKw KFqDL5onP/U6YpmNzpPxFuB1bTprjNU7ED/Pnx9/muJF1QXL7qs/gEAg3osTmipKRe3G 4t/kEDK2hrlysfDalh6WTMbn/RpDhVQ6Nl7sZ89GIf/+rsxaAicFJ8+vz/AtQOC7tijO Y5cczGj4NscisVrlEgqZKtsdCnaO5hqsp5AAivshjaw/nsKqln7g7odwITOA7jIX+ROv uyig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o2kVd8IK; 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 de15-20020a05620a370f00b00767d20f324fsi258280qkb.467.2023.07.10.15.27.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:46 -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=o2kVd8IK; 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 1qIzLN-0003X6-Vz; Mon, 10 Jul 2023 18:26:58 -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 1qIzLN-0003WZ-8E for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:57 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLL-0001km-Gx for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:26:57 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3143b88faebso5803828f8f.3 for ; Mon, 10 Jul 2023 15:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028013; x=1691620013; 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=5oVbsbU8jbT/CYyTr6Av4cwt8dIizvkvGiVKYMDBysA=; b=o2kVd8IKx2TS8v+XDHY58FgtBcDVgYY3By3/Rl+YZ1+0PHAsJ5gTATaZ0HXOPE/Xzu y9ESqjMQaEaphd4Dv+SsdHI/mZSJbT99sG8Yl/uUCDLMymlnLDgnPVyYg/mMOB0l2L8o Y/NwFZ3omQIdWx5wAzPuaRIM5oJdSZmxbgkhVkhK5uqXM+FYzbLKXh7NOugM+L9t/xex 0LKSJYJinQbddXt2dJb+fNt5ds73q9GDV9C8VszPuN4ZNaKt1OyKdjiL7N2j2306IVzf doupaJsMoAss0yTOqUsDNBLaMIITOf1LlCOj1KKKXdm9qZVPU8o/cLpYCMOww4KzOeWl tsVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028013; x=1691620013; 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=5oVbsbU8jbT/CYyTr6Av4cwt8dIizvkvGiVKYMDBysA=; b=W8Virv19993Ic97Os7hA+PqGFH98D/F5SjHAAyftcOmADlxBBlrngfzfuUaFz1NBjr nd4zFFLLi8Isl13ZomrhoJ6S2X5yYBE/GQ7yh1FG8c3iV/8z+6chxSookt4yIzb7MIGZ vVPIXhMnx7qsm1EivYFB9H2iDy+ZarYTc+BYkT77lScPZREqnZnmeRRywoUH6asX3ScI pRAUfllOfY6QJGuEn650yZRonsSHEay9BzBAvFn9uam8sHbjOMVBg3NfLGJhkpqH0sKp LxvJIMiBAcEnNPc1IieNb394FVNWB5/S1VoClmq9aJ5xb2xzR9MhGTCbqIyla66/xmht IpHg== X-Gm-Message-State: ABy/qLbPCzF6N0I/Y1cSoCoV+ohP6JvLNlNRdla6zOd7v6aueX/sfgYT sUdy4aJOaHbsfcwB3RK8Q833+aHObkG9MTzorj4Lpw== X-Received: by 2002:a5d:6a48:0:b0:313:f2bf:295a with SMTP id t8-20020a5d6a48000000b00313f2bf295amr14270540wrw.39.1689028013702; Mon, 10 Jul 2023 15:26:53 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id c3-20020a5d4cc3000000b00311299df211sm517959wrt.77.2023.07.10.15.26.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 07/44] target/mips/mxu: Add S32MADD/MADDU/MSUB/MSUBU instructions Date: Tue, 11 Jul 2023 00:25:34 +0200 Message-Id: <20230710222611.50978-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions used to multiply 2x32-bit GPR sources & accumulate result into 64-bit pair of XRF registers. These instructions stain HI/LO registers with the final result. Their opcode is close to the MIPS32R1 MADD[U]/MSUB[U], so it have to call decode_opc_special2_legacy when failing to find MXU opcode. Moreover, it solves issue with reinventing MUL and malfunction MULU/CLZ/CLO instructions. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-5-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 105 +++++++++++++++++++++++++++++++- target/mips/tcg/translate.c | 7 +-- 2 files changed, 105 insertions(+), 7 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 6703e8aca4..00a4d1da18 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -353,7 +353,11 @@ */ enum { + OPC_MXU_S32MADD = 0x00, + OPC_MXU_S32MADDU = 0x01, OPC_MXU__POOL00 = 0x03, + OPC_MXU_S32MSUB = 0x04, + OPC_MXU_S32MSUBU = 0x05, OPC_MXU_D16MUL = 0x08, OPC_MXU_D16MAC = 0x0A, OPC_MXU__POOL04 = 0x10, @@ -1571,6 +1575,70 @@ static void gen_mxu_S32ALNI(DisasContext *ctx) } } +/* + * S32MADD XRa, XRd, rb, rc + * 32 to 64 bit signed multiply with subsequent add + * result stored in {XRa, XRd} pair, stain HI/LO. + * S32MADDU XRa, XRd, rb, rc + * 32 to 64 bit unsigned multiply with subsequent add + * result stored in {XRa, XRd} pair, stain HI/LO. + * S32MSUB XRa, XRd, rb, rc + * 32 to 64 bit signed multiply with subsequent subtract + * result stored in {XRa, XRd} pair, stain HI/LO. + * S32MSUBU XRa, XRd, rb, rc + * 32 to 64 bit unsigned multiply with subsequent subtract + * result stored in {XRa, XRd} pair, stain HI/LO. + */ +static void gen_mxu_s32madd_sub(DisasContext *ctx, bool sub, bool uns) +{ + uint32_t XRa, XRd, Rb, Rc; + + XRa = extract32(ctx->opcode, 6, 4); + XRd = extract32(ctx->opcode, 10, 4); + Rb = extract32(ctx->opcode, 16, 5); + Rc = extract32(ctx->opcode, 21, 5); + + if (unlikely(Rb == 0 || Rc == 0)) { + /* do nothing because x + 0 * y => x */ + } else if (unlikely(XRa == 0 && XRd == 0)) { + /* do nothing because result just dropped */ + } else { + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv_i64 t2 = tcg_temp_new_i64(); + TCGv_i64 t3 = tcg_temp_new_i64(); + + gen_load_gpr(t0, Rb); + gen_load_gpr(t1, Rc); + + if (uns) { + tcg_gen_extu_tl_i64(t2, t0); + tcg_gen_extu_tl_i64(t3, t1); + } else { + tcg_gen_ext_tl_i64(t2, t0); + tcg_gen_ext_tl_i64(t3, t1); + } + tcg_gen_mul_i64(t2, t2, t3); + + gen_load_mxu_gpr(t0, XRa); + gen_load_mxu_gpr(t1, XRd); + + tcg_gen_concat_tl_i64(t3, t1, t0); + if (sub) { + tcg_gen_sub_i64(t3, t3, t2); + } else { + tcg_gen_add_i64(t3, t3, t2); + } + gen_move_low32(t1, t3); + gen_move_high32(t0, t3); + + tcg_gen_mov_tl(cpu_HI[0], t0); + tcg_gen_mov_tl(cpu_LO[0], t1); + + gen_store_mxu_gpr(t1, XRd); + gen_store_mxu_gpr(t0, XRa); + } +} /* * Decoding engine for MXU @@ -1601,6 +1669,35 @@ static void decode_opc_mxu__pool00(DisasContext *ctx) } } +static bool decode_opc_mxu_s32madd_sub(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 0, 6); + uint32_t pad = extract32(ctx->opcode, 14, 2); + + if (pad != 2) { + /* MIPS32R1 MADD/MADDU/MSUB/MSUBU are on pad == 0 */ + return false; + } + + switch (opcode) { + case OPC_MXU_S32MADD: + gen_mxu_s32madd_sub(ctx, false, false); + break; + case OPC_MXU_S32MADDU: + gen_mxu_s32madd_sub(ctx, false, true); + break; + case OPC_MXU_S32MSUB: + gen_mxu_s32madd_sub(ctx, true, false); + break; + case OPC_MXU_S32MSUBU: + gen_mxu_s32madd_sub(ctx, true, true); + break; + default: + return false; + } + return true; +} + static void decode_opc_mxu__pool04(DisasContext *ctx) { uint32_t reversed = extract32(ctx->opcode, 20, 1); @@ -1833,6 +1930,11 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) tcg_gen_brcondi_tl(TCG_COND_NE, t_mxu_cr, MXU_CR_MXU_EN, l_exit); switch (opcode) { + case OPC_MXU_S32MADD: + case OPC_MXU_S32MADDU: + case OPC_MXU_S32MSUB: + case OPC_MXU_S32MSUBU: + return decode_opc_mxu_s32madd_sub(ctx); case OPC_MXU__POOL00: decode_opc_mxu__pool00(ctx); break; @@ -1879,8 +1981,7 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) decode_opc_mxu__pool19(ctx); break; default: - MIPS_INVAL("decode_opc_mxu"); - gen_reserved_instruction(ctx); + return false; } gen_set_label(l_exit); diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index 7abbb0b5e2..9bb40f1849 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -14644,12 +14644,9 @@ static bool decode_opc_legacy(CPUMIPSState *env, DisasContext *ctx) } #endif if (TARGET_LONG_BITS == 32 && (ctx->insn_flags & ASE_MXU)) { - if (MASK_SPECIAL2(ctx->opcode) == OPC_MUL) { - gen_arith(ctx, OPC_MUL, rd, rs, rt); - } else { - decode_ase_mxu(ctx, ctx->opcode); + if (decode_ase_mxu(ctx, ctx->opcode)) { + break; } - break; } decode_opc_special2_legacy(env, ctx); break; From patchwork Mon Jul 10 22:25:35 2023 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: 701057 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5408880wrs; Mon, 10 Jul 2023 15:27:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlFdxzM+1jZRNBW5bNPLEZKhBnMqXs/FsXW8IhyHd8bxcz2q27e9Sy06hS4AHYe+AOCx5sMV X-Received: by 2002:a05:622a:5ca:b0:403:864b:7aac with SMTP id d10-20020a05622a05ca00b00403864b7aacmr16173117qtb.0.1689028055165; Mon, 10 Jul 2023 15:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028055; cv=none; d=google.com; s=arc-20160816; b=Zs1ETHpsUZol1eLsQxl0EeacmsIGnLivRJb3r6S7IU6InqK3swaB+dbmLH8kcoIC49 KAM4SwUwSa/266gIKeh8YPiYl/bOuQ+kJtxiI2odwTfZA6avGvB2Eeai30Bf0F3G33pJ 8i6xendKPIyAFvr+9SlynaQ9lXq4Mav2zWtfdOXdJ+422UiMHkHiUJ8ISsKzzgZHDGxz aKTrLzm53RZw/rnsApb5l4+qCbffzTn5d+XjZ1OLL2/0uNIYXaXoKD3cWutLD6X9kIt9 o0kkXtYv7l6OhGru7C/a5RpEawW0eqMoWSTcl3ZrFz5ZbWlb4ZcgQkfiVweXLECotyXn aoHA== 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=agZFEaOSiD5GDKXw/f3lIVw/fpih6HqrjVN+YXK8gFk=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=RjA4/6XTFzW3C9FmqLGbftq9xssyvjh0tDZQAdVg09Et0YB8ydYPGib2d9hMQ9m/xF hd9oWzSMMfFR7g5JWM6cI/peAjJ4Kgm5RtWRHVMFulWSUZYXNUYt9jYV0wUtQF5slDYJ bnzQlYQHafKcMqbUuU9wo68E/S/v2RDtl9wBUxRU3l7XQXO+zy3qz946UGjrDyzseSQo vo4axxY6UcYp1I4yngQlkpXSY+OLsCYRfdIs9f6iQHOTaNjhI8kKInh8pjLUZA1Kvs93 1DbWHaICNSfIfLavBFgkw4EE4lvNICRIpB0NFrHt2gHnqisUQyFs4ZByr8AtH+bA8sYa qROA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YS3Xr/LK"; 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 h6-20020ac87d46000000b004032d91e8b7si310989qtb.295.2023.07.10.15.27.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:35 -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="YS3Xr/LK"; 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 1qIzLS-0003Zd-TO; Mon, 10 Jul 2023 18:27:02 -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 1qIzLS-0003ZK-6z for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:02 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLQ-0001l6-JI for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:01 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fb4146e8deso64039825e9.0 for ; Mon, 10 Jul 2023 15:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028019; x=1691620019; 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=agZFEaOSiD5GDKXw/f3lIVw/fpih6HqrjVN+YXK8gFk=; b=YS3Xr/LK00/qdvoDMhiWQg0JhkFH6XVoI3BBF0DTJ0dv0UgU8bDxytdIYtsFsBZqCd b3BlyLYLkP5MBe4DncKhEtPrls4qOk1rc8f/8cF5lUBcwvpaz3t059moxo4eUGuWwT/B zjKclJQUu5MdinSiABqxUp+UgYqopuXI6iNui4khNympHyFt24QCDzBgQ537W2MXE/fb KdKy0Cfui1cw2VukwNegF7fk26KBRFXDxFcxaRSkGnwDVFBkeAOiUmTzT8qkELxcriDT CzsW9JUHRVVJg2QsJJuP4E/tMj+e+8J3q9FDQvIy+76KNovn3/wYavX4DOKltWi7ntCM SUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028019; x=1691620019; 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=agZFEaOSiD5GDKXw/f3lIVw/fpih6HqrjVN+YXK8gFk=; b=Ck68o6SFmiNzf5Lhoz/qweh/CLArFzhauiiUNLmdJtkNpeevo0BAIuPHBu1njdwJLp HVRQErxHFtPOuohKEqNd9xWJ8tN120lgEnTnhHQaS5FbfF8iHy1e93/jV0iFJALQwe8j Axyb+XHfYVaFq1cN/WBURVW1oQnfPS45UiJDNcp5aIJpKbKbh/X/5gxIAVBwdvnmCTO/ Av4B6HbZVSQUsQAUQfsafu8SSjXEe0amz86hh06tWohkcWq2itswXcAsEfAjv7kelfRj lN6wGQikrrhEVQxvdHlSTjznEuiejkZ3ZPZvZR3npUBBREfjAaoXOBCl51waFcRN24Bj Y3OA== X-Gm-Message-State: ABy/qLY/XPAVSg36RqpU0Tv3zKc7ZNEGDall5kMeK6T5ZEHxP2+S+ix1 GGf7p5HMdGmpZixKEuW3yk/uY5ERmB5mvPgPMaNL9g== X-Received: by 2002:a7b:c455:0:b0:3fa:85ad:6672 with SMTP id l21-20020a7bc455000000b003fa85ad6672mr16871394wmi.41.1689028019085; Mon, 10 Jul 2023 15:26:59 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b003f819faff24sm11440591wmi.40.2023.07.10.15.26.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:26:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 08/44] target/mips/mxu: Add Q8SLT Q8SLTU instructions Date: Tue, 11 Jul 2023 00:25:35 +0200 Message-Id: <20230710222611.50978-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are used to set bits depending on comparison result in each byte respectively. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-6-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 00a4d1da18..6d25562710 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -387,6 +387,8 @@ enum { OPC_MXU_D16MIN = 0x03, OPC_MXU_Q8MAX = 0x04, OPC_MXU_Q8MIN = 0x05, + OPC_MXU_Q8SLT = 0x06, + OPC_MXU_Q8SLTU = 0x07, }; /* @@ -1397,6 +1399,63 @@ static void gen_mxu_Q8MAX_Q8MIN(DisasContext *ctx) } } +/* + * Q8SLT + * Update XRa with the signed "set less than" comparison of XRb and XRc + * on per-byte basis. + * a.k.a. XRa[0..3] = XRb[0..3] < XRc[0..3] ? 1 : 0; + * + * Q8SLTU + * Update XRa with the unsigned "set less than" comparison of XRb and XRc + * on per-byte basis. + * a.k.a. XRa[0..3] = XRb[0..3] < XRc[0..3] ? 1 : 0; + */ +static void gen_mxu_q8slt(DisasContext *ctx, bool sltu) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRb == XRc)) { + /* both operands same registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + tcg_gen_movi_tl(t2, 0); + + for (int i = 0; i < 4; i++) { + if (sltu) { + tcg_gen_extract_tl(t0, t3, 8 * i, 8); + tcg_gen_extract_tl(t1, t4, 8 * i, 8); + } else { + tcg_gen_sextract_tl(t0, t3, 8 * i, 8); + tcg_gen_sextract_tl(t1, t4, 8 * i, 8); + } + tcg_gen_setcond_tl(TCG_COND_LT, t0, t0, t1); + tcg_gen_deposit_tl(t2, t2, t0, 8 * i, 8); + } + gen_store_mxu_gpr(t2, XRa); + } +} + /* * MXU instruction category: align @@ -1662,6 +1721,12 @@ static void decode_opc_mxu__pool00(DisasContext *ctx) case OPC_MXU_Q8MIN: gen_mxu_Q8MAX_Q8MIN(ctx); break; + case OPC_MXU_Q8SLT: + gen_mxu_q8slt(ctx, false); + break; + case OPC_MXU_Q8SLTU: + gen_mxu_q8slt(ctx, true); + break; default: MIPS_INVAL("decode_opc_mxu"); gen_reserved_instruction(ctx); From patchwork Mon Jul 10 22:25:36 2023 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: 701067 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409364wrs; Mon, 10 Jul 2023 15:29:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlGp0DtnWOSfVcPNQ8Tm2zwS6uxdXM7p8rHC65fHjRbR6d1ebdRYa9Tri1Z8cZft3t4iAa0r X-Received: by 2002:a0c:da04:0:b0:626:1be5:177b with SMTP id x4-20020a0cda04000000b006261be5177bmr11389668qvj.65.1689028147462; Mon, 10 Jul 2023 15:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028147; cv=none; d=google.com; s=arc-20160816; b=YFw8TB/0Vu5eXGbyDENG/Hc41mXAuUcuu+Mr2mfQMfTSN3byzn3TMfo8ueuvKxC/7/ W8z6DfgTxwrGmm8xnozt6O16LkKECtt8U++U+PCcNNQ8PNlxjg3e0O3V83zjACL7AiZ/ Eb47WcpwtCmN1NDp8OikJCndM5CkNSXdv0hGBh8sbwa/XJg8BFDXfUUzDv3ZgM8kYcDd y6Wqao1yCF7NIAKhSzgGc6ceQQ99zzq80m2eKQmgjO7i0TaqvHNJb6Pq569gNNYPjhDx NUIcn8iUP2cwciVJ3l0GjIfcUJXBvl2DgFuv1m4Y8DYcWjLEsOAuyqcg/rTtQhNHIZHV gEXQ== 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=DGaYnatoGOgdlFc+Y429tF9PlhmF+pcnR+hTd6tWiJE=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=YFEnsCYCA+VoKZ+6986Uoq1MW2hhmwcUNvPA+LKmb7phKkwXFpZvRGP0UESThnkE1U FNmzGemFoOpU4mmuF8J7AJX/MbOaY80MAGmXu0eKbdN74+OILH5Iz2esRyLcDJFV0gQH ykr0gYRmB9p2fn6R6BTU3eMTam7Agdsx4gKwilbPY5K0OSrNsCU1akLQ3Bid3XAquRTY S+hyQtHkRLYiDCMELIuYf3Rifd7yZuTuqzVlVja61piFHDuNUF71chaMGl1wrc8R2Qf7 7S0CY0PFQFVikVm/JOv255Ov7AN/JCVrLu+4WRrS2cWcLYo5DIBFThIF0s28jBLon5aR bdxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IPPGKaxU; 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 g14-20020a0ce4ce000000b006361f10b1b5si232591qvm.561.2023.07.10.15.29.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:07 -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=IPPGKaxU; 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 1qIzLZ-0003hb-MO; Mon, 10 Jul 2023 18:27:09 -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 1qIzLX-0003dw-L3 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:07 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLV-0001ln-SO for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:07 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3159d5e409dso857574f8f.0 for ; Mon, 10 Jul 2023 15:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028024; x=1691620024; 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=DGaYnatoGOgdlFc+Y429tF9PlhmF+pcnR+hTd6tWiJE=; b=IPPGKaxUdEx/9EvZ3MVe7n16jVAQ5o7liVuSL5bCniDyheMU+FzTdoFmpp74hDXgpf T+9x3OO4H+eIoLQI5NcfjkgLE5vPcAHUSWvio4OfAJX/EvwNj7oBE57WSvhfw6zmd+qI l+DOnHSIFye4vY1G5Yt4cjrEfEN2FghAy1+afHPk4dt0tMrlJrew20HNsKypcIe6Zogb Yu2cpOGFwcWNjacmvo5kTdUKFiITHPdSCp82GXVu08yj97xN6jQIVxvS1sr+QUxEXpOB jHb4I4YGnOPjgp3Ah7bc/FyCnAdMAo4Ti8oHpSSSmZZGT+4qENWz9hcUTub7KkO2eeNG 8rWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028024; x=1691620024; 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=DGaYnatoGOgdlFc+Y429tF9PlhmF+pcnR+hTd6tWiJE=; b=fXT5ZZDVWB3aZXbxyoaRSbfgK24DTpFUZ0g+GU//ykGLGDAyVeBN0htju+dFuOI8Lt tUfUPSeV52jIhk8YC84TrondTL/WquQQzFGUGyb9gcxQQWGaeau8UsmZZjJSJ18kNRz7 nvuBryjVfyxBGhUGu3pyG+QfEcd6/XzlUi3JgbhUWF0Tpa/zu8/+l1bfZYISoeazF1KK nLjMyOLIu50LPOSxWi0U9qIvDH5tN002nt+8act3pQ6JnlI3gnwwMjRBrvVhRpTxfc5E 7qdvWTjT3T87fjUK04sFYdAQtCv/+uZzIhk0UzznI90KNIrpbiO7JUtbs2cKnHs07tjW 2OmQ== X-Gm-Message-State: ABy/qLb0Me1xPnnQ6rE393ZbxBm8cTc55yjW4Dz6pOCWnYsC7lLCmeLX SD25YOG68VhdcdTk5eUHGZN3aNDx8bv0iHWgitx3Cg== X-Received: by 2002:adf:f592:0:b0:314:1d6:8aa7 with SMTP id f18-20020adff592000000b0031401d68aa7mr13084622wro.29.1689028024400; Mon, 10 Jul 2023 15:27:04 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id h7-20020a5d5487000000b0030ae901bc54sm520740wrv.62.2023.07.10.15.27.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 09/44] target/mips/mxu: Fix D16MAX D16MIN Q8MAX Q8MIN instructions Date: Tue, 11 Jul 2023 00:25:36 +0200 Message-Id: <20230710222611.50978-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions were designed that they overwrite source register during partial storing of result. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-7-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 6d25562710..e63b4754be 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -1241,13 +1241,14 @@ static void gen_mxu_D16MAX_D16MIN(DisasContext *ctx) /* ...and do half-word-wise max/min with one operand 0 */ TCGv_i32 t0 = tcg_temp_new(); TCGv_i32 t1 = tcg_constant_i32(0); + TCGv_i32 t2 = tcg_temp_new(); /* the left half-word first */ tcg_gen_andi_i32(t0, mxu_gpr[XRx - 1], 0xFFFF0000); if (opc == OPC_MXU_D16MAX) { - tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smax_i32(t2, t0, t1); } else { - tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smin_i32(t2, t0, t1); } /* the right half-word */ @@ -1263,7 +1264,7 @@ static void gen_mxu_D16MAX_D16MIN(DisasContext *ctx) /* return resulting half-words to its original position */ tcg_gen_shri_i32(t0, t0, 16); /* finally update the destination */ - tcg_gen_or_i32(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + tcg_gen_or_i32(mxu_gpr[XRa - 1], t2, t0); } else if (unlikely(XRb == XRc)) { /* both operands same -> just set destination to one of them */ tcg_gen_mov_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); @@ -1271,14 +1272,15 @@ static void gen_mxu_D16MAX_D16MIN(DisasContext *ctx) /* the most general case */ TCGv_i32 t0 = tcg_temp_new(); TCGv_i32 t1 = tcg_temp_new(); + TCGv_i32 t2 = tcg_temp_new(); /* the left half-word first */ tcg_gen_andi_i32(t0, mxu_gpr[XRb - 1], 0xFFFF0000); tcg_gen_andi_i32(t1, mxu_gpr[XRc - 1], 0xFFFF0000); if (opc == OPC_MXU_D16MAX) { - tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smax_i32(t2, t0, t1); } else { - tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smin_i32(t2, t0, t1); } /* the right half-word */ @@ -1296,7 +1298,7 @@ static void gen_mxu_D16MAX_D16MIN(DisasContext *ctx) /* return resulting half-words to its original position */ tcg_gen_shri_i32(t0, t0, 16); /* finally update the destination */ - tcg_gen_or_i32(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + tcg_gen_or_i32(mxu_gpr[XRa - 1], t2, t0); } } @@ -1332,14 +1334,15 @@ static void gen_mxu_Q8MAX_Q8MIN(DisasContext *ctx) /* ...and do byte-wise max/min with one operand 0 */ TCGv_i32 t0 = tcg_temp_new(); TCGv_i32 t1 = tcg_constant_i32(0); + TCGv_i32 t2 = tcg_temp_new(); int32_t i; /* the leftmost byte (byte 3) first */ tcg_gen_andi_i32(t0, mxu_gpr[XRx - 1], 0xFF000000); if (opc == OPC_MXU_Q8MAX) { - tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smax_i32(t2, t0, t1); } else { - tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smin_i32(t2, t0, t1); } /* bytes 2, 1, 0 */ @@ -1357,8 +1360,9 @@ static void gen_mxu_Q8MAX_Q8MIN(DisasContext *ctx) /* return resulting byte to its original position */ tcg_gen_shri_i32(t0, t0, 8 * (3 - i)); /* finally update the destination */ - tcg_gen_or_i32(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + tcg_gen_or_i32(t2, t2, t0); } + gen_store_mxu_gpr(t2, XRa); } else if (unlikely(XRb == XRc)) { /* both operands same -> just set destination to one of them */ tcg_gen_mov_i32(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); @@ -1366,15 +1370,16 @@ static void gen_mxu_Q8MAX_Q8MIN(DisasContext *ctx) /* the most general case */ TCGv_i32 t0 = tcg_temp_new(); TCGv_i32 t1 = tcg_temp_new(); + TCGv_i32 t2 = tcg_temp_new(); int32_t i; /* the leftmost bytes (bytes 3) first */ tcg_gen_andi_i32(t0, mxu_gpr[XRb - 1], 0xFF000000); tcg_gen_andi_i32(t1, mxu_gpr[XRc - 1], 0xFF000000); if (opc == OPC_MXU_Q8MAX) { - tcg_gen_smax_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smax_i32(t2, t0, t1); } else { - tcg_gen_smin_i32(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_smin_i32(t2, t0, t1); } /* bytes 2, 1, 0 */ @@ -1394,8 +1399,9 @@ static void gen_mxu_Q8MAX_Q8MIN(DisasContext *ctx) /* return resulting byte to its original position */ tcg_gen_shri_i32(t0, t0, 8 * (3 - i)); /* finally update the destination */ - tcg_gen_or_i32(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + tcg_gen_or_i32(t2, t2, t0); } + gen_store_mxu_gpr(t2, XRa); } } From patchwork Mon Jul 10 22:25:37 2023 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: 701079 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410374wrs; Mon, 10 Jul 2023 15:31:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGnch4txRQdcWOS5jj9/0d6886wA6M7prRP73xRWRjhAbBYABr7iRxDsXy0sVe+S1NXUX9 X-Received: by 2002:ac8:7f84:0:b0:403:b680:3df1 with SMTP id z4-20020ac87f84000000b00403b6803df1mr1124460qtj.66.1689028283884; Mon, 10 Jul 2023 15:31:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028283; cv=none; d=google.com; s=arc-20160816; b=F9AXyPmF2+tnFYjFDh4XQnjbwmWWSr58vI38viiobXEgDC0YbL3eYdekiehvALY+VZ C4CEp7uI8Rfcp13CBYYjYz7AFtJ68tliO9iEHB/+o5xe5FbvBLEM0uFD7HfB67DKBmyI fBLYUspsCJxClDL6hiNfEfDz9gucKx2Tbx9B1sJl69XjVHxh3C3OQsXJGhKIlCUDvhqG 2M9xlHQGB50eSRH3f+YVg6hdfj2steRD0I0cwGpsmkzW/XNrvXKM54N/c65iTNKap3vH ZNzBOmBh9I+zvcWNAPVBUbMXoy3vMgICMUyoAl2nqSxOuDNdTg6oHYzSRicbK5R7mh/z kS7w== 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=+cKmfCehL9ccjAK2Zy+PLAYfzOsJV5kPaaPkIQJVXoM=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=W7Juucz1SAeMXLKgRM1AI8CG2FV1MeZuDHkhs124IMRf0Sx7WM6hfC++d/2OXXbPuS NnVO5oDLwwwZfCOfXpUMpZz0Q10SkbRvN0KHlIN0olW5aqqH9AteRGYva95anZUbGiJT 0EermST2X3D9NLrIWIGPSo/NoXgkicIsG7oLv06CVv4uv7yFsEClWJ+alFCVm76GfHyn DbaIiV52y0RVE6uemI5BuOhOtvmskTIecE02UqMW/UtQBS4/HV4Dvyvnw6IZPTHcfdBG OjO5frFEh5Bm0L47U137LzyUCt/AhwFdMUvW7usU/YGRxnAtRlW0BLwlx8Cxmk4fVJXC 5gEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKKCJEbk; 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 z14-20020a05622a028e00b003f9a7314533si337251qtw.127.2023.07.10.15.31.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31: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=EKKCJEbk; 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 1qIzLe-0003iM-JO; Mon, 10 Jul 2023 18:27:14 -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 1qIzLd-0003iD-8Y for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:13 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLb-0001mM-8k for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:13 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3142860734aso4694598f8f.1 for ; Mon, 10 Jul 2023 15:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028029; x=1691620029; 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=+cKmfCehL9ccjAK2Zy+PLAYfzOsJV5kPaaPkIQJVXoM=; b=EKKCJEbkvGfGYO6Up/3e9CTTJbKdeFwem7D7RWNBiHMGLvu0r8VfOyQN7w9sINkXHj Z5aNxFVyISX3pUV133KVAyF4Wa9CwHSoGDpAXMDME+zGCxqBhhKCi2Yj30d1eyNr9Fjv 7MDLWyIboYczozJ3ujae+QSfXvf8qMFaKdHufu7QVG1Zfx+vHHdcaoqWUl+nMMDhAQSu zz2GGstCXYaWuM3iV5VmcF6/zNV6YwCdry+Hm5nM+3ht0qcvK9fZQ3GdghTLlixZ/zS4 fq782GHukHdhrC1A+A/kFLhWSQ0rHu71M16vT56e2YVfjOUnyAKYAYEJtmSUs/sKWz8f t2NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028029; x=1691620029; 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=+cKmfCehL9ccjAK2Zy+PLAYfzOsJV5kPaaPkIQJVXoM=; b=AJZGrRtH99p44RGKcqS5sXDjElwI9WovpsUiY9Ri+L+JetvV0kw7FeMmyLsABwUCoU X+TqNn4KVqPJ4ELW9ZEy2nzOC7MY9mvWYMniPEuEXArQaut4+YoFpooRGZqyw106AYjn HoYsvvTPWEpldJU9eCL6nHwjqOUmU3SOVuWCQpY1FZJJBp/nwzdKJZeSX/HA83OTP61m UJHhsGRu0hJvPrxtRWJZL4gJEVNiolx9zzvlTZOXFLqvGVB+K/oy5yi/ge0t45bfpjTP cECsjY0apeTSW+e905KggzZ/IM3S4kEjwvV4hmuMNCTzkeSxm1U21dXqWk3ph3T9C4pP jRIg== X-Gm-Message-State: ABy/qLatUNpvYernuf1sOgVxD+PJrrlf2jvsDqynIQVyPvefl47EuLyw DoU/qqCUybyGTJIgq61zt4AJtxM3DzKKWHlZBKe2sA== X-Received: by 2002:a5d:44cb:0:b0:311:b18:9ca4 with SMTP id z11-20020a5d44cb000000b003110b189ca4mr15126312wrr.17.1689028029615; Mon, 10 Jul 2023 15:27:09 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id s14-20020adfea8e000000b00301a351a8d6sm515832wrm.84.2023.07.10.15.27.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 10/44] target/mips/mxu: Add S32SLT D16SLT D16AVG[R] Q8AVG[R] insns Date: Tue, 11 Jul 2023 00:25:37 +0200 Message-Id: <20230710222611.50978-11-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are part of pool1, see the grand tree above in the file. Q8ADD is part of pool1 too but belong to another category of instructions, thus will be made in later patches. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-8-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 244 +++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 1 deletion(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index e63b4754be..f170195feb 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -358,6 +358,7 @@ enum { OPC_MXU__POOL00 = 0x03, OPC_MXU_S32MSUB = 0x04, OPC_MXU_S32MSUBU = 0x05, + OPC_MXU__POOL01 = 0x06, OPC_MXU_D16MUL = 0x08, OPC_MXU_D16MAC = 0x0A, OPC_MXU__POOL04 = 0x10, @@ -391,6 +392,18 @@ enum { OPC_MXU_Q8SLTU = 0x07, }; +/* + * MXU pool 01 + */ +enum { + OPC_MXU_S32SLT = 0x00, + OPC_MXU_D16SLT = 0x01, + OPC_MXU_D16AVG = 0x02, + OPC_MXU_D16AVGR = 0x03, + OPC_MXU_Q8AVG = 0x04, + OPC_MXU_Q8AVGR = 0x05, +}; + /* * MXU pool 04 05 06 07 08 09 10 11 */ @@ -1152,11 +1165,15 @@ static void gen_mxu_S32XOR(DisasContext *ctx) /* - * MXU instruction category max/min + * MXU instruction category max/min/avg * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * S32MAX D16MAX Q8MAX * S32MIN D16MIN Q8MIN + * S32SLT D16SLT Q8SLT + * Q8SLTU + * D16AVG Q8AVG + * D16AVGR Q8AVGR */ /* @@ -1462,6 +1479,199 @@ static void gen_mxu_q8slt(DisasContext *ctx, bool sltu) } } +/* + * S32SLT + * Update XRa with the signed "set less than" comparison of XRb and XRc. + * a.k.a. XRa = XRb < XRc ? 1 : 0; + */ +static void gen_mxu_S32SLT(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRb == XRc)) { + /* both operands same registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + tcg_gen_setcond_tl(TCG_COND_LT, mxu_gpr[XRa - 1], + mxu_gpr[XRb - 1], mxu_gpr[XRc - 1]); + } +} + +/* + * D16SLT + * Update XRa with the signed "set less than" comparison of XRb and XRc + * on per-word basis. + * a.k.a. XRa[0..1] = XRb[0..1] < XRc[0..1] ? 1 : 0; + */ +static void gen_mxu_D16SLT(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRb == XRc)) { + /* both operands same registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + tcg_gen_sextract_tl(t0, t3, 16, 16); + tcg_gen_sextract_tl(t1, t4, 16, 16); + tcg_gen_setcond_tl(TCG_COND_LT, t0, t0, t1); + tcg_gen_shli_tl(t2, t0, 16); + tcg_gen_sextract_tl(t0, t3, 0, 16); + tcg_gen_sextract_tl(t1, t4, 0, 16); + tcg_gen_setcond_tl(TCG_COND_LT, t0, t0, t1); + tcg_gen_or_tl(mxu_gpr[XRa - 1], t2, t0); + } +} + +/* + * D16AVG + * Update XRa with the signed average of XRb and XRc + * on per-word basis, rounding down. + * a.k.a. XRa[0..1] = (XRb[0..1] + XRc[0..1]) >> 1; + * + * D16AVGR + * Update XRa with the signed average of XRb and XRc + * on per-word basis, math rounding 4/5. + * a.k.a. XRa[0..1] = (XRb[0..1] + XRc[0..1] + 1) >> 1; + */ +static void gen_mxu_d16avg(DisasContext *ctx, bool round45) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRb == XRc)) { + /* both operands same registers -> just set destination to same */ + tcg_gen_mov_tl(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + tcg_gen_sextract_tl(t0, t3, 16, 16); + tcg_gen_sextract_tl(t1, t4, 16, 16); + tcg_gen_add_tl(t0, t0, t1); + if (round45) { + tcg_gen_addi_tl(t0, t0, 1); + } + tcg_gen_shli_tl(t2, t0, 15); + tcg_gen_andi_tl(t2, t2, 0xffff0000); + tcg_gen_sextract_tl(t0, t3, 0, 16); + tcg_gen_sextract_tl(t1, t4, 0, 16); + tcg_gen_add_tl(t0, t0, t1); + if (round45) { + tcg_gen_addi_tl(t0, t0, 1); + } + tcg_gen_shri_tl(t0, t0, 1); + tcg_gen_deposit_tl(t2, t2, t0, 0, 16); + gen_store_mxu_gpr(t2, XRa); + } +} + +/* + * Q8AVG + * Update XRa with the signed average of XRb and XRc + * on per-byte basis, rounding down. + * a.k.a. XRa[0..3] = (XRb[0..3] + XRc[0..3]) >> 1; + * + * Q8AVGR + * Update XRa with the signed average of XRb and XRc + * on per-word basis, math rounding 4/5. + * a.k.a. XRa[0..3] = (XRb[0..3] + XRc[0..3] + 1) >> 1; + */ +static void gen_mxu_q8avg(DisasContext *ctx, bool round45) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRb == XRc)) { + /* both operands same registers -> just set destination to same */ + tcg_gen_mov_tl(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + tcg_gen_movi_tl(t2, 0); + + for (int i = 0; i < 4; i++) { + tcg_gen_extract_tl(t0, t3, 8 * i, 8); + tcg_gen_extract_tl(t1, t4, 8 * i, 8); + tcg_gen_add_tl(t0, t0, t1); + if (round45) { + tcg_gen_addi_tl(t0, t0, 1); + } + tcg_gen_shri_tl(t0, t0, 1); + tcg_gen_deposit_tl(t2, t2, t0, 8 * i, 8); + } + gen_store_mxu_gpr(t2, XRa); + } +} + /* * MXU instruction category: align @@ -1769,6 +1979,35 @@ static bool decode_opc_mxu_s32madd_sub(DisasContext *ctx) return true; } +static void decode_opc_mxu__pool01(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 18, 3); + + switch (opcode) { + case OPC_MXU_S32SLT: + gen_mxu_S32SLT(ctx); + break; + case OPC_MXU_D16SLT: + gen_mxu_D16SLT(ctx); + break; + case OPC_MXU_D16AVG: + gen_mxu_d16avg(ctx, false); + break; + case OPC_MXU_D16AVGR: + gen_mxu_d16avg(ctx, true); + break; + case OPC_MXU_Q8AVG: + gen_mxu_q8avg(ctx, false); + break; + case OPC_MXU_Q8AVGR: + gen_mxu_q8avg(ctx, true); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} static void decode_opc_mxu__pool04(DisasContext *ctx) { uint32_t reversed = extract32(ctx->opcode, 20, 1); @@ -2015,6 +2254,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_D16MAC: gen_mxu_d16mac(ctx); break; + case OPC_MXU__POOL01: + decode_opc_mxu__pool01(ctx); + break; case OPC_MXU__POOL04: decode_opc_mxu__pool04(ctx); break; From patchwork Mon Jul 10 22:25:38 2023 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: 701059 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5408979wrs; Mon, 10 Jul 2023 15:27:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEo4VojqBPjAJ1csafYxw8bMsKxHy0LDBu+s8CShPJr7+qsZKPhsBji1TeRvuYfK0slkDk3 X-Received: by 2002:a05:622a:488:b0:3f6:bf12:cc57 with SMTP id p8-20020a05622a048800b003f6bf12cc57mr16325876qtx.17.1689028072780; Mon, 10 Jul 2023 15:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028072; cv=none; d=google.com; s=arc-20160816; b=FQyxTHKWcRxI/ZgelB4wt3ZF+c/hnPivc3+xvl5+oHH+OAKsHHEXa9AsvcVYAsQFaZ OHgvwhr3Y9hYdQJeKA3cYLTTdDPwKb2MVm0pWrKbulBwnhDfZVZvADnWoGY/aIbWLxDP EVKU3Q54pjlvBYT63lWPEvJEQBflvjVilB/TlMz5cFbymr9zYx/J2AEyxGGNjhgXlA5d 9oRklzQtwB+KpJzvW4lIwi7sDh0Jo1n/t3WAo9xoBx8KmGe+uQ8sb6QkC2sMJa+uqa6g hNWm+SmTBX5xEimWbcXAs1FSrBppK57wV6b1DPNFaVZL8h2ORVls+Q1HaP0Rw2/IAh4s 3+Cw== 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=KlOVLh0VbIxlNWq6zZht8cBZYeoWPrgyVYcBv1fu/3w=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=NGcryD3OO0KJROEXNAiDfH0k3192QtzCb6v9kGolctQVyUm+2Nm33eF2tmUAFSO/8Q c8sJeCegDEr7X7o1Z+vSRUEmFEgeRWZx17amGBoNRmqeig/q+dMerQtPKi6bRiez02bJ EZUak+ERRbdMYTAV37RZy1fXDHGTdBfeWCRu3oxjsiQdWb7797R+kO0DDW6yCcdyk1D5 oMpDKTPL+nUbp0WZBOvHitQCzC4Q2AdkaIP6gPE9h1MJ+smCtJhHBobl51O17Mg8TXqy M1TD540QKgYvSHPNLjKq3pMbvCFaGnEX4XeXYi1M+pi7vxRwNpuNThlcB5FDvW3tDgoF Moxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HX9YgduL; 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 t21-20020a05622a01d500b00403aaf33a03si336416qtw.47.2023.07.10.15.27.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:52 -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=HX9YgduL; 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 1qIzLk-0003pm-9g; Mon, 10 Jul 2023 18:27:20 -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 1qIzLi-0003nr-F4 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:18 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLg-0001mv-Ra for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:18 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3142ee41fd2so5090732f8f.3 for ; Mon, 10 Jul 2023 15:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028035; x=1691620035; 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=KlOVLh0VbIxlNWq6zZht8cBZYeoWPrgyVYcBv1fu/3w=; b=HX9YgduLVXDtk1ZKMunEFgE7s6FdcK3lPXrl8kJuZ62UfhbBTGGh0GePHruZRKM54K 0aB9R/DfnQHXVEycOjwCC1I0OpPp32xh9Ms5xoIZC9ODv+IlIYeeNdHoMrSj6HTXnPEM cZh7ABKyUkx5PeMGZNvZeB3oO7u3D6YUmuZAIr79WJcc1VoTNypnFj2pzr6ebPYY1t2t 5bPvNn+8bC+oeNY0VOpFqAUNYYgLeAxphspczxo/VS/9+rJ8eUYAwslGsfVAqjvfzPq4 c4By9tEhvX0wfnB9S0nc9CVaLsXuxcq1+9c6XuxgzkyNrJ7LDFzIIKlmujtnOms5e4cJ ee9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028035; x=1691620035; 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=KlOVLh0VbIxlNWq6zZht8cBZYeoWPrgyVYcBv1fu/3w=; b=fdzbJhHDCX2eX0T1pKyfWG+OfDhPXVY++qZ0GfkHrrS0vwJOU9Cc7hSIh4DRVU65Iw vAgSgbdCilzJ5oH0952xmXA1vN6Iha+s3Z9Z/L6agwAFREvRY5xAt4g1q3NOMhIzC0us ePYjnSNdO85t8Io7So3/u/Uwn5ee/ueoPg7jZHXUYnoubnLkynBtHqM3Kf9rj2T6jCj7 kEmXcX6svV/IL3j+SHDtwjsuFz3ylDVFzXohQdJJEX21GqxJxJnwRRo4Rn1lphnY+n4y h6C0xnmfaeNXMyKjVktA6pyW8iHAY2a2mOi0O9uaaIMjny3xUFHyePtIxIFZwDAl58fb oeYw== X-Gm-Message-State: ABy/qLYEQHJfppW8tstPTm7sGj2JC7PiMna+cuiFnRNRDMEB9GhtcBPn 24ynmgW7TE/nGJfv4lbb8tcN0HNVC0OYbxtqgZHXqw== X-Received: by 2002:a05:6000:18ce:b0:313:fe1b:f444 with SMTP id w14-20020a05600018ce00b00313fe1bf444mr12479741wrq.68.1689028035133; Mon, 10 Jul 2023 15:27:15 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id f4-20020a5d4dc4000000b0031424f4ef1dsm542939wru.19.2023.07.10.15.27.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 11/44] target/mips/mxu: Add Q8ADD instruction Date: Tue, 11 Jul 2023 00:25:38 +0200 Message-Id: <20230710222611.50978-12-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau This instruction is used to add/subtract quadruple 8-bit values to another quadruple in parallel. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-9-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index f170195feb..034287e54b 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -402,6 +402,7 @@ enum { OPC_MXU_D16AVGR = 0x03, OPC_MXU_Q8AVG = 0x04, OPC_MXU_Q8AVGR = 0x05, + OPC_MXU_Q8ADD = 0x07, }; /* @@ -1673,6 +1674,79 @@ static void gen_mxu_q8avg(DisasContext *ctx, bool round45) } +/* + * MXU instruction category: Arithmetic + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Q8ADD + */ + +/* + * Q8ADD XRa, XRb, XRc, ptn2 + * Add/subtract quadruple of 8-bit packed in XRb + * to another one in XRc, put the result in XRa. + */ +static void gen_mxu_Q8ADD(DisasContext *ctx) +{ + uint32_t aptn2, pad, XRc, XRb, XRa; + + aptn2 = extract32(ctx->opcode, 24, 2); + pad = extract32(ctx->opcode, 21, 3); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_i32(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + + for (int i = 0; i < 4; i++) { + tcg_gen_andi_tl(t0, t3, 0xff); + tcg_gen_andi_tl(t1, t4, 0xff); + + if (i < 2) { + if (aptn2 & 0x01) { + tcg_gen_sub_tl(t0, t0, t1); + } else { + tcg_gen_add_tl(t0, t0, t1); + } + } else { + if (aptn2 & 0x02) { + tcg_gen_sub_tl(t0, t0, t1); + } else { + tcg_gen_add_tl(t0, t0, t1); + } + } + if (i < 3) { + tcg_gen_shri_tl(t3, t3, 8); + tcg_gen_shri_tl(t4, t4, 8); + } + if (i > 0) { + tcg_gen_deposit_tl(t2, t2, t0, 8 * i, 8); + } else { + tcg_gen_andi_tl(t0, t0, 0xff); + tcg_gen_mov_tl(t2, t0); + } + } + gen_store_mxu_gpr(t2, XRa); + } +} + + /* * MXU instruction category: align * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2002,6 +2076,9 @@ static void decode_opc_mxu__pool01(DisasContext *ctx) case OPC_MXU_Q8AVGR: gen_mxu_q8avg(ctx, true); break; + case OPC_MXU_Q8ADD: + gen_mxu_Q8ADD(ctx); + break; default: MIPS_INVAL("decode_opc_mxu"); gen_reserved_instruction(ctx); From patchwork Mon Jul 10 22:25:39 2023 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: 701066 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409362wrs; Mon, 10 Jul 2023 15:29:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEkTcLh+RI3zA0fcDDrAuPJ/SMSPFWXBFRzAWgY8eJ9HDHv121D6i+cR4PpboOfKTYnKgJJ X-Received: by 2002:a05:622a:1647:b0:403:2966:8fc8 with SMTP id y7-20020a05622a164700b0040329668fc8mr16390205qtj.2.1689028147213; Mon, 10 Jul 2023 15:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028147; cv=none; d=google.com; s=arc-20160816; b=UQv1mnEIYsBkR2djmEgpXBtx+zf5RM1oByhXvUhASlni0uzA2wi1YXkPqMwE5+pM7t rsbZBJH8hEMhhHmNWW9xlPxcraMNa5wogoTguY2of5in7Sb6sz9zExNcWTyoWDLd1YJI GlN+QL4HEH4SdEyZsY+5dWXSZIrTjvzE2vrWhAFl6KTp6MozDk5XWtiJrzdsHAiDMzaj col8QsRJhU/GOK4u4ruQW2t2ziYZhWJvLiDpjlzZfvAhrz60qSqjdXoUIk7LpxIIx1NR PiChgFEEjh95fB5R0j3ser9ZYBbg6WBsNeDougXD+UKvMbi9jBUy7oAle8b4SLRxYDkC Jtbw== 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=RtTL5bQ25A6n7tfhgT5171sR9zV7gwztAuSP4914Akw=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=JWw/QlrrcO3rNblRdw8TznWmfAJigMSY60E+sCEH6i7Fl2ipEki8sHoSY8hziHSsh/ SNvA7IZoRP9ZjyUaJczAst/1XPDCwZi2slXZ13PUiryuFO4fhl+LIw8LHRX2gR5D3XaD vKQe1GytY4t0BabYsCnqf+sEPnMcK9WHqtb+kpftji0pZNErWyX68wMA2cfDGzoLcvr8 nJpI6w4UeTbgcyOxR7ldqFJJE+cG2JgNwUNQShYeVxcsasuuoioggMVYF8P4nDwgLs4B X1vg/34OWJrxtcLbUVvDns/k86UNI9ZvbApPfCTLVVMWG+0dh06njHcWacDBX4YWS9t0 WAKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esYikflR; 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 s14-20020a05622a018e00b004036e610f2csi336136qtw.44.2023.07.10.15.29.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:07 -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=esYikflR; 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 1qIzLq-0003qp-Fn; Mon, 10 Jul 2023 18:27:26 -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 1qIzLp-0003qd-CS for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:25 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLm-0001nS-9e for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:24 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3142970df44so4841755f8f.3 for ; Mon, 10 Jul 2023 15:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028040; x=1691620040; 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=RtTL5bQ25A6n7tfhgT5171sR9zV7gwztAuSP4914Akw=; b=esYikflRpF0k3Wpw2ornQWqHUx/vXyZvat4PSsLj5XUhJhhqDr7xsNX0owkHFMwPrD UX1NjL788EBi+At98Pkz98xnhticsvsi00zkQXPO6BZ9sBzcdHk91Z056rilkc8gWl2R LlgmxBxNbgd+oGVChmeIyGWHjeZhK7M3euqdorztwkkTqW4Fl4hR5bgNm2PEkOK2bx6D mEj0x7WzMHY0tRik28tQR6vGm54Hf3U3LpPI98tNBiX/hy3N262y8k4s2rqYpZx6VrAY r/gP2l3UNQwedEGrY0/RG83Re2gRJP3NxscjlfjN7UenSo/UXqXxTXFXSQ5CJUbsmKIx 69yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028040; x=1691620040; 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=RtTL5bQ25A6n7tfhgT5171sR9zV7gwztAuSP4914Akw=; b=EYRN6zwyzRfWYFV7Uj/g1g01bm9MH/vmrjGq0yg5nMpWJaYsWwWFBfOx+iiNhU//Ae q9iyQTOjVH6UfK3WZExYBNST/MeIIVZmz23UKdNaWhFx6rwgDcn7ibX80khf7KM+eulC hYtY6PglZ/mc7ThhoJw7i/Vr6bfUVf3s9AMECHToYcBYqlOV/GPtShRItCXf+NU27fxb mWj7sxW9H0KfQCC4kG+ddsMDZX4dOB/LeSSQQdsD9WpB4xvgwiVQEiJ8NMkWdiIhwUja HGOnA0YQbRtGQ4v/AQsjzmsg37je28lEnAdHVlpBR8HNph7KtVdJOR7hvoiwAVRW17mN hugw== X-Gm-Message-State: ABy/qLY/q+gu5mIjVjuVimsfFLYCQHTg1wyHtHn1f7KpgDz5ddUH8AVC li1Lgg3rDxug1k20ZxVUQJhkNrva549hvtvFuft1dA== X-Received: by 2002:adf:e803:0:b0:314:11ea:480d with SMTP id o3-20020adfe803000000b0031411ea480dmr12073700wrm.9.1689028040581; Mon, 10 Jul 2023 15:27:20 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id q13-20020a05600000cd00b00314367cf43asm506633wrx.106.2023.07.10.15.27.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 12/44] target/mips/mxu: Add S32CPS D16CPS Q8ABD Q16SAT insns Date: Tue, 11 Jul 2023 00:25:39 +0200 Message-Id: <20230710222611.50978-13-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are part of pool2, see the grand tree above in the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-10-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 296 +++++++++++++++++++++++++++++++- 1 file changed, 293 insertions(+), 3 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 034287e54b..3bd5fcb98a 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -359,6 +359,7 @@ enum { OPC_MXU_S32MSUB = 0x04, OPC_MXU_S32MSUBU = 0x05, OPC_MXU__POOL01 = 0x06, + OPC_MXU__POOL02 = 0x07, OPC_MXU_D16MUL = 0x08, OPC_MXU_D16MAC = 0x0A, OPC_MXU__POOL04 = 0x10, @@ -405,6 +406,16 @@ enum { OPC_MXU_Q8ADD = 0x07, }; +/* + * MXU pool 02 + */ +enum { + OPC_MXU_S32CPS = 0x00, + OPC_MXU_D16CPS = 0x02, + OPC_MXU_Q8ABD = 0x04, + OPC_MXU_Q16SAT = 0x06, +}; + /* * MXU pool 04 05 06 07 08 09 10 11 */ @@ -1675,12 +1686,155 @@ static void gen_mxu_q8avg(DisasContext *ctx, bool round45) /* - * MXU instruction category: Arithmetic - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * MXU instruction category: Addition and subtraction + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Q8ADD + * S32CPS D16CPS + * Q8ADD */ +/* + * S32CPS + * Update XRa if XRc < 0 by value of 0 - XRb + * else XRa = XRb + */ +static void gen_mxu_S32CPS(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely(XRb == 0)) { + /* XRc make no sense 0 - 0 = 0 -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRc == 0)) { + /* condition always false -> just move XRb to XRa */ + tcg_gen_mov_tl(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGLabel *l_not_less = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + tcg_gen_brcondi_tl(TCG_COND_GE, mxu_gpr[XRc - 1], 0, l_not_less); + tcg_gen_neg_tl(t0, mxu_gpr[XRb - 1]); + tcg_gen_br(l_done); + gen_set_label(l_not_less); + gen_load_mxu_gpr(t0, XRb); + gen_set_label(l_done); + gen_store_mxu_gpr(t0, XRa); + } +} + +/* + * D16CPS + * Update XRa[0..1] if XRc[0..1] < 0 by value of 0 - XRb[0..1] + * else XRa[0..1] = XRb[0..1] + */ +static void gen_mxu_D16CPS(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely(XRb == 0)) { + /* XRc make no sense 0 - 0 = 0 -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else if (unlikely(XRc == 0)) { + /* condition always false -> just move XRb to XRa */ + tcg_gen_mov_tl(mxu_gpr[XRa - 1], mxu_gpr[XRb - 1]); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGLabel *l_done_hi = gen_new_label(); + TCGLabel *l_not_less_lo = gen_new_label(); + TCGLabel *l_done_lo = gen_new_label(); + + tcg_gen_sextract_tl(t0, mxu_gpr[XRc - 1], 16, 16); + tcg_gen_sextract_tl(t1, mxu_gpr[XRb - 1], 16, 16); + tcg_gen_brcondi_tl(TCG_COND_GE, t0, 0, l_done_hi); + tcg_gen_subfi_tl(t1, 0, t1); + + gen_set_label(l_done_hi); + tcg_gen_shli_i32(t1, t1, 16); + + tcg_gen_sextract_tl(t0, mxu_gpr[XRc - 1], 0, 16); + tcg_gen_brcondi_tl(TCG_COND_GE, t0, 0, l_not_less_lo); + tcg_gen_sextract_tl(t0, mxu_gpr[XRb - 1], 0, 16); + tcg_gen_subfi_tl(t0, 0, t0); + tcg_gen_br(l_done_lo); + + gen_set_label(l_not_less_lo); + tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 0, 16); + + gen_set_label(l_done_lo); + tcg_gen_deposit_tl(mxu_gpr[XRa - 1], t1, t0, 0, 16); + } +} + +/* + * Q8ABD XRa, XRb, XRc + * Gets absolute difference for quadruple of 8-bit + * packed in XRb to another one in XRc, + * put the result in XRa. + * a.k.a. XRa[0..3] = abs(XRb[0..3] - XRc[0..3]); + */ +static void gen_mxu_Q8ABD(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 3); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t4, XRc); + tcg_gen_movi_tl(t2, 0); + + for (int i = 0; i < 4; i++) { + tcg_gen_extract_tl(t0, t3, 8 * i, 8); + tcg_gen_extract_tl(t1, t4, 8 * i, 8); + + tcg_gen_sub_tl(t0, t0, t1); + tcg_gen_abs_tl(t0, t0); + + tcg_gen_deposit_tl(t2, t2, t0, 8 * i, 8); + } + gen_store_mxu_gpr(t2, XRa); + } +} + /* * Q8ADD XRa, XRb, XRc, ptn2 * Add/subtract quadruple of 8-bit packed in XRb @@ -1746,6 +1900,114 @@ static void gen_mxu_Q8ADD(DisasContext *ctx) } } +/* + * MXU instruction category: Miscellaneous + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * Q16SAT + */ + +/* + * Q16SAT XRa, XRb, XRc + * Packs four 16-bit signed integers in XRb and XRc to + * four saturated unsigned 8-bit into XRa. + * + */ +static void gen_mxu_Q16SAT(DisasContext *ctx) +{ + uint32_t pad, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 21, 3); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, 0); + if (XRb != 0) { + TCGLabel *l_less_hi = gen_new_label(); + TCGLabel *l_less_lo = gen_new_label(); + TCGLabel *l_lo = gen_new_label(); + TCGLabel *l_greater_hi = gen_new_label(); + TCGLabel *l_greater_lo = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + tcg_gen_sari_tl(t0, mxu_gpr[XRb - 1], 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t0, 0, l_less_hi); + tcg_gen_brcondi_tl(TCG_COND_GT, t0, 255, l_greater_hi); + tcg_gen_br(l_lo); + gen_set_label(l_less_hi); + tcg_gen_movi_tl(t0, 0); + tcg_gen_br(l_lo); + gen_set_label(l_greater_hi); + tcg_gen_movi_tl(t0, 255); + + gen_set_label(l_lo); + tcg_gen_shli_tl(t1, mxu_gpr[XRb - 1], 16); + tcg_gen_sari_tl(t1, t1, 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t1, 0, l_less_lo); + tcg_gen_brcondi_tl(TCG_COND_GT, t1, 255, l_greater_lo); + tcg_gen_br(l_done); + gen_set_label(l_less_lo); + tcg_gen_movi_tl(t1, 0); + tcg_gen_br(l_done); + gen_set_label(l_greater_lo); + tcg_gen_movi_tl(t1, 255); + + gen_set_label(l_done); + tcg_gen_shli_tl(t2, t0, 24); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(t2, t2, t1); + } + + if (XRc != 0) { + TCGLabel *l_less_hi = gen_new_label(); + TCGLabel *l_less_lo = gen_new_label(); + TCGLabel *l_lo = gen_new_label(); + TCGLabel *l_greater_hi = gen_new_label(); + TCGLabel *l_greater_lo = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + tcg_gen_sari_tl(t0, mxu_gpr[XRc - 1], 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t0, 0, l_less_hi); + tcg_gen_brcondi_tl(TCG_COND_GT, t0, 255, l_greater_hi); + tcg_gen_br(l_lo); + gen_set_label(l_less_hi); + tcg_gen_movi_tl(t0, 0); + tcg_gen_br(l_lo); + gen_set_label(l_greater_hi); + tcg_gen_movi_tl(t0, 255); + + gen_set_label(l_lo); + tcg_gen_shli_tl(t1, mxu_gpr[XRc - 1], 16); + tcg_gen_sari_tl(t1, t1, 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t1, 0, l_less_lo); + tcg_gen_brcondi_tl(TCG_COND_GT, t1, 255, l_greater_lo); + tcg_gen_br(l_done); + gen_set_label(l_less_lo); + tcg_gen_movi_tl(t1, 0); + tcg_gen_br(l_done); + gen_set_label(l_greater_lo); + tcg_gen_movi_tl(t1, 255); + + gen_set_label(l_done); + tcg_gen_shli_tl(t0, t0, 8); + tcg_gen_or_tl(t2, t2, t0); + tcg_gen_or_tl(t2, t2, t1); + } + gen_store_mxu_gpr(t2, XRa); + } +} + /* * MXU instruction category: align @@ -2085,6 +2347,31 @@ static void decode_opc_mxu__pool01(DisasContext *ctx) break; } } + +static void decode_opc_mxu__pool02(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 18, 3); + + switch (opcode) { + case OPC_MXU_S32CPS: + gen_mxu_S32CPS(ctx); + break; + case OPC_MXU_D16CPS: + gen_mxu_D16CPS(ctx); + break; + case OPC_MXU_Q8ABD: + gen_mxu_Q8ABD(ctx); + break; + case OPC_MXU_Q16SAT: + gen_mxu_Q16SAT(ctx); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool04(DisasContext *ctx) { uint32_t reversed = extract32(ctx->opcode, 20, 1); @@ -2334,6 +2621,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL01: decode_opc_mxu__pool01(ctx); break; + case OPC_MXU__POOL02: + decode_opc_mxu__pool02(ctx); + break; case OPC_MXU__POOL04: decode_opc_mxu__pool04(ctx); break; From patchwork Mon Jul 10 22:25:40 2023 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: 701069 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409614wrs; Mon, 10 Jul 2023 15:29:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6n3LQlNFbbsOsEDjeNHrYHdkK+wdSORz7kM1jseeo+TQfKl2Ay81KJ6EaRqSWy9h3XR7u X-Received: by 2002:a05:622a:1ba7:b0:403:b736:8ad with SMTP id bp39-20020a05622a1ba700b00403b73608admr624012qtb.63.1689028192743; Mon, 10 Jul 2023 15:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028192; cv=none; d=google.com; s=arc-20160816; b=0zqeoGWCeYdtNh8Zsc3BuPgs2Q9poZjqcDl+x/8cj9efjqbz3dJp3jT1NdULYemCA4 sd4DR4aJEHS31sPyrQxJsMBGg53sCA4gsk6eXvOj5fEpYO+7qE79qPxRAquXgxf16Vbs FuvkX+A6UqAq65e60QWxMTH32+ckPj781OStV0PNYOL6nShfQN1nXBE5yOIp+kXn/WSd wN5e1H3OjTzRMvx/EMwB7FHHlxYu3iHo3P1JRR7NhlJmDEQNH3C7ZCbY3i/lIxnlDCRa 2QZjh8gPKsfJKlJJHUTv+nQXUzjDfnt69PV0jgvAvxUleq5z52oEB1Xrqzo6IK36rHCU CIig== 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=0FO2ha3etxMvQjKWnYnIqZK4pico0eQHriQkByVcS+E=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=wgWaJ6a/8UKNog6Gzpxye8IhY8cl+LkPvCVI1QLY5Kjw6UCBlFfxLUZ00Tb8CiMdR8 marmgEIjFqnXXw2/hafiLSmw0N46ecncZdxSFR0e1uhTL1Itd5rhNbv4dIARp+HbrGMb d9UmZ7FkAA40mJ8QQlcy2NGQ/KQ+z+UCz1O0stiShExLrbG2gH42xmvCxf6wIzVRzydo DGcb8bi7Eoi9Y4l1r6vvRhhkX/EnpobLugslF69gi5DAHUS0I1z6lcmI1nQ9cPyEYG/y IOtmrUpRslBkJgkREdcu6izEC0hj/3UQqIfogohgkVHC6xMzaXXpR1vVOwjVA1X9DU6N DFwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j4DF+mZJ; 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 f30-20020a05622a1a1e00b00403b6b0c0a2si292438qtb.749.2023.07.10.15.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:52 -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=j4DF+mZJ; 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 1qIzM4-0003z6-7i; Mon, 10 Jul 2023 18:27: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 1qIzLy-0003uL-6F for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:34 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLr-0001pB-KK for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:32 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3094910b150so5525843f8f.0 for ; Mon, 10 Jul 2023 15:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028046; x=1691620046; 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=0FO2ha3etxMvQjKWnYnIqZK4pico0eQHriQkByVcS+E=; b=j4DF+mZJ7K27vE4VKQfBOwNHgX2/auzSpYWfJjwjdyBuOoT1j5exFabFia2odkeI6U MMVQTOWrpjp3s3byRj50l5vfTnj0ISu8cgv2EpHiT9fBqSpBS1/jBWZ0CmagrJ+A/Tqs I7XVuLRA02fmgvPWQRn0Q8oosNNzqtn4q3WqvWgkSozx32wLaDWVkqBqtpGbIqL8hkvl lT4Lw3f+yLuZNvhC0C4zHfn8aLlI9a52Eio66WbEguy+iC3jKqu771XI9rc52M/LQ4+G RoZ+aWPmnxrESu9IjnSB3IhjZV2DezSkbTAlJ5zkSAekJDs0CuUvDYjFJIhhATcZamsZ R14w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028046; x=1691620046; 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=0FO2ha3etxMvQjKWnYnIqZK4pico0eQHriQkByVcS+E=; b=Nk0jqu07zxaoIVCbIxvLfh+g5IiEefLpus6CYwpkz+pgz4DFD96zRff9cytXyKeC/I VrBFQcbHcOvaBXJKJ2qbdlbwMFKDoBNYQdOp4pTejp8W+sofVwG8tf7rr+aiUKEi3sD3 K+jdrn9mD6Cu027wyoL1ji9azzVtFvd+ae7DuteLi0gtbGCBPZ6gY8aCEyMO1OIvwnIT uz+8jScGLdlJN7TtW9+zLRFY0R+K5qGgmeLfFjkFtM13GjESbd2Ae1Ex2Fe3yDjd1YJ7 BDU+9zhrupb+e/xYXnjm/C6aZHvldYVWs0Do94R6GesZ9XViDaa8L09FPnRtmif9qV1J R1fQ== X-Gm-Message-State: ABy/qLYCIGw2OmsJRWGrAEwwLWqvAJHc6TR/EuQOjK4EudHrth7uGJL/ L8VctwT8GDB7SQf/ZRUkHOLw4WugLwjFFsEcmQFAsg== X-Received: by 2002:a05:6000:1087:b0:314:dc0:2fca with SMTP id y7-20020a056000108700b003140dc02fcamr13612629wrw.29.1689028046115; Mon, 10 Jul 2023 15:27:26 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id f6-20020adff586000000b003142eb75724sm541344wro.24.2023.07.10.15.27.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 13/44] target/mips/mxu: Add D16MULF D16MULE instructions Date: Tue, 11 Jul 2023 00:25:40 +0200 Message-Id: <20230710222611.50978-14-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are part of pool3, see the grand tree above in the file. The instructions are close to D16MUL so common generation function provided. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-11-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 95 +++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 3bd5fcb98a..b683f3d95c 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -361,6 +361,7 @@ enum { OPC_MXU__POOL01 = 0x06, OPC_MXU__POOL02 = 0x07, OPC_MXU_D16MUL = 0x08, + OPC_MXU__POOL03 = 0x09, OPC_MXU_D16MAC = 0x0A, OPC_MXU__POOL04 = 0x10, OPC_MXU__POOL05 = 0x11, @@ -416,6 +417,14 @@ enum { OPC_MXU_Q16SAT = 0x06, }; +/* + * MXU pool 03 + */ +enum { + OPC_MXU_D16MULF = 0x00, + OPC_MXU_D16MULE = 0x01, +}; + /* * MXU pool 04 05 06 07 08 09 10 11 */ @@ -660,9 +669,14 @@ static void gen_mxu_s8ldd(DisasContext *ctx) } /* - * D16MUL XRa, XRb, XRc, XRd, optn2 - Signed 16 bit pattern multiplication + * D16MUL XRa, XRb, XRc, XRd, optn2 - Signed 16 bit pattern multiplication + * D16MULF XRa, XRb, XRc, optn2 - Signed Q15 fraction pattern multiplication + * with rounding and packing result + * D16MULE XRa, XRb, XRc, XRd, optn2 - Signed Q15 fraction pattern + * multiplication with rounding */ -static void gen_mxu_d16mul(DisasContext *ctx) +static void gen_mxu_d16mul(DisasContext *ctx, bool fractional, + bool packed_result) { TCGv t0, t1, t2, t3; uint32_t XRa, XRb, XRc, XRd, optn2; @@ -678,6 +692,12 @@ static void gen_mxu_d16mul(DisasContext *ctx) XRd = extract32(ctx->opcode, 18, 4); optn2 = extract32(ctx->opcode, 22, 2); + /* + * TODO: XRd field isn't used for D16MULF + * There's no knowledge how this field affect + * instruction decoding/behavior + */ + gen_load_mxu_gpr(t1, XRb); tcg_gen_sextract_tl(t0, t1, 0, 16); tcg_gen_sextract_tl(t1, t1, 16, 16); @@ -703,8 +723,52 @@ static void gen_mxu_d16mul(DisasContext *ctx) tcg_gen_mul_tl(t2, t1, t2); break; } - gen_store_mxu_gpr(t3, XRa); - gen_store_mxu_gpr(t2, XRd); + if (fractional) { + TCGLabel *l_done = gen_new_label(); + TCGv rounding = tcg_temp_new(); + + tcg_gen_shli_tl(t3, t3, 1); + tcg_gen_shli_tl(t2, t2, 1); + tcg_gen_andi_tl(rounding, mxu_CR, 0x2); + tcg_gen_brcondi_tl(TCG_COND_EQ, rounding, 0, l_done); + if (packed_result) { + TCGLabel *l_apply_bias_l = gen_new_label(); + TCGLabel *l_apply_bias_r = gen_new_label(); + TCGLabel *l_half_done = gen_new_label(); + TCGv bias = tcg_temp_new(); + + /* + * D16MULF supports unbiased rounding aka "bankers rounding", + * "round to even", "convergent rounding" + */ + tcg_gen_andi_tl(bias, mxu_CR, 0x4); + tcg_gen_brcondi_tl(TCG_COND_NE, bias, 0, l_apply_bias_l); + tcg_gen_andi_tl(t0, t3, 0x1ffff); + tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0x8000, l_half_done); + gen_set_label(l_apply_bias_l); + tcg_gen_addi_tl(t3, t3, 0x8000); + gen_set_label(l_half_done); + tcg_gen_brcondi_tl(TCG_COND_NE, bias, 0, l_apply_bias_r); + tcg_gen_andi_tl(t0, t2, 0x1ffff); + tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0x8000, l_done); + gen_set_label(l_apply_bias_r); + tcg_gen_addi_tl(t2, t2, 0x8000); + } else { + /* D16MULE doesn't support unbiased rounding */ + tcg_gen_addi_tl(t3, t3, 0x8000); + tcg_gen_addi_tl(t2, t2, 0x8000); + } + gen_set_label(l_done); + } + if (!packed_result) { + gen_store_mxu_gpr(t3, XRa); + gen_store_mxu_gpr(t2, XRd); + } else { + tcg_gen_andi_tl(t3, t3, 0xffff0000); + tcg_gen_shri_tl(t2, t2, 16); + tcg_gen_or_tl(t3, t3, t2); + gen_store_mxu_gpr(t3, XRa); + } } /* @@ -2372,6 +2436,24 @@ static void decode_opc_mxu__pool02(DisasContext *ctx) } } +static void decode_opc_mxu__pool03(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 24, 2); + + switch (opcode) { + case OPC_MXU_D16MULF: + gen_mxu_d16mul(ctx, true, true); + break; + case OPC_MXU_D16MULE: + gen_mxu_d16mul(ctx, true, false); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool04(DisasContext *ctx) { uint32_t reversed = extract32(ctx->opcode, 20, 1); @@ -2613,7 +2695,7 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) decode_opc_mxu__pool00(ctx); break; case OPC_MXU_D16MUL: - gen_mxu_d16mul(ctx); + gen_mxu_d16mul(ctx, false, false); break; case OPC_MXU_D16MAC: gen_mxu_d16mac(ctx); @@ -2624,6 +2706,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL02: decode_opc_mxu__pool02(ctx); break; + case OPC_MXU__POOL03: + decode_opc_mxu__pool03(ctx); + break; case OPC_MXU__POOL04: decode_opc_mxu__pool04(ctx); break; From patchwork Mon Jul 10 22:25:41 2023 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: 701097 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411218wrs; Mon, 10 Jul 2023 15:33:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFalVX1B+5aQonnPVUhbSfUQyCRpgxLJU0DtR1btkChNSs3WBCHZFr08UdYLnZg9t3sBgPw X-Received: by 2002:a05:620a:19a8:b0:767:26a4:ab38 with SMTP id bm40-20020a05620a19a800b0076726a4ab38mr16499091qkb.25.1689028417328; Mon, 10 Jul 2023 15:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028417; cv=none; d=google.com; s=arc-20160816; b=lBlHa7qLMP1ydrE5NYt2E1cvpYiSNfGmPOdLwipEnr4kmQRAwGgh06RlxNO9HazXnc j0zA0nY/A8iAoIopErFTLGiFRIIH7aiTZEKI06A7SmEBzOeLJ+r4iDIHB+IxlwuR/x16 kCgqU9am/rX2i+2saukMgVM0SMT8VzsNnZpPH5agS3nD86MSfMhMr6jVrqhBWVhZNWFp 8fGmGJlIGbHA61Q3YSKxnfrY+/gG3ahB9lytlIkgh4MbGWozh3o42bDi6UgpkitPg2xa syG5fUoN90MhLrmHvmjdGu2K+gtJD9AXnvk00Gr1k5L1NpqpgfWDRSF3LnB/ZiGQeq4F 6lxg== 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=nYkFz4+3J6+gMYy7zGAAByxRLT3tZPBqXFdIfL3YZhY=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=zo+6NcKFFjH1XKR4oz1KGZw+3yIepkZah/JzXFn9tbAMu6RQFNy1TJkhgLRhbsuKri +SGosd0IsXF4YoSWBnMWPSr8V02dBJdF8p+PRr+cziXa8qcCisrZWsmugIe97dTTmfLE PriwTJrooalsnotrTmT5qw1ObILsM5evoKg30hsXIHEzd3GHWJ8XSdnCdgkmdGFmZwFT iH6r8ohP+ym+OPziz6nSiG5q5kKEW5ivHkjvAhpTeJlRHBV0uTuZHtBw+KGkSukAsBS7 sV32EHlxSuF8WrONN/VLPDNSNnWsLwVX0SvwNG4XWsaDQZ906YkJZAZ87wLxSDULOloz hdUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jLzpWlDm; 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 w14-20020a0cdf8e000000b006366264487bsi246743qvl.359.2023.07.10.15.33.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:37 -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=jLzpWlDm; 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 1qIzM7-0004GU-TR; Mon, 10 Jul 2023 18:27:43 -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 1qIzLy-0003wC-T1 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:36 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzLx-0001pp-4i for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:34 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-314319c0d3eso5457560f8f.0 for ; Mon, 10 Jul 2023 15:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028051; x=1691620051; 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=nYkFz4+3J6+gMYy7zGAAByxRLT3tZPBqXFdIfL3YZhY=; b=jLzpWlDmGYMb3wWZP9PfPzWY+B7UXgZL9aCKfifz3KqOtfrkibdR7p1ECxQOrCJVNA IeWftKWH/Fh39AKaDouZSzKK3T9RRzKn5KKQx7atsUKTq6CX2wnZ/jIwUNN2ievx4PTf EXtllCN80htHGX+3sqJ2rabwtpdDCghGbdZmdFC3OMAigJqclsGEL7brNonblh+oZivS FpCBtdK55X8pQ4Z8Ry8mTOLLMzJWE+hzFvXsr70p8lRILNI177ih1iOAwvA3wuqYFjwe 5DQ+vRZmLDkwRy8f5bGo5VSmvpaErOcGjLEuwppRRwDdjT7jJY17oZaIyzPDZvKLnBan nKQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028051; x=1691620051; 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=nYkFz4+3J6+gMYy7zGAAByxRLT3tZPBqXFdIfL3YZhY=; b=TM743kN+Pmk9jU3oyG+YxOt26dA5OUXhW6omh0GjpzbTSnRB36lgjEG2H2WH5kCtAU A5sZD8+8sRT/Nnk7ao6E4zJhcuyjca0TEeIUkjVfq/PXbFnz4iV5+ZyzsSAOF6Kfubfb Rled9TK84GCZDb3NQioaTdx3vrEx8oCCwDmpq5GCXn3IYcpOIeFWJxDPvFVv5JD45Y5+ C1me7qspUg1JeMNBOJeR/QAsnFzVE8P5/8VoOG8i+XDZ65VZKQj+0w7wwobuS2D54pBE xajQDbmzBphkZhG2gq4XT6xD4agwPdH4AK9i5f1B8blZyhPM5yE9D2nZNT7sDoFrlwRm h31A== X-Gm-Message-State: ABy/qLZQAqK6KTadqGZ4jBnYvz71TYfahbEek/jtOW3gO2oaGXA96lit xJvF8ybqXi4+hKbKkLODkjn2UzekmWaoEmalIegstA== X-Received: by 2002:a05:6000:4e4:b0:313:f61c:42ab with SMTP id cr4-20020a05600004e400b00313f61c42abmr14709193wrb.56.1689028051737; Mon, 10 Jul 2023 15:27:31 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id q15-20020adffecf000000b003142439c7bcsm515194wrs.80.2023.07.10.15.27.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 14/44] target/mips/mxu: Add D16MACF D16MACE instructions Date: Tue, 11 Jul 2023 00:25:41 +0200 Message-Id: <20230710222611.50978-15-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are close to D16MAC so common generation function provided. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-12-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 74 ++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index b683f3d95c..b58fad4436 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -363,6 +363,8 @@ enum { OPC_MXU_D16MUL = 0x08, OPC_MXU__POOL03 = 0x09, OPC_MXU_D16MAC = 0x0A, + OPC_MXU_D16MACF = 0x0B, + OPC_MXU_D16MACE = 0x0F, OPC_MXU__POOL04 = 0x10, OPC_MXU__POOL05 = 0x11, OPC_MXU__POOL06 = 0x12, @@ -772,10 +774,15 @@ static void gen_mxu_d16mul(DisasContext *ctx, bool fractional, } /* - * D16MAC XRa, XRb, XRc, XRd, aptn2, optn2 - Signed 16 bit pattern multiply - * and accumulate + * D16MAC XRa, XRb, XRc, XRd, aptn2, optn2 + * Signed 16 bit pattern multiply and accumulate + * D16MACF XRa, XRb, XRc, aptn2, optn2 + * Signed Q15 fraction pattern multiply accumulate and pack + * D16MACE XRa, XRb, XRc, XRd, aptn2, optn2 + * Signed Q15 fraction pattern multiply and accumulate */ -static void gen_mxu_d16mac(DisasContext *ctx) +static void gen_mxu_d16mac(DisasContext *ctx, bool fractional, + bool packed_result) { TCGv t0, t1, t2, t3; uint32_t XRa, XRb, XRc, XRd, optn2, aptn2; @@ -818,6 +825,11 @@ static void gen_mxu_d16mac(DisasContext *ctx) tcg_gen_mul_tl(t2, t1, t2); break; } + + if (fractional) { + tcg_gen_shli_tl(t3, t3, 1); + tcg_gen_shli_tl(t2, t2, 1); + } gen_load_mxu_gpr(t0, XRa); gen_load_mxu_gpr(t1, XRd); @@ -839,8 +851,52 @@ static void gen_mxu_d16mac(DisasContext *ctx) tcg_gen_sub_tl(t2, t1, t2); break; } - gen_store_mxu_gpr(t3, XRa); - gen_store_mxu_gpr(t2, XRd); + + if (fractional) { + TCGLabel *l_done = gen_new_label(); + TCGv rounding = tcg_temp_new(); + + tcg_gen_andi_tl(rounding, mxu_CR, 0x2); + tcg_gen_brcondi_tl(TCG_COND_EQ, rounding, 0, l_done); + if (packed_result) { + TCGLabel *l_apply_bias_l = gen_new_label(); + TCGLabel *l_apply_bias_r = gen_new_label(); + TCGLabel *l_half_done = gen_new_label(); + TCGv bias = tcg_temp_new(); + + /* + * D16MACF supports unbiased rounding aka "bankers rounding", + * "round to even", "convergent rounding" + */ + tcg_gen_andi_tl(bias, mxu_CR, 0x4); + tcg_gen_brcondi_tl(TCG_COND_NE, bias, 0, l_apply_bias_l); + tcg_gen_andi_tl(t0, t3, 0x1ffff); + tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0x8000, l_half_done); + gen_set_label(l_apply_bias_l); + tcg_gen_addi_tl(t3, t3, 0x8000); + gen_set_label(l_half_done); + tcg_gen_brcondi_tl(TCG_COND_NE, bias, 0, l_apply_bias_r); + tcg_gen_andi_tl(t0, t2, 0x1ffff); + tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0x8000, l_done); + gen_set_label(l_apply_bias_r); + tcg_gen_addi_tl(t2, t2, 0x8000); + } else { + /* D16MACE doesn't support unbiased rounding */ + tcg_gen_addi_tl(t3, t3, 0x8000); + tcg_gen_addi_tl(t2, t2, 0x8000); + } + gen_set_label(l_done); + } + + if (!packed_result) { + gen_store_mxu_gpr(t3, XRa); + gen_store_mxu_gpr(t2, XRd); + } else { + tcg_gen_andi_tl(t3, t3, 0xffff0000); + tcg_gen_shri_tl(t2, t2, 16); + tcg_gen_or_tl(t3, t3, t2); + gen_store_mxu_gpr(t3, XRa); + } } /* @@ -2698,7 +2754,13 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) gen_mxu_d16mul(ctx, false, false); break; case OPC_MXU_D16MAC: - gen_mxu_d16mac(ctx); + gen_mxu_d16mac(ctx, false, false); + break; + case OPC_MXU_D16MACF: + gen_mxu_d16mac(ctx, true, true); + break; + case OPC_MXU_D16MACE: + gen_mxu_d16mac(ctx, true, false); break; case OPC_MXU__POOL01: decode_opc_mxu__pool01(ctx); From patchwork Mon Jul 10 22:25:42 2023 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: 701060 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409008wrs; Mon, 10 Jul 2023 15:27:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlHuI8vDbgtbXMrEXVK1EW/naW3cFs8TiXCsXDFb0TY2cczMHMANtLmHwnnxc2VeDgE4qOHp X-Received: by 2002:a0c:b21c:0:b0:630:7d0:56f4 with SMTP id x28-20020a0cb21c000000b0063007d056f4mr11469779qvd.49.1689028078641; Mon, 10 Jul 2023 15:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028078; cv=none; d=google.com; s=arc-20160816; b=MQcgwqgg+BnLTIwO/a+gxnLXVs5FgRdyZXuGH/YDOwBBCVAZCdhn5r13TFBUZXqg9a HsSyDunWqJ6vUAhSTHQ5QA9DgmA94/U6iKUkK8gb+lsdFlfHh1ObJeVhVbmvec2sp7df KQsp93suRnUaS4fz6MKz67HtHq/+MHdW1vT2l6zWooc7T+/hSTxzCaLw4YrVbuir7cN4 2TmmFlgCPjO7WlQWtX5LcBPQNqz2Zh+8HWmkpEXGU0yMjstqRBXxK2AxnSL1Uvm5mJET 64daTqawQwAzBdUe5WoS/VyiBx76WvgLYgDxN+J5o+ag1ff83UBYCloGy7cs2gtT2eLJ 5yog== 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=W0etzPMoTBfN1VORUKR+U0D0LCT8oYv5PqzNMcPmRIw=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=GGss/a6hTTm/puvJT4NNXVEPts760HAIzH3z/2qdr9YWHf0B4MWGLFtQ4a2WarAzQa R3AaAn4fYaVUss0z7riQ9tYZ111M8oMKWX0YXekpVVwPKmFp2hDPOXpiI/Im7Xf3idTy YkqkPa86WV7PgmFt2s13MO9hr2wc87LexBAghkG4anJtcFv9dTgCbpYFNKPUgg/G/yIJ 0S4S6JM1wGd1Ih46su0oOohLqkNq7gWgkFC0IgcR8B1REj9EwM9ypg8fcTQwsTsk+LVK pmArzMVJZPH84JBark+C8BIjxDHBrfC/iJd2XXb5L77XKj5G0Uu6u1h9L9jpR2X4+Za/ KaHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jmadiZwO; 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 q5-20020a0c8cc5000000b00625c59cf054si251036qvb.329.2023.07.10.15.27.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:27:58 -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=jmadiZwO; 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 1qIzM9-0004iT-C2; Mon, 10 Jul 2023 18:27: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 1qIzM4-0004CY-QJ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:41 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzM3-0001qP-3H for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:40 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fc02a92dcfso32932285e9.0 for ; Mon, 10 Jul 2023 15:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028057; x=1691620057; 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=W0etzPMoTBfN1VORUKR+U0D0LCT8oYv5PqzNMcPmRIw=; b=jmadiZwOlFxTnx23IDexFnDh9DKyFuEkZ2j+53bdtjZJogB8xz5JCEcrtbsqwzE9YD xbWDjJN7GpNb+oJ3oIQ7tvgch7n6dHNeTcERsis6A/uu6h+Q1C6jGmMjNjsSfoEs9q4A HTVzZE7P8gqO0nGaOOxDRUmPzHU8TlGiq8pkU+T9Axz6U3W5/7oEVwvRPrlpzmxZmvWn D3o00NWVW7LcQoiKfrQALTjYqjURdhdTMlrYIkCrB9vZO4Tl3QUhUjAmRvGhVgz5qFYo 5VI2lxLwS7oa+lvfjFkDV/+Qs/IDZQ1Z9tgvCFOCRHZgFIuqQLf2mEluLRYAWMTULymV rk0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028057; x=1691620057; 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=W0etzPMoTBfN1VORUKR+U0D0LCT8oYv5PqzNMcPmRIw=; b=OkNjGx3862lb7LdbpBjF46+29pnPz1SII3M7dMk0A+1MZj3PKnpjXkMSy7Mbw6urVr BTVTKniLtQ+PgTKUdcm2AuPcGGilvC1bbH5oWUuO4lQWAGkQwrgebtfH6l4elaHwYD+4 vlvLpQh83z8yhASLaa4iKxUXRJULGMuTRKHDn3J3zjiIhrOs3yDd46CwESKt8mSbivGq H2lzCi6qpnm/g33M20b//6gROy3LTUiFrZJRUFf8VE5fkFU/BidNtN7kkIyQ86xkPNK3 LB4MrPLNMSpElJ8kSivEYjIuimArTjTr8QT2oIHCvJMZ6hNpF0AhqZV3p9XkN0qEAiBY 0Aew== X-Gm-Message-State: ABy/qLbNLhQdH9Gsc4oY28gfVpcRZDpXlaHHnEasjOZVvNtuOl4+UWjy swDW79lhFsOkvHkOBNy/ymHB5hDpNLzgjv+KQq19Ow== X-Received: by 2002:a05:600c:2193:b0:3f9:b955:5584 with SMTP id e19-20020a05600c219300b003f9b9555584mr13024472wme.34.1689028057223; Mon, 10 Jul 2023 15:27:37 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id f1-20020a5d50c1000000b0031438e42599sm520750wrt.82.2023.07.10.15.27.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 15/44] target/mips/mxu: Add D16MADL instruction Date: Tue, 11 Jul 2023 00:25:42 +0200 Message-Id: <20230710222611.50978-16-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction is similar to multiply and accumulate but works with MXU registers set. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-13-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 82 +++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index b58fad4436..202e1c6d35 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -364,6 +364,7 @@ enum { OPC_MXU__POOL03 = 0x09, OPC_MXU_D16MAC = 0x0A, OPC_MXU_D16MACF = 0x0B, + OPC_MXU_D16MADL = 0x0C, OPC_MXU_D16MACE = 0x0F, OPC_MXU__POOL04 = 0x10, OPC_MXU__POOL05 = 0x11, @@ -899,6 +900,84 @@ static void gen_mxu_d16mac(DisasContext *ctx, bool fractional, } } +/* + * D16MADL XRa, XRb, XRc, XRd, aptn2, optn2 - Double packed + * unsigned 16 bit pattern multiply and add/subtract. + */ +static void gen_mxu_d16madl(DisasContext *ctx) +{ + TCGv t0, t1, t2, t3; + uint32_t XRa, XRb, XRc, XRd, optn2, aptn2; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + t3 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRd = extract32(ctx->opcode, 18, 4); + optn2 = extract32(ctx->opcode, 22, 2); + aptn2 = extract32(ctx->opcode, 24, 2); + + gen_load_mxu_gpr(t1, XRb); + tcg_gen_sextract_tl(t0, t1, 0, 16); + tcg_gen_sextract_tl(t1, t1, 16, 16); + + gen_load_mxu_gpr(t3, XRc); + tcg_gen_sextract_tl(t2, t3, 0, 16); + tcg_gen_sextract_tl(t3, t3, 16, 16); + + switch (optn2) { + case MXU_OPTN2_WW: /* XRB.H*XRC.H == lop, XRB.L*XRC.L == rop */ + tcg_gen_mul_tl(t3, t1, t3); + tcg_gen_mul_tl(t2, t0, t2); + break; + case MXU_OPTN2_LW: /* XRB.L*XRC.H == lop, XRB.L*XRC.L == rop */ + tcg_gen_mul_tl(t3, t0, t3); + tcg_gen_mul_tl(t2, t0, t2); + break; + case MXU_OPTN2_HW: /* XRB.H*XRC.H == lop, XRB.H*XRC.L == rop */ + tcg_gen_mul_tl(t3, t1, t3); + tcg_gen_mul_tl(t2, t1, t2); + break; + case MXU_OPTN2_XW: /* XRB.L*XRC.H == lop, XRB.H*XRC.L == rop */ + tcg_gen_mul_tl(t3, t0, t3); + tcg_gen_mul_tl(t2, t1, t2); + break; + } + tcg_gen_extract_tl(t2, t2, 0, 16); + tcg_gen_extract_tl(t3, t3, 0, 16); + + gen_load_mxu_gpr(t1, XRa); + tcg_gen_extract_tl(t0, t1, 0, 16); + tcg_gen_extract_tl(t1, t1, 16, 16); + + switch (aptn2) { + case MXU_APTN2_AA: + tcg_gen_add_tl(t3, t1, t3); + tcg_gen_add_tl(t2, t0, t2); + break; + case MXU_APTN2_AS: + tcg_gen_add_tl(t3, t1, t3); + tcg_gen_sub_tl(t2, t0, t2); + break; + case MXU_APTN2_SA: + tcg_gen_sub_tl(t3, t1, t3); + tcg_gen_add_tl(t2, t0, t2); + break; + case MXU_APTN2_SS: + tcg_gen_sub_tl(t3, t1, t3); + tcg_gen_sub_tl(t2, t0, t2); + break; + } + + tcg_gen_andi_tl(t2, t2, 0xffff); + tcg_gen_shli_tl(t3, t3, 16); + tcg_gen_or_tl(mxu_gpr[XRd - 1], t3, t2); +} + /* * Q8MUL XRa, XRb, XRc, XRd - Parallel unsigned 8 bit pattern multiply * Q8MULSU XRa, XRb, XRc, XRd - Parallel signed 8 bit pattern multiply @@ -2759,6 +2838,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_D16MACF: gen_mxu_d16mac(ctx, true, true); break; + case OPC_MXU_D16MADL: + gen_mxu_d16madl(ctx); + break; case OPC_MXU_D16MACE: gen_mxu_d16mac(ctx, true, false); break; From patchwork Mon Jul 10 22:25:43 2023 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: 701072 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409842wrs; Mon, 10 Jul 2023 15:30:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMPwnA9rFL+HYC5GTAmcAPLr2jUwfvl0kTBX4fj7wT3i+2FMQND1eWu/5dBG47P6+513nn X-Received: by 2002:a05:620a:4490:b0:767:27e1:fcc4 with SMTP id x16-20020a05620a449000b0076727e1fcc4mr14666023qkp.22.1689028215230; Mon, 10 Jul 2023 15:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028215; cv=none; d=google.com; s=arc-20160816; b=PO7EFawRTO+MIbMRdxLEk+Ym3RKcFL4zilonqaz9rReRLhLr5Y6pauPcmkGpPyZaCz FIMdSdkHpEqtMNvlN1brNAJP78jnsquu2+x8QtraJTEYPyd3T6PCv76pgihXF6q9tmo1 WpJFZc1Tlbez04PueOyMD2pXpvpqFdmh4G+f30nTCHcjfv5LIRStVe8DrSvr0Ev5m03x lQ+5F2yZOCVm/zMCcypsMyr3xA6otxD/6iBWbI5O4C3I9tIa14+HMF33YbHw72FBEDv/ BIVNJ0w8TyIqCSh91ZZoLL7zrZRHCOoz+d1wex5kPUv0U8yZBb58ZJDFzf0OdYuZH+up cP6A== 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=y2cFjMtcI1fhdAdPikpinVWIlu5aYzG/8DNZsPsFkiQ=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=MX/fDS4GVMpErMKP+RlTj6sWoIajOGDhQVnX2P/uXq0sOPI7IhZZZM0rhrBQ85MOvy LK+wsspXAPad4ZOIGJa9BWJG2O/AlB/Gc1fXTSWxATXD2mwhV44cg9eb7vhsNcnwGgiu T/KgvcclpFO2wjwjYAE9xhRaC9VqQneGsl2sK62+OWdKOZ/kr6k6ztK032NsfXcbzSZc uSRS4muGvmracrGMhy/CoTySXncoibjQZLbrw5w5zw9AbnseN6v6MqIwivrNfz8v+0LQ VVbP77oe6vXyYqKsJdCIUkeu1TqJUuTIwpNxJ55bRfCJqlHbTH7i0AU27daPZn4JIyRn Ok9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M6p/UPn6"; 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 x7-20020a05620a258700b00766fc21efb8si262749qko.442.2023.07.10.15.30.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:30:15 -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="M6p/UPn6"; 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 1qIzMB-0004yi-A3; Mon, 10 Jul 2023 18:27:47 -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 1qIzM9-0004kn-OO for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:45 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzM7-0001qv-TH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:45 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3142ee41fd2so5091044f8f.3 for ; Mon, 10 Jul 2023 15:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028062; x=1691620062; 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=y2cFjMtcI1fhdAdPikpinVWIlu5aYzG/8DNZsPsFkiQ=; b=M6p/UPn6Yr3W8Bmv36Db/H0UFpv+NvYrIluwAuqDA/NavUtg55tNm2PTne+gZBEvMA wMoqiZadsKuWVZ66wrBgGX8493hnC+b86oASlSX69BTCdSGWwXbmPAg4ZKrP/nYFxigD 5i4F1LnDlQXcRAEpWCje5tORTIyI7jzeQJLDwBkFBh11i8zCypgxz/LZ5vkYoIfq0pv8 m61BPrjQ0CIrljk1a5w/WcFumCm3pChdznXoqcn2cPEDFGclhKvsLxdIE14CrOxOMZMh 3jM0NJPKV3aGOBQ1jCw0X6EyC0mKK8PRHZhEW0Jn+QXp5C8WIylOpp/XYmSXqmobnR1m yC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028062; x=1691620062; 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=y2cFjMtcI1fhdAdPikpinVWIlu5aYzG/8DNZsPsFkiQ=; b=XATwrOdR8GDGeL0rJvEM6wR/R4xgT4sUEMSuzuU97ap09dtXnsg5/gjkYyDsmX8ZUV NKVap5CRsSTqRVDJzoqHqX7Y3KeIV8ty/U7O0kw+mpa3BK2gIAyWJcNt5AbmlFXXhjJC k1hWQjXAm4krAh37Tb/YbBmjrN8TAmOld2xmStU7yp981okt97zZng4A+XdUmoB/dIUz IHrZO3KQD1dbsYszqK+dyYi1o7SEXQRsT2x9v/K0MXQ9X6T2F2jvRAlPmsxYQXEstYEV vI95JoEz4wCwP+AxIuJal2trapBo3Ea6iH/P6F4M2kQi3+zuqmVNGBTF8nfoDk/LneTd gFxw== X-Gm-Message-State: ABy/qLZ4WA71GY5GznXbfwzThEHa96vGb1zvXZYd9XYWdn35yCwYBj0F GOw6GIbHAd2bNS9BgplkvLExxFTQq/JgtTQcwfuOlg== X-Received: by 2002:adf:f949:0:b0:313:f4f5:2ddc with SMTP id q9-20020adff949000000b00313f4f52ddcmr12676398wrr.62.1689028062520; Mon, 10 Jul 2023 15:27:42 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id q10-20020adfdfca000000b003144b95e1ecsm507049wrn.93.2023.07.10.15.27.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 16/44] target/mips/mxu: Add S16MAD instruction Date: Tue, 11 Jul 2023 00:25:43 +0200 Message-Id: <20230710222611.50978-17-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction is similar to multiply and accumulate but works with MXU registers set. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-14-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 202e1c6d35..88d5d659c6 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -365,6 +365,7 @@ enum { OPC_MXU_D16MAC = 0x0A, OPC_MXU_D16MACF = 0x0B, OPC_MXU_D16MADL = 0x0C, + OPC_MXU_S16MAD = 0x0D, OPC_MXU_D16MACE = 0x0F, OPC_MXU__POOL04 = 0x10, OPC_MXU__POOL05 = 0x11, @@ -978,6 +979,67 @@ static void gen_mxu_d16madl(DisasContext *ctx) tcg_gen_or_tl(mxu_gpr[XRd - 1], t3, t2); } +/* + * S16MAD XRa, XRb, XRc, XRd, aptn2, optn2 - Single packed + * signed 16 bit pattern multiply and 32-bit add/subtract. + */ +static void gen_mxu_s16mad(DisasContext *ctx) +{ + TCGv t0, t1; + uint32_t XRa, XRb, XRc, XRd, optn2, aptn1, pad; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRd = extract32(ctx->opcode, 18, 4); + optn2 = extract32(ctx->opcode, 22, 2); + aptn1 = extract32(ctx->opcode, 24, 1); + pad = extract32(ctx->opcode, 25, 1); + + if (pad) { + /* FIXME check if it influence the result */ + } + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + + switch (optn2) { + case MXU_OPTN2_WW: /* XRB.H*XRC.H */ + tcg_gen_sextract_tl(t0, t0, 16, 16); + tcg_gen_sextract_tl(t1, t1, 16, 16); + break; + case MXU_OPTN2_LW: /* XRB.L*XRC.L */ + tcg_gen_sextract_tl(t0, t0, 0, 16); + tcg_gen_sextract_tl(t1, t1, 0, 16); + break; + case MXU_OPTN2_HW: /* XRB.H*XRC.L */ + tcg_gen_sextract_tl(t0, t0, 16, 16); + tcg_gen_sextract_tl(t1, t1, 0, 16); + break; + case MXU_OPTN2_XW: /* XRB.L*XRC.H */ + tcg_gen_sextract_tl(t0, t0, 0, 16); + tcg_gen_sextract_tl(t1, t1, 16, 16); + break; + } + tcg_gen_mul_tl(t0, t0, t1); + + gen_load_mxu_gpr(t1, XRa); + + switch (aptn1) { + case MXU_APTN1_A: + tcg_gen_add_tl(t1, t1, t0); + break; + case MXU_APTN1_S: + tcg_gen_sub_tl(t1, t1, t0); + break; + } + + gen_store_mxu_gpr(t1, XRd); +} + /* * Q8MUL XRa, XRb, XRc, XRd - Parallel unsigned 8 bit pattern multiply * Q8MULSU XRa, XRb, XRc, XRd - Parallel signed 8 bit pattern multiply @@ -2841,6 +2903,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_D16MADL: gen_mxu_d16madl(ctx); break; + case OPC_MXU_S16MAD: + gen_mxu_s16mad(ctx); + break; case OPC_MXU_D16MACE: gen_mxu_d16mac(ctx, true, false); break; From patchwork Mon Jul 10 22:25:44 2023 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: 701063 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409125wrs; Mon, 10 Jul 2023 15:28:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZ8pnmUZ7rd3GxhNB2EUJi8mpj2yCFEhbr/cirUtkX4BlDbt8dDjnoZPNvVCYOL+dFAgDR X-Received: by 2002:a05:620a:d8b:b0:765:5a1f:89 with SMTP id q11-20020a05620a0d8b00b007655a1f0089mr14246090qkl.13.1689028100582; Mon, 10 Jul 2023 15:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028100; cv=none; d=google.com; s=arc-20160816; b=jKrDlMdLeFbQpIAbn4tp8vfV4PiMsj8sAa6xWmFI1Y0nybLq31TmQl/6EZBMXXNEqG FHcoVf8ASMk9YFpTmREZvecEdZd1GSslFctkcapqlPo3pdRTSG0TWaedWGpU1dZiAW/E oSqj+2cQLxLlmaCUkJwFKxKJLtBZmalJwO9my1pytOSoNAJ/DEKFnpF7VzLnjfOQ8vxM /Gl4J+SajUtXhAuXfAE2rK9mI70kh+HcHb6cNPcn2QLBN4prGfId/dXRHBSXWy5eFRyg WxjiIGVYYxjxTWgzyy35vQz/ucsDgCFr6XdboH1PjNgIsepBXL0wE6AEhaXOPlh9U4nB Goqw== 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=c2gywGlg3U3R0miq997BeVmgkx+5ZHsZAXz08FZ2lJw=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=JtRDZtwACbQXMeu3GW0SgV2HLFlmzII9Xlmuve5mHDq/4i05fR4M2fdZc733wfcBZq MTm3ynTtApj4ypl4ui8Ia98HHQkhP6MTEI8u/4tamZ8Di7wDthagb/sl/a1GeiVJtZp9 PwMNzooItfArgRPYf/SeVWIF/V1sNRlfOSew3p64zN/97FZ1ulzJUroJDRj6rDD/uuOL Op6GQUqQ7xN6HFOaIN2B7mo+/bpDhI4YUGvFnNWXDhhRsCZLjUB5oyIuV0Ndjoeym2Te gv6OojbHu+oHJ72HICi2YwKaiiOwlvUgmzuzwXAGs1D1a3dlEFNVymwy9OrvEU8a7++G rRmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vTbbqKg4; 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 s18-20020a05620a29d200b00767d9c2c5c2si256431qkp.473.2023.07.10.15.28.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:28:20 -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=vTbbqKg4; 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 1qIzMH-0005uR-4U; Mon, 10 Jul 2023 18:27:53 -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 1qIzMF-0005j8-8S for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:51 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMD-0001rO-Gf for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:51 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc6ab5ff5so52525715e9.1 for ; Mon, 10 Jul 2023 15:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028068; x=1691620068; 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=c2gywGlg3U3R0miq997BeVmgkx+5ZHsZAXz08FZ2lJw=; b=vTbbqKg4hGH/ptcVd+ssjzSNCzvZDoVUIH+3H+K0+wDAyeOpxp+Hs4N4ZZQUPTSCU4 pNevUhjqbFMtIwPM4nuG9g9FklTAE/4AFVBhKg1CtnsDuW3r5DEnFR3yFp1LfaUvVkyH +N2tzjoQvYWuDvCMUfLu3DDWlAjfGjcd1O7lmAawdr3K8EDR9CjzQsNjbr1SJCcyDXvT DINvKWPYyxRzZLX+BIqqZw0D4jACbRdIS4z+J1FF38ZX6sp/cpN76174M+UznNE7WQRu ptWOzoAG6pupnJr7Rs6PNrqf0QbJClgj8x8UB9fhNTauKd9unfaOSWCHp91/DeFGc3X2 nuSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028068; x=1691620068; 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=c2gywGlg3U3R0miq997BeVmgkx+5ZHsZAXz08FZ2lJw=; b=SE0ydmXeU0tUkm8HQZhl4o91JsYPnMv8ZdQiwuxPf9OSdkP+ixgeaNejB1efEVQf1m PnCuKhbrhMfcxk0kAO4nouybfeAFBsRXVZS4KffwQlrhnXE3PpBWRpht8o1ouN/qpypr n+jYpxARHQeYQG2n+UWKvgvPH9ezJri1Ta0G5opF2Yk3Jk74q3Ti2tJtHeSO01ffGauG tmQDtmzlmfY9+WKLrLFvpnsPDIXKd2LQSSjLMIezlrdxSoJx97MZIhlyeoUCjB3vgQSA IlGXCTP62XbY/0ecz+V26s0IMp7M3wmlUT8hgE8JcJ6Yk0i41LTzkC+pv6QYj2lM/fVo VwTw== X-Gm-Message-State: ABy/qLbzLec45rZDuwYUcdDubFHkCNYLq6+DXCrHTxT2USp/mYdIqKOz NodPjA1bQfAREltNCEy1zgZsG1gCl9+KucRAk92ztQ== X-Received: by 2002:a05:600c:228d:b0:3f9:82f:bad1 with SMTP id 13-20020a05600c228d00b003f9082fbad1mr12964818wmf.40.1689028067928; Mon, 10 Jul 2023 15:27:47 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id hn32-20020a05600ca3a000b003fbdd5d0758sm891030wmb.22.2023.07.10.15.27.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 17/44] target/mips/mxu: Add Q16ADD instruction Date: Tue, 11 Jul 2023 00:25:44 +0200 Message-Id: <20230710222611.50978-18-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction adds/subtracts four 16-bit packed in XRb and XRc. Placing packed 16-bit results in XRa and XRd. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-15-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 89 +++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 88d5d659c6..dc4fdf1dd9 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -366,6 +366,7 @@ enum { OPC_MXU_D16MACF = 0x0B, OPC_MXU_D16MADL = 0x0C, OPC_MXU_S16MAD = 0x0D, + OPC_MXU_Q16ADD = 0x0E, OPC_MXU_D16MACE = 0x0F, OPC_MXU__POOL04 = 0x10, OPC_MXU__POOL05 = 0x11, @@ -2161,6 +2162,91 @@ static void gen_mxu_Q8ADD(DisasContext *ctx) } } +/* + * Q16ADD XRa, XRb, XRc, XRd, aptn2, optn2 - Quad packed + * 16-bit pattern addition. + */ +static void gen_mxu_q16add(DisasContext *ctx) +{ + uint32_t aptn2, optn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + optn2 = extract32(ctx->opcode, 22, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + TCGv t5 = tcg_temp_new(); + + gen_load_mxu_gpr(t1, XRb); + tcg_gen_extract_tl(t0, t1, 0, 16); + tcg_gen_extract_tl(t1, t1, 16, 16); + + gen_load_mxu_gpr(t3, XRc); + tcg_gen_extract_tl(t2, t3, 0, 16); + tcg_gen_extract_tl(t3, t3, 16, 16); + + switch (optn2) { + case MXU_OPTN2_WW: /* XRB.H+XRC.H == lop, XRB.L+XRC.L == rop */ + tcg_gen_mov_tl(t4, t1); + tcg_gen_mov_tl(t5, t0); + break; + case MXU_OPTN2_LW: /* XRB.L+XRC.H == lop, XRB.L+XRC.L == rop */ + tcg_gen_mov_tl(t4, t0); + tcg_gen_mov_tl(t5, t0); + break; + case MXU_OPTN2_HW: /* XRB.H+XRC.H == lop, XRB.H+XRC.L == rop */ + tcg_gen_mov_tl(t4, t1); + tcg_gen_mov_tl(t5, t1); + break; + case MXU_OPTN2_XW: /* XRB.L+XRC.H == lop, XRB.H+XRC.L == rop */ + tcg_gen_mov_tl(t4, t0); + tcg_gen_mov_tl(t5, t1); + break; + } + + switch (aptn2) { + case MXU_APTN2_AA: /* lop +, rop + */ + tcg_gen_add_tl(t0, t4, t3); + tcg_gen_add_tl(t1, t5, t2); + tcg_gen_add_tl(t4, t4, t3); + tcg_gen_add_tl(t5, t5, t2); + break; + case MXU_APTN2_AS: /* lop +, rop + */ + tcg_gen_sub_tl(t0, t4, t3); + tcg_gen_sub_tl(t1, t5, t2); + tcg_gen_add_tl(t4, t4, t3); + tcg_gen_add_tl(t5, t5, t2); + break; + case MXU_APTN2_SA: /* lop +, rop + */ + tcg_gen_add_tl(t0, t4, t3); + tcg_gen_add_tl(t1, t5, t2); + tcg_gen_sub_tl(t4, t4, t3); + tcg_gen_sub_tl(t5, t5, t2); + break; + case MXU_APTN2_SS: /* lop +, rop + */ + tcg_gen_sub_tl(t0, t4, t3); + tcg_gen_sub_tl(t1, t5, t2); + tcg_gen_sub_tl(t4, t4, t3); + tcg_gen_sub_tl(t5, t5, t2); + break; + } + + tcg_gen_shli_tl(t0, t0, 16); + tcg_gen_extract_tl(t1, t1, 0, 16); + tcg_gen_shli_tl(t4, t4, 16); + tcg_gen_extract_tl(t5, t5, 0, 16); + + tcg_gen_or_tl(mxu_gpr[XRa - 1], t4, t5); + tcg_gen_or_tl(mxu_gpr[XRd - 1], t0, t1); +} + /* * MXU instruction category: Miscellaneous * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2906,6 +2992,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_S16MAD: gen_mxu_s16mad(ctx); break; + case OPC_MXU_Q16ADD: + gen_mxu_q16add(ctx); + break; case OPC_MXU_D16MACE: gen_mxu_d16mac(ctx, true, false); break; From patchwork Mon Jul 10 22:25:45 2023 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: 701061 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409066wrs; Mon, 10 Jul 2023 15:28:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlG02mAqEVa4i1+nFrJrOOazZjcXSL1A2NiNEnpcOgLfhAMQAtseEQZTIoS278ZkP/4dG7O+ X-Received: by 2002:a0c:b399:0:b0:634:e718:2fa5 with SMTP id t25-20020a0cb399000000b00634e7182fa5mr11925921qve.24.1689028090515; Mon, 10 Jul 2023 15:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028090; cv=none; d=google.com; s=arc-20160816; b=ntrD72vgrF3PObYadBL+ff+yxOHdbMPcRtqQSLrirp42VNDzjGz6JRug5LhrzqdauA CSeS7T3Ry/OG0X3bTz43U33jlwKOwII2U5Wo62ZeDIsKI6VhoH2+YSHIPN26E4a0p3mX KPmxuZNx3q24LkfbNUU2weB7Dh82TEkZvUrLKaXpPEg6voG9LcLO7mY2VvPAplc2Ko/g Q/o1vgP4Kya+5CLf1Ei5yT2z0lptoff+xj8hlgx0d08m8N7I+yKCiebDM3rqNds3a6di rUabvz62jybZr7fddXn5FS7qQDhUVB/Sx5IHWJAvTNH/mEqF3nqFD6eJvi5CpgX0mnpe qaIg== 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=AU1HvItk70vnhoMbywXGUhi8V0SZiSsR4Yq02rZeJz4=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=md//mCEdYEr2FbFThlmPRbwC8fPJTgyY3NEuju3OWCzx9kKX5JHHAxFXIzCGw+8xAH 2J+0s65+M3P+Hj7y0mN9moF7EjcHJxhVqEpO9mjMc5B18BPjcCdYpNsjIKeyFiUg/OP3 XOYgH8txZw0fl6AP5IqS6SYFAiGKLpJNaFb/Rzgh8uv1yJXB2uNzaX/lGStIIuuLau5Y 0lktVB7XPZk0PjDBuYVXZGtoPhzS36XqK3tq4+PLfvvWq8igWFwsWuA2cedvMqRETZ92 HbiJJNszZODhYJlqHNDs4kl643IDLLaCK6I0HYEre4ZasMAUcSXHwvLPMb8xILXVznr+ 4jvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=miqHtfuJ; 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 n8-20020a0c9d48000000b006366b687c87si231755qvf.559.2023.07.10.15.28.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:28:10 -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=miqHtfuJ; 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 1qIzMM-000617-3l; Mon, 10 Jul 2023 18:27:58 -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 1qIzMK-00060L-E5 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:56 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMI-0001re-Lz for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:27:56 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbef8ad9bbso56165155e9.0 for ; Mon, 10 Jul 2023 15:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028073; x=1691620073; 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=AU1HvItk70vnhoMbywXGUhi8V0SZiSsR4Yq02rZeJz4=; b=miqHtfuJfnxjGbyIA5VNBs86lwGZOxlsTUC2NUqDMcKOwp9TdhIPEWSQ7mfOznjjdc pe7dQ55GPwKxKntdKSeRRtPtqKB0QERyEstGAh+8gtElefCX3kNkNFd45N/VJyw/UxJ1 Q8S0uN7GXqsJXOEHYlsKgSv0Jkyfv1tOzZYeZb5mG+22SApaYv7TE4PEehGzJ4V6RVx3 TBj8nhcx3+4LC0qqNXX1UXoeKViCi3fL5XsxT+qlhJwSVYMoScUblO8ZaM3V74tRFURW GrwVQXgG0OabwBczQvOlYELxhBF6YtqYqOSfI5TAu/W4Q7ebdcAb38TDg27nln0S9e26 qVNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028073; x=1691620073; 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=AU1HvItk70vnhoMbywXGUhi8V0SZiSsR4Yq02rZeJz4=; b=AAVB23/UUiJldiCLxEM8SmBGNbb83Q3ohwa51/L6Mf0E9C20XEHZztV/8Ll2wOIJWJ 4gEWBt/LefPYzMrydKNKOcArHv3XPhqlwOLtzYDtpxvPSN6jVP4CnKHCNN+VNJhTLEfY umRlCp882fIkjd/enbKs3p8/uMQkvl9X+lWG3rznIjqc2lc02GHKjobIl9N3eDA2cR1X k1kKuS1u7wXzwaodDTn5IoaA54BZhFd7Tx4C5T/BZPLquW11Mr+YUo6lPZyRz4AyXvYT 37pJuR4ktkl7rb8wqC8J2OS5AXwMoHsEek07ZHslSC+MJNU9iYrS011EETXpvm/aYyyn Yc+A== X-Gm-Message-State: ABy/qLYim2YL1nKD7NEGIvhnCc+b6IDYpFsQn1uLB4eAp7fSib1wgP94 /pcUp6E0EJgwe/VoZ2wEr5NqIEJa7IWdpk8MrZBTnA== X-Received: by 2002:adf:f8c3:0:b0:314:3985:b291 with SMTP id f3-20020adff8c3000000b003143985b291mr14190930wrq.15.1689028073144; Mon, 10 Jul 2023 15:27:53 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id c14-20020adfed8e000000b0031411b7087dsm542729wro.20.2023.07.10.15.27.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 18/44] target/mips/mxu: Add D32ADD instruction Date: Tue, 11 Jul 2023 00:25:45 +0200 Message-Id: <20230710222611.50978-19-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction adds/subtracts two 32-bit values in XRb and XRc. Placing results in XRa and XRd and updates carry bits for each path in the MXU control register. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-16-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index dc4fdf1dd9..b133f9f11d 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -376,6 +376,7 @@ enum { OPC_MXU__POOL09 = 0x15, OPC_MXU__POOL10 = 0x16, OPC_MXU__POOL11 = 0x17, + OPC_MXU_D32ADD = 0x18, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, @@ -2247,6 +2248,66 @@ static void gen_mxu_q16add(DisasContext *ctx) tcg_gen_or_tl(mxu_gpr[XRd - 1], t0, t1); } +/* + * D32ADD XRa, XRb, XRc, XRd, aptn2 - Double + * 32 bit pattern addition/subtraction. + */ +static void gen_mxu_d32add(DisasContext *ctx) +{ + uint32_t aptn2, pad, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + pad = extract32(ctx->opcode, 22, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv carry = tcg_temp_new(); + TCGv cr = tcg_temp_new(); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0 && XRd == 0)) { + /* destinations are zero register -> do nothing */ + } else { + /* common case */ + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + gen_load_mxu_cr(cr); + if (XRa != 0) { + if (aptn2 & 2) { + tcg_gen_sub_i32(t2, t0, t1); + tcg_gen_setcond_tl(TCG_COND_GTU, carry, t0, t1); + } else { + tcg_gen_add_i32(t2, t0, t1); + tcg_gen_setcond_tl(TCG_COND_GTU, carry, t0, t2); + } + tcg_gen_andi_tl(cr, cr, 0x7fffffff); + tcg_gen_shli_tl(carry, carry, 31); + tcg_gen_or_tl(cr, cr, carry); + gen_store_mxu_gpr(t2, XRa); + } + if (XRd != 0) { + if (aptn2 & 1) { + tcg_gen_sub_i32(t2, t0, t1); + tcg_gen_setcond_tl(TCG_COND_GTU, carry, t0, t1); + } else { + tcg_gen_add_i32(t2, t0, t1); + tcg_gen_setcond_tl(TCG_COND_GTU, carry, t0, t2); + } + tcg_gen_andi_tl(cr, cr, 0xbfffffff); + tcg_gen_shli_tl(carry, carry, 30); + tcg_gen_or_tl(cr, cr, carry); + gen_store_mxu_gpr(t2, XRd); + } + gen_store_mxu_cr(cr); + } +} + /* * MXU instruction category: Miscellaneous * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3031,6 +3092,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL11: decode_opc_mxu__pool11(ctx); break; + case OPC_MXU_D32ADD: + gen_mxu_d32add(ctx); + break; case OPC_MXU_S8LDD: gen_mxu_s8ldd(ctx); break; From patchwork Mon Jul 10 22:25:46 2023 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: 701091 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411111wrs; Mon, 10 Jul 2023 15:33:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlEN9C/rPmfvAigzm2C1ZFb54wb8W3EI+6RJlLiCPaqnTTDOCaavCCVqnPE92sqbPIgB/UdM X-Received: by 2002:a05:620a:4050:b0:767:923:48e7 with SMTP id i16-20020a05620a405000b00767092348e7mr18063380qko.5.1689028401006; Mon, 10 Jul 2023 15:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028400; cv=none; d=google.com; s=arc-20160816; b=OqGLRiIYZG9Ocpau0zsLmPm45nJxzzRd+8aewR1CI7Rn4BR42rJ9eqAftXFpszqxxo aF+n0zNIKL7WQYM0iOOuflgf1wWm9Bj0Q1TeYCc+GcoyofzA9no5bggF/Ntl35kEADzE 9S1yhEfQJg3QKhzOYQVrhyEGdL5mNyKxWtAfhP73L7QNqMGeSwtp0SPAqZ5GCtDxq2Gz NQm9DwHxlm+YuFlTkLweDspIrYN4TbMhw1ufwKcsjYPUPye2z44ddKNzQ9+W0kR50jXv U9gSKBjB5lIDhR2/7FLLDptwCQBhRDFQhHwoKX+QHvlG2raK94Bu3JgyP2IXM6X193cl /I6Q== 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=ZdZ4gNf3XP6DiS9UM8yuMmk3g2CgY2vf17KOgAxSDJA=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=RObkOB524kp+LurXMviqZqYtQyStvQCSlA0tmJ3rBSK/tSXZ54TDeXwuFEU3FAKHWB xa4FaxH+JLCxeGXjRWdL3cDNb0aaCGzBHzJs6DwasG+4dh7KZzUNH8TUy8kR83BxA4BX obyY86iap7fi8O2ydtuDSooUlNtxtZatkatgNX13TVGrt4LeprVdyLvXZJBsNnBAgQTq GVIZAySB9FONsh5UfXpx/5a+iI+y+ZTOY7Hvll7UjVOV9LgjSgUFbU/pAqah381VNE3I soKSnCo5l3bGraqOzjHYSmxDzcrhz7DJ2jZrIoR9jejjiaa5LeRoiJmrUGJDuqEu75S7 zIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="q/NxL+0I"; 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 br31-20020a05620a461f00b007670458fa9esi267032qkb.385.2023.07.10.15.33.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:20 -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="q/NxL+0I"; 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 1qIzMQ-0006Ns-Oq; Mon, 10 Jul 2023 18:28:02 -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 1qIzMP-0006LK-Pw for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:01 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMN-0001sD-WC for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:01 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbef8ad9bbso56165815e9.0 for ; Mon, 10 Jul 2023 15:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028078; x=1691620078; 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=ZdZ4gNf3XP6DiS9UM8yuMmk3g2CgY2vf17KOgAxSDJA=; b=q/NxL+0ImGqujRHLBG4sLqeKUzonCBf98HOhp+nAaC8QAg2X/SsZFRrfUfczUa4uaZ rq0aD5sbqjXDc+hTAAfCHO2QaJDlcXvlbjm2ujYOKgbhqZQZiP4bigsY8wI+Je8XdHIV SIzGawf+bqYzaird60qDVA7VdkY8GgurdHS7FfKL3geXIcRpWYpBw1UHoeu9CbEKwHL3 YGAEWetnQgjxEkQzqMRXcIJ9H85obi7bDjW9Gy/cybJpLcObMMUPymZTsSngC6l/sN6X zMPAIoiBkH/b5nqRvpbaTN/HtCT1A3qLONbHuFul4aXy6B4izCg5R2QLzXLdhVfKH0Ru 6BFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028078; x=1691620078; 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=ZdZ4gNf3XP6DiS9UM8yuMmk3g2CgY2vf17KOgAxSDJA=; b=TZELiTW+kGE0A0HODilEkPZKYv3HXg3r0Z9iwEFBWiY2uzTDe/D/Z3ybqOhpzb/7Zt Aj94L74wy+RM1o6EmAKB4mMae5IB55c3Dx0EZIPTpEllbpk+/A820kFpFiJukc1N2a8z CV9y7TOfalMz8OO8nD8uFxoyxNhYE9rnpYHj0McxlQcXn7pRfKgzpBILcJHIrT2VbQhE GxqMaQnK5pbBLWTE38y9xrduQG3D2POEW6BV/PNd8p7OjrlfoQwvLW9qSE1rVZ8JOi8B 9cqi7SEBqGrt2c9kl7w62FpjrQRCdxBvWFjyA7PIMPXeQxewsTHhVohTO3B1ANnc8kzy zm6Q== X-Gm-Message-State: ABy/qLaJRr80XVgN8jMW1V68lDL5klv80wyPnTO34hhMJ/3bjeMFEASZ rBxBOb+/6NG+g9fTKYur0AGafMEM6fYDPBiTG0eN4Q== X-Received: by 2002:a5d:6590:0:b0:314:db7:d132 with SMTP id q16-20020a5d6590000000b003140db7d132mr14235563wru.61.1689028078368; Mon, 10 Jul 2023 15:27:58 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id j16-20020a5d4650000000b0031435c2600esm518482wrs.79.2023.07.10.15.27.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:27:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 19/44] target/mips/mxu: Add D32ACC D32ACCM D32ASUM instructions Date: Tue, 11 Jul 2023 00:25:46 +0200 Message-Id: <20230710222611.50978-20-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are all dual 32-bit addition/subtraction in various combinations. The instructions are grouped in pool12, see the opcode organization in the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-17-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 160 ++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index b133f9f11d..82a07040c6 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -377,6 +377,7 @@ enum { OPC_MXU__POOL10 = 0x16, OPC_MXU__POOL11 = 0x17, OPC_MXU_D32ADD = 0x18, + OPC_MXU__POOL12 = 0x19, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, @@ -439,6 +440,15 @@ enum { OPC_MXU_S32LDSTR = 0x01, }; +/* + * MXU pool 12 + */ +enum { + OPC_MXU_D32ACC = 0x00, + OPC_MXU_D32ACCM = 0x01, + OPC_MXU_D32ASUM = 0x02, +}; + /* * MXU pool 16 */ @@ -2308,6 +2318,132 @@ static void gen_mxu_d32add(DisasContext *ctx) } } +/* + * D32ACC XRa, XRb, XRc, XRd, aptn2 - Double + * 32 bit pattern addition/subtraction and accumulate. + */ +static void gen_mxu_d32acc(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + if (unlikely(XRa == 0 && XRd == 0)) { + /* destinations are zero register -> do nothing */ + } else { + /* common case */ + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + if (XRa != 0) { + if (aptn2 & 2) { + tcg_gen_sub_tl(t2, t0, t1); + } else { + tcg_gen_add_tl(t2, t0, t1); + } + tcg_gen_add_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t2); + } + if (XRd != 0) { + if (aptn2 & 1) { + tcg_gen_sub_tl(t2, t0, t1); + } else { + tcg_gen_add_tl(t2, t0, t1); + } + tcg_gen_add_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t2); + } + } +} + +/* + * D32ACCM XRa, XRb, XRc, XRd, aptn2 - Double + * 32 bit pattern addition/subtraction and accumulate. + */ +static void gen_mxu_d32accm(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + if (unlikely(XRa == 0 && XRd == 0)) { + /* destinations are zero register -> do nothing */ + } else { + /* common case */ + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + if (XRa != 0) { + tcg_gen_add_tl(t2, t0, t1); + if (aptn2 & 2) { + tcg_gen_sub_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t2); + } else { + tcg_gen_add_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t2); + } + } + if (XRd != 0) { + tcg_gen_sub_tl(t2, t0, t1); + if (aptn2 & 1) { + tcg_gen_sub_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t2); + } else { + tcg_gen_add_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t2); + } + } + } +} + +/* + * D32ASUM XRa, XRb, XRc, XRd, aptn2 - Double + * 32 bit pattern addition/subtraction. + */ +static void gen_mxu_d32asum(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + + if (unlikely(XRa == 0 && XRd == 0)) { + /* destinations are zero register -> do nothing */ + } else { + /* common case */ + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + if (XRa != 0) { + if (aptn2 & 2) { + tcg_gen_sub_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + } else { + tcg_gen_add_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + } + } + if (XRd != 0) { + if (aptn2 & 1) { + tcg_gen_sub_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t1); + } else { + tcg_gen_add_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t1); + } + } + } +} + /* * MXU instruction category: Miscellaneous * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2930,6 +3066,27 @@ static void decode_opc_mxu__pool11(DisasContext *ctx) } } +static void decode_opc_mxu__pool12(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 22, 2); + + switch (opcode) { + case OPC_MXU_D32ACC: + gen_mxu_d32acc(ctx); + break; + case OPC_MXU_D32ACCM: + gen_mxu_d32accm(ctx); + break; + case OPC_MXU_D32ASUM: + gen_mxu_d32asum(ctx); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool16(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 18, 3); @@ -3095,6 +3252,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_D32ADD: gen_mxu_d32add(ctx); break; + case OPC_MXU__POOL12: + decode_opc_mxu__pool12(ctx); + break; case OPC_MXU_S8LDD: gen_mxu_s8ldd(ctx); break; From patchwork Mon Jul 10 22:25:47 2023 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: 701080 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410385wrs; Mon, 10 Jul 2023 15:31:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEAbobQkiPl6F6KFtyvzga8I+oAHYkj9VTIjhBBqkfXI8JkFlmJb/FqvGGNGSS1NAwVEzE1 X-Received: by 2002:a05:620a:28cd:b0:767:28b5:b9f3 with SMTP id l13-20020a05620a28cd00b0076728b5b9f3mr16153215qkp.57.1689028285157; Mon, 10 Jul 2023 15:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028285; cv=none; d=google.com; s=arc-20160816; b=XXE/MzRENMiscy2K3VZ6h4CbbIvFQugEY73K8fJl5R3ZqnZfltkChfdEsGy4kdj5xj XAxT5EWny2BAYft8XQjV73uSrvxvJFlvm4JaHsKx7OG30UkJUjmi5QK1VoLZRNub9C3b 1dwgNBAkpkTmBhwRYFWaoqdHc+dRyPqSaj3ymq0uFaONd6pI91BH3mkMcwHTnQLixU/9 llgojw6pWP/9NiXwh3NgNv2dj81MxBkijwoKfkFJ007u5aIp9RxgFhP54WdiJupZbdGW ADwxaVl2njsUpki370nCmbTWioKw3cgvMfyYlYy8oMNItk9lZd6I7CJEfoIFjatzs7GN OzYQ== 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=a6rUXAteCDM3yinm9Mi50Z+IwG3Y1n6ccXie7HTooFg=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=R+6avQaoM5tlwBAxzZePxgmjxamLAeJHsdYL46strekJ1PSPcE81hRgTNPKML8auJl kAqFsNa7blQct7xQeKm9fPWeSYr1zCQO/wSh/ZwDcsrBh6o3L82XQdeXym+n6pL/rNBt dIFoHkrm4Kb2BE6fbF077Rs1n4r44ZKQzys5tJ7APwZNIx2MZjkUiIDbxJMfzFVARbZf izs8lFPwXooBjnZcEUy3wSWgV3CO974bSCq152HFrZBOGxrR6D2FJt3vLDqh1iRcx/xc 0R6T5nILgw6kq1g9uUy3iv4kVC3thvyDg43KZGwWxlJ1teKGXWYdlVufn1B5cEYRbN8u enkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qbg4oqPO; 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 bi33-20020a05620a31a100b007654c4689bfsi270191qkb.300.2023.07.10.15.31.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:25 -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=Qbg4oqPO; 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 1qIzMV-0006Rn-Tc; Mon, 10 Jul 2023 18:28:07 -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 1qIzMV-0006RR-3y for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:07 -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 1qIzMT-0001su-G6 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:06 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3144098df56so5809438f8f.2 for ; Mon, 10 Jul 2023 15:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028083; x=1691620083; 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=a6rUXAteCDM3yinm9Mi50Z+IwG3Y1n6ccXie7HTooFg=; b=Qbg4oqPO5DCRLWRHRhTtaLiC5LSwgTcJvsii+pIWTDNvQY95wFBs8d1zr0rPkZv4hH xhQwEMhIICvZp+sINqYF/NIOm+/cB7xsRe7oJK14euQ4008ecm0mYZ2dJi049BacYy2F 35izpecOxgyhbphh++yw9HaMqbmraRNop6mJwROvmaCM4Wq9BqbS6Z5AXt0EjQwfu4yj 9fs2MewHjgFhM71Gi5cb0zPiF/2KMWZ8g3k9vueS/Skxkn1yd1rvHMuCMVpXYapEfWYQ zv21nJliXaKTfcSvSAAWSs3xeDV2Ck+VI1x5M+tCxHt8igANyoNkZ7SspQ/3xBWBR6Lv FRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028083; x=1691620083; 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=a6rUXAteCDM3yinm9Mi50Z+IwG3Y1n6ccXie7HTooFg=; b=WxZs89Cy6JN9fh73E4u6fYdJB6xS32w4ptwrM0mruIatQwRNKGJ+twonW5iebn7RrR pGfN/53ChpBnXE894YUTwX83Ke5Eg1jVHdhfeO8ImlnTADPUmpv5YQyodfELrXf4O/tu +LrewOp5lJYwlnHIpLs/lR4y8n8l5SFhcuKY/Z+ZAUdksjgDu76g6SyHc62Gli9PFJvV EfeziX+kLqg3EBGaRUKml9M8dVkEz607i7oL3PnR0MPGAjAn92DBCWptkE5ZDNs3bX7n 7zZEDFKUlsS1nirS8BViicR0QZK0tPUjYRfxDZDbSMGK7AuVFLKoZ56Qd+d07vDTMCLO 4obw== X-Gm-Message-State: ABy/qLa5cFqeZzAGO3QCqslSVh3esOru5LBm3zCC+50dhOieODigdiMz RyUqMlvpm3mpLWm2OnkaKEObo+V8jXEVkYeiwi/+6w== X-Received: by 2002:adf:df90:0:b0:314:9189:ce17 with SMTP id z16-20020adfdf90000000b003149189ce17mr10126533wrl.48.1689028083565; Mon, 10 Jul 2023 15:28:03 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id f14-20020adfe90e000000b0030647449730sm523187wrm.74.2023.07.10.15.28.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 20/44] target/mips/mxu: Add D32ADDC instruction Date: Tue, 11 Jul 2023 00:25:47 +0200 Message-Id: <20230710222611.50978-21-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction adds two 32-bit values with respect to corresponding carry flags in MXU_CR. XRa += XRb + LeftCarry flag; XRd += XRc + RightCarry flag; Suddenly, it doesn't modify carry flags as a result of addition. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-18-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 39 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 82a07040c6..84e8f760e4 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -268,7 +268,7 @@ * │ 13..10 * ├─ 010111 ─ OPC_MXU__POOL11 ─┬─ 0000 ─ OPC_MXU_S32SDIV * │ └─ 0001 ─ OPC_MXU_S32SDIVR - * ├─ 011000 ─ OPC_MXU_D32ADD + * ├─ 011000 ─ OPC_MXU_D32ADD (catches D32ADDC too) * │ 23..22 * MXU ├─ 011001 ─ OPC_MXU__POOL12 ─┬─ 00 ─ OPC_MXU_D32ACC * opcodes ─┤ ├─ 01 ─ OPC_MXU_D32ACCM @@ -2260,14 +2260,17 @@ static void gen_mxu_q16add(DisasContext *ctx) /* * D32ADD XRa, XRb, XRc, XRd, aptn2 - Double - * 32 bit pattern addition/subtraction. + * 32 bit pattern addition/subtraction, set carry. + * + * D32ADDC XRa, XRb, XRc, XRd, aptn2 - Double + * 32 bit pattern addition/subtraction with carry. */ static void gen_mxu_d32add(DisasContext *ctx) { - uint32_t aptn2, pad, XRc, XRb, XRa, XRd; + uint32_t aptn2, addc, XRc, XRb, XRa, XRd; aptn2 = extract32(ctx->opcode, 24, 2); - pad = extract32(ctx->opcode, 22, 2); + addc = extract32(ctx->opcode, 22, 2); XRd = extract32(ctx->opcode, 18, 4); XRc = extract32(ctx->opcode, 14, 4); XRb = extract32(ctx->opcode, 10, 4); @@ -2276,15 +2279,37 @@ static void gen_mxu_d32add(DisasContext *ctx) TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); - TCGv carry = tcg_temp_new(); TCGv cr = tcg_temp_new(); - if (unlikely(pad != 0)) { - /* opcode padding incorrect -> do nothing */ + if (unlikely(addc > 1)) { + /* opcode incorrect -> do nothing */ + } else if (addc == 1) { + if (unlikely(XRa == 0 && XRd == 0)) { + /* destinations are zero register -> do nothing */ + } else { + /* FIXME ??? What if XRa == XRd ??? */ + /* aptn2 is unused here */ + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + gen_load_mxu_cr(cr); + if (XRa != 0) { + tcg_gen_extract_tl(t2, cr, 31, 1); + tcg_gen_add_tl(t0, t0, t2); + tcg_gen_add_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + } + if (XRd != 0) { + tcg_gen_extract_tl(t2, cr, 30, 1); + tcg_gen_add_tl(t1, t1, t2); + tcg_gen_add_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t1); + } + } } else if (unlikely(XRa == 0 && XRd == 0)) { /* destinations are zero register -> do nothing */ } else { /* common case */ + /* FIXME ??? What if XRa == XRd ??? */ + TCGv carry = tcg_temp_new(); + gen_load_mxu_gpr(t0, XRb); gen_load_mxu_gpr(t1, XRc); gen_load_mxu_cr(cr); From patchwork Mon Jul 10 22:25:48 2023 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: 701085 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410629wrs; Mon, 10 Jul 2023 15:32:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEiqQVhWFyhRRvjST3YlOar173nnsdL/V+ichuetNMQfcoHe558tQjnE/tAh3m4Cu8Zwhgn X-Received: by 2002:a05:622a:10b:b0:400:aa4d:7a5d with SMTP id u11-20020a05622a010b00b00400aa4d7a5dmr17948117qtw.24.1689028329149; Mon, 10 Jul 2023 15:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028329; cv=none; d=google.com; s=arc-20160816; b=YLYqWs6IvFr5Onf3lQa+wlA5wfBdMdRj0Iv6CvV9dHIYsCaI8GDuLaaRGvnfavB645 cJDxvsuRd4VnilVU4w5F/iMYmNiaY1WK0M39DAEBj021n8S0l6UvkFt8Ezt4Plcc/pHQ LxcvAfXJpFa3WSC4Uv05tymeMNson3WoYzcbHSVMpd2LLHcMmNiPheuyMrzjILmSKV6d FlqNE3Mc7fOyWrCDViJJsJ0kiwMAyCLVrbEI6tRLIH4LcVtaS3klYqinPfWmL4N6RfBH tvjwwOuCPe+cBWJ3xyqx/NVTMS73EkFN6hNeGzO0oiCRMAVuoWJLJymCadu2B4TuXUSF Zl+w== 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=+mmAezQBBJcxFsMt/6yHPGp2uS2b1jkU7KB0S8apiWQ=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=Hznpbcceqb5GVPQqmu+9HqcGDv7MSxf/kn+ge0HD77HobTM8laKgEhI/+Ms/Y2KtKh rN5dUJYiTpEvaz4teoO2unzcCCWT3Qg8uCRpdCI+n8Ck+/qO5Zae/Ja8vb4GveJ2r/5T l1zwSHvbCLwHa2c3JsBYHf2HdY7X6M2VTHgb73DT/l5IHbBD4nJZHaBW7pF7H9Pp9N4x UaegEYC7um/n5qKMEwxz5h7Er9qU9+7Bu2xLf302gml1RVLPWElq/CyLpXmL0oyGzwg3 t16U56meko4TwntqGP1ssqaw8aD18HL3sXg7mkSzN2V7qNYZvwU1fU4WR+FdkuqxMAw8 Cd/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XVZIfaC5; 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 c19-20020a05622a025300b0040359cb66c0si305938qtx.414.2023.07.10.15.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:32:09 -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=XVZIfaC5; 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 1qIzMo-00084K-4R; Mon, 10 Jul 2023 18:28:26 -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 1qIzMm-0007wX-7Z for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:24 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMY-0001tf-3p for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:23 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-314172bac25so4941090f8f.3 for ; Mon, 10 Jul 2023 15:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028088; x=1691620088; 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=+mmAezQBBJcxFsMt/6yHPGp2uS2b1jkU7KB0S8apiWQ=; b=XVZIfaC5xL+XKg9XrX6pDBjlYz+NeNExNs7/9KXj+R18wPP0VFsuiwRjM9YO4kCrrq POrBIy3+HIitAQMHqSnQ9sHRKKONLodTGKH3MIocivROInycMgSLUXTvqcNTxUVH/QQ+ OxYyRMkOex5K5yfFyEtRRwojE9f73Xa16ulxKwYaU9SShODTD3Y4Ps5JiM9nIYv8NkF4 ZekDo2sa0LMBEVU5e+hvJh/7ZTE617VxdRnBNRuewZj1Gk6d9fHEIsFPQrpLpO67/8dI SDBq/nk0TAMGRDRHjqxuyOusam6D/fQGWS3lwR/ctL8xeGYurG7pYZYvla071ENZB9ev Sd4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028088; x=1691620088; 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=+mmAezQBBJcxFsMt/6yHPGp2uS2b1jkU7KB0S8apiWQ=; b=YG+692BOV6H90ZzqRhHlSab+AdIVvbKtflC/GYFy7Ggv1uUftTzXrFlsrOgNqlI22p D5fIS9kIYuH7TSUIjE8Qvchkxv/O/PTi3OH5Gu76kAtlN1dvRNUivJiL8nPgQN6CEk4g sB49+zbxPQj37uaPxDESP4AqeWs2TexUETFm+WpcD7X8vqXe3pRPdHfVVJXcIXlum5A7 gN1xjbBmYA5218z0uC2SeapMlzKK3Rlz1UkrsjL/kD602nQq8V0DtbhwQIsltg1RfyAg ZMU1GehiUGxIlV8mgs5VrtH4YXQy2JuJ0JyfRRjm6bx6JhidRjeh8bi6VCYLvxFGUVSd 8mzA== X-Gm-Message-State: ABy/qLaxhp+lCRWBsLxOtRTpO8udY4rT1a3WAvmTZtC3OHDtWRZD0t5T orRJG1GNJ72AEOItb2ZWPnL6oUITLlbyozVIIjQViA== X-Received: by 2002:adf:f94c:0:b0:314:de6:3200 with SMTP id q12-20020adff94c000000b003140de63200mr11380234wrr.41.1689028088532; Mon, 10 Jul 2023 15:28:08 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id n8-20020a5d6b88000000b003141e9e2f81sm559235wrx.4.2023.07.10.15.28.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 21/44] target/mips/mxu: Add Q16ACC Q16ACCM D16ASUM instructions Date: Tue, 11 Jul 2023 00:25:48 +0200 Message-Id: <20230710222611.50978-22-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are all dual 16-bit addition/subtraction in various combinations. The instructions are grouped in pool13, see the opcode organization in the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-19-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 228 +++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 84e8f760e4..18188208b7 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -277,7 +277,7 @@ * │ 23..22 * ├─ 011011 ─ OPC_MXU__POOL13 ─┬─ 00 ─ OPC_MXU_Q16ACC * │ ├─ 01 ─ OPC_MXU_Q16ACCM - * │ └─ 10 ─ OPC_MXU_Q16ASUM + * │ └─ 10 ─ OPC_MXU_D16ASUM * │ * │ 23..22 * ├─ 011100 ─ OPC_MXU__POOL14 ─┬─ 00 ─ OPC_MXU_Q8ADDE @@ -378,6 +378,7 @@ enum { OPC_MXU__POOL11 = 0x17, OPC_MXU_D32ADD = 0x18, OPC_MXU__POOL12 = 0x19, + OPC_MXU__POOL13 = 0x1B, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, @@ -449,6 +450,15 @@ enum { OPC_MXU_D32ASUM = 0x02, }; +/* + * MXU pool 13 + */ +enum { + OPC_MXU_Q16ACC = 0x00, + OPC_MXU_Q16ACCM = 0x01, + OPC_MXU_D16ASUM = 0x02, +}; + /* * MXU pool 16 */ @@ -2258,6 +2268,198 @@ static void gen_mxu_q16add(DisasContext *ctx) tcg_gen_or_tl(mxu_gpr[XRd - 1], t0, t1); } +/* + * Q16ACC XRa, XRb, XRc, XRd, aptn2 - Quad packed + * 16-bit addition/subtraction with accumulate. + */ +static void gen_mxu_q16acc(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv s3 = tcg_temp_new(); + TCGv s2 = tcg_temp_new(); + TCGv s1 = tcg_temp_new(); + TCGv s0 = tcg_temp_new(); + + gen_load_mxu_gpr(t1, XRb); + tcg_gen_extract_tl(t0, t1, 0, 16); + tcg_gen_extract_tl(t1, t1, 16, 16); + + gen_load_mxu_gpr(t3, XRc); + tcg_gen_extract_tl(t2, t3, 0, 16); + tcg_gen_extract_tl(t3, t3, 16, 16); + + switch (aptn2) { + case MXU_APTN2_AA: /* lop +, rop + */ + tcg_gen_add_tl(s3, t1, t3); + tcg_gen_add_tl(s2, t0, t2); + tcg_gen_add_tl(s1, t1, t3); + tcg_gen_add_tl(s0, t0, t2); + break; + case MXU_APTN2_AS: /* lop +, rop - */ + tcg_gen_sub_tl(s3, t1, t3); + tcg_gen_sub_tl(s2, t0, t2); + tcg_gen_add_tl(s1, t1, t3); + tcg_gen_add_tl(s0, t0, t2); + break; + case MXU_APTN2_SA: /* lop -, rop + */ + tcg_gen_add_tl(s3, t1, t3); + tcg_gen_add_tl(s2, t0, t2); + tcg_gen_sub_tl(s1, t1, t3); + tcg_gen_sub_tl(s0, t0, t2); + break; + case MXU_APTN2_SS: /* lop -, rop - */ + tcg_gen_sub_tl(s3, t1, t3); + tcg_gen_sub_tl(s2, t0, t2); + tcg_gen_sub_tl(s1, t1, t3); + tcg_gen_sub_tl(s0, t0, t2); + break; + } + + if (XRa != 0) { + tcg_gen_add_tl(t0, mxu_gpr[XRa - 1], s0); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_extract_tl(t1, mxu_gpr[XRa - 1], 16, 16); + tcg_gen_add_tl(t1, t1, s1); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(mxu_gpr[XRa - 1], t1, t0); + } + + if (XRd != 0) { + tcg_gen_add_tl(t0, mxu_gpr[XRd - 1], s2); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_extract_tl(t1, mxu_gpr[XRd - 1], 16, 16); + tcg_gen_add_tl(t1, t1, s3); + tcg_gen_shli_tl(t1, t1, 16); + tcg_gen_or_tl(mxu_gpr[XRd - 1], t1, t0); + } +} + +/* + * Q16ACCM XRa, XRb, XRc, XRd, aptn2 - Quad packed + * 16-bit accumulate. + */ +static void gen_mxu_q16accm(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + + gen_load_mxu_gpr(t2, XRb); + gen_load_mxu_gpr(t3, XRc); + + if (XRa != 0) { + TCGv a0 = tcg_temp_new(); + TCGv a1 = tcg_temp_new(); + + tcg_gen_extract_tl(t0, t2, 0, 16); + tcg_gen_extract_tl(t1, t2, 16, 16); + + gen_load_mxu_gpr(a1, XRa); + tcg_gen_extract_tl(a0, a1, 0, 16); + tcg_gen_extract_tl(a1, a1, 16, 16); + + if (aptn2 & 2) { + tcg_gen_sub_tl(a0, a0, t0); + tcg_gen_sub_tl(a1, a1, t1); + } else { + tcg_gen_add_tl(a0, a0, t0); + tcg_gen_add_tl(a1, a1, t1); + } + tcg_gen_extract_tl(a0, a0, 0, 16); + tcg_gen_shli_tl(a1, a1, 16); + tcg_gen_or_tl(mxu_gpr[XRa - 1], a1, a0); + } + + if (XRd != 0) { + TCGv a0 = tcg_temp_new(); + TCGv a1 = tcg_temp_new(); + + tcg_gen_extract_tl(t0, t3, 0, 16); + tcg_gen_extract_tl(t1, t3, 16, 16); + + gen_load_mxu_gpr(a1, XRd); + tcg_gen_extract_tl(a0, a1, 0, 16); + tcg_gen_extract_tl(a1, a1, 16, 16); + + if (aptn2 & 1) { + tcg_gen_sub_tl(a0, a0, t0); + tcg_gen_sub_tl(a1, a1, t1); + } else { + tcg_gen_add_tl(a0, a0, t0); + tcg_gen_add_tl(a1, a1, t1); + } + tcg_gen_extract_tl(a0, a0, 0, 16); + tcg_gen_shli_tl(a1, a1, 16); + tcg_gen_or_tl(mxu_gpr[XRd - 1], a1, a0); + } +} + + +/* + * D16ASUM XRa, XRb, XRc, XRd, aptn2 - Double packed + * 16-bit sign extended addition and accumulate. + */ +static void gen_mxu_d16asum(DisasContext *ctx) +{ + uint32_t aptn2, XRc, XRb, XRa, XRd; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + + gen_load_mxu_gpr(t2, XRb); + gen_load_mxu_gpr(t3, XRc); + + if (XRa != 0) { + tcg_gen_sextract_tl(t0, t2, 0, 16); + tcg_gen_sextract_tl(t1, t2, 16, 16); + tcg_gen_add_tl(t0, t0, t1); + if (aptn2 & 2) { + tcg_gen_sub_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + } else { + tcg_gen_add_tl(mxu_gpr[XRa - 1], mxu_gpr[XRa - 1], t0); + } + } + + if (XRd != 0) { + tcg_gen_sextract_tl(t0, t3, 0, 16); + tcg_gen_sextract_tl(t1, t3, 16, 16); + tcg_gen_add_tl(t0, t0, t1); + if (aptn2 & 1) { + tcg_gen_sub_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t0); + } else { + tcg_gen_add_tl(mxu_gpr[XRd - 1], mxu_gpr[XRd - 1], t0); + } + } +} + /* * D32ADD XRa, XRb, XRc, XRd, aptn2 - Double * 32 bit pattern addition/subtraction, set carry. @@ -3112,6 +3314,27 @@ static void decode_opc_mxu__pool12(DisasContext *ctx) } } +static void decode_opc_mxu__pool13(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 22, 2); + + switch (opcode) { + case OPC_MXU_Q16ACC: + gen_mxu_q16acc(ctx); + break; + case OPC_MXU_Q16ACCM: + gen_mxu_q16accm(ctx); + break; + case OPC_MXU_D16ASUM: + gen_mxu_d16asum(ctx); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool16(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 18, 3); @@ -3280,6 +3503,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL12: decode_opc_mxu__pool12(ctx); break; + case OPC_MXU__POOL13: + decode_opc_mxu__pool13(ctx); + break; case OPC_MXU_S8LDD: gen_mxu_s8ldd(ctx); break; From patchwork Mon Jul 10 22:25:49 2023 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: 701077 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410333wrs; Mon, 10 Jul 2023 15:31:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDiktYsN8e0ewlsoG5lEH3OFLULL/AI1dX102YMjfG1DbiGIVV0t7xeg6C6dtkK9RPMIkR X-Received: by 2002:ac8:4e94:0:b0:400:e685:d18e with SMTP id 20-20020ac84e94000000b00400e685d18emr19037479qtp.18.1689028277464; Mon, 10 Jul 2023 15:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028277; cv=none; d=google.com; s=arc-20160816; b=ie6RCZvMreQzLK3fdBRoB/PSahOZMACAduGgvK8tkgVHS6CSlK0gZtlK+c27xNf3sz BOrS2u2JwSO1WSeAVzsnUq406Cm4WBWtiUSZ/VOW3zVM8CpFnGcAjscVYm5L/iIiVbGv SB0u4mX6oA19ycQGau1eFEdBYB1cjLzW3mVnVRBEr8GqzzFiCSVTdH9GqrkEG3K5M2V4 NXeDSYCSOiz6JppRRMThDo3qOatkjsp9hpdSqybVzaqR6lSQm6nPeS0+f1AZuRqicfvN SwrYh/2NWEYIIPsTmkCrLR0CDspRTi1UuRdfwokEuQhrE3dFyqEDAfV+0tMc24NztFgu Sr1Q== 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=qrKWorx2W+9ITDLrESbxcQflFKH3wr3nKlJX3FtN6Gw=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=ug1Abx/QamkczWWMcYUl2hXXzb3k7GZ/5s4E0rZKvNfmd2QK6XeOhwXf8Vky/eeuzX UUCp3/V7lCy1ySg9RnuVIMeYVFjhmokqeFRvS6pxjMe4WJE5blcT6CLTAOE8N+zVU/js sylFlEsypXFSdxmKAS19JbakmVyVvzeILKOyGflfVoDmlXI/edCEvIpA0gblzkzT5yJ9 NMkSzKG0SRu9ixw+OjVLatLjTknLK6icP/3vPYuYNpnFyNeuXfBouo1Dxh149octgKXu ByTAlenucRrDV4vk2e13BW2VrLMpTca27KhGDdXGPVSUyoyKXykdfLAJ9Rbw6qWBevwX Jc2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pw1hyuLi; 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 n10-20020ac85a0a000000b00403b1e68f33si328349qta.169.2023.07.10.15.31.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:17 -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=Pw1hyuLi; 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 1qIzMh-0007dA-1C; Mon, 10 Jul 2023 18:28:19 -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 1qIzMf-0007LR-As for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:17 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMd-0001va-AH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:17 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so56012065e9.3 for ; Mon, 10 Jul 2023 15:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028093; x=1691620093; 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=qrKWorx2W+9ITDLrESbxcQflFKH3wr3nKlJX3FtN6Gw=; b=Pw1hyuLiT4qLkwa28njNl+Brv81uWAg7KV6zzEMZmu4mj2KM9fru9vyq/9/Qe0Cf4A t0AzH5Sow4vVINlL5EG/PsTyn/pvKMp6Y1rWc/e/sYoIMTnw5989OVawxA7ut/TGOP1I e9Z5QszGLibV1fGO20UegaXPufXSDxUkc4MDfIfgaICjWa7hBpCDMy8MNwgzE+Tejf3d vraglAkLiJOlg3ID1JU9LE9rw0mEYqKdi1DXq86+iyKV06it+rBTOktdD8R6eDTtsppd oko4EJeXpuW1rqAi9vkwl6Ly0pYHwEG71Fth/klKrFpay5NTlF+p9KByL3+xlp8/F2xf cSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028093; x=1691620093; 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=qrKWorx2W+9ITDLrESbxcQflFKH3wr3nKlJX3FtN6Gw=; b=XCsBsa41YrE7H55wkDVDwb2/oerDEK1hSfgKSR+HiJgBCBlbpweiP7VZgkF+yOgvT5 V3fqUG1wL6tK4NzsSNBm7qL2uxUg/nrBKuih28UU9Hn3FZIiSEX8Db8hzmpoKtn4h8qI s63KZ/1zNsNkwKPsQki3audhrKz57gnVjw1Wm41rkfuBjpjDkWegUlu47XJzJFOisMpO gAkLcRylvL9CLLY7ySy6mic8xtXASwPhkAKnM5/Y7Dq57n0jLw71k6oxRrASyjfi1fPw rpyVw63/ea9Zumfcsckm1WmdUEZiqzxLRHoyNvkuh/XJOx7xIuCCDqPr8lpgqO24TMjq alYg== X-Gm-Message-State: ABy/qLa7UBuZ2xuTNvqZdwCEZ9Itb4KIk5Qd12Fe55HIVBgQxzs89SOg FSt4zzSyEB60SmH8Pyx+a84BoqlAjz/AyidihNMdYg== X-Received: by 2002:a5d:6092:0:b0:314:3994:cd98 with SMTP id w18-20020a5d6092000000b003143994cd98mr13519424wrt.62.1689028093682; Mon, 10 Jul 2023 15:28:13 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id a23-20020a5d4577000000b0030ae53550f5sm530260wrc.51.2023.07.10.15.28.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 22/44] target/mips/mxu: Add Q8ADDE Q8ACCE D8SUM D8SUMC instructions Date: Tue, 11 Jul 2023 00:25:49 +0200 Message-Id: <20230710222611.50978-23-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are all dual 8-bit addition/subtraction in various combinations. Most instructions are grouped in pool14, see the opcode organization in the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-20-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 200 ++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 18188208b7..5556fd152d 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -379,6 +379,8 @@ enum { OPC_MXU_D32ADD = 0x18, OPC_MXU__POOL12 = 0x19, OPC_MXU__POOL13 = 0x1B, + OPC_MXU__POOL14 = 0x1C, + OPC_MXU_Q8ACCE = 0x1D, OPC_MXU_S8LDD = 0x22, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, @@ -459,6 +461,15 @@ enum { OPC_MXU_D16ASUM = 0x02, }; +/* + * MXU pool 14 + */ +enum { + OPC_MXU_Q8ADDE = 0x00, + OPC_MXU_D8SUM = 0x01, + OPC_MXU_D8SUMC = 0x02, +}; + /* * MXU pool 16 */ @@ -2183,6 +2194,168 @@ static void gen_mxu_Q8ADD(DisasContext *ctx) } } +/* + * Q8ADDE XRa, XRb, XRc, XRd, aptn2 + * Add/subtract quadruple of 8-bit packed in XRb + * to another one in XRc, with zero extending + * to 16-bit and put results as packed 16-bit data + * into XRa and XRd. + * aptn2 manages action add or subract of pairs of data. + * + * Q8ACCE XRa, XRb, XRc, XRd, aptn2 + * Add/subtract quadruple of 8-bit packed in XRb + * to another one in XRc, with zero extending + * to 16-bit and accumulate results as packed 16-bit data + * into XRa and XRd. + * aptn2 manages action add or subract of pairs of data. + */ +static void gen_mxu_q8adde(DisasContext *ctx, bool accumulate) +{ + uint32_t aptn2, XRd, XRc, XRb, XRa; + + aptn2 = extract32(ctx->opcode, 24, 2); + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + if (XRa != 0) { + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } + if (XRd != 0) { + tcg_gen_movi_tl(mxu_gpr[XRd - 1], 0); + } + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + TCGv t5 = tcg_temp_new(); + + if (XRa != 0) { + tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 16, 8); + tcg_gen_extract_tl(t1, mxu_gpr[XRc - 1], 16, 8); + tcg_gen_extract_tl(t2, mxu_gpr[XRb - 1], 24, 8); + tcg_gen_extract_tl(t3, mxu_gpr[XRc - 1], 24, 8); + if (aptn2 & 2) { + tcg_gen_sub_tl(t0, t0, t1); + tcg_gen_sub_tl(t2, t2, t3); + } else { + tcg_gen_add_tl(t0, t0, t1); + tcg_gen_add_tl(t2, t2, t3); + } + if (accumulate) { + gen_load_mxu_gpr(t5, XRa); + tcg_gen_extract_tl(t1, t5, 0, 16); + tcg_gen_extract_tl(t3, t5, 16, 16); + tcg_gen_add_tl(t0, t0, t1); + tcg_gen_add_tl(t2, t2, t3); + } + tcg_gen_shli_tl(t2, t2, 16); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_or_tl(t4, t2, t0); + } + if (XRd != 0) { + tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 0, 8); + tcg_gen_extract_tl(t1, mxu_gpr[XRc - 1], 0, 8); + tcg_gen_extract_tl(t2, mxu_gpr[XRb - 1], 8, 8); + tcg_gen_extract_tl(t3, mxu_gpr[XRc - 1], 8, 8); + if (aptn2 & 1) { + tcg_gen_sub_tl(t0, t0, t1); + tcg_gen_sub_tl(t2, t2, t3); + } else { + tcg_gen_add_tl(t0, t0, t1); + tcg_gen_add_tl(t2, t2, t3); + } + if (accumulate) { + gen_load_mxu_gpr(t5, XRd); + tcg_gen_extract_tl(t1, t5, 0, 16); + tcg_gen_extract_tl(t3, t5, 16, 16); + tcg_gen_add_tl(t0, t0, t1); + tcg_gen_add_tl(t2, t2, t3); + } + tcg_gen_shli_tl(t2, t2, 16); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_or_tl(t5, t2, t0); + } + + gen_store_mxu_gpr(t4, XRa); + gen_store_mxu_gpr(t5, XRd); + } +} + +/* + * D8SUM XRa, XRb, XRc + * Double parallel add of quadruple unsigned 8-bit together + * with zero extending to 16-bit data. + * D8SUMC XRa, XRb, XRc + * Double parallel add of quadruple unsigned 8-bit together + * with zero extending to 16-bit data and adding 2 to each + * parallel result. + */ +static void gen_mxu_d8sum(DisasContext *ctx, bool sumc) +{ + uint32_t pad, pad2, XRc, XRb, XRa; + + pad = extract32(ctx->opcode, 24, 2); + pad2 = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(pad != 0 || pad2 != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to zero */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + TCGv t5 = tcg_temp_new(); + + if (XRb != 0) { + tcg_gen_extract_tl(t0, mxu_gpr[XRb - 1], 0, 8); + tcg_gen_extract_tl(t1, mxu_gpr[XRb - 1], 8, 8); + tcg_gen_extract_tl(t2, mxu_gpr[XRb - 1], 16, 8); + tcg_gen_extract_tl(t3, mxu_gpr[XRb - 1], 24, 8); + tcg_gen_add_tl(t4, t0, t1); + tcg_gen_add_tl(t4, t4, t2); + tcg_gen_add_tl(t4, t4, t3); + } else { + tcg_gen_mov_tl(t4, 0); + } + if (XRc != 0) { + tcg_gen_extract_tl(t0, mxu_gpr[XRc - 1], 0, 8); + tcg_gen_extract_tl(t1, mxu_gpr[XRc - 1], 8, 8); + tcg_gen_extract_tl(t2, mxu_gpr[XRc - 1], 16, 8); + tcg_gen_extract_tl(t3, mxu_gpr[XRc - 1], 24, 8); + tcg_gen_add_tl(t5, t0, t1); + tcg_gen_add_tl(t5, t5, t2); + tcg_gen_add_tl(t5, t5, t3); + } else { + tcg_gen_mov_tl(t5, 0); + } + + if (sumc) { + tcg_gen_addi_tl(t4, t4, 2); + tcg_gen_addi_tl(t5, t5, 2); + } + tcg_gen_shli_tl(t4, t4, 16); + + tcg_gen_or_tl(mxu_gpr[XRa - 1], t4, t5); + } +} + /* * Q16ADD XRa, XRb, XRc, XRd, aptn2, optn2 - Quad packed * 16-bit pattern addition. @@ -3335,6 +3508,27 @@ static void decode_opc_mxu__pool13(DisasContext *ctx) } } +static void decode_opc_mxu__pool14(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 22, 2); + + switch (opcode) { + case OPC_MXU_Q8ADDE: + gen_mxu_q8adde(ctx, false); + break; + case OPC_MXU_D8SUM: + gen_mxu_d8sum(ctx, false); + break; + case OPC_MXU_D8SUMC: + gen_mxu_d8sum(ctx, true); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool16(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 18, 3); @@ -3506,6 +3700,12 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL13: decode_opc_mxu__pool13(ctx); break; + case OPC_MXU__POOL14: + decode_opc_mxu__pool14(ctx); + break; + case OPC_MXU_Q8ACCE: + gen_mxu_q8adde(ctx, true); + break; case OPC_MXU_S8LDD: gen_mxu_s8ldd(ctx); break; From patchwork Mon Jul 10 22:25:50 2023 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: 701073 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410239wrs; Mon, 10 Jul 2023 15:31:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTEmkas7QNuX/xkaXBP/L11Jndvu7NKihpqCjwJhHqGvWaWNoQUbn4IkW7EPtbtyBHLA8i X-Received: by 2002:a67:db89:0:b0:443:5cbc:82f9 with SMTP id f9-20020a67db89000000b004435cbc82f9mr4070870vsk.31.1689028264191; Mon, 10 Jul 2023 15:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028264; cv=none; d=google.com; s=arc-20160816; b=JGL2gc9ng2OL81QBZYppj27WsFn05A7hYmXE4HkC6u0YgkjrUW8MBCs+AxaAFcMCl3 1OYlAvamDZ0gXSyJVcd5Iao71Qdl0wsYXyShRlG2gsgZITn33CSyXD5holQlqhbFe8nX 9JT5L5sbIvcELlVIMpj4I/VWzEzAwE/+j2p+L9+FGa4FENEtq1p4LkMhpiFAK3mrH1Rc 3xr731Ls47fZB1OvoFVkeBRWM9iMuXG554Xwv2z2g70ltK95WqdEbfKilPoA2v2Pr+ic 9xiO0u1VYB3Mig7AH1hsCvFAJ8aQf244QNvNN+d9+wBf/2QNy1gYu/rCJMXtcZ/9Ps8O kaAg== 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=NQthq4rjmEx3k6hdMx4Zv3YTZEjHKOj7dC7fmyz9pe0=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=Ff3cumbCJlNfIeR7IN3ZvNz6xQxFluI7dvDTtFQcGSGIQaaB82EwjdaF2G1kTwaY5E FG45RsOVxfobXdMttoprIiYaJoJ6fbicYAQbo/rCJ2sY0fre21XSe14vDDHpuslXSFdo U5Lz37pZCpgxVGBrUD//3wSF/y6//DwjetvYvhYv/RLZDHDhIwsRjqr/ffFqYIH05+zr F5GnA631indY8SniT9BTJPP/3C1npHPcItX8N7mBADUbkdZz/eM/FHJyTXPlA6ztJT2/ TXmcTA7DzaA+/BDFkORxero/COxTKTieV9KWr7FuHplMu6whuwRawPynGGZ7abLOhHHQ MQSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TnqrhNvd; 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 s15-20020a0ce30f000000b0062b6ed187besi260834qvl.183.2023.07.10.15.31.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:04 -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=TnqrhNvd; 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 1qIzMm-0007xK-GH; Mon, 10 Jul 2023 18:28:24 -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 1qIzMl-0007tK-8g for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:23 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMi-0001zS-IZ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:22 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc59de009so53097905e9.3 for ; Mon, 10 Jul 2023 15:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028099; x=1691620099; 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=NQthq4rjmEx3k6hdMx4Zv3YTZEjHKOj7dC7fmyz9pe0=; b=TnqrhNvdtMJ/Du9kKZTHxZ5Yb7U1+bFf5E5x7cpr/Qi/vh2XC+FILXUlgsKnPO5hVx WduGNQEXQafdxRkW9AHgPwMH9sAlIyFkSv6EfsFSdVgnjdUv4egq/yEMsix3sk/aCSGp uNt76JP015fYNC5KHu4Ghk1bqj+Q69wBnm+7xY0UyrDHuWk+7OTqQJckmLhMuoXs8d3j OErlcLGZJTr2QQSOLsXqH/BERHj37TFfNvZVoRlvyJX2MlJsWF+X5VTTv7BGCRZPrRtA hT9Tbt1oRUA/6ytKWMcXHrXEo8KUe6Z+UP58eWyhco0nnOIHjZVdZyQkfwzs8I0wpnC1 2Skg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028099; x=1691620099; 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=NQthq4rjmEx3k6hdMx4Zv3YTZEjHKOj7dC7fmyz9pe0=; b=b1GQExFf58DTdt5iu92pjJGa3jwyV4ZDbwBPdg0ypVeNPaD8sliVCTrNwCex3vATJY dxMguhU4y/iLHRAQuMg5pZexf3511mAKEZ9KoFXiTRle38qAu0+Vk9XTCsq0a8PBJ3om nnZiScH1l+uS03GPElA+zUyyzJ+0mdOPqT0kSp6h7lrUF7TM99wefqkD1NIxP7rBUDPG yV0izRJRMAuYEOkP5I2ijysMAniaV+yL5iHl3CR10Kq6jY/weNFaI2dRkSKtkn5T4rQL wx/q6ENgNQX4cImLhKc1L1GnU7ef+pZKlmVcmC2XmZI6AFEa7cPSW+HuXXxuqtR66qc1 2jNw== X-Gm-Message-State: ABy/qLYcNdVFQm68k8754N7UiL5/Hcj3WXTG1NKAXiTOFZLFOOUy6O+3 VnxlKcFgwm/IuWqXyQTVzoLWbrGZ2RsgFHS1MopzRw== X-Received: by 2002:a7b:ce0f:0:b0:3f9:b87c:10db with SMTP id m15-20020a7bce0f000000b003f9b87c10dbmr11647072wmc.3.1689028098724; Mon, 10 Jul 2023 15:28:18 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id y23-20020a1c4b17000000b003fbd0c50ba2sm11323365wma.32.2023.07.10.15.28.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 23/44] target/mips/mxu: Add S8STD S8LDI S8SDI instructions Date: Tue, 11 Jul 2023 00:25:50 +0200 Message-Id: <20230710222611.50978-24-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are all load/store a byte from memory and put it into/get it from MXU register in various combinations. I-suffix instructions modify the base address GPR by offset provided. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-21-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 74 ++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 5556fd152d..dcb0e13f93 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -382,6 +382,9 @@ enum { OPC_MXU__POOL14 = 0x1C, OPC_MXU_Q8ACCE = 0x1D, OPC_MXU_S8LDD = 0x22, + OPC_MXU_S8STD = 0x23, + OPC_MXU_S8LDI = 0x24, + OPC_MXU_S8SDI = 0x25, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, OPC_MXU_S32M2I = 0x2E, @@ -633,8 +636,11 @@ static void gen_mxu_s32m2i(DisasContext *ctx) /* * S8LDD XRa, Rb, s8, optn3 - Load a byte from memory to XRF + * + * S8LDI XRa, Rb, s8, optn3 - Load a byte from memory to XRF, + * post modify address register */ -static void gen_mxu_s8ldd(DisasContext *ctx) +static void gen_mxu_s8ldd(DisasContext *ctx, bool postmodify) { TCGv t0, t1; uint32_t XRa, Rb, s8, optn3; @@ -649,6 +655,9 @@ static void gen_mxu_s8ldd(DisasContext *ctx) gen_load_gpr(t0, Rb); tcg_gen_addi_tl(t0, t0, (int8_t)s8); + if (postmodify) { + gen_store_gpr(t0, Rb); + } switch (optn3) { /* XRa[7:0] = tmp8 */ @@ -705,6 +714,58 @@ static void gen_mxu_s8ldd(DisasContext *ctx) gen_store_mxu_gpr(t0, XRa); } +/* + * S8STD XRa, Rb, s8, optn3 - Store a byte from XRF to memory + * + * S8SDI XRa, Rb, s8, optn3 - Store a byte from XRF to memory, + * post modify address register + */ +static void gen_mxu_s8std(DisasContext *ctx, bool postmodify) +{ + TCGv t0, t1; + uint32_t XRa, Rb, s8, optn3; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + s8 = extract32(ctx->opcode, 10, 8); + optn3 = extract32(ctx->opcode, 18, 3); + Rb = extract32(ctx->opcode, 21, 5); + + if (optn3 > 3) { + /* reserved, do nothing */ + return; + } + + gen_load_gpr(t0, Rb); + tcg_gen_addi_tl(t0, t0, (int8_t)s8); + if (postmodify) { + gen_store_gpr(t0, Rb); + } + gen_load_mxu_gpr(t1, XRa); + + switch (optn3) { + /* XRa[7:0] => tmp8 */ + case MXU_OPTN3_PTN0: + tcg_gen_extract_tl(t1, t1, 0, 8); + break; + /* XRa[15:8] => tmp8 */ + case MXU_OPTN3_PTN1: + tcg_gen_extract_tl(t1, t1, 8, 8); + break; + /* XRa[23:16] => tmp8 */ + case MXU_OPTN3_PTN2: + tcg_gen_extract_tl(t1, t1, 16, 8); + break; + /* XRa[31:24] => tmp8 */ + case MXU_OPTN3_PTN3: + tcg_gen_extract_tl(t1, t1, 24, 8); + break; + } + + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_UB); +} /* * D16MUL XRa, XRb, XRc, XRd, optn2 - Signed 16 bit pattern multiplication * D16MULF XRa, XRb, XRc, optn2 - Signed Q15 fraction pattern multiplication @@ -3707,7 +3768,16 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) gen_mxu_q8adde(ctx, true); break; case OPC_MXU_S8LDD: - gen_mxu_s8ldd(ctx); + gen_mxu_s8ldd(ctx, false); + break; + case OPC_MXU_S8STD: + gen_mxu_s8std(ctx, false); + break; + case OPC_MXU_S8LDI: + gen_mxu_s8ldd(ctx, true); + break; + case OPC_MXU_S8SDI: + gen_mxu_s8std(ctx, true); break; case OPC_MXU__POOL16: decode_opc_mxu__pool16(ctx); From patchwork Mon Jul 10 22:25:51 2023 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: 701068 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409447wrs; Mon, 10 Jul 2023 15:29:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOJrPByN+Y6YtBDR+1jTb5p36xrMOHw+/qCWhVnmzW4+5uS2gH849HaKNNwAY70izYQuDo X-Received: by 2002:ac8:7d4d:0:b0:403:b052:7f58 with SMTP id h13-20020ac87d4d000000b00403b0527f58mr5263251qtb.39.1689028164009; Mon, 10 Jul 2023 15:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028163; cv=none; d=google.com; s=arc-20160816; b=dAwEqCta5ypI6Bik4PLxqysvcCWM0ciUh2xT5z0Up7RRDkJzT8KdgQKqlXIBzArQ18 sDUsxTozkDqdAbjJo95B2yU/xa9xcdoanBcCEzZPHy/23Ijm4xQX0ikH/7ApmOH49B5z YXsWvewbRUKL9msTQvTqJ61L4yhpC4p7TFM9rl0E5X8WXWUa202XuUT+P1zAWSWHmhXp 25586MOZ3f8EimiYzKdR/6bzZsL+62t10lM5dVkcsbZE/5llXpT52SYHaErmmBjSKYl+ wfaYofFvEuFHaCDgi3h09duBHnRKEqCwFr+vvPrfbhTxnyyeyTsUPrASnmflsEHB3nfN 7KAg== 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=MuYh0Au2c1khtQa06fc1w+tPP6kd62N+ofg7GxEkmT8=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=bol3eykZ4o7Rd6p0r6NjDGskjFGdWzgltaU0mSzwX/yhHDfKdU5Mqii9B7+0y57VgX EzSUU98isEpaykeZ9RCMownUW8ChX5tj1nhay1nqgtQD+qcoUdhm8cywhczuZh/mgSfE qqiNkjZx1c5vMSZbb5MB4xM9PhCOHJboY+ahUNX6w+b8rxc3S0FY+s9yJ10DaX3gyXJH /7R0EVXeWpBDPz5zZZu6MflQcc/XxH+Xkrv9uU/2RO+nFFhXajmD5mEyU+YVOwQQKVvA GUmpylbUOfmGvqB9Sc9WsZ+BbbDOL2Ai8RIKkk+AAAB0WrwfGaP/THkdXBNFW08+W8f+ Jrrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=usPDuRau; 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 b11-20020ac87fcb000000b00403a9183b90si313759qtk.347.2023.07.10.15.29.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29: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=usPDuRau; 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 1qIzMq-0008BT-PY; Mon, 10 Jul 2023 18:28:28 -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 1qIzMp-00089M-GB for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:27 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMn-00021D-IK for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:27 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-307d58b3efbso4967252f8f.0 for ; Mon, 10 Jul 2023 15:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028104; x=1691620104; 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=MuYh0Au2c1khtQa06fc1w+tPP6kd62N+ofg7GxEkmT8=; b=usPDuRauV6ECeLjYWoPq+nfzkW6sSwqn4ChDb/DCwR2JcHfQ9HCwXeBYQUJbyLDjqX pcKgLRzheuqfkCB86pgYaslhBaTevbY2mJtCUf7qqVv5rAEBGFSXt5f0bDMhohkUH9CL t2gumqBlOJJuCx0nrSCbW8iSEIqZOuf4JYHvxXGDVeeTKEH4nqNcezBnueoCi3nAocek Nz67F71tTYFpB0BfNwCx8IDWcbGBcYezz5mkbROeN2sKICQ7NWMXcE47/tmtXRrodAx7 WELZRFP21/ZO+byAwvEKHEK5Q8zMXzzYONxQjY9+3V3GW70cXAsjTvJu3qM3Nkak+5LG lIVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028104; x=1691620104; 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=MuYh0Au2c1khtQa06fc1w+tPP6kd62N+ofg7GxEkmT8=; b=RqIFlZw6ffuvNJ2R13FjyV/JVI/ZeIgUz3wX5cnncU52fZKkiCvNKgHA5lErR1GucT Lgjucae0eEaD7oF1fduj4v5Pm3jxplaapLpOWWzDkcOCWqReXkOGMrI4BpYPYn4/hGVS 6qT+uckJpXEYY/KAOtZhGskUnh/JhMVeyCtwfk0HXq618yQ+NoyD/9nr1au6eN1XIvtn 1ouMcttANmppnAEfLKeYv42vzy6osLONr/L1qL8cNOjFRS0ru75089ZUZrcmZP9H6LDI YS4O4vPBs/oeB3GgDYWazyKV4rZlEY/IQcNAhztCr6EsL36TRciNS/HhMbUEHHLNKhAz ylHg== X-Gm-Message-State: ABy/qLYh0Scfh+1/6HGYukGV1v+3MkyCPWXu9h89di52BUbZlla/ZL3r OCRnK6FJC606rUH8pDLEB20WqR3d0q7gm6SrU73Nqw== X-Received: by 2002:a05:6000:4eb:b0:314:d8c:b881 with SMTP id cr11-20020a05600004eb00b003140d8cb881mr6580699wrb.70.1689028104083; Mon, 10 Jul 2023 15:28:24 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id i16-20020adffdd0000000b0030fb4b55c13sm510772wrs.96.2023.07.10.15.28.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 24/44] target/mips/mxu: Add S16LDD S16STD S16LDI S16SDI instructions Date: Tue, 11 Jul 2023 00:25:51 +0200 Message-Id: <20230710222611.50978-25-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are all load/store a halfword from memory and put it into/get it from MXU register in various combinations. I-suffix instructions modify the base address GPR by offset provided. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-22-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 117 ++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index dcb0e13f93..caf5257952 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -387,6 +387,10 @@ enum { OPC_MXU_S8SDI = 0x25, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, + OPC_MXU_S16LDD = 0x2A, + OPC_MXU_S16STD = 0x2B, + OPC_MXU_S16LDI = 0x2C, + OPC_MXU_S16SDI = 0x2D, OPC_MXU_S32M2I = 0x2E, OPC_MXU_S32I2M = 0x2F, OPC_MXU__POOL19 = 0x38, @@ -766,6 +770,107 @@ static void gen_mxu_s8std(DisasContext *ctx, bool postmodify) tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_UB); } + +/* + * S16LDD XRa, Rb, s10, optn2 - Load a halfword from memory to XRF + * + * S16LDI XRa, Rb, s10, optn2 - Load a halfword from memory to XRF, + * post modify address register + */ +static void gen_mxu_s16ldd(DisasContext *ctx, bool postmodify) +{ + TCGv t0, t1; + uint32_t XRa, Rb, optn2; + int32_t s10; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + s10 = sextract32(ctx->opcode, 10, 9) * 2; + optn2 = extract32(ctx->opcode, 19, 2); + Rb = extract32(ctx->opcode, 21, 5); + + gen_load_gpr(t0, Rb); + tcg_gen_addi_tl(t0, t0, s10); + if (postmodify) { + gen_store_gpr(t0, Rb); + } + + switch (optn2) { + /* XRa[15:0] = tmp16 */ + case MXU_OPTN2_PTN0: + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UW); + gen_load_mxu_gpr(t0, XRa); + tcg_gen_deposit_tl(t0, t0, t1, 0, 16); + break; + /* XRa[31:16] = tmp16 */ + case MXU_OPTN2_PTN1: + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UW); + gen_load_mxu_gpr(t0, XRa); + tcg_gen_deposit_tl(t0, t0, t1, 16, 16); + break; + /* XRa = sign_extend(tmp16) */ + case MXU_OPTN2_PTN2: + tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_SW); + break; + /* XRa = {tmp16, tmp16} */ + case MXU_OPTN2_PTN3: + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_UW); + tcg_gen_deposit_tl(t0, t1, t1, 0, 16); + tcg_gen_deposit_tl(t0, t1, t1, 16, 16); + break; + } + + gen_store_mxu_gpr(t0, XRa); +} + +/* + * S16STD XRa, Rb, s8, optn2 - Store a byte from XRF to memory + * + * S16SDI XRa, Rb, s8, optn2 - Store a byte from XRF to memory, + * post modify address register + */ +static void gen_mxu_s16std(DisasContext *ctx, bool postmodify) +{ + TCGv t0, t1; + uint32_t XRa, Rb, optn2; + int32_t s10; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + s10 = sextract32(ctx->opcode, 10, 9) * 2; + optn2 = extract32(ctx->opcode, 19, 2); + Rb = extract32(ctx->opcode, 21, 5); + + if (optn2 > 1) { + /* reserved, do nothing */ + return; + } + + gen_load_gpr(t0, Rb); + tcg_gen_addi_tl(t0, t0, s10); + if (postmodify) { + gen_store_gpr(t0, Rb); + } + gen_load_mxu_gpr(t1, XRa); + + switch (optn2) { + /* XRa[15:0] => tmp16 */ + case MXU_OPTN2_PTN0: + tcg_gen_extract_tl(t1, t1, 0, 16); + break; + /* XRa[31:16] => tmp16 */ + case MXU_OPTN2_PTN1: + tcg_gen_extract_tl(t1, t1, 16, 16); + break; + } + + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_UW); +} + /* * D16MUL XRa, XRb, XRc, XRd, optn2 - Signed 16 bit pattern multiplication * D16MULF XRa, XRb, XRc, optn2 - Signed Q15 fraction pattern multiplication @@ -3785,6 +3890,18 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL17: decode_opc_mxu__pool17(ctx); break; + case OPC_MXU_S16LDD: + gen_mxu_s16ldd(ctx, false); + break; + case OPC_MXU_S16STD: + gen_mxu_s16std(ctx, false); + break; + case OPC_MXU_S16LDI: + gen_mxu_s16ldd(ctx, true); + break; + case OPC_MXU_S16SDI: + gen_mxu_s16std(ctx, true); + break; case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; From patchwork Mon Jul 10 22:25:52 2023 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: 701065 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409355wrs; Mon, 10 Jul 2023 15:29:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEjkGI1SvYlSyHjJxz9PnxaBJWQxov/D/Y3af6zShQwQx5F1DYvxGjyuVe/m70xH12RRO42 X-Received: by 2002:ac8:4e4b:0:b0:403:a9d3:91e3 with SMTP id e11-20020ac84e4b000000b00403a9d391e3mr7031225qtw.32.1689028146182; Mon, 10 Jul 2023 15:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028146; cv=none; d=google.com; s=arc-20160816; b=GWUcEQZSR8zycoBRPUqQMGWp9PGrInmIT0gWXUaeKD41kOPCFXOX3MNX0aGM+jqX+L w1knhWTgBy2Vtugf9DyzzIvVm98HLs3taqvAs9vflT1WHJ52F6v9K5n5Bthg0GlHrlS8 ERxVMD/dnE8ZZ31ulKZx/QRWxzEKSvx2q1qAw335tRvRd1IRu78b7RAC8C/OgeNcIvoV YE3EzldAjvlHjNbeZzEW2m2JTqy+8Uax5jGrvIBg9SOz2JmozdTu0vevNgEv0VRiXPg+ jfWgPATCd7L6VwfWF63JXjS9JwX9LRpW6ZaWKLNxtp6iD13UlTQoHeO3B+WJEZ8QLEyG Lhyw== 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=itjW2Dx9jMI4ZUdMZbVpdbe/iacDRQ27Ew+SxZAZu2Y=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=jxt/51mHjZx9HSkBrtJQ4h4OdSpmsy0B8iZHEm8mSuChVaaEI1o7xhBeWpeoQVrNrm aL6KPSBtW0WEcuyUYyaokdwEfSgp7sEWT6cbPdrrRnHHugifEHsDjKZzo2cVaETAZWZb rKbErSNMA8S6eYYB4vylsSHVIOXuc9lkgPHKuRzeUA+0F3rdPZBnUzigmdppxx/obdUM eRiDOPUrzHtdOX6GCr/qFUhw7kdtUw6LOAwiOu/TjbI5KOy0yagef1HB1BsSl844b8kY BjFA+QMQVU7IhQ90HOj68Rl7YFiOoBtwNGIeEWd/bYAwczwMMotyWoPpYgMB2hXTYY3w CuiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vbm/Exlc"; 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 e13-20020ac85dcd000000b004039c2d8ed9si301746qtx.611.2023.07.10.15.29.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:06 -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="vbm/Exlc"; 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 1qIzMz-0000hR-L1; Mon, 10 Jul 2023 18:28:37 -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 1qIzMy-0000aJ-GN for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:36 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMs-00023B-Qw for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:36 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbca8935bfso51951635e9.3 for ; Mon, 10 Jul 2023 15:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028109; x=1691620109; 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=itjW2Dx9jMI4ZUdMZbVpdbe/iacDRQ27Ew+SxZAZu2Y=; b=vbm/Exlcetj7nBJvcVwxM/X2ThDuMMNfzksLZ0MDwo7Y/4dgeA43ODZ0ql93QRumO4 ubVcxyBKlaLaaOLsSCIZqhutB70POs4CVen83FwNYpBgs1xIDtBap0p6/TFw4Qps3msR lOTtXe5e83jwnYH/2Nehn2aoZe/+2/LcHyycoqBA6auLUlD9df5YoVuH1Q6EgiH5/0JK TehhDvFIpBV0tscL6k9LLXCOOMhW/NSUat0pJkC6dX3D9zi/j1nzQzE+PbcVlrWu1w1c hXnJ508P71wITW9JJ+JHTnrql4/fzEsRu43wgQ5zbBeFpoELtLewTqXnvGo4D0gHBZw2 hREQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028109; x=1691620109; 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=itjW2Dx9jMI4ZUdMZbVpdbe/iacDRQ27Ew+SxZAZu2Y=; b=kRXr3IjzV21uf6udBrtluTDOSWAJwN0ARXkDi0ltjUtavYiEbutF8GGwRjdg75m5EH oZ1lwQyfLvmKVJo3h6nK6anpMTAfLYdP52t7xlx+O8Y019ApIRWIjGKT6sbzJDebLoyI Y90pYYNy6/nSk8Bl9rf5t7EFxZUys4SLp35MKKp8SSSxPSvqiwWljZ3vi4w2xgjW9NGT efu6J3gMHRcuzWpvqajJOs6IuxUxoOqF4CxRVhzj37F1PtSrgxoVOGzLwJTVfGH00u2P Z2xH9O7CLsdlZFcFfPhDDA4nFH4f3ofR569mKKcN40TIGpmORAYG62bXJWpB0sUadEOx 0LVQ== X-Gm-Message-State: ABy/qLa4sqkHFlJmmUDP4eghdMMsdmUq1Jpjmn4EoHY5raOyFQq4xH1Z 79t5cmToK0om5NQuBQN1Flvm02+JOquQ/8eXaAVfGw== X-Received: by 2002:a7b:cbd8:0:b0:3f9:9a93:217f with SMTP id n24-20020a7bcbd8000000b003f99a93217fmr11194386wmi.3.1689028109302; Mon, 10 Jul 2023 15:28:29 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id s21-20020a7bc395000000b003fbc89af035sm897465wmj.17.2023.07.10.15.28.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 25/44] target/mips/mxu: Add S32MUL S32MULU S32EXTR S32EXTRV insns Date: Tue, 11 Jul 2023 00:25:52 +0200 Message-Id: <20230710222611.50978-26-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are part of pool15, see the grand opcode organization tree on top of the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-23-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 200 +++++++++++++++++++++++++++++++- 1 file changed, 196 insertions(+), 4 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index caf5257952..0704a8c7ff 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -290,9 +290,9 @@ * ├─ 100010 ─ OPC_MXU_S8LDD * ├─ 100011 ─ OPC_MXU_S8STD 15..14 * ├─ 100100 ─ OPC_MXU_S8LDI ┌─ 00 ─ OPC_MXU_S32MUL - * ├─ 100101 ─ OPC_MXU_S8SDI ├─ 00 ─ OPC_MXU_S32MULU - * │ ├─ 00 ─ OPC_MXU_S32EXTR - * ├─ 100110 ─ OPC_MXU__POOL15 ─┴─ 00 ─ OPC_MXU_S32EXTRV + * ├─ 100101 ─ OPC_MXU_S8SDI ├─ 01 ─ OPC_MXU_S32MULU + * │ ├─ 10 ─ OPC_MXU_S32EXTR + * ├─ 100110 ─ OPC_MXU__POOL15 ─┴─ 11 ─ OPC_MXU_S32EXTRV * │ * │ 20..18 * ├─ 100111 ─ OPC_MXU__POOL16 ─┬─ 000 ─ OPC_MXU_D32SARW @@ -385,6 +385,7 @@ enum { OPC_MXU_S8STD = 0x23, OPC_MXU_S8LDI = 0x24, OPC_MXU_S8SDI = 0x25, + OPC_MXU__POOL15 = 0x26, OPC_MXU__POOL16 = 0x27, OPC_MXU__POOL17 = 0x28, OPC_MXU_S16LDD = 0x2A, @@ -477,6 +478,16 @@ enum { OPC_MXU_D8SUMC = 0x02, }; +/* + * MXU pool 15 + */ +enum { + OPC_MXU_S32MUL = 0x00, + OPC_MXU_S32MULU = 0x01, + OPC_MXU_S32EXTR = 0x02, + OPC_MXU_S32EXTRV = 0x03, +}; + /* * MXU pool 16 */ @@ -871,6 +882,47 @@ static void gen_mxu_s16std(DisasContext *ctx, bool postmodify) tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_UW); } +/* + * S32MUL XRa, XRd, rs, rt - Signed 32x32=>64 bit multiplication + * of GPR's and stores result into pair of MXU registers. + * It strains HI and LO registers. + * + * S32MULU XRa, XRd, rs, rt - Unsigned 32x32=>64 bit multiplication + * of GPR's and stores result into pair of MXU registers. + * It strains HI and LO registers. + */ +static void gen_mxu_s32mul(DisasContext *ctx, bool mulu) +{ + TCGv t0, t1; + uint32_t XRa, XRd, rs, rt; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + XRd = extract32(ctx->opcode, 10, 4); + rs = extract32(ctx->opcode, 16, 5); + rt = extract32(ctx->opcode, 21, 5); + + if (unlikely(rs == 0 || rt == 0)) { + tcg_gen_movi_tl(t0, 0); + tcg_gen_movi_tl(t1, 0); + } else { + gen_load_gpr(t0, rs); + gen_load_gpr(t1, rt); + + if (mulu) { + tcg_gen_mulu2_tl(t0, t1, t0, t1); + } else { + tcg_gen_muls2_tl(t0, t1, t0, t1); + } + } + tcg_gen_mov_tl(cpu_HI[0], t1); + tcg_gen_mov_tl(cpu_LO[0], t0); + gen_store_mxu_gpr(t1, XRa); + gen_store_mxu_gpr(t0, XRd); +} + /* * D16MUL XRa, XRb, XRc, XRd, optn2 - Signed 16 bit pattern multiplication * D16MULF XRa, XRb, XRc, optn2 - Signed Q15 fraction pattern multiplication @@ -3014,9 +3066,122 @@ static void gen_mxu_d32asum(DisasContext *ctx) * MXU instruction category: Miscellaneous * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Q16SAT + * S32EXTR + * S32EXTRV + * Q16SAT */ +/* + * S32EXTR XRa, XRd, rs, bits5 + * Extract bits5 bits from 64-bit pair {XRa:XRd} + * starting from rs[4:0] offset and put to the XRa. + */ +static void gen_mxu_s32extr(DisasContext *ctx) +{ + TCGv t0, t1, t2, t3; + uint32_t XRa, XRd, rs, bits5; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + t3 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + XRd = extract32(ctx->opcode, 10, 4); + bits5 = extract32(ctx->opcode, 16, 5); + rs = extract32(ctx->opcode, 21, 5); + + /* {tmp} = {XRa:XRd} >> (64 - rt - bits5); */ + /* {XRa} = extract({tmp}, 0, bits5); */ + if (bits5 > 0) { + TCGLabel *l_xra_only = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + gen_load_mxu_gpr(t0, XRd); + gen_load_mxu_gpr(t1, XRa); + gen_load_gpr(t2, rs); + tcg_gen_andi_tl(t2, t2, 0x1f); + tcg_gen_subfi_tl(t2, 32, t2); + tcg_gen_brcondi_tl(TCG_COND_GE, t2, bits5, l_xra_only); + tcg_gen_subfi_tl(t2, bits5, t2); + tcg_gen_subfi_tl(t3, 32, t2); + tcg_gen_shr_tl(t0, t0, t3); + tcg_gen_shl_tl(t1, t1, t2); + tcg_gen_or_tl(t0, t0, t1); + tcg_gen_br(l_done); + gen_set_label(l_xra_only); + tcg_gen_subi_tl(t2, t2, bits5); + tcg_gen_shr_tl(t0, t1, t2); + gen_set_label(l_done); + tcg_gen_extract_tl(t0, t0, 0, bits5); + } else { + /* unspecified behavior but matches tests on real hardware*/ + tcg_gen_movi_tl(t0, 0); + } + gen_store_mxu_gpr(t0, XRa); +} + +/* + * S32EXTRV XRa, XRd, rs, rt + * Extract rt[4:0] bits from 64-bit pair {XRa:XRd} + * starting from rs[4:0] offset and put to the XRa. + */ +static void gen_mxu_s32extrv(DisasContext *ctx) +{ + TCGv t0, t1, t2, t3, t4; + uint32_t XRa, XRd, rs, rt; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + t3 = tcg_temp_new(); + t4 = tcg_temp_new(); + TCGLabel *l_xra_only = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + TCGLabel *l_zero = gen_new_label(); + TCGLabel *l_extract = gen_new_label(); + + XRa = extract32(ctx->opcode, 6, 4); + XRd = extract32(ctx->opcode, 10, 4); + rt = extract32(ctx->opcode, 16, 5); + rs = extract32(ctx->opcode, 21, 5); + + /* {tmp} = {XRa:XRd} >> (64 - rs - rt) */ + gen_load_mxu_gpr(t0, XRd); + gen_load_mxu_gpr(t1, XRa); + gen_load_gpr(t2, rs); + gen_load_gpr(t4, rt); + tcg_gen_brcondi_tl(TCG_COND_EQ, t4, 0, l_zero); + tcg_gen_andi_tl(t2, t2, 0x1f); + tcg_gen_subfi_tl(t2, 32, t2); + tcg_gen_brcond_tl(TCG_COND_GE, t2, t4, l_xra_only); + tcg_gen_sub_tl(t2, t4, t2); + tcg_gen_subfi_tl(t3, 32, t2); + tcg_gen_shr_tl(t0, t0, t3); + tcg_gen_shl_tl(t1, t1, t2); + tcg_gen_or_tl(t0, t0, t1); + tcg_gen_br(l_extract); + + gen_set_label(l_xra_only); + tcg_gen_sub_tl(t2, t2, t4); + tcg_gen_shr_tl(t0, t1, t2); + tcg_gen_br(l_extract); + + /* unspecified behavior but matches tests on real hardware*/ + gen_set_label(l_zero); + tcg_gen_movi_tl(t0, 0); + tcg_gen_br(l_done); + + /* {XRa} = extract({tmp}, 0, rt) */ + gen_set_label(l_extract); + tcg_gen_subfi_tl(t4, 32, t4); + tcg_gen_shl_tl(t0, t0, t4); + tcg_gen_shr_tl(t0, t0, t4); + + gen_set_label(l_done); + gen_store_mxu_gpr(t0, XRa); +} + /* * Q16SAT XRa, XRb, XRc * Packs four 16-bit signed integers in XRb and XRc to @@ -3695,6 +3860,30 @@ static void decode_opc_mxu__pool14(DisasContext *ctx) } } +static void decode_opc_mxu__pool15(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 14, 2); + + switch (opcode) { + case OPC_MXU_S32MUL: + gen_mxu_s32mul(ctx, false); + break; + case OPC_MXU_S32MULU: + gen_mxu_s32mul(ctx, true); + break; + case OPC_MXU_S32EXTR: + gen_mxu_s32extr(ctx); + break; + case OPC_MXU_S32EXTRV: + gen_mxu_s32extrv(ctx); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool16(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 18, 3); @@ -3884,6 +4073,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_S8SDI: gen_mxu_s8std(ctx, true); break; + case OPC_MXU__POOL15: + decode_opc_mxu__pool15(ctx); + break; case OPC_MXU__POOL16: decode_opc_mxu__pool16(ctx); break; From patchwork Mon Jul 10 22:25:53 2023 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: 701094 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411166wrs; Mon, 10 Jul 2023 15:33:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDt7m+vJgbuofrBsaHHo7KEpEae7nrohbgTHliR28mzIfUH3sHXcSeo9mBDOS24hobUvY2 X-Received: by 2002:a05:620a:1488:b0:765:59d8:d421 with SMTP id w8-20020a05620a148800b0076559d8d421mr12103501qkj.1.1689028409236; Mon, 10 Jul 2023 15:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028409; cv=none; d=google.com; s=arc-20160816; b=Piw0wXDzbhNxRpXviKK+gpjH+92P69YujuQmtLl3j5axmRAMfAF+dELcmr+Gfo+WbZ whoSCQodRx3hfwzsSya4zmjSfYBlg0G/BCopU5cbXzamh0VMd4HI4NpqnIYaioH0GLkk RhI72WwitdZuz3f95uSzhAHcRTyhowmfn7OxssuwgTwvaiLPibOOBAMBD3luh5gK1e6N 1wzmL+kWXVLfIL2OaaGQcxoDaqn2r4HMqmMF8jNBWLEYl87YRVYrLt5VWofo0b9oHmzU P2B1jbVBDNm/elmr0qhViYlQQGFMecVqGi1NYd9esA8PBhPRHCrRSbYn7uly5Ne7fzW8 uhWg== 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=CdUqHTuEdqBmvrkfm1bRIEI+OIlwJsW52MELVUyLflY=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=kzyoos29qpTM1wQiCRlWRFJxLnypIuLGuXO11J2Wr57M3xlrufV5jUFjAnTc65CkQf wOI07IfnyLzqnUgK/C5aJwKbndqyaAf/vHwg67QmN3r2b2h8qoiOzJurORr+dG6mtTqy ZLFvIToKMkWopMjXBj+LJoJFn0V2KTPmQSwZfB4/gSPwPfB3pN3cGj0Uw8fBXp+EBKxD snImc3KqXXyp/8lITuV6ERBbKVeZatmHF9Z7AUgFRQYnyuLynih4VCUUcKnejqeuaB0g y/sp9w2NwLirBYkWvFs4d3PhhqHIAN4cPwGvjF/pqohzWTdCdNfyqw2mB3nSYCN4dIPj Qdgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jeyJNCPH; 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 t12-20020a05620a0b0c00b00767d452f030si251831qkg.658.2023.07.10.15.33.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:29 -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=jeyJNCPH; 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 1qIzN2-0000mK-CJ; Mon, 10 Jul 2023 18:28:40 -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 1qIzMz-0000ie-Pu for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:37 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzMx-00023G-T2 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:37 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbab0d0b88so46138425e9.0 for ; Mon, 10 Jul 2023 15:28:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028114; x=1691620114; 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=CdUqHTuEdqBmvrkfm1bRIEI+OIlwJsW52MELVUyLflY=; b=jeyJNCPH/Inz+m5VtHTgxLVwvsYbrM8bOArFCqB99rpoAYwXwwVoL1yJETHUWzp6Dp Edh6zgMdzFFMtcMKwiNk1PXoDKBIHJe3cQmU84L0iuGQefjmdhi4gNq9iF8EOzShgYOQ i7LeRk2bFHX/7d4m5KSUybiJYENPblmTJMYkSg9EDpwcZbQ8rOCWAbbvxdGcm7+LJO/4 nWiFtsgFKohDyiuRvXcsEg3GmOp8yCH9psbaEFxBh+I0GEuq07rMadSEHZgVmzUVGtIY HO1fMyRBV3gOuKf/ToC5dCIWrDK36hCSOtBWtG/uWJl2a+HI9oe6QweTbhKDZxK8VA/5 tCyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028114; x=1691620114; 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=CdUqHTuEdqBmvrkfm1bRIEI+OIlwJsW52MELVUyLflY=; b=QNPKxQ1C2Z6hg1yyE85ioGwHPCBtIu4iPwtYYj/bCy+Azj7/S01UVpEub5Wu/Ltm4z WXcN5fAfwfHmt85gkv5Z+9wKbxEJsLDhvJlBTN1rfkFTlJo81L693eZG6iVw3Gpw4mk7 nDIHm3kvqApXaZMk/6Wo/mceqxz+zetur0cAY2UZ2t/XmUueK4FG5f+YGWV7Wl4uYWI7 sDpcniCNZVDDG/2Doe/WB5ANG3+IXJth0M1SL8rHBt/YZqECTEmr/drbqNgcwKgEL77r PuEQhOYCDwRZKbK/kZQwcyJ7XZv3grZIq+WnTYwJz2mQe+NI2mwdQh3D85dtR3qjyNpN NADw== X-Gm-Message-State: ABy/qLaKtM5uuAYO48M2U7iWrUj1ZzPQnraib4AySfqHKWR6vpBxBQ59 Wk0MvbIy8Agp1PxhPIUzjEc3KNO3Hu3Z6988fMHz+A== X-Received: by 2002:adf:fd84:0:b0:314:a8d:2c9 with SMTP id d4-20020adffd84000000b003140a8d02c9mr13540589wrr.0.1689028114279; Mon, 10 Jul 2023 15:28:34 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id v16-20020a5d4b10000000b003143be36d99sm528224wrq.58.2023.07.10.15.28.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 26/44] target/mips/mxu: Add S32ALN S32LUI insns Date: Tue, 11 Jul 2023 00:25:53 +0200 Message-Id: <20230710222611.50978-27-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are part of pool16, see the grand opcode organization tree on top of the file. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-24-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 122 +++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 0704a8c7ff..4f07201fcc 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -492,7 +492,9 @@ enum { * MXU pool 16 */ enum { + OPC_MXU_S32ALN = 0x01, OPC_MXU_S32ALNI = 0x02, + OPC_MXU_S32LUI = 0x03, OPC_MXU_S32NOR = 0x04, OPC_MXU_S32AND = 0x05, OPC_MXU_S32OR = 0x06, @@ -3066,7 +3068,7 @@ static void gen_mxu_d32asum(DisasContext *ctx) * MXU instruction category: Miscellaneous * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * S32EXTR + * S32EXTR S32LUI * S32EXTRV * Q16SAT */ @@ -3182,6 +3184,59 @@ static void gen_mxu_s32extrv(DisasContext *ctx) gen_store_mxu_gpr(t0, XRa); } +/* + * S32LUI XRa, S8, optn3 + * Permutate the immediate S8 value to form a word + * to update XRa. + */ +static void gen_mxu_s32lui(DisasContext *ctx) +{ + uint32_t XRa, s8, optn3, pad; + + XRa = extract32(ctx->opcode, 6, 4); + s8 = extract32(ctx->opcode, 10, 8); + pad = extract32(ctx->opcode, 21, 2); + optn3 = extract32(ctx->opcode, 23, 3); + + if (unlikely(pad != 0)) { + /* opcode padding incorrect -> do nothing */ + } else if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else { + uint32_t s16; + TCGv t0 = tcg_temp_new(); + + switch (optn3) { + case 0: + tcg_gen_movi_tl(t0, s8); + break; + case 1: + tcg_gen_movi_tl(t0, s8 << 8); + break; + case 2: + tcg_gen_movi_tl(t0, s8 << 16); + break; + case 3: + tcg_gen_movi_tl(t0, s8 << 24); + break; + case 4: + tcg_gen_movi_tl(t0, (s8 << 16) | s8); + break; + case 5: + tcg_gen_movi_tl(t0, (s8 << 24) | (s8 << 8)); + break; + case 6: + s16 = (uint16_t)(int16_t)(int8_t)s8; + tcg_gen_movi_tl(t0, (s16 << 16) | s16); + break; + case 7: + tcg_gen_movi_tl(t0, (s8 << 24) | (s8 << 16) | (s8 << 8) | s8); + break; + } + gen_store_mxu_gpr(t0, XRa); + } +} + /* * Q16SAT XRa, XRb, XRc * Packs four 16-bit signed integers in XRb and XRc to @@ -3461,6 +3516,65 @@ static void gen_mxu_S32ALNI(DisasContext *ctx) } } +/* + * S32ALN XRc, XRb, XRa, rs + * Arrange bytes from XRb and XRc according to one of five sets of + * rules determined by rs[2:0], and place the result in XRa. + */ +static void gen_mxu_S32ALN(DisasContext *ctx) +{ + uint32_t rs, XRc, XRb, XRa; + + rs = extract32(ctx->opcode, 21, 5); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else if (unlikely((XRb == 0) && (XRc == 0))) { + /* both operands zero registers -> just set destination to all 0s */ + tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); + } else { + /* the most general case */ + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGLabel *l_exit = gen_new_label(); + TCGLabel *l_b_only = gen_new_label(); + TCGLabel *l_c_only = gen_new_label(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + gen_load_gpr(t2, rs); + tcg_gen_andi_tl(t2, t2, 0x07); + + /* do nothing for undefined cases */ + tcg_gen_brcondi_tl(TCG_COND_GE, t2, 5, l_exit); + + tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l_b_only); + tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 4, l_c_only); + + tcg_gen_shli_tl(t2, t2, 3); + tcg_gen_subfi_tl(t3, 32, t2); + + tcg_gen_shl_tl(t0, t0, t2); + tcg_gen_shr_tl(t1, t1, t3); + tcg_gen_or_tl(mxu_gpr[XRa - 1], t0, t1); + tcg_gen_br(l_exit); + + gen_set_label(l_b_only); + gen_store_mxu_gpr(t0, XRa); + tcg_gen_br(l_exit); + + gen_set_label(l_c_only); + gen_store_mxu_gpr(t1, XRa); + + gen_set_label(l_exit); + } +} + /* * S32MADD XRa, XRd, rb, rc * 32 to 64 bit signed multiply with subsequent add @@ -3889,9 +4003,15 @@ static void decode_opc_mxu__pool16(DisasContext *ctx) uint32_t opcode = extract32(ctx->opcode, 18, 3); switch (opcode) { + case OPC_MXU_S32ALN: + gen_mxu_S32ALN(ctx); + break; case OPC_MXU_S32ALNI: gen_mxu_S32ALNI(ctx); break; + case OPC_MXU_S32LUI: + gen_mxu_s32lui(ctx); + break; case OPC_MXU_S32NOR: gen_mxu_S32NOR(ctx); break; From patchwork Mon Jul 10 22:25:54 2023 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: 701096 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411205wrs; Mon, 10 Jul 2023 15:33:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlEktsr0Cnqsb0PBHsSEKS5sI8W3rQyMLC2cO0O3nV5B9dvU3VCQmaewzjeGEOfrqSrRWIhn X-Received: by 2002:a0c:a711:0:b0:635:a1f5:5464 with SMTP id u17-20020a0ca711000000b00635a1f55464mr11337307qva.37.1689028415603; Mon, 10 Jul 2023 15:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028415; cv=none; d=google.com; s=arc-20160816; b=n/Q8c2nia3mTR6mUJ9EWBtuFH9XvWUMxwwnpiIfLCpUkB6SDdmnHDJs9Ay5b+76xLI fBORNujpKeT5mG+iU/4QCcg4jONOskAyco4k17I/BocteLwq39pwr3pIkES8TwZ04BF4 Tk0zi7G0mWHO8hFvMFTQXS8jJHE7k/Bz3cm8Y3lukcO5Fi0Clqx4wOObkpYMDUgwvK1g akWcIrmviKoByjjEi2GuBxBLGBcST72oPjCP4teEL3+BjOIYONsNZV+pbc4V3+6QfPwP OdPdvdGRnGrLmrVPkVzhhoGFgXz3YdPsUS/W92Bzi1uOYeyYUiekpA5iVCLEGRtHV20o lkSQ== 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=+wp+sjHHgL9R8LRSHFq7OIwpxhd2bBWYkZc/QFRjA1g=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=z/q+dhqtnXyjpvCVeGQo+fC72gSzK91m91AxgnWWtIUiGWIAA9Oz+IDB2uxv8vqfgb hUTju9hNf+i0dx8/hFi6owcUEy8T7lhpeCYVFM11VA/+gT9vQzb5+tdYVnS5MTaN3ceU uDa3iTtqoF80dRCYMgtFpcSmMSDcnLcP1lc6rVNJ9falJF0bbOEtSwOaJfrGS2oMXYva kcNzMTZcoi1oiFsv4ZWXwiZ1PzA2g7ZzBZCt79LFGikba2NytTDjSrmOP3Ab6FVaVs/K s25IqkEscS9MM6o2lB3f4NwBp50wkrnbmkXQFp1QOzAkvrG7p1Y5JkbnZxIg+i8hcKAJ drfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BT8bZqNk; 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 de16-20020a05620a371000b00766fc1a6ad5si269617qkb.318.2023.07.10.15.33.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:35 -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=BT8bZqNk; 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 1qIzN7-000151-5V; Mon, 10 Jul 2023 18:28: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 1qIzN5-0000uX-TR for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:43 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzN3-00023w-AB for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:43 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-314313f127fso5207800f8f.1 for ; Mon, 10 Jul 2023 15:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028119; x=1691620119; 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=+wp+sjHHgL9R8LRSHFq7OIwpxhd2bBWYkZc/QFRjA1g=; b=BT8bZqNkzZXtyVMnSY7q4DcTn2OuJLtCUu1kPOlJd3hfdI4pCVtgts1SDVFDy3f5Lc 9dia1GxmmWUGprVhGkClXQaOEKcFk+a8H1dhFhxkdpykifeyutNeeH/fFKXeOIClQfZU VgyfAAMyOUURM15VtfpaXbXXBYqsi2D4RDba49sKqEzES+ciNDm1gpSl/26oDu5LM95e 3ljZ1J0cby+rn7+VwA9ZoNSoJqKsQfSvb72/zhel79g6k432U/cqsFvpYQU0e1UPHlTH OsdqCf3e+HQAvqK7nShq08oQmzXuM1Nd8bT/tHEIi8yNcB2allbUM3K70Ed0rsQ2sczN 9vjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028119; x=1691620119; 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=+wp+sjHHgL9R8LRSHFq7OIwpxhd2bBWYkZc/QFRjA1g=; b=NfpKYdEF106z2T7mI8zKpBAyYqKRe9JJCBZMLh3SNcWbymTfIICdGcmHCQzFjZ/dhC sSVFinCHzdDRRsp1VpRxMEAR7ALX00phe8/MThjNtzC+EPqzqiCo6P56ysDw13yakVEa oWYHd6zAMkQY3vwDgYaC98+WZemjEJNi+Lt87r/pVN6Uarjz4y1C3SSkOdrz6q719Mu6 DccP6l2KRSTihoomrx8O/wGY2zk2KYOEmG3tnhEo9tpMw8YfoflSd7vbL8HqO+cPH6fq zH6v0rJQgNwd2BR6FJPVUaPN3kWu3UojFvaMtIWcdkqtb6DfIl6iKgIXbl0IbUYyTqb/ EkmQ== X-Gm-Message-State: ABy/qLZDaJtNHl3n95osplw5PQTvZOaMHtQUuK95k9UbLhD2ZAk7fKFx oh2hpOgECKxgenC1zSM3qnZIX9u2O7X8XjqZA87V3A== X-Received: by 2002:adf:f5cf:0:b0:313:f4ea:4d97 with SMTP id k15-20020adff5cf000000b00313f4ea4d97mr13156115wrp.23.1689028119462; Mon, 10 Jul 2023 15:28:39 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id a3-20020a5d5703000000b003143cb109d5sm544865wrv.14.2023.07.10.15.28.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 27/44] target/mips/mxu: Add D32SARL D32SARW instructions Date: Tue, 11 Jul 2023 00:25:54 +0200 Message-Id: <20230710222611.50978-28-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are dual 32-bit arithmetic shift right and pack LSBs to 2x 16-bit into a MXU register. The difference is the shift amount source: immediate or GP reg. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-25-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 4f07201fcc..36fb4232cd 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -394,6 +394,7 @@ enum { OPC_MXU_S16SDI = 0x2D, OPC_MXU_S32M2I = 0x2E, OPC_MXU_S32I2M = 0x2F, + OPC_MXU_D32SARL = 0x32, OPC_MXU__POOL19 = 0x38, }; @@ -492,6 +493,7 @@ enum { * MXU pool 16 */ enum { + OPC_MXU_D32SARW = 0x00, OPC_MXU_S32ALN = 0x01, OPC_MXU_S32ALNI = 0x02, OPC_MXU_S32LUI = 0x03, @@ -1689,6 +1691,57 @@ static void gen_mxu_S32XOR(DisasContext *ctx) } } +/* + * MXU instruction category: shift + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * D32SLL D32SLR D32SAR D32SARL + * D32SLLV D32SLRV D32SARV D32SARW + * Q16SLL Q16SLR Q16SAR + * Q16SLLV Q16SLRV Q16SARV + */ + +/* + * D32SARL XRa, XRb, XRc, SFT4 + * Dual shift arithmetic right 32-bit integers in XRb and XRc + * to SFT4 bits (0..15). Pack 16 LSBs of each into XRa. + * + * D32SARW XRa, XRb, XRc, rb + * Dual shift arithmetic right 32-bit integers in XRb and XRc + * to rb[3:0] bits. Pack 16 LSBs of each into XRa. + */ +static void gen_mxu_d32sarl(DisasContext *ctx, bool sarw) +{ + uint32_t XRa, XRb, XRc, rb; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + rb = extract32(ctx->opcode, 21, 5); + + if (unlikely(XRa == 0)) { + /* destination is zero register -> do nothing */ + } else { + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + if (!sarw) { + /* Make SFT4 from rb field */ + tcg_gen_movi_tl(t2, rb >> 1); + } else { + gen_load_gpr(t2, rb); + tcg_gen_andi_tl(t2, t2, 0x0f); + } + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + tcg_gen_sar_tl(t0, t0, t2); + tcg_gen_sar_tl(t1, t1, t2); + tcg_gen_extract_tl(t2, t1, 0, 16); + tcg_gen_deposit_tl(t2, t2, t0, 16, 16); + gen_store_mxu_gpr(t2, XRa); + } +} /* * MXU instruction category max/min/avg @@ -4003,6 +4056,9 @@ static void decode_opc_mxu__pool16(DisasContext *ctx) uint32_t opcode = extract32(ctx->opcode, 18, 3); switch (opcode) { + case OPC_MXU_D32SARW: + gen_mxu_d32sarl(ctx, true); + break; case OPC_MXU_S32ALN: gen_mxu_S32ALN(ctx); break; @@ -4214,6 +4270,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_S16SDI: gen_mxu_s16std(ctx, true); break; + case OPC_MXU_D32SARL: + gen_mxu_d32sarl(ctx, false); + break; case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; From patchwork Mon Jul 10 22:25:55 2023 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: 701093 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411148wrs; Mon, 10 Jul 2023 15:33:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7DwwgabY6+UxQCu0CsAKvGaBgHDR1LBic1bhIKNCx5gLGKzUAJTDguSP4lPm7ta8tb/sd X-Received: by 2002:a0c:f30a:0:b0:625:536f:4f01 with SMTP id j10-20020a0cf30a000000b00625536f4f01mr16592076qvl.11.1689028407117; Mon, 10 Jul 2023 15:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028407; cv=none; d=google.com; s=arc-20160816; b=DDVMXKZkTFYQ7viyVCn13YaBghrUcLX8mkJZ8IPowLGWV/Wt5T8BPsw6c/tXaA48Fd XlRPKI0LWsVG66OwmHOsbL69n3irPmL6mxehzGFZhRRxuaDhhbuBsMf0+WAvrm85znzK zm0cEvj+rIL64wPq3NlvpVAvhNZWDzIdlzO/YaCGR665mKqFUGLywJ657s/6JrqaJWOO b2CLFi0X8GAP0ClIforQX/XjlkJ100DCbTfiFVRzxNxvD7b2NL2UwE5cP7sn+i9nS6Xs 7APd3r5d3YOwIkckssl9/YaMyC0gBqxqgT5wH+7BmVqJeVtgM00uxgrmqMsUdyqcwneB NLSA== 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=3MsxiCt5nJiEc6wQO1pDa009vw+SZ+eH48A/Z+HwV3w=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=s88O5gNudRPGJPozFj008Li4kiRjGhlvTSzUzXv3dzOqC8rGRR2TcywrReuwrgLteK 1nxPu9bwPZQEvoBGpkO4aS35LSHv02sV5u6mOgHolReevpfsicD+l89p/M91CPyUMx/c M4tNEjYHE3Wm0TSHuyrCxE2+VrdIIbcBDXOjthMXpzi+8230HeBXMJORDB8jcHnnEBDn Dzg2Ptnxi8I9k+T+Tt32kd2pA0uv4nnIz2Q9S5naQgy0DI8i0/NT7fHTKVsVwRCo2x+t 9wc/gwf4AlzvIp9MRhd/Q9i6J5dQuoH5eiqQJYPLLDZyaMFjSYTOtqPUu2UCZRNq6dXN MlzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SEUtmzUb; 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 e11-20020a0cf34b000000b0063725bf37c9si248075qvm.420.2023.07.10.15.33.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:27 -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=SEUtmzUb; 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 1qIzNA-0001YH-Sk; Mon, 10 Jul 2023 18:28:48 -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 1qIzNA-0001V3-3C for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:48 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzN8-000247-El for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:47 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbdfda88f4so51776805e9.1 for ; Mon, 10 Jul 2023 15:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028124; x=1691620124; 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=3MsxiCt5nJiEc6wQO1pDa009vw+SZ+eH48A/Z+HwV3w=; b=SEUtmzUbDEhxPF2xY3DCyqGkUHzyxlcmmgZSJz1nncYOzxNdXlZjykpTahJqxUQ07R wlaDpaorXkWH1WeHxiyW/CtJTOjbOgeJqNq1ghS3c+5hCZwBJCbZqemzNqiwSqr/NK9+ gRVvT5QRCGWAnukN4qYMoizo1kcsml8R0jPKyKb2AHf3s2eUls6E22f8nzV13O8FynMT XRhGI9AaiAhudTSCT6zKyifpnMxIqugb7kOdRJ5vDrYKC9digN5QGbJnQHJvLWzxsLpd DjrMrh4hzgQEJISjkav6dO8sbuMZvvt0Avn2sr5jWxI9nwP+tDWLWGao6eA8u6UAtxf+ 3nig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028124; x=1691620124; 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=3MsxiCt5nJiEc6wQO1pDa009vw+SZ+eH48A/Z+HwV3w=; b=MSInKqBRY0hPJ+n/mW2eq0kzDv7Zf5Vtwk3TnvQAW809Pl6VHp6ZC0meqamO+cvJPq B2i8MnbSzPZN6vfZLpqZ378VyU5Ky3JpLCkSXfXhrugpk360ry6CIy2FEND28yFffMcH ZvwqfhZ9IFIy3XqLx/5vDTSwwD2HzoGVMF8P1u7LXwVP9ueLCkPUk/qOMo1Qv8JN650v 6MnJR/mKfbX8ifElHcqzbfimizBXptXAWj3k4KdNFBeWW5MUwdNEYwMDIQQAEr2CNGdG DfRLe+bS0DeFdMRlgXzDstCa2T2IeqAtlU/R05ZJdNfEUVWopjnX6MP8oTw2uvHFZ7Eq HCvA== X-Gm-Message-State: ABy/qLbJGQBbVAVmNjlPPbnX8ht75uiyMkDg259sQeZQx2LwqeZTtsJ7 /URdtMsYKknzO9YkuoceBF9O6O46epiQ0umLl0/Dcw== X-Received: by 2002:adf:fb07:0:b0:314:d19:fc31 with SMTP id c7-20020adffb07000000b003140d19fc31mr12409561wrr.51.1689028124664; Mon, 10 Jul 2023 15:28:44 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id cr13-20020a05600004ed00b003143ba62cf4sm524681wrb.86.2023.07.10.15.28.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 28/44] target/mips/mxu: Add D32SLL D32SLR D32SAR instructions Date: Tue, 11 Jul 2023 00:25:55 +0200 Message-Id: <20230710222611.50978-29-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are same data shift in various directions, thus one generation function is implemented for all three. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-26-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 36fb4232cd..79263e97c3 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -394,7 +394,10 @@ enum { OPC_MXU_S16SDI = 0x2D, OPC_MXU_S32M2I = 0x2E, OPC_MXU_S32I2M = 0x2F, + OPC_MXU_D32SLL = 0x30, + OPC_MXU_D32SLR = 0x31, OPC_MXU_D32SARL = 0x32, + OPC_MXU_D32SAR = 0x33, OPC_MXU__POOL19 = 0x38, }; @@ -1701,6 +1704,49 @@ static void gen_mxu_S32XOR(DisasContext *ctx) * Q16SLLV Q16SLRV Q16SARV */ +/* + * D32SLL XRa, XRd, XRb, XRc, SFT4 + * Dual 32-bit shift left from XRb and XRc to SFT4 + * bits (0..15). Store to XRa and XRd respectively. + * D32SLR XRa, XRd, XRb, XRc, SFT4 + * Dual 32-bit shift logic right from XRb and XRc + * to SFT4 bits (0..15). Store to XRa and XRd respectively. + * D32SAR XRa, XRd, XRb, XRc, SFT4 + * Dual 32-bit shift arithmetic right from XRb and XRc + * to SFT4 bits (0..15). Store to XRa and XRd respectively. + */ +static void gen_mxu_d32sxx(DisasContext *ctx, bool right, bool arithmetic) +{ + uint32_t XRa, XRb, XRc, XRd, sft4; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRd = extract32(ctx->opcode, 18, 4); + sft4 = extract32(ctx->opcode, 22, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + + if (right) { + if (arithmetic) { + tcg_gen_sari_tl(t0, t0, sft4); + tcg_gen_sari_tl(t1, t1, sft4); + } else { + tcg_gen_shri_tl(t0, t0, sft4); + tcg_gen_shri_tl(t1, t1, sft4); + } + } else { + tcg_gen_shli_tl(t0, t0, sft4); + tcg_gen_shli_tl(t1, t1, sft4); + } + gen_store_mxu_gpr(t0, XRa); + gen_store_mxu_gpr(t1, XRd); +} + /* * D32SARL XRa, XRb, XRc, SFT4 * Dual shift arithmetic right 32-bit integers in XRb and XRc @@ -4270,9 +4316,18 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_S16SDI: gen_mxu_s16std(ctx, true); break; + case OPC_MXU_D32SLL: + gen_mxu_d32sxx(ctx, false, false); + break; + case OPC_MXU_D32SLR: + gen_mxu_d32sxx(ctx, true, false); + break; case OPC_MXU_D32SARL: gen_mxu_d32sarl(ctx, false); break; + case OPC_MXU_D32SAR: + gen_mxu_d32sxx(ctx, true, true); + break; case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; From patchwork Mon Jul 10 22:25:56 2023 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: 701081 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410393wrs; Mon, 10 Jul 2023 15:31:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqeMukxieYa0hgrMD8dwd/WQpAkimMpyCYlKGux4dvs0fHVHO43M75O3Kd7wb4us3GI7aV X-Received: by 2002:a05:620a:2a05:b0:767:4246:1f83 with SMTP id o5-20020a05620a2a0500b0076742461f83mr19162429qkp.49.1689028286706; Mon, 10 Jul 2023 15:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028286; cv=none; d=google.com; s=arc-20160816; b=suNT17VJTj+K8kRXjzM2ZfGfuaaOYllUF5RXPCfY2AFrQToJhaPhfcArmtY5ZWIzHg 6fo6ArROVEkg3Q82jX6i0XPOFcJGskItps5ZK+698LGxhj8L8EeYKzFqNfPn6tLrrt3C 8JWYvHyxPTcvVARyZ1FJJ/1AnvWYnq5cQBxb5SZR1biAl178YQQZl7MLt5xzGgoo0IXH RoVKlGY1U236FhbO7NrYCmyGEYO32xEDzCTIuki5YObiAqwkQZI/hqO/MjrF4lgOALDD 16riinVdusLTnZ0XG+KpExEMKgL+iaLnO4/4MMSPPTqQ/mbKsQK6U7Q0RGgW0c1cMAfH J1+w== 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=w24qCGipOFLgfiJ0fjsZXsRTZKWbqT9NbJtcLXAN6Ok=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=l87NRNJQtgzvYlC78POmlHM+Zi2DpcVFGEcn8/BmebfjwuXueuY5tzUNBSIyLVpDZz K6KwLyNCnWRPmNZtJwIaJpevL4PVMDd58VIXWGmVm4zFgR2ZWArwYCzzaYAHFbTbBSul 4bhiNWMVA03saRVJRqYZ3hgLAskO9zghV/6NF00cSmdw8VWXJTb1tORzBphzRGFgYqNB y4aWHQi2k4vxD/QjjjLdfos85J7+j4xBtsOnZ9jxQGWxR+sjHL+mkszjBXMeOA1F/EuT C5dn0cAGVjs/b/aYtPkNFf4l6NtiJX5AMhVgU2F+FzjdU16DplzOPuu0CjB25iHLrW9b q8Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aQ1PsucQ; 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 l12-20020a05620a0c0c00b007673316a71csi251772qki.570.2023.07.10.15.31.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:26 -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=aQ1PsucQ; 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 1qIzNG-000231-LA; Mon, 10 Jul 2023 18:28:54 -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 1qIzNE-0001n6-VK for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:52 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzND-00024f-7Z for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:52 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbd33a57dcso56177905e9.0 for ; Mon, 10 Jul 2023 15:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028129; x=1691620129; 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=w24qCGipOFLgfiJ0fjsZXsRTZKWbqT9NbJtcLXAN6Ok=; b=aQ1PsucQ07ewoyVYYnvmTDM3PLf9s+XEUOASDvuZwBhuerIz/p7qtLN2BJEjw6vDuT bHmQaAXwPcdpV9zAYzGDBp9o6h6Sovny/6+5YiSn5QN4VcJOCwV5RhIVKXmPClWydEts 9v9iOfeiOA0C2Ef7fzSjuUqULZbtGmor5Qg+bfgYdp7DxRX8DQpGMTcJqcSEc3wyS9J7 B4N1KHcooYqQ9X2DjzQ1J7NQ1+gb59cvrpo62BCLUsB5K/YHbC9tdvU12irBqBUpoQRY sEpywLBwLxmtppqASkEyH5yVpph4ud2MCSqQ6I1Pg3oHimgnH2l/aWVV/6q7RbsLGHHY ywOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028129; x=1691620129; 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=w24qCGipOFLgfiJ0fjsZXsRTZKWbqT9NbJtcLXAN6Ok=; b=d1/PsPdCFvjUgIC58OXqdJoFHs0Dc+tYi3a1CVcBrqnwTTvfwX25Yy+YwkYzF/K6z2 uhIO/dl7mUQ75fYcwdqYrr2/fTK1zK5FxZYWz5RnvVYLvlteisiNxER+Ef6BoD2kW1xd wyqabSW4HPwEnrEWUsQmEjTQcA7e6YM7SR29bLECbrzNvglTpsopWfU4mkojzTNXt+tt rz+48+1c2vuuyBW/q5tcvUTQHVBptsfR6KZj5ZNcyb/SPc0C0aEzZEiuhihJJjWvqhg1 2CKL6bRVhe0+cL9q1+x7VcJ4QVrvTX8CDA3H4sd/4dYDkFZS76C+8JBsGLsCSQYl0N7E M6dQ== X-Gm-Message-State: ABy/qLblUJ0Soldj0+qZBUCNNV0nbbU/lS3Wm+hlgBnH62EWd7MBOMji 1AZYbjm/9qa8JL0GcbLqUdoN26CRKOhI1AmSzqSqEQ== X-Received: by 2002:a05:600c:378d:b0:3fc:e1:24b5 with SMTP id o13-20020a05600c378d00b003fc00e124b5mr8770498wmr.23.1689028129812; Mon, 10 Jul 2023 15:28:49 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id 13-20020a05600c228d00b003fbe4cecc3bsm11324921wmf.16.2023.07.10.15.28.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 29/44] target/mips/mxu: Add Q16SLL Q16SLR Q16SAR instructions Date: Tue, 11 Jul 2023 00:25:56 +0200 Message-Id: <20230710222611.50978-30-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are same data shift in various directions, thus one generation function is implemented for all three. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-27-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 79263e97c3..672b0041b5 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -398,6 +398,9 @@ enum { OPC_MXU_D32SLR = 0x31, OPC_MXU_D32SARL = 0x32, OPC_MXU_D32SAR = 0x33, + OPC_MXU_Q16SLL = 0x34, + OPC_MXU_Q16SLR = 0x35, + OPC_MXU_Q16SAR = 0x37, OPC_MXU__POOL19 = 0x38, }; @@ -1789,6 +1792,72 @@ static void gen_mxu_d32sarl(DisasContext *ctx, bool sarw) } } +/* + * Q16SLL XRa, XRd, XRb, XRc, SFT4 + * Quad 16-bit shift left from XRb and XRc to SFT4 + * bits (0..15). Store to XRa and XRd respectively. + * Q16SLR XRa, XRd, XRb, XRc, SFT4 + * Quad 16-bit shift logic right from XRb and XRc + * to SFT4 bits (0..15). Store to XRa and XRd respectively. + * Q16SAR XRa, XRd, XRb, XRc, SFT4 + * Quad 16-bit shift arithmetic right from XRb and XRc + * to SFT4 bits (0..15). Store to XRa and XRd respectively. + */ +static void gen_mxu_q16sxx(DisasContext *ctx, bool right, bool arithmetic) +{ + uint32_t XRa, XRb, XRc, XRd, sft4; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRd = extract32(ctx->opcode, 18, 4); + sft4 = extract32(ctx->opcode, 22, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t2, XRc); + + if (arithmetic) { + tcg_gen_sextract_tl(t1, t0, 16, 16); + tcg_gen_sextract_tl(t0, t0, 0, 16); + tcg_gen_sextract_tl(t3, t2, 16, 16); + tcg_gen_sextract_tl(t2, t2, 0, 16); + } else { + tcg_gen_extract_tl(t1, t0, 16, 16); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_extract_tl(t3, t2, 16, 16); + tcg_gen_extract_tl(t2, t2, 0, 16); + } + + if (right) { + if (arithmetic) { + tcg_gen_sari_tl(t0, t0, sft4); + tcg_gen_sari_tl(t1, t1, sft4); + tcg_gen_sari_tl(t2, t2, sft4); + tcg_gen_sari_tl(t3, t3, sft4); + } else { + tcg_gen_shri_tl(t0, t0, sft4); + tcg_gen_shri_tl(t1, t1, sft4); + tcg_gen_shri_tl(t2, t2, sft4); + tcg_gen_shri_tl(t3, t3, sft4); + } + } else { + tcg_gen_shli_tl(t0, t0, sft4); + tcg_gen_shli_tl(t1, t1, sft4); + tcg_gen_shli_tl(t2, t2, sft4); + tcg_gen_shli_tl(t3, t3, sft4); + } + tcg_gen_deposit_tl(t0, t0, t1, 16, 16); + tcg_gen_deposit_tl(t2, t2, t3, 16, 16); + + gen_store_mxu_gpr(t0, XRa); + gen_store_mxu_gpr(t2, XRd); +} + /* * MXU instruction category max/min/avg * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -4328,6 +4397,15 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_D32SAR: gen_mxu_d32sxx(ctx, true, true); break; + case OPC_MXU_Q16SLL: + gen_mxu_q16sxx(ctx, false, false); + break; + case OPC_MXU_Q16SLR: + gen_mxu_q16sxx(ctx, true, false); + break; + case OPC_MXU_Q16SAR: + gen_mxu_q16sxx(ctx, true, true); + break; case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; From patchwork Mon Jul 10 22:25:57 2023 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: 701078 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410366wrs; Mon, 10 Jul 2023 15:31:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9IGrsoynaPonynk+U2JY8aCxy8cTDb5VEi1KYzzoRBJF2BVu5ZV0bCRL7G5nxPXZi0EBW X-Received: by 2002:a05:622a:205:b0:3fe:3074:64bc with SMTP id b5-20020a05622a020500b003fe307464bcmr19701045qtx.10.1689028282679; Mon, 10 Jul 2023 15:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028282; cv=none; d=google.com; s=arc-20160816; b=nP0U5mAqG8bXYSKlxF9rGefeehwTAYDMVdHDLB1uoeihttWmSYpKmFYOE9+UdAG+TY lgwPw/HD32Ly2Zj5Kp/OL6I5Tp8+rpwRMQXtfipnaM4PQwD3Qo9NKgXXWoZyznTNymqO mw/++75UztiwlfUoMUCVU32FNXjBtOi6blKIhsVwxOm7subRD+g1Mq0+HnDanQjcsWvr h4C0Quippoyfv+m3aCadraORifDMFRP73pe0lApqvVRROVtLWbYjkGGnmxb0JeNXXJ73 sGsE6qvFW+6zO3jWH2UpUKtNa5wjn6K7hg+mJthEBUjVihOY0XdfqdRG9Dfbs9VjBXlT fMUA== 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=vYeMIHzHX1cHcnWJO9AChRg0C7l8GR/aS1YwDn2EvQs=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=pWKieYChZf1r7OgWJN2QNTjXZR2WTY4XKXB5z3pRMDrxXc65oOKPfHHNlw/ncrdKvz EsXo9TQiBRi4TkcPYkpIH6d51RP1+GpqCiEjkwzz0VLGQuITtn9g29zLt5F1ewErFRqJ onc07YGxgiy/WGZ1vJ12/8g0BbFwQjapWqrP8HPugjgrJZmu2ZbGYY7WFlLnoTJaKwKE 22W4sjeYMGGkSJaL2XrumRCzJatYddZD0TZA2MMWPUEfubwPlSeRLAWxemdMYMCfdTv5 Zs1gPJRatQ4y6OQtb+u8pu0wJSimWtyOb0nDPTM5XeEE5wrTTh9vnaw5Kk80gFE2Y7jM iu/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oivgdqHO; 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 i20-20020a0cf494000000b006287044a477si253736qvm.227.2023.07.10.15.31.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:22 -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=oivgdqHO; 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 1qIzNM-0002HR-IU; Mon, 10 Jul 2023 18:29:00 -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 1qIzNK-0002Ex-G0 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:58 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNI-00024w-IH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:28:58 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fbc5d5746cso57974525e9.2 for ; Mon, 10 Jul 2023 15:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028135; x=1691620135; 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=vYeMIHzHX1cHcnWJO9AChRg0C7l8GR/aS1YwDn2EvQs=; b=oivgdqHOnuuHbcxanvFuHsTbFHL3Pb62/ONsHxgM/K/RFgQmg9iIUV3oKWhzgQ9VTs jLe2H7vwZ0xVu0C1joldFU8wGpGeMo8T5BuawYsAYamS6/jn5g66in8tq91v3QDQz7Xd GRf5FnGvtx6x4oDFShvA2pgUX1ojq4otaFRFqIdc4yKz43mcHQDTaqDatfxnEz3+NUm4 UeB+0wQOXmsdiD3esjOxd6sFIiH1FY2ggYXaE4jC/ukDFw+L7hLCrSxtl0qkr4R8T6xx uGN3DuxPzcjw3RszYzwnhYmCQTSDdRAuzeV16aw0k2P9Qh+vapBycj67DO1KOMN5DPJE G3GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028135; x=1691620135; 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=vYeMIHzHX1cHcnWJO9AChRg0C7l8GR/aS1YwDn2EvQs=; b=YYvztORuvmDwVelNu/h/dvdlppqRh2vBaxnUZU+4ExcIkAKrAxsVQ8XP2cmO0j6U6M u/iQDvBMSHQFlpj+IGYBr6rpwOQzIIKCzwsm8vQZyhCWvXeumq8tpAQQELQi70xE9b0h SGYH0ree2SUgovhGDavcqAH8C/FrfxnppWXkh3Mu/06xGiPY+j/Ann5XwjIBmvAo/FZh hAF6xRDUWJCgHtkcgvwIQb5Z/K7s0iB7JzPqBbAvWqNlEFr0R7F2INV7JgO3YhdVm+n5 VMFAgXjqeLqOj/P87gi6kOaGpy5Dvo9tC3RZSVFVcoCiYCAL3JDrv3WzP9Pk9WAmxlXJ bkxw== X-Gm-Message-State: ABy/qLYAMwEk5ylbied5LRuPS0cIDzLyQhS7WRiOsBTyWl1n8YqBN1YG CFSpS5m5wb966TLwj1yhP7lxaNLsKSulBFIivZb9KA== X-Received: by 2002:a05:600c:251:b0:3fb:e4ce:cc7a with SMTP id 17-20020a05600c025100b003fbe4cecc7amr13536246wmj.0.1689028134920; Mon, 10 Jul 2023 15:28:54 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id p6-20020a7bcc86000000b003fa95890484sm890875wma.20.2023.07.10.15.28.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 30/44] target/mips/mxu: Add D32/Q16- SLLV/SLRV/SARV instructions Date: Tue, 11 Jul 2023 00:25:57 +0200 Message-Id: <20230710222611.50978-31-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are counterparts for D32/Q16-SLL/SLR/SAR with difference that the shift amount placed into GPR. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-28-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 166 +++++++++++++++++++++++++++++++- 1 file changed, 162 insertions(+), 4 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 672b0041b5..32fc236d87 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -318,10 +318,10 @@ * ├─ 110001 ─ OPC_MXU_D32SLR 20..18 * ├─ 110010 ─ OPC_MXU_D32SARL ┌─ 000 ─ OPC_MXU_D32SLLV * ├─ 110011 ─ OPC_MXU_D32SAR ├─ 001 ─ OPC_MXU_D32SLRV - * ├─ 110100 ─ OPC_MXU_Q16SLL ├─ 010 ─ OPC_MXU_D32SARV - * ├─ 110101 ─ OPC_MXU_Q16SLR ├─ 011 ─ OPC_MXU_Q16SLLV - * │ ├─ 100 ─ OPC_MXU_Q16SLRV - * ├─ 110110 ─ OPC_MXU__POOL18 ─┴─ 101 ─ OPC_MXU_Q16SARV + * ├─ 110100 ─ OPC_MXU_Q16SLL ├─ 011 ─ OPC_MXU_D32SARV + * ├─ 110101 ─ OPC_MXU_Q16SLR ├─ 100 ─ OPC_MXU_Q16SLLV + * │ ├─ 101 ─ OPC_MXU_Q16SLRV + * ├─ 110110 ─ OPC_MXU__POOL18 ─┴─ 111 ─ OPC_MXU_Q16SARV * │ * ├─ 110111 ─ OPC_MXU_Q16SAR * │ 23..22 @@ -400,6 +400,7 @@ enum { OPC_MXU_D32SAR = 0x33, OPC_MXU_Q16SLL = 0x34, OPC_MXU_Q16SLR = 0x35, + OPC_MXU__POOL18 = 0x36, OPC_MXU_Q16SAR = 0x37, OPC_MXU__POOL19 = 0x38, }; @@ -520,6 +521,18 @@ enum { OPC_MXU_LXHU = 0x05, }; +/* + * MXU pool 18 + */ +enum { + OPC_MXU_D32SLLV = 0x00, + OPC_MXU_D32SLRV = 0x01, + OPC_MXU_D32SARV = 0x03, + OPC_MXU_Q16SLLV = 0x04, + OPC_MXU_Q16SLRV = 0x05, + OPC_MXU_Q16SARV = 0x07, +}; + /* * MXU pool 19 */ @@ -1750,6 +1763,50 @@ static void gen_mxu_d32sxx(DisasContext *ctx, bool right, bool arithmetic) gen_store_mxu_gpr(t1, XRd); } +/* + * D32SLLV XRa, XRd, rs + * Dual 32-bit shift left from XRa and XRd to rs[3:0] + * bits. Store back to XRa and XRd respectively. + * D32SLRV XRa, XRd, rs + * Dual 32-bit shift logic right from XRa and XRd to rs[3:0] + * bits. Store back to XRa and XRd respectively. + * D32SARV XRa, XRd, rs + * Dual 32-bit shift arithmetic right from XRa and XRd to rs[3:0] + * bits. Store back to XRa and XRd respectively. + */ +static void gen_mxu_d32sxxv(DisasContext *ctx, bool right, bool arithmetic) +{ + uint32_t XRa, XRd, rs; + + XRa = extract32(ctx->opcode, 10, 4); + XRd = extract32(ctx->opcode, 14, 4); + rs = extract32(ctx->opcode, 21, 5); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRa); + gen_load_mxu_gpr(t1, XRd); + gen_load_gpr(t2, rs); + tcg_gen_andi_tl(t2, t2, 0x0f); + + if (right) { + if (arithmetic) { + tcg_gen_sar_tl(t0, t0, t2); + tcg_gen_sar_tl(t1, t1, t2); + } else { + tcg_gen_shr_tl(t0, t0, t2); + tcg_gen_shr_tl(t1, t1, t2); + } + } else { + tcg_gen_shl_tl(t0, t0, t2); + tcg_gen_shl_tl(t1, t1, t2); + } + gen_store_mxu_gpr(t0, XRa); + gen_store_mxu_gpr(t1, XRd); +} + /* * D32SARL XRa, XRb, XRc, SFT4 * Dual shift arithmetic right 32-bit integers in XRb and XRc @@ -1858,6 +1915,74 @@ static void gen_mxu_q16sxx(DisasContext *ctx, bool right, bool arithmetic) gen_store_mxu_gpr(t2, XRd); } +/* + * Q16SLLV XRa, XRd, rs + * Quad 16-bit shift left from XRa and XRd to rs[3:0] + * bits. Store to XRa and XRd respectively. + * Q16SLRV XRa, XRd, rs + * Quad 16-bit shift logic right from XRa and XRd to rs[3:0] + * bits. Store to XRa and XRd respectively. + * Q16SARV XRa, XRd, rs + * Quad 16-bit shift arithmetic right from XRa and XRd to rs[3:0] + * bits. Store to XRa and XRd respectively. + */ +static void gen_mxu_q16sxxv(DisasContext *ctx, bool right, bool arithmetic) +{ + uint32_t XRa, XRd, rs; + + XRa = extract32(ctx->opcode, 10, 4); + XRd = extract32(ctx->opcode, 14, 4); + rs = extract32(ctx->opcode, 21, 5); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t5 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRa); + gen_load_mxu_gpr(t2, XRd); + gen_load_gpr(t5, rs); + tcg_gen_andi_tl(t5, t5, 0x0f); + + + if (arithmetic) { + tcg_gen_sextract_tl(t1, t0, 16, 16); + tcg_gen_sextract_tl(t0, t0, 0, 16); + tcg_gen_sextract_tl(t3, t2, 16, 16); + tcg_gen_sextract_tl(t2, t2, 0, 16); + } else { + tcg_gen_extract_tl(t1, t0, 16, 16); + tcg_gen_extract_tl(t0, t0, 0, 16); + tcg_gen_extract_tl(t3, t2, 16, 16); + tcg_gen_extract_tl(t2, t2, 0, 16); + } + + if (right) { + if (arithmetic) { + tcg_gen_sar_tl(t0, t0, t5); + tcg_gen_sar_tl(t1, t1, t5); + tcg_gen_sar_tl(t2, t2, t5); + tcg_gen_sar_tl(t3, t3, t5); + } else { + tcg_gen_shr_tl(t0, t0, t5); + tcg_gen_shr_tl(t1, t1, t5); + tcg_gen_shr_tl(t2, t2, t5); + tcg_gen_shr_tl(t3, t3, t5); + } + } else { + tcg_gen_shl_tl(t0, t0, t5); + tcg_gen_shl_tl(t1, t1, t5); + tcg_gen_shl_tl(t2, t2, t5); + tcg_gen_shl_tl(t3, t3, t5); + } + tcg_gen_deposit_tl(t0, t0, t1, 16, 16); + tcg_gen_deposit_tl(t2, t2, t3, 16, 16); + + gen_store_mxu_gpr(t0, XRa); + gen_store_mxu_gpr(t2, XRd); +} + /* * MXU instruction category max/min/avg * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -4236,6 +4361,36 @@ static void decode_opc_mxu__pool17(DisasContext *ctx) } } +static void decode_opc_mxu__pool18(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 18, 3); + + switch (opcode) { + case OPC_MXU_D32SLLV: + gen_mxu_d32sxxv(ctx, false, false); + break; + case OPC_MXU_D32SLRV: + gen_mxu_d32sxxv(ctx, true, false); + break; + case OPC_MXU_D32SARV: + gen_mxu_d32sxxv(ctx, true, true); + break; + case OPC_MXU_Q16SLLV: + gen_mxu_q16sxxv(ctx, false, false); + break; + case OPC_MXU_Q16SLRV: + gen_mxu_q16sxxv(ctx, true, false); + break; + case OPC_MXU_Q16SARV: + gen_mxu_q16sxxv(ctx, true, true); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + static void decode_opc_mxu__pool19(DisasContext *ctx) { uint32_t opcode = extract32(ctx->opcode, 22, 2); @@ -4400,6 +4555,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_Q16SLL: gen_mxu_q16sxx(ctx, false, false); break; + case OPC_MXU__POOL18: + decode_opc_mxu__pool18(ctx); + break; case OPC_MXU_Q16SLR: gen_mxu_q16sxx(ctx, true, false); break; From patchwork Mon Jul 10 22:25:58 2023 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: 701075 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410311wrs; Mon, 10 Jul 2023 15:31:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFhMxZEMcq9HyAks+CU+N+ylaEUkcKoQ5hd26bBcjvtV/K8qzcN8tbCiUrVsqYGlQlRCztC X-Received: by 2002:a05:622a:1a83:b0:402:6c1d:f249 with SMTP id s3-20020a05622a1a8300b004026c1df249mr15495902qtc.5.1689028273910; Mon, 10 Jul 2023 15:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028273; cv=none; d=google.com; s=arc-20160816; b=aXyjdmhLMSvCi/UV3LobftZABFnRpZQeHwq6M19ShigN+L/eZFmuduL2LCBGdQey+w D1ZqIUZl8Pszd7TaNaumuv1WthSr0gm4ORjucNZBHmbeQwKcSMBjHYc+362mXRJ/Kczq 1kL+1k+6oRFVBtuJtrotfue6G9qzzDXYf9c1dHjYX5gVFeWtHMYoLzdoThkKlW48ECkK EtQ+jeoQjLuUEjMIQtP3pcoY2ari3HSpnPcSIrvhUmw+SkkQm9PKi8HHkZSn40wzdp4S IHEEDPwIMetTM0h2shNQoHrFbEDYk9A10vkcf0Ge43l3HodVIKkbb1F7Z1vNSaV5hGHN 2hYA== 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=euQhAQvXbEs7j0sguxx0MdXawuSdWHEUZ1wzSe2fcO4=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=eMxxrBv57ggBK4sul27uvLR1aMsT8vdJOLwarlM5Mxw631sHACqP6NsCd/SEWUaBjM TN+oxC/iyY1zfjb7vZErxoJYOUN9vhCC9kFSC2xba82MAJrAG/mlzqRrihr6PrxHkV9a f/JUVleGqHKV30EGV9I9UhDo9CqtvtSnTmji6F0xsCjQILmcMy9hhFM0jsYhDSUpQAFm 3Q4/wX/74ByTYOwA2X8SpUKHoL2UyrLHJsah6hfLd8WlQZPS6Yzcna1VDHoLG/xXOYYq iAgQpxxUyzJmzduuC7+CnV7rfhweDdiWjimjvbTwamynY1JdK9AhTfIHwwZEg2FtWjyi b3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=es+bfiED; 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 l6-20020a05622a050600b003f683dbaaeasi319119qtx.341.2023.07.10.15.31.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:13 -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=es+bfiED; 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 1qIzNa-0002ph-79; Mon, 10 Jul 2023 18:29:14 -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 1qIzNT-0002XH-Nt for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:08 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNO-00025N-1m for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:06 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fbc12181b6so56030375e9.2 for ; Mon, 10 Jul 2023 15:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028140; x=1691620140; 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=euQhAQvXbEs7j0sguxx0MdXawuSdWHEUZ1wzSe2fcO4=; b=es+bfiEDvv3SAnV/ZY6MlOVd+vm2AfisOdccq+RjzMiXfmy72Dw7F+nbgWbV+Qvps1 8K9MMK1KsQz5pd634d8wld2sHbRc1+jceUl2uDoOK6z+EHA5LMsopf4zyAtMl3bjvCE/ Gncju3pTinWbE22GOKWgkifwaTcX88ANdt2N+zLs51VHBosfrFi/C5iTNfkhFAcLaZ5G 39pSZTk//bLKKfxE8slmndSE7uTy+jnGkxIdZ9lHUT0hZh/aOMewbnOKuIMkVvQ4CzIf 0f86VrNV9giYv/AFbo7nU2Tgb4tBFnf8CV6Hr3/SlyVeco36BVKisyiEvr20OCL7Xqbu hXiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028140; x=1691620140; 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=euQhAQvXbEs7j0sguxx0MdXawuSdWHEUZ1wzSe2fcO4=; b=M3+nhyUQEZszwoGmvz/gsIOS5RLqN52owWmZ8WLZt5d24qpdAnxMdwMvnOqhPyUwPz SwVhNJE9mWTuQkOSVLj5thRajpedB2Ed9DZ78J6R68FQ779HiZ7EQNBKqeXsj8p6fdmj Skpht2EqqMW1Kni8f2nQ6toNBYdzFuBomvC/DlXqvU+fnSsBCM3PobA7b3xkl6AB+SOd 5YG3WiqVkFgaPqwhf97VBK6WvLXWe8y1JI75XXWG6N/yMZvJYE2gfkZIUkgmYRKQV7uV hJS5mnSToKjipAjXun/Zb+dcovsl2JpzRX8WL5KTx2n/4DVZDXLKCH5SxEBsypqAy2pF 8dgg== X-Gm-Message-State: ABy/qLY5+ljl3R1GFzOe9lX6ltVoVx5NyEgGGP9tQTNR9VdKOD+YLKKj C5pJbAxuRtAbyMeORXeLg7RVmPpAls5zRh11DkQsgg== X-Received: by 2002:a7b:cd8e:0:b0:3f9:b9e7:2f8d with SMTP id y14-20020a7bcd8e000000b003f9b9e72f8dmr12554446wmj.2.1689028140162; Mon, 10 Jul 2023 15:29:00 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id 11-20020a05600c230b00b003fbaade0735sm11295211wmo.19.2023.07.10.15.28.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:28:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 31/44] target/mips/mxu: Add S32/D16/Q8- MOVZ/MOVN instructions Date: Tue, 11 Jul 2023 00:25:58 +0200 Message-Id: <20230710222611.50978-32-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions are: - single 32-bit - dual 16-bit packed - quad 8-bit packed conditional moves. They are grouped in pool20 in the source code. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-29-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 188 ++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 32fc236d87..f8c3fdb103 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -403,6 +403,7 @@ enum { OPC_MXU__POOL18 = 0x36, OPC_MXU_Q16SAR = 0x37, OPC_MXU__POOL19 = 0x38, + OPC_MXU__POOL20 = 0x39, }; @@ -541,6 +542,18 @@ enum { OPC_MXU_Q8MULSU = 0x01, }; +/* + * MXU pool 20 + */ +enum { + OPC_MXU_Q8MOVZ = 0x00, + OPC_MXU_Q8MOVN = 0x01, + OPC_MXU_D16MOVZ = 0x02, + OPC_MXU_D16MOVN = 0x03, + OPC_MXU_S32MOVZ = 0x04, + OPC_MXU_S32MOVN = 0x05, +}; + /* MXU accumulate add/subtract 1-bit pattern 'aptn1' */ #define MXU_APTN1_A 0 #define MXU_APTN1_S 1 @@ -1993,6 +2006,8 @@ static void gen_mxu_q16sxxv(DisasContext *ctx, bool right, bool arithmetic) * Q8SLTU * D16AVG Q8AVG * D16AVGR Q8AVGR + * S32MOVZ D16MOVZ Q8MOVZ + * S32MOVN D16MOVN Q8MOVN */ /* @@ -2491,6 +2506,146 @@ static void gen_mxu_q8avg(DisasContext *ctx, bool round45) } } +/* + * Q8MOVZ + * Quadruple 8-bit packed conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb[0..3] == 0) { XRa[0..3] = XRc[0..3] } + * + * Q8MOVN + * Quadruple 8-bit packed conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb[0..3] != 0) { XRa[0..3] = XRc[0..3] } + */ +static void gen_mxu_q8movzn(DisasContext *ctx, TCGCond cond) +{ + uint32_t XRc, XRb, XRa; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGLabel *l_quarterdone = gen_new_label(); + TCGLabel *l_halfdone = gen_new_label(); + TCGLabel *l_quarterrest = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + gen_load_mxu_gpr(t0, XRc); + gen_load_mxu_gpr(t1, XRb); + gen_load_mxu_gpr(t2, XRa); + + tcg_gen_extract_tl(t3, t1, 24, 8); + tcg_gen_brcondi_tl(cond, t3, 0, l_quarterdone); + tcg_gen_extract_tl(t3, t0, 24, 8); + tcg_gen_deposit_tl(t2, t2, t3, 24, 8); + + gen_set_label(l_quarterdone); + tcg_gen_extract_tl(t3, t1, 16, 8); + tcg_gen_brcondi_tl(cond, t3, 0, l_halfdone); + tcg_gen_extract_tl(t3, t0, 16, 8); + tcg_gen_deposit_tl(t2, t2, t3, 16, 8); + + gen_set_label(l_halfdone); + tcg_gen_extract_tl(t3, t1, 8, 8); + tcg_gen_brcondi_tl(cond, t3, 0, l_quarterrest); + tcg_gen_extract_tl(t3, t0, 8, 8); + tcg_gen_deposit_tl(t2, t2, t3, 8, 8); + + gen_set_label(l_quarterrest); + tcg_gen_extract_tl(t3, t1, 0, 8); + tcg_gen_brcondi_tl(cond, t3, 0, l_done); + tcg_gen_extract_tl(t3, t0, 0, 8); + tcg_gen_deposit_tl(t2, t2, t3, 0, 8); + + gen_set_label(l_done); + gen_store_mxu_gpr(t2, XRa); +} + +/* + * D16MOVZ + * Double 16-bit packed conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb[0..1] == 0) { XRa[0..1] = XRc[0..1] } + * + * D16MOVN + * Double 16-bit packed conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb[0..3] != 0) { XRa[0..1] = XRc[0..1] } + */ +static void gen_mxu_d16movzn(DisasContext *ctx, TCGCond cond) +{ + uint32_t XRc, XRb, XRa; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGLabel *l_halfdone = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + gen_load_mxu_gpr(t0, XRc); + gen_load_mxu_gpr(t1, XRb); + gen_load_mxu_gpr(t2, XRa); + + tcg_gen_extract_tl(t3, t1, 16, 16); + tcg_gen_brcondi_tl(cond, t3, 0, l_halfdone); + tcg_gen_extract_tl(t3, t0, 16, 16); + tcg_gen_deposit_tl(t2, t2, t3, 16, 16); + + gen_set_label(l_halfdone); + tcg_gen_extract_tl(t3, t1, 0, 16); + tcg_gen_brcondi_tl(cond, t3, 0, l_done); + tcg_gen_extract_tl(t3, t0, 0, 16); + tcg_gen_deposit_tl(t2, t2, t3, 0, 16); + + gen_set_label(l_done); + gen_store_mxu_gpr(t2, XRa); +} + +/* + * S32MOVZ + * Quadruple 32-bit conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb == 0) { XRa = XRc } + * + * S32MOVN + * Single 32-bit conditional move where + * XRb contains conditions, XRc what to move and + * XRa is the destination. + * a.k.a. if (XRb != 0) { XRa = XRc } + */ +static void gen_mxu_s32movzn(DisasContext *ctx, TCGCond cond) +{ + uint32_t XRc, XRb, XRa; + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGLabel *l_done = gen_new_label(); + + gen_load_mxu_gpr(t0, XRc); + gen_load_mxu_gpr(t1, XRb); + + tcg_gen_brcondi_tl(cond, t1, 0, l_done); + gen_store_mxu_gpr(t0, XRa); + gen_set_label(l_done); +} /* * MXU instruction category: Addition and subtraction @@ -4407,6 +4562,36 @@ static void decode_opc_mxu__pool19(DisasContext *ctx) } } +static void decode_opc_mxu__pool20(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 18, 3); + + switch (opcode) { + case OPC_MXU_Q8MOVZ: + gen_mxu_q8movzn(ctx, TCG_COND_NE); + break; + case OPC_MXU_Q8MOVN: + gen_mxu_q8movzn(ctx, TCG_COND_EQ); + break; + case OPC_MXU_D16MOVZ: + gen_mxu_d16movzn(ctx, TCG_COND_NE); + break; + case OPC_MXU_D16MOVN: + gen_mxu_d16movzn(ctx, TCG_COND_EQ); + break; + case OPC_MXU_S32MOVZ: + gen_mxu_s32movzn(ctx, TCG_COND_NE); + break; + case OPC_MXU_S32MOVN: + gen_mxu_s32movzn(ctx, TCG_COND_EQ); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) { uint32_t opcode = extract32(insn, 0, 6); @@ -4567,6 +4752,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL19: decode_opc_mxu__pool19(ctx); break; + case OPC_MXU__POOL20: + decode_opc_mxu__pool20(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:25:59 2023 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: 701087 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411076wrs; Mon, 10 Jul 2023 15:33:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEF9UrkOwVLnx3E5w+c1nj76gCKud5HjiXXqvAOFlIdC54EvaO+BnQR8BY3Q6AiNXjibaAZ X-Received: by 2002:a05:620a:290d:b0:767:250d:f083 with SMTP id m13-20020a05620a290d00b00767250df083mr15575571qkp.78.1689028397401; Mon, 10 Jul 2023 15:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028397; cv=none; d=google.com; s=arc-20160816; b=mnCAvUkrhMhmC41oU+fodTp/2I73eyhlkXpLWitVGva7c3dZ0SXt/2/kCCR+VDoJU1 gdnjbH0dvUGbvow2NK1w/IQyFik9mlmosYzJrecqeDW9K46MzBFCwB5Lno7bvCLqbTkp VeVDD2zCj5q6GcJqH8UvcRxC3d4krlRDt4p9u66MhFeoRcbIA9L2oBDUgz8kW1tf6pVm hoqMFYRFNOWtDI6Ty0iWYfVEyATfKwWijLjakgIH+BlrLRRkoHiZNoUQyD1Zvo8TtTRR 2j/P/+rV6ykFH3XPNyyGQozk7mLW1WRjZfc5/OadFt5E0dZwsb3dIwnbd0NjjlVLyegW w7fA== 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=jk3TdcHIxqTem2Pjvqcy8oiXG7odaogilZzWv2/mbGk=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=KY4J763hQtEwQjAcnt16jXS1upwdZI+A1q+OGrSbBjjcsKUSfy8MEpkrQvD33AtN0A BDteABuf8/SdaAjcGB9eJYRLS0k03cNgYfbo0HZYTJ9rDmVmNPBmp4iFVM1sf+Sm/nDj 5LEsZ+0fbL1g0vXyW7home2MvHlvjrbSGCXSZpRRCwi3WfuYayI8zlEHGkGvdN+WEl+0 /xqx/pe1k93f+3a8EJrCX9XnmnrazmnbTVyXtqVJx6n77Qml15MYy/F+eJEXxoKniYjw w9njR6hp5MiPDaDMulx7S5rFOLUPEP9sVJNfjI6FXo36wodiSBKKsaiSUqCtTAcf0B7n pQlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wB6aH42l; 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 c12-20020a05620a200c00b007654cff1cbcsi266821qka.530.2023.07.10.15.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:17 -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=wB6aH42l; 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 1qIzNb-00033i-UF; Mon, 10 Jul 2023 18:29:15 -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 1qIzNZ-0002mK-T5 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:13 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNT-00026v-HJ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:11 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbea14700bso51718725e9.3 for ; Mon, 10 Jul 2023 15:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028145; x=1691620145; 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=jk3TdcHIxqTem2Pjvqcy8oiXG7odaogilZzWv2/mbGk=; b=wB6aH42lbBCR25SIIFOUQULdZmvm7BL924ohCj+ImmuRTPR//MqS+DUB8QIhr+KG/D wzf0axyvHpV2Q1VY5dPkKf4CpUOPHD7jWnQQm/QJl+Iqc8qIE/cljBpxcXWTXPutG0dd WkJTg6SqRuRLDNLRLzfc9csrJHqq8NzWoxIVl9LJL9MWibr25yL4+0hQfKAR5v+NiJpp oeUchO9RKhBUjlh6vtiQpcfjIqSWagmK7v8udj71gwmonrZ0yxNeMF5oJYbmYcoZ1mm1 MxzZSyX+M0x/KToosfmK7YA3ShN0K/4WtGK71zk+/VxcdNngLSs+SuxeVper2P5Yx0Sf n9sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028145; x=1691620145; 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=jk3TdcHIxqTem2Pjvqcy8oiXG7odaogilZzWv2/mbGk=; b=G5wB8B7i/4/5sewQFIfwJSj1nCAn2M5RIaW7BkZi2jy4t1LvyyNLVGoKEQumrNE+hz ZqI6vsvN6G1B/63kaNNEoig7IqzqQPnb5GIkkyZQBqwMEgi4R/9+Fp1xWhH8t/GpaAij JxK2JbUn7OQJXWOoPOkUYWh7Te3BtAQuEe0bokwllj1WLWKm75x5A3RgnlAFE2bUz7O9 HcQb0AIiyMVi4G44BRvvoQTWQVhIe+Qks/y4yKyP7hObuiwJ5lWuaOTPrXXD10rh9MWa fvrmIzRqs/CocVU6oZoC7LF1VB2LPmoVKE/oUJp9x3+OUi1wt3BmuvAHRcNVxsRjPLE/ lqmA== X-Gm-Message-State: ABy/qLbch3Vq7vxvJoMLLlne2GSogAmO4atqjhV2mkUfQnhPmnIN+xJQ qp90JM0kn/om+1Fsod0SPCLt13UD/q3nnQRIsjxbbA== X-Received: by 2002:a7b:c019:0:b0:3fb:a62d:1992 with SMTP id c25-20020a7bc019000000b003fba62d1992mr10725914wmb.0.1689028145282; Mon, 10 Jul 2023 15:29:05 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id z9-20020a1c4c09000000b003fa74bff02asm884601wmf.26.2023.07.10.15.29.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 32/44] target/mips/mxu: Add Q8MAC Q8MACSU instructions Date: Tue, 11 Jul 2023 00:25:59 +0200 Message-Id: <20230710222611.50978-33-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau These instructions do parallel quad 8-bit multiply and accumulate. They are close to existing Q8MUL Q8MULSU so the generation function modified to support all of them. Also the patch fixes decoding of Q8MULSU according to tests on hardware. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-30-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 128 +++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 42 deletions(-) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index f8c3fdb103..6a82849ef7 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -326,7 +326,7 @@ * ├─ 110111 ─ OPC_MXU_Q16SAR * │ 23..22 * ├─ 111000 ─ OPC_MXU__POOL19 ─┬─ 00 ─ OPC_MXU_Q8MUL - * │ └─ 01 ─ OPC_MXU_Q8MULSU + * │ └─ 10 ─ OPC_MXU_Q8MULSU * │ * │ 20..18 * ├─ 111001 ─ OPC_MXU__POOL20 ─┬─ 000 ─ OPC_MXU_Q8MOVZ @@ -404,6 +404,7 @@ enum { OPC_MXU_Q16SAR = 0x37, OPC_MXU__POOL19 = 0x38, OPC_MXU__POOL20 = 0x39, + OPC_MXU__POOL21 = 0x3A, }; @@ -539,7 +540,7 @@ enum { */ enum { OPC_MXU_Q8MUL = 0x00, - OPC_MXU_Q8MULSU = 0x01, + OPC_MXU_Q8MULSU = 0x02, }; /* @@ -554,6 +555,15 @@ enum { OPC_MXU_S32MOVN = 0x05, }; +/* + * MXU pool 21 + */ +enum { + OPC_MXU_Q8MAC = 0x00, + OPC_MXU_Q8MACSU = 0x02, +}; + + /* MXU accumulate add/subtract 1-bit pattern 'aptn1' */ #define MXU_APTN1_A 0 #define MXU_APTN1_S 1 @@ -1328,13 +1338,17 @@ static void gen_mxu_s16mad(DisasContext *ctx) } /* - * Q8MUL XRa, XRb, XRc, XRd - Parallel unsigned 8 bit pattern multiply - * Q8MULSU XRa, XRb, XRc, XRd - Parallel signed 8 bit pattern multiply + * Q8MUL XRa, XRb, XRc, XRd - Parallel quad unsigned 8 bit multiply + * Q8MULSU XRa, XRb, XRc, XRd - Parallel quad signed 8 bit multiply + * Q8MAC XRa, XRb, XRc, XRd - Parallel quad unsigned 8 bit multiply + * and accumulate + * Q8MACSU XRa, XRb, XRc, XRd - Parallel quad signed 8 bit multiply + * and accumulate */ -static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx) +static void gen_mxu_q8mul_mac(DisasContext *ctx, bool su, bool mac) { TCGv t0, t1, t2, t3, t4, t5, t6, t7; - uint32_t XRa, XRb, XRc, XRd, sel; + uint32_t XRa, XRb, XRc, XRd, aptn2; t0 = tcg_temp_new(); t1 = tcg_temp_new(); @@ -1349,54 +1363,60 @@ static void gen_mxu_q8mul_q8mulsu(DisasContext *ctx) XRb = extract32(ctx->opcode, 10, 4); XRc = extract32(ctx->opcode, 14, 4); XRd = extract32(ctx->opcode, 18, 4); - sel = extract32(ctx->opcode, 22, 2); + aptn2 = extract32(ctx->opcode, 24, 2); gen_load_mxu_gpr(t3, XRb); gen_load_mxu_gpr(t7, XRc); - if (sel == 0x2) { - /* Q8MULSU */ - tcg_gen_ext8s_tl(t0, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8s_tl(t1, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8s_tl(t2, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8s_tl(t3, t3); + if (su) { + /* Q8MULSU / Q8MACSU */ + tcg_gen_sextract_tl(t0, t3, 0, 8); + tcg_gen_sextract_tl(t1, t3, 8, 8); + tcg_gen_sextract_tl(t2, t3, 16, 8); + tcg_gen_sextract_tl(t3, t3, 24, 8); } else { - /* Q8MUL */ - tcg_gen_ext8u_tl(t0, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8u_tl(t1, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8u_tl(t2, t3); - tcg_gen_shri_tl(t3, t3, 8); - tcg_gen_ext8u_tl(t3, t3); + /* Q8MUL / Q8MAC */ + tcg_gen_extract_tl(t0, t3, 0, 8); + tcg_gen_extract_tl(t1, t3, 8, 8); + tcg_gen_extract_tl(t2, t3, 16, 8); + tcg_gen_extract_tl(t3, t3, 24, 8); } - tcg_gen_ext8u_tl(t4, t7); - tcg_gen_shri_tl(t7, t7, 8); - tcg_gen_ext8u_tl(t5, t7); - tcg_gen_shri_tl(t7, t7, 8); - tcg_gen_ext8u_tl(t6, t7); - tcg_gen_shri_tl(t7, t7, 8); - tcg_gen_ext8u_tl(t7, t7); + tcg_gen_extract_tl(t4, t7, 0, 8); + tcg_gen_extract_tl(t5, t7, 8, 8); + tcg_gen_extract_tl(t6, t7, 16, 8); + tcg_gen_extract_tl(t7, t7, 24, 8); tcg_gen_mul_tl(t0, t0, t4); tcg_gen_mul_tl(t1, t1, t5); tcg_gen_mul_tl(t2, t2, t6); tcg_gen_mul_tl(t3, t3, t7); - tcg_gen_andi_tl(t0, t0, 0xFFFF); - tcg_gen_andi_tl(t1, t1, 0xFFFF); - tcg_gen_andi_tl(t2, t2, 0xFFFF); - tcg_gen_andi_tl(t3, t3, 0xFFFF); + if (mac) { + gen_load_mxu_gpr(t4, XRd); + gen_load_mxu_gpr(t5, XRa); + tcg_gen_extract_tl(t6, t4, 0, 16); + tcg_gen_extract_tl(t7, t4, 16, 16); + if (aptn2 & 1) { + tcg_gen_sub_tl(t0, t6, t0); + tcg_gen_sub_tl(t1, t7, t1); + } else { + tcg_gen_add_tl(t0, t6, t0); + tcg_gen_add_tl(t1, t7, t1); + } + tcg_gen_extract_tl(t6, t5, 0, 16); + tcg_gen_extract_tl(t7, t5, 16, 16); + if (aptn2 & 2) { + tcg_gen_sub_tl(t2, t6, t2); + tcg_gen_sub_tl(t3, t7, t3); + } else { + tcg_gen_add_tl(t2, t6, t2); + tcg_gen_add_tl(t3, t7, t3); + } + } - tcg_gen_shli_tl(t1, t1, 16); - tcg_gen_shli_tl(t3, t3, 16); - - tcg_gen_or_tl(t0, t0, t1); - tcg_gen_or_tl(t1, t2, t3); + tcg_gen_deposit_tl(t0, t0, t1, 16, 16); + tcg_gen_deposit_tl(t1, t2, t3, 16, 16); gen_store_mxu_gpr(t0, XRd); gen_store_mxu_gpr(t1, XRa); @@ -4548,12 +4568,14 @@ static void decode_opc_mxu__pool18(DisasContext *ctx) static void decode_opc_mxu__pool19(DisasContext *ctx) { - uint32_t opcode = extract32(ctx->opcode, 22, 2); + uint32_t opcode = extract32(ctx->opcode, 22, 4); switch (opcode) { case OPC_MXU_Q8MUL: + gen_mxu_q8mul_mac(ctx, false, false); + break; case OPC_MXU_Q8MULSU: - gen_mxu_q8mul_q8mulsu(ctx); + gen_mxu_q8mul_mac(ctx, true, false); break; default: MIPS_INVAL("decode_opc_mxu"); @@ -4592,6 +4614,25 @@ static void decode_opc_mxu__pool20(DisasContext *ctx) } } +static void decode_opc_mxu__pool21(DisasContext *ctx) +{ + uint32_t opcode = extract32(ctx->opcode, 22, 2); + + switch (opcode) { + case OPC_MXU_Q8MAC: + gen_mxu_q8mul_mac(ctx, false, true); + break; + case OPC_MXU_Q8MACSU: + gen_mxu_q8mul_mac(ctx, true, true); + break; + default: + MIPS_INVAL("decode_opc_mxu"); + gen_reserved_instruction(ctx); + break; + } +} + + bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) { uint32_t opcode = extract32(insn, 0, 6); @@ -4755,6 +4796,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL20: decode_opc_mxu__pool20(ctx); break; + case OPC_MXU__POOL21: + decode_opc_mxu__pool21(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:26:00 2023 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: 701086 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410691wrs; Mon, 10 Jul 2023 15:32:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlELg9zXaT3tINeS29/mlJzxOHdJ+vpVx9P5GmmLtobTKh+In8WQx6mJ0kVdlvpuQeB94Vlx X-Received: by 2002:a0c:e153:0:b0:634:d868:f0f7 with SMTP id c19-20020a0ce153000000b00634d868f0f7mr12107256qvl.60.1689028338488; Mon, 10 Jul 2023 15:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028338; cv=none; d=google.com; s=arc-20160816; b=B+U2OXijdUskspGvJTThnQ+Qzow2oCBVR/AJQITsxqQC1zFPAVjVnWSGUi0ohhjeT5 AKQdg6pqbLyu2SwzyX2Oh1Qh15SMYSd6aaCJw5U8r28RGlPW6eq5C2GU9MYhHAOd6G/L WYytppAWnyr35R+IUD7p9zl8m61YWtVJDnx+t4iR1XDLGOPt0EjMVKpcX8MWCzQe2Da4 CUmqSNvjA1nE2cl0eN0uU85MHLMkQfJiZI1+qCBoTFEIAP0FjQCTz1Lhkoh0tP5aiRC1 QdVl2cdkA8aM6Wt8/a+qRMQ+peyct7DX///CDVDWQj0lnHJqATwdAlQ05hllYQ6OOg4D zZTQ== 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=aMSCVh+rYmfl+WvzT2g9sfMjvqMygJA4VscuqXPupYg=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=yJjH8TxU2TAgTojtps8VK/1K7hneFOMGS+istkrF4wagKzwgV+0CkN3QCuvCyYSHwo r/8iQ9EGOH0Q0+ItjWZqFOP3b5Tm5bDKVDBXYj0nbZy34Kn5juz9pEkOU9hY0aQm7XJK saU7EfZuA8oy9HyZ+ASGGVViqVL+TrK+DwJIOkxQJ6vkSZONoBE/lY0I6jM2R7cW2b/2 ahUDkBxOs5Xosz9x2sXYKPAojkYWokMjfrgLaLdYdsTHmsi6SrKUqKNcNJaXM38EE5dd vUUi7maHc6N+Tq18xwU7hTKlRcMTE+EOM7x9WjtbaSsZ+hLRm66y4NcsW9w4Vt0tilo9 Ln/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xiiZ+Rta; 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 h12-20020a0cf44c000000b00636a496bba8si264089qvm.129.2023.07.10.15.32.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:32:18 -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=xiiZ+Rta; 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 1qIzNd-0003An-F5; Mon, 10 Jul 2023 18:29:17 -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 1qIzNb-00031C-EP for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:15 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNZ-000284-Kc for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:15 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-314417861b9so5111076f8f.0 for ; Mon, 10 Jul 2023 15:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028150; x=1691620150; 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=aMSCVh+rYmfl+WvzT2g9sfMjvqMygJA4VscuqXPupYg=; b=xiiZ+RtadDtDMnF4Te7Qo0rUKmo6VV1HNRZFqeunAgCDa8iXy5lsfW+3tWoc1ICCxn TJw9R1MwGzOCuMZp/Z/xJYCLEhji6TO+9eyUarrqbKtHWO96SNZz7zKUhYEzWlf3OkhI YGiPWvGS819/jPprGxAzF/fagzf1qHviGpLx8LlbJYe/+2Y15rMbcyut1xZvXnHPt+L1 yQ/nFq8Y6odVs8PVH1IXBAa3wkGnZ+4votIwUvpB1o5px3rAVzZ4YIcFNzomV6m0YXXG zKcXapXAO+sCxhZK/v3dwIqEVksW772WVNiVW/GhvmkMogVOobD3gT/60CLnh77o5mvl r6XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028150; x=1691620150; 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=aMSCVh+rYmfl+WvzT2g9sfMjvqMygJA4VscuqXPupYg=; b=joFf+e5GSAWniw6Xh6w042Ma+uBqzH/g5naS6Mt9qJ7rM2ZDT9gjJqYwfkmvJALUBj Wid+t0VLcL2hOq8efwReX0eqoGst82xfYFjVzUaJ0B7uzqCIFfnLH2BOKom8DeXuZC5V hNXXFD/aPYfmXBgppzCwkFi1sfQqUiR6XWcYE7Q3oj6gYqabJphXaQighUsLdcyfXHya DT5Fpi0d0vB8zj+R+13NiV/KoxD7UnawNsrPpymfN1ZEUPU+dVOTGJeF0DwGRDalgriT aSnm4fDIBCUgDwecmQjmQ3jNttNRn7tOSiUaemD4vSmTnq574in29glw/EzakEJQROGk stdw== X-Gm-Message-State: ABy/qLYqYVWvT/24bq9+JqaJx8xY3U96xRT8VVZ0m7dz54kGXWQEXKEn VugqJdAg+skeHKQy4fZWoxYIH2zyDfi3PoIb398HiQ== X-Received: by 2002:adf:f7d0:0:b0:314:4439:151a with SMTP id a16-20020adff7d0000000b003144439151amr7758881wrq.6.1689028150582; Mon, 10 Jul 2023 15:29:10 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id h3-20020a5d4fc3000000b0031272fced4dsm533312wrw.52.2023.07.10.15.29.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 33/44] target/mips/mxu: Add Q16SCOP instruction Date: Tue, 11 Jul 2023 00:26:00 +0200 Message-Id: <20230710222611.50978-34-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction is used to determine sign of four 16-bit packed data in parallel. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-31-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 6a82849ef7..6945dcb440 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -405,6 +405,7 @@ enum { OPC_MXU__POOL19 = 0x38, OPC_MXU__POOL20 = 0x39, OPC_MXU__POOL21 = 0x3A, + OPC_MXU_Q16SCOP = 0x3B, }; @@ -3539,6 +3540,7 @@ static void gen_mxu_d32asum(DisasContext *ctx) * S32EXTR S32LUI * S32EXTRV * Q16SAT + * Q16SCOP */ /* @@ -3806,6 +3808,86 @@ static void gen_mxu_Q16SAT(DisasContext *ctx) } } +/* + * Q16SCOP XRa, XRd, XRb, XRc + * Determine sign of quad packed 16-bit signed values + * in XRb and XRc put result in XRa and XRd respectively. + */ +static void gen_mxu_q16scop(DisasContext *ctx) +{ + uint32_t XRd, XRc, XRb, XRa; + + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + + TCGLabel *l_b_hi_lt = gen_new_label(); + TCGLabel *l_b_hi_gt = gen_new_label(); + TCGLabel *l_b_lo = gen_new_label(); + TCGLabel *l_b_lo_lt = gen_new_label(); + TCGLabel *l_c_hi = gen_new_label(); + TCGLabel *l_c_hi_lt = gen_new_label(); + TCGLabel *l_c_hi_gt = gen_new_label(); + TCGLabel *l_c_lo = gen_new_label(); + TCGLabel *l_c_lo_lt = gen_new_label(); + TCGLabel *l_done = gen_new_label(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + + tcg_gen_sextract_tl(t2, t0, 16, 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t2, 0, l_b_hi_lt); + tcg_gen_brcondi_tl(TCG_COND_GT, t2, 0, l_b_hi_gt); + tcg_gen_movi_tl(t3, 0); + tcg_gen_br(l_b_lo); + gen_set_label(l_b_hi_lt); + tcg_gen_movi_tl(t3, 0xffff0000); + tcg_gen_br(l_b_lo); + gen_set_label(l_b_hi_gt); + tcg_gen_movi_tl(t3, 0x00010000); + + gen_set_label(l_b_lo); + tcg_gen_sextract_tl(t2, t0, 0, 16); + tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l_c_hi); + tcg_gen_brcondi_tl(TCG_COND_LT, t2, 0, l_b_lo_lt); + tcg_gen_ori_tl(t3, t3, 0x00000001); + tcg_gen_br(l_c_hi); + gen_set_label(l_b_lo_lt); + tcg_gen_ori_tl(t3, t3, 0x0000ffff); + tcg_gen_br(l_c_hi); + + gen_set_label(l_c_hi); + tcg_gen_sextract_tl(t2, t1, 16, 16); + tcg_gen_brcondi_tl(TCG_COND_LT, t2, 0, l_c_hi_lt); + tcg_gen_brcondi_tl(TCG_COND_GT, t2, 0, l_c_hi_gt); + tcg_gen_movi_tl(t4, 0); + tcg_gen_br(l_c_lo); + gen_set_label(l_c_hi_lt); + tcg_gen_movi_tl(t4, 0xffff0000); + tcg_gen_br(l_c_lo); + gen_set_label(l_c_hi_gt); + tcg_gen_movi_tl(t4, 0x00010000); + + gen_set_label(l_c_lo); + tcg_gen_sextract_tl(t2, t1, 0, 16); + tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l_done); + tcg_gen_brcondi_tl(TCG_COND_LT, t2, 0, l_c_lo_lt); + tcg_gen_ori_tl(t4, t4, 0x00000001); + tcg_gen_br(l_done); + gen_set_label(l_c_lo_lt); + tcg_gen_ori_tl(t4, t4, 0x0000ffff); + + gen_set_label(l_done); + gen_store_mxu_gpr(t3, XRa); + gen_store_mxu_gpr(t4, XRd); +} /* * MXU instruction category: align @@ -4799,6 +4881,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU__POOL21: decode_opc_mxu__pool21(ctx); break; + case OPC_MXU_Q16SCOP: + gen_mxu_q16scop(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:26:01 2023 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: 701089 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411084wrs; Mon, 10 Jul 2023 15:33:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGYtzjx/q/R6U9F6qTs7PJ1ySZfq+ROiOfISZ3Lihl6NYnX8iZxoN4A1Dgx8n4YEwLYQrqh X-Received: by 2002:a0c:cb87:0:b0:636:4e70:5425 with SMTP id p7-20020a0ccb87000000b006364e705425mr10275388qvk.54.1689028398041; Mon, 10 Jul 2023 15:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028398; cv=none; d=google.com; s=arc-20160816; b=smXT4AY4vw/c8TGeJrGnWXkWUusSUdicEAlV9OgYsra5e+WatkMPxgBhx4oqN+1jMB EkoehmvaWaIl/LrcwWx2UIR1a88DP2VbPKxZ+lQIbCJA8cLz1BXffGzytW4naQlZBI2s lBYNzZ6YQEKqISBC7wm9Hf13Jtd+L+3K/f2jQe0/vXtc+V2S4MODA4px5DdgOq2KtXQA 8tldUNLBH7kWZNHGwX06YaMdA7PbCqxxi25cAdtQRz95H1ACL1yvAYpEEZZt4ntV2gbZ Vwf/mWyLYjV3qwPdFpL+SRxQOsUmhpFswFUVW3apt7V+NB6Pz8OPI5Moy7706gktigq0 F3xw== 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=LCln3jJ+7gG+jrosvGc4eMbbvwHvlD0VQ3ORBziIIBU=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=KvQQ6KPcZCbovP1MbRN/dq6J/FrOY7CDbjE0POheSLy8SGIoRbE8zSGULSeGqU0jXE eH38Pekq7GNLgCoFz+1NgkTq0WSWyouu2OVFkf8LtozMXqMAlNb06kc5r8SVhRXbD8B+ iOOn+Dtyv4ndDdP8BQN4YP/8He52rSqToIvcSnclPxpe5p0I91Sn01qNmv9TaT2oJBJC 108XL8GOWaXsMZrTbw7bNkbgMzvlPrUnK34rTRbQFZAiBu7gDTE/8hUz09uWJ4E9r7Lc WoTGBAVXv5ma123E4oYA4y9epIb4wbQb0DR4zohgQTzUPLrwn1UFjHhg8I1m/9S0Evit tm1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y+YvRxeR; 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 h15-20020a0cf40f000000b00637041fb4b1si263978qvl.76.2023.07.10.15.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:18 -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=y+YvRxeR; 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 1qIzNg-0003I9-Lt; Mon, 10 Jul 2023 18:29:21 -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 1qIzNf-0003GJ-Ck for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:19 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNd-000298-By for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:18 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3142ee41fd2so5092121f8f.3 for ; Mon, 10 Jul 2023 15:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028155; x=1691620155; 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=LCln3jJ+7gG+jrosvGc4eMbbvwHvlD0VQ3ORBziIIBU=; b=y+YvRxeRpvmZOekGyTZH6r/9C5PzFF3kuKfu/268fuZTgoRbLalZwklNO7dGW4F8RC ZTEr+Yd/sysufTY3bdgunYkDFDMtoW1TVH273FFUB7fLvcT7nXQD9oVsJj/PJyEwFX6Q WSiXd9yPprN3MhVkFsQFrwntqSSrPrinXL3vTZ0u53sO6QPN+BYIkuyROKTDYbU+cRMh /dhtCUx2mSI9C0GYFYTawvUQl/mmaK5iD0X+CikKSaEOsFBS/nk9QCPvfK9aJxWCP5Dd u9DozI44iQGZEuP6mFCXR9ZutH0IBMR9dKlRc7ouxLP6UZzhGMk3LeHBRz1iIbf0LlPk yYSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028155; x=1691620155; 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=LCln3jJ+7gG+jrosvGc4eMbbvwHvlD0VQ3ORBziIIBU=; b=IQO5qUqL56EX8aulmCdXy6+R3aORQ5fTgIh0h4vdop0/Gh9OI2/WiA2xpqE/wzhRIl FnXWxsKkqwjKOnZwdXozUJHcFVKgyiJMawSLaRUfWw1uRTCKjRtwo3LMw9KKpI7nFZes I28ZbZYN5bAessJjgu9eIAouVCFE+EKGLDaKxqXwXfqb4F0exwQnO7Km89Nr9tCS//g/ wHd/XKAZWCoRoxoDOlBuxd0NSX7Q4tLRJsh5CnbS7wwMmcKjyAKhmf/7kVXlQcVNYiNS Zp09bvzMsWEdJweZDYOJBTm+2Zpk6YKH1hwSlGqhl+2RliqsfLzvBgqIFbASHN6PJtcc MLjA== X-Gm-Message-State: ABy/qLboJ6EOT9VQQ5SNXh7a42MJpo98+laxf3GVFeCBC9HXELfKCu9B eW4V/2MqRfotCe8D3qbZnnkHG9s/l8KbB0ZQVlzddw== X-Received: by 2002:a5d:6d4b:0:b0:313:f54a:a83b with SMTP id k11-20020a5d6d4b000000b00313f54aa83bmr11938671wri.59.1689028155793; Mon, 10 Jul 2023 15:29:15 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id g12-20020a5d46cc000000b0031455482d1fsm537070wrs.47.2023.07.10.15.29.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 34/44] target/mips/mxu: Add Q8MADL instruction Date: Tue, 11 Jul 2023 00:26:01 +0200 Message-Id: <20230710222611.50978-35-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction is used to parallel multiply and accumulate four 8-bit data. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-32-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 6945dcb440..84c52c55d6 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -406,6 +406,7 @@ enum { OPC_MXU__POOL20 = 0x39, OPC_MXU__POOL21 = 0x3A, OPC_MXU_Q16SCOP = 0x3B, + OPC_MXU_Q8MADL = 0x3C, }; @@ -1423,6 +1424,77 @@ static void gen_mxu_q8mul_mac(DisasContext *ctx, bool su, bool mac) gen_store_mxu_gpr(t1, XRa); } +/* + * Q8MADL XRd, XRa, XRb, XRc + * Parallel quad unsigned 8 bit multiply and accumulate. + * e.g. XRd[0..3] = XRa[0..3] + XRb[0..3] * XRc[0..3] + */ +static void gen_mxu_q8madl(DisasContext *ctx) +{ + TCGv t0, t1, t2, t3, t4, t5, t6, t7; + uint32_t XRa, XRb, XRc, XRd, aptn2; + + t0 = tcg_temp_new(); + t1 = tcg_temp_new(); + t2 = tcg_temp_new(); + t3 = tcg_temp_new(); + t4 = tcg_temp_new(); + t5 = tcg_temp_new(); + t6 = tcg_temp_new(); + t7 = tcg_temp_new(); + + XRa = extract32(ctx->opcode, 6, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRd = extract32(ctx->opcode, 18, 4); + aptn2 = extract32(ctx->opcode, 24, 2); + + gen_load_mxu_gpr(t3, XRb); + gen_load_mxu_gpr(t7, XRc); + + tcg_gen_extract_tl(t0, t3, 0, 8); + tcg_gen_extract_tl(t1, t3, 8, 8); + tcg_gen_extract_tl(t2, t3, 16, 8); + tcg_gen_extract_tl(t3, t3, 24, 8); + + tcg_gen_extract_tl(t4, t7, 0, 8); + tcg_gen_extract_tl(t5, t7, 8, 8); + tcg_gen_extract_tl(t6, t7, 16, 8); + tcg_gen_extract_tl(t7, t7, 24, 8); + + tcg_gen_mul_tl(t0, t0, t4); + tcg_gen_mul_tl(t1, t1, t5); + tcg_gen_mul_tl(t2, t2, t6); + tcg_gen_mul_tl(t3, t3, t7); + + gen_load_mxu_gpr(t4, XRa); + tcg_gen_extract_tl(t6, t4, 0, 8); + tcg_gen_extract_tl(t7, t4, 8, 8); + if (aptn2 & 1) { + tcg_gen_sub_tl(t0, t6, t0); + tcg_gen_sub_tl(t1, t7, t1); + } else { + tcg_gen_add_tl(t0, t6, t0); + tcg_gen_add_tl(t1, t7, t1); + } + tcg_gen_extract_tl(t6, t4, 16, 8); + tcg_gen_extract_tl(t7, t4, 24, 8); + if (aptn2 & 2) { + tcg_gen_sub_tl(t2, t6, t2); + tcg_gen_sub_tl(t3, t7, t3); + } else { + tcg_gen_add_tl(t2, t6, t2); + tcg_gen_add_tl(t3, t7, t3); + } + + tcg_gen_andi_tl(t5, t0, 0xff); + tcg_gen_deposit_tl(t5, t5, t1, 8, 8); + tcg_gen_deposit_tl(t5, t5, t2, 16, 8); + tcg_gen_deposit_tl(t5, t5, t3, 24, 8); + + gen_store_mxu_gpr(t5, XRd); +} + /* * S32LDD XRa, Rb, S12 - Load a word from memory to XRF * S32LDDR XRa, Rb, S12 - Load a word from memory to XRF @@ -4884,6 +4956,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_Q16SCOP: gen_mxu_q16scop(ctx); break; + case OPC_MXU_Q8MADL: + gen_mxu_q8madl(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:26:02 2023 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: 701070 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409616wrs; Mon, 10 Jul 2023 15:29:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7ys2O6L0F9drqehYEpwNqjHXVAmHsxOBmA/gW3FS9DRarpycIGugdX5skDhFEyS1Yk/pD X-Received: by 2002:a0c:aa18:0:b0:626:37fe:218c with SMTP id d24-20020a0caa18000000b0062637fe218cmr11384326qvb.24.1689028192970; Mon, 10 Jul 2023 15:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028192; cv=none; d=google.com; s=arc-20160816; b=Xd9y6w3RW5vysflSMdxknK1FIJ65D463fwI9t3n10XT7pKbWuXWnPFGzCjVNfkoxNg WWSWNORTBsonTxCsAFIMhpApnS4SrrsphXVOpQiJvOfwULLxopySIAloZr6kdKbcKztW VYZffuMXw0LTzSWdcsw0Sxc14HcotHmMSfdOUsWPuqAOgrBVS24/Cw8ZnmhKM9UOH+Jv XCSeDV3pejAgWDeGtAjZwhqAvQvSloq/z+QD9l+sI8aCr2zoqYUhmx7I5RmBJFIQF0Mx HUBcI/5Hhsi4wLJ8zI8cvOk+Xj+ZY6jUEdfwj1bCCJMdjXmVpkrGMZRIMSEbnklHDdFP dD2w== 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=olCE9WSawbC5JQmxGAo+xHeL9zp5d/vNOzhW5eRBh7k=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=qm7I3kJxmBFwJVTHcw8Eo0OIjqZmST7pYspws8Td2iarZtllI0zw5NJtTV0FJgw5EV elBs685xfeodPdkN505gE5zhb3+AvmVBjQJjnjbCw7PfgBQZ4ltIGio9C2O/OHiuDqme i07lHxiNjpNqqfpZE3nK9h0FxlYwPbgWuasTeYsgW7Xn7YuSflBJc6gYC1EXzJJ4MSsu CdYwFLeChhUlptNENBAynP8DCckFuebxI+7MsJLgAMOuVS4hSoqQ/b/t4CTfdza+2+/g KG65BGJLlPKWxjo24F8vP4IBrrcVXXDDN1EPH/G4lC03AqNSbS0uJl8ScEdsmndDw+Na rr5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZDu5aJ2; 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 d13-20020a0ce44d000000b0062637621f8csi257269qvm.82.2023.07.10.15.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:52 -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=JZDu5aJ2; 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 1qIzNm-0003PL-Nm; Mon, 10 Jul 2023 18:29:26 -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 1qIzNl-0003Ls-61 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:25 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNj-00029x-Hp for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:24 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso63881645e9.1 for ; Mon, 10 Jul 2023 15:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028161; x=1691620161; 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=olCE9WSawbC5JQmxGAo+xHeL9zp5d/vNOzhW5eRBh7k=; b=JZDu5aJ2HJ6iVL2+oe2xuhiazVCCtclQyXGZDhrHqno/bHP7siKTWJuIb6zaAeCB0V K649QFH3/484lunI5N6PaxIIanwlX6l/qQal5SkGTN0hrgVfecnh4O3/llAZNIkeE+dS w3nN0xjKRU/vK8/3TyB+gpZWQiZ2Drg+9vjVGlUSSk8RlHd6QisR3bQDNC7srSXEObKK tgFIrPTn72YyPqNih8T5tj5qPKVbTkw6On4xx2gsx0STwWDJu/Oe7hkQ1jicwvDig801 kCDpzCZ2Gy0ESdaHYL4H3HfChppWL1QvAbx81erfBcIoidykKXhD7Q8tibLRZSJkiMXJ vqtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028161; x=1691620161; 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=olCE9WSawbC5JQmxGAo+xHeL9zp5d/vNOzhW5eRBh7k=; b=QHHyaSPAS/TdMxcPbnKOZ8+jR2z8nZ0F6ck9PnK94nugCSEhCVJlFQ4Be/C/ORYB4T N7nKTGef3lIA0sPt5jfH5F+Fvb1Niysf4gEakI/8h2Te3ZfnYtoTXu+cfXKKQaB3Ay/U +SaKJRrEwDf31IVg84h6zo5GS7opcFxeZdRVGD+/QCD4s14gRvhjVhXkovC/bhAkyu/S iEUUOBeVyB3zf5A7Xat3DM7Ioe+doVYAvIN9e03M07chF09kThVR+d5TYg8KQVU8FKK9 kUr4NTghU7ounMDLYNYdIYz9k+9H5p6HGrJLVLYAEHVLMre1ELCqHt9mZcltgTB8fwc/ ur+A== X-Gm-Message-State: ABy/qLZBpHGWEXzWtghVhFcINpVVi94VzEeiC7gTdxSedg+afU8fkRnF iC1Kl7cFx+AazQTiDuGIPhfis9j+mGnS7T64jmse1w== X-Received: by 2002:a5d:5301:0:b0:314:44c8:aa98 with SMTP id e1-20020a5d5301000000b0031444c8aa98mr14841139wrv.67.1689028161039; Mon, 10 Jul 2023 15:29:21 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id y18-20020adffa52000000b00313f031876esm535652wrr.43.2023.07.10.15.29.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 35/44] target/mips/mxu: Add S32SFL instruction Date: Tue, 11 Jul 2023 00:26:02 +0200 Message-Id: <20230710222611.50978-36-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction shuffles 8 bytes in two registers by one of 4 predefined patterns. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-33-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index 84c52c55d6..c60404f739 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -407,6 +407,7 @@ enum { OPC_MXU__POOL21 = 0x3A, OPC_MXU_Q16SCOP = 0x3B, OPC_MXU_Q8MADL = 0x3C, + OPC_MXU_S32SFL = 0x3D, }; @@ -3961,6 +3962,83 @@ static void gen_mxu_q16scop(DisasContext *ctx) gen_store_mxu_gpr(t4, XRd); } +/* + * S32SFL XRa, XRd, XRb, XRc + * Shuffle bytes according to one of four patterns. + */ +static void gen_mxu_s32sfl(DisasContext *ctx) +{ + uint32_t XRd, XRc, XRb, XRa, ptn2; + + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + ptn2 = extract32(ctx->opcode, 24, 2); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + + switch (ptn2) { + case 0: + tcg_gen_andi_tl(t2, t0, 0xff000000); + tcg_gen_andi_tl(t3, t1, 0x000000ff); + tcg_gen_deposit_tl(t3, t3, t0, 8, 8); + tcg_gen_shri_tl(t0, t0, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t3, t3, t0, 24, 8); + tcg_gen_deposit_tl(t3, t3, t1, 16, 8); + tcg_gen_shri_tl(t0, t0, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t2, t2, t0, 8, 8); + tcg_gen_deposit_tl(t2, t2, t1, 0, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t2, t2, t1, 16, 8); + break; + case 1: + tcg_gen_andi_tl(t2, t0, 0xff000000); + tcg_gen_andi_tl(t3, t1, 0x000000ff); + tcg_gen_deposit_tl(t3, t3, t0, 16, 8); + tcg_gen_shri_tl(t0, t0, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t2, t2, t0, 16, 8); + tcg_gen_deposit_tl(t2, t2, t1, 0, 8); + tcg_gen_shri_tl(t0, t0, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t3, t3, t0, 24, 8); + tcg_gen_deposit_tl(t3, t3, t1, 8, 8); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t2, t2, t1, 8, 8); + break; + case 2: + tcg_gen_andi_tl(t2, t0, 0xff00ff00); + tcg_gen_andi_tl(t3, t1, 0x00ff00ff); + tcg_gen_deposit_tl(t3, t3, t0, 8, 8); + tcg_gen_shri_tl(t0, t0, 16); + tcg_gen_shri_tl(t1, t1, 8); + tcg_gen_deposit_tl(t2, t2, t1, 0, 8); + tcg_gen_deposit_tl(t3, t3, t0, 24, 8); + tcg_gen_shri_tl(t1, t1, 16); + tcg_gen_deposit_tl(t2, t2, t1, 16, 8); + break; + case 3: + tcg_gen_andi_tl(t2, t0, 0xffff0000); + tcg_gen_andi_tl(t3, t1, 0x0000ffff); + tcg_gen_shri_tl(t1, t1, 16); + tcg_gen_deposit_tl(t2, t2, t1, 0, 16); + tcg_gen_deposit_tl(t3, t3, t0, 16, 16); + break; + } + + gen_store_mxu_gpr(t2, XRa); + gen_store_mxu_gpr(t3, XRd); +} + /* * MXU instruction category: align * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -4959,6 +5037,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_Q8MADL: gen_mxu_q8madl(ctx); break; + case OPC_MXU_S32SFL: + gen_mxu_s32sfl(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:26:03 2023 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: 701071 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5409653wrs; Mon, 10 Jul 2023 15:29:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGe2P0zLE3g5jmM+HxpKv8hxYRP1CQuQD2h4QkUtecwv223+ylx1N0cYBfmWTcGLjKwpip X-Received: by 2002:a05:620a:1aa4:b0:765:8478:11ed with SMTP id bl36-20020a05620a1aa400b00765847811edmr14944970qkb.23.1689028196297; Mon, 10 Jul 2023 15:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028196; cv=none; d=google.com; s=arc-20160816; b=cx7Bm1q+YKGW8OuKQ/bBsKIOLI8ZO/5cPZMfaXDF9lcrUBoy/cyUI5YgkiiO0GrBqU mqPsTGYfC6iL5LFOPfwLuZFjtqgqxzVAaJwdzFrepWbyVI6tTOxVwTWUmapJRxHSsVBz VBBHeplyFIy57HnhkMOR0XzUU16wPpKiqUXny0Kft6fDvTzgW7VfSZrrgFyfLtCFHD+W 9ulmNOMfrznJqCwp015SpmDUT1vZcRHBqzFrLeT1/EZ9kvdu6X8t5ar0RLIoKmi7GF4u FInnDomF/3xfEl09j5CziQg40eN9FXFYY1+krIM35Q99WM7FJD3vVlbuy2YJOD0wF6lV +Trw== 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=IrdP+GTxx+78k+evZZHpP7bnuC4vtcn0hNtOHyqG+DU=; fh=bu9kv7nLVntBptyUjn85d0dzQ/yk/vWp3GUpc2G2nFI=; b=bJHPRSvVg8Et3HBy0gYagZuIpQGyJ5R3vtelBpmDJ2f9ioYzB07K4hzgUkSq5J0Byw gLzfo3tbueCcmjtce9aIWqgg1IRTQvua0peMVYahR41RBfj3R1dNspKkkLsQIIJBjfr2 ui93MPmHH31HFkiDTkFztKx3yBtrQqHPA7EkCPJnlfYNwmeZSq0gugGHI9gvxHnQfnrn mYtUZTtrkL9cc8oT+gnL9uw242qDqdmTRpV8y6WywUsuQSx0zhJqn92eNP4DUHRzge2m COZmqcs8fPxK2GgkyI1bAqFAkYtKJCcdivIVDm42b+/f2thrvGhI3RiVljw+NN8Inp/E XWOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mdl4n0C5; 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 t11-20020a0cb38b000000b00635da950a90si255100qve.137.2023.07.10.15.29.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:29:56 -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=Mdl4n0C5; 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 1qIzNq-0003o6-K3; Mon, 10 Jul 2023 18:29:30 -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 1qIzNp-0003lL-Di for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:29 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNn-0002Bp-MD for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:29 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3141fa31c2bso5110896f8f.2 for ; Mon, 10 Jul 2023 15:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028166; x=1691620166; 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=IrdP+GTxx+78k+evZZHpP7bnuC4vtcn0hNtOHyqG+DU=; b=Mdl4n0C527tiFyPWA+x6EWtNVgjj50oRQETsNTSDm7olCkLR25tz/ZWLXM8XOFTqFS 0hmCtdt5kwcaYRMHK9DTE0NenRvJaJ+N+M5lzFfV1cL7TUgcQJBIZ2R522hQcETr0J6L JjPVk1XK24zyJHF2WcHagf5bUca19+KmobberaCCZ7BwDXY9cLdSf+xYocvsHrGFTrQF wgggA1ugMQ2jIfRasxiIB37RO/pQ9zI15YI5XJOEgl3biDWnbB+nufRvBSR8twKjcFxU /UZWwmYfg8vV8QtSXTGg+3xR5eYAwT/gRHcO8bs27fALZMzrdJlDea+Ck4NPnmD6DhC+ TraQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028166; x=1691620166; 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=IrdP+GTxx+78k+evZZHpP7bnuC4vtcn0hNtOHyqG+DU=; b=ignQxScebWe6zX3wtB+hAxIyviD+XdcukLEYE8n0DNbQmgIyYSooBUQv9zc4aDbAfK bPImxrL6gS8tmv/GWN4DndUF4XGn+8VisHjaeSvv1zQx4F3ByKd7M3FeWkkWYEbvoZRe fO07keGm3Tt0h8BWbgP+dIQxUW1NWzCYtixZVMkNaYXyhcDudLEmKYJXOOSAbIbjK6Tq EamhWcJnxWoUhPowaoszz39b3+6SvRO7ZtwMM0J6BRN1Pd/2KGNOgBY7xRVjG2FsS/DO zS1VPJyBaMW2bpCnoi4HY9dDXkcvxY/ZBLRaqVWzjTmMMS/Cjk0uJGRnC68aFoDNyj+W g+mQ== X-Gm-Message-State: ABy/qLbMHGXILt9aiuvP1ObaQEpLmTPtI/H1qgJPEep7FqPaPQ1J7/Qp Q41fWdpqwCfxjD6LZFPotDxmqnWw5oZQm9ZR4Ym5Sg== X-Received: by 2002:adf:e30f:0:b0:314:2f96:a23a with SMTP id b15-20020adfe30f000000b003142f96a23amr14158145wrj.66.1689028166092; Mon, 10 Jul 2023 15:29:26 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id q10-20020adfdfca000000b003144b95e1ecsm509960wrn.93.2023.07.10.15.29.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 36/44] target/mips/mxu: Add Q8SAD instruction Date: Tue, 11 Jul 2023 00:26:03 +0200 Message-Id: <20230710222611.50978-37-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Siarhei Volkau The instruction implements SAD (sum-absolute-difference) operation which is used in motion estimation algorithms. The instruction handles four 8-bit data in parallel. Signed-off-by: Siarhei Volkau Message-Id: <20230608104222.1520143-34-lis8215@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/tcg/mxu_translate.c | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index c60404f739..deb8060a17 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -408,6 +408,7 @@ enum { OPC_MXU_Q16SCOP = 0x3B, OPC_MXU_Q8MADL = 0x3C, OPC_MXU_S32SFL = 0x3D, + OPC_MXU_Q8SAD = 0x3E, }; @@ -4039,6 +4040,47 @@ static void gen_mxu_s32sfl(DisasContext *ctx) gen_store_mxu_gpr(t3, XRd); } +/* + * Q8SAD XRa, XRd, XRb, XRc + * Typical SAD opration for motion estimation. + */ +static void gen_mxu_q8sad(DisasContext *ctx) +{ + uint32_t XRd, XRc, XRb, XRa; + + XRd = extract32(ctx->opcode, 18, 4); + XRc = extract32(ctx->opcode, 14, 4); + XRb = extract32(ctx->opcode, 10, 4); + XRa = extract32(ctx->opcode, 6, 4); + + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + TCGv t3 = tcg_temp_new(); + TCGv t4 = tcg_temp_new(); + TCGv t5 = tcg_temp_new(); + + gen_load_mxu_gpr(t2, XRb); + gen_load_mxu_gpr(t3, XRc); + gen_load_mxu_gpr(t5, XRd); + tcg_gen_movi_tl(t4, 0); + + for (int i = 0; i < 4; i++) { + tcg_gen_andi_tl(t0, t2, 0xff); + tcg_gen_andi_tl(t1, t3, 0xff); + tcg_gen_sub_tl(t0, t0, t1); + tcg_gen_abs_tl(t0, t0); + tcg_gen_add_tl(t4, t4, t0); + if (i < 3) { + tcg_gen_shri_tl(t2, t2, 8); + tcg_gen_shri_tl(t3, t3, 8); + } + } + tcg_gen_add_tl(t5, t5, t4); + gen_store_mxu_gpr(t4, XRa); + gen_store_mxu_gpr(t5, XRd); +} + /* * MXU instruction category: align * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -5040,6 +5082,9 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn) case OPC_MXU_S32SFL: gen_mxu_s32sfl(ctx); break; + case OPC_MXU_Q8SAD: + gen_mxu_q8sad(ctx); + break; default: return false; } From patchwork Mon Jul 10 22:26:04 2023 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: 701076 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410334wrs; Mon, 10 Jul 2023 15:31:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHWR4RxLyLjCCG6D5GpjMCPiKW5G6NNtsdZCmpJAF1Wi6KoC0IX93h+xQmuKfQQUzRzVFMe X-Received: by 2002:a05:620a:2b0f:b0:765:a95a:571b with SMTP id do15-20020a05620a2b0f00b00765a95a571bmr13204823qkb.41.1689028277480; Mon, 10 Jul 2023 15:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028277; cv=none; d=google.com; s=arc-20160816; b=hPUzvWCG9tnXKmp6Z1DxuEym0E3HjQFnZax9YnCbBm77Rl7NzDFFGXwKPZ2HhVjRw7 b8VVrtzxOee8eHuLLR7nXFTaBXB2ysi9v2q/72AwnnrUpy4tnydivNKEPOJ+ebe6mryA UB9cFQmOIMw4K75Q8QyCqIIO6e+WG/T2k1uGMh9EDdqfTawPAZUGOq7KHojUZlp8rXh6 Vs5aS3e/D1/S8cdPCKc2q8PvZUND2DiIGBre6alq0Buqx760PdUUlYp9tv9a5LW147kf Ze7VS0OHT3WipKEn9fsuLhRrwi1qkpD349G4Xeaoo152d85jrQ6pvCkj27Fz9pmeLrxi eGrw== 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=noAqc1iM8teP3z/+IYxbUAPdYxzHFromapc0DSXQg/4=; fh=aCcEwGhsSGSNR0xggAlhyAli0IIy+XLKD6nFEBIBxh8=; b=J84cyg1WjcpmSTqgD5Q4UsM7F+i7SpN/TMwajmKYusa3oe6GTlOZQxhySibZLAxLCS +CChX/DacVFl7Iwl/BZjhPcD/7kWIBTyTat60Np8tvwwh0D+BPkQ8+6AgrXTSmMnSb9U tD6+PZUBfo81dkGDfzt7cfaCjO+KbW7REaT8JzrKT+7lEbSXjbQxj1cz3vyBQObYZDln FoZUsVWKpwR0dyUFyh36dP0sl8JfQzECb4VXZSiZyNJkFuA/GtOR2HS6eprP+k6k/z3n wKbS3OuvIc4ZFjn2zPtLoLSgLJY13/ngt0NrzjioYLpUHzOSeTV94n0TaLGDeh3va0LN qJkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hF+jBTV3; 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 v187-20020a3793c4000000b00767d573c639si258997qkd.454.2023.07.10.15.31.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:17 -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=hF+jBTV3; 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 1qIzNw-0003q3-69; Mon, 10 Jul 2023 18:29:36 -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 1qIzNu-0003pf-O3 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:34 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNt-0002CT-76 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:34 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fba8e2aa52so56073755e9.1 for ; Mon, 10 Jul 2023 15:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028172; x=1691620172; 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=noAqc1iM8teP3z/+IYxbUAPdYxzHFromapc0DSXQg/4=; b=hF+jBTV3EnOCwcEfWvbAwTKTVwocoomrdLT3EuM51Zq+v3jgCmt1F5v5LBQKPkrqS8 IkapOZdHw+9gElHseZCyQXWMjTdMnnMVstgDfILgKTDCTAXHALQOncVCdea9hrPm2GFe RrNDVJwwR26UlS1C6I0S1t7ezNDIVg6h1Jc8bmoGKNpUhecf/jni2L49+OWaMRDFfrFP /JALgXQVo1/deQfjxv77xfs4wp8u2d07uI5QeWzIQ2c445U9YpOysTaR/9CB3o/+oOhO Zc/bV4HuV6fR+9uuZAovfctziPq4uDZYx0q3reTAc3N03S8ceZnMJ5twH6si4hVYYAaF DA4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028172; x=1691620172; 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=noAqc1iM8teP3z/+IYxbUAPdYxzHFromapc0DSXQg/4=; b=JPvMqxr+o+IR+E7VQGcs+0y4vTJ1/pIv9iGaUjABW2lrwDUb0eXfzTK6W47JC9jW7v RUz+Wt3QsBImAgYSk+BZ5+vPCUrtb5643FMLjdBtDXxG98T9SsYbR4TleBMm0rQXIJMu PXWZ2M8jkdAHacmTLwZDgv3qojXbCafF/ihl02ghjdor6kiAhUnvx/OwRpuCCDGzc356 RXDzrwspE9W5/PeQxImgUaS+sqm7O2sQpAAld1dXyZe8+LAhBka26mfbumrgnb2PI7V6 8aV6Nl9TMCHcb6ZLRuT11fTk4l6JZK7zE1AEbKl+Nk87hfu9X99eIW0sjgGBEtHF8mO4 ZMaQ== X-Gm-Message-State: ABy/qLYrMucmfFo+rYyw1SuCkJ5MWP2aZy67bVAUpAJ7q1KMnJ+DPcLd j/XSi3oVJA1t+pPapDnvnv28MYkVlHoaoQvpW6XUHQ== X-Received: by 2002:adf:f8c3:0:b0:314:38e4:25a2 with SMTP id f3-20020adff8c3000000b0031438e425a2mr12902983wrq.37.1689028171737; Mon, 10 Jul 2023 15:29:31 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id g15-20020a5d554f000000b0031411e46af3sm512346wrw.97.2023.07.10.15.29.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Marcin Nowakowski , qemu-stable@nongnu.org Subject: [PULL 37/44] target/mips: enable GINVx support for I6400 and I6500 Date: Tue, 11 Jul 2023 00:26:04 +0200 Message-Id: <20230710222611.50978-38-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Marcin Nowakowski GINVI and GINVT operations are supported on MIPS I6400 and I6500 cores, so indicate that properly in CP0.Config5 register bits [16:15]. Cc: qemu-stable@nongnu.org Signed-off-by: Marcin Nowakowski Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630072806.3093704-1-marcin.nowakowski@fungible.com> Signed-off-by: Philippe Mathieu-Daudé --- target/mips/cpu-defs.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc index 05d9ec7125..03185d9aa0 100644 --- a/target/mips/cpu-defs.c.inc +++ b/target/mips/cpu-defs.c.inc @@ -755,7 +755,7 @@ const mips_def_t mips_defs[] = .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) | (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist), .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) | - (1 << CP0C5_LLB) | (1 << CP0C5_MRP), + (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI), .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) | (1 << CP0C5_UFE), .CP0_LLAddr_rw_bitmask = 0, @@ -795,7 +795,7 @@ const mips_def_t mips_defs[] = .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) | (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist), .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) | - (1 << CP0C5_LLB) | (1 << CP0C5_MRP), + (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI), .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) | (1 << CP0C5_UFE), .CP0_LLAddr_rw_bitmask = 0, From patchwork Mon Jul 10 22:26:05 2023 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: 701088 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411088wrs; Mon, 10 Jul 2023 15:33:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlH73ZdYjWMkBb9D6nYvmpCQCvCNBGtB8feGvXBaKNU21JSCtShxXScuaBzr/HSJfroaq+k1 X-Received: by 2002:a0c:f344:0:b0:62d:e09c:fd73 with SMTP id e4-20020a0cf344000000b0062de09cfd73mr12692207qvm.59.1689028398134; Mon, 10 Jul 2023 15:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028398; cv=none; d=google.com; s=arc-20160816; b=wqWQx3ngPvf/3CK3Vq9EqUGkONcfC9DNW99tJ089GI4cUpwAbTnlOVirv1uX14m0/B 35tlvVeG36wd+hhJGHKXWxYyxjx80wn5AaVuYzsnQM25AgoxnhnfCYSKoyh7kkKQbiEK MJPTV5geR6iZ0Ue4pw2Z5OoJOoP7f7oQTO+lboZ4TrFijoiFHIHC1RlNWa6y/m5Vv1yl 934T7duWoh/oR0vHRztlV47BAzkGLvr83u9WTdAU+fzQin/BUdBG5hr9L9u2SuqFiwne 4idNe+d2ZN7VKj1DGlQZqhIm/ijGX+/V1OtnFLi+wNgf1/+wNecl1zXdPB9lHHbBJ2RU AaUQ== 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=cspC1pmJKd9x8KtL27yFisUZgwn8qgFbFWAuYt1IY7s=; fh=JAI4GJqjM59PxWmatoCaOlMDql9K9SApKGQIxVFGkUg=; b=xofrtAfqJ+b6tKJ66x6sNylHQHcTMWuOhY/SiHn1qC9w3VV1lxqGifE3cDQNiAZUnQ 9+zV86d/SrsQxNmSSLEcYbG3byowAhgUIPEA4pI+cH1r/c+N17P+QLORYvQ41CvBLNhd SvylrU4+btZRAEbhEKXhFxBBSydhioAk1NDWaIMKnK+r10MQWKyLyitZKlvi918X5IEt /zC8Zzeaw+XUNn+GMeeUnIDGlp01KQzglB28qRcUt8NMcQRVR6HVDlGPyiCf/Wdef3RQ j9w3DiVUz6eL5zdbHQLqcINPZG1Auq0iC+DLHYTHeUFw7hKrO0afZi04W7x42dRCrdKX dPhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JiNtlaFe; 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 y7-20020a0cf147000000b005ab07d135e0si267541qvl.46.2023.07.10.15.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:18 -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=JiNtlaFe; 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 1qIzO1-00040f-J0; Mon, 10 Jul 2023 18:29: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 1qIzO0-00040F-GV for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:40 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzNz-0002Cl-10 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:40 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fc02a92dcfso32946725e9.0 for ; Mon, 10 Jul 2023 15:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028177; x=1691620177; 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=cspC1pmJKd9x8KtL27yFisUZgwn8qgFbFWAuYt1IY7s=; b=JiNtlaFeHEnKDsRcmcT6meSyxoB5WgFk+yv3FTb2RSh2U7kL2afNGN2XxUh4/gShy+ wHnDxz/7233TjSALL6uBb9oGyPYB+XEfX9HnIxWNsqyvDEjdan+NvZniU6H4cLlSIPPu 0wXgzP3XcAuzU7/t9R2h8LWjKNxNRBxSBvb7uSFnmtpdBTv3xqqP3vcpSPMgy6mEd40K tmnXLbhW6afvmGjaBr1YH83o6ihQkvvpXotMTeclY2iv/Lh1QIlHjfXhQIuEbDfsqAT4 a5CIy+ECKpFyt0jf8EsyyK0Hn/P6BjEv4vvXn4IJgyD4sSCiAYMcn9uVl73wtN/nec8a 73NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028177; x=1691620177; 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=cspC1pmJKd9x8KtL27yFisUZgwn8qgFbFWAuYt1IY7s=; b=csKLWbPSS7PZneMszHkeHApxWGnRQJWrRnPn4P7EPPfdDFyo6FQ+bzJaWXhyLB7Coi f8MRcfDecFKHuO1WSu4gBPguND8P9PXNL0ypSUqG5uHTtbBDFZURPUU2vHrUb0aPK2Xu 8E1vgDvP1Nd0sHLS/hV59/1P94qhUwzMJoMtS7aXNVXK8r18Pye5ll7jZzADROhhLkx8 Qn+SeFULMJp/PbCso5+tyVli+WmqQSE6rRnR68lohPePfvoTGAiz8EDRQ+N6a+bkiKtk bO0elLtI3MHSGHnXxT8v3kuPr5YGlCLzujdGoy4R0plnLg1+zlhVl969VXRHuDAGEgXE wAEg== X-Gm-Message-State: ABy/qLZiHJjtIDPZfI7CS/sOr4NG5Od3cFrUiNprZ8ZoK+sast/FKrmj UDjfJ0lojp/Otj9lSSQmaJ4HKa2ccaPnOO92rVv8qg== X-Received: by 2002:a1c:f713:0:b0:3fb:adc0:609b with SMTP id v19-20020a1cf713000000b003fbadc0609bmr13258048wmh.13.1689028177270; Mon, 10 Jul 2023 15:29:37 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id v6-20020a05600c444600b003fbb1ce274fsm20965127wmn.0.2023.07.10.15.29.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow , Mark Cave-Ayland Subject: [PULL 38/44] hw/ide/pci: Expose legacy interrupts as named GPIOs Date: Tue, 11 Jul 2023 00:26:05 +0200 Message-Id: <20230710222611.50978-39-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow Exposing the legacy IDE interrupts as GPIOs allows them to be connected in the parent device through qdev_connect_gpio_out(), i.e. without accessing private data of TYPE_PCI_IDE. Signed-off-by: Bernhard Beschow Reviewed-by: Mark Cave-Ayland Message-Id: <20230531211043.41724-2-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index fc9224bbc9..9a5a7089d4 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -522,10 +522,19 @@ void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d) bm->pci_dev = d; } +static void pci_ide_init(Object *obj) +{ + PCIIDEState *d = PCI_IDE(obj); + + qdev_init_gpio_out_named(DEVICE(d), d->isa_irq, "isa-irq", + ARRAY_SIZE(d->isa_irq)); +} + static const TypeInfo pci_ide_type_info = { .name = TYPE_PCI_IDE, .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIIDEState), + .instance_init = pci_ide_init, .abstract = true, .interfaces = (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, From patchwork Mon Jul 10 22:26:06 2023 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: 701092 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411135wrs; Mon, 10 Jul 2023 15:33:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHUSV2iQbflN/Sw7UJPD/9GRf7OorKYYUQ+n+04JNKnXznM8q3dmlR4DK7QtlPTtxtAcdjW X-Received: by 2002:a05:620a:40d6:b0:765:5b54:93c8 with SMTP id g22-20020a05620a40d600b007655b5493c8mr16047574qko.76.1689028404956; Mon, 10 Jul 2023 15:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028404; cv=none; d=google.com; s=arc-20160816; b=ELrXfDUPV+ty2URIxxSbamSu5bA3Bnl/LelkDbTRLeWm0otODp7ZAkgb1CmDKBGSY1 UZH+3Deif1oQVC2kJ9vwz/OYwfZtppjP3uByxRr4jxbReRM62C9kOdcuidkRzd+cuIT+ lW/xrfbcE0Kk95+evA1me9aQBIrI+7aUkfe/zeGjvyqUvgOAoS9J+G13JdV33IaHbi/T sfzaptcMMqWqvvnvAGBpXB7sY4EtldUb8AbKO5tvAiDHGVgFegHLQXKM9Xq/efp7iDmA tPQsOLJBlUI71fTB+yq9xz/gC6s/2CbYRrq+yLeTkvf30de5N7SRTuFibJIKMHFkJ/2R tErg== 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=LuOsTCwPo/F0jCl0d7iU/xlYr9uDvJyyAysToBkVdZo=; fh=JAI4GJqjM59PxWmatoCaOlMDql9K9SApKGQIxVFGkUg=; b=SUP5/is5nmBpCb46gu/HnMRM3KWGPqtvfMj9abYaEcVp+KtKkYVp9dQisOCYpsDSk6 1kR6pT5M5viagf4bwyqwPSMG5nuPLp1OKLu5QMLsQUiKzbxSTWt93GvJ+FxI7xI5vqkK ElUFUrSG6ONE1U7G/7qByrR5U+b+WMNpGE9u93FGusEYBD7HTFzIKkiul4GJMAugZxbY ChOpPCncttqrESyqV415t4ImHeZPNNtGRLdXmMkI2HStMRA9Ae01qhT3LYPNDhqMtjBe +5H3S0Tds/g5T0bZiyVhHrFLWkjMSVKKvs1bJIPo+lsMJ3G4tBcsrjXneCOBnk/q1RRz JXJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GU3H3QeG; 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 bi8-20020a05620a318800b00767b3ce0926si265507qkb.312.2023.07.10.15.33.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:24 -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=GU3H3QeG; 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 1qIzO7-00041b-3l; Mon, 10 Jul 2023 18:29:47 -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 1qIzO5-00041B-FJ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:45 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzO3-0002DA-Tp for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:45 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31441bc0092so4956293f8f.1 for ; Mon, 10 Jul 2023 15:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028182; x=1691620182; 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=LuOsTCwPo/F0jCl0d7iU/xlYr9uDvJyyAysToBkVdZo=; b=GU3H3QeG0cYxJ6fVuP3tvIek4HiCbsHISQmjv5JnwDuDN8GSTbhqfiPPnkZpN55ikn n5WYN+Q/EmV9HIJYYpWPIgc4UQLgJkUdpWR7M2qCHSfVBf9qZ6y38dUGxLAnk2GFJ5ed bAxfSvQmL4z0dbm0BxELSCEqr7LpZTM+vht43yu74K6XT8VmxcinWctlUiEOhxrmuJfu o5ituDzRGI9HDSmp9q5EMvJu3vWG015O+9zmYaanwkMZDhtNhmTLNSenv4WX/WF339VY o0cq3M2uE1awVYmlTvk+im/rDUzOL8TXkHOQTDGJO2JYoCMkFDcrvk6F3p1UxewvMUYb 0HNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028182; x=1691620182; 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=LuOsTCwPo/F0jCl0d7iU/xlYr9uDvJyyAysToBkVdZo=; b=TMChjeeXOkV5AORO5WCcoPP8nJ7QrlbVriIFySkAP7a5sHlCd2URgNsx7buq1KH7u6 KkKHvQKmooGem8+Kdzfj5HEEWwHzynFlLaCMmMJfYSy1rO6uXCQUTyDuTWHMWWRLjCCz 3lnsZlWEztAi9f5EQsgYdEmQAGLRdVPTvUjGboJ/fDdb0B8/H07UEmWGCS4YlPIc8/wW qYYuG14XDnRm5XP+0zR73/hIKiEDypdmM2IMc7VNMPd7WkNZAFrieUc84jnFwIqpCPBU EPJNXTyTT1Q1rsj3Cs6rM97z3RtP7lYZg4mzPQobAnAjx0HQ6RnX28df9uroituxs62X ITpw== X-Gm-Message-State: ABy/qLZNQGSnJrM1gBAWDMqsIDvCIdjxDAXWwliXY1osrFlDBPxgeA6L 4k71RvzO+X2+0esmlrdOKbF8ngqrHgGxpyP63c1Ymw== X-Received: by 2002:a5d:526d:0:b0:314:1a63:be9a with SMTP id l13-20020a5d526d000000b003141a63be9amr10720254wrc.26.1689028182517; Mon, 10 Jul 2023 15:29:42 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id s15-20020adff80f000000b00313f9a0c521sm512043wrp.107.2023.07.10.15.29.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow , Mark Cave-Ayland Subject: [PULL 39/44] hw/ide/via: Wire up IDE legacy interrupts in host device Date: Tue, 11 Jul 2023 00:26:06 +0200 Message-Id: <20230710222611.50978-40-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow Resolves circular depencency between IDE function and south bridge. Signed-off-by: Bernhard Beschow Reviewed-by: Mark Cave-Ayland Message-Id: <20230531211043.41724-3-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/via.c | 6 ++++-- hw/isa/vt82c686.c | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 177baea9a7..0caae52276 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -31,6 +31,7 @@ #include "sysemu/dma.h" #include "hw/isa/vt82c686.h" #include "hw/ide/pci.h" +#include "hw/irq.h" #include "trace.h" static uint64_t bmdma_read(void *opaque, hwaddr addr, @@ -104,7 +105,8 @@ static void bmdma_setup_bar(PCIIDEState *d) static void via_ide_set_irq(void *opaque, int n, int level) { - PCIDevice *d = PCI_DEVICE(opaque); + PCIIDEState *s = opaque; + PCIDevice *d = PCI_DEVICE(s); if (level) { d->config[0x70 + n * 8] |= 0x80; @@ -112,7 +114,7 @@ static void via_ide_set_irq(void *opaque, int n, int level) d->config[0x70 + n * 8] &= ~0x80; } - via_isa_set_irq(pci_get_function_0(d), 14 + n, level); + qemu_set_irq(s->isa_irq[n], level); } static void via_ide_reset(DeviceState *dev) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index ca89119ce0..8016c71315 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -692,6 +692,10 @@ static void via_isa_realize(PCIDevice *d, Error **errp) if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { return; } + for (i = 0; i < 2; i++) { + qdev_connect_gpio_out_named(DEVICE(&s->ide), "isa-irq", i, + s->isa_irqs_in[14 + i]); + } /* Functions 2-3: USB Ports */ for (i = 0; i < ARRAY_SIZE(s->uhci); i++) { @@ -814,6 +818,7 @@ static void vt8231_isa_reset(DeviceState *dev) PCI_COMMAND_MASTER | PCI_COMMAND_SPECIAL); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); + pci_conf[0x4c] = 0x04; /* IDE interrupt Routing */ pci_conf[0x58] = 0x40; /* Miscellaneous Control 0 */ pci_conf[0x67] = 0x08; /* Fast IR Config */ pci_conf[0x6b] = 0x01; /* Fast IR I/O Base */ From patchwork Mon Jul 10 22:26:07 2023 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: 701084 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410615wrs; Mon, 10 Jul 2023 15:32:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFy4A2GtkguMWiLCTY7JwPZq4XHePQ8K4cqn2iDnbGO1Qn4vP40vgXkFqnCqe1SXBMXETb X-Received: by 2002:a05:620a:28cd:b0:767:28b5:b9f3 with SMTP id l13-20020a05620a28cd00b0076728b5b9f3mr16155672qkp.57.1689028326783; Mon, 10 Jul 2023 15:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028326; cv=none; d=google.com; s=arc-20160816; b=Jwtz5H/owwu/yDTvGKB+TcWBXqaDag3OR5NFEoxOjdN/KK1onnu5jY1CfoDiY92V5g 1aglKJrveFoig7p5kQiTBMmiaFg7HHDoGw/ybRg4TnmxnMT2R8ReTFxn1kt4I+p5oG4p g/XgfqK7dRFbmWkfQ1N9CFliSVZd0rIj6AdpFw59bqVFdQueK4YlNV0Di/5XcYkhQvDz 6v221mWHpIqA2qQ0NbTX5GcaWZBkoWh1luOwfSOZOvIH8dmVufqwfb5CvfSZD2otmfBR IqOUKw/2yi352JCCfysJO59loHNiQazR5Y/0TFICQ4wDSI7o4Z1cEnCepsUZFIDwOr29 jc9g== 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=QX2IEM9dRwmrf277j4zOSy3qa25+owguTvW7VNekX1w=; fh=JAI4GJqjM59PxWmatoCaOlMDql9K9SApKGQIxVFGkUg=; b=sq8wPUVe9BDljqrA8mrxWypSh9GhZttv8cAI9SOKhyl44otQ5KiEp2EXuVW5yr7DFk XG8+SD54Y/nlsy+nWrLV6d7lLMEAnpQJYDQniLNYqlj181ZQWr84UdcOYBWzPpifes5Z A8GS6UutVLINRlAUhEX2yuQbWhpaxaikJFlq8pQJbKbdWM+7PMDoryhxAhtyzM5lKjJM DFVjCW5aMVamh2KWT3G3g9GFTXuL9dunm6cQ9Ur38ZOkkbo5ZHm0u1jQkteaqOjV/BY5 lXwOYStvhsZsg+H6xAmbZrm1NpZ5oAmHy517V+gtxwAeHXIB5WFp0KTl5FRRP1fsMPFd kMWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zJqnkhEC; 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 i17-20020a05620a249100b00767b348d2aasi280322qkn.79.2023.07.10.15.32.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:32:06 -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=zJqnkhEC; 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 1qIzOC-000460-Sd; Mon, 10 Jul 2023 18:29:52 -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 1qIzOA-00042F-Uf for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:50 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzO9-0002DQ-FT for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:50 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc244d384so52015505e9.0 for ; Mon, 10 Jul 2023 15:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028188; x=1691620188; 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=QX2IEM9dRwmrf277j4zOSy3qa25+owguTvW7VNekX1w=; b=zJqnkhECawB70bO01qwUEgZyXDAdHYGT9OOrWgLMFDUp4lpz+WbX3vkIztfyp+2fX0 yZIj+JmWdFkLt4IZZxh7eEJMU3asSwLOhFzKyaayjUwG5zyWPgIB5gf35WtABkaarDi/ PuuFbG6a4TRZnSDTLekYTA0pb3mw2+LEiePMvyl5boxTcYNEXCchcWu4ZdYj3K/nKe3A YBb2lJ/aRuW5Mcp8//uLbRVR7yvOObnZd81nswBIQdLJulQa9gPHXBWIaKwYNXx1xLhI VMlaNbJPG29Kw1ZITwZofQgttzG5yfLwBAH1meiEW7c32yVAXnicBrkVcGtq29Lk6Xak YWZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028188; x=1691620188; 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=QX2IEM9dRwmrf277j4zOSy3qa25+owguTvW7VNekX1w=; b=kcl0HPghHe8PRFcAqwRHzB/rD1uYGRbmlCoFlqFjr4CCl9U6xQ6pZMDW3+Tq1+hBs8 EVhlQ64+/wsdPJ5dbbCJ/oTbl4A4N74bTQer6uQobDGxF3kLTUurTQm1RMmukqJTUhPy u7kHIcCt3bxZhNcVkQnFTaGFAYzy+TM5p+oh0fP6KDE7APfXgFmgCGpaHldnXHeVYpbd eKme2Uw2POlxU1DPFdTZAKdF4LuT4fDaH19cqSb2T8OS0rzFw/FnpykZ3JUtPG5oXHpZ tMLAeR51OAzjWzYFIrBhbWP8WZRm7JJ9yRfYTafr+uKXcpLp3tShQGYcCCUvMEBFcTRl bMmA== X-Gm-Message-State: ABy/qLahu/h8X9XHmfyq7nNJf4819ySKApMEj29pEmlo2UxhGzG90Vn0 yC/fQdgQ+9eaveHteQ0GHQaLdsp7KB2/M6JdA/kwiw== X-Received: by 2002:adf:f592:0:b0:313:f1ec:f429 with SMTP id f18-20020adff592000000b00313f1ecf429mr11955357wro.46.1689028187859; Mon, 10 Jul 2023 15:29:47 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id y3-20020a056000108300b003141f96ed36sm579893wrw.0.2023.07.10.15.29.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow , Mark Cave-Ayland Subject: [PULL 40/44] hw/isa/vt82c686: Remove via_isa_set_irq() Date: Tue, 11 Jul 2023 00:26:07 +0200 Message-Id: <20230710222611.50978-41-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow Now that via_isa_set_irq() is unused it can be removed. Signed-off-by: Bernhard Beschow Reviewed-by: Mark Cave-Ayland Message-Id: <20230531211043.41724-4-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/isa/vt82c686.h | 2 -- hw/isa/vt82c686.c | 6 ------ 2 files changed, 8 deletions(-) diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h index da1722daf2..b6e95b2851 100644 --- a/include/hw/isa/vt82c686.h +++ b/include/hw/isa/vt82c686.h @@ -34,6 +34,4 @@ struct ViaAC97State { uint32_t ac97_cmd; }; -void via_isa_set_irq(PCIDevice *d, int n, int level); - #endif diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 8016c71315..57bdfb4e78 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -592,12 +592,6 @@ static const TypeInfo via_isa_info = { }, }; -void via_isa_set_irq(PCIDevice *d, int n, int level) -{ - ViaISAState *s = VIA_ISA(d); - qemu_set_irq(s->isa_irqs_in[n], level); -} - static void via_isa_request_i8259_irq(void *opaque, int irq, int level) { ViaISAState *s = opaque; From patchwork Mon Jul 10 22:26:08 2023 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: 701095 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411192wrs; Mon, 10 Jul 2023 15:33:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3beeoYUpnxuPre8fryaQaSvULQNzYbroowBXCFhqE7gtOHdTBZX/FClVIlEbBY9g/A9eA X-Received: by 2002:a05:6214:1bcb:b0:630:1b99:5c53 with SMTP id m11-20020a0562141bcb00b006301b995c53mr20139888qvc.9.1689028413372; Mon, 10 Jul 2023 15:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028413; cv=none; d=google.com; s=arc-20160816; b=Sknx/3FCgJpmCvxb8vhtpRDy6lOfzRCbcyzk3m+NHkDnt6qchFUEfZ9SfKIfOm2PHk Rl/RCdn3/AnbpLLo+MjtK/OyvDkLHFq1+jlMQYExgwoFvi+I1bgKxh9zvz2CKZyOpJ5o pgvpzzGzbBdcFmeZaGBXrK9ZdCH3MkEiuTahHGxL3UsC26AhNqfJoZiPzVnqG94iwChM xgSJfOGjM3R1GLF+02WB6SGfOeyey0SUVG9MTsaE9LnqLgu6+oUmDQqusH1VV9CeDJkE +4qsQegw46L8PyQv7+3mkR3XIvSUCo0hJQTQXuJwOJd1ZVHHnDmhfzsaPPFfIRo0EicS Pa1Q== 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=74d72XaIdb+kCGd1hbNsukTmdt2SOlQTd25zIPi+waM=; fh=unAycENEVQGObgAkCH5LYKVVGiZ+PlUWoTdastBTU5A=; b=U2JVKmhqdEuvvKoCIiV5t0SSPeoGSD+xEwKoYPGbP0+OKOHWBOgmTLEQzeGdxmlz9A MutEf7p+JaJ4YO8wivNWH73q9H24+HthySX6Xh3tbZfy/Tzhff/jXehYrVrSRvOF7M4W eZQeUpZs5wQ7XqPMARaBIXf3azYDQMPjCUWW0oxpgbI6JpBce/0gFR/GlLvrxpFxt0g/ rnNGerp2G2Yzx1oY+/X97yPqi5WthXPMKkVSOjzFv81he0Ixl2VME2LFmfq7uOkgumFL WwucNZpe9rn5NvMp2Jj6e0DEt3ky5Ps6h0EV2x/SUx9ANtk6r7EC9qy30qtH5AAkrD5o J1jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wXuBupMr; 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 g67-20020a37b646000000b00765ad20c2f9si258451qkf.768.2023.07.10.15.33.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:33 -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=wXuBupMr; 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 1qIzOI-0004go-Lq; Mon, 10 Jul 2023 18:29:58 -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 1qIzOH-0004Wa-K1 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:57 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzOF-0002Dr-R0 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:29:57 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3159d75606dso1356320f8f.1 for ; Mon, 10 Jul 2023 15:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028193; x=1691620193; 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=74d72XaIdb+kCGd1hbNsukTmdt2SOlQTd25zIPi+waM=; b=wXuBupMrGmVm+dtkpH7RaYfWL9YMYN0jNlE/kEzde+LTeGnBtMUaCRUFye789juOcw ozP4K6eep1/sNSm53mEFFMlWqemXRvu6s412MtGHXAajgBMzyxoA3lt3/Vxm43j+MrUd hnECW42whWbyyhXc99beYydKR78eH0SROoN3CANTJY6gj14e9UU/VmP3FzyKx01Me/28 pVdllTsSoflOEYu1qSxgDyUQ+0BiFMT6zrXkWosySf7dPOxb92jcDJ8M+Xo5IVVuITWR gZSNxB3OnKPsAFkVePQwXt/ZSDysD06HUSL3rAZjxCMz9GNy+7n7XJf1sqAjFAlcYXUQ g4Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028193; x=1691620193; 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=74d72XaIdb+kCGd1hbNsukTmdt2SOlQTd25zIPi+waM=; b=DdRi1DQVlzMsUU1GsG5gnq9VYKg53mlDpJDJcpiXtWML5XHIuxOV+N6zWDCDwbnMiy 8yhKJ08VQcs3KvEIoH1C3lmWfYahEEFN1yIKkP3jBtVmY6JjCpePf21ZlRElEqK4jNQ5 VvIw11qzh67ntJZnKwXq5t8IKE2JvHaAtPh3h5a+CYH3cYeKn/D08DaLaeNA27KnZfBz jd+jPrDev5SCia9+k1Rkt1IpZgkt0Hv5mlpu3QPQSso7Nwruou9rwwEcXT3Om/7z1q3u Mb4G77LV4QcSnq768LmwwoLgokouH38Vjc66A9YWUcBeQzHvrprhm8939zypdYECg0gE rF1w== X-Gm-Message-State: ABy/qLZLxcvCD8POz7EOZimU4EuswX78G7rBB+rUEU4x/lBHsI54Z797 L3x+dXoJug/IAOhFPUcJvOCkbOe5w4pNnGkuWUYVWw== X-Received: by 2002:a5d:408b:0:b0:314:1ddc:ecbd with SMTP id o11-20020a5d408b000000b003141ddcecbdmr12183874wrp.18.1689028193387; Mon, 10 Jul 2023 15:29:53 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id o6-20020adfeac6000000b00314145e6d61sm560200wrn.6.2023.07.10.15.29.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow , BALATON Zoltan , Mark Cave-Ayland Subject: [PULL 41/44] hw/ide: Extract IDEBus assignment into bmdma_init() Date: Tue, 11 Jul 2023 00:26:08 +0200 Message-Id: <20230710222611.50978-42-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow Every invocation of bmdma_init() is followed by `d->bmdma[i].bus = &d->bus[i]`. Resolve this redundancy by extracting it into bmdma_init(). Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Message-Id: <20230531211043.41724-5-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/cmd646.c | 1 - hw/ide/pci.c | 1 + hw/ide/piix.c | 1 - hw/ide/sii3112.c | 1 - hw/ide/via.c | 1 - 5 files changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index a68357c1c5..a094a6e12a 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -297,7 +297,6 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp) ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); - d->bmdma[i].bus = &d->bus[i]; ide_bus_register_restart_cb(&d->bus[i]); } } diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 9a5a7089d4..4cf1e9c679 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -519,6 +519,7 @@ void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d) bus->dma = &bm->dma; bm->irq = bus->irq; bus->irq = qemu_allocate_irq(bmdma_irq, bm, 0); + bm->bus = bus; bm->pci_dev = d; } diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 41d60921e3..a32f7ccece 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -144,7 +144,6 @@ static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp) ide_bus_init_output_irq(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); bmdma_init(&d->bus[i], &d->bmdma[i], d); - d->bmdma[i].bus = &d->bus[i]; ide_bus_register_restart_cb(&d->bus[i]); return true; diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index f9becdff8e..5dd3d03c29 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -287,7 +287,6 @@ static void sii3112_pci_realize(PCIDevice *dev, Error **errp) ide_bus_init_output_irq(&s->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&s->bus[i], &s->bmdma[i], s); - s->bmdma[i].bus = &s->bus[i]; ide_bus_register_restart_cb(&s->bus[i]); } } diff --git a/hw/ide/via.c b/hw/ide/via.c index 0caae52276..91253fa4ef 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -196,7 +196,6 @@ static void via_ide_realize(PCIDevice *dev, Error **errp) ide_bus_init_output_irq(&d->bus[i], qdev_get_gpio_in(ds, i)); bmdma_init(&d->bus[i], &d->bmdma[i], d); - d->bmdma[i].bus = &d->bus[i]; ide_bus_register_restart_cb(&d->bus[i]); } } From patchwork Mon Jul 10 22:26:09 2023 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: 701090 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5411106wrs; Mon, 10 Jul 2023 15:33:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzV+d+r0OgYqKdDEY/FNeKBbs2U8oIl9eA5wLegq9WH4g0L09ShyhY5Fj6H2hP4rPI/C/Z X-Received: by 2002:a05:620a:198a:b0:765:abeb:a13e with SMTP id bm10-20020a05620a198a00b00765abeba13emr16029576qkb.60.1689028400721; Mon, 10 Jul 2023 15:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028400; cv=none; d=google.com; s=arc-20160816; b=h/7/X/otiuL0wgGxwZn2mNOVEVJck/iY/AOyHJ5JHHVcjqYPO7fDtVh5An24G3Ml0X wL8YKPR5cn/0Vx98BhcvSzx30rb+QIvLZFkjd+rWzbzZmMnTe2c5e+1G7jd4O7REKo5W +q4UiT56namzFxoql0MSJKKne815Z3Hm639ReUfBS5SLVFTASJ/Jn5lYMvYaeCXMWuUX UfZJFb5NAMnQ0REIdYP1MYDPF/DoESk73Gy6gyP3T6o2gJ+iggcVmJBXM/ua+/2K9sTf NququXURRkF8ww3dRF0hsTn4C7k5DJrW8d0oaQTxdtjCxtgbM4UiBei1jSPBaTaXWM7A Psgg== 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=PvLt4SnnoFbS9lrbdOB+CQ2d7RCt4t40/o8unofp3lw=; fh=zxY8YoiaDw75VCQhtXaoe5GFBVtHNhrvMuRIEtH7IXI=; b=iWyoFflHjHJTLSraV+35nL73QbWxbTsCcnmHg435bYXcAWRhoqz7i+U0ux2xqPhj8o wk2JX+xKtEg6/slMwPllgIBoBbHhYvmwqRIALVKT0MzFFYrEJvO04oYVzGyMxi/dR/pJ 1vkpTmdZq2URjeNi1jjAcm7PwcvCTjf3mMABEQYjgohUrJIj4l1sG0suL9/MgccdEbbM V93Spw6VH2cICfyHyTO6pOH+NVvH+O0KwscKzV7F1WCpQ5wZgAEXdgsscHkdfNZFJclP EbMd+q5tT6Juhew4D/gknvIFKHBUcLoWN5BjyDPXMLrhMDRepKBZzDklfSs4jMYIS8BK YFFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vsz61TZd; 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 f23-20020a0caa97000000b00636dbdec256si253033qvb.103.2023.07.10.15.33.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:33:20 -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=vsz61TZd; 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 1qIzOd-0005YW-5A; Mon, 10 Jul 2023 18:30:20 -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 1qIzOQ-0005IL-K8 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:09 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzOK-0002EV-Jv for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:05 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3143ccb0f75so5910067f8f.0 for ; Mon, 10 Jul 2023 15:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028198; x=1691620198; 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=PvLt4SnnoFbS9lrbdOB+CQ2d7RCt4t40/o8unofp3lw=; b=vsz61TZdVk8RdSKNNseEZK+enFJcn54ttNB409F5B1gqsipW5xi1wbtO4v7sI2gxXJ g4WKdBrilbPHnfQI9EH9E6JaRS9fyGTlM4+F32wMk3dE6a6j+ka0ZRdDC7wd7e1DBdPk bSkpYpDpUiSwxHccZVrbuw6kiJRCRSZ2cL6Z/6JNpuYnI2BugbNxz82HKR0MEUJ2tAzB nIaSg37pQx//AMYEi09eczT1x+Vh91zxWS0EL3s+732+n9aTfXMnFCAvYOum3zm8HQV3 0AwCl+9v3Ocu4DcovrV4dqwuPjHi2AvsTroUBVMddF/GOBjMEtLGkajZGmnstw/9gwtH 88Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028198; x=1691620198; 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=PvLt4SnnoFbS9lrbdOB+CQ2d7RCt4t40/o8unofp3lw=; b=B/wubosVsUny8iEDXemGyyEcq3pRtGDZNNVx+KxOOkC4jrT4tmslM3cMWB/9uSwbmS +2QjdCG+uOGSswV2uvrd6itSsM9UQEPRJrxDdIT4N80JsiaFD9Qv0rywE83Yd2hUsmoK UCwF1X+Eg++lqchgt/txSq0hfWpQnvuKB39PmjlEJo9vZQQwdmZSfkk7xpHxqZWpV8H+ UowpWLHYsbnUY4feWfYRkbjjDM/2VX7ALP0ZvIfCUIxqTgp4ef0WyFS/vgwcM71vVld1 6Y4E3kYmBeE3fiGpoaTQi0/yARRKR8y3Y0AVZQD9pLxZe8CVZ/Az6pvP4oN9tgvweDER 9liQ== X-Gm-Message-State: ABy/qLatAY7+v+loETgs8YC/TBjpWbCDIDcnsNvouEKvvGMb8hCocyDm K+NxlD4Yv81jsxmgtrgMHqTV44ej9aSJkbfETHzuog== X-Received: by 2002:a05:6000:549:b0:314:1e69:f4b3 with SMTP id b9-20020a056000054900b003141e69f4b3mr15824458wrf.63.1689028198725; Mon, 10 Jul 2023 15:29:58 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id h25-20020a1ccc19000000b003fbcf032c55sm11455140wmb.7.2023.07.10.15.29.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:29:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow , BALATON Zoltan Subject: [PULL 42/44] hw/ide: Extract bmdma_status_writeb() Date: Tue, 11 Jul 2023 00:26:09 +0200 Message-Id: <20230710222611.50978-43-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 From: Bernhard Beschow Every TYPE_PCI_IDE device performs the same not-so-trivial bit manipulation by copy'n'paste code. Extract this into bmdma_status_writeb(), mirroring bmdma_cmd_writeb(). Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20230531211043.41724-6-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/ide/pci.h | 1 + hw/ide/cmd646.c | 2 +- hw/ide/pci.c | 5 +++++ hw/ide/piix.c | 2 +- hw/ide/sii3112.c | 6 ++---- hw/ide/via.c | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h index 74c127e32f..1ff469de87 100644 --- a/include/hw/ide/pci.h +++ b/include/hw/ide/pci.h @@ -58,6 +58,7 @@ struct PCIIDEState { void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d); void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val); +void bmdma_status_writeb(BMDMAState *bm, uint32_t val); extern MemoryRegionOps bmdma_addr_ioport_ops; void pci_ide_create_devs(PCIDevice *dev); diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index a094a6e12a..cabe9048b1 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -144,7 +144,7 @@ static void bmdma_write(void *opaque, hwaddr addr, cmd646_update_irq(pci_dev); break; case 2: - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); + bmdma_status_writeb(bm, val); break; case 3: if (bm == &bm->pci_dev->bmdma[0]) { diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 4cf1e9c679..0b26a4ce9f 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -318,6 +318,11 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) bm->cmd = val & 0x09; } +void bmdma_status_writeb(BMDMAState *bm, uint32_t val) +{ + bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); +} + static uint64_t bmdma_addr_read(void *opaque, hwaddr addr, unsigned width) { diff --git a/hw/ide/piix.c b/hw/ide/piix.c index a32f7ccece..47e0b474c3 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -76,7 +76,7 @@ static void bmdma_write(void *opaque, hwaddr addr, bmdma_cmd_writeb(bm, val); break; case 2: - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); + bmdma_status_writeb(bm, val); break; } } diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c index 5dd3d03c29..63dc4a0494 100644 --- a/hw/ide/sii3112.c +++ b/hw/ide/sii3112.c @@ -149,8 +149,7 @@ static void sii3112_reg_write(void *opaque, hwaddr addr, break; case 0x02: case 0x12: - d->i.bmdma[0].status = (val & 0x60) | (d->i.bmdma[0].status & 1) | - (d->i.bmdma[0].status & ~val & 6); + bmdma_status_writeb(&d->i.bmdma[0], val); break; case 0x04 ... 0x07: bmdma_addr_ioport_ops.write(&d->i.bmdma[0], addr - 4, val, size); @@ -165,8 +164,7 @@ static void sii3112_reg_write(void *opaque, hwaddr addr, break; case 0x0a: case 0x1a: - d->i.bmdma[1].status = (val & 0x60) | (d->i.bmdma[1].status & 1) | - (d->i.bmdma[1].status & ~val & 6); + bmdma_status_writeb(&d->i.bmdma[1], val); break; case 0x0c ... 0x0f: bmdma_addr_ioport_ops.write(&d->i.bmdma[1], addr - 12, val, size); diff --git a/hw/ide/via.c b/hw/ide/via.c index 91253fa4ef..fff23803a6 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -75,7 +75,7 @@ static void bmdma_write(void *opaque, hwaddr addr, bmdma_cmd_writeb(bm, val); break; case 2: - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); + bmdma_status_writeb(bm, val); break; default:; } From patchwork Mon Jul 10 22:26:10 2023 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: 701083 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410608wrs; Mon, 10 Jul 2023 15:32:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjMzV+oMVJaE2Bbb5ZBvpR6a92STGdWRjuz9jTJVVqlDjEC0ZU/ga26m0+4l3lKdcPOXkN X-Received: by 2002:a05:620a:40d3:b0:767:b348:5a9 with SMTP id g19-20020a05620a40d300b00767b34805a9mr13222859qko.21.1689028326357; Mon, 10 Jul 2023 15:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028326; cv=none; d=google.com; s=arc-20160816; b=pUFNCX71H73X4K3EXSNnHf4k0FTzsmUsvZmBbcXUD+JJGWL65MM6o5hmJ8JG0fO4qe 2yJ9K+AAYC/emOehL9gJ7LC7sOQ4fNZKDgWmjRdfDyJ6EBBcEeYya9ZJsSqJHlcBSX6S KetczIzxRT1eKJ2BvUHcGI3soP7LCc3KguxqzggPVTWog/pLQLPHIa/TsMvSMv6Jujhk imiKhGP5W2m2aEc8Dg6DHIfporm8LgqwU3eO4IvrhSRGVv0Fvr0cTadUstB99N4zV3L2 GZcxh50g9Bp2EayYZhm8ITesvZxa9xUH5MhTTejfNjOhELVMOS1/i9Z0HcBSonpOjvxP iXqA== 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=yijSgmGH6Oo6rFXhTFj5oyPztYxt45G89j4AU83zdDI=; fh=hcwln6fraUM3+9Hj3KHhLVXh6W//hTqT+Pt2BsvEI7E=; b=NoTuRkLq/b0VUS5VZTAJrGF06/jZOJW6beWtPHRkuUCagbkMbEtsosUNT8QDukwGs3 CKY+rSxzTUbNE9/Joq38OWOQWL+Wx83DDHOPlwXnbryI9vT1/UoFhyidRctwlA7ElUrH qx0PPm+lrS1X+FSXugdgeZDZvic2+YFpZuQa+FIkAC4R3pYxMbb6TcI1mowGxh/BwPRP 1G8DGN3eCr1+pB+lgCU1Qd9ap+tmqSYqSlXclF/bApaFJSkuzktaMEHeLyYZGFoXYtAU CWMaZb+B/krYnK5vyfEYTjqu+25ILLSBdT8uGqHcEP+FBbErlKrFfMFMM4Vr5Q8kBqsU Cnqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jPUuqUkL; 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 s27-20020a05620a081b00b00767247d8e3esi253077qks.654.2023.07.10.15.32.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:32:06 -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=jPUuqUkL; 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 1qIzOe-0005hM-QM; Mon, 10 Jul 2023 18:30:20 -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 1qIzOT-0005Lt-Pd for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:11 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzOQ-0002Qj-CI for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:09 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbc656873eso63886495e9.1 for ; Mon, 10 Jul 2023 15:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028204; x=1691620204; 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=yijSgmGH6Oo6rFXhTFj5oyPztYxt45G89j4AU83zdDI=; b=jPUuqUkLXcZwdFCESnFiL30uQiuqYh7B7F6YuPqfGAquhVNNml/KDjkCkxPPDb9R7h 3CPaWuDExgTf78wH5rbLBBk0ovPFsYAHTBB77Lt7WyjGxG7tIAKf9vUYBZ+01zUA/5sj equLZGfJdBxmrbdq8BpE+MBJ28cKdgUTyvclLbIJOFKjJFS00XQZFzdUnNqtgUX/PqAJ 4jQoWYUd35ZSp84IgBK54a6CjJqO574l1iEHf00G9cSOkUV8prLaHb5ePFKxxmrqulAc V5z+Q1HyZZTITUBpTOasjlc9P+lL/ASiCySclNmZGnqc565j7eLrjiCB1xlVwuT+mx6M jUtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028204; x=1691620204; 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=yijSgmGH6Oo6rFXhTFj5oyPztYxt45G89j4AU83zdDI=; b=ZklOQkps+OK5oYiyuviKEaGGA2RPL6mCzpMkBtM4gBQhido4h5WmAhm6ohnOJ+ft2E DUC/Hmi7YujgU9eW32ObAbzKKz46lZBc+Y8zObAbBvVevWUvKfw4LQHZsqiMRMCXCLAj 7PXH+biczrj+RPEN4dWHpmK0pXvgQotsxEYtE5qd2ew5kUR87v8yWC4qAvjqf+74j3uA OGdFnrKfWO8eUwlibgLuI1oAJMC6y0Zv/4XtM10pGmHJ/e7gV7L5ZUGhELeGHsD5EjpQ ZEqSUsVr64IYN8Ud7sc9cHANOoUdklgl3n0DQ03kdkGM4SQyoWji5cpWS/IB4P2xT0B+ 2jlw== X-Gm-Message-State: ABy/qLZI+pJDFKtnJINUu+2JTsyT1/Hh6R0ANGB2chUd8jJN8qipo2C0 U++YrY6ORahiZ074lXOphYN9FfnsRf/i14cD7vbLgg== X-Received: by 2002:a1c:7404:0:b0:3fb:424b:ef6e with SMTP id p4-20020a1c7404000000b003fb424bef6emr15816852wmc.23.1689028204092; Mon, 10 Jul 2023 15:30:04 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm520227wrm.81.2023.07.10.15.30.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:30:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow Subject: [PULL 43/44] hw/ide/pci: Replace some magic numbers by constants Date: Tue, 11 Jul 2023 00:26:10 +0200 Message-Id: <20230710222611.50978-44-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow Signed-off-by: Bernhard Beschow Message-Id: <20230531211043.41724-7-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 0b26a4ce9f..a25b352537 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -320,7 +320,8 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) void bmdma_status_writeb(BMDMAState *bm, uint32_t val) { - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); + bm->status = (val & 0x60) | (bm->status & BM_STATUS_DMAING) + | (bm->status & ~val & (BM_STATUS_ERROR | BM_STATUS_INT)); } static uint64_t bmdma_addr_read(void *opaque, hwaddr addr, From patchwork Mon Jul 10 22:26:11 2023 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: 701082 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5410525wrs; Mon, 10 Jul 2023 15:31:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUnb6mVJsnWAB78V1eOydA4AkRDyPDjzCTQrLCkYu3mKOYR3hndTW8IUfnifSMtodQF4uT X-Received: by 2002:a37:2c81:0:b0:765:ab6e:53fb with SMTP id s123-20020a372c81000000b00765ab6e53fbmr11262075qkh.40.1689028310538; Mon, 10 Jul 2023 15:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689028310; cv=none; d=google.com; s=arc-20160816; b=HN3H8YW9JhCqzl8VfuQpKaapDvqSUji1LetvGZxtgeTy449XrORHA3/75WV4YkplrB KLRYdBdgv2A/iJjPCPUxTdx14IFrDTHM0c8rA+g4nt2bTJlMGfjrq0ib0qL9oQMi/Lhf cYF6aujgULc8i8gcPpqt89TQMoNISDKMv/zP0s7RU7anUWYX4hjULP9wEiKF/P0gXDqt u55qc92CcJfFjAR/ndIDN/frDwgtQ/cvDQABg40ifqKBOyq1k2Qo5zSh9x8inwWjD7fp zoP2Zd2USJ3VAqmhur1mx9A8G4t8cUFtvz9AnFW1yX1NPE3+HytIjzBSISdaCbgUnwJR E2iQ== 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=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; fh=hcwln6fraUM3+9Hj3KHhLVXh6W//hTqT+Pt2BsvEI7E=; b=cvGzfZrGPIJaIfqlgRoHu/x0dmQ6VETXDFFtFzSSIwNg3irDLuINyC2ZDShVs53vq2 rGt5X/wZj1L6aoOO7RQcBr9Ig8lOe5SyV5CNO47AXN1VUIekBJzO6zenD+KWdDUUGxdN 7smca6k9B41KJLklwj2+aSIxDmiWFusLkVX+/xSczv7BdXE+USWQKlUoZ93uIKm12eZv xo8NbeVXD4SqLG0Vw2b/BH8r93uUvHP44Ws15v8Tvjs9VFsqgs5trohS0ZgNKWYhSUFp jhl14Q+8mszO05oyRd9O9et4XVKi/d9io3Hgbc1R6pYw6AU7EQdaxjruPBBFsHS6rlAC Gy2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hEPjb8/C"; 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 u9-20020a05620a430900b00767117b9c26si274350qko.210.2023.07.10.15.31.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 15:31:50 -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="hEPjb8/C"; 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 1qIzOf-0005i2-1P; Mon, 10 Jul 2023 18:30:21 -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 1qIzOX-0005P9-5y for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:14 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIzOU-0002S3-VF for qemu-devel@nongnu.org; Mon, 10 Jul 2023 18:30:12 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fc03aa6e04so30160835e9.2 for ; Mon, 10 Jul 2023 15:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689028209; x=1691620209; 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=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; b=hEPjb8/CeLGyUKZlGSHWX5jprjvTOLtpLi1Rx/Fm7B7nmowdwglGrAjnds3GHSwGJB 57LFuXMVNxE2UBSUSW+SrTKaSnxHjLhRfrza6BWXzSsxcU4KnWYwF9jJceVYGd1uunrU vbNV21XiCdY8i6bptyG/u4qAw4xX3lJQNf+XvR789NBeL5ZlGc4KOEFe0udM/9x/DYX6 4uQeRDLtefcURQIvNP7ZKy1AkTfr28H2damXICgVyQujdS3B6cCw0bU5A0HU3BxMX4tu S7snt7e+Wy+W17RSk0y052HrA5RoeEWXsOR8r0dKhxwWojeZRpj+pAcrQ7ECPYVUMbBW opkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689028209; x=1691620209; 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=6Cp+d10dJMsCx7odnm1IN8BJal/+SMZmh3wzGdS75IY=; b=duacImi+k/DWFKetvkfAyEWPhPRzdK3c7SnYXkqHOHP9Jt1AVfEj/K/jUMEHzFgo7i cZs43o64MO8Bl/McMnt941wA0KEJbAKeRNfSO6UZFZzD0QlpWxJKONSxHPW62htb2ft2 tPkdGj2cWEI9p7dWz3OK7m1sjnFSu2MatsfmiiVhNGRW8CoJX0ZKyDcRRTIhdyYIkbLr T63Xub66ZPcXZABDJfvEFpJaqi67y1H8i9ueW2iNHzfRNAEZpLKY4qHVv1sJwOAw1pDs SZhrcnO14lBMHw22VBjMynSMyxhmcBH1S4cxLWrRBG6GF+LjRy9sV0RtgkCJjlIeysRX 03dg== X-Gm-Message-State: ABy/qLbipor7SmRbhe5zQap8RXvUhGXETRfTGSZYO69t6GZ0h8Pgq+Oa HCg6AJbvvDUG50F2x4Uat5OEYLu4p+hwNi3ksXzQNw== X-Received: by 2002:a1c:7910:0:b0:3fa:962e:e8f4 with SMTP id l16-20020a1c7910000000b003fa962ee8f4mr3827286wme.26.1689028209177; Mon, 10 Jul 2023 15:30:09 -0700 (PDT) Received: from m1x-phil.lan (mst45-h01-176-184-47-225.dsl.sta.abo.bbox.fr. [176.184.47.225]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c378400b003fbfc61d36asm929811wmr.5.2023.07.10.15.30.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 15:30:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Siarhei Volkau , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang , Bernhard Beschow Subject: [PULL 44/44] hw/ide/piix: Move registration of VMStateDescription to DeviceClass Date: Tue, 11 Jul 2023 00:26:11 +0200 Message-Id: <20230710222611.50978-45-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230710222611.50978-1-philmd@linaro.org> References: <20230710222611.50978-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Bernhard Beschow The modern, declarative way to set up VM state handling is to assign to DeviceClass::vmsd attribute. There shouldn't be any change in behavior since dc->vmsd causes vmstate_register_with_alias_id() to be called on the instance during the instance init phase. vmstate_register() was also called during the instance init phase which forwards to vmstate_register_with_alias_id() internally. Checking the migration schema before and after this patch confirms: before: > qemu-system-x86_64 -S > qemu > migrate -d exec:cat>before.mig after: > qemu-system-x86_64 -S > qemu > migrate -d exec:cat>after.mig > analyze-migration.py -d desc -f before.mig > before.json > analyze-migration.py -d desc -f after.mig > after.json > diff before.json after.json -> empty Signed-off-by: Bernhard Beschow Message-Id: <20230531211043.41724-8-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/ide/piix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 47e0b474c3..151f206046 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -28,7 +28,6 @@ */ #include "qemu/osdep.h" -#include "migration/vmstate.h" #include "qapi/error.h" #include "hw/pci/pci.h" #include "hw/ide/piix.h" @@ -159,8 +158,6 @@ static void pci_piix_ide_realize(PCIDevice *dev, Error **errp) bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); - vmstate_register(VMSTATE_IF(dev), 0, &vmstate_ide_pci, d); - for (unsigned i = 0; i < 2; i++) { if (!pci_piix_init_bus(d, i, errp)) { return; @@ -186,6 +183,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->reset = piix_ide_reset; + dc->vmsd = &vmstate_ide_pci; k->realize = pci_piix_ide_realize; k->exit = pci_piix_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_INTEL; @@ -208,6 +206,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); dc->reset = piix_ide_reset; + dc->vmsd = &vmstate_ide_pci; k->realize = pci_piix_ide_realize; k->exit = pci_piix_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_INTEL;