From: Palmer Dabbelt <palmer@dabbelt.com>
To: zhiwei_liu@c-sky.com
Cc: alistair23@gmail.com, richard.henderson@linaro.org,
qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 05/38] target/riscv: 8-bit Addition & Subtraction Instruction
Date: Tue, 25 May 2021 23:15:37 -0700 (PDT) [thread overview]
Message-ID: <mhng-79de2915-d9b8-4cbb-8d78-bd4634de1984@palmerdabbelt-glaptop> (raw)
In-Reply-To: <1f8c7632-6254-d418-4529-9f107b053145@c-sky.com>
On Tue, 25 May 2021 22:43:27 PDT (-0700), zhiwei_liu@c-sky.com wrote:
>
> On 5/24/21 9:00 AM, Palmer Dabbelt wrote:
>> On Mon, 15 Mar 2021 14:22:58 PDT (-0700), alistair23@gmail.com wrote:
>>> On Fri, Feb 12, 2021 at 10:14 AM LIU Zhiwei <zhiwei_liu@c-sky.com>
>>> wrote:
>>>>
>>>> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
>>>
>>> Acked-by: Alistair Francis <alistair.francis@wdc.com>
>>
>> I saw some reviews on the other ones, but since others (like this)
>> just have acks and haven't had any other traffic I'm going to start here.
>>
>> It looks like the latest spec is 0.9.4, but the changelog is pretty
>> minimal between 0.9.5 and 0.9.2:
>>
>> [0.9.2 -> 0.9.3]
>>
>> * Changed Zp64 name to Zpsfoperand.
>> * Added Zprvsfextra for RV64 only instructions.
>> * Removed SWAP16 encoding. It is an alias of PKBT16.
>> * Fixed few typos and enhanced precision descriptions on imtermediate
>> results.
>>
>> [0.9.3 -> 0.9.4]
>>
>> * Fixed few typos and enhanced precision descriptions on imtermediate
>> results.
>> * Fixed/Changed data types for some intrinsic functions.
>> * Removed "RV32 Only" for Zpsfoperand.
>>
>> So I'm just going to stick with reviewing based on the latest spec
>> <https://github.com/riscv/riscv-p-spec/blob/d33a761f805d3b7c84214e5654a511267985a0a0/P-ext-proposal.pdf>
>> and try to keep those differences in mind, assuming we're just
>> tracking the latest draft here.
>>
> Hi Palmer,
>
> It's a good news.
>
> I plan to rebase the patch set and update to the latest specification.
>
> Probably before next week, we can get a v2 patch set.
Sounds good. I'll keep slowly going through these until the v2 shows up
and then jump over there.
>
> Zhiwei
>
>>> Alistair
>>>
>>>> ---
>>>> target/riscv/helper.h | 9 +++
>>>> target/riscv/insn32.decode | 11 ++++
>>>> target/riscv/insn_trans/trans_rvp.c.inc | 79 +++++++++++++++++++++++++
>>>> target/riscv/packed_helper.c | 73 +++++++++++++++++++++++
>>>> 4 files changed, 172 insertions(+)
>>>>
>>>> diff --git a/target/riscv/helper.h b/target/riscv/helper.h
>>>> index 6d622c732a..a69a6b4e84 100644
>>>> --- a/target/riscv/helper.h
>>>> +++ b/target/riscv/helper.h
>>>> @@ -1175,3 +1175,12 @@ DEF_HELPER_3(rstsa16, tl, env, tl, tl)
>>>> DEF_HELPER_3(urstsa16, tl, env, tl, tl)
>>>> DEF_HELPER_3(kstsa16, tl, env, tl, tl)
>>>> DEF_HELPER_3(ukstsa16, tl, env, tl, tl)
>>>> +
>>>> +DEF_HELPER_3(radd8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(uradd8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(kadd8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(ukadd8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(rsub8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(ursub8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(ksub8, tl, env, tl, tl)
>>>> +DEF_HELPER_3(uksub8, tl, env, tl, tl)
>>>> diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
>>>> index 8815e90476..358dd1fa10 100644
>>>> --- a/target/riscv/insn32.decode
>>>> +++ b/target/riscv/insn32.decode
>>>> @@ -624,3 +624,14 @@ rstsa16 1011011 ..... ..... 010 .....
>>>> 1111111 @r
>>>> urstsa16 1101011 ..... ..... 010 ..... 1111111 @r
>>>> kstsa16 1100011 ..... ..... 010 ..... 1111111 @r
>>>> ukstsa16 1110011 ..... ..... 010 ..... 1111111 @r
>>>> +
>>>> +add8 0100100 ..... ..... 000 ..... 1111111 @r
>>>> +radd8 0000100 ..... ..... 000 ..... 1111111 @r
>>>> +uradd8 0010100 ..... ..... 000 ..... 1111111 @r
>>>> +kadd8 0001100 ..... ..... 000 ..... 1111111 @r
>>>> +ukadd8 0011100 ..... ..... 000 ..... 1111111 @r
>>>> +sub8 0100101 ..... ..... 000 ..... 1111111 @r
>>>> +rsub8 0000101 ..... ..... 000 ..... 1111111 @r
>>>> +ursub8 0010101 ..... ..... 000 ..... 1111111 @r
>>>> +ksub8 0001101 ..... ..... 000 ..... 1111111 @r
>>>> +uksub8 0011101 ..... ..... 000 ..... 1111111 @r
>>>> diff --git a/target/riscv/insn_trans/trans_rvp.c.inc
>>>> b/target/riscv/insn_trans/trans_rvp.c.inc
>>>> index 0885a4fd45..109f560ec9 100644
>>>> --- a/target/riscv/insn_trans/trans_rvp.c.inc
>>>> +++ b/target/riscv/insn_trans/trans_rvp.c.inc
>>>> @@ -159,3 +159,82 @@ GEN_RVP_R_OOL(rstsa16);
>>>> GEN_RVP_R_OOL(urstsa16);
>>>> GEN_RVP_R_OOL(kstsa16);
>>>> GEN_RVP_R_OOL(ukstsa16);
>>>> +
>>>> +/* 8-bit Addition & Subtraction Instructions */
>>>> +/*
>>>> + * Copied from tcg-op-gvec.c.
>>>> + *
>>>> + * Perform a vector addition using normal addition and a mask.
>>>> The mask
>>>> + * should be the sign bit of each lane. This 6-operation form is
>>>> more
>>>> + * efficient than separate additions when there are 4 or more
>>>> lanes in
>>>> + * the 64-bit operation.
>>>> + */
>>>> +
>>>> +static void gen_simd_add_mask(TCGv d, TCGv a, TCGv b, TCGv m)
>>>> +{
>>>> + TCGv t1 = tcg_temp_new();
>>>> + TCGv t2 = tcg_temp_new();
>>>> + TCGv t3 = tcg_temp_new();
>>>> +
>>>> + tcg_gen_andc_tl(t1, a, m);
>>>> + tcg_gen_andc_tl(t2, b, m);
>>>> + tcg_gen_xor_tl(t3, a, b);
>>>> + tcg_gen_add_tl(d, t1, t2);
>>>> + tcg_gen_and_tl(t3, t3, m);
>>>> + tcg_gen_xor_tl(d, d, t3);
>>>> +
>>>> + tcg_temp_free(t1);
>>>> + tcg_temp_free(t2);
>>>> + tcg_temp_free(t3);
>>>> +}
>>>> +
>>>> +static void tcg_gen_simd_add8(TCGv d, TCGv a, TCGv b)
>>>> +{
>>>> + TCGv m = tcg_const_tl((target_ulong)dup_const(MO_8, 0x80));
>>>> + gen_simd_add_mask(d, a, b, m);
>>>> + tcg_temp_free(m);
>>>> +}
>>>> +
>>>> +GEN_RVP_R_INLINE(add8, add, 0, trans_add);
>>>> +
>>>> +/*
>>>> + * Copied from tcg-op-gvec.c.
>>>> + *
>>>> + * Perform a vector subtraction using normal subtraction and a mask.
>>>> + * Compare gen_addv_mask above.
>>>> + */
>>>> +static void gen_simd_sub_mask(TCGv d, TCGv a, TCGv b, TCGv m)
>>>> +{
>>>> + TCGv t1 = tcg_temp_new();
>>>> + TCGv t2 = tcg_temp_new();
>>>> + TCGv t3 = tcg_temp_new();
>>>> +
>>>> + tcg_gen_or_tl(t1, a, m);
>>>> + tcg_gen_andc_tl(t2, b, m);
>>>> + tcg_gen_eqv_tl(t3, a, b);
>>>> + tcg_gen_sub_tl(d, t1, t2);
>>>> + tcg_gen_and_tl(t3, t3, m);
>>>> + tcg_gen_xor_tl(d, d, t3);
>>>> +
>>>> + tcg_temp_free(t1);
>>>> + tcg_temp_free(t2);
>>>> + tcg_temp_free(t3);
>>>> +}
>>>> +
>>>> +static void tcg_gen_simd_sub8(TCGv d, TCGv a, TCGv b)
>>>> +{
>>>> + TCGv m = tcg_const_tl((target_ulong)dup_const(MO_8, 0x80));
>>>> + gen_simd_sub_mask(d, a, b, m);
>>>> + tcg_temp_free(m);
>>>> +}
>>>> +
>>>> +GEN_RVP_R_INLINE(sub8, sub, 0, trans_sub);
>>>> +
>>>> +GEN_RVP_R_OOL(radd8);
>>>> +GEN_RVP_R_OOL(uradd8);
>>>> +GEN_RVP_R_OOL(kadd8);
>>>> +GEN_RVP_R_OOL(ukadd8);
>>>> +GEN_RVP_R_OOL(rsub8);
>>>> +GEN_RVP_R_OOL(ursub8);
>>>> +GEN_RVP_R_OOL(ksub8);
>>>> +GEN_RVP_R_OOL(uksub8);
>>>> diff --git a/target/riscv/packed_helper.c
>>>> b/target/riscv/packed_helper.c
>>>> index b84abaaf25..62db072204 100644
>>>> --- a/target/riscv/packed_helper.c
>>>> +++ b/target/riscv/packed_helper.c
>>>> @@ -352,3 +352,76 @@ static inline void do_ukstsa16(CPURISCVState
>>>> *env, void *vd, void *va,
>>>> }
>>>>
>>>> RVPR(ukstsa16, 2, 2);
>>>> +
>>>> +/* 8-bit Addition & Subtraction Instructions */
>>>> +static inline void do_radd8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + int8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = hadd32(a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(radd8, 1, 1);
>>>> +
>>>> +static inline void do_uradd8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + uint8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = haddu32(a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(uradd8, 1, 1);
>>>> +
>>>> +static inline void do_kadd8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + int8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = sadd8(env, 0, a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(kadd8, 1, 1);
>>>> +
>>>> +static inline void do_ukadd8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + uint8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = saddu8(env, 0, a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(ukadd8, 1, 1);
>>>> +
>>>> +static inline void do_rsub8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + int8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = hsub32(a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(rsub8, 1, 1);
>>>> +
>>>> +static inline void do_ursub8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + uint8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = hsubu64(a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(ursub8, 1, 1);
>>>> +
>>>> +static inline void do_ksub8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + int8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = ssub8(env, 0, a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(ksub8, 1, 1);
>>>> +
>>>> +static inline void do_uksub8(CPURISCVState *env, void *vd, void *va,
>>>> + void *vb, uint8_t i)
>>>> +{
>>>> + uint8_t *d = vd, *a = va, *b = vb;
>>>> + d[i] = ssubu8(env, 0, a[i], b[i]);
>>>> +}
>>>> +
>>>> +RVPR(uksub8, 1, 1);
>>>> --
>>>> 2.17.1
>>>>
>>
>> The naming on some of these helpers is a bit odd, but given that
>> they're a mix of the V and P extensions it's probably fine to just
>> leave them as-is.
>> Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
next prev parent reply other threads:[~2021-05-26 6:16 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-12 15:02 [PATCH 00/38] target/riscv: support packed extension v0.9.2 LIU Zhiwei
2021-02-12 15:02 ` [PATCH 01/38] target/riscv: implementation-defined constant parameters LIU Zhiwei
2021-03-09 14:08 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 02/38] target/riscv: Hoist vector functions LIU Zhiwei
2021-03-09 14:10 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 03/38] target/riscv: Fixup saturate subtract function LIU Zhiwei
2021-02-12 18:52 ` Richard Henderson
2021-03-09 14:11 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 04/38] target/riscv: 16-bit Addition & Subtraction Instructions LIU Zhiwei
2021-02-12 18:03 ` Richard Henderson
2021-02-18 8:39 ` LIU Zhiwei
2021-02-18 16:20 ` Richard Henderson
2021-02-12 19:02 ` Richard Henderson
2021-02-18 8:47 ` LIU Zhiwei
2021-02-18 16:21 ` Richard Henderson
2021-02-12 15:02 ` [PATCH 05/38] target/riscv: 8-bit Addition & Subtraction Instruction LIU Zhiwei
2021-03-15 21:22 ` Alistair Francis
2021-05-24 1:00 ` Palmer Dabbelt
2021-05-26 5:43 ` LIU Zhiwei
2021-05-26 6:15 ` Palmer Dabbelt [this message]
2021-02-12 15:02 ` [PATCH 06/38] target/riscv: SIMD 16-bit Shift Instructions LIU Zhiwei
2021-03-15 21:25 ` Alistair Francis
2021-03-16 2:40 ` LIU Zhiwei
2021-03-16 19:54 ` Alistair Francis
2021-03-17 2:30 ` LIU Zhiwei
2021-03-17 20:39 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 07/38] target/riscv: SIMD 8-bit " LIU Zhiwei
2021-03-15 21:27 ` Alistair Francis
2021-05-24 4:46 ` Palmer Dabbelt
2021-02-12 15:02 ` [PATCH 08/38] target/riscv: SIMD 16-bit Compare Instructions LIU Zhiwei
2021-03-15 21:28 ` Alistair Francis
2021-05-26 5:30 ` Palmer Dabbelt
2021-05-26 5:31 ` Palmer Dabbelt
2021-02-12 15:02 ` [PATCH 09/38] target/riscv: SIMD 8-bit " LIU Zhiwei
2021-03-15 21:31 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 10/38] target/riscv: SIMD 16-bit Multiply Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 11/38] target/riscv: SIMD 8-bit " LIU Zhiwei
2021-03-15 21:33 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 12/38] target/riscv: SIMD 16-bit Miscellaneous Instructions LIU Zhiwei
2021-03-15 21:35 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 13/38] target/riscv: SIMD 8-bit " LIU Zhiwei
2021-03-16 14:38 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 14/38] target/riscv: 8-bit Unpacking Instructions LIU Zhiwei
2021-03-16 14:40 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 15/38] target/riscv: 16-bit Packing Instructions LIU Zhiwei
2021-03-16 14:42 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 16/38] target/riscv: Signed MSW 32x32 Multiply and Add Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 17/38] target/riscv: Signed MSW 32x16 " LIU Zhiwei
2021-03-16 16:01 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 18/38] target/riscv: Signed 16-bit Multiply 32-bit Add/Subtract Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 19/38] target/riscv: Signed 16-bit Multiply 64-bit " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 20/38] target/riscv: Partial-SIMD Miscellaneous Instructions LIU Zhiwei
2021-03-16 19:44 ` Alistair Francis
2021-02-12 15:02 ` [PATCH 21/38] target/riscv: 8-bit Multiply with 32-bit Add Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 22/38] target/riscv: 64-bit Add/Subtract Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 23/38] target/riscv: 32-bit Multiply " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 24/38] target/riscv: Signed 16-bit Multiply with " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 25/38] target/riscv: Non-SIMD Q15 saturation ALU Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 26/38] target/riscv: Non-SIMD Q31 " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 27/38] target/riscv: 32-bit Computation Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 28/38] target/riscv: Non-SIMD Miscellaneous Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 29/38] target/riscv: RV64 Only SIMD 32-bit Add/Subtract Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 30/38] target/riscv: RV64 Only SIMD 32-bit Shift Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 31/38] target/riscv: RV64 Only SIMD 32-bit Miscellaneous Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 32/38] target/riscv: RV64 Only SIMD Q15 saturating Multiply Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 33/38] target/riscv: RV64 Only 32-bit " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 34/38] target/riscv: RV64 Only 32-bit Multiply & Add Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 35/38] target/riscv: RV64 Only 32-bit Parallel " LIU Zhiwei
2021-02-12 15:02 ` [PATCH 36/38] target/riscv: RV64 Only Non-SIMD 32-bit Shift Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 37/38] target/riscv: RV64 Only 32-bit Packing Instructions LIU Zhiwei
2021-02-12 15:02 ` [PATCH 38/38] target/riscv: configure and turn on packed extension from command line LIU Zhiwei
2021-03-05 6:14 ` [PATCH 00/38] target/riscv: support packed extension v0.9.2 LIU Zhiwei
2021-04-13 3:27 ` LIU Zhiwei
2021-04-15 4:46 ` Alistair Francis
2021-04-15 5:50 ` LIU Zhiwei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mhng-79de2915-d9b8-4cbb-8d78-bd4634de1984@palmerdabbelt-glaptop \
--to=palmer@dabbelt.com \
--cc=alistair23@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhiwei_liu@c-sky.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).