From: Dmitry Selyutin Date: Sun, 14 Jan 2024 13:22:34 +0000 (+0300) Subject: oppc/code: support ternary expr inside binary and unary X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3bee8dd761bbd80e19b4c53750dd173c98b3a31;p=openpower-isa.git oppc/code: support ternary expr inside binary and unary --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index f713e55b..d18bd140 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -149,6 +149,11 @@ class CodeVisitor(pc_util.Visitor): pc_ast.Eq, pc_ast.NotEq, pc_ast.Ge, pc_ast.Gt, ) + if isinstance(node.left, pc_ast.IfExpr): + self.ternary(node=node.left) + if isinstance(node.right, pc_ast.IfExpr): + self.ternary(node=node.right) + if isinstance(node.op, comparison): ccall = self.ccall(name=str(self[node.op]), node=node, code=[ self[node.left], @@ -168,6 +173,8 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.UnaryExpr) def UnaryExpr(self, node): yield node + if isinstance(node.value, pc_ast.IfExpr): + self.ternary(node=node.value) ccall = self.ccall(name=str(self[node.op]), node=node, code=[ self[node.value], ])