[llvm] [RISCV][GISel] Support unaligned-scalar-mem. (PR #108905)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 04:43:01 PDT 2024
================
@@ -287,34 +287,48 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
auto &LoadActions = getActionDefinitionsBuilder(G_LOAD);
auto &StoreActions = getActionDefinitionsBuilder(G_STORE);
+ auto &ExtLoadActions = getActionDefinitionsBuilder({G_SEXTLOAD, G_ZEXTLOAD});
- LoadActions
- .legalForTypesWithMemDesc({{s32, p0, s8, 8},
- {s32, p0, s16, 16},
- {s32, p0, s32, 32},
- {p0, p0, sXLen, XLen}});
- StoreActions
- .legalForTypesWithMemDesc({{s32, p0, s8, 8},
- {s32, p0, s16, 16},
- {s32, p0, s32, 32},
- {p0, p0, sXLen, XLen}});
- auto &ExtLoadActions =
- getActionDefinitionsBuilder({G_SEXTLOAD, G_ZEXTLOAD})
- .legalForTypesWithMemDesc({{s32, p0, s8, 8}, {s32, p0, s16, 16}});
+ // Return the alignment needed for scalar memory ops. If unaligned scalar mem
+ // is supported, we only require byte alignment. Otherwise, we need the memory
+ // op to be natively aligned.
+ auto getScalarMemAlign = [&ST](unsigned Size) {
+ return ST.enableUnalignedScalarMem() ? 8 : Size;
+ };
----------------
arsenm wrote:
We really need to replace the load/store legalization. You shouldn't have to do all this to support decomposing unaligned accesses. Currently we're abusing the register types for this, when it's really a property of the in-memory type which differs in the extend/truncate case. I have an old patch I need to resurrect to move all of this into a new lowering action
https://github.com/llvm/llvm-project/pull/108905
More information about the llvm-commits
mailing list