From patchwork Wed Mar 17 15:34:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 403197 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp604455jai; Wed, 17 Mar 2021 08:56:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRFcO6+1T+eBIuBy95gbGGG4v2PM32ZtCTIY7jQ6fSsHLdv4nXH20w72giDW0+zF+InQ78 X-Received: by 2002:a92:b00d:: with SMTP id x13mr8095355ilh.128.1615996569333; Wed, 17 Mar 2021 08:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615996569; cv=none; d=google.com; s=arc-20160816; b=ACJVwiCXKCHLJwLJiA+dWHKaEubSN1vO3vCeJMVxyU/zYmmi0okUvIE7cLdGuXUBZQ jp/bP50soDJhk5j51aTxgvrf9rkunCGUdxWvVyvRZFdy6lbWAp5Ac6QQkQPpyhC75vFE 9aIvv8tq019h2nOzzkXpX4B/hYaDUqALm0GurpZjC3ntDad7u4fQyEuLoOodbqLbsR7m BjrSfQ96fbLOJldCvx0bTMrng9LF88oL8iHl3rb1mqRifP2V2TMXdRN8+CVzMr+CBdNA gbVl0wgBVlzhPSH593PE4bB7+KDKYQuhF+g3sBmkSYjxA+91NNDtInOxlmRinSEaConj hCEQ== 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=NmBZo7AXRGPv0b50PXBcgMx9DdtcXIoXUKSXEv41j2E=; b=xIBbP1vvDOFw/G705uAakH2ARIKuFDAufca59qxQkSudIMsgK6t+neNvjjjSgFIoUN TCsEUoH8B+rG1ZO/AJMhdmkmxcAr22J9G1K4E2SVh6LOes0dPpaNXNeFTu6IYSIF66aG SIxhQoqBO4cACDvb/zACZVfOhy0uahw+qRbIotgmedSf9eXuwuDu6K3C8iazeUShNA5d HebY/nOC8eR3NSblpf7I+6gecOUczYo9olbKeb6fSCDQhfIUUd9PeokA9D1NatxcCE1L lFau623zk4Y/URg7akOiO2HeamWnPa5zVw5RhhPw4hv9vjZkLdjgg57s9sGLbgaFegry /fBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YrDE5Yoy; 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 p2si15157191iln.65.2021.03.17.08.56.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Mar 2021 08:56: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=YrDE5Yoy; 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]:55248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMYWm-00020x-MW for patch@linaro.org; Wed, 17 Mar 2021 11:56:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMYCR-0005CI-CU for qemu-devel@nongnu.org; Wed, 17 Mar 2021 11:35:07 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:36737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMYCN-0007Bh-7k for qemu-devel@nongnu.org; Wed, 17 Mar 2021 11:35:07 -0400 Received: by mail-ot1-x332.google.com with SMTP id g8-20020a9d6c480000b02901b65ca2432cso2180067otq.3 for ; Wed, 17 Mar 2021 08:35:02 -0700 (PDT) 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=NmBZo7AXRGPv0b50PXBcgMx9DdtcXIoXUKSXEv41j2E=; b=YrDE5YoyQdpDau7WrKwMsvfPgvg1yS/rPssulrB9VlESBJAVMxx/tFPh93veIdPq4a rWZZA49KnLKqA28bwQslm8doU3Zu6x94fqBs0ElSx40sAd+qEDb5WknOToJmUTzB+Ut7 OS1IEWaQl6jDi06B+LILmsD8US27TJaaLCoYq7FTfm3BleGYl5leVeo93UD9MrFdlY+w bYBnWHTV9emDmTtRm7K2SXPYgD/V0m4t3oIUhg6Igo21MxbZSvEk6hpHwOsTtwrtCigP /mCM87XuaANdYZPFDFLu8ktV8Zsr83xwOujQB4AleHKuN9sl7RNz2tOChASTFobn9rbl Hyww== 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=NmBZo7AXRGPv0b50PXBcgMx9DdtcXIoXUKSXEv41j2E=; b=DJdNSUa+kfq+6eV0NnTYAwH8TmRQsE/42Zwn+aAxQBHdg29LcAIXB1N9uTS2c3ndI8 JVA2FXkj8G91TufPvvpm2O+xMh8tNt6n7QJCIJdtQ5lpl6JhuFlX5DaBryx7s58ZNVuz 08ohjq70oI+1Rpndb0yFsgxf3PoKLBoUJcM4dWjJ4LXTSOmno1u6AzvTdKMBiVaILHMD s+ZbJCy4Rv2dQ+ROjjBjQhRetVDIOUcCNoST3/28E5JeeG/5+yETBSZtj0YBt05HwIaJ IS5xzb8TnlPqm6/avSvl3sxbB4N9LkVWQIUjxutvI2P6D+hQIgWcnVO9Voxe+nTUGY2+ P/Qg== X-Gm-Message-State: AOAM530l/iahhuikcsVeqzjXFNAy/cUWeeREExBZNelKTayC8Iz0G6Ad euTf0a6vAhd60scijL/aiY9fntIpkDImgi5m X-Received: by 2002:a9d:12a4:: with SMTP id g33mr3803799otg.308.1615995302133; Wed, 17 Mar 2021 08:35:02 -0700 (PDT) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id i11sm8271154otp.76.2021.03.17.08.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 08:35:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/38] tcg/tci: Clean up deposit operations Date: Wed, 17 Mar 2021 09:34:22 -0600 Message-Id: <20210317153444.310566-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317153444.310566-1-richard.henderson@linaro.org> References: <20210317153444.310566-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.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: peter.maydell@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= 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. Reviewed-by: Philippe Mathieu-Daudé 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 2fcf5a2473..22a5832387 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) * c = condition (TCGCond) * i = immediate (uint32_t) * I = immediate (tcg_target_ulong) @@ -238,6 +239,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) @@ -434,11 +445,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 @@ -629,13 +638,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: @@ -791,13 +795,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)