power_insn: support all specifier
authorDmitry Selyutin <ghostmansd@gmail.com>
Mon, 21 Nov 2022 17:33:22 +0000 (20:33 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:16 +0000 (19:51 +0100)
src/openpower/decoder/power_insn.py

index a6e69dfa4dc6248d640e6333b5b17f643cc44bb6..84cd5e1cf49dfd4574c9365d91c3366c914d2a1d 100644 (file)
@@ -2915,6 +2915,31 @@ class SpecifierCRM(Specifier):
         rm.crm = 1
 
 
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierBranch(Specifier):
+    @classmethod
+    def match(cls, desc, record, etalon):
+        if desc != etalon:
+            return None
+
+        return cls(record=record)
+
+    def validate(self, others):
+        if self.record.svp64.mode != _SVMode.BRANCH:
+            raise ValueError("only branch modes supported")
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierAll(SpecifierBranch):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record, etalon="all")
+
+    def assemble(self, insn):
+        rm = insn.prefix.rm.select(record=self.record)
+        rm.ALL = 1
+
+
 class Specifiers(tuple):
     SPECS = (
         SpecifierW,
@@ -2935,6 +2960,7 @@ class Specifiers(tuple):
         SpecifierMR,
         SpecifierMRR,
         SpecifierCRM,
+        SpecifierAll,
     )
 
     def __new__(cls, items, record):