power_insn: simplify word instruction assembly
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 6 Nov 2022 09:29:55 +0000 (12:29 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 15 Jan 2023 19:47:22 +0000 (22:47 +0300)
src/openpower/decoder/power_insn.py

index 5deefbc973e4a1d0c8838257efcabd6b1b3af0e5..09b4d0a26c663304a7a5e13ea3b196ea42edc2c6 100644 (file)
@@ -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