@@ -20524,7 +20524,7 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
20524
20524
return Subtarget.getMinimumJumpTableEntries();
20525
20525
}
20526
20526
20527
- void RVVArgDispatcher::constructHelper (Type *Ty) {
20527
+ void RVVArgDispatcher::constructArgInfos (Type *Ty) {
20528
20528
const DataLayout &DL = MF->getDataLayout();
20529
20529
const Function &F = MF->getFunction();
20530
20530
LLVMContext &Context = F.getContext();
@@ -20557,16 +20557,14 @@ void RVVArgDispatcher::constructHelper(Type *Ty) {
20557
20557
RegisterVT = TLI->getContainerForFixedLengthVector(RegisterVT);
20558
20558
20559
20559
RVVArgInfo Info{1, RegisterVT, false};
20560
-
20561
- while (NumRegs--)
20562
- RVVArgInfos.push_back(Info);
20560
+ RVVArgInfos.insert(RVVArgInfos.end(), NumRegs, Info);
20563
20561
}
20564
20562
}
20565
20563
}
20566
20564
20567
- void RVVArgDispatcher::construct(std::vector<Type *> &TypeList) {
20565
+ void RVVArgDispatcher::construct(const std::vector<Type *> &TypeList) {
20568
20566
for (Type *Ty : TypeList)
20569
- constructHelper (Ty);
20567
+ constructArgInfos (Ty);
20570
20568
20571
20569
for (auto &Info : RVVArgInfos)
20572
20570
if (Info.NF == 1 && Info.VT.getVectorElementType() == MVT::i1) {
@@ -20601,28 +20599,27 @@ void RVVArgDispatcher::allocatePhysReg(unsigned NF, unsigned LMul,
20601
20599
if (StartReg)
20602
20600
AllocatedPhysRegs.push_back(VRArrays[(StartReg - 8) / LMul + i]);
20603
20601
else
20604
- AllocatedPhysRegs.push_back(0 );
20602
+ AllocatedPhysRegs.push_back(MCPhysReg() );
20605
20603
}
20606
20604
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.
20608
20608
void 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) {
20612
20611
// Allocate first vector mask argument to V0.
20613
20612
if (ArgInfo.FirstVMask) {
20614
20613
AllocatedPhysRegs.push_back(RISCV::V0);
20615
20614
return;
20616
20615
}
20617
20616
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);
20622
20619
unsigned TotalRegsNeeded = ArgInfo.NF * RegsNeeded;
20623
20620
for (unsigned StartReg = 0; StartReg + TotalRegsNeeded <= NumArgVRs;
20624
20621
StartReg += RegsNeeded) {
20625
- unsigned Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20622
+ uint32_t Map = ((1 << TotalRegsNeeded) - 1) << StartReg;
20626
20623
if ((AssignedMap & Map) == 0) {
20627
20624
allocatePhysReg(ArgInfo.NF, RegsNeeded, StartReg + 8);
20628
20625
AssignedMap |= Map;
@@ -20631,11 +20628,10 @@ void RVVArgDispatcher::compute() {
20631
20628
}
20632
20629
20633
20630
allocatePhysReg(ArgInfo.NF, RegsNeeded, 0);
20634
- return;
20635
20631
};
20636
20632
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]);
20639
20635
}
20640
20636
20641
20637
MCPhysReg RVVArgDispatcher::getNextPhysReg() {
0 commit comments