This adds at extra check into ARMBaseInstrInfo::verifyInstruction to verify the offsets used in addressing mode immediates using isLegalAddressImm. Some tests needed fixing up as a result, including using t2STRHT instead of t2STRHi8 to test some outliner offsets, and adjusting the opcode created from CMSE stack adjustments.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Is this the kind of constraint that can be baked into the operand type in the instruction's (ins ...) in tablegen?
Yeah it already is, to a certain degree. The instructions have an AddrMode set in the AM variable, such as set by this MVE instruction: https://github.com/llvm/llvm-project/blob/8dcaf3aa0bf25508700a7452ed963c1487221dfd/llvm/lib/Target/ARM/ARMInstrMVE.td#L6222 (it's a bit hidden there, as it goes through the MVE_memsz. This t2LDRHi8 example is more clear, where it sets AM=AddrModeT2_i8neg https://github.com/llvm/llvm-project/blob/8dcaf3aa0bf25508700a7452ed963c1487221dfd/llvm/lib/Target/ARM/ARMInstrFormats.td#L1402.
That is what we are using here, along with some code already present in the load-store optimizer to validate the range of the immediates in the instruction.
I'm wondering if this verification could be done for us automatically, because the tablegen operands presumably already check what the immediate is before it's allowed to become a t2_addrmode_i7 etc. If that isn't possible then this LGTM.