qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2] linux-user/elfload: Implement ELF_HWCAP for RISC-V


From: Richard Henderson
Subject: Re: [PATCH v2] linux-user/elfload: Implement ELF_HWCAP for RISC-V
Date: Mon, 5 Jul 2021 20:28:52 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 7/4/21 11:43 PM, Kito Cheng wrote:
+static uint32_t get_elf_hwcap(void)
+{
+    RISCVCPU *cpu = RISCV_CPU(thread_cpu);
+    uint32_t hwcap = 0;
+
+#define MISA_BIT(EXT) (1 << (EXT - 'A'))
+#define GET_EXT(EXT)                           \
+    do {                                       \
+        if (cpu->env.misa & MISA_BIT(EXT)) {    \
+            hwcap |= MISA_BIT(EXT);            \
+        }                                      \
+    } while (0)
+
+    GET_EXT('I');
+    GET_EXT('M');
+    GET_EXT('A');
+    GET_EXT('F');
+    GET_EXT('D');
+    GET_EXT('C');

You're not transforming the bits; there's no reason to be so around-the-bush about this. Just use

    uint32_t mask = MISA_BIT('I') | ...
    return cpu->env.misa & mask;


r~



reply via email to

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