From: Dmitry Selyutin Date: Fri, 12 Jan 2024 19:24:22 +0000 (+0300) Subject: oppc/code: support binary mul/div/mod X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=03b4b33cfe7d66060db38e16e0cd12abb8cf2d91;p=openpower-isa.git oppc/code: support binary mul/div/mod --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 4e985048..cb7260ee 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -70,11 +70,15 @@ class CodeVisitor(pc_util.Visitor): 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)): + if isinstance(node.op, (pc_ast.Add, pc_ast.Sub, + pc_ast.Mul, pc_ast.Div, pc_ast.Mod)): op = { pc_ast.Not: "~", pc_ast.Add: "+", pc_ast.Sub: "-", + pc_ast.Mul: "*", + pc_ast.Div: "/", + pc_ast.Mod: "%", }[node.op.__class__] stmt = " ".join([left, op, right]) self[node].emit(stmt=f"({stmt})") @@ -98,7 +102,8 @@ class CodeVisitor(pc_util.Visitor): else: raise ValueError(node) - @pc_util.Hook(pc_ast.Not, pc_ast.Add, pc_ast.Sub) + @pc_util.Hook(pc_ast.Not, pc_ast.Add, pc_ast.Sub, + pc_ast.Mul, pc_ast.Div, pc_ast.Mod) def Op(self, node): yield node