oppc/code: do not emit pseudocode unless necessary
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:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index 04dcf23630605cfc00dabf232a76364a2564ff3a..bf15f57f2e24f747e7946985dc4df0b97ab83177 100644 (file)
@@ -172,8 +172,9 @@ class CodeVisitor(pc_util.Visitor):
 
     @contextlib.contextmanager
     def pseudocode(self, node):
-        for (level, stmt) in self.__pseudocode[node]:
-            self[node].emit(stmt=f"/* {stmt} */", level=level)
+        if node in self.__pseudocode:
+            for (level, stmt) in self.__pseudocode[node]:
+                self[node].emit(stmt=f"/* {stmt} */", level=level)
         yield
 
     @pc_util.Hook(pc_ast.Scope)