oppc/code: adopt pseudocode calls to C realities
authorDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:09:45 +0000 (22:09 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:08 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index b8e30ee12e68905538f73c773da1eba09c59dbc6..8e307adfb022ebb96c0ed88a056075293d761a7d 100644 (file)
@@ -608,10 +608,17 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.Call)
     def Call(self, node):
         yield node
-        code = tuple(map(lambda arg: self[arg], node.args))
-        call = self.call(name=str(node.name), code=code)
-        for (level, stmt) in self[call]:
-            self[node].emit(stmt=stmt, level=level)
+        if node.args:
+            transient = self.transient()
+            code = [self[transient]]
+        else:
+            code = []
+        code.extend(map(lambda arg: self[arg], node.args))
+        name = f"OPPC_CALL_{str(node.name)}"
+        with self.pseudocode(node=node):
+            call = self.call(name=name, code=code)
+            for (level, stmt) in self[call]:
+                self[node].emit(stmt=stmt, level=level)
 
     @pc_util.Hook(pc_ast.Attribute.Name)
     def AttributeName(self, node):