qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 25/43] target/loongarch: Add LoongArch CSR instruction


From: Richard Henderson
Subject: Re: [PATCH v2 25/43] target/loongarch: Add LoongArch CSR instruction
Date: Tue, 26 Apr 2022 07:52:20 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0

On 4/26/22 02:03, yangxiaojuan wrote:
Hi, Richard

On 2022/4/26 上午6:55, Richard Henderson wrote:
On 4/25/22 02:10, Xiaojuan Yang wrote:
+static void output_r_csr(DisasContext *ctx, arg_r_csr *a,
+                         const char *mnemonic)
+{
+    output(ctx, mnemonic, "r%d, %d # %s", a->rd, a->csr, csr_names[a->csr]);
+}
+
+static void output_rr_csr(DisasContext *ctx, arg_rr_csr *a,
+                          const char *mnemonic)
+{
+    output(ctx, mnemonic, "r%d, r%d, %d # %s",
+           a->rd, a->rj, a->csr, csr_names[a->csr]);

Need to check for csr not in csr_names.

I will re-used  get_csr() to check csr,

like this:
if (get_csr() == NULL)
{
     printf("Undefined CSR.\n");
} else {
     printf(" %s\n",  csr_names[a->csr]);
}

No, please don't. Since this is used twice, you may wish to create a local get_csr_name() function, but it's as simple as checking ARRAY_SIZE(csr_names), and validating that the entry has a name.

The disassembler should stay self-contained, so that we may re-use it for tcg/loongarch64 host disassembly.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]