From: Richard Henderson <richard.henderson@linaro.org>
To: LIU Zhiwei <zhiwei_liu@c-sky.com>
Cc: Chih-Min Chao <chihmin.chao@sifive.com>,
palmer@sifive.com, Alistair.Francis@wdc.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] RISCV: support riscv vector extension 0.7.1
Date: Thu, 19 Dec 2019 10:38:07 -1000 [thread overview]
Message-ID: <fe1a210e-e4cf-f62a-a39f-2818358d53c9@linaro.org> (raw)
In-Reply-To: <1b1826c3-50e4-2481-56a2-4ebb01e04498@c-sky.com>
On 12/18/19 11:11 PM, LIU Zhiwei wrote:
> I'm sorry that it's really hard to absorb your opinion. I don't know why clang
> will fail
>
> when index beyond the end of vreg[n] into vreg[n+1].
I thought sure one of the address sanitizer checks would detect array bounds
overrun. But it becomes irrelevant
> As Chih-Min Chao said in another part of PATCH V2 thread, VLEN will be a
> property which can be
>
> specified from command line. So the sub-struct maybe defined as
>
> struct {
> union{
> uint64_t *u64 ;
> int64_t *s64;
> uint32_t *u32;
> int32_t *s32;
> uint16_t *u16;
> int16_t *s16;
> uint8_t *u8;
> int8_t *s8;
> } mem;
> target_ulong vxrm;
> target_ulong vxsat;
> target_ulong vl;
> target_ulong vstart;
> target_ulong vtype;
> } vext;
>
> Will that be OK?
Pointers have consequences. It can be done, but I don't think it is ideal.
> The (ill, lmul, sew ) of vtype will be placed within tb_flags, also the bit of
> (VSTART == 0 && VL == VLMAX).
>
> So it will take 8 bits of tb flags for vector extension at least.
Good.
> However, I have one problem to support both command line VLEN and vreg_ofs.
>
> As in SVE, vreg ofs is the offset from cpu_env. If the structure of vector
> extension (to support command line VLEN) is
>
> struct {
> union{
> uint64_t *u64 ;
> int64_t *s64;
> uint32_t *u32;
> int32_t *s32;
> uint16_t *u16;
> int16_t *s16;
> uint8_t *u8;
> int8_t *s8;
> } mem;
> target_ulong vxrm;
> target_ulong vxsat;
> target_ulong vl;
> target_ulong vstart;
> target_ulong vtype;
> } vext
>
> I can't find the way to get the direct offset of vreg from cpu_env.
>
> Maybe I should specify a max VLEN like the way of SVE?
I think a maximum vlen is best. A command-line option to adjust vlen is all
well and good, but there's no reason to have to support vlen=(1<<29).
Oh, and you probably need a minimum vlen of 16 bytes as well, otherwise you
will run afoul of the assert in tcg-op-gvec.c that requires gvec operations to
be aligned mod 16.
I think that all you need is
uint64_t vreg[32 * MAX_VLEN / 8] QEMU_ALIGNED(16);
which gives us
uint32_t vreg_ofs(DisasContext *ctx, int reg)
{
return offsetof(CPURISCVState, vreg) + reg * ctx->vlen;
}
I don't see the point of a union for vreg. I don't think you'll find that you
actually use it at all.
You do need to document the element ordering that you're going to use for vreg.
I.e. the mapping between the architectural vector register state and the
emulation state. You have two choices:
(1) all bytes in host endianness (e.g. target/ppc)
(2) bytes within each uint64_t in host endianness,
but each uint64_t is little-endian (e.g. target/arm).
Both require some fixup when running on a big-endian host.
r~
next prev parent reply other threads:[~2019-12-19 20:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1566959818-38369-1-git-send-email-zhiwei_liu@c-sky.com>
2019-08-28 9:08 ` [Qemu-devel] [PATCH] RISCV: support riscv vector extension 0.7.1 Alex Bennée
2019-08-28 16:39 ` Richard Henderson
2019-08-29 13:35 ` liuzhiwei
2019-08-28 18:54 ` Richard Henderson
2019-08-28 20:43 ` Richard Henderson
2019-08-29 12:45 ` liuzhiwei
2019-08-29 15:09 ` Richard Henderson
2019-09-02 7:45 ` liuzhiwei
2019-09-03 14:38 ` Richard Henderson
2019-09-02 9:43 ` liuzhiwei
2019-09-03 14:21 ` Richard Henderson
2019-12-19 9:11 ` LIU Zhiwei
2019-12-19 20:38 ` Richard Henderson [this message]
2019-12-25 9:36 ` LIU Zhiwei
2019-12-28 1:14 ` Richard Henderson
2019-12-30 8:11 ` LIU Zhiwei
2020-01-05 20:19 ` Richard Henderson
2019-08-28 21:34 ` Alistair Francis
2019-08-29 12:00 ` liuzhiwei
2019-08-29 15:14 ` Richard Henderson
2019-09-02 6:54 ` liuzhiwei
2019-08-29 21:50 ` Alistair Francis
2019-08-30 9:06 ` Alex Bennée
2019-08-30 18:39 ` Alistair Francis
2019-09-02 6:36 ` liuzhiwei
[not found] ` <CAL1e-=iHangj7w+HgJ+FM=iqRLmaY-_CYeUv0gx+c8bpScb9RQ@mail.gmail.com>
[not found] ` <46ade3da-d642-bd19-7975-7dc228d401e4@c-sky.com>
2019-08-29 18:32 ` Aleksandar Markovic
[not found] ` <CAEiOBXXofjrY2=sjuMDb9dTV2fk9yUVKnr+qmf+7mg9vki6OCw@mail.gmail.com>
2019-09-02 8:17 ` [Qemu-devel] [Qemu-riscv] " liuzhiwei
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=fe1a210e-e4cf-f62a-a39f-2818358d53c9@linaro.org \
--to=richard.henderson@linaro.org \
--cc=Alistair.Francis@wdc.com \
--cc=chihmin.chao@sifive.com \
--cc=palmer@sifive.com \
--cc=qemu-devel@nongnu.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).