From 91159f431d52604e510ad18af899526bb23ae87c Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 7 Sep 2023 22:57:39 +0300 Subject: [PATCH] libsvp64: refactor operands generation --- src/libsvp64/codegen.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libsvp64/codegen.py b/src/libsvp64/codegen.py index 3fc550d6..8508bdca 100644 --- a/src/libsvp64/codegen.py +++ b/src/libsvp64/codegen.py @@ -320,17 +320,23 @@ class DisGenSource(Source): yield from generic_handler(span, "SVP64_OPERAND_CR5") handlers = { - insndb.SignedOperand: signed_handler, - insndb.GPROperand: gpr_handler, - insndb.GPROperand: fpr_handler, insndb.GPRPairOperand: lambda span: gpr_handler(span, True), insndb.FPRPairOperand: lambda span: fpr_handler(span, True), + insndb.GPROperand: gpr_handler, + insndb.GPROperand: fpr_handler, insndb.CR3Operand: cr3_handler, insndb.CR5Operand: cr5_handler, + insndb.SignedOperand: signed_handler, + insndb.DynamicOperand: generic_handler, + object: None, } self.emit(f"case 0x{(path + 1):02x}: /* {', '.join(node.names)} */") with self: - handler = handlers.get(node.cls, generic_handler) + for (cls, handler) in handlers.items(): + if issubclass(node.cls, cls): + break + if handler is None: + raise ValueError("unknown handler") for line in handler(span=node.span): self.emit(line) self.emit("") -- 2.30.2