@@ -20524,7 +20524,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
2052420524 return Subtarget.getMinimumJumpTableEntries();
2052520525}
2052620526
20527- void RVVArgDispatcher::constructHelper (Type *Ty) {
20527+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
2052820528 const DataLayout &DL = MF->getDataLayout();
2052920529 const Function &F = MF->getFunction();
2053020530 LLVMContext &Context = F.getContext();
@@ -20557,16 +20557,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
2055720557 RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
2055820558
2055920559 RVVArgInfo Info{1, RegisterVT, false};
20560-
20561- while (NumRegs--)
20562- RVVArgInfos.push_back(Info);
20560+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
2056320561 }
2056420562 }
2056520563}
2056620564
20567- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20565+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
2056820566 for (Type *Ty : TypeList)
20569- constructHelper (Ty);
20567+ constructArgInfos (Ty);
2057020568
2057120569 for (auto &Info : RVVArgInfos)
2057220570 if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20601,28 +20599,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
2060120599 if (StartReg)
2060220600 AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
2060320601 else
20604- AllocatedPhysRegs.push_back(0 );
20602+ AllocatedPhysRegs.push_back(MCPhysReg() );
2060520603}
2060620604
20607- // This function determines if each RVV argument is passed by register.
20605+ /// This function determines if each RVV argument is passed by register, if the
20606+ /// argument can be assigned to a VR, then give it a specific register.
20607+ /// Otherwise, assign the argument to 0 which is a invalid MCPhysReg.
2060820608void RVVArgDispatcher::compute() {
20609- unsigned ToBeAssigned = RVVArgInfos.size();
20610- uint64_t AssignedMap = 0;
20611- auto tryAllocate = [&](const RVVArgInfo &ArgInfo) {
20609+ uint32_t AssignedMap = 0;
20610+ auto allocate = [&](const RVVArgInfo &ArgInfo) {
2061220611 // Allocate first vector mask argument to V0.
2061320612 if (ArgInfo.FirstVMask) {
2061420613 AllocatedPhysRegs.push_back(RISCV::V0);
2061520614 return;
2061620615 }
2061720616
20618- unsigned RegsNeeded =
20619- std::max((unsigned)ArgInfo.VT.getSizeInBits().getKnownMinValue() /
20620- RISCV::RVVBitsPerBlock,
20621- (unsigned)1);
20617+ unsigned RegsNeeded = divideCeil(
20618+ ArgInfo.VT.getSizeInBits().getKnownMinValue(), RISCV::RVVBitsPerBlock);
2062220619 unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
2062320620 for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
2062420621 StartReg += RegsNeeded) {
20625- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20622+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
2062620623 if ((AssignedMap & Map) == 0) {
2062720624 allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
2062820625 AssignedMap |= Map;
@@ -20631,11 +20628,10 @@ void RVVArgDispatcher::compute() {
2063120628 }
2063220629
2063320630 allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20634- return;
2063520631 };
2063620632
20637- for (unsigned i = 0; i < ToBeAssigned ; ++i)
20638- tryAllocate (RVVArgInfos[i]);
20633+ for (unsigned i = 0; i < RVVArgInfos.size() ; ++i)
20634+ allocate (RVVArgInfos[i]);
2063920635}
2064020636
2064120637MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments