From: Dmitry Selyutin Date: Sun, 11 Sep 2022 12:42:20 +0000 (+0300) Subject: power_insn: refactor register operands X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14ec1bc1b6620caa2080aa63308d22023bb5bad0;p=openpower-isa.git power_insn: refactor register operands --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 90aac4d0..9034f37c 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -568,7 +568,13 @@ class NonZeroOperand(DynamicOperand): class RegisterOperand(DynamicOperand): - def spec(self, insn, record, merge): + def sv_spec_enter(self, value, span): + return (value, span) + + def sv_spec_leave(self, value, span, origin_value, origin_span): + return (value, span) + + def spec(self, insn, record): vector = False span = self.span(record=record) if isinstance(insn, SVP64Instruction): @@ -577,6 +583,9 @@ class RegisterOperand(DynamicOperand): span = tuple(map(str, span)) if isinstance(insn, SVP64Instruction): + (origin_value, origin_span) = (value, span) + (value, span) = self.sv_spec_enter(value=value, span=span) + extra_idx = self.extra_idx(record=record) if extra_idx is _SVExtra.NONE: return (vector, value, span) @@ -605,7 +614,22 @@ class RegisterOperand(DynamicOperand): else: raise ValueError(record.etype) - (value, span) = merge(vector, value, span, spec, spec_span) + vector_shift = (2 + (5 - value.bits)) + scalar_shift = value.bits + spec_shift = (5 - value.bits) + + bits = (len(span) + len(spec_span)) + value = _SelectableInt(value=value.value, bits=bits) + spec = _SelectableInt(value=spec.value, bits=bits) + if vector: + value = ((value << vector_shift) | (spec << spec_shift)) + span = (span + spec_span + ((spec_shift * ('{0}',)))) + else: + value = ((spec << scalar_shift) | value) + span = ((spec_shift * ('{0}',)) + spec_span + span) + + (value, span) = self.sv_spec_leave(value=value, span=span, + origin_value=origin_value, origin_span=origin_span) return (vector, value, span) @@ -645,30 +669,7 @@ class RegisterOperand(DynamicOperand): yield f"{vector}{prefix}{int(value)}" -class GPRFPROperand(RegisterOperand): - def spec(self, insn, record): - def merge(vector, value, span, spec, spec_span): - bits = (len(span) + len(spec_span)) - value = _SelectableInt(value=value.value, bits=bits) - spec = _SelectableInt(value=spec.value, bits=bits) - # this is silly these should be in a general base class, - # settable by constructor - vshift = 2 - sshift = 5 - spshft = 0 - if vector: - value = ((value << vshift) | (spec<>lsbshf, bits=bits) - spec = _SelectableInt(value=spec.value, bits=bits) - #print ("spec", bin(spec.value), spec.bits) - #print ("value", bin(value.value), value.bits) - #print ("lsbs", bin(lsbs.value), lsbs.bits) - if vector: - value = ((value << vshift) | (spec<> 2), bits=3) + return (value, span) + + def sv_spec_leave(self, value, span, origin_value, origin_span): + value = _selectconcat(value, origin_value[3:5]) + span += origin_span + return (value, span) class TargetAddrOperand(RegisterOperand):