[binutils-gdb] aarch64: Cleanup optional_operand_p
Alice Carlotti
acarlotti@sourceware.org
Thu Apr 9 14:36:42 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=254a4c9a4c64b77cee2613cd056c0237416d735f
commit 254a4c9a4c64b77cee2613cd056c0237416d735f
Author: Alice Carlotti <alice.carlotti@arm.com>
Date: Thu Apr 9 01:45:18 2026 +0100
aarch64: Cleanup optional_operand_p
Every time I looked at this function I initially misread the
implementation. Make it less confusing.
Diff:
---
include/opcode/aarch64.h | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
index e38de9a99dc..79cbed433bb 100644
--- a/include/opcode/aarch64.h
+++ b/include/opcode/aarch64.h
@@ -1598,16 +1598,13 @@ aarch64_opcode_subclass_p (const aarch64_opcode *opcode, uint64_t flag)
return ((opcode->flags & F_SUBCLASS) == flag);
}
-/* Deal with two possible scenarios: If F_OP_PAIR_OPT not set, as is the case
- by default, F_OPDn_OPT must equal IDX + 1, else F_OPDn_OPT must be in range
- [IDX, IDX + 1]. */
+/* Return whether OPCODE has an optional operand at position IDX. */
static inline bool
optional_operand_p (const aarch64_opcode *opcode, unsigned int idx)
{
- if (opcode->flags & F_OPD_PAIR_OPT)
- return (((opcode->flags >> 12) & 0x7) == idx
- || ((opcode->flags >> 12) & 0x7) == idx + 1);
- return ((opcode->flags >> 12) & 0x7) == idx + 1;
+ unsigned int optional_idx = ((opcode->flags >> 12) & 0x7) - 1;
+ return (idx == optional_idx
+ || ((opcode->flags & F_OPD_PAIR_OPT) && idx == optional_idx + 1));
}
static inline aarch64_insn
More information about the Binutils-cvs
mailing list