From: Dmitry Selyutin Date: Tue, 20 Sep 2022 13:39:56 +0000 (+0300) Subject: power_insn: unify predicates X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf2d0bb000c2525f997aa3ab8b5638bffd3e4a95;p=openpower-isa.git power_insn: unify predicates --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 66238369..c4152057 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -1306,16 +1306,7 @@ class FFPRRc1BaseRM(BaseRM): inv = _SelectableInt(value=int(self.inv), bits=1) CR = _SelectableInt(value=int(self.CR), bits=2) mask = int(_selectconcat(inv, CR)) - predicate = { # exactly same table as in NormalLDSTBaseRM - 0b000: "lt", - 0b001: "ge", - 0b010: "gt", - 0b011: "le", - 0b100: "eq", - 0b101: "ne", - 0b110: "so", - 0b111: "ns", - }[mask] + predicate = PredicateBaseRM.predicate(True, mask) yield f"{mode}={predicate}" yield from super().specifiers(record=record) @@ -1382,65 +1373,85 @@ class ElsBaseRM(BaseRM): yield from super().specifiers(record=record) -class NormalLDSTBaseRM(BaseRM): - def specifiers(self, record): - # these go in inverse order. calculable as: "8<<(3-width)" - # TODO later: fp operations would be ew=fp16 ew=bf16 ew=fp32 - widths = { +class WidthBaseRM(BaseRM): + @staticmethod + def width(FP, width): + width = { 0b11: "8", 0b10: "16", 0b01: "32", - } - predicates = { + }.get(width) + if width is None: + return None + if FP: + width = ("fp" + width) + return width + + def specifiers(self, record): + # elwidths: use "w=" if same otherwise dw/sw + # FIXME this should consider FP instructions + FP = False + dw = WidthBaseRM.width(FP, int(self.elwidth)) + sw = WidthBaseRM.width(FP, int(self.ewsrc)) + if dw == sw and dw: + yield ("w=" + dw) + else: + if dw: + yield ("dw=" + dw) + if sw: + yield ("sw=" + sw) + + yield from super().specifiers(record=record) + + +class PredicateBaseRM(BaseRM): + @staticmethod + def predicate(CR, mask): + return { # integer - (0, 0b001): "1<