Handling out-of-bounds AArch64 immediates
Good morning,
I've been bitten a few times by out-of-bounds AArch64 immediates, e.g.
stp Dn, Dm, [Xa|SP], #simm
is only valid for (-512 <= #simm < 512, #simm = 8 * N)
This is nicely documented in the Instruction Reference, but it would be convenient to panic either at compile time (if #simm is a constant) or a run-time (if it's an expression).
If that sounds like a good idea, I could probably put together a PR given some rough guidance on where to start looking.
Hey! glad to hear someone else using this!
Such a check is already in place for things that can be resolved at compile time. At run-time it's a bit more complex, especially for aarch64 due to the sheer amount of immediates it uses.
It might also be a bit of a perf hit, so I'm wondering if it could be enabled conditionally. Thinking about a design for that, but I don't have immediate answers.
Either way, a good starting point would be here. This is where immediates are handled, compile-time checks are often done, and the runtime code is generated.
There's also likely a bit of run-time support necessary. There's already some precedent for that in the aarch64 module in the handling of special immediates.
I've got this working on dev now, just going to do a bit more test for it.
Fixed in v3.0.0!
Awesome, thanks!