@property
def opcodes(self):
def opcode(ppc):
- value = ([0] * 32)
- mask = ([0] * 32)
+ bits = 32
+ if self.svp64 is not None:
+ bits = 64
+ value = ([0] * bits)
+ mask = ([0] * bits)
for operand in self.static_operands:
for (src, dst) in enumerate(reversed(operand.span)):
@cached_property
def span(self):
- return self.record.fields[self.name]
+ span = self.record.fields[self.name]
+ if self.record.svp64 is not None:
+ span = tuple(map(lambda bit: (bit + 32), span))
+ return span
def assemble(self, value, insn):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
if isinstance(value, str):
value = int(value, 0)
if value < 0:
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
@cached_property
def span(self):
- return tuple(range(0, 6))
+ span = tuple(range(0, 6))
+ if self.record.svp64 is not None:
+ span = tuple(map(lambda bit: (bit + 32), span))
+ return span
@_dataclasses.dataclass(eq=True, frozen=True)
value = int(_selectconcat(*(value[bit] for bit in span.values())))
span = tuple(span.keys())
+ if self.record.svp64 is not None:
+ span = tuple(map(lambda bit: (bit + 32), span))
object.__setattr__(self, "value", value)
object.__setattr__(self, "span", span)
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
def spec(self, insn):
vector = False
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
span = tuple(map(str, span))
@cached_property
def span(self):
- return self.record.fields[self.field]
+ span = self.record.fields[self.field]
+ if self.record.svp64 is not None:
+ span = tuple(map(lambda bit: (bit + 32), span))
+ return span
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
cls = lambda name: DynamicOperand(record=self.record, name=name)
operands = map(cls, ("d0", "d1", "d2"))
spans = map(lambda operand: operand.span, operands)
- return sum(spans, tuple())
+ span = sum(spans, tuple())
+ if self.record.svp64 is not None:
+ span = tuple(map(lambda bit: (bit + 32), span))
+ return span
def disassemble(self, insn,
verbosity=Verbosity.NORMAL, indent=""):
span = self.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
if verbosity >= Verbosity.VERBOSE:
for (subname, subspan) in mapping.items():
operand = DynamicOperand(name=subname)
span = operand.span
- if isinstance(insn, SVP64Instruction):
- span = tuple(map(lambda bit: (bit + 32), span))
value = insn[span]
span = map(str, span)
yield f"{indent}{indent}{operand.name} = D{subspan}"
return self.storage.__setitem__(key, value)
def bytes(self, byteorder="little"):
- nr_bytes = (self.storage.bits // 8)
+ nr_bytes = (len(self.__class__) // 8)
return int(self).to_bytes(nr_bytes, byteorder=byteorder)
def record(self, db):
def disassemble(self, db,
byteorder="little",
verbosity=Verbosity.NORMAL):
- integer = int(self)
if verbosity <= Verbosity.SHORT:
blob = ""
else:
- blob = integer.to_bytes(length=4, byteorder=byteorder)
+ blob = self.bytes(byteorder=byteorder)
blob = " ".join(map(lambda byte: f"{byte:02x}", blob))
blob += " "
record = db[self]
if record is None:
- yield f"{blob}.long 0x{integer:08x}"
+ yield f"{blob}.long 0x{int(self):08x}"
return
operands = tuple(map(_operator.itemgetter(1),
def assemble(cls, db, opcode, arguments):
record = db[opcode]
insn = cls.integer(value=0)
+
for operand in record.static_operands:
operand.assemble(insn=insn)
def disassemble(self, db,
byteorder="little",
verbosity=Verbosity.NORMAL):
- def blob(integer):
+ def blob(insn):
if verbosity <= Verbosity.SHORT:
return ""
else:
- blob = integer.to_bytes(length=4, byteorder=byteorder)
+ blob = insn.bytes(byteorder=byteorder)
blob = " ".join(map(lambda byte: f"{byte:02x}", blob))
return f"{blob} "
record = self.record(db=db)
- blob_prefix = blob(int(self.prefix))
- blob_suffix = blob(int(self.suffix))
+ blob_prefix = blob(self.prefix)
+ blob_suffix = blob(self.suffix)
if record is None or record.svp64 is None:
yield f"{blob_prefix}.long 0x{int(self.prefix):08x}"
yield f"{blob_suffix}.long 0x{int(self.suffix):08x}"
yield f"{indent}{indent}{opcode!r}"
for (cls, kwargs) in record.mdwn.operands:
operand = cls(record=record, **kwargs)
- yield from operand.disassemble(insn=self, record=record,
+ yield from operand.disassemble(insn=self,
verbosity=verbosity, indent=indent)
yield f"{indent}RM"
yield f"{indent}{indent}{rm.__doc__}"