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>
Fri, 8 Sep 2023 17:44:27 +0000 (20:44 +0300)
src/libsvp64/codegen.py

index c916ff3a7494281a195f17d3ff50d93f4c50ffd8..f6d16307b500c76c7c2b3f4b718b5f2dbeb87289 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.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("")