power_insn: support sats/satu specifiers
authorDmitry Selyutin <ghostmansd@gmail.com>
Mon, 21 Nov 2022 16:34:06 +0000 (19:34 +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 ac07e627677707f3f5f483bb6244e107b7bc988d..2134750398fc97afa87da4e8c27fbd40b773f0e7 100644 (file)
@@ -2834,6 +2834,40 @@ class SpecifierSEA(Specifier):
         rm.sea = 1
 
 
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierSat(Specifier):
+    desc: str
+    sign: bool
+
+    @classmethod
+    def match(cls, desc, record, etalon, sign):
+        if desc != etalon:
+            return None
+
+        return cls(record=record, desc=desc, sign=sign)
+
+    def assemble(self, insn):
+        rm = insn.prefix.rm.select(record=self.record)
+        rm.mode.sel = 2
+        rm.sat = 1 if self.sign else 0
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierSatS(Specifier):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record,
+            etalon="sats", sign=True)
+
+
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierSatU(Specifier):
+    @classmethod
+    def match(cls, desc, record):
+        return super().match(desc=desc, record=record,
+            etalon="satu", sign=False)
+
+
 class Specifiers(tuple):
     SPECS = (
         SpecifierW,
@@ -2849,6 +2883,8 @@ class Specifiers(tuple):
         SpecifierSZ,
         SpecifierDZ,
         SpecifierEls,
+        SpecifierSatS,
+        SpecifierSatU,
     )
 
     def __new__(cls, items, record):