Skip to content

Commit 1c66ef9

Browse files
authored
[GISEL][RISCV] RegBank Select for Scalable Vector Load/Store (llvm#99932)
This patch supports GlobalISel for register bank selection for scalable vector load and store instructions in RISC-V
1 parent a0d8fa5 commit 1c66ef9

File tree

4 files changed

+2986
-6
lines changed

4 files changed

+2986
-6
lines changed

llvm/lib/CodeGen/RegisterBankInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const {
215215
}
216216
}
217217

218-
unsigned Size = getSizeInBits(Reg, MRI, TRI);
219-
const ValueMapping *ValMapping = &getValueMapping(0, Size, *CurRegBank);
218+
TypeSize Size = getSizeInBits(Reg, MRI, TRI);
219+
const ValueMapping *ValMapping =
220+
&getValueMapping(0, Size.getKnownMinValue(), *CurRegBank);
220221
if (IsCopyLike) {
221222
if (!OperandsMapping[0]) {
222223
if (MI.isRegSequence()) {

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,18 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
310310
switch (Opc) {
311311
case TargetOpcode::G_LOAD: {
312312
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
313-
OpdsMapping[0] = GPRValueMapping;
313+
TypeSize Size = Ty.getSizeInBits();
314+
if (Ty.isVector())
315+
OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
316+
else
317+
OpdsMapping[0] = GPRValueMapping;
318+
314319
OpdsMapping[1] = GPRValueMapping;
320+
321+
if (Ty.isVector())
322+
break;
315323
// Use FPR64 for s64 loads on rv32.
316-
if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
324+
if (GPRSize == 32 && Size.getFixedValue() == 64) {
317325
assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
318326
OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
319327
break;
@@ -333,10 +341,19 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
333341
}
334342
case TargetOpcode::G_STORE: {
335343
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
336-
OpdsMapping[0] = GPRValueMapping;
344+
TypeSize Size = Ty.getSizeInBits();
345+
if (Ty.isVector())
346+
OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
347+
else
348+
OpdsMapping[0] = GPRValueMapping;
349+
337350
OpdsMapping[1] = GPRValueMapping;
351+
352+
if (Ty.isVector())
353+
break;
354+
338355
// Use FPR64 for s64 stores on rv32.
339-
if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
356+
if (GPRSize == 32 && Size.getFixedValue() == 64) {
340357
assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
341358
OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
342359
break;

0 commit comments

Comments
 (0)