@@ -20531,7 +20531,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
2053120531 return Subtarget.getMinimumJumpTableEntries();
2053220532}
2053320533
20534- void RVVArgDispatcher::constructHelper (Type *Ty) {
20534+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
2053520535 const DataLayout &DL = MF->getDataLayout();
2053620536 const Function &F = MF->getFunction();
2053720537 LLVMContext &Context = F.getContext();
@@ -20564,16 +20564,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
2056420564 RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
2056520565
2056620566 RVVArgInfo Info{1, RegisterVT, false};
20567-
20568- while (NumRegs--)
20569- RVVArgInfos.push_back(Info);
20567+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
2057020568 }
2057120569 }
2057220570}
2057320571
20574- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20572+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
2057520573 for (Type *Ty : TypeList)
20576- constructHelper (Ty);
20574+ constructArgInfos (Ty);
2057720575
2057820576 for (auto &Info : RVVArgInfos)
2057920577 if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20608,28 +20606,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
2060820606 if (StartReg)
2060920607 AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
2061020608 else
20611- AllocatedPhysRegs.push_back(0 );
20609+ AllocatedPhysRegs.push_back(MCPhysReg() );
2061220610}
2061320611
20614- // This function determines if each RVV argument is passed by register.
20612+ /// This function determines if each RVV argument is passed by register, if the
20613+ /// argument can be assigned to a VR, then give it a specific register.
20614+ /// Otherwise, assign the argument to 0 which is a invalid MCPhysReg.
2061520615void RVVArgDispatcher::compute() {
20616- unsigned ToBeAssigned = RVVArgInfos.size();
20617- uint64_t AssignedMap = 0;
20618- auto tryAllocate = [&](const RVVArgInfo &ArgInfo) {
20616+ uint32_t AssignedMap = 0;
20617+ auto allocate = [&](const RVVArgInfo &ArgInfo) {
2061920618 // Allocate first vector mask argument to V0.
2062020619 if (ArgInfo.FirstVMask) {
2062120620 AllocatedPhysRegs.push_back(RISCV::V0);
2062220621 return;
2062320622 }
2062420623
20625- unsigned RegsNeeded =
20626- std::max((unsigned)ArgInfo.VT.getSizeInBits().getKnownMinValue() /
20627- RISCV::RVVBitsPerBlock,
20628- (unsigned)1);
20624+ unsigned RegsNeeded = divideCeil(
20625+ ArgInfo.VT.getSizeInBits().getKnownMinValue(), RISCV::RVVBitsPerBlock);
2062920626 unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
2063020627 for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
2063120628 StartReg += RegsNeeded) {
20632- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20629+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
2063320630 if ((AssignedMap & Map) == 0) {
2063420631 allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
2063520632 AssignedMap |= Map;
@@ -20638,11 +20635,10 @@ void RVVArgDispatcher::compute() {
2063820635 }
2063920636
2064020637 allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20641- return;
2064220638 };
2064320639
20644- for (unsigned i = 0; i < ToBeAssigned ; ++i)
20645- tryAllocate (RVVArgInfos[i]);
20640+ for (unsigned i = 0; i < RVVArgInfos.size() ; ++i)
20641+ allocate (RVVArgInfos[i]);
2064620642}
2064720643
2064820644MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments