From: Dmitry Selyutin Date: Thu, 1 Sep 2022 12:32:38 +0000 (+0300) Subject: pysvp64dis: refactor instruction loading X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c9fe2fe97d513d781ebb03fd040aa602d399c20f;p=openpower-isa.git pysvp64dis: refactor instruction loading --- diff --git a/src/openpower/sv/trans/pysvp64dis.py b/src/openpower/sv/trans/pysvp64dis.py index 39d63ef5..98848c66 100644 --- a/src/openpower/sv/trans/pysvp64dis.py +++ b/src/openpower/sv/trans/pysvp64dis.py @@ -25,31 +25,28 @@ def load(ifile, byteorder, **_): byteorder = str(byteorder) while True: - prefix = ifile.read(4) - length = len(prefix) + insn = ifile.read(4) + length = len(insn) if length == 0: return elif length < 4: - raise IOError(prefix) - prefix = _WordInstruction.integer(value=prefix, byteorder=byteorder) - - suffix = ifile.read(4) - length = len(suffix) - if length == 0: - yield prefix - return - elif length < 4: - raise IOError(suffix) - suffix = _WordInstruction.integer(value=suffix, byteorder=byteorder) - - if prefix.po == 0x1: + raise IOError(insn) + insn = _WordInstruction.integer(value=insn, byteorder=byteorder) + if insn.po == 0x1: + suffix = ifile.read(4) + length = len(suffix) + if length == 0: + yield insn + return + elif length < 4: + raise IOError(suffix) + + prefix = insn + suffix = _WordInstruction.integer(value=suffix, byteorder=byteorder) insn = _SVP64Instruction.pair(prefix=prefix, suffix=suffix) if insn.prefix.id != 0b11: insn = _PrefixedInstruction.pair(prefix=prefix, suffix=suffix) - yield insn - else: - yield prefix - yield suffix + yield insn def dump(insns, **_):