fix SVSHAPE iterator for index case, stop deepcopy
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 10 Jul 2022 11:42:26 +0000 (12:42 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 10 Jul 2022 11:42:26 +0000 (12:42 +0100)
(was copying entire GPR)

src/openpower/decoder/isa/remapyield.py
src/openpower/decoder/isa/svshape.py

index d0cfd295de4bc1823e8c319b916e5a44f4038cbb..93de9723e913b9ba4bd95fb099da37388fc2d001 100644 (file)
@@ -68,6 +68,8 @@ def iterate_indices(SVSHAPE):
                                ((y_end and x_end)<<1) |
                                 ((y_end and x_end and z_end)<<2))
 
+                    if hasattr(SVSHAPE, "postprocess"): # for Indexed mode
+                        result = SVSHAPE.postprocess(result)
                     yield result + SVSHAPE.offset, loopends
 
 def demo():
index e5d9ed26d469301722a538d0a4cc7a03c9ad6577..7e9ad3227a1431aeaff5b827fceb5bd985b5246b 100644 (file)
@@ -24,7 +24,7 @@ from openpower.util import log
 class SVSHAPE(SelectableInt):
     def __init__(self, value, gpr=None):
         SelectableInt.__init__(self, value, 32)
-        selfยทgpr = gpr # for Indexed mode
+        self.gpr = gpr # for Indexed mode
         offs = 0
         # set up sub-fields from Record layout
         self.fsi = {}
@@ -38,6 +38,9 @@ class SVSHAPE(SelectableInt):
             log("SVSHAPE setup field", field, offs, end)
             offs = end
 
+    def copy(self):
+        return SVSHAPE(self.value, self.gpr)
+
     def is_indexed(self):
         "REMAP Indexed Mode"
         return self.mode == 0b00 and self.submode2 in [0b110, 0b111]
@@ -145,17 +148,18 @@ class SVSHAPE(SelectableInt):
     def offset(self, value):
         self.fsi['offset'].eq(value)
 
-    def _indexed_iterator(self, *args):
-        idx, stop = yield from iterate_indices(*args)
+    def postprocess(self, idx):
+        if self.mode != 0b00 or not self.is_indexed():
+            return idx
         if self.gpr is None:
-            return idx, stop
-        return self.gpr(self.svgpr+idx), stop # TODO: ekwidths
+            return idx
+        remap = self.gpr(self.svgpr+idx).value # TODO: elwidths
+        log ("indexed_iterator", self.svgpr, idx, remap)
+        return remap
 
     def get_iterator(self):
-        log ("SVSHAPE get_iterator", self.mode, self.ydimsz)
-        if self.mode == 0b00 and self.is_indexed():
-            iterate_fn = self._indexed_iterator
-        elif self.mode == 0b00:
+        log ("SVSHAPE get_iterator", self.mode, self.ydimsz, self.is_indexed())
+        if self.mode == 0b00:
             iterate_fn = iterate_indices
         elif self.mode in [0b01, 0b11]:
             # further sub-selection
@@ -170,7 +174,7 @@ class SVSHAPE(SelectableInt):
             elif self.ydimsz in [6, 14, 15]:
                 iterate_fn = iterate_dct_inner_halfswap_loadstore
         # create a **NEW** iterator each time this is called
-        return iterate_fn(deepcopy(self))
+        return iterate_fn(self.copy())
 
 
 if __name__ == '__main__':