Skip to content

Commit 5bf908e

Browse files
committed
register bank select for scalable vector load/store
1 parent fa84297 commit 5bf908e

File tree

3 files changed

+3166
-6
lines changed

3 files changed

+3166
-6
lines changed

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,20 @@ 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;
314-
OpdsMapping[1] = GPRValueMapping;
313+
TypeSize Size = Ty.getSizeInBits();
314+
if (Ty.isVector()) {
315+
OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
316+
OpdsMapping[1] = getVRBValueMapping(Size.getKnownMinValue());
317+
} else if (isPreISelGenericFloatingPointOpcode(Opc)) {
318+
OpdsMapping[0] = getFPValueMapping(Size.getFixedValue());
319+
OpdsMapping[1] = getFPValueMapping(Size.getFixedValue());
320+
} else {
321+
OpdsMapping[0] = GPRValueMapping;
322+
OpdsMapping[1] = GPRValueMapping;
323+
}
315324
// Use FPR64 for s64 loads on rv32.
316-
if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
325+
if (GPRSize == 32 && Ty.getSizeInBits().getKnownMinValue() == 64 &&
326+
!Ty.isVector()) {
317327
assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
318328
OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
319329
break;
@@ -333,10 +343,21 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
333343
}
334344
case TargetOpcode::G_STORE: {
335345
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
336-
OpdsMapping[0] = GPRValueMapping;
337-
OpdsMapping[1] = GPRValueMapping;
346+
TypeSize Size = Ty.getSizeInBits();
347+
if (Ty.isVector()) {
348+
OpdsMapping[0] = getVRBValueMapping(Size.getKnownMinValue());
349+
OpdsMapping[1] = getVRBValueMapping(Size.getKnownMinValue());
350+
} else if (isPreISelGenericFloatingPointOpcode(Opc)) {
351+
OpdsMapping[0] = getFPValueMapping(Size.getFixedValue());
352+
OpdsMapping[1] = getFPValueMapping(Size.getFixedValue());
353+
} else {
354+
OpdsMapping[0] = GPRValueMapping;
355+
OpdsMapping[1] = GPRValueMapping;
356+
}
357+
338358
// Use FPR64 for s64 stores on rv32.
339-
if (GPRSize == 32 && Ty.getSizeInBits() == 64) {
359+
if (GPRSize == 32 && Ty.getSizeInBits().getKnownMinValue() == 64 &&
360+
!Ty.isVector()) {
340361
assert(MF.getSubtarget<RISCVSubtarget>().hasStdExtD());
341362
OpdsMapping[0] = getFPValueMapping(Ty.getSizeInBits());
342363
break;

0 commit comments

Comments
 (0)