From: Dmitry Selyutin Date: Sun, 14 Jan 2024 14:19:58 +0000 (+0300) Subject: oppc/code: fix if exprs check X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ee7df7eae56bb7b577d8c13b56182b8f7338ea2;p=openpower-isa.git oppc/code: fix if exprs check --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index de0150f4..28dfb34a 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -77,9 +77,12 @@ class CodeVisitor(pc_util.Visitor): def ternary(self, node): self[node].clear() + test = self.ccall(name="oppc_bool", node=node, code=[ + self[node.test], + ]) self[node].emit(stmt="(") with self[node]: - for (level, stmt) in self[node.test]: + for (level, stmt) in self[test]: self[node].emit(stmt=stmt, level=level) self[node].emit(stmt="?") for (level, stmt) in self[node.body]: @@ -400,9 +403,12 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.IfExpr) def IfExpr(self, node): yield node + test = self.ccall(name="oppc_bool", node=node, code=[ + self[node.test], + ]) self[node].emit(stmt="if (") with self[node]: - for (level, stmt) in self[node.test]: + for (level, stmt) in self[test]: self[node].emit(stmt=stmt, level=level) self[node].emit(stmt=") {") for (level, stmt) in self[node.body]: