Skip to content

Commit 264f5ec

Browse files
committed
[RISCV][GISel] Refactor the load/store action builder to prepare for upcoming patch. NFC
Remove redundancy from RV32 by not using sXLen in the legalization rules. Make s64 conditional on XLen==64 instead. Preparation for making s64 legal on RV32+D.
1 parent d199ff1 commit 264f5ec

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,24 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) {
9595
.clampScalar(0, sXLen, sXLen)
9696
.clampScalar(1, sXLen, sXLen);
9797

98-
getActionDefinitionsBuilder({G_LOAD, G_STORE})
99-
.legalForTypesWithMemDesc({{s32, p0, s8, 8},
100-
{s32, p0, s16, 16},
101-
{s32, p0, s32, 32},
102-
{sXLen, p0, s8, 8},
103-
{sXLen, p0, s16, 16},
104-
{sXLen, p0, s32, 32},
105-
{sXLen, p0, sXLen, XLen},
106-
{p0, p0, sXLen, XLen}})
107-
.clampScalar(0, s32, sXLen)
108-
.lower();
109-
110-
auto &ExtLoadActions = getActionDefinitionsBuilder({G_SEXTLOAD, G_ZEXTLOAD})
111-
.legalForTypesWithMemDesc({{s32, p0, s8, 8},
112-
{s32, p0, s16, 16},
113-
{sXLen, p0, s8, 8},
114-
{sXLen, p0, s16, 16}});
115-
if (XLen == 64)
116-
ExtLoadActions.legalForTypesWithMemDesc({{sXLen, p0, s32, 32}});
98+
auto &LoadStoreActions =
99+
getActionDefinitionsBuilder({G_LOAD, G_STORE})
100+
.legalForTypesWithMemDesc({{s32, p0, s8, 8},
101+
{s32, p0, s16, 16},
102+
{s32, p0, s32, 32},
103+
{p0, p0, sXLen, XLen}});
104+
auto &ExtLoadActions =
105+
getActionDefinitionsBuilder({G_SEXTLOAD, G_ZEXTLOAD})
106+
.legalForTypesWithMemDesc({{s32, p0, s8, 8}, {s32, p0, s16, 16}});
107+
if (XLen == 64) {
108+
LoadStoreActions.legalForTypesWithMemDesc({{s64, p0, s8, 8},
109+
{s64, p0, s16, 16},
110+
{s64, p0, s32, 32},
111+
{s64, p0, s64, 64}});
112+
ExtLoadActions.legalForTypesWithMemDesc(
113+
{{s64, p0, s8, 8}, {s64, p0, s16, 16}, {s64, p0, s32, 32}});
114+
}
115+
LoadStoreActions.clampScalar(0, s32, sXLen).lower();
117116
ExtLoadActions.widenScalarToNextPow2(0).clampScalar(0, s32, sXLen).lower();
118117

119118
getActionDefinitionsBuilder(G_PTR_ADD).legalFor({{p0, sXLen}});

0 commit comments

Comments
 (0)