From: Dmitry Selyutin Date: Thu, 7 Sep 2023 19:57:39 +0000 (+0300) Subject: libsvp64: refactor operands generation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=90a4941b823d8b11a2a330b483bd19b0b9adb06e;p=openpower-isa.git libsvp64: refactor operands generation --- diff --git a/src/libsvp64/codegen.py b/src/libsvp64/codegen.py index c916ff3a..f6d16307 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.FPROperand: fpr_handler, insndb.GPRPairOperand: lambda span: gpr_handler(span, True), insndb.FPRPairOperand: lambda span: fpr_handler(span, True), + insndb.GPROperand: gpr_handler, + insndb.FPROperand: 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("")