From: Dmitry Selyutin Date: Fri, 12 Jan 2024 19:47:48 +0000 (+0300) Subject: oppc/code: support subscript assignments X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c5d0d6ab03582bf78d37665f646f5661a9a3d9b4;p=openpower-isa.git oppc/code: support subscript assignments --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 78d3ce55..c7205946 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -47,12 +47,33 @@ class CodeVisitor(pc_util.Visitor): if isinstance(node.rvalue, (pc_ast.GPR, pc_ast.FPR)): self.__regfetch[str(node.rvalue)].append(node.rvalue) - stmt = " ".join([ - str(self[node.lvalue]), - "=", - str(self[node.rvalue]), - ]) - self[node].emit(stmt=f"{stmt};") + if isinstance(node.lvalue, pc_ast.SubscriptExpr): + index = str(self[node.lvalue.index]) + subject = str(self[node.lvalue.subject]) + args = ", ".join([ + f"&{subject}", + index, + str(self[node.rvalue]), + ]) + self[node].emit(f"oppc_subscript_assign({args});") + elif isinstance(node.lvalue, pc_ast.RangeSubscriptExpr): + start = str(self[node.lvalue.start]) + end = str(self[node.lvalue.end]) + subject = str(self[node.lvalue.subject]) + args = ", ".join([ + f"&{subject}", + start, + end, + str(self[node.rvalue]), + ]) + self[node].emit(f"oppc_range_subscript_assign({args});") + else: + stmt = " ".join([ + str(self[node.lvalue]), + "=", + str(self[node.rvalue]), + ]) + self[node].emit(stmt=f"{stmt};") @pc_util.Hook(pc_ast.BinaryExpr) def BinaryExpr(self, node):