libsvp64: refactor operands generation
authorDmitry Selyutin <ghostmansd@gmail.com>
Thu, 7 Sep 2023 19:57:39 +0000 (22:57 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Thu, 7 Sep 2023 19:57:39 +0000 (22:57 +0300)
src/libsvp64/codegen.py

index 3fc550d60259a073a1c8136461a1368a571593f9..8508bdca7431f33f1ab3dec0e89919aebf489d39 100644 (file)
@@ -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("")