summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:09 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:09 +0100
commit199cfcc4754cea6f4c42dcbb8d8d5161f5b2d186 (patch)
tree421a44c2103aed91928b78ca2ac89ce055c9ffb1 /opcodes
parentd09b87e0b11f14c267014e22716b91ba61c1e458 (diff)
downloadbinutils-gdb-199cfcc4754cea6f4c42dcbb8d8d5161f5b2d186.tar.gz
aarch64: Add a aarch64_cpu_supports_inst_p helper
Quite a lot of SME2 instructions have an opcode bit that selects between 32-bit and 64-bit forms of an instruction, with the 32-bit forms being part of base SME2 and with the 64-bit forms being part of an optional extension. It's nevertheless useful to have a single opcode entry for both forms since (a) that matches the ISA definition and (b) it tends to improve error reporting. This patch therefore adds a libopcodes function called aarch64_cpu_supports_inst_p that tests whether the target supports a particular instruction. In future it will depend on internal libopcodes routines.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/aarch64-opc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index b9029010c47..7a88c19633d 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -6158,6 +6158,19 @@ aarch64_sve_dupm_mov_immediate_p (uint64_t uvalue, int esize)
return svalue < -128 || svalue >= 128;
}
+/* Return true if a CPU with the AARCH64_FEATURE_* bits in CPU_VARIANT
+ supports the instruction described by INST. */
+
+bool
+aarch64_cpu_supports_inst_p (uint64_t cpu_variant, aarch64_inst *inst)
+{
+ if (!inst->opcode->avariant
+ || !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, *inst->opcode->avariant))
+ return false;
+
+ return true;
+}
+
/* Include the opcode description table as well as the operand description
table. */
#define VERIFIER(x) verify_##x