From patchwork Mon Feb 8 02:37:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 378459 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp4322043jah; Sun, 7 Feb 2021 19:09:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwXkSVKAYGdMKbi8tKVPj5cvHKLm7ajDsmmUnFhrWa8S3ckYsmfwoPTKjBshE8aqH7l4Cn X-Received: by 2002:a25:b951:: with SMTP id s17mr23994421ybm.498.1612753748769; Sun, 07 Feb 2021 19:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612753748; cv=none; d=google.com; s=arc-20160816; b=M2x13xm7d1s3Kt6Ua1lWV3be/xCC0oBoRc++6LzB/lbdoJ7t1+ecHcrEr/LFwNrDfc 0L82j9x10AXmp0qe65F9tzAasuBV8USBILCYDMNy3ioNLmN4UrY8SH/u7PYbKVPIWNmK 1mbqUAraw9wdnyaJrT41drzloOhNQYE349bXP/NPkRwlyS8SuIUEHzTBnwwLIeRitzB7 wsMXPnTgq/EXHgiYpxrL8q91ofcMTGMw9ZUurvSoa9jTEh52nle7C11k0TGJOsIdUxVU ViQNWLWJSKBN6TAs71+elcH6jV8jXycnxoECNAxuIzi2TQUVChHL7r4ZIQ/s2+ry6ABi DfXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=wOvkZ0sAbeq0kMMHx/GBq6hm2tymswKeRwzIJ0G9jzI=; b=go++WfVhlSxj9JyWdsC8iiaQu9z7dHeS8mSjxP+Vjj2rI5lsbNpHoJg1NLhXth2HUA PllIwn6CmBwq+1IC/53Ni+v4r3QKwANnIlvMJkWFsWC6NedSP8uqoRPqI+p+GzagVpZc O/M5fyM4Ey54kYRxZmX/NEiNOAB9SicvP/i90yv0XMwURn3N3gnn9x2yfgiUxQGO4VRH QrkAPM/j+ScTke1aIp8uKyHzoYAljUmCc7XvbGOCn7aqf/kca9F9vFR8DvGm6KLQC2xA rg07ARu/wwTDbYNGcUfp4d0wkfz00dwPTVe0QT8qabNyTqptCQcHYQmH/74i+AiWbdvr QZbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DgcCHug/"; 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 x13si15780439ybt.404.2021.02.07.19.09.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 07 Feb 2021 19:09:08 -0800 (PST) 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="DgcCHug/"; 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]:45010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8wvE-0000ft-7y for patch@linaro.org; Sun, 07 Feb 2021 22:09:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8wRn-0001dK-2c for qemu-devel@nongnu.org; Sun, 07 Feb 2021 21:38:43 -0500 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:44640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8wRe-0005sO-Gh for qemu-devel@nongnu.org; Sun, 07 Feb 2021 21:38:42 -0500 Received: by mail-pg1-x529.google.com with SMTP id j5so452313pgb.11 for ; Sun, 07 Feb 2021 18:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wOvkZ0sAbeq0kMMHx/GBq6hm2tymswKeRwzIJ0G9jzI=; b=DgcCHug/M2uULdTogyMNGY0ZQNznIvwJcHVmw1Fs2SHZPByN8VIdjNK0dfP0M4J1Kl Z1lYqbRv973FShU8dux2pYUnKy8gvsNBn+krckSMKVQUEbxlK99d20gBV27dvWwUWQYU 495nU7rXqG+goRCZnss9pPlMXPab/QVfD7pUC7KqHGQU41lhcPLXPWa4lBK0lhOxEM7s iELrF3jfci1/w7xRLRY64AzdfqJVxx1OMuKcgPKHiXBpn1t4czuevzxsb8tjlcgwgddZ GK6pUmBck5YAq0qya/+3eu3IhBJc2fOqEslL+Md1TUMoYCiymqVQpnfxJqEC9WEHycYr U/tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wOvkZ0sAbeq0kMMHx/GBq6hm2tymswKeRwzIJ0G9jzI=; b=AxKsoevgC4fAxosqEklxM9nGdG+Vdp8JFwlMa9WbYzJ1O26D5YXRzDY8r5qpJU9wxQ ScHLQiyIn7E+r/C/nmWWxSguIHy8yc/czveoYoECVhtjuH/DmfBXop4XlTSPTYJVBBGM AXIblpUZx0eDId1xgYcxtCTKl15YtKQAa4nSC11NYTQ4wV1rDGVz6zaqxjTml6zlaWBr gKps3tnDEWU4Q8kI7nCHNf5y+DDsL6kNxWGVWGx8Ys7Jy3SSr1pH7FPTbVz/ZnxCEJ1T QDoPHpEVK/wbkomTHuwcJKoqkLAzSeIjDjWSOjR7AN/Kz1F3DOnqa59SRUAtmxCrgGbE r6TQ== X-Gm-Message-State: AOAM5320MS8Eacxap1nIYk6iWlejiNH6+OPNZXI/c2pYXzbu4/AL9Pbi v208W1sPH4UYQsfSB2IFcM/IQEb/cJBg0A== X-Received: by 2002:a63:fc48:: with SMTP id r8mr14659281pgk.300.1612751912535; Sun, 07 Feb 2021 18:38:32 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id j17sm16158689pfh.183.2021.02.07.18.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 18:38:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 31/70] tcg/tci: Clean up deposit operations Date: Sun, 7 Feb 2021 18:37:13 -0800 Message-Id: <20210208023752.270606-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210208023752.270606-1-richard.henderson@linaro.org> References: <20210208023752.270606-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sw@weilnetz.de Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the correct set of asserts during code generation. We do not require the first input to overlap the output; the existing interpreter already supported that. Split out tci_args_rrrbb in the translator. Use the deposit32/64 functions rather than inline expansion. Signed-off-by: Richard Henderson --- tcg/tci/tcg-target-con-set.h | 1 - tcg/tci.c | 33 ++++++++++++++++----------------- tcg/tci/tcg-target.c.inc | 24 ++++++++++++++---------- 3 files changed, 30 insertions(+), 28 deletions(-) -- 2.25.1 diff --git a/tcg/tci/tcg-target-con-set.h b/tcg/tci/tcg-target-con-set.h index f51b7bcb13..316730f32c 100644 --- a/tcg/tci/tcg-target-con-set.h +++ b/tcg/tci/tcg-target-con-set.h @@ -13,7 +13,6 @@ C_O0_I2(r, r) C_O0_I3(r, r, r) C_O0_I4(r, r, r, r) C_O1_I1(r, r) -C_O1_I2(r, 0, r) C_O1_I2(r, r, r) C_O1_I4(r, r, r, r, r) C_O2_I1(r, r, r) diff --git a/tcg/tci.c b/tcg/tci.c index cb24295cd9..e10ccfc344 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -168,6 +168,7 @@ static tcg_target_ulong tci_read_label(const uint8_t **tb_ptr) * tci_args_ * where arguments is a sequence of * + * b = immediate (bit position) * i = immediate (uint32_t) * I = immediate (tcg_target_ulong) * r = register @@ -236,6 +237,16 @@ static void tci_args_rrrc(const uint8_t **tb_ptr, *c3 = tci_read_b(tb_ptr); } +static void tci_args_rrrbb(const uint8_t **tb_ptr, TCGReg *r0, TCGReg *r1, + TCGReg *r2, uint8_t *i3, uint8_t *i4) +{ + *r0 = tci_read_r(tb_ptr); + *r1 = tci_read_r(tb_ptr); + *r2 = tci_read_r(tb_ptr); + *i3 = tci_read_b(tb_ptr); + *i4 = tci_read_b(tb_ptr); +} + #if TCG_TARGET_REG_BITS == 32 static void tci_args_rrrr(const uint8_t **tb_ptr, TCGReg *r0, TCGReg *r1, TCGReg *r2, TCGReg *r3) @@ -449,11 +460,9 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, TCGReg r0, r1, r2; tcg_target_ulong t0; tcg_target_ulong t1; - tcg_target_ulong t2; TCGCond condition; target_ulong taddr; - uint8_t tmp8; - uint16_t tmp16; + uint8_t pos, len; uint32_t tmp32; uint64_t tmp64; #if TCG_TARGET_REG_BITS == 32 @@ -644,13 +653,8 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, #endif #if TCG_TARGET_HAS_deposit_i32 case INDEX_op_deposit_i32: - t0 = *tb_ptr++; - t1 = tci_read_rval(regs, &tb_ptr); - t2 = tci_read_rval(regs, &tb_ptr); - tmp16 = *tb_ptr++; - tmp8 = *tb_ptr++; - tmp32 = (((1 << tmp8) - 1) << tmp16); - tci_write_reg(regs, t0, (t1 & ~tmp32) | ((t2 << tmp16) & tmp32)); + tci_args_rrrbb(&tb_ptr, &r0, &r1, &r2, &pos, &len); + regs[r0] = deposit32(regs[r1], pos, len, regs[r2]); break; #endif case INDEX_op_brcond_i32: @@ -806,13 +810,8 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env, #endif #if TCG_TARGET_HAS_deposit_i64 case INDEX_op_deposit_i64: - t0 = *tb_ptr++; - t1 = tci_read_rval(regs, &tb_ptr); - t2 = tci_read_rval(regs, &tb_ptr); - tmp16 = *tb_ptr++; - tmp8 = *tb_ptr++; - tmp64 = (((1ULL << tmp8) - 1) << tmp16); - tci_write_reg(regs, t0, (t1 & ~tmp64) | ((t2 << tmp16) & tmp64)); + tci_args_rrrbb(&tb_ptr, &r0, &r1, &r2, &pos, &len); + regs[r0] = deposit64(regs[r1], pos, len, regs[r2]); break; #endif case INDEX_op_brcond_i64: diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 2c64b4f617..640407b4a8 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -126,11 +126,9 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_rotr_i64: case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: - return C_O1_I2(r, r, r); - case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: - return C_O1_I2(r, 0, r); + return C_O1_I2(r, r, r); case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: @@ -480,13 +478,19 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, break; CASE_32_64(deposit) /* Optional (TCG_TARGET_HAS_deposit_*). */ - tcg_out_r(s, args[0]); - tcg_out_r(s, args[1]); - tcg_out_r(s, args[2]); - tcg_debug_assert(args[3] <= UINT8_MAX); - tcg_out8(s, args[3]); - tcg_debug_assert(args[4] <= UINT8_MAX); - tcg_out8(s, args[4]); + { + TCGArg pos = args[3], len = args[4]; + TCGArg max = opc == INDEX_op_deposit_i32 ? 32 : 64; + + tcg_debug_assert(pos < max); + tcg_debug_assert(pos + len <= max); + + tcg_out_r(s, args[0]); + tcg_out_r(s, args[1]); + tcg_out_r(s, args[2]); + tcg_out8(s, pos); + tcg_out8(s, len); + } break; CASE_32_64(brcond)