import collections
import contextlib
+import operator
import openpower.oppc.pc_ast as pc_ast
import openpower.oppc.pc_util as pc_util
import openpower.oppc.pc_pseudocode as pc_pseudocode
+from openpower.insndb.core import DynamicOperand
class Transient(pc_ast.Node):
super().__init__(root=root)
- for decl in self.__decls:
+ 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};")
- decls = sorted(filter(lambda decl: decl in insn.fields, self.__decls))
- if decls:
- self.__code[self.__header].emit()
- for decl in decls:
- bits = f"{len(insn.fields[decl])}"
+ self.__code[self.__header].emit()
+
+ for operand in insn.dynamic_operands:
+ bits = f"{len(operand.span)}"
transient = Transient(bits=bits)
- symbol = pc_ast.Symbol(decl)
+ symbol = pc_ast.Symbol(operand.name)
assign = pc_ast.AssignExpr(lvalue=symbol, rvalue=transient)
self.traverse(root=assign)
for (level, stmt) in self[assign]:
self[self.__header].emit(stmt=stmt, level=level)
- for (lbit, rbit) in enumerate(insn.fields[decl]):
- lsymbol = pc_ast.Symbol(decl)
+
+ for (lbit, rbit) in enumerate(operand.span):
+ lsymbol = pc_ast.Symbol(operand.name)
rsymbol = Instruction()
lindex = Transient(value=str(lbit))
rindex = Transient(value=str(rbit))
for (level, stmt) in self[assign]:
self[self.__header].emit(stmt=stmt, level=level)
self.__code[self.__header].emit()
- if decls:
- self.__code[self.__header].emit()
def __iter__(self):
yield from self[self.__header]