From: Dmitry Selyutin Date: Tue, 16 Jan 2024 19:09:45 +0000 (+0300) Subject: oppc/code: refactor declarations order X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3ca3e42b7f85bca642c86aecfa93a8af377d930;p=openpower-isa.git oppc/code: refactor declarations order --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 123d65b3..f6d7b908 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -39,7 +39,7 @@ class CodeVisitor(pc_util.Visitor): self.__root = root self.__insn = insn - self.__decls = set() + self.__vars = set() self.__header = object() self.__footer = object() self.__code = collections.defaultdict(lambda: pc_util.Code()) @@ -49,11 +49,11 @@ class CodeVisitor(pc_util.Visitor): super().__init__(root=root) - for decl in (operand.name for operand in insn.dynamic_operands): - if decl not in self.__decls: - self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};") - for decl in sorted(self.__decls): - self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};") + operands = tuple(operand.name for operand in insn.dynamic_operands) + for var in operands: + self.__code[self.__header].emit(stmt=f"struct oppc_value {var};") + for var in filter(lambda var: var not in operands, sorted(self.__vars)): + self.__code[self.__header].emit(stmt=f"struct oppc_value {var};") self.__code[self.__header].emit() for operand in insn.dynamic_operands: @@ -643,14 +643,14 @@ class CodeVisitor(pc_util.Visitor): def Symbol(self, node): yield node with self.pseudocode(node=node): - decl = str(node) - if decl not in ("fallthrough",): - if decl in ("TRAP",): - self[node].emit(stmt=f"OPPC_CALL_{decl}();") + var = str(node) + if var not in ("fallthrough",): + if var in ("TRAP",): + self[node].emit(stmt=f"OPPC_CALL_{var}();") else: if node in self.__pseudocode: - self.__decls.add(decl) - self[node].emit(stmt=f"&{decl}") + self.__vars.add(var) + self[node].emit(stmt=f"&{var}") @pc_util.Hook(Instruction) def Instruction(self, node):