rename/convert/merge XLCASTU/XLCASTS to EXTZXL/EXTSXL change-xlenification-bug-1064
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 21 Apr 2023 03:23:48 +0000 (20:23 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 21 Apr 2023 03:23:48 +0000 (20:23 -0700)
src/openpower/decoder/helpers.py

index 76dad8a2efbf614d8b82e35be8ad083006fd5f48..3f8845bf04c9cee1a83e78d14fa9d1ee376d56f7 100644 (file)
@@ -818,21 +818,21 @@ class ISACallerHelper:
     def XLEN(self):
         return self.__XLEN
 
-    def XLCASTS(self, value):
-        if isinstance(value, SelectableInt):
-            value = value.value
-        return SelectableInt(exts(value, self.XLEN), self.XLEN)
-
-    def XLCASTU(self, value):
+    def EXTZXL(self, value, bits=None):
+        if bits is None:
+            bits = self.XLEN
+        elif isinstance(bits, SelectableInt):
+            bits = bits.value
         if isinstance(value, SelectableInt):
             value = value.value
-        # SelectableInt already takes care of masking out the bits
-        return SelectableInt(value, self.XLEN)
+        return SelectableInt(value & ((1 << bits) - 1), self.XLEN)
 
-    def EXTSXL(self, value, bits):
+    def EXTSXL(self, value, bits=None):
         if isinstance(value, SelectableInt):
             value = value.value
-        if isinstance(bits, SelectableInt):
+        if bits is None:
+            bits = self.XLEN
+        elif isinstance(bits, SelectableInt):
             bits = bits.value
         return SelectableInt(exts(value, bits), self.XLEN)