qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] target/riscv: Implement dynamic establishment of custom deco


From: Richard Henderson
Subject: Re: [PATCH] target/riscv: Implement dynamic establishment of custom decoder
Date: Thu, 7 Mar 2024 10:35:45 -1000
User-agent: Mozilla Thunderbird

-        for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i) {
-            if (decoders[i].guard_func(ctx->cfg_ptr) &&
-                decoders[i].decode_func(ctx, opcode32)) {
+        for (size_t i = 0; i < decoder_table_size; ++i) {
+            if (ctx->decoder[i](ctx, opcode32)) {
                  return;

By the way, you're adding layers of pointer chasing, so I suspect you'll find all of this is a wash or worse, performance-wise.

Indeed, since some of the predicates are trivial, going the other way might help: allow everything to be inlined:

    if (decode_insn32(...)) {
        return;
    }
    if (has_xthead_p(...) && decode_xthead(...)) {
        return;
    }
    ...

Even if there are 10 entries here, so what? All of the code has to be compiled into QEMU. You're not going to somehow add truly dynamic code that you've loaded from a module.

You could perhaps streamline predicates such as has_xthead_p to not test 11 variables by adding an artificial "ext_xthead_any" configuration entry that is the sum of all of those.


r~



reply via email to

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