[llvm] [RISCV][GlobalISel] Legalize Scalable Vector Loads and Stores (PR #84965)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 11:25:34 PDT 2024
topperc wrote:
> When we have alignment restrictions for `load`, we need to check `allowsMemoryAccessForAlignment`, like [what SelectionDAG did](https://github.com/llvm/llvm-project/blob/16a5fd3fdb91ffb39b97dbd3a7e9346ba406360d/llvm/lib/Target/RISCV/RISCVISelLowering.cpp#L5433). Therefore, equivalently, we can insert `customIf(!allowsMemoryAccessForAlignment)` around [here](https://github.com/llvm/llvm-project/blob/3c8423d1b2bf9ae5502ed16dde1d5c23deca5fef/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp#L257)
>
> But to get such information, we need to have `LLVMContext`, `DataLayout`, etc. However, [`RISCVLegalizerInfo`](https://github.com/llvm/llvm-project/blob/16a5fd3fdb91ffb39b97dbd3a7e9346ba406360d/llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp#L69) does not have those fields in it. Nor can I figure out a way to use `LegalityQuery` to obtain those required arguments.
>
> Can I get some help on this? Thanks!
The DataLayout belongs to Module. The LegalizerInfo constructor runs before the Module exists or at least without knowledge of the Module. I don't think you can call allowsMemoryAccessForAlignment.
A misaligned vector can be handled by converting it to a vle8. Not sure if the generic legalization can handle that or we need to do custom legalization for RISC-V. SelectionDAG uses custom legalization, see RISCVTargetLowering::expandUnalignedRVVLoad
https://github.com/llvm/llvm-project/pull/84965
More information about the llvm-commits
mailing list