aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:05 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2023-03-30 11:09:05 +0100
commit61dac77e931e254a3caeb4d924999e11875308d0 (patch)
treed051573f7dcb132be4523bb3629a17382ae7928a
parent9d862382668651a1bc44f6072c1ccc3c92ab906d (diff)
downloadbinutils-61dac77e931e254a3caeb4d924999e11875308d0.zip
binutils-61dac77e931e254a3caeb4d924999e11875308d0.tar.gz
binutils-61dac77e931e254a3caeb4d924999e11875308d0.tar.bz2
aarch64: Commonise index parsing
Just a minor clean-up to factor out the index parsing, partly to ensure that the error handling remains consistent. No behavioural change intended.
-rw-r--r--gas/config/tc-aarch64.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index e518535..dafd5bc 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1022,6 +1022,23 @@ aarch64_valid_suffix_char_p (aarch64_reg_type type, char ch)
}
}
+/* Parse an index expression at *STR, storing it in *IMM on success. */
+
+static bool
+parse_index_expression (char **str, int64_t *imm)
+{
+ expressionS exp;
+
+ aarch64_get_expression (&exp, str, GE_NO_PREFIX, REJECT_ABSENT);
+ if (exp.X_op != O_constant)
+ {
+ first_error (_("constant expression required"));
+ return false;
+ }
+ *imm = exp.X_add_number;
+ return true;
+}
+
/* Parse a register of the type TYPE.
Return null if the string pointed to by *CCP is not a valid register
@@ -1116,8 +1133,6 @@ parse_typed_reg (char **ccp, aarch64_reg_type type,
if (!(flags & PTR_FULL_REG) && skip_past_char (&str, '['))
{
- expressionS exp;
-
/* Reject Sn[index] syntax. */
if (!is_typed_vecreg)
{
@@ -1133,18 +1148,11 @@ parse_typed_reg (char **ccp, aarch64_reg_type type,
atype.defined |= NTA_HASINDEX;
- aarch64_get_expression (&exp, &str, GE_NO_PREFIX, REJECT_ABSENT);
-
- if (exp.X_op != O_constant)
- {
- first_error (_("constant expression required"));
- return NULL;
- }
+ if (!parse_index_expression (&str, &atype.index))
+ return NULL;
if (! skip_past_char (&str, ']'))
return NULL;
-
- atype.index = exp.X_add_number;
}
else if (!(flags & PTR_IN_REGLIST) && (atype.defined & NTA_HASINDEX) != 0)
{
@@ -1318,18 +1326,10 @@ parse_vector_reg_list (char **ccp, aarch64_reg_type type,
{
if (skip_past_char (&str, '['))
{
- expressionS exp;
-
- aarch64_get_expression (&exp, &str, GE_NO_PREFIX, REJECT_ABSENT);
- if (exp.X_op != O_constant)
- {
- set_first_syntax_error (_("constant expression required."));
- error = true;
- }
+ if (!parse_index_expression (&str, &typeinfo_first.index))
+ error = true;
if (! skip_past_char (&str, ']'))
error = true;
- else
- typeinfo_first.index = exp.X_add_number;
}
else
{