add comments into CR5Operand class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 11 Sep 2022 09:54:24 +0000 (10:54 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 11 Sep 2022 09:54:24 +0000 (10:54 +0100)
src/openpower/decoder/power_insn.py

index 63db6856844ea016a89b3953c2a69e887e9496bd..994319bbb37b3a6e5ee0433824005ad03e712343 100644 (file)
@@ -724,29 +724,31 @@ class CR3Operand(RegisterOperand):
 class CR5Operand(RegisterOperand):
     def spec(self, insn, record):
         def merge(vector, value, span, spec, spec_span):
+            # this is silly these should be in a general base class,
+            # settable by constructor
+            sshift = 3 # len(value) aka value.bits
+            vshift = 4 # 7-sshift
+            spshft = 2 # 5-sshift
+            spmask = (1<<spshft)-1
             # record the 2 lsbs first
-            lsbs = _SelectableInt(value=value.value&3, bits=2)
+            lsbs = _SelectableInt(value=value.value&(spmask), bits=spshft)
             bits = (len(span) + len(spec_span))
             #print ("value", bin(value.value), value.bits)
-            value = _SelectableInt(value=value.value>>2, bits=bits)
+            value = _SelectableInt(value=value.value>>spshft, bits=bits)
             spec = _SelectableInt(value=spec.value, bits=bits)
             #print ("spec", bin(spec.value), spec.bits)
             #print ("value", bin(value.value), value.bits)
             #print ("lsbs", bin(lsbs.value), lsbs.bits)
-            # this is silly these should be in a general base class,
-            # settable by constructor
-            vshift = 4
-            sshift = 3
-            spshft = 2
             if vector:
                 value = ((value << vshift) | (spec<<spshft))
-                span = (span[0:3] + spec_span + ('{0}', '{0}') + span[3:5])
+                span = (span[0:3] + spec_span + spshft*('{0}',) + span[3:5])
             else:
                 value = ((spec << sshift) | value)
-                span = (('{0}', '{0}') + spec_span + span)
+                span = (spshft*('{0}',) + spec_span + span)
 
             # add the 2 LSBs back in
-            res = _SelectableInt(value=(value.value<<2)+lsbs.value, bits=bits+2)
+            v = (value.value<<spshft)+lsbs.value
+            res = _SelectableInt(value=v, bits=bits+spshft)
             #print ("after", bin(value.value), value.bits)
             #print ("res", bin(res.value), res.bits)
             return (res, span)