From f8da85b83b63d76fb53cc5bb415764b5377c7770 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 6 Nov 2022 12:29:55 +0300 Subject: [PATCH] power_insn: simplify word instruction assembly --- src/openpower/decoder/power_insn.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 5deefbc9..09b4d0a2 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -1315,20 +1315,15 @@ class WordInstruction(Instruction): @classmethod def assemble(cls, db, opcode, arguments): - value = 0 - mask = 0 record = db[opcode] - for opcode in record.opcodes: - value |= int(opcode.value) - mask |= int(opcode.mask) - insn = cls.integer(value=(value & mask)) + insn = cls.integer(value=0) + for operand in record.static_operands: + operand.assemble(insn=insn, record=record) - operands = tuple(record.mdwn.operands.dynamic) - if len(operands) != len(arguments): + dynamic_operands = tuple(record.dynamic_operands) + if len(dynamic_operands) != len(arguments): raise ValueError("operands count mismatch") - for (index, (cls, kwargs)) in enumerate(operands): - operand = cls(record=record, **kwargs) - value = arguments[index] + for (value, operand) in zip(arguments, dynamic_operands): operand.assemble(value=value, insn=insn, record=record) return insn -- 2.30.2