qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 02/27] arc: Decoder code


From: Richard Henderson
Subject: Re: [PATCH 02/27] arc: Decoder code
Date: Tue, 6 Apr 2021 18:25:04 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

On 4/5/21 7:31 AM, cupertinomiranda@gmail.com wrote:
+static long long int
+extract_uimm6_20(unsigned long long insn ATTRIBUTE_UNUSED,

global replace long long int with int64_t,
and unsigned long long int with uint64_t.


+{
+  unsigned value = 0;
+
+  value |= ((insn >> 6) & 0x003f) << 0;
+
+  return value;
+}

return extract64(insn, 6, 6);

and so forth.  Please minimize the by-hand bit manipulation.

+static const struct arc_opcode *find_format(insn_t *pinsn,
+                                            uint64_t insn,
+                                            uint8_t insn_len,
+                                            uint32_t isa_mask)
+{
+    uint32_t i = 0;
+    const struct arc_opcode *opcode = NULL;
+    const uint8_t *opidx;
+    const uint8_t *flgidx;
+    bool has_limm = false;
+
+    do {
+        bool invalid = false;
+        uint32_t noperands = 0;
+
+        opcode = &arc_opcodes[i++];
+        memset(pinsn, 0, sizeof(*pinsn));
+
+        if (!(opcode->cpu & isa_mask)) {
+            continue;
+        }
+
+        if (arc_opcode_len(opcode) != (int) insn_len) {
+            continue;
+        }
+
+        if ((insn & opcode->mask) != opcode->opcode) {
+            continue;
+        }

A linear search through the entire opcode table, really?
You can do better.

Before you re-invent the wheel, please first have a look at docs/devel/decodetree.rst. I see no reason why you can't take those tables that you import your tables from binutils, as you're doing now, and then have a small program that converts to decodetree at build-time.


r~



reply via email to

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