@@ -20877,7 +20877,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
20877
20877
return Subtarget.getMinimumJumpTableEntries();
20878
20878
}
20879
20879
20880
- void RVVArgDispatcher::constructHelper (Type *Ty) {
20880
+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
20881
20881
const DataLayout &DL = MF->getDataLayout();
20882
20882
const Function &F = MF->getFunction();
20883
20883
LLVMContext &Context = F.getContext();
@@ -20910,16 +20910,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
20910
20910
RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
20911
20911
20912
20912
RVVArgInfo Info{1, RegisterVT, false};
20913
-
20914
- while (NumRegs--)
20915
- RVVArgInfos.push_back(Info);
20913
+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
20916
20914
}
20917
20915
}
20918
20916
}
20919
20917
20920
- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20918
+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
20921
20919
for (Type *Ty : TypeList)
20922
- constructHelper (Ty);
20920
+ constructArgInfos (Ty);
20923
20921
20924
20922
for (auto &Info : RVVArgInfos)
20925
20923
if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20954,28 +20952,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
20954
20952
if (StartReg)
20955
20953
AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
20956
20954
else
20957
- AllocatedPhysRegs.push_back(0 );
20955
+ AllocatedPhysRegs.push_back(MCPhysReg() );
20958
20956
}
20959
20957
20960
- // This function determines if each RVV argument is passed by register.
20958
+ /// This function determines if each RVV argument is passed by register, if the
20959
+ /// argument can be assigned to a VR, then give it a specific register.
20960
+ /// Otherwise, assign the argument to 0 which is a invalid MCPhysReg.
20961
20961
void RVVArgDispatcher::compute() {
20962
- unsigned ToBeAssigned = RVVArgInfos.size();
20963
- uint64_t AssignedMap = 0;
20964
- auto tryAllocate = [&](const RVVArgInfo &ArgInfo) {
20962
+ uint32_t AssignedMap = 0;
20963
+ auto allocate = [&](const RVVArgInfo &ArgInfo) {
20965
20964
// Allocate first vector mask argument to V0.
20966
20965
if (ArgInfo.FirstVMask) {
20967
20966
AllocatedPhysRegs.push_back(RISCV::V0);
20968
20967
return;
20969
20968
}
20970
20969
20971
- unsigned RegsNeeded =
20972
- std::max((unsigned)ArgInfo.VT.getSizeInBits().getKnownMinValue() /
20973
- RISCV::RVVBitsPerBlock,
20974
- (unsigned)1);
20970
+ unsigned RegsNeeded = divideCeil(
20971
+ ArgInfo.VT.getSizeInBits().getKnownMinValue(), RISCV::RVVBitsPerBlock);
20975
20972
unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
20976
20973
for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
20977
20974
StartReg += RegsNeeded) {
20978
- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20975
+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20979
20976
if ((AssignedMap & Map) == 0) {
20980
20977
allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
20981
20978
AssignedMap |= Map;
@@ -20984,11 +20981,10 @@ void RVVArgDispatcher::compute() {
20984
20981
}
20985
20982
20986
20983
allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20987
- return;
20988
20984
};
20989
20985
20990
- for (unsigned i = 0; i < ToBeAssigned ; ++i)
20991
- tryAllocate (RVVArgInfos[i]);
20986
+ for (unsigned i = 0; i < RVVArgInfos.size() ; ++i)
20987
+ allocate (RVVArgInfos[i]);
20992
20988
}
20993
20989
20994
20990
MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments