This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Verify addressing immediates
ClosedPublic

Authored by dmgreen on Dec 2 2021, 2:12 AM.

Details

Summary

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.

Diff Detail

Event Timeline

dmgreen created this revision.Dec 2 2021, 2:12 AM
dmgreen requested review of this revision.Dec 2 2021, 2:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2021, 2:12 AM

Is this the kind of constraint that can be baked into the operand type in the instruction's (ins ...) in tablegen?

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.

samtebbs accepted this revision.Dec 14 2021, 3:26 AM
This revision is now accepted and ready to land.Dec 14 2021, 3:26 AM
This revision was landed with ongoing or failed builds.Jan 1 2022, 12:08 PM
This revision was automatically updated to reflect the committed changes.