power_insn: support predicates masks
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 15 Nov 2022 15:49:23 +0000 (18:49 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 15 Jan 2023 19:47:22 +0000 (22:47 +0300)
src/openpower/decoder/power_insn.py

index d5b3487511f34690195cee5cd17e14ce524d0586..f22536270d7c62049a310afdebe93ee58155eb54 100644 (file)
@@ -2588,6 +2588,51 @@ class SpecifierPR(SpecifierFFPR):
         return super().match(desc=desc, record=record, mode="pr")
 
 
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierMask(SpecifierPredicate):
+    @classmethod
+    def match(cls, desc, record, mode):
+        return super().match(desc=desc, record=record,
+            mode_match=lambda mode_arg: mode_arg == mode,
+            pred_match=lambda pred_arg: _SVP64PredicateType(pred_arg) in (
+                _SVP64PredicateType.INTEGER,
+                _SVP64PredicateType.CR,
+            ))
+
+    def assemble(self, insn):
+        raise NotImplementedError
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierM(SpecifierMask):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record, mode="m")
+
+    def assemble(self, insn):
+        insn.prefix.rm.mask = self.pred.mask
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierSM(SpecifierMask):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record, mode="sm")
+
+    def assemble(self, insn):
+        insn.prefix.rm.smask = self.pred.mask
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierDM(SpecifierMask):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record, mode="dm")
+
+    def assemble(self, insn):
+        insn.prefix.rm.mask = self.pred.mask
+
+
 class SVP64Instruction(PrefixedInstruction):
     """SVP64 instruction: https://libre-soc.org/openpower/sv/svp64/"""
     class Prefix(PrefixedInstruction.Prefix):
@@ -2617,6 +2662,9 @@ class SVP64Instruction(PrefixedInstruction):
             SpecifierSubVL,
             SpecifierFF,
             SpecifierPR,
+            SpecifierMask,
+            SpecifierSM,
+            SpecifierDM,
         )
 
         for spec_cls in specifiers: