[Libre-soc-bugs] [Bug 898] binutils svp64 objdump support

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Aug 21 10:57:27 BST 2022


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

--- Comment #9 from Dmitry Selyutin <ghostmansd at gmail.com> ---
I also added a "special" __post_init__ method, like dataclasses do. The code we
use now looks like this:

class PrefixedInstruction(Instruction):
    class Prefix(WordInstruction):
        class Error(ValueError):
            pass

        def __post_init__(self):
            if self.major != 0x1:
                raise self.__class__.Error(self.major)
            return super().__post_init__()

    class Suffix(WordInstruction):
        pass

    prefix: Prefix = range(0, 32)
    suffix: Suffix = range(32, 64)
    major: _Field = Suffix.major


class SVP64Instruction(PrefixedInstruction):
    class Prefix(PrefixedInstruction.Prefix, _Prefix):
        class Error(PrefixedInstruction.Prefix.Error):
            pass

        def __post_init__(self):
            if self.pid != 0b11:
                raise self.__class__.Error(self.pid)
            return super().__post_init__()

    prefix: Prefix


This can be even more reduced if I drop custom Error classes; however, I found
it convenient to simply try to create SVP64Instruction and catch
SVP64Instruction.Prefix.Error. If the error is caught, we resort to simple
PrefixedInstruction (which, in turn, might raise its own exception, which can
be also caught).

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


More information about the libre-soc-bugs mailing list