[RISCV] Add early-exit to RVV stack computation. NFCI.
This patch was split off from D126465, where an early-exit is necessary as it checks the VLEN and that asserts that V instructions are present. Since this makes logical sense on its own, I think it's worth landing regardless of D126465. Reviewed By: kito-cheng Differential Revision: https://reviews.llvm.org/D129617
This commit is contained in:
parent
491d27013d
commit
b336cf856e
|
@ -899,7 +899,8 @@ void RISCVFrameLowering::determineCalleeSaves(MachineFunction &MF,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int64_t, Align>
|
std::pair<int64_t, Align>
|
||||||
RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFrameInfo &MFI) const {
|
RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFunction &MF) const {
|
||||||
|
MachineFrameInfo &MFI = MF.getFrameInfo();
|
||||||
// Create a buffer of RVV objects to allocate.
|
// Create a buffer of RVV objects to allocate.
|
||||||
SmallVector<int, 8> ObjectsToAllocate;
|
SmallVector<int, 8> ObjectsToAllocate;
|
||||||
for (int I = 0, E = MFI.getObjectIndexEnd(); I != E; ++I) {
|
for (int I = 0, E = MFI.getObjectIndexEnd(); I != E; ++I) {
|
||||||
|
@ -912,10 +913,18 @@ RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFrameInfo &MFI) const {
|
||||||
ObjectsToAllocate.push_back(I);
|
ObjectsToAllocate.push_back(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate all RVV locals and spills
|
|
||||||
int64_t Offset = 0;
|
|
||||||
// The minimum alignment is 16 bytes.
|
// The minimum alignment is 16 bytes.
|
||||||
Align RVVStackAlign(16);
|
Align RVVStackAlign(16);
|
||||||
|
const auto &ST = MF.getSubtarget<RISCVSubtarget>();
|
||||||
|
|
||||||
|
if (!ST.hasVInstructions()) {
|
||||||
|
assert(ObjectsToAllocate.empty() &&
|
||||||
|
"Can't allocate scalable-vector objects without V instructions");
|
||||||
|
return std::make_pair(0, RVVStackAlign);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate all RVV locals and spills
|
||||||
|
int64_t Offset = 0;
|
||||||
for (int FI : ObjectsToAllocate) {
|
for (int FI : ObjectsToAllocate) {
|
||||||
// ObjectSize in bytes.
|
// ObjectSize in bytes.
|
||||||
int64_t ObjectSize = MFI.getObjectSize(FI);
|
int64_t ObjectSize = MFI.getObjectSize(FI);
|
||||||
|
@ -997,7 +1006,7 @@ void RISCVFrameLowering::processFunctionBeforeFrameFinalized(
|
||||||
|
|
||||||
int64_t RVVStackSize;
|
int64_t RVVStackSize;
|
||||||
Align RVVStackAlign;
|
Align RVVStackAlign;
|
||||||
std::tie(RVVStackSize, RVVStackAlign) = assignRVVStackObjectOffsets(MFI);
|
std::tie(RVVStackSize, RVVStackAlign) = assignRVVStackObjectOffsets(MF);
|
||||||
|
|
||||||
RVFI->setRVVStackSize(RVVStackSize);
|
RVFI->setRVVStackSize(RVVStackSize);
|
||||||
RVFI->setRVVStackAlign(RVVStackAlign);
|
RVFI->setRVVStackAlign(RVVStackAlign);
|
||||||
|
|
|
@ -84,7 +84,7 @@ private:
|
||||||
MachineBasicBlock::iterator MBBI, const DebugLoc &DL,
|
MachineBasicBlock::iterator MBBI, const DebugLoc &DL,
|
||||||
int64_t Amount, MachineInstr::MIFlag Flag) const;
|
int64_t Amount, MachineInstr::MIFlag Flag) const;
|
||||||
std::pair<int64_t, Align>
|
std::pair<int64_t, Align>
|
||||||
assignRVVStackObjectOffsets(MachineFrameInfo &MFI) const;
|
assignRVVStackObjectOffsets(MachineFunction &MF) const;
|
||||||
};
|
};
|
||||||
}
|
} // namespace llvm
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue