From patchwork Thu Feb 15 19:28:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0ECFEC4829E for ; Thu, 15 Feb 2024 19:30:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahPs-0001dn-19; Thu, 15 Feb 2024 14:29:04 -0500 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 1rahPp-0001d9-V7 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:01 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPR-0004gw-Fa for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:01 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d72f71f222so10297925ad.1 for ; Thu, 15 Feb 2024 11:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025314; x=1708630114; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QW83A0gGAC5k+fWtH60j37LLDzdUuqaercnK+L70kbg=; b=jtRQL4VJJtrTWj6tHERaodTWHqIjVqAisFj/f6w+TA61FwHHrz5tJR9F9A6n/4741z xQ0B3IJj4P1HJVeVBLDbfhF63xfK0F5z4qzuUtPCsBZfMywi7ugD+DHEK0ugEYHt7e8f v1xLy86EPHM3dA+aILvRKGNoXAsP4SKZulXuAS/6myAtp8d7zJi90OBDzEeTwt4+4ICT th0yuWI0KftDsxCbih0f5E0xl2IR92G2xyMO0zl7hXkLgYAVXVl3/C4MI4KIOjVQhMnS WTtDT8mUlDDPJd7rjAvr+OL0AhK9wU5ymM4HwXpvbb+7mW7pP7tM5N4WgE/y6H6DDhgP 4yQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025314; x=1708630114; 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=QW83A0gGAC5k+fWtH60j37LLDzdUuqaercnK+L70kbg=; b=lNt0+WGSpC1Ag9QJb6rxO35StB/SxNz8kRuvHQTFkIAz0FzPqvkGxULoRvsfZmh3pT V489HRwgCzp4mtFbkpl974OpZ6qicIUkSGqqwiq0wRyl1SpqlwpKNcfTtBW3Yox0/nxa YbU+TsCZuWM8mnAm4kd1YNqnCcc2HPXAVaWyyWp1qm7Qxkb7QuWwkN0axouMBOJiC1uq QXHRy+4gAIdPY15NPeZs4UPw96Dlzri0CZKznNa7VKdABf8MXPcD84Q+lEsraLH111ig HJCF5vZjYLbmvwCJ4fm2rmlfiDV086WYWZIy6CUgdblokNLqGaiCjd86ZHQl0Q6bfy5C XyNQ== X-Gm-Message-State: AOJu0YyFP3O7khG4w/c/cCg+UGlRD1GegwFyjHm3R36T4zMhhFFF4WvU O6m3TQx6WZ6f6pPCNJW1rCiRIPefBWAeEQrmAZFdnn45vVXWcqOsPLIZZMQgURxv813zqEgCFqD 1DxIHfxiNnf5eulQ32G5ZtZLoqx7/V0IFpJp1Y4D1X2gH3pFYm7oS+ktuBaWTBuqLndW1kzpi6H luDKvbIWvrZV1ZRQyZsSeM+Zkl7oCVaLGd/Xi5B1UJ X-Google-Smtp-Source: AGHT+IFoF6FsR2Rio4oDdz1n5oVrhHIaT1Pw5UsSUcdAluhuK7sNic1WojHYS4NGZJV5rYY/tca0mQ== X-Received: by 2002:a17:902:b20a:b0:1d9:a647:5579 with SMTP id t10-20020a170902b20a00b001d9a6475579mr2431187plr.1.1708025314095; Thu, 15 Feb 2024 11:28:34 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:33 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Richard Henderson , Junqiang Wang Subject: [RFC PATCH 1/6] target/riscv: Seperate vector segment ld/st instructions Date: Fri, 16 Feb 2024 03:28:12 +0800 Message-Id: <20240215192823.729209-2-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=max.chou@sifive.com; helo=mail-pl1-x62d.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This commit seperate the helper function implementations of vector segment load/store instructions from other vector load/store instructions. This can improve performance by avoiding unnecessary segment operation when NF = 1. Signed-off-by: Max Chou --- target/riscv/helper.h | 4 + target/riscv/insn32.decode | 11 ++- target/riscv/insn_trans/trans_rvv.c.inc | 61 +++++++++++++++ target/riscv/vector_helper.c | 100 +++++++++++++++++++++--- 4 files changed, 164 insertions(+), 12 deletions(-) diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 8a635238514..8b6ddc4cb88 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -157,18 +157,22 @@ DEF_HELPER_FLAGS_3(hyp_hsv_d, TCG_CALL_NO_WG, void, env, tl, tl) /* Vector functions */ DEF_HELPER_3(vsetvl, tl, env, tl, tl) DEF_HELPER_5(vle8_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vlsege8_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle16_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle32_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle64_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle8_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vlsege8_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle16_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle32_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vle64_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse8_v, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vssege8_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse16_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse32_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse64_v, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse8_v_mask, void, ptr, ptr, tl, env, i32) +DEF_HELPER_5(vssege8_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse16_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse32_v_mask, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vse64_v_mask, void, ptr, ptr, tl, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index f22df04cfd1..0712e9f6314 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -77,6 +77,7 @@ @r2 ....... ..... ..... ... ..... ....... &r2 %rs1 %rd @r2_vm_1 ...... . ..... ..... ... ..... ....... &rmr vm=1 %rs2 %rd @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd +@r2_nf_1_vm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm nf=1 %rs1 %rd @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd @r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd @r_nfvm ... ... vm:1 ..... ..... ... ..... ....... &rnfvm %nf %rs2 %rs1 %rd @@ -349,11 +350,17 @@ hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s # *** Vector loads and stores are encoded within LOADFP/STORE-FP *** # Vector unit-stride load/store insns. -vle8_v ... 000 . 00000 ..... 000 ..... 0000111 @r2_nfvm +{ + vle8_v 000 000 . 00000 ..... 000 ..... 0000111 @r2_nf_1_vm + vlsege8_v ... 000 . 00000 ..... 000 ..... 0000111 @r2_nfvm +} vle16_v ... 000 . 00000 ..... 101 ..... 0000111 @r2_nfvm vle32_v ... 000 . 00000 ..... 110 ..... 0000111 @r2_nfvm vle64_v ... 000 . 00000 ..... 111 ..... 0000111 @r2_nfvm -vse8_v ... 000 . 00000 ..... 000 ..... 0100111 @r2_nfvm +{ + vse8_v 000 000 . 00000 ..... 000 ..... 0100111 @r2_nf_1_vm + vssege8_v ... 000 . 00000 ..... 000 ..... 0100111 @r2_nfvm +} vse16_v ... 000 . 00000 ..... 101 ..... 0100111 @r2_nfvm vse32_v ... 000 . 00000 ..... 110 ..... 0100111 @r2_nfvm vse64_v ... 000 . 00000 ..... 111 ..... 0100111 @r2_nfvm diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 9e101ab4343..04fc6329359 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -690,6 +690,40 @@ GEN_VEXT_TRANS(vle16_v, MO_16, r2nfvm, ld_us_op, ld_us_check) GEN_VEXT_TRANS(vle32_v, MO_32, r2nfvm, ld_us_op, ld_us_check) GEN_VEXT_TRANS(vle64_v, MO_64, r2nfvm, ld_us_op, ld_us_check) +static bool ld_us_seg_op(DisasContext *s, arg_r2nfvm *a, uint8_t eew) +{ + uint32_t data = 0; + gen_helper_ldst_us *fn; + static gen_helper_ldst_us * const fns[2][4] = { + /* masked unit stride load */ + { gen_helper_vlsege8_v_mask, gen_helper_vle16_v_mask, + gen_helper_vle32_v_mask, gen_helper_vle64_v_mask }, + /* unmasked unit stride load */ + { gen_helper_vlsege8_v, gen_helper_vle16_v, + gen_helper_vle32_v, gen_helper_vle64_v } + }; + + fn = fns[a->vm][eew]; + if (fn == NULL) { + return false; + } + + /* + * Vector load/store instructions have the EEW encoded + * directly in the instructions. The maximum vector size is + * calculated with EMUL rather than LMUL. + */ + uint8_t emul = vext_get_emul(s, eew); + data = FIELD_DP32(data, VDATA, VM, a->vm); + data = FIELD_DP32(data, VDATA, LMUL, emul); + data = FIELD_DP32(data, VDATA, NF, a->nf); + data = FIELD_DP32(data, VDATA, VTA, s->vta); + data = FIELD_DP32(data, VDATA, VMA, s->vma); + return ldst_us_trans(a->rd, a->rs1, data, fn, s, false); +} + +GEN_VEXT_TRANS(vlsege8_v, MO_8, r2nfvm, ld_us_seg_op, ld_us_check) + static bool st_us_op(DisasContext *s, arg_r2nfvm *a, uint8_t eew) { uint32_t data = 0; @@ -727,6 +761,33 @@ GEN_VEXT_TRANS(vse16_v, MO_16, r2nfvm, st_us_op, st_us_check) GEN_VEXT_TRANS(vse32_v, MO_32, r2nfvm, st_us_op, st_us_check) GEN_VEXT_TRANS(vse64_v, MO_64, r2nfvm, st_us_op, st_us_check) +static bool st_us_seg_op(DisasContext *s, arg_r2nfvm *a, uint8_t eew) +{ + uint32_t data = 0; + gen_helper_ldst_us *fn; + static gen_helper_ldst_us * const fns[2][4] = { + /* masked unit stride store */ + { gen_helper_vssege8_v_mask, gen_helper_vse16_v_mask, + gen_helper_vse32_v_mask, gen_helper_vse64_v_mask }, + /* unmasked unit stride store */ + { gen_helper_vssege8_v, gen_helper_vse16_v, + gen_helper_vse32_v, gen_helper_vse64_v } + }; + + fn = fns[a->vm][eew]; + if (fn == NULL) { + return false; + } + + uint8_t emul = vext_get_emul(s, eew); + data = FIELD_DP32(data, VDATA, VM, a->vm); + data = FIELD_DP32(data, VDATA, LMUL, emul); + data = FIELD_DP32(data, VDATA, NF, a->nf); + return ldst_us_trans(a->rd, a->rs1, data, fn, s, true); +} + +GEN_VEXT_TRANS(vssege8_v, MO_8, r2nfvm, st_us_seg_op, st_us_check) + /* *** unit stride mask load and store */ diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 84cec73eb20..e8fbb921449 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -201,6 +201,32 @@ vext_ldst_stride(void *vd, void *v0, target_ulong base, uint32_t desc, uint32_t vm, vext_ldst_elem_fn *ldst_elem, uint32_t log2_esz, uintptr_t ra) +{ + uint32_t i; + uint32_t max_elems = vext_max_elems(desc, log2_esz); + uint32_t esz = 1 << log2_esz; + uint32_t vma = vext_vma(desc); + + for (i = env->vstart; i < env->vl; i++, env->vstart++) { + if (!vm && !vext_elem_mask(v0, i)) { + /* set masked-off elements to 1s */ + vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz); + continue; + } + target_ulong addr = base + stride * i; + ldst_elem(env, adjust_addr(env, addr), i, vd, ra); + } + env->vstart = 0; + + vext_set_tail_elems_1s(env->vl, vd, desc, 1, esz, max_elems); +} + +static void +vext_ldst_stride_segment(void *vd, void *v0, target_ulong base, + target_ulong stride, CPURISCVState *env, + uint32_t desc, uint32_t vm, + vext_ldst_elem_fn *ldst_elem, + uint32_t log2_esz, uintptr_t ra) { uint32_t i, k; uint32_t nf = vext_nf(desc); @@ -234,8 +260,8 @@ void HELPER(NAME)(void *vd, void * v0, target_ulong base, \ uint32_t desc) \ { \ uint32_t vm = vext_vm(desc); \ - vext_ldst_stride(vd, v0, base, stride, env, desc, vm, LOAD_FN, \ - ctzl(sizeof(ETYPE)), GETPC()); \ + vext_ldst_stride_segment(vd, v0, base, stride, env, desc, vm, \ + LOAD_FN, ctzl(sizeof(ETYPE)), GETPC()); \ } GEN_VEXT_LD_STRIDE(vlse8_v, int8_t, lde_b) @@ -249,8 +275,8 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ uint32_t desc) \ { \ uint32_t vm = vext_vm(desc); \ - vext_ldst_stride(vd, v0, base, stride, env, desc, vm, STORE_FN, \ - ctzl(sizeof(ETYPE)), GETPC()); \ + vext_ldst_stride_segment(vd, v0, base, stride, env, desc, vm, \ + STORE_FN, ctzl(sizeof(ETYPE)), GETPC()); \ } GEN_VEXT_ST_STRIDE(vsse8_v, int8_t, ste_b) @@ -267,6 +293,26 @@ static void vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, vext_ldst_elem_fn *ldst_elem, uint32_t log2_esz, uint32_t evl, uintptr_t ra) +{ + uint32_t i; + uint32_t max_elems = vext_max_elems(desc, log2_esz); + uint32_t esz = 1 << log2_esz; + + /* load bytes from guest memory */ + for (i = env->vstart; i < evl; i++, env->vstart++) { + target_ulong addr = base + (i << log2_esz); + ldst_elem(env, adjust_addr(env, addr), i, vd, ra); + } + env->vstart = 0; + + vext_set_tail_elems_1s(evl, vd, desc, 1, esz, max_elems); +} + +/* unmasked unit-stride segment load and store operation */ +static void +vext_ldst_us_segment(void *vd, target_ulong base, CPURISCVState *env, + uint32_t desc, vext_ldst_elem_fn *ldst_elem, + uint32_t log2_esz, uint32_t evl, uintptr_t ra) { uint32_t i, k; uint32_t nf = vext_nf(desc); @@ -308,10 +354,27 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ ctzl(sizeof(ETYPE)), env->vl, GETPC()); \ } +#define GEN_VEXT_LD_US_SEG(NAME, ETYPE, LOAD_FN) \ +void HELPER(NAME##_mask)(void *vd, void *v0, target_ulong base, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + uint32_t stride = vext_nf(desc) << ctzl(sizeof(ETYPE)); \ + vext_ldst_stride_segment(vd, v0, base, stride, env, desc, false, \ + LOAD_FN, ctzl(sizeof(ETYPE)), GETPC()); \ +} \ + \ +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + vext_ldst_us_segment(vd, base, env, desc, LOAD_FN, \ + ctzl(sizeof(ETYPE)), env->vl, GETPC()); \ +} + GEN_VEXT_LD_US(vle8_v, int8_t, lde_b) -GEN_VEXT_LD_US(vle16_v, int16_t, lde_h) -GEN_VEXT_LD_US(vle32_v, int32_t, lde_w) -GEN_VEXT_LD_US(vle64_v, int64_t, lde_d) +GEN_VEXT_LD_US_SEG(vlsege8_v, int8_t, lde_b) +GEN_VEXT_LD_US_SEG(vle16_v, int16_t, lde_h) +GEN_VEXT_LD_US_SEG(vle32_v, int32_t, lde_w) +GEN_VEXT_LD_US_SEG(vle64_v, int64_t, lde_d) #define GEN_VEXT_ST_US(NAME, ETYPE, STORE_FN) \ void HELPER(NAME##_mask)(void *vd, void *v0, target_ulong base, \ @@ -329,10 +392,27 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ ctzl(sizeof(ETYPE)), env->vl, GETPC()); \ } +#define GEN_VEXT_ST_US_SEG(NAME, ETYPE, STORE_FN) \ +void HELPER(NAME##_mask)(void *vd, void *v0, target_ulong base, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + uint32_t stride = vext_nf(desc) << ctzl(sizeof(ETYPE)); \ + vext_ldst_stride_segment(vd, v0, base, stride, env, desc, false, \ + STORE_FN, ctzl(sizeof(ETYPE)), GETPC()); \ +} \ + \ +void HELPER(NAME)(void *vd, void *v0, target_ulong base, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + vext_ldst_us_segment(vd, base, env, desc, STORE_FN, \ + ctzl(sizeof(ETYPE)), env->vl, GETPC()); \ +} + GEN_VEXT_ST_US(vse8_v, int8_t, ste_b) -GEN_VEXT_ST_US(vse16_v, int16_t, ste_h) -GEN_VEXT_ST_US(vse32_v, int32_t, ste_w) -GEN_VEXT_ST_US(vse64_v, int64_t, ste_d) +GEN_VEXT_ST_US_SEG(vssege8_v, int8_t, ste_b) +GEN_VEXT_ST_US_SEG(vse16_v, int16_t, ste_h) +GEN_VEXT_ST_US_SEG(vse32_v, int32_t, ste_w) +GEN_VEXT_ST_US_SEG(vse64_v, int64_t, ste_d) /* * unit stride mask load and store, EEW = 1 From patchwork Thu Feb 15 19:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B312C4829E for ; Thu, 15 Feb 2024 19:30:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahPw-0001f6-Ai; Thu, 15 Feb 2024 14:29:08 -0500 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 1rahPt-0001dr-AK for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:05 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPZ-0004hF-71 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:03 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d51ba18e1bso12737315ad.0 for ; Thu, 15 Feb 2024 11:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025318; x=1708630118; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3KR/e7xd2t/WfUhq1nU3nYx+Y5DrBWOVXBN9h9UKvfc=; b=RjVJwxAdZRI1wo40etlhF1Ffh0FaC5Eutzl9iHNbDcox3hjElCl5OZdAnojTDOU93c i2STawdRueljR01Pttx+pztyy1Ddx8yf2aAHvyp80wvlkRBtZ8e55jYJH8yguGS1015p ZCne2UufDLVif8tHNbMSMDseCE6TGmjuuBqJtNa9cynltNPN/nmzSIFC4TwoOxxOjQKt aIKMYdrjTFVFiv2mltNIXVzwUhRPOvhu5C7jRTebUnVRCrGPlMGeTZRgpsoWPuGDWosC 1IfEO8K7+MFrfF1WOUu3ZYWnQSOGb7/lP7LBoW0PWe9o6Rg4DGMH5mIy8GPSR7bJfFyZ xhJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025318; x=1708630118; 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=3KR/e7xd2t/WfUhq1nU3nYx+Y5DrBWOVXBN9h9UKvfc=; b=Lp8zTnqb8wiKCkd3tnqs0Scl2WRZO4iQePTm92yuMNPMy+v7RXn9IWAkhSsb+Ek2A/ Hgeaz/2pFfOwh2C8cuZpnrM/8GDHA1baCpJtor1ZXQE+I3TFqwVGuOGnXA2KVPzkP/QE JWTJcWzzO7XspbaxUVGTeOqGoSZbAghs8SqqUP3PSMys8esilsJ69o3U35wCc0jMbIo1 Q8tJPy6NuUX+i71CQixQyaQqbmUmASLmg2fswjR4N3YSNI4tPoT0At6zL8GfjFG6c3Wf r1oMDZTX1Yg9ekg3tpI0ON2Jo5MWKCBWk227RrMIKB8/wpAwomuEHv8Wq7rNKVqZMmqE M89g== X-Gm-Message-State: AOJu0YwgK8SyBmG5Rag5rJFoexdnyEwZJ1iAQT616b8IviDGsYTv+4R5 lQTKHl7OoCxkTuf8CYidYELZv7KgiFb/GVBf0erDfWl9hozth2HvGfSLwLU3eTM6pCo6rzX+IWz W2hcT/WgVgO2k0UmE5Zjr23SyOfHXSN13BlmJOJ0UKRhPq4EOBNnHoeJvegUKk7nz4ZOmveyCal d89+mcWYZixtnr6NUaAggXILnHxULDAAnX+T/Qa9JH X-Google-Smtp-Source: AGHT+IHH07zKpvDk6lvEZgaiG7tRGZgTkNUFnN8TiRSiVQbRRAR2azynSv/UhmuI4NuIotPhoe4okg== X-Received: by 2002:a17:902:8218:b0:1db:5eaa:e9a2 with SMTP id x24-20020a170902821800b001db5eaae9a2mr2529567pln.64.1708025317939; Thu, 15 Feb 2024 11:28:37 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:37 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH 2/6] accel/tcg: Avoid uncessary call overhead from qemu_plugin_vcpu_mem_cb Date: Fri, 16 Feb 2024 03:28:13 +0800 Message-Id: <20240215192823.729209-3-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=max.chou@sifive.com; helo=mail-pl1-x62a.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If there are not any QEMU plugin memory callback functions, checking before calling the qemu_plugin_vcpu_mem_cb function can reduce the function call overhead. Signed-off-by: Max Chou --- accel/tcg/ldst_common.c.inc | 40 +++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index c82048e377e..bf24986c562 100644 --- a/accel/tcg/ldst_common.c.inc +++ b/accel/tcg/ldst_common.c.inc @@ -134,7 +134,9 @@ uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra) tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_UB); ret = do_ld1_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_load_cb(env, addr, oi); + } return ret; } @@ -145,7 +147,9 @@ uint16_t cpu_ldw_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); ret = do_ld2_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_load_cb(env, addr, oi); + } return ret; } @@ -156,7 +160,9 @@ uint32_t cpu_ldl_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); ret = do_ld4_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_load_cb(env, addr, oi); + } return ret; } @@ -167,7 +173,9 @@ uint64_t cpu_ldq_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); ret = do_ld8_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_load_cb(env, addr, oi); + } return ret; } @@ -178,7 +186,9 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); ret = do_ld16_mmu(env_cpu(env), addr, oi, ra); - plugin_load_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_load_cb(env, addr, oi); + } return ret; } @@ -195,7 +205,9 @@ void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val, MemOpIdx oi, uintptr_t retaddr) { helper_stb_mmu(env, addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_store_cb(env, addr, oi); + } } void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, @@ -203,7 +215,9 @@ void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); do_st2_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_store_cb(env, addr, oi); + } } void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, @@ -211,7 +225,9 @@ void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); do_st4_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_store_cb(env, addr, oi); + } } void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, @@ -219,7 +235,9 @@ void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); do_st8_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_store_cb(env, addr, oi); + } } void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, @@ -227,7 +245,9 @@ void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); do_st16_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + plugin_store_cb(env, addr, oi); + } } /* From patchwork Thu Feb 15 19:28:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95FFFC48BEC for ; Thu, 15 Feb 2024 19:30:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahPz-0001io-IU; Thu, 15 Feb 2024 14:29:11 -0500 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 1rahPx-0001iC-Sz for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:09 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPg-0004hX-Jc for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:09 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1db640fc901so11587705ad.0 for ; Thu, 15 Feb 2024 11:28:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025322; x=1708630122; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PqJOdAFlOLuV8CILgRx55cvxXityDOLPppAKVjprA0M=; b=SR+6R8q8d+O9K5ZjJsH/LxdGOsB2RRGKTAifaG9fnl01MF8NA/sQvi1NngGKD/ff3k fRRYwD3wD3sgBfjR8zytGwS4UEt4z94w6AyY7mUrYyy++FAUr3pOJQ1o7XYI5vBF66wr /MEYXaIqXobrAJfW632Fk63vHNtsvYg4agNxeSSkhYJVt7DSai1vwAqbCSGdX9uml9/7 PuvbISa2ocHkOOPqgL3LpKAT9s81nymchZxbxLA6mx/KPMEuPqA6YQcd8HmU+Bbss3DL iK95ul/aS4b9vyTKSiKDOLGx5NwGJW0eBH+AlJo+q01O8OrFZ21HHtKpH+gYuiV7SwHX bzDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025322; x=1708630122; 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=PqJOdAFlOLuV8CILgRx55cvxXityDOLPppAKVjprA0M=; b=kJTMGRuSP64afwWexBnkCqHMA7LoGE2MP9ich39T597qOvKHNMembFXQzi9YfTnRFz VcSovY2PZZimag9mTHOZ9ylKtcEl03d+bWIIEi/6xskQWtjkzbync78a3VobIiCrp8sx 4TJ3wwsxvmAkiCriqJS3ICD/4YQ4Pkza9jwlj/cKuv4TiSeOTCUMPmibErXG/veyMgXW Xt72S4O6VfK2gOr6k92aSEsFlsivY6AKTnkG/46O0Wyv2AVoBRUra7ugEZ1Q0qVmIWyx VK8Ejs10a+vTgaySaMQwK2cOaJF6SQcL/ilR+Gvf2m1/7TkJjR9mVxlaSYxFj1e7JMaR +/vg== X-Gm-Message-State: AOJu0Yzqb0CNu0zm73f8enMyn0hM+V9OBYPjMXWp1/jxpwwfOhjJdjio QiT6Mk/0Xug8m85fvsF2uubVogYbJJ0G7vrsThXz9wEnNpf5YYU32IPsWexstTBFTpFTQ18WIFa CFqsRrUpzGi/KlrvX+W7nBI9f9I6UFQ/t499XFMqqX/F5qPwhQA8B4lxYl2DawB71FhLiAEg/SV e34uXTFgnfhuYSzInU+s6whMo7Wrj7zIKdS47iv7ec X-Google-Smtp-Source: AGHT+IGG99BIj2DOfKEYVErGN6NYizRM/krbGTsBNJ/Cse47yT3eBsPe+SAt74cbFA/GMmDjybeAuw== X-Received: by 2002:a17:902:8a96:b0:1d8:d5b0:aadb with SMTP id p22-20020a1709028a9600b001d8d5b0aadbmr2168871plo.66.1708025321984; Thu, 15 Feb 2024 11:28:41 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:41 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei Subject: [RFC PATCH 3/6] target/riscv: Inline vext_ldst_us and coressponding function for performance Date: Fri, 16 Feb 2024 03:28:14 +0800 Message-Id: <20240215192823.729209-4-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=max.chou@sifive.com; helo=mail-pl1-x62c.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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In the vector unit-stride load/store helper functions. the vext_ldst_us function corresponding most of the execution time. Inline the functions can avoid the function call overhead to imperove the helper function performance. Signed-off-by: Max Chou Reviewed-by: Richard Henderson --- target/riscv/vector_helper.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index e8fbb921449..866f77d321d 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -149,25 +149,27 @@ static inline void vext_set_elem_mask(void *v0, int index, typedef void vext_ldst_elem_fn(CPURISCVState *env, abi_ptr addr, uint32_t idx, void *vd, uintptr_t retaddr); -#define GEN_VEXT_LD_ELEM(NAME, ETYPE, H, LDSUF) \ -static void NAME(CPURISCVState *env, abi_ptr addr, \ - uint32_t idx, void *vd, uintptr_t retaddr)\ -{ \ - ETYPE *cur = ((ETYPE *)vd + H(idx)); \ - *cur = cpu_##LDSUF##_data_ra(env, addr, retaddr); \ -} \ +#define GEN_VEXT_LD_ELEM(NAME, ETYPE, H, LDSUF) \ +static inline QEMU_ALWAYS_INLINE \ +void NAME(CPURISCVState *env, abi_ptr addr, \ + uint32_t idx, void *vd, uintptr_t retaddr) \ +{ \ + ETYPE *cur = ((ETYPE *)vd + H(idx)); \ + *cur = cpu_##LDSUF##_data_ra(env, addr, retaddr); \ +} \ GEN_VEXT_LD_ELEM(lde_b, int8_t, H1, ldsb) GEN_VEXT_LD_ELEM(lde_h, int16_t, H2, ldsw) GEN_VEXT_LD_ELEM(lde_w, int32_t, H4, ldl) GEN_VEXT_LD_ELEM(lde_d, int64_t, H8, ldq) -#define GEN_VEXT_ST_ELEM(NAME, ETYPE, H, STSUF) \ -static void NAME(CPURISCVState *env, abi_ptr addr, \ - uint32_t idx, void *vd, uintptr_t retaddr)\ -{ \ - ETYPE data = *((ETYPE *)vd + H(idx)); \ - cpu_##STSUF##_data_ra(env, addr, data, retaddr); \ +#define GEN_VEXT_ST_ELEM(NAME, ETYPE, H, STSUF) \ +static inline QEMU_ALWAYS_INLINE \ +void NAME(CPURISCVState *env, abi_ptr addr, \ + uint32_t idx, void *vd, uintptr_t retaddr) \ +{ \ + ETYPE data = *((ETYPE *)vd + H(idx)); \ + cpu_##STSUF##_data_ra(env, addr, data, retaddr); \ } GEN_VEXT_ST_ELEM(ste_b, int8_t, H1, stb) @@ -289,7 +291,7 @@ GEN_VEXT_ST_STRIDE(vsse64_v, int64_t, ste_d) */ /* unmasked unit-stride load and store operation */ -static void +static inline QEMU_ALWAYS_INLINE void vext_ldst_us(void *vd, target_ulong base, CPURISCVState *env, uint32_t desc, vext_ldst_elem_fn *ldst_elem, uint32_t log2_esz, uint32_t evl, uintptr_t ra) From patchwork Thu Feb 15 19:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC16EC4829E for ; Thu, 15 Feb 2024 19:29:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahQB-0001ne-Jt; Thu, 15 Feb 2024 14:29:23 -0500 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 1rahQ8-0001mD-NU for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:20 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPg-0004hp-DX for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:19 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d7393de183so10668955ad.3 for ; Thu, 15 Feb 2024 11:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025325; x=1708630125; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aY2GQ2qh0XeeuvRECl5CCzJvBtPvf5PTqd8C4F8QamY=; b=Lr9neBHW2U6psaW+xZqiqL3vVcdNOWTuKglnkguwba6Hl8HLtfkewIM40jsKyFPoGE KiPHsTMzJ0Nl9qMyfbeduW8fTQfgTufT4zeyp+hmpNoVUuocLa/nq/DCskcbr5hTCa/1 wrcSkX5DKPjcLspGlED9lKs+Fn/uR+V+O2hLxLo/DS+84mjHYzhBxqVvFpbcCcvjVL0k tSniwdiEFLO0T0IcumvDvq+na85mKj7fu9qGKDZ/OB33Y7YAVz2A9gzigI3SvW4TKyTm hNGZbo4Ngyh/pgUoovYuNwk1S6k8Ms7+TAmDuNW4sVgbUiMmSiaPmVUWbaRB1P9m4Xuf o5FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025325; x=1708630125; 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=aY2GQ2qh0XeeuvRECl5CCzJvBtPvf5PTqd8C4F8QamY=; b=a96CgphfcwdPyTKYz8kBUTuBmejnl9Trig8D1QI70J+/4URcEiUQE+X7v13fPrlNZ4 LZNpS/UlAf9rh/P6+1N2XQvBLsIh1koPrGNkMXyhYfGqNllaoTCiuKXST6x4dxProihm ClJqSxLDy4HHwnyKzQ1HIsKrckCcEmE3jaw5S6QDdByGXxUnzT+W43Q+o2iHfr7r9OdB cWiLRkfiawDuUEM84UsdgkkkNnmCTS+64FEVihvjtcz/8YxzF1IfTO2p2YXucRPmnla6 YhkQSm4D/6FxTneUYG1Aj/4QukpBzA0UktC4vz1Zqfl4Wcxg6Z4dZoyO4toQOnHU59Ry 3PIA== X-Gm-Message-State: AOJu0YzQo/gLpWXjXN7KnEN2toyI8fL6KHIJoWeY41aPxuBiGM3YGScl g4xU4A+X79uR1fdDxETTM4K35MvLVda/Xe3K8uTeard2By2KOHhSEyBgG5ke+BdBJ6c16o+z0tA stYfVuKAaW5e4tpECAz7YoxUa1Omlb8kJPdH2ceW0dW2SI0fWXTU4uKDTekxjkQG+6+6Wrc5lZX 071WiVcXebsyNFkp1loVKKYZJ3d3NyIZFUmHStsbu5 X-Google-Smtp-Source: AGHT+IEr5o8CE3vDUoaj1VJw5ztI2DVXDsB6xUJRSWSZa/Sb69YA4XaF7abySA7YnUhjty3OTnZJig== X-Received: by 2002:a17:903:2281:b0:1db:7052:2f75 with SMTP id b1-20020a170903228100b001db70522f75mr3277770plh.49.1708025325471; Thu, 15 Feb 2024 11:28:45 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:45 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Riku Voipio , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH 4/6] accel/tcg: Inline cpu_mmu_lookup function Date: Fri, 16 Feb 2024 03:28:15 +0800 Message-Id: <20240215192823.729209-5-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=max.chou@sifive.com; helo=mail-pl1-x62c.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Max Chou --- accel/tcg/user-exec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 68b252cb8e8..c5453810eee 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -942,8 +942,11 @@ void page_reset_target_data(target_ulong start, target_ulong last) { } /* The system-mode versions of these helpers are in cputlb.c. */ -static void *cpu_mmu_lookup(CPUState *cpu, vaddr addr, - MemOp mop, uintptr_t ra, MMUAccessType type) +static inline QEMU_ALWAYS_INLINE void *cpu_mmu_lookup(CPUState *cpu, + vaddr addr, + MemOp mop, + uintptr_t ra, + MMUAccessType type) { int a_bits = get_alignment_bits(mop); void *ret; From patchwork Thu Feb 15 19:28:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA5AAC48BC4 for ; Thu, 15 Feb 2024 19:30:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahQ2-0001k0-GV; Thu, 15 Feb 2024 14:29:14 -0500 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 1rahQ0-0001ir-N7 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:12 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPj-0004i7-GF for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:11 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d7881b1843so11201095ad.3 for ; Thu, 15 Feb 2024 11:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025329; x=1708630129; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gEt4deq/UXy6XjJi0lNE/l34mZOHICza+3YtE+V4xPU=; b=aLXYWJAH7BfLmCtSEjsfLQENezwx4n7JvzqGWJuc0o6ZUU03Yb3fYU2RWYziSbT1uL kwueU/j4N9mirvNqZ+BfjQ6tiKuma1DwHTzw4R5XC2bDvRsjj+VFXme5aUNdhmovB5j+ agyWb/Z/BjvkSw+q3p/Uc4d5KAtugPz6zPw7BdZsqJP6Njhx+ma+HbiAav8z+Pl1ruXM 4TWzxKqB614QgmcB616Js3X0Ir4JK+ncQtL/ekDn11Hu/GeAt3hfU9Z7TbFBjgfxy7Z5 QCq/3ZwnbBUDwLkrSdyePr7El0q2BaiUSiXAf/MLivlvXQS1ir4K9ZsMO2h8zH7atXUB uZKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025329; x=1708630129; 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=gEt4deq/UXy6XjJi0lNE/l34mZOHICza+3YtE+V4xPU=; b=HFuleJygEI3SrbfSQ3/n0QVYOq1jgPRN64onxX7hkM1AwXFi80v2gixAukx1VrWR7A 1y14/cOm+L6tHDx3JMC18EPDUSBQ9La4sVQ2TyA8FGr1hpRLlILDfZsi6fqZxZysYSbn r2caXYzwdx+RkqbBtSvY2nHLLWkh5GhJSWkV7bGO76XFmrngw57ekLCOq3XiGNoMuTYA Jyjb2u33R2w7gFK8FU5CpYyhmKZF70afrRDKjm8PB1j/gpEuUQE8uV6z7ZuOFZYZz2lJ AA/VktFfq6MSkOob7G4hfYIzJraSfiH2bzHzb36saW4yAlZzQdHPdDUNA6JGIfzvwd3M /PbQ== X-Gm-Message-State: AOJu0YwZwc9TB5gGjbUgZ5sf+v1U9QKSuDQbWpoS6pbzu2gJ86FGaMR1 G7cFLLJQdFGHyC37AwkOSQAZn7OuyrrrxztdYzuhle9MubF24TnTqA/rPia9yMShWBkdPpj+K+6 F06Eh4SOOA8sM/5blEIXFtshraucPNtv7f2TVrfAoo+XoFH1iVzic1jAys0F/tPcoyIaJnI/rJZ GWp2mmiew7pRcNY2wJuK+0Y61PyV99KY5aepl/ieFU X-Google-Smtp-Source: AGHT+IGHAHX1Tw7jQlHnb04leAp3wxKMj30AYnshK4kIzS48wvnjbVhwfahXCANJ18i+CPSkRl/wkw== X-Received: by 2002:a17:903:24c:b0:1d4:cd4d:923b with SMTP id j12-20020a170903024c00b001d4cd4d923bmr3115439plh.54.1708025329019; Thu, 15 Feb 2024 11:28:49 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:48 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Riku Voipio , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH 5/6] accel/tcg: Inline do_ld1_mmu function Date: Fri, 16 Feb 2024 03:28:16 +0800 Message-Id: <20240215192823.729209-6-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=max.chou@sifive.com; helo=mail-pl1-x62b.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Max Chou --- accel/tcg/user-exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index c5453810eee..803c271df11 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -963,8 +963,9 @@ static inline QEMU_ALWAYS_INLINE void *cpu_mmu_lookup(CPUState *cpu, #include "ldst_atomicity.c.inc" -static uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, MemOpIdx oi, - uintptr_t ra, MMUAccessType access_type) +static inline QEMU_ALWAYS_INLINE uint8_t do_ld1_mmu(CPUState *cpu, vaddr addr, + MemOpIdx oi, uintptr_t ra, + MMUAccessType access_type) { void *haddr; uint8_t ret; From patchwork Thu Feb 15 19:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Chou X-Patchwork-Id: 13559087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF656C4829E for ; Thu, 15 Feb 2024 19:31:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rahQ6-0001lG-BS; Thu, 15 Feb 2024 14:29:19 -0500 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 1rahQ3-0001kY-Od for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:16 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rahPj-0004iZ-72 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 14:29:15 -0500 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-296cca9169bso1060323a91.3 for ; Thu, 15 Feb 2024 11:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708025332; x=1708630132; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hnoQZWyM3IQrdfNlHpKnjwy/1Zr4Y+mdXFsSbK4jOXc=; b=CtdvXNJ4VbnpEP0ovK72hVQ2e6ihvnIHCCvhQ5BFEq3My4WXqYYvmIMyN/PtfFL5uN FnRnHw+zOcpYl79z4uQZfjUgNYr9NtndKML7XPMcN1fYvONv8ZvV3lbU7s3MViuy4y0g Y4Dx27UFdLgDfzVoD3YV17SKPTT+HqBIONrSxcQN84uRsu7JmAYP6EtA9i/WB1i6kMSo ZJFmBWtcieSSuPrrqan932hvPB5YjYekqWsljeGq5+uahqoX5tKKTcMmPVfKondu/A40 3gEl1DfRTm8fFGe6GnGlJFP4AYQ3y8HmjOJJd9cD66V22N34YmaOErdweeYBh2/szn5e 25Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708025332; x=1708630132; 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=hnoQZWyM3IQrdfNlHpKnjwy/1Zr4Y+mdXFsSbK4jOXc=; b=Pk2gFk7JAV2loiW7tEbus/0417PihjfkUn+T9JmvQJlmrtp/k9/OlgnjMLKo4++03d 7GYVBxpt88Ifv6syj9MKehyKSwtF8hLG2mwPC311pQaFPQm3w9lpdh9kLLFSCPAE4L7F psH/3Jy6CWbcKfGSd9kdRoH4efyvI0b/pnAOhp7Tla922DtmRTivPlUoxoVZ7Wu7qGrH AgiNusZ0JcbElQa3gfcolDlhBsP2aHGBfdra3E+ONgFperzm3j/5F8fgA25sFws7obrU boQavF4F5dbkxttzumtnwK5NK1nXTnsjY18yw0xP49zPo111EVEG3b3hyQ9SjZyDqluW lEZA== X-Gm-Message-State: AOJu0Yxur88s4f7Ztr9yWV6HoQq5sxbuYio4Vr5Lv0MMfkS5rTmkLfa9 joSEyeAtzUDUQ+H4kNfzM40RpiUX8UmPPQsmMhX4QHPZsVE/Yl5gYmAsFtkZp9VXgnNywt7qImE rUN/aw2A2gbldji44is5Z6/NidEbJu5gmV0ZrPjGm3zMMf+1cpamNOhjvJ0O+/cqSri9mA8eJT1 zFr/6WMaJ57L2Kq4cTq2Egz9kVTuJ/siNJsJNta3lK X-Google-Smtp-Source: AGHT+IG5YuTs6vjhF3Bi69Xsf/3ASVE8egLuLKosMtoQKuXI34cy1tP7UDdbE3vL9XaQUz9VElWqJw== X-Received: by 2002:a17:90b:154b:b0:299:ed7:24fc with SMTP id ig11-20020a17090b154b00b002990ed724fcmr1910269pjb.49.1708025332282; Thu, 15 Feb 2024 11:28:52 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id u8-20020a170902a60800b001db5ee73fe9sm1618653plq.114.2024.02.15.11.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 11:28:52 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: dbarboza@ventanamicro.com, Max Chou , Riku Voipio , Richard Henderson , Paolo Bonzini Subject: [RFC PATCH 6/6] accel/tcg: Inline do_st1_mmu function Date: Fri, 16 Feb 2024 03:28:17 +0800 Message-Id: <20240215192823.729209-7-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215192823.729209-1-max.chou@sifive.com> References: <20240215192823.729209-1-max.chou@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=max.chou@sifive.com; helo=mail-pj1-x102f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Max Chou --- accel/tcg/user-exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 803c271df11..9ef35a22279 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -1050,8 +1050,9 @@ static Int128 do_ld16_mmu(CPUState *cpu, abi_ptr addr, return ret; } -static void do_st1_mmu(CPUState *cpu, vaddr addr, uint8_t val, - MemOpIdx oi, uintptr_t ra) +static inline QEMU_ALWAYS_INLINE void do_st1_mmu(CPUState *cpu, vaddr addr, + uint8_t val, MemOpIdx oi, + uintptr_t ra) { void *haddr;