[PATCH 2/2] aarch64: Treat operand ADDR_SIMPLE as address with base register
Richard Earnshaw (lists)
Richard.Earnshaw@arm.com
Tue Jun 25 14:51:47 GMT 2024
On 21/06/2024 16:50, Jens Remus wrote:
> Notes (jremus):
> I ran into two issues where union members of struct aarch64_opnd_info
> were erroneously used interchangeably:
> - https://sourceware.org/PR31561
> - https://sourceware.org/PR31919
>
> This got me the idea to change the union to struct for debugging
> purposes to check whether there were further instances.
I think having an operand type field would be more robust. Then, instead of accessing the union directly you'd use accessor macros which could optionally (when in debug mode) validate the type, much like GCC does for RTL accessors.
Something like
...
OP_SET_TYPE (opnds[0], REG);
OP_REG (opnds[0]).regno = 13; // OK, type is REG;
if (OP_ADDR (opnds[0]).base_regno == 13) // Type fault, type is not ADDR.
But of course, it wouldn't be quite as easy to rework the code this way.
R.
More information about the Binutils
mailing list