@@ -20531,7 +20531,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
20531
20531
return Subtarget.getMinimumJumpTableEntries();
20532
20532
}
20533
20533
20534
- void RVVArgDispatcher::constructHelper (Type *Ty) {
20534
+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
20535
20535
const DataLayout &DL = MF->getDataLayout();
20536
20536
const Function &F = MF->getFunction();
20537
20537
LLVMContext &Context = F.getContext();
@@ -20564,16 +20564,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
20564
20564
RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
20565
20565
20566
20566
RVVArgInfo Info{1, RegisterVT, false};
20567
-
20568
- while (NumRegs--)
20569
- RVVArgInfos.push_back(Info);
20567
+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
20570
20568
}
20571
20569
}
20572
20570
}
20573
20571
20574
- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20572
+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
20575
20573
for (Type *Ty : TypeList)
20576
- constructHelper (Ty);
20574
+ constructArgInfos (Ty);
20577
20575
20578
20576
for (auto &Info : RVVArgInfos)
20579
20577
if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20608,28 +20606,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
20608
20606
if (StartReg)
20609
20607
AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
20610
20608
else
20611
- AllocatedPhysRegs.push_back(0 );
20609
+ AllocatedPhysRegs.push_back(MCPhysReg() );
20612
20610
}
20613
20611
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.
20615
20615
void 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) {
20619
20618
// Allocate first vector mask argument to V0.
20620
20619
if (ArgInfo.FirstVMask) {
20621
20620
AllocatedPhysRegs.push_back(RISCV::V0);
20622
20621
return;
20623
20622
}
20624
20623
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);
20629
20626
unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
20630
20627
for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
20631
20628
StartReg += RegsNeeded) {
20632
- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20629
+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20633
20630
if ((AssignedMap & Map) == 0) {
20634
20631
allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
20635
20632
AssignedMap |= Map;
@@ -20638,11 +20635,10 @@ void RVVArgDispatcher::compute() {
20638
20635
}
20639
20636
20640
20637
allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20641
- return;
20642
20638
};
20643
20639
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]);
20646
20642
}
20647
20643
20648
20644
MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments