[Libre-soc-bugs] [Bug 979] Implement C-based Power ISA decoder compiler

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Thu Sep 7 21:14:11 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=979

--- Comment #36 from Dmitry Selyutin <ghostmansd at gmail.com> ---
Good news everyone! I've updated the code generation so that it also includes
the details about the operand flags:

struct svp64_operand {
    uint32_t value;
    uint32_t flags;
};

#define SVP64_OPERAND_SIGNED    (UINT32_C(1) << UINT32_C(0))
#define SVP64_OPERAND_GPR       (UINT32_C(1) << UINT32_C(1))
#define SVP64_OPERAND_FPR       (UINT32_C(1) << UINT32_C(2))
#define SVP64_OPERAND_PAIR      (UINT32_C(1) << UINT32_C(3))
#define SVP64_OPERAND_CR3       (UINT32_C(1) << UINT32_C(4))
#define SVP64_OPERAND_CR5       (UINT32_C(1) << UINT32_C(5))
#define SVP64_OPERAND_NONZERO   (UINT32_C(1) << UINT32_C(6))
#define SVP64_OPERAND_ADDRESS   (UINT32_C(1) << UINT32_C(7))

>From now on, every operand has flags assigned as well, including tricky cases
like address operands and operands split accross multiple fields:

    case 0x0e: /* target_addr */
        value = (
            (
                (
                    /* 16 */ (((insn >> UINT32_C(15)) & UINT32_C(1)) <<
UINT32_C(13)) |
                    /* 17 */ (((insn >> UINT32_C(14)) & UINT32_C(1)) <<
UINT32_C(12)) |
                    /* 18 */ (((insn >> UINT32_C(13)) & UINT32_C(1)) <<
UINT32_C(11)) |
                    /* 19 */ (((insn >> UINT32_C(12)) & UINT32_C(1)) <<
UINT32_C(10)) |
                    /* 20 */ (((insn >> UINT32_C(11)) & UINT32_C(1)) <<
UINT32_C(9)) |
                    /* 21 */ (((insn >> UINT32_C(10)) & UINT32_C(1)) <<
UINT32_C(8)) |
                    /* 22 */ (((insn >> UINT32_C(9)) & UINT32_C(1)) <<
UINT32_C(7)) |
                    /* 23 */ (((insn >> UINT32_C(8)) & UINT32_C(1)) <<
UINT32_C(6)) |
                    /* 24 */ (((insn >> UINT32_C(7)) & UINT32_C(1)) <<
UINT32_C(5)) |
                    /* 25 */ (((insn >> UINT32_C(6)) & UINT32_C(1)) <<
UINT32_C(4)) |
                    /* 26 */ (((insn >> UINT32_C(5)) & UINT32_C(1)) <<
UINT32_C(3)) |
                    /* 27 */ (((insn >> UINT32_C(4)) & UINT32_C(1)) <<
UINT32_C(2)) |
                    /* 28 */ (((insn >> UINT32_C(3)) & UINT32_C(1)) <<
UINT32_C(1)) |
                    /* 29 */ (((insn >> UINT32_C(2)) & UINT32_C(1)) <<
UINT32_C(0)) |
                    UINT32_C(0)
                )
                ^
                (UINT32_C(1) << (UINT32_C(14) - 1))
            )
            -
            (UINT32_C(1) << (UINT32_C(14) - 1))
        );
        flags = SVP64_OPERAND_SIGNED;
        break;

    case 0x12: /* D */
        value = (
            (
                (
                    /* 16 */ (((insn >> UINT32_C(15)) & UINT32_C(1)) <<
UINT32_C(15)) |
                    /* 17 */ (((insn >> UINT32_C(14)) & UINT32_C(1)) <<
UINT32_C(14)) |
                    /* 18 */ (((insn >> UINT32_C(13)) & UINT32_C(1)) <<
UINT32_C(13)) |
                    /* 19 */ (((insn >> UINT32_C(12)) & UINT32_C(1)) <<
UINT32_C(12)) |
                    /* 20 */ (((insn >> UINT32_C(11)) & UINT32_C(1)) <<
UINT32_C(11)) |
                    /* 21 */ (((insn >> UINT32_C(10)) & UINT32_C(1)) <<
UINT32_C(10)) |
                    /* 22 */ (((insn >> UINT32_C(9)) & UINT32_C(1)) <<
UINT32_C(9)) |
                    /* 23 */ (((insn >> UINT32_C(8)) & UINT32_C(1)) <<
UINT32_C(8)) |
                    /* 24 */ (((insn >> UINT32_C(7)) & UINT32_C(1)) <<
UINT32_C(7)) |
                    /* 25 */ (((insn >> UINT32_C(6)) & UINT32_C(1)) <<
UINT32_C(6)) |
                    /* 11 */ (((insn >> UINT32_C(20)) & UINT32_C(1)) <<
UINT32_C(5)) |
                    /* 12 */ (((insn >> UINT32_C(19)) & UINT32_C(1)) <<
UINT32_C(4)) |
                    /* 13 */ (((insn >> UINT32_C(18)) & UINT32_C(1)) <<
UINT32_C(3)) |
                    /* 14 */ (((insn >> UINT32_C(17)) & UINT32_C(1)) <<
UINT32_C(2)) |
                    /* 15 */ (((insn >> UINT32_C(16)) & UINT32_C(1)) <<
UINT32_C(1)) |
                    /* 31 */ (((insn >> UINT32_C(0)) & UINT32_C(1)) <<
UINT32_C(0)) |
                    UINT32_C(0)
                )
                ^
                (UINT32_C(1) << (UINT32_C(16) - 1))
            )
            -
            (UINT32_C(1) << (UINT32_C(16) - 1))
        );
        flags = SVP64_OPERAND_SIGNED;
        break;

    case 0x1b: /* SVxd */
        value = (
            /* 6  */ (((insn >> UINT32_C(25)) & UINT32_C(1)) << UINT32_C(4)) |
            /* 7  */ (((insn >> UINT32_C(24)) & UINT32_C(1)) << UINT32_C(3)) |
            /* 8  */ (((insn >> UINT32_C(23)) & UINT32_C(1)) << UINT32_C(2)) |
            /* 9  */ (((insn >> UINT32_C(22)) & UINT32_C(1)) << UINT32_C(1)) |
            /* 10 */ (((insn >> UINT32_C(21)) & UINT32_C(1)) << UINT32_C(0)) |
            UINT32_C(0)
        );
        flags = SVP64_OPERAND_NONZERO;
        break;

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list