Hexagon (target/hexagon) Check each opcode against current CPU definition
During decoding, check that the opcode is supported in the current Hexagon CPU definition Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com> Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com> Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com> Reviewed-by: Anton Johansson <anjo@rev.ng> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Taylor Simpson committed
Feb 17, 2026 at 14:22 UTC
050749560499043406de950f8dddf5912f13457c
2 files changed
+29
target/hexagon/decode.c
+27
@@ -647,6 +647,22 @@ decode_set_slot_number(Packet *pkt)
647
return has_valid_slot_assignment(pkt);
648
}
649
650
+bool opcode_supported(uint16_t opcode, const HexagonCPUDef *hex_def)
651
+{
652
+ HexagonVersion hex_version = hex_def->hex_version;
653
+#include "tag_rev_info.c.inc"
654
+
655
+ struct tag_rev_info info = tag_rev_info[opcode];
656
+ if (hex_version == HEX_VER_ANY) {
657
+ return true;
658
+ }
659
+ if ((info.introduced != HEX_VER_NONE && hex_version < info.introduced) ||
660
+ (info.removed != HEX_VER_NONE && hex_version >= info.removed)) {
661
+ return false;
662
+ }
663
+ return true;
664
+}
665
+
666
/*
667
* Check for GPR write conflicts in the packet.
668
* A conflict exists when a register is written by more than one instruction
@@ -746,6 +762,17 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,
762
/* Ran out of words! */
763
return 0;
764
}
765
+
766
+ /*
767
+ * Check that all the opcodes are supported in this Hexagon definition
768
+ * If not, return decode error
769
+ */
770
+ for (i = 0; i < num_insns; i++) {
771
+ if (!opcode_supported(pkt->insn[i].opcode, ctx->hex_def)) {
772
+ return 0;
773
+ }
774
+ }
775
+
776
pkt->encod_pkt_size_in_bytes = words_read * 4;
777
pkt->pkt_has_hvx = false;
778
for (i = 0; i < num_insns; i++) {
target/hexagon/decode.h
+2
@@ -30,4 +30,6 @@ void decode_send_insn_to(Packet *packet, int start, int newloc);
30
int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,
31
Packet *pkt, bool disas_only);
32
33
+bool opcode_supported(uint16_t opcode, const HexagonCPUDef *hex_def);
34
+
35
#endif