power_insn: support sea specifier assembly
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 20 Nov 2022 14:49:44 +0000 (17:49 +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 58190b4630509b1687ba247a73aaeb9b031e4939..a382e146527742a5a9d46556d55473fcb7c2d13a 100644 (file)
@@ -2833,6 +2833,33 @@ class SpecifierEls(Specifier):
             rm.mode.sel = 1
 
 
+@_dataclasses.dataclass(eq=True, frozen=True)
+class SpecifierSEA(Specifier):
+    @classmethod
+    def match(cls, desc, record):
+        if desc != "els":
+            return None
+
+        return cls(record=record)
+
+    def validate(self, others):
+        if self.record.svp64.mode is not _SVMode.LDST_IDX:
+            raise ValueError("sea is only valid in ld/st modes")
+
+        items = list(others)
+        while items:
+            spec = items.pop()
+            if isinstance(spec, SpecifierFF):
+                raise ValueError(f"sea cannot be used in ff mode")
+            spec.validate(others=items)
+
+    def assemble(self, insn):
+        rm = insn.prefix.rm.select(record=self.record)
+        if rm.mode.sel not in (0b00, 0b01):
+            raise ValueError("sea is only valid for normal and els modes")
+        rm.sea = 1
+
+
 class Specifiers(tuple):
     SPECS = (
         SpecifierW,