From: Dmitry Selyutin Date: Mon, 16 Jan 2023 19:10:44 +0000 (+0300) Subject: power_insn: support legacy style X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=886d5c681f1b529110c6494c4da791f0105aff39;p=openpower-isa.git power_insn: support legacy style --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 5679a880..a87a029f 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -56,6 +56,7 @@ from openpower.decoder.pseudo.pagereader import ISA as _ISA @_functools.total_ordering class Style(_enum.Enum): + LEGACY = _enum.auto() SHORT = _enum.auto() NORMAL = _enum.auto() VERBOSE = _enum.auto() @@ -1729,13 +1730,6 @@ class WordInstruction(Instruction): record = cls.record(db=db, entry=entry) insn = cls.integer(value=0) - opcode = record.section.opcode - if opcode is None: - opcode = record.ppc.opcode - bits = record.section.bitsel - for (src, dst) in enumerate(reversed(bits)): - insn[dst] = ((opcode.value & (1 << src)) != 0) - for (op_cls, op_kwargs) in record.static_operands: operand = op_cls(record=record, **op_kwargs) operand.assemble(insn=insn) @@ -1749,8 +1743,7 @@ class WordInstruction(Instruction): def disassemble(self, db, byteorder="little", - style=Style.NORMAL, - compatibility=False): + style=Style.NORMAL): if style <= Style.SHORT: blob = "" else: @@ -1763,13 +1756,16 @@ class WordInstruction(Instruction): yield f"{blob}.long 0x{int(self):08x}" return - operands = tuple(map(_operator.itemgetter(1), - self.dynamic_operands(db=db, style=style))) - if operands: - operands = ",".join(operands) - yield f"{blob}{record.name} {operands}" + if style <= Style.LEGACY and record.ppc.unofficial: + yield f"{blob}.long 0x{int(self):08x}" else: - yield f"{blob}{record.name}" + operands = tuple(map(_operator.itemgetter(1), + self.dynamic_operands(db=db, style=style))) + if operands: + operands = ",".join(operands) + yield f"{blob}{record.name} {operands}" + else: + yield f"{blob}{record.name}" if style >= Style.VERBOSE: indent = (" " * 4) @@ -3450,11 +3446,13 @@ class SVP64Instruction(PrefixedInstruction): insn.prefix.PO = 0x1 insn.prefix.id = 0x3 + return insn def disassemble(self, db, byteorder="little", style=Style.NORMAL): + def blob(insn): if style <= Style.SHORT: return "" @@ -3488,9 +3486,15 @@ class SVP64Instruction(PrefixedInstruction): if len(operands) > 0: # if any separate with a space operands = (" " + operands) - yield f"{blob_prefix}{name}{specifiers}{operands}" - if blob_suffix: - yield f"{blob_suffix}" + if style <= Style.LEGACY: + yield f"{blob_prefix}.long 0x{int(self.prefix):08x}" + suffix = WordInstruction.integer(value=int(self.suffix)) + yield from suffix.disassemble(db=db, + byteorder=byteorder, style=style) + else: + yield f"{blob_prefix}{name}{specifiers}{operands}" + if blob_suffix: + yield f"{blob_suffix}" if style >= Style.VERBOSE: indent = (" " * 4) diff --git a/src/openpower/sv/trans/pysvp64dis.py b/src/openpower/sv/trans/pysvp64dis.py index 203610a3..eedf7b1e 100644 --- a/src/openpower/sv/trans/pysvp64dis.py +++ b/src/openpower/sv/trans/pysvp64dis.py @@ -72,7 +72,10 @@ def main(): parser.add_argument("-v", "--verbose", dest="style", default=_Style.NORMAL, action="store_const", const=_Style.VERBOSE) - parser.add_argument("-l", "--log", + parser.add_argument("-l", "--legacy", + dest="style", default=_Style.NORMAL, + action="store_const", const=_Style.LEGACY) + parser.add_argument("-L", "--log", action="store_true", default=False) args = dict(vars(parser.parse_args())) diff --git a/src/openpower/sv/trans/svp64.py b/src/openpower/sv/trans/svp64.py index 90063f33..7792a9a3 100644 --- a/src/openpower/sv/trans/svp64.py +++ b/src/openpower/sv/trans/svp64.py @@ -273,12 +273,7 @@ class SVP64Asm: if record is not None: insn = WordInstruction.assemble(db=DB, entry=opcode, arguments=fields) - yield " ".join(( - f".long 0x{int(insn):08X}", - "#", - opcode, - ",".join(fields), - )) + yield from insn.disassemble(db=DB, style=Style.LEGACY) return # identify if is a svp64 mnemonic @@ -305,10 +300,7 @@ class SVP64Asm: entry=v30b_op_orig, arguments=fields, specifiers=opmodes) - prefix = int(insn.prefix) - suffix = int(insn.suffix) - yield f".long 0x{prefix:08X}" - yield from insn.suffix.disassemble(db=DB, style=Style.SHORT) + yield from insn.disassemble(db=DB, style=Style.LEGACY) return # look up the 32-bit op (original, with "." if it has it) @@ -957,12 +949,7 @@ class SVP64Asm: if record is not None: insn = WordInstruction.assemble(db=DB, entry=opcode, arguments=fields) - yield " ".join(( - f".long 0x{int(insn):08X}", - "#", - opcode, - ",".join(fields), - )) + yield from insn.disassemble(db=DB, style=Style.LEGACY) else: if not v30b_op.endswith('.'): v30b_op += rc