qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Mayuresh Chitale <mchitale@ventanamicro.com>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	alistair.francis@wdc.com
Cc: Alistair Francis <alistair23@gmail.com>,
	Daniel Barboza <dbarboza@ventanamicro.com>,
	liweiwei@iscas.ac.cn
Subject: Re: [RFC PATCH 3/4] target/riscv: check smstateen fcsr flag
Date: Mon, 10 Apr 2023 18:52:48 -0700	[thread overview]
Message-ID: <9592dac6-2ba7-533a-1d70-2244ecc59761@linaro.org> (raw)
In-Reply-To: <20230410141316.3317474-4-mchitale@ventanamicro.com>

On 4/10/23 07:13, Mayuresh Chitale wrote:
> +#ifndef CONFIG_USER_ONLY
> +#define smstateen_fcsr_check(ctx) do { \
> +    if (!ctx->smstateen_fcsr_ok) { \
> +        if (ctx->virt_enabled) { \
> +            generate_exception(ctx, RISCV_EXCP_VIRT_INSTRUCTION_FAULT); \
> +        } else { \
> +            generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST); \
> +        } \
> +        return true; \
> +    } \
> +} while (0)
> +#else
> +#define smstateen_fcsr_check(ctx)
> +#endif
> +
> +#define REQUIRE_ZFINX_OR_F(ctx) do { \
> +    if (!has_ext(ctx, RVF)) { \
> +        if (!ctx->cfg_ptr->ext_zfinx) { \
> +            return false; \
> +        } \
> +        smstateen_fcsr_check(ctx); \
>       } \
>   } while (0)

As a matter of style, I strongly object to a *nested* macro returning from the calling 
function.  These should all be changed to normal functions of the form

     if (!require_xyz(ctx) || !require_abc(ctx)) {
         return something;
     }

etc.  insn_trans/trans_rvv.c.inc is much much cleaner in this respect.


r~


  parent reply	other threads:[~2023-04-11  1:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 14:13 [RFC PATCH 0/4] Smstateen FCSR implementation Mayuresh Chitale
2023-04-10 14:13 ` [RFC PATCH 1/4] target/riscv: smstateen check for fcsr Mayuresh Chitale
2023-04-10 14:44   ` liweiwei
2023-04-14  5:41     ` Mayuresh Chitale
2023-04-10 14:13 ` [RFC PATCH 2/4] target/riscv: Add fcsr field in tb->flags Mayuresh Chitale
2023-04-11  1:47   ` Richard Henderson
2023-04-14  5:46     ` Mayuresh Chitale
2023-04-10 14:13 ` [RFC PATCH 3/4] target/riscv: check smstateen fcsr flag Mayuresh Chitale
2023-04-10 14:30   ` liweiwei
2023-04-14  5:42     ` Mayuresh Chitale
2023-04-11  1:52   ` Richard Henderson [this message]
2023-04-14  5:44     ` Mayuresh Chitale
2023-04-10 14:13 ` [RFC PATCH 4/4] target/riscv: smstateen knobs Mayuresh Chitale

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=9592dac6-2ba7-533a-1d70-2244ecc59761@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=mchitale@ventanamicro.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@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).