power_insn: migrate to new byteorder class
authorDmitry Selyutin <ghostmansd@gmail.com>
Wed, 10 May 2023 17:52:32 +0000 (17:52 +0000)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 13 May 2023 18:37:22 +0000 (18:37 +0000)
src/openpower/decoder/power_insn.py

index 1efa16e76e73fb39a88cf6c1a32794ecf39fb114..6a34ccc44c090e0eba4c29f768f30faf27efc398 100644 (file)
@@ -1643,14 +1643,14 @@ class DOperandDX(SignedOperand):
 
 class Instruction(_Mapping):
     @classmethod
-    def integer(cls, value=0, bits=None, byteorder="little"):
+    def integer(cls, value=0, bits=None, byteorder=ByteOrder.LITTLE):
         if isinstance(value, (int, bytes)) and not isinstance(bits, int):
             raise ValueError(bits)
 
         if isinstance(value, bytes):
             if ((len(value) * 8) != bits):
                 raise ValueError(f"bit length mismatch")
-            value = int.from_bytes(value, byteorder=byteorder)
+            value = int.from_bytes(value, byteorder=str(byteorder))
 
         if isinstance(value, int):
             value = _SelectableInt(value=value, bits=bits)
@@ -1677,9 +1677,9 @@ class Instruction(_Mapping):
     def __setitem__(self, key, value):
         return self.storage.__setitem__(key, value)
 
-    def bytes(self, byteorder="little"):
+    def bytes(self, byteorder=ByteOrder.LITTLE):
         nr_bytes = (len(self.__class__) // 8)
-        return int(self).to_bytes(nr_bytes, byteorder=byteorder)
+        return int(self).to_bytes(nr_bytes, byteorder=str(byteorder))
 
     @classmethod
     def record(cls, db, entry):
@@ -1762,7 +1762,7 @@ class Instruction(_Mapping):
         return insn
 
     def disassemble(self, record,
-            byteorder="little",
+            byteorder=ByteOrder.LITTLE,
             style=Style.NORMAL):
         raise NotImplementedError()
 
@@ -1772,7 +1772,7 @@ class WordInstruction(Instruction):
     PO: _Field = range(0, 6)
 
     @classmethod
-    def integer(cls, value, byteorder="little"):
+    def integer(cls, value, byteorder=ByteOrder.LITTLE):
         return super().integer(bits=32, value=value, byteorder=byteorder)
 
     @property
@@ -1784,7 +1784,7 @@ class WordInstruction(Instruction):
         return "".join(map(str, bits))
 
     def disassemble(self, record,
-            byteorder="little",
+            byteorder=ByteOrder.LITTLE,
             style=Style.NORMAL):
         if style <= Style.SHORT:
             blob = ""
@@ -1851,11 +1851,11 @@ class PrefixedInstruction(Instruction):
     PO: Suffix.PO
 
     @classmethod
-    def integer(cls, value, byteorder="little"):
+    def integer(cls, value, byteorder=ByteOrder.LITTLE):
         return super().integer(bits=64, value=value, byteorder=byteorder)
 
     @classmethod
-    def pair(cls, prefix=0, suffix=0, byteorder="little"):
+    def pair(cls, prefix=0, suffix=0, byteorder=ByteOrder.LITTLE):
         def transform(value):
             return WordInstruction.integer(value=value,
                 byteorder=byteorder)[0:32]
@@ -3375,7 +3375,7 @@ class SVP64Instruction(PrefixedInstruction):
         return insn
 
     def disassemble(self, record,
-            byteorder="little",
+            byteorder=ByteOrder.LITTLE,
             style=Style.NORMAL):
         def blob(insn):
             if style <= Style.SHORT: