@@ -5805,7 +5805,7 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
5805
5805
assert(!Res && "Call operand has unhandled type");
5806
5806
(void)Res;
5807
5807
}
5808
- SmallVector<SDValue, 16> ArgValues;
5808
+
5809
5809
unsigned ExtraArgLocs = 0;
5810
5810
for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
5811
5811
CCValAssign &VA = ArgLocs[i - ExtraArgLocs];
@@ -6157,17 +6157,10 @@ void AArch64TargetLowering::saveVarArgRegisters(CCState &CCInfo,
6157
6157
/// appropriate copies out of appropriate physical registers.
6158
6158
SDValue AArch64TargetLowering::LowerCallResult(
6159
6159
SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg,
6160
- const SmallVectorImpl<ISD::InputArg > &Ins , const SDLoc &DL,
6160
+ const SmallVectorImpl<CCValAssign > &RVLocs , const SDLoc &DL,
6161
6161
SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals, bool isThisReturn,
6162
6162
SDValue ThisVal) const {
6163
- CCAssignFn *RetCC = CCAssignFnForReturn(CallConv);
6164
- // Assign locations to each value returned by this call.
6165
- SmallVector<CCValAssign, 16> RVLocs;
6166
6163
DenseMap<unsigned, SDValue> CopiedRegs;
6167
- CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), RVLocs,
6168
- *DAG.getContext());
6169
- CCInfo.AnalyzeCallResult(Ins, RetCC);
6170
-
6171
6164
// Copy all of the result registers out of their specified physreg.
6172
6165
for (unsigned i = 0; i != RVLocs.size(); ++i) {
6173
6166
CCValAssign VA = RVLocs[i];
@@ -6508,17 +6501,39 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
6508
6501
GuardWithBTI = FuncInfo->branchTargetEnforcement();
6509
6502
}
6510
6503
6504
+ // Analyze operands of the call, assigning locations to each operand.
6505
+ SmallVector<CCValAssign, 16> ArgLocs;
6506
+ CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
6507
+
6508
+ if (IsVarArg) {
6509
+ unsigned NumArgs = Outs.size();
6510
+
6511
+ for (unsigned i = 0; i != NumArgs; ++i) {
6512
+ if (!Outs[i].IsFixed && Outs[i].VT.isScalableVector())
6513
+ report_fatal_error("Passing SVE types to variadic functions is "
6514
+ "currently not supported");
6515
+ }
6516
+ }
6517
+
6518
+ analyzeCallOperands(*this, Subtarget, CLI, CCInfo);
6519
+
6520
+ CCAssignFn *RetCC = CCAssignFnForReturn(CallConv);
6521
+ // Assign locations to each value returned by this call.
6522
+ SmallVector<CCValAssign, 16> RVLocs;
6523
+ CCState RetCCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), RVLocs,
6524
+ *DAG.getContext());
6525
+ RetCCInfo.AnalyzeCallResult(Ins, RetCC);
6526
+
6511
6527
// Check callee args/returns for SVE registers and set calling convention
6512
6528
// accordingly.
6513
6529
if (CallConv == CallingConv::C || CallConv == CallingConv::Fast) {
6514
- bool CalleeOutSVE = any_of(Outs, [](ISD::OutputArg &Out){
6515
- return Out.VT.isScalableVector();
6516
- });
6517
- bool CalleeInSVE = any_of(Ins, [](ISD::InputArg &In){
6518
- return In.VT.isScalableVector();
6519
- });
6520
-
6521
- if (CalleeInSVE || CalleeOutSVE)
6530
+ auto HasSVERegLoc = [](CCValAssign &Loc) {
6531
+ if (!Loc.isRegLoc())
6532
+ return false;
6533
+ return AArch64::ZPRRegClass.contains(Loc.getLocReg()) ||
6534
+ AArch64::PPRRegClass.contains(Loc.getLocReg());
6535
+ };
6536
+ if (any_of(RVLocs, HasSVERegLoc) || any_of(ArgLocs, HasSVERegLoc))
6522
6537
CallConv = CallingConv::AArch64_SVE_VectorCall;
6523
6538
}
6524
6539
@@ -6540,22 +6555,6 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
6540
6555
report_fatal_error("failed to perform tail call elimination on a call "
6541
6556
"site marked musttail");
6542
6557
6543
- // Analyze operands of the call, assigning locations to each operand.
6544
- SmallVector<CCValAssign, 16> ArgLocs;
6545
- CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
6546
-
6547
- if (IsVarArg) {
6548
- unsigned NumArgs = Outs.size();
6549
-
6550
- for (unsigned i = 0; i != NumArgs; ++i) {
6551
- if (!Outs[i].IsFixed && Outs[i].VT.isScalableVector())
6552
- report_fatal_error("Passing SVE types to variadic functions is "
6553
- "currently not supported");
6554
- }
6555
- }
6556
-
6557
- analyzeCallOperands(*this, Subtarget, CLI, CCInfo);
6558
-
6559
6558
// Get a count of how many bytes are to be pushed on the stack.
6560
6559
unsigned NumBytes = CCInfo.getNextStackOffset();
6561
6560
@@ -6961,7 +6960,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
6961
6960
6962
6961
// Handle result values, copying them out of physregs into vregs that we
6963
6962
// return.
6964
- return LowerCallResult(Chain, InFlag, CallConv, IsVarArg, Ins , DL, DAG,
6963
+ return LowerCallResult(Chain, InFlag, CallConv, IsVarArg, RVLocs , DL, DAG,
6965
6964
InVals, IsThisReturn,
6966
6965
IsThisReturn ? OutVals[0] : SDValue());
6967
6966
}
0 commit comments