oppc/code: support GRP0
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 14 Jan 2024 20:17:22 +0000 (23:17 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index 47aded9d974929fecb1ec71805c02684b7def067..293a7d64da354ac5db94c0e33851803f3e2ebac7 100644 (file)
@@ -389,6 +389,19 @@ class CodeVisitor(pc_util.Visitor):
         with self.pseudocode(node=node):
             self[node].emit(stmt=f"&OPPC_GPR[OPPC_GPR_{str(node)}]")
 
+    @pc_util.Hook(pc_ast.GPRZero)
+    def GPRZero(self, node):
+        yield node
+        name = str(node)
+        test = pc_ast.Symbol(name)
+        body = pc_ast.Scope([pc_ast.GPR(name)])
+        orelse = pc_ast.Scope([Transient()])
+        ifexpr = pc_ast.IfExpr(test=test, body=body, orelse=orelse)
+        self.traverse(root=ifexpr)
+        self.fixup_ternary(node=ifexpr)
+        for (level, stmt) in self[ifexpr]:
+            self[node].emit(stmt=stmt, level=level)
+
     @pc_util.Hook(pc_ast.FPR)
     def FPR(self, node):
         yield node