@samitouri / QOSamiQemu / commits / 97a75a12d6

hexagon: print info on "-d in_asm" for disabled IEEE FP instructions

When cpu->cfg.ieee_fp_extension is off, IEEE FP instructions don't get executed. Let's print that info on the "-d in_asm" output to help users. This will generate an output like the following: 0x00020e30: 0x1f82e1c0 { V0.sf = vadd(V1.sf,V2.sf) (disabled: no ieee_fp) } Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/1bdc772e4a795ecd9f5bf2b7e7143cc4b297318c.1776339451.git.matheus.bernardino@oss.qualcomm.com Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Matheus Tavares Bernardino committed Apr 16, 2026 at 04:38 UTC 97a75a12d6875b0b86211ea5699d1f7a4825e131
6 files changed +19 -10
disas/hexagon.c
+2 -2
@@ -31,7 +31,6 @@
31
32 int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
33 {
34 - const HexagonCPUDef *hex_def = (const HexagonCPUDef *)info->target_info;
34 uint32_t words[PACKET_WORDS_MAX];
35 bool found_end = false;
36 GString *buf;
@@ -58,8 +57,9 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
57 return PACKET_WORDS_MAX * sizeof(uint32_t);
58 }
59
60 + const HexagonCPUConfig *cfg = info->target_info;
61 buf = g_string_sized_new(PACKET_BUFFER_LEN);
62 - len = disassemble_hexagon(words, i, memaddr, buf, hex_def);
62 + len = disassemble_hexagon(words, i, memaddr, buf, cfg);
63 (*info->fprintf_func)(info->stream, "%s", buf->str);
64 g_string_free(buf, true);
65
target/hexagon/cpu.c
+4 -1
@@ -444,12 +444,13 @@ static void hexagon_cpu_disas_set_info(const CPUState *cs,
444 const HexagonCPU *cpu = HEXAGON_CPU(cs);
445 info->print_insn = print_insn_hexagon;
446 info->endian = BFD_ENDIAN_LITTLE;
447 - info->target_info = HEXAGON_CPU_GET_CLASS(cpu)->hex_def;
447 + info->target_info = &cpu->cfg;
448 }
449
450 static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
451 {
452 CPUState *cs = CPU(dev);
453 + HexagonCPU *cpu = HEXAGON_CPU(dev);
454 HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(dev);
455 Error *local_err = NULL;
456
@@ -459,6 +460,8 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
460 return;
461 }
462
463 + cpu->cfg.hex_def = mcc->hex_def;
464 +
465 gdb_register_coprocessor(cs, hexagon_hvx_gdb_read_register,
466 hexagon_hvx_gdb_write_register,
467 gdb_find_static_feature("hexagon-hvx.xml"));
target/hexagon/cpu_bits.h
+3 -2
@@ -26,6 +26,7 @@ typedef struct HexagonCPUConfig {
26 uint32_t lldb_stack_adjust;
27 bool short_circuit;
28 bool ieee_fp_extension;
29 + const HexagonCPUDef *hex_def;
30 } HexagonCPUConfig;
31
32 #define PCALIGN 4
@@ -130,7 +131,7 @@ static inline bool is_packet_end(uint32_t endocing)
131 return ((bits == 0x3) || (bits == 0x0));
132 }
133
133 -int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc, GString *buf,
134 - const HexagonCPUDef *hex_def);
134 +int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc,
135 + GString *buf, const HexagonCPUConfig *cfg);
136
137 #endif
target/hexagon/decode.c
+2 -2
@@ -856,7 +856,7 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,
856
857 /* Used for "-d in_asm" logging */
858 int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc,
859 - GString *buf, const HexagonCPUDef *hex_def)
859 + GString *buf, const HexagonCPUConfig *cfg)
860 {
861 HexagonCPUDef any_def = {
862 .hex_version = HEX_VER_ANY, /* Allow decode to accept anything */
@@ -867,7 +867,7 @@ int disassemble_hexagon(uint32_t *words, int nwords, bfd_vma pc,
867 ctx.hex_def = &any_def;
868
869 if (decode_packet(&ctx, nwords, words, &ctx.pkt, true) > 0) {
870 - snprint_a_pkt_disas(buf, &ctx.pkt, words, pc, hex_def);
870 + snprint_a_pkt_disas(buf, &ctx.pkt, words, pc, cfg);
871 return ctx.pkt.encod_pkt_size_in_bytes;
872 } else {
873 for (int i = 0; i < nwords; i++) {
target/hexagon/printinsn.c
+7 -2
@@ -139,7 +139,7 @@ static void snprintinsn(GString *buf, Insn *insn)
139 }
140
141 void snprint_a_pkt_disas(GString *buf, Packet *pkt, uint32_t *words,
142 - target_ulong pc, const HexagonCPUDef *hex_def)
142 + target_ulong pc, const HexagonCPUConfig *cfg)
143 {
144 bool has_endloop0 = false;
145 bool has_endloop1 = false;
@@ -171,12 +171,17 @@ void snprint_a_pkt_disas(GString *buf, Packet *pkt, uint32_t *words,
171 }
172
173 g_string_append(buf, "\t");
174 - if (opcode_supported(pkt->insn[i].opcode, hex_def)) {
174 + if (opcode_supported(pkt->insn[i].opcode, cfg->hex_def)) {
175 snprintinsn(buf, &(pkt->insn[i]));
176 } else {
177 g_string_append(buf, "<invalid>");
178 }
179
180 + if (!cfg->ieee_fp_extension &&
181 + GET_ATTRIB(pkt->insn[i].opcode, A_HVX_IEEE_FP)) {
182 + g_string_append(buf, " (disabled: no ieee_fp)");
183 + }
184 +
185 if (i < pkt->num_insns - 1) {
186 /*
187 * Subinstructions are two instructions encoded
target/hexagon/printinsn.h
+1 -1
@@ -22,6 +22,6 @@
22 #include "insn.h"
23
24 void snprint_a_pkt_disas(GString *buf, Packet *pkt, uint32_t *words,
25 - target_ulong pc, const HexagonCPUDef *hex_def);
25 + target_ulong pc, const HexagonCPUConfig *cfg);
26
27 #endif