power_insn: support int and index opcode methods
authorDmitry Selyutin <ghostmansd@gmail.com>
Thu, 27 Apr 2023 19:08:39 +0000 (22:08 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 30 Apr 2023 18:38:53 +0000 (21:38 +0300)
src/openpower/decoder/power_insn.py

index 483b7ac52c8a223aa4842f002b39a725cd0ebd1a..b27fdb9f0d5c09123e1ec44a591a0b926aeb9ed0 100644 (file)
@@ -155,6 +155,12 @@ class Opcode:
             return NotImplemented
         return ((self.value, self.mask) < (other.value, other.mask))
 
+    def __int__(self):
+        return (self.value & self.mask)
+
+    def __index__(self):
+        return int(self).__index__()
+
     def __repr__(self):
         def pattern(value, mask, bit_length):
             for bit in range(bit_length):