From patchwork Wed Apr 12 11:43:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672614 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp287481wrx; Wed, 12 Apr 2023 04:44:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YSk90U05D4tNuoREHpxj0eiHsRZ3ed3KXITW47OZv0POhYpCClPH+a8x9folCy8zW8KQIB X-Received: by 2002:ac8:5b56:0:b0:3e6:459c:1312 with SMTP id n22-20020ac85b56000000b003e6459c1312mr24977452qtw.11.1681299897869; Wed, 12 Apr 2023 04:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681299897; cv=none; d=google.com; s=arc-20160816; b=tytBIH8eQgvgKpbQ8T9j+9xpM9xsm4nwcqGnJ9rA7BRpKPHjlS0zqF4Lem4/LlXmV8 37u0zjfL0OolBl/PJe0NFQb3P5r0BC9qvTloebVr3G6ZGFEczwfYLGJTv1l15OfSRyLU OlbfE35ygZZUkVD/kbj223Ep3SKHuJ6Hz82X3pjJQoGgld7OT2kM4Pp+Ah9pMPzxaS6W NQMc25JS6HayyM22IewCEXdKaMkDK95TAB3S+2rvfLGk4B9whgJVS0roFiJ4rfSn5df+ cX7i1HM+oVkYaatR89fqTye+u4X3wUH+QEpnZTXrf7giapIbPfkhN0md7UTRcqIhFRat queQ== 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=MWsW7ULWn4A1fSKqhQgD2QQ0V+0wVuw8Sc2XWLbfpiw=; b=VNAQqEKWw8jpajj/sbzbtOxBp5MZFPexnGZ54tM1he32GPw8T0lCMetiXSWpHhqTY4 8U1T0pWfTe03M/BTS6RyuZOrKkPneUk/xHd/qouadYkcgpdz2mBRtZkU/nwx7SFwvJJd Swjn+NNQ7yJSnCUiARb75QM5lmmAll/mRNPhHTGLexsim+DWjjTncTIfIF8QPEi/LJuO YXIRMja/+NsoA+KlWRymDkm9Au4YPY2I+7+0i6X4o2375Omf0ostCFMigHcieiBDQCnc VnSCHOnaioKccZfp0kl6MKrNY88/R71bZQLaIPP8JEfpSr7TuIpZdRmvgZckAmmBTWM0 7OPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EaGiVx4G; 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 h16-20020a05622a171000b003b9ec33eabesi10235074qtk.463.2023.04.12.04.44.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Apr 2023 04:44:57 -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=EaGiVx4G; 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 1pmYtJ-0004wx-G2; Wed, 12 Apr 2023 07:43:57 -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 1pmYt6-0004k7-I5 for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:45 -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 1pmYt3-0002OA-Ah for qemu-devel@nongnu.org; Wed, 12 Apr 2023 07:43:44 -0400 Received: by mail-wr1-x431.google.com with SMTP id j1so14578095wrb.0 for ; Wed, 12 Apr 2023 04:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681299819; x=1683891819; 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=MWsW7ULWn4A1fSKqhQgD2QQ0V+0wVuw8Sc2XWLbfpiw=; b=EaGiVx4GjyyxgSsuNjJfa17MmsOKGI61kKrBoCOg/r7MFkgDWealhajr5GU/1r361p lsBlJ5LSdh3Gu5YaDhGX7so8r8b9mlAxU2z/lzBqBtR1NHidKH6xFCGckErGpkdUcVrA dvbyvUFKT8U1UZvWjpg6QR2ZM+hbwCSUHDutG6KZXJrNmTYYxdbA0kQZrP14dZa5xRa/ 1qWkSHXfWU1w0kk7UUgZbd+BMuX6VLaz59aMnOZYoOdsqItr3NP7jhgCWsl6ES7tVoUW gqvmBUfMDIovJUDfbEFsWvh9IBS6s6PnnAKWlz5FMSdxhawBC1UdQOBtJdnd34iW1jQT EpCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681299819; x=1683891819; 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=MWsW7ULWn4A1fSKqhQgD2QQ0V+0wVuw8Sc2XWLbfpiw=; b=K2eNtzgudVG7RPQnpg6nrKmFgJV61DcbDiHacL+lIZOoPujBLx8lM+L+xQ0J8YIzI+ m2Al/T/oyKTtd8d4BYy93aqBiZ3fSPssxGohU3Z1ATZZqAa9KPixP2lc6U9DKuj5OLoR hSK6L11dMESm/iVyOQVwxWzELEwuD9zt6y8ajYNnl6E+Eyx8reQTtifVZtVSJkjWmI9h YVSXuuHtmq5RDjN5zr+B0nF1O4GgjnixgeplHa9N7GcUgTBI5qX5ZWKBPVnOkamZdYae Omc8xr4jjC1AcPgI/KmGFXwKUMWIAgeA/CgsnEiy+8VExCUtBiziNpFOhLTnIxZzFrWp NGiQ== X-Gm-Message-State: AAQBX9fXeVLbjV3AI6/9JDAlv3Y8byRSLaGBvqchyFy9/NToxGrRiWcR QrtFO8aL1d6IkSXjYV+zOZzkJMM8nDzKAszRXBD246W1 X-Received: by 2002:adf:f1ca:0:b0:2f4:eb13:4091 with SMTP id z10-20020adff1ca000000b002f4eb134091mr758520wro.45.1681299819677; Wed, 12 Apr 2023 04:43:39 -0700 (PDT) Received: from stoup.hotel.gast (ip-037-024-010-236.um08.pools.vodafone-ip.de. [37.24.10.236]) by smtp.gmail.com with ESMTPSA id k9-20020a5d4289000000b002d21379bcabsm16980826wrq.110.2023.04.12.04.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 04:43:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, qemu-riscv@nongnu.org, LIU Zhiwei , Weiwei Li , Alistair Francis , Daniel Henrique Barboza Subject: [PATCH v7 05/25] target/riscv: Add a tb flags field for vstart Date: Wed, 12 Apr 2023 13:43:13 +0200 Message-Id: <20230412114333.118895-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230412114333.118895-1-richard.henderson@linaro.org> References: <20230412114333.118895-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: LIU Zhiwei Once we mistook the vstart directly from the env->vstart. As env->vstart is not a constant, we should record it in the tb flags if we want to use it in translation. Reported-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: LIU Zhiwei Reviewed-by: Weiwei Li Message-Id: <20230324143031.1093-5-zhiwei_liu@linux.alibaba.com> Reviewed-by: Alistair Francis Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-6-richard.henderson@linaro.org> --- target/riscv/cpu.h | 1 + target/riscv/cpu_helper.c | 1 + target/riscv/translate.c | 4 ++-- target/riscv/insn_trans/trans_rvv.c.inc | 14 +++++++------- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index ab64d5f92d..786ad047ee 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -655,6 +655,7 @@ FIELD(TB_FLAGS, VMA, 21, 1) FIELD(TB_FLAGS, ITRIGGER, 22, 1) /* Virtual mode enabled */ FIELD(TB_FLAGS, VIRT_ENABLED, 23, 1) +FIELD(TB_FLAGS, VSTART_EQ_ZERO, 24, 1) #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index e3e620137b..7579e83c3d 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -74,6 +74,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, FIELD_EX64(env->vtype, VTYPE, VTA)); flags = FIELD_DP32(flags, TB_FLAGS, VMA, FIELD_EX64(env->vtype, VTYPE, VMA)); + flags = FIELD_DP32(flags, TB_FLAGS, VSTART_EQ_ZERO, env->vstart == 0); } else { flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1); } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 3092c942ab..3ab8a9999e 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -99,7 +99,7 @@ typedef struct DisasContext { uint8_t vta; uint8_t vma; bool cfg_vta_all_1s; - target_ulong vstart; + bool vstart_eq_zero; bool vl_eq_vlmax; CPUState *cs; TCGv zero; @@ -1168,7 +1168,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->vta = FIELD_EX32(tb_flags, TB_FLAGS, VTA) && cpu->cfg.rvv_ta_all_1s; ctx->vma = FIELD_EX32(tb_flags, TB_FLAGS, VMA) && cpu->cfg.rvv_ma_all_1s; ctx->cfg_vta_all_1s = cpu->cfg.rvv_ta_all_1s; - ctx->vstart = env->vstart; + ctx->vstart_eq_zero = FIELD_EX32(tb_flags, TB_FLAGS, VSTART_EQ_ZERO); ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX); ctx->misa_mxl_max = env->misa_mxl_max; ctx->xl = FIELD_EX32(tb_flags, TB_FLAGS, XL); diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index ecbdf1b3d7..6c07eebc52 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -547,7 +547,7 @@ static bool vext_check_sds(DisasContext *s, int vd, int vs1, int vs2, int vm) */ static bool vext_check_reduction(DisasContext *s, int vs2) { - return require_align(vs2, s->lmul) && (s->vstart == 0); + return require_align(vs2, s->lmul) && s->vstart_eq_zero; } /* @@ -3083,7 +3083,7 @@ static bool trans_vcpop_m(DisasContext *s, arg_rmr *a) { if (require_rvv(s) && vext_check_isa_ill(s) && - s->vstart == 0) { + s->vstart_eq_zero) { TCGv_ptr src2, mask; TCGv dst; TCGv_i32 desc; @@ -3112,7 +3112,7 @@ static bool trans_vfirst_m(DisasContext *s, arg_rmr *a) { if (require_rvv(s) && vext_check_isa_ill(s) && - s->vstart == 0) { + s->vstart_eq_zero) { TCGv_ptr src2, mask; TCGv dst; TCGv_i32 desc; @@ -3148,7 +3148,7 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a) \ vext_check_isa_ill(s) && \ require_vm(a->vm, a->rd) && \ (a->rd != a->rs2) && \ - (s->vstart == 0)) { \ + s->vstart_eq_zero) { \ uint32_t data = 0; \ gen_helper_gvec_3_ptr *fn = gen_helper_##NAME; \ TCGLabel *over = gen_new_label(); \ @@ -3189,7 +3189,7 @@ static bool trans_viota_m(DisasContext *s, arg_viota_m *a) !is_overlapped(a->rd, 1 << MAX(s->lmul, 0), a->rs2, 1) && require_vm(a->vm, a->rd) && require_align(a->rd, s->lmul) && - (s->vstart == 0)) { + s->vstart_eq_zero) { uint32_t data = 0; TCGLabel *over = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); @@ -3638,7 +3638,7 @@ static bool vcompress_vm_check(DisasContext *s, arg_r *a) require_align(a->rs2, s->lmul) && (a->rd != a->rs2) && !is_overlapped(a->rd, 1 << MAX(s->lmul, 0), a->rs1, 1) && - (s->vstart == 0); + s->vstart_eq_zero; } static bool trans_vcompress_vm(DisasContext *s, arg_r *a) @@ -3677,7 +3677,7 @@ static bool trans_##NAME(DisasContext *s, arg_##NAME * a) \ QEMU_IS_ALIGNED(a->rd, LEN) && \ QEMU_IS_ALIGNED(a->rs2, LEN)) { \ uint32_t maxsz = (s->cfg_ptr->vlen >> 3) * LEN; \ - if (s->vstart == 0) { \ + if (s->vstart_eq_zero) { \ /* EEW = 8 */ \ tcg_gen_gvec_mov(MO_8, vreg_ofs(s, a->rd), \ vreg_ofs(s, a->rs2), maxsz, maxsz); \