@@ -19122,17 +19122,16 @@ static bool CC_RISCVAssign2XLen(unsigned XLen, CCState &State, CCValAssign VA1,
1912219122 return false;
1912319123}
1912419124
19125- static MCRegister allocateRVVReg(MVT ValVT, unsigned ValNo,
19126- std::optional<unsigned> FirstMaskArgument,
19127- CCState &State,
19125+ static MCRegister allocateRVVReg(MVT ValVT, unsigned ValNo, CCState &State,
1912819126 const RISCVTargetLowering &TLI) {
1912919127 const TargetRegisterClass *RC = TLI.getRegClassFor(ValVT);
1913019128 if (RC == &RISCV::VRRegClass) {
1913119129 // Assign the first mask argument to V0.
1913219130 // This is an interim calling convention and it may be changed in the
1913319131 // future.
19134- if (FirstMaskArgument && ValNo == *FirstMaskArgument)
19135- return State.AllocateReg(RISCV::V0);
19132+ if (ValVT.getVectorElementType() == MVT::i1)
19133+ if (MCRegister Reg = State.AllocateReg(RISCV::V0))
19134+ return Reg;
1913619135 return State.AllocateReg(ArgVRs);
1913719136 }
1913819137 if (RC == &RISCV::VRM2RegClass)
@@ -19170,8 +19169,7 @@ static MCRegister allocateRVVReg(MVT ValVT, unsigned ValNo,
1917019169bool RISCV::CC_RISCV(const DataLayout &DL, RISCVABI::ABI ABI, unsigned ValNo,
1917119170 MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo,
1917219171 ISD::ArgFlagsTy ArgFlags, CCState &State, bool IsFixed,
19173- bool IsRet, Type *OrigTy, const RISCVTargetLowering &TLI,
19174- std::optional<unsigned> FirstMaskArgument) {
19172+ bool IsRet, Type *OrigTy, const RISCVTargetLowering &TLI) {
1917519173 unsigned XLen = DL.getLargestLegalIntTypeSizeInBits();
1917619174 assert(XLen == 32 || XLen == 64);
1917719175 MVT XLenVT = XLen == 32 ? MVT::i32 : MVT::i64;
@@ -19351,7 +19349,7 @@ bool RISCV::CC_RISCV(const DataLayout &DL, RISCVABI::ABI ABI, unsigned ValNo,
1935119349 else if (ValVT == MVT::f64 && !UseGPRForF64)
1935219350 Reg = State.AllocateReg(ArgFPR64s);
1935319351 else if (ValVT.isVector() || ValVT.isRISCVVectorTuple()) {
19354- Reg = allocateRVVReg(ValVT, ValNo, FirstMaskArgument, State, TLI);
19352+ Reg = allocateRVVReg(ValVT, ValNo, State, TLI);
1935519353 if (!Reg) {
1935619354 // For return values, the vector must be passed fully via registers or
1935719355 // via the stack.
@@ -19421,27 +19419,13 @@ bool RISCV::CC_RISCV(const DataLayout &DL, RISCVABI::ABI ABI, unsigned ValNo,
1942119419 return false;
1942219420}
1942319421
19424- template <typename ArgTy>
19425- static std::optional<unsigned> preAssignMask(const ArgTy &Args) {
19426- for (const auto &ArgIdx : enumerate(Args)) {
19427- MVT ArgVT = ArgIdx.value().VT;
19428- if (ArgVT.isVector() && ArgVT.getVectorElementType() == MVT::i1)
19429- return ArgIdx.index();
19430- }
19431- return std::nullopt;
19432- }
19433-
1943419422void RISCVTargetLowering::analyzeInputArgs(
1943519423 MachineFunction &MF, CCState &CCInfo,
1943619424 const SmallVectorImpl<ISD::InputArg> &Ins, bool IsRet,
1943719425 RISCVCCAssignFn Fn) const {
1943819426 unsigned NumArgs = Ins.size();
1943919427 FunctionType *FType = MF.getFunction().getFunctionType();
1944019428
19441- std::optional<unsigned> FirstMaskArgument;
19442- if (Subtarget.hasVInstructions())
19443- FirstMaskArgument = preAssignMask(Ins);
19444-
1944519429 for (unsigned i = 0; i != NumArgs; ++i) {
1944619430 MVT ArgVT = Ins[i].VT;
1944719431 ISD::ArgFlagsTy ArgFlags = Ins[i].Flags;
@@ -19454,8 +19438,7 @@ void RISCVTargetLowering::analyzeInputArgs(
1945419438
1945519439 RISCVABI::ABI ABI = MF.getSubtarget<RISCVSubtarget>().getTargetABI();
1945619440 if (Fn(MF.getDataLayout(), ABI, i, ArgVT, ArgVT, CCValAssign::Full,
19457- ArgFlags, CCInfo, /*IsFixed=*/true, IsRet, ArgTy, *this,
19458- FirstMaskArgument)) {
19441+ ArgFlags, CCInfo, /*IsFixed=*/true, IsRet, ArgTy, *this)) {
1945919442 LLVM_DEBUG(dbgs() << "InputArg #" << i << " has unhandled type "
1946019443 << ArgVT << '\n');
1946119444 llvm_unreachable(nullptr);
@@ -19469,19 +19452,14 @@ void RISCVTargetLowering::analyzeOutputArgs(
1946919452 CallLoweringInfo *CLI, RISCVCCAssignFn Fn) const {
1947019453 unsigned NumArgs = Outs.size();
1947119454
19472- std::optional<unsigned> FirstMaskArgument;
19473- if (Subtarget.hasVInstructions())
19474- FirstMaskArgument = preAssignMask(Outs);
19475-
1947619455 for (unsigned i = 0; i != NumArgs; i++) {
1947719456 MVT ArgVT = Outs[i].VT;
1947819457 ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
1947919458 Type *OrigTy = CLI ? CLI->getArgs()[Outs[i].OrigArgIndex].Ty : nullptr;
1948019459
1948119460 RISCVABI::ABI ABI = MF.getSubtarget<RISCVSubtarget>().getTargetABI();
1948219461 if (Fn(MF.getDataLayout(), ABI, i, ArgVT, ArgVT, CCValAssign::Full,
19483- ArgFlags, CCInfo, Outs[i].IsFixed, IsRet, OrigTy, *this,
19484- FirstMaskArgument)) {
19462+ ArgFlags, CCInfo, Outs[i].IsFixed, IsRet, OrigTy, *this)) {
1948519463 LLVM_DEBUG(dbgs() << "OutputArg #" << i << " has unhandled type "
1948619464 << ArgVT << "\n");
1948719465 llvm_unreachable(nullptr);
@@ -19659,8 +19637,7 @@ bool RISCV::CC_RISCV_FastCC(const DataLayout &DL, RISCVABI::ABI ABI,
1965919637 CCValAssign::LocInfo LocInfo,
1966019638 ISD::ArgFlagsTy ArgFlags, CCState &State,
1966119639 bool IsFixed, bool IsRet, Type *OrigTy,
19662- const RISCVTargetLowering &TLI,
19663- std::optional<unsigned> FirstMaskArgument) {
19640+ const RISCVTargetLowering &TLI) {
1966419641 if (LocVT == MVT::i32 || LocVT == MVT::i64) {
1966519642 if (MCRegister Reg = State.AllocateReg(getFastCCArgGPRs(ABI))) {
1966619643 State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
@@ -19744,8 +19721,7 @@ bool RISCV::CC_RISCV_FastCC(const DataLayout &DL, RISCVABI::ABI ABI,
1974419721 }
1974519722
1974619723 if (LocVT.isVector()) {
19747- if (MCRegister Reg =
19748- allocateRVVReg(ValVT, ValNo, FirstMaskArgument, State, TLI)) {
19724+ if (MCRegister Reg = allocateRVVReg(ValVT, ValNo, State, TLI)) {
1974919725 // Fixed-length vectors are located in the corresponding scalable-vector
1975019726 // container types.
1975119727 if (ValVT.isFixedLengthVector())
@@ -20377,17 +20353,13 @@ bool RISCVTargetLowering::CanLowerReturn(
2037720353 SmallVector<CCValAssign, 16> RVLocs;
2037820354 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
2037920355
20380- std::optional<unsigned> FirstMaskArgument;
20381- if (Subtarget.hasVInstructions())
20382- FirstMaskArgument = preAssignMask(Outs);
20383-
2038420356 for (unsigned i = 0, e = Outs.size(); i != e; ++i) {
2038520357 MVT VT = Outs[i].VT;
2038620358 ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
2038720359 RISCVABI::ABI ABI = MF.getSubtarget<RISCVSubtarget>().getTargetABI();
2038820360 if (RISCV::CC_RISCV(MF.getDataLayout(), ABI, i, VT, VT, CCValAssign::Full,
2038920361 ArgFlags, CCInfo, /*IsFixed=*/true, /*IsRet=*/true,
20390- nullptr, *this, FirstMaskArgument ))
20362+ nullptr, *this))
2039120363 return false;
2039220364 }
2039320365 return true;
0 commit comments