From: Dmitry Selyutin Date: Sun, 14 Jan 2024 18:41:16 +0000 (+0300) Subject: oppc/code: support multiple assignments X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e33289eea5b899fbff1a00e4eb7a92f0d89cc165;p=openpower-isa.git oppc/code: support multiple assignments --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 4a2b4f75..6ac371cb 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -164,6 +164,21 @@ class CodeVisitor(pc_util.Visitor): if isinstance(node.rvalue, pc_ast.Attribute): self.fixup_attr(node=node.rvalue) + if isinstance(node.lvalue, pc_ast.Sequence): + if not isinstance(node.rvalue, pc_ast.Sequence): + raise ValueError(node.rvalue) + if len(node.lvalue) != len(node.rvalue): + raise ValueError(node) + for (lvalue, rvalue) in zip(node.lvalue, node.rvalue): + assign = node.__class__( + lvalue=lvalue.clone(), + rvalue=rvalue.clone(), + ) + self.traverse(root=assign) + for (level, stmt) in self[assign]: + self[node].emit(stmt=stmt, level=level) + return + if isinstance(node.lvalue, pc_ast.SubscriptExpr): call = self.call(name="oppc_subscript_assign", node=node, stmt=True, code=[ self[node.lvalue.subject], @@ -553,6 +568,10 @@ class CodeVisitor(pc_util.Visitor): def AttributeName(self, node): yield node + @pc_util.Hook(pc_ast.Sequence) + def Sequence(self, node): + yield node + @pc_util.Hook(pc_ast.Attribute) def Attribute(self, node): yield node