From: Dmitry Selyutin Date: Fri, 12 Jan 2024 19:24:22 +0000 (+0300) Subject: oppc/code: support binary add/sub X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a6a3781e0655e636f9fd09478429f91678556ae;p=openpower-isa.git oppc/code: support binary add/sub --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 2f7e0b5d..4e985048 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -62,6 +62,24 @@ class CodeVisitor(pc_util.Visitor): self.__regfetch[str(node.left)].append(node.left) if isinstance(node.right, (pc_ast.GPR, pc_ast.FPR)): self.__regfetch[str(node.right)].append(node.left) + if isinstance(node.left, (pc_ast.GPR, pc_ast.FPR)): + left = f"oppc_reg_fetch({str(self[node.left])})" + else: + left = str(self[node.left]) + if isinstance(node.right, (pc_ast.GPR, pc_ast.FPR)): + right = f"oppc_reg_fetch({str(self[node.right])})" + else: + right = str(self[node.right]) + if isinstance(node.op, (pc_ast.Add, pc_ast.Sub)): + op = { + pc_ast.Not: "~", + pc_ast.Add: "+", + pc_ast.Sub: "-", + }[node.op.__class__] + stmt = " ".join([left, op, right]) + self[node].emit(stmt=f"({stmt})") + else: + raise ValueError(node) @pc_util.Hook(pc_ast.UnaryExpr) def UnaryExpr(self, node):