oppc/code: support calls
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 12 Jan 2024 19:52:30 +0000 (22:52 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index c72059466c1f48a00cf4317bf379948cfa4ee1d4..69dfad8524fa4fb6c58fbb417530424e07389296 100644 (file)
@@ -192,6 +192,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.Call.Name)
     def CallName(self, node):
         yield node
+        self[node].emit(stmt=str(node))
 
     @pc_util.Hook(pc_ast.Call.Arguments)
     def CallArguments(self, node):
@@ -199,6 +200,16 @@ class CodeVisitor(pc_util.Visitor):
         for subnode in node:
             if isinstance(subnode, (pc_ast.GPR, pc_ast.FPR)):
                 self.__regfetch[str(subnode)].append(subnode)
+        stmt = ", ".join(map(lambda subnode: str(self[subnode]), node))
+        self[node].emit(stmt=stmt)
+
+    @pc_util.Hook(pc_ast.Call)
+    def Call(self, node):
+        yield node
+        name = str(self[node.name])
+        args = str(self[node.args])
+        stmt = f"{name}({args})"
+        self[node].emit(stmt=stmt)
 
     @pc_util.Hook(pc_ast.Symbol)
     def Symbol(self, node):