@@ -20877,7 +20877,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
2087720877 return Subtarget.getMinimumJumpTableEntries();
2087820878}
2087920879
20880- void RVVArgDispatcher::constructHelper (Type *Ty) {
20880+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
2088120881 const DataLayout &DL = MF->getDataLayout();
2088220882 const Function &F = MF->getFunction();
2088320883 LLVMContext &Context = F.getContext();
@@ -20910,16 +20910,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
2091020910 RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
2091120911
2091220912 RVVArgInfo Info{1, RegisterVT, false};
20913-
20914- while (NumRegs--)
20915- RVVArgInfos.push_back(Info);
20913+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
2091620914 }
2091720915 }
2091820916}
2091920917
20920- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20918+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
2092120919 for (Type *Ty : TypeList)
20922- constructHelper (Ty);
20920+ constructArgInfos (Ty);
2092320921
2092420922 for (auto &Info : RVVArgInfos)
2092520923 if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20954,28 +20952,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
2095420952 if (StartReg)
2095520953 AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
2095620954 else
20957- AllocatedPhysRegs.push_back(0 );
20955+ AllocatedPhysRegs.push_back(MCPhysReg() );
2095820956}
2095920957
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.
2096120961void 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) {
2096520964 // Allocate first vector mask argument to V0.
2096620965 if (ArgInfo.FirstVMask) {
2096720966 AllocatedPhysRegs.push_back(RISCV::V0);
2096820967 return;
2096920968 }
2097020969
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);
2097520972 unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
2097620973 for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
2097720974 StartReg += RegsNeeded) {
20978- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20975+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
2097920976 if ((AssignedMap & Map) == 0) {
2098020977 allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
2098120978 AssignedMap |= Map;
@@ -20984,11 +20981,10 @@ void RVVArgDispatcher::compute() {
2098420981 }
2098520982
2098620983 allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20987- return;
2098820984 };
2098920985
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]);
2099220988}
2099320989
2099420990MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments