From: Dmitry Selyutin Date: Sun, 4 Sep 2022 11:23:45 +0000 (+0300) Subject: power_insn: remove the whitespaces properly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aadf3b780259bba4c668a455949c541dcbeb60e5;p=openpower-isa.git power_insn: remove the whitespaces properly --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 34fb1f39..34ae8895 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -227,8 +227,9 @@ class PPCRecord: flags.add(flag) record["flags"] = PPCRecord.Flags(flags) - return dataclass(cls, record, keymap=PPCRecord.__KEYMAP, - typemap=typemap) + return dataclass(cls, record, + keymap=PPCRecord.__KEYMAP, + typemap=typemap) @cached_property def names(self): @@ -259,8 +260,9 @@ class PPCMultiRecord(tuple): value |= (vstate << bit) mask |= (mstate << bit) - return _dataclasses.replace(lhs, - opcode=Opcode(value=value, mask=mask)) + opcode = opcode=Opcode(value=value, mask=mask) + + return _dataclasses.replace(lhs, opcode=opcode) return _functools.reduce(merge, self) @@ -337,8 +339,11 @@ class SVP64Record: if value == "0": record[key] = "NONE" - record["extra"] = cls.ExtraMap(record.pop(f"{index}") \ - for index in range(0, 4)) + extra = [] + for idx in range(0, 4): + extra.append(record.pop(f"{idx}")) + + record["extra"] = cls.ExtraMap(extra) return dataclass(cls, record, keymap=cls.__KEYMAP) @@ -1253,10 +1258,12 @@ class SVP64Instruction(PrefixedInstruction): def parse(stream, factory): + def match(entry): + return ("TODO" not in frozenset(entry.values())) + lines = filter(lambda line: not line.strip().startswith("#"), stream) entries = _csv.DictReader(lines) - entries = filter(lambda entry: "TODO" \ - not in frozenset(entry.values()), entries) + entries = filter(match, entries) return tuple(map(factory, entries)) @@ -1315,8 +1322,8 @@ class PPCDatabase: section.Mode.INTEGER: IntegerOpcode, section.Mode.PATTERN: PatternOpcode, }[section.mode] - factory = _functools.partial(PPCRecord.CSV, - opcode_cls=opcode_cls) + factory = _functools.partial( + PPCRecord.CSV, opcode_cls=opcode_cls) with open(path, "r", encoding="UTF-8") as stream: for insn in parse(stream, factory): records[section][insn.comment].add(insn)