[committed] aarch64: Cleanup optional_operand_p
Alice Carlotti
alice.carlotti@arm.com
Thu Apr 9 14:39:54 GMT 2026
Every time I looked at this function I initially misread the
implementation. Make it less confusing.
diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
index e38de9a99dc4880129d07eeb89758beb09a1970a..79cbed433bb08c9f99268ac2b6abbae88ea6f8d6 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
mailing list