From: Dmitry Selyutin Date: Fri, 12 Jan 2024 20:07:18 +0000 (+0300) Subject: oppc/code: support for exprs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7bf27de1919581843bab03d0b551fd4c51da15d6;p=openpower-isa.git oppc/code: support for exprs --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 69dfad85..a1cd4314 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -189,6 +189,17 @@ class CodeVisitor(pc_util.Visitor): subject = str(self[node.subject]) self[node].emit(f"oppc_range_subscript({subject}, {start}, {end})") + @pc_util.Hook(pc_ast.ForExpr) + def ForExpr(self, node): + yield node + subject = str(self[node.subject]) + start = str(self[node.start]) + end = str(self[node.end]) + self[node].emit(f"for ({subject} = {start}; {subject} != ({end} + 1); ++{subject}) {{") + for (level, stmt) in self[node.body]: + self[node].emit(stmt=stmt, level=level) + self[node].emit(f"}}") + @pc_util.Hook(pc_ast.Call.Name) def CallName(self, node): yield node