From: Dmitry Selyutin Date: Thu, 7 Sep 2023 18:44:29 +0000 (+0300) Subject: libsvp64: update operands types X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c8c52accaf409021f656c6dfe8b1cc15ad5053b5;p=openpower-isa.git libsvp64: update operands types --- diff --git a/src/libsvp64/codegen.py b/src/libsvp64/codegen.py index ccd4ef1c..ff80119d 100644 --- a/src/libsvp64/codegen.py +++ b/src/libsvp64/codegen.py @@ -26,14 +26,14 @@ def traverse(root, visitor, walker, **kwargs): def fetch(span): bits = len(span) - one = "UINT64_C(1)" + one = "UINT32_C(1)" for (dst, origin) in enumerate(span): src = (32 - (origin + 1)) dst = (bits - (dst + 1)) - dst = f"UINT64_C({dst})" - src = f"UINT64_C({src})" + dst = f"UINT32_C({dst})" + src = f"UINT32_C({src})" yield f"/* {origin:<2} */ (((insn >> {src}) & {one}) << {dst}) |" - yield f"UINT64_C(0)" + yield f"UINT32_C(0)" class Mode(enum.Enum): @@ -233,7 +233,7 @@ class DisGenSource(Source): self.emit("static inline enum svp64_state") self.emit("svp64_disassemble_operand(struct svp64_ctx *ctx, uint32_t insn, size_t id) {") with self: - self.emit("int64_t value;") + self.emit("uint32_t value;") self.emit("") self.emit(f"switch (ctx->record->operands[id]) {{") yield node @@ -243,7 +243,7 @@ class DisGenSource(Source): self.emit("}") self.emit("") with self: - self.emit("ctx->operands[id] = value;") + self.emit("ctx->operands[id].value = value;") self.emit("") self.emit("return SVP64_SUCCESS;") self.emit("}") @@ -273,15 +273,15 @@ class DisGenSource(Source): @contextlib.contextmanager def dispatch_operand(self, node, *, path, pathcls): def generic_handler(span): - yield f"value = (int64_t)(" + yield f"value = (" with self: yield from fetch(span) yield f");" self.emit("break;") def signed_handler(span): - mask = f"(UINT64_C(1) << (UINT64_C({len(span)}) - 1))" - yield "value = (int64_t)(" + mask = f"(UINT32_C(1) << (UINT32_C({len(span)}) - 1))" + yield "value = (" with self: yield "(" with self: @@ -385,7 +385,7 @@ class OpcGenSource(Source): @mdis.dispatcher.Hook(insndb.Record.Opcode.Value, insndb.Record.Opcode.Mask) @contextlib.contextmanager def dispatch_opcode_parts(self, node, *, path, pathcls): - self.emit(f"{pathcls(path)} = UINT64_C(0x{node:016x}),") + self.emit(f"{pathcls(path)} = UINT32_C(0x{node:016x}),") with self: yield node @mdis.dispatcher.Hook(insndb.Record.Opcode) diff --git a/src/libsvp64/svp64.h b/src/libsvp64/svp64.h index 1b7033c1..5949e179 100644 --- a/src/libsvp64/svp64.h +++ b/src/libsvp64/svp64.h @@ -27,9 +27,13 @@ struct svp64_record { char name[16]; }; +struct svp64_operand { + uint32_t value; +}; + struct svp64_ctx { struct svp64_record const *record; - int64_t operands[8]; + struct svp64_operand operands[8]; }; enum svp64_state