oppc/code: drop explicit ctx argument
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 14 Jan 2024 12:30:42 +0000 (15:30 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000 (22:10 +0300)
src/openpower/oppc/pc_code.py

index f351f5b825678fc4632807e01c13ad0abdf19cff..1b66a1ca1e027505faaedf1382ffd09441907ead 100644 (file)
@@ -7,7 +7,7 @@ import openpower.oppc.pc_pseudocode as pc_pseudocode
 
 
 class Transient(pc_ast.Node):
-    def __init__(self, value="UINT64_C(0)", bits="(uint8_t)ctx->XLEN"):
+    def __init__(self, value="UINT64_C(0)", bits="(uint8_t)OPPC_XLEN"):
         self.__value = value
         self.__bits = bits
 
@@ -51,7 +51,7 @@ class CodeVisitor(pc_util.Visitor):
     def __getitem__(self, node):
         return self.__code[node]
 
-    def transient(self, node, value="UINT64_C(0)", bits="(uint8_t)ctx->XLEN"):
+    def transient(self, node, value="UINT64_C(0)", bits="(uint8_t)OPPC_XLEN"):
         transient = Transient(value=value, bits=bits)
         with self.pseudocode(node=node):
             self.traverse(root=transient)
@@ -209,7 +209,7 @@ class CodeVisitor(pc_util.Visitor):
             bits = f"UINT8_C({str(len(value[2:]) * 4)})"
             value = int(value, 16)
         else:
-            bits = "ctx->XLEN"
+            bits = "(uint8_t)OPPC_XLEN"
             value = int(value)
             fmt = str
         if (value > ((2**64) - 1)):
@@ -251,13 +251,13 @@ class CodeVisitor(pc_util.Visitor):
     def GPR(self, node):
         yield node
         with self.pseudocode(node=node):
-            self[node].emit(stmt=f"&ctx->gpr[OPPC_GPR_{str(node)}]")
+            self[node].emit(stmt=f"&OPPC_GPR[OPPC_GPR_{str(node)}]")
 
     @pc_util.Hook(pc_ast.FPR)
     def FPR(self, node):
         yield node
         with self.pseudocode(node=node):
-            self[node].emit(stmt=f"&ctx->fpr[OPPC_FPR_{str(node)}]")
+            self[node].emit(stmt=f"&OPPC_FPR[OPPC_FPR_{str(node)}]")
 
     @pc_util.Hook(pc_ast.RepeatExpr)
     def RepeatExpr(self, node):
@@ -274,7 +274,7 @@ class CodeVisitor(pc_util.Visitor):
     @pc_util.Hook(pc_ast.XLEN)
     def XLEN(self, node):
         yield node
-        (value, bits) = ("ctx->XLEN", "(uint8_t)ctx->XLEN")
+        (value, bits) = ("OPPC_XLEN", "(uint8_t)OPPC_XLEN")
         transient = self.transient(node=node, value=value, bits=bits)
         for (level, stmt) in self[transient]:
             self[node].emit(stmt=stmt, level=level)