power_insn: support instruction bytes conversion
authorDmitry Selyutin <ghostmansd@gmail.com>
Wed, 14 Sep 2022 23:04:12 +0000 (02:04 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 15 Sep 2022 20:54:31 +0000 (21:54 +0100)
src/openpower/decoder/power_insn.py

index c57ec57ac3ee53bea3b09deb4ce9179a7e350d51..c6bb65d8dc5a7308e46895eb56125ffa9e3bdb6f 100644 (file)
@@ -1064,6 +1064,10 @@ class Instruction(_Mapping):
     def __setitem__(self, key, value):
         return self.storage.__setitem__(key, value)
 
+    def bytes(self, byteorder="little"):
+        nr_bytes = (self.storage.bits // 8)
+        return int(self).to_bytes(nr_bytes, byteorder=byteorder)
+
     def record(self, db):
         record = db[self]
         if record is None: