From 4f88279d7597420337a41aa58a2bd6c5d12dbcd3 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 4 Sep 2022 20:36:16 +0300 Subject: [PATCH] power_insn: decouple mode function --- src/openpower/decoder/power_insn.py | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 4c0ac759..cb08b1df 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -1140,28 +1140,14 @@ class SVP64Instruction(PrefixedInstruction): def mask(self, db): return self.suffix.mask(db=db) - def disassemble(self, db, byteorder="little", verbose=False): - integer_prefix = int(self.prefix) - blob_prefix = integer_prefix.to_bytes(length=4, byteorder=byteorder) - blob_prefix = " ".join(map(lambda byte: f"{byte:02x}", blob_prefix)) - - integer_suffix = int(self.suffix) - blob_suffix = integer_suffix.to_bytes(length=4, byteorder=byteorder) - blob_suffix = " ".join(map(lambda byte: f"{byte:02x}", blob_suffix)) - + def mode(self, db): record = self.record(db=db) - if record is None or record.svp64 is None: - yield f"{blob_prefix} .long 0x{int(self.prefix):08x}" - yield f"{blob_suffix} .long 0x{int(self.suffix):08x}" - return - - yield f"{blob_prefix} sv.{record.name}" - yield f"{blob_suffix}" Rc = False if record.operands["Rc"] is not None: Rc = bool(self[record.fields["Rc"]]) + record = self.record(db=db) subvl = self.prefix.rm.subvl mode = self.prefix.rm.mode sel = mode.sel @@ -1236,6 +1222,26 @@ class SVP64Instruction(PrefixedInstruction): if type(mode) is Mode: raise NotImplementedError + return mode + + def disassemble(self, db, byteorder="little", verbose=False): + integer_prefix = int(self.prefix) + blob_prefix = integer_prefix.to_bytes(length=4, byteorder=byteorder) + blob_prefix = " ".join(map(lambda byte: f"{byte:02x}", blob_prefix)) + + integer_suffix = int(self.suffix) + blob_suffix = integer_suffix.to_bytes(length=4, byteorder=byteorder) + blob_suffix = " ".join(map(lambda byte: f"{byte:02x}", blob_suffix)) + + record = self.record(db=db) + if record is None or record.svp64 is None: + yield f"{blob_prefix} .long 0x{int(self.prefix):08x}" + yield f"{blob_suffix} .long 0x{int(self.suffix):08x}" + return + + yield f"{blob_prefix} sv.{record.name}" + yield f"{blob_suffix}" + if verbose: indent = (" " * 4) binary = self.binary -- 2.30.2