From b61d7c0def4be0ccf5b449fce9c365be085d9c7a Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Wed, 10 May 2023 17:52:32 +0000 Subject: [PATCH] power_insn: migrate to new byteorder class --- src/openpower/decoder/power_insn.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 1efa16e7..6a34ccc4 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -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: -- 2.30.2