convert all test_caller*.py to work with pytest/unittest test discovery
[openpower-isa.git] / src / openpower / decoder / isa / remapyield.py
index 93de9723e913b9ba4bd95fb099da37388fc2d001..b50df8665cff190d1c2fb95d389b052a13f56f87 100644 (file)
@@ -17,6 +17,7 @@ def iterate_indices(SVSHAPE):
     if SVSHAPE.invxyz[1]: y_r.reverse()
     if SVSHAPE.invxyz[2]: z_r.reverse()
     # start an infinite (wrapping) loop
+    step = 0 # track src/dst step
     while True:
         for z in z_r:   # loop over 1st order dimension
             z_end = z == z_r[-1]
@@ -38,40 +39,30 @@ def iterate_indices(SVSHAPE):
                             vals[SVSHAPE.order[1]],
                             vals[SVSHAPE.order[2]]
                            ]
-                    # some of the dimensions can be "skipped".  the order
-                    # was actually selected above on all 3 dimensions,
-                    # e.g. [z][x][y] or [y][z][x].  "skip" allows one of
-                    # those to be knocked out
-                    if SVSHAPE.skip == 0b00:
-                        select = 0b111
-                    elif SVSHAPE.skip == 0b11:
-                        select = 0b011
-                    elif SVSHAPE.skip == 0b01:
-                        select = 0b110
-                    elif SVSHAPE.skip == 0b10:
-                        select = 0b101
-                    else:
-                        select = 0b111
-                    result = 0
-                    mult = 1
                     # ok now we can construct the result, using bits of
                     # "order" to say which ones get stacked on
+                    result = 0
+                    mult = 1
                     for i in range(3):
                         lim, idx, dbg = vals[i]
-                        if select & (1<<i):
-                            #print ("select %d %s" % (i, dbg))
-                            idx *= mult   # shifts up by previous dimension(s)
-                            result += idx # adds on this dimension
-                            mult *= lim   # for the next dimension
+                        # some of the dimensions can be "skipped".  the order
+                        # was actually selected above on all 3 dimensions,
+                        # e.g. [z][x][y] or [y][z][x].  "skip" allows one of
+                        # those to be knocked out
+                        if SVSHAPE.skip == i+1: continue
+                        #print ("select %d %s" % (i, dbg))
+                        idx *= mult   # shifts up by previous dimension(s)
+                        result += idx # adds on this dimension
+                        mult *= lim   # for the next dimension
 
                     loopends = (x_end |
                                ((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)
+                        result = SVSHAPE.postprocess(result, step)
                     yield result + SVSHAPE.offset, loopends
-
+                    step += 1
 def demo():
     # set the dimension sizes here
     xdim = 3