summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:07 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:07 +0100
commit859f51df4d0e23c21adc2167d738cf1e6c0f2613 (patch)
tree4be0fd16ae64e3c2cca72c6fba77171a54ad8fe8 /opcodes
parent36043bcff490e6c588d5b52318fbba233f478fab (diff)
downloadbinutils-gdb-859f51df4d0e23c21adc2167d738cf1e6c0f2613.tar.gz
aarch64: Add an error code for out-of-range registers
libopcodes currently reports out-of-range registers as a general AARCH64_OPDE_OTHER_ERROR. However, this means that each register range needs its own hard-coded string, which is a bit cumbersome if the range is determined programmatically. This patch therefore adds a dedicated error type for out-of-range errors.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/aarch64-opc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index 24cca9e8193..c36e4cc67f6 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -1336,6 +1336,18 @@ set_syntax_error (aarch64_operand_error *mismatch_detail, int idx,
}
static inline void
+set_invalid_regno_error (aarch64_operand_error *mismatch_detail, int idx,
+ const char *prefix, int lower_bound, int upper_bound)
+{
+ if (mismatch_detail == NULL)
+ return;
+ set_error (mismatch_detail, AARCH64_OPDE_INVALID_REGNO, idx, NULL);
+ mismatch_detail->data[0].s = prefix;
+ mismatch_detail->data[1].i = lower_bound;
+ mismatch_detail->data[2].i = upper_bound;
+}
+
+static inline void
set_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound,
const char* error)
@@ -1569,11 +1581,7 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
mask = (1 << shift) - 1;
if (opnd->reg.regno > mask)
{
- assert (mask == 7 || mask == 15);
- set_other_error (mismatch_detail, idx,
- mask == 15
- ? _("z0-z15 expected")
- : _("z0-z7 expected"));
+ set_invalid_regno_error (mismatch_detail, idx, "z", 0, mask);
return 0;
}
mask = (1u << (size - shift)) - 1;
@@ -1642,7 +1650,7 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx,
if (opnd->reg.regno >= 8
&& get_operand_fields_width (get_operand_from_code (type)) == 3)
{
- set_other_error (mismatch_detail, idx, _("p0-p7 expected"));
+ set_invalid_regno_error (mismatch_detail, idx, "p", 0, 7);
return 0;
}
break;