From: Richard Henderson <richard.henderson@linaro.org>
To: Ivan Klokov <ivan.klokov@syntacore.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/riscv: Add RVV registers to log
Date: Wed, 1 Feb 2023 11:30:15 -1000 [thread overview]
Message-ID: <53b0cacd-18b4-c524-0877-7813f916b9bb@linaro.org> (raw)
In-Reply-To: <20230201142454.109260-1-ivan.klokov@syntacore.com>
On 2/1/23 04:24, Ivan Klokov wrote:
> + * @CPU_DUMP_RVV: dump RISC-V RVV registers
> */
> enum CPUDumpFlags {
> CPU_DUMP_CODE = 0x00010000,
> CPU_DUMP_FPU = 0x00020000,
> CPU_DUMP_CCOP = 0x00040000,
> + CPU_DUMP_RVV = 0x00080000,
We're certainly not going to call this "RVV", as that is not generic. But we certainly
can add something named "VPU" or "VEC" or "VECTOR".
> +++ b/accel/tcg/cpu-exec.c
> @@ -296,6 +296,11 @@ static void log_cpu_exec(target_ulong pc, CPUState *cpu,
> }
> #if defined(TARGET_I386)
> flags |= CPU_DUMP_CCOP;
> +#endif
> +#if defined(TARGET_RISCV)
> + if (qemu_loglevel_mask(CPU_LOG_RISCV_RVV)) {
> + flags |= CPU_DUMP_RVV;
> + }
> #endif
Hard no here. Most of the time while debugging we don't care about vector state.
What you should add is a new -d vec flag to match -d fpu, so that one can select vector
state explicitly.
> @@ -459,6 +468,44 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
> }
> }
> }
> + if (riscv_has_ext(env, RVV)) {
> + if (flags & CPU_DUMP_RVV) {
> +
> + static const int dump_rvv_csrs[] = {
> + CSR_VSTART,
> + CSR_VXSAT,
> + CSR_VXRM,
> + CSR_VCSR,
> + CSR_VL,
> + CSR_VTYPE,
> + CSR_VLENB,
> + };
> + for (int i = 0; i < ARRAY_SIZE(dump_rvv_csrs); ++i) {
> + int csrno = dump_rvv_csrs[i];
> + target_ulong val = 0;
> + RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
> +
> + /*
> + * Rely on the smode, hmode, etc, predicates within csr.c
> + * to do the filtering of the registers that are present.
> + */
> + if (res == RISCV_EXCP_NONE) {
> + qemu_fprintf(f, " %-8s " TARGET_FMT_lx "\n",
> + csr_ops[csrno].name, val);
> + }
> + }
> + uint16_t vlenb = env_archcpu(env)->cfg.vlen >> 3;
> +
> + for (i = 0; i < 32; i++) {
> + qemu_fprintf(f, " %-8s ", riscv_rvv_regnames[i]);
> + p = (uint8_t *)env->vreg;
> + for (j = 0; j < vlenb; j++) {
> + qemu_fprintf(f, "%02x", *(p + i * vlenb + j));
> + }
> + qemu_fprintf(f, "\n");
> + }
This doesn't take host byte ordering into account.
See HOST_BIG_ENDIAN in vector_helper.c.
If you read and print in units of uint64_t, you'll avoid this problem.
r~
prev parent reply other threads:[~2023-02-01 21:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 14:24 [PATCH] target/riscv: Add RVV registers to log Ivan Klokov
2023-02-01 21:30 ` Richard Henderson [this message]
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=53b0cacd-18b4-c524-0877-7813f916b9bb@linaro.org \
--to=richard.henderson@linaro.org \
--cc=ivan.klokov@syntacore.com \
--cc=qemu-devel@nongnu.org \
/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).