From 460c71f9bc6b68a82f407f76898a082273ac7e13 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Fri, 12 Jan 2024 22:24:22 +0300 Subject: [PATCH] oppc/code: support binary mul/div/mod --- src/openpower/oppc/pc_code.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.30.2