From 0399a3143a470010289d4830825eb298d5487ec2 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 14 Jan 2024 22:13:03 +0300 Subject: [PATCH] oppc/code: deprecate redundant node arguments --- src/openpower/oppc/pc_code.py | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 939bcae8..d4086483 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -56,14 +56,14 @@ class CodeVisitor(pc_util.Visitor): def __setitem__(self, node, code): self.__code[node] = code - def transient(self, node, + def transient(self, value="UINT64_C(0)", bits="(uint8_t)OPPC_XLEN"): transient = Transient(value=value, bits=bits) self.traverse(root=transient) return transient - def call(self, node, name, code, stmt=False): + def call(self, name, code, stmt=False): def validate(item): def validate(item): (level, stmt) = item @@ -82,7 +82,7 @@ class CodeVisitor(pc_util.Visitor): def fixup_ternary(self, node): self[node].clear() - test = self.call(name="oppc_bool", node=node, code=[ + test = self.call(name="oppc_bool", code=[ self[node.test], ]) self[node].emit(stmt="(") @@ -130,7 +130,7 @@ class CodeVisitor(pc_util.Visitor): code[-1] = (level, stmt[:-1]) if not assign: - call = self.call(name="oppc_attr", node=root, code=[ + call = self.call(name="oppc_attr", code=[ code, ]) code = self[call] @@ -181,25 +181,25 @@ class CodeVisitor(pc_util.Visitor): return if isinstance(node.lvalue, pc_ast.SubscriptExpr): - call = self.call(name="oppc_subscript_assign", node=node, stmt=True, code=[ + call = self.call(name="oppc_subscript_assign", stmt=True, code=[ self[node.lvalue.subject], self[node.lvalue.index], self[node.rvalue], ]) elif isinstance(node.lvalue, pc_ast.RangeSubscriptExpr): - call = self.call(name="oppc_range_subscript_assign", node=node, stmt=True, code=[ + call = self.call(name="oppc_range_subscript_assign", stmt=True, code=[ self[node.lvalue.subject], self[node.lvalue.start], self[node.lvalue.end], self[node.rvalue], ]) elif isinstance(node.lvalue, pc_ast.Attribute): - call = self.call(name="oppc_attr_assign", stmt=True, node=node, code=[ + call = self.call(name="oppc_attr_assign", stmt=True, code=[ self[node.lvalue], self[node.rvalue], ]) else: - call = self.call(name="oppc_assign", stmt=True, node=node, code=[ + call = self.call(name="oppc_assign", stmt=True, code=[ self[node.lvalue], self[node.rvalue], ]) @@ -231,13 +231,13 @@ class CodeVisitor(pc_util.Visitor): self.fixup_attr(node=node.right) if isinstance(node.op, comparison): - call = self.call(name=str(self[node.op]), node=node, code=[ + call = self.call(name=str(self[node.op]), code=[ self[node.left], self[node.right], ]) else: - transient = self.transient(node=node) - call = self.call(name=str(self[node.op]), node=node, code=[ + transient = self.transient() + call = self.call(name=str(self[node.op]), code=[ self[transient], self[node.left], self[node.right], @@ -251,7 +251,7 @@ class CodeVisitor(pc_util.Visitor): yield node if isinstance(node.value, pc_ast.IfExpr): self.fixup_ternary(node=node.value) - call = self.call(name=str(self[node.op]), node=node, code=[ + call = self.call(name=str(self[node.op]), code=[ self[node.value], ]) with self.pseudocode(node=node): @@ -319,7 +319,7 @@ class CodeVisitor(pc_util.Visitor): if (value > ((2**64) - 1)): raise NotImplementedError() value = f"UINT64_C({fmt(value)})" - transient = self.transient(node=node, value=value, bits=bits) + transient = self.transient(value=value, bits=bits) with self.pseudocode(node=node): for (level, stmt) in self[transient]: self[node].emit(stmt=stmt, level=level) @@ -367,8 +367,8 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.RepeatExpr) def RepeatExpr(self, node): yield node - transient = self.transient(node=node) - call = self.call(name="oppc_repeat", node=node, code=[ + transient = self.transient() + call = self.call(name="oppc_repeat", code=[ self[transient], self[node.subject], self[node.times], @@ -380,7 +380,7 @@ class CodeVisitor(pc_util.Visitor): def XLEN(self, node): yield node (value, bits) = ("OPPC_XLEN", "(uint8_t)OPPC_XLEN") - transient = self.transient(node=node, value=value, bits=bits) + transient = self.transient(value=value, bits=bits) with self.pseudocode(node=node): for (level, stmt) in self[transient]: self[node].emit(stmt=stmt, level=level) @@ -395,7 +395,7 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.SubscriptExpr) def SubscriptExpr(self, node): yield node - call = self.call(name="oppc_subscript", node=node, code=[ + call = self.call(name="oppc_subscript", code=[ self[node.subject], self[node.index], ]) @@ -405,7 +405,7 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.RangeSubscriptExpr) def RangeSubscriptExpr(self, node): yield node - call = self.call(name="oppc_subscript", node=node, code=[ + call = self.call(name="oppc_subscript", code=[ self[node.subject], self[node.start], self[node.end], @@ -479,7 +479,7 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.IfExpr) def IfExpr(self, node): yield node - test = self.call(name="oppc_bool", node=node, code=[ + test = self.call(name="oppc_bool", code=[ self[node.test], ]) self[node].emit(stmt="if (") @@ -498,7 +498,7 @@ class CodeVisitor(pc_util.Visitor): @pc_util.Hook(pc_ast.SwitchExpr) def SwitchExpr(self, node): yield node - subject = self.call(name="oppc_int64", node=node, code=[ + subject = self.call(name="oppc_int64", code=[ self[node.subject], ]) self[node].emit(stmt="switch (") @@ -561,7 +561,7 @@ class CodeVisitor(pc_util.Visitor): def Call(self, node): yield node code = tuple(map(lambda arg: self[arg], node.args)) - call = self.call(name=str(node.name), node=node, code=code) + call = self.call(name=str(node.name), code=code) for (level, stmt) in self[call]: self[node].emit(stmt=stmt, level=level) -- 2.30.2