Index: include/llvm/CodeGen/CallingConvLower.h =================================================================== --- include/llvm/CodeGen/CallingConvLower.h +++ include/llvm/CodeGen/CallingConvLower.h @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/SelectionDAGNodes.h" #include "llvm/CodeGen/TargetCallingConv.h" #include "llvm/IR/CallingConv.h" #include "llvm/MC/MCRegisterInfo.h" @@ -191,11 +192,13 @@ private: CallingConv::ID CallingConv; bool IsVarArg; + bool IsCCSplit = false; bool AnalyzingMustTailForwardedRegs = false; MachineFunction &MF; const TargetRegisterInfo &TRI; SmallVectorImpl &Locs; LLVMContext &Context; + MVT CCSplitType; unsigned StackOffset; unsigned MaxStackArgAlign; @@ -265,6 +268,11 @@ MachineFunction &getMachineFunction() const { return MF; } CallingConv::ID getCallingConv() const { return CallingConv; } bool isVarArg() const { return IsVarArg; } + bool isCCSplit() const { return IsCCSplit; } + void setCCSplit() { IsCCSplit = true; } + void resetCCSplit() { IsCCSplit = false; } + void setCCSplitType(MVT T) { CCSplitType = T; } + MVT getCCSplitType() { return CCSplitType; } /// getNextStackOffset - Return the next stack offset such that all stack /// slots satisfy their alignment requirements. @@ -285,14 +293,21 @@ return UsedRegs[Reg/32] & (1 << (Reg&31)); } + /// SplitOutputArg - Split Ins for supporting CCAssignToRegWithType. + void SplitInputArg(SmallVectorImpl &Ins, unsigned SplitArg); + + /// SplitOutputArg - Split Outs and OutVals for supporting + /// CCAssignToRegWithType. + void SplitOutputArg(SelectionDAG &DAG, SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, unsigned SplitArg); + /// AnalyzeFormalArguments - Analyze an array of argument values, /// incorporating info about the formals into this state. - void AnalyzeFormalArguments(const SmallVectorImpl &Ins, + void AnalyzeFormalArguments(SmallVectorImpl &Ins, CCAssignFn Fn); /// The function will invoke AnalyzeFormalArguments. - void AnalyzeArguments(const SmallVectorImpl &Ins, - CCAssignFn Fn) { + void AnalyzeArguments(SmallVectorImpl &Ins, CCAssignFn Fn) { AnalyzeFormalArguments(Ins, Fn); } @@ -301,6 +316,11 @@ void AnalyzeReturn(const SmallVectorImpl &Outs, CCAssignFn Fn); + /// AnalyzeReturn - Same as above except it takes DAG and + /// OutVals for supporting CCAssignToRegWithType. + void AnalyzeReturn(SelectionDAG &DAG, SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, CCAssignFn Fn); + /// CheckReturn - Analyze the return values of a function, returning /// true if the return can be performed without sret-demotion, and /// false otherwise. @@ -318,6 +338,12 @@ SmallVectorImpl &Flags, CCAssignFn Fn); + /// AnalyzeCallOperands - Same as above except it takes DAG and + /// OutVals for supporting CCAssignToRegWithType. + void AnalyzeCallOperands(SelectionDAG &DAG, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, CCAssignFn Fn); + /// The function will invoke AnalyzeCallOperands. void AnalyzeArguments(const SmallVectorImpl &Outs, CCAssignFn Fn) { @@ -329,6 +355,11 @@ void AnalyzeCallResult(const SmallVectorImpl &Ins, CCAssignFn Fn); + /// AnalyzeCallResult - Same as above except it's Ins may split + /// accroding to CCAssignToRegWithReg. + void AnalyzeCallResult(SmallVectorImpl &Ins, + CCAssignFn Fn); + /// A shadow allocated register is a register that was allocated /// but wasn't added to the location list (Locs). /// \returns true if the register was allocated as shadow or false otherwise. Index: include/llvm/CodeGen/TargetLowering.h =================================================================== --- include/llvm/CodeGen/TargetLowering.h +++ include/llvm/CodeGen/TargetLowering.h @@ -2888,7 +2888,7 @@ /// return the resulting token chain value. virtual SDValue LowerFormalArguments( SDValue /*Chain*/, CallingConv::ID /*CallConv*/, bool /*isVarArg*/, - const SmallVectorImpl & /*Ins*/, const SDLoc & /*dl*/, + SmallVectorImpl & /*Ins*/, const SDLoc & /*dl*/, SelectionDAG & /*DAG*/, SmallVectorImpl & /*InVals*/) const { llvm_unreachable("Not Implemented"); } @@ -3085,8 +3085,8 @@ /// return the resulting token chain value. virtual SDValue LowerReturn(SDValue /*Chain*/, CallingConv::ID /*CallConv*/, bool /*isVarArg*/, - const SmallVectorImpl & /*Outs*/, - const SmallVectorImpl & /*OutVals*/, + SmallVectorImpl & /*Outs*/, + SmallVectorImpl & /*OutVals*/, const SDLoc & /*dl*/, SelectionDAG & /*DAG*/) const { llvm_unreachable("Not Implemented"); Index: include/llvm/Target/TargetCallingConv.td =================================================================== --- include/llvm/Target/TargetCallingConv.td +++ include/llvm/Target/TargetCallingConv.td @@ -90,6 +90,17 @@ list RegList = regList; } +/// CCAssignToRegWithType - Same as CCAssignToReg, but split the argument to +/// multiple destTy type arguments if the first part of destTy assigns to the +/// register successfully. The original type size must be multiple of desTy +/// type size. The target have to call AnalyzeCallOperands and AnalyzeReturn +/// with DAG and OutVals parameters to support the feature. +class CCAssignToRegWithType regList> : CCAction { + list RegList = regList; + ValueType DestTy = destTy; +} + /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers /// which became shadowed, when some register is used. class CCAssignToRegWithShadow regList, Index: lib/CodeGen/CallingConvLower.cpp =================================================================== --- lib/CodeGen/CallingConvLower.cpp +++ lib/CodeGen/CallingConvLower.cpp @@ -81,11 +81,31 @@ return true; } +void CCState::SplitInputArg(SmallVectorImpl &Ins, + unsigned SplitArg) { + SmallVector TmpIns; + MVT OriVT = Ins[SplitArg].VT; + MVT SplitVT = this->getCCSplitType(); + unsigned SplitNum = OriVT.getSizeInBits() / SplitVT.getSizeInBits(); + unsigned NumArgs = Ins.size(); + + for (unsigned i = 0; i != NumArgs; ++i) { + if (i == SplitArg) { + Ins[i].VT = SplitVT; + for (unsigned j = 0; j != SplitNum; ++j) { + TmpIns.push_back(Ins[i]); + } + } else { + TmpIns.push_back(Ins[i]); + } + } + Ins = TmpIns; +} + /// Analyze an array of argument values, /// incorporating info about the formals into this state. -void -CCState::AnalyzeFormalArguments(const SmallVectorImpl &Ins, - CCAssignFn Fn) { +void CCState::AnalyzeFormalArguments(SmallVectorImpl &Ins, + CCAssignFn Fn) { unsigned NumArgs = Ins.size(); for (unsigned i = 0; i != NumArgs; ++i) { @@ -98,6 +118,11 @@ #endif llvm_unreachable(nullptr); } + if (this->isCCSplit()) { + SplitInputArg(Ins, i); + this->resetCCSplit(); + NumArgs = Ins.size(); + } } } @@ -133,6 +158,32 @@ } } +/// AnalyzeReturn - Same as above except it takes DAG and +/// OutVals for supporting CCAssignToRegWithType. +void CCState::AnalyzeReturn(SelectionDAG &DAG, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, + CCAssignFn Fn) { + + // Determine which register each value should be copied into. + for (unsigned i = 0, e = Outs.size(); i != e; ++i) { + MVT VT = Outs[i].VT; + ISD::ArgFlagsTy ArgFlags = Outs[i].Flags; + if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)) { +#ifndef NDEBUG + dbgs() << "Return operand #" << i << " has unhandled type " + << EVT(VT).getEVTString() << '\n'; +#endif + llvm_unreachable(nullptr); + } + if (this->isCCSplit()) { + SplitOutputArg(DAG, Outs, OutVals, i); + this->resetCCSplit(); + e = Outs.size(); + } + } +} + /// Analyze the outgoing arguments to a call, /// incorporating info about the passed values into this state. void CCState::AnalyzeCallOperands(const SmallVectorImpl &Outs, @@ -169,6 +220,88 @@ } } +void CCState::SplitOutputArg(SelectionDAG &DAG, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, + unsigned SplitArg) { + SmallVector TmpOuts; + SmallVector TmpOutVals; + MVT OriVT = Outs[SplitArg].VT; + MVT SplitVT = this->getCCSplitType(); + unsigned OriTypeSize = OriVT.getSizeInBits(); + unsigned SplitTypeSize = SplitVT.getSizeInBits(); + unsigned SplitNum = OriTypeSize / SplitTypeSize; + unsigned NumArgs = Outs.size(); + SDLoc DL; + SDValue Part, OriVal; + + assert(OriTypeSize > SplitTypeSize && + "OriTypeSize should be bigger than SplitTypeSize"); + assert(OriTypeSize % SplitTypeSize == 0 && + "OriTypeSize should be multiple of SplitTypeSize"); + + for (unsigned i = 0; i != NumArgs; ++i) { + // The argument should split. + if (i == SplitArg) { + Outs[i].VT = SplitVT; + DL = SDLoc(OutVals[i]); + + // Bit cast the floating or vector type to integer type for generate + // EXTRACT_ELEMENT SDValue. + if (OriVT.isFloatingPoint() || OriVT.isVector()) { + EVT ValueVT = + EVT::getIntegerVT(*DAG.getContext(), OriVT.getSizeInBits()); + OriVal = DAG.getNode(ISD::BITCAST, DL, ValueVT, OutVals[i]); + } + for (unsigned j = 0; j != SplitNum; ++j) { + // Push split ISD::OutputArg. + TmpOuts.push_back(Outs[i]); + EVT ThisVT = + EVT::getIntegerVT(*DAG.getContext(), SplitVT.getSizeInBits()); + // Generate EXTRACT_ELEMENT to extract split argument SDValue. + Part = DAG.getNode(ISD::EXTRACT_ELEMENT, DL, ThisVT, OriVal, + DAG.getIntPtrConstant(j, DL)); + // Cast to SplitVT type. + Part = DAG.getNode(ISD::BITCAST, DL, SplitVT, Part); + // Push split Output SDValue. + TmpOutVals.push_back(Part); + } + if (DAG.getDataLayout().isBigEndian()) + std::reverse(&TmpOutVals[i], &TmpOutVals[i] + SplitNum); + } else { + TmpOuts.push_back(Outs[i]); + TmpOutVals.push_back(OutVals[i]); + } + } + Outs = TmpOuts; + OutVals = TmpOutVals; +} + +/// AnalyzeCallOperands - Same as above AnalyzeCallOperands +/// except it takes DAG and OutVals for supporting CCSplitToType. +void CCState::AnalyzeCallOperands(SelectionDAG &DAG, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, + CCAssignFn Fn) { + unsigned NumOps = Outs.size(); + for (unsigned i = 0; i != NumOps; ++i) { + MVT ArgVT = Outs[i].VT; + ISD::ArgFlagsTy ArgFlags = Outs[i].Flags; + if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) { +#ifndef NDEBUG + dbgs() << "Call operand #" << i << " has unhandled type " + << EVT(ArgVT).getEVTString() << '\n'; +#endif + llvm_unreachable(nullptr); + } + if (this->isCCSplit()) { + SplitOutputArg(DAG, Outs, OutVals, i); + this->resetCCSplit(); + NumOps = Outs.size(); + } + } +} + /// Analyze the return values of a call, incorporating info about the passed /// values into this state. void CCState::AnalyzeCallResult(const SmallVectorImpl &Ins, @@ -186,6 +319,27 @@ } } +/// Same as above except it's Ins may split according to CCAssignToRegWith. +void CCState::AnalyzeCallResult(SmallVectorImpl &Ins, + CCAssignFn Fn) { + for (unsigned i = 0, e = Ins.size(); i != e; ++i) { + MVT VT = Ins[i].VT; + ISD::ArgFlagsTy Flags = Ins[i].Flags; + if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) { +#ifndef NDEBUG + dbgs() << "Call result #" << i << " has unhandled type " + << EVT(VT).getEVTString() << '\n'; +#endif + llvm_unreachable(nullptr); + } + if (this->isCCSplit()) { + SplitInputArg(Ins, i); + this->resetCCSplit(); + e = Ins.size(); + } + } +} + /// Same as above except it's specialized for calls that produce a single value. void CCState::AnalyzeCallResult(MVT VT, CCAssignFn Fn) { if (Fn(0, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) { Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -8026,6 +8026,44 @@ setValue(&I, Res); } +// isInsSplitByCC - The function return true if the Ins have been split +// by CCState::SplitInputArg, and calculate SplitNum, SplitType of the +// split result. +static bool isInsSplitByCC(SmallVectorImpl &ValueVT, + SmallVectorImpl &Ins, + MVT &SplitType, + unsigned &SplitNum, + unsigned CurIndex) { + unsigned CurTypeSize = ValueVT[CurIndex].getSizeInBits(); + unsigned InsTypeSizeSum = 0, PrevTypeSize = 0; + unsigned InsTypeSize; + + for (unsigned I = 0; I != CurIndex; ++I) { + PrevTypeSize += ValueVT[I].getSizeInBits(); + } + + // Scan Ins to find Ins[I] mapping to ValueVT[CurIndex] + for (unsigned I = 0, E = Ins.size(); I != E; ++I) { + InsTypeSize = Ins[I].VT.getSizeInBits(); + // Find the Ins[I] mapping to ValueVT[CurIndex] + // if (ValueVT[0].getSizeInBits() + .. + + // ValueVT[CurIndex - 1].getSizeInBits() == + // Ins[0].VT.getSizeInBits() + .. + Ins[I - 1].VT.getSizeInBits()) + if (PrevTypeSize == InsTypeSizeSum) { + if (CurTypeSize > InsTypeSize) { + SplitType = Ins[I].VT; + SplitNum = CurTypeSize / InsTypeSize; + if (CurTypeSize % InsTypeSize) + ++SplitNum; + return true; + } + } else { + InsTypeSizeSum += InsTypeSize; + } + } + return false; +} + /// Returns an AttributeList representing the attributes applied to the return /// value of the given call. static AttributeList getReturnAttrs(TargetLowering::CallLoweringInfo &CLI) { @@ -8363,6 +8401,10 @@ unsigned NumRegs = getNumRegistersForCallingConv(CLI.RetTy->getContext(), VT); + // Update NumRegs and RegisterVT if Ins have been split by + // CCState::SplitInputArg. + isInsSplitByCC(RetTys, CLI.Ins, RegisterVT, NumRegs, I); + ReturnValues.push_back(getCopyFromParts(CLI.DAG, CLI.DL, &InVals[CurReg], NumRegs, RegisterVT, VT, nullptr, AssertOp, true)); @@ -8830,6 +8872,16 @@ unsigned NumParts = TLI->getNumRegistersForCallingConv(*CurDAG->getContext(), VT); + // Ins type size will not equal to VT type size if Ins have been split + // by CCState::SplitInputArg. Update PartVT and NumParts for this case. + if (VT.getSizeInBits() > Ins[i].VT.getSizeInBits()) { + PartVT = Ins[i].VT; + NumParts = VT.getSizeInBits() / Ins[i].VT.getSizeInBits(); + + if (VT.getSizeInBits() % Ins[i].VT.getSizeInBits()) + ++NumParts; + } + // Even an apparant 'unused' swifterror argument needs to be returned. So // we do generate a copy for it that can be used on return from the // function. Index: lib/Target/AArch64/AArch64ISelLowering.h =================================================================== --- lib/Target/AArch64/AArch64ISelLowering.h +++ lib/Target/AArch64/AArch64ISelLowering.h @@ -488,7 +488,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -527,8 +527,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; SDValue getTargetNode(GlobalAddressSDNode *N, EVT Ty, SelectionDAG &DAG, Index: lib/Target/AArch64/AArch64ISelLowering.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelLowering.cpp +++ lib/Target/AArch64/AArch64ISelLowering.cpp @@ -2727,7 +2727,7 @@ SDValue AArch64TargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -3596,8 +3596,8 @@ SDValue AArch64TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { CCAssignFn *RetCC = CallConv == CallingConv::WebKit_JS ? RetCC_AArch64_WebKit_JS Index: lib/Target/AMDGPU/AMDGPUISelLowering.h =================================================================== --- lib/Target/AMDGPU/AMDGPUISelLowering.h +++ lib/Target/AMDGPU/AMDGPUISelLowering.h @@ -172,8 +172,8 @@ static CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg); SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; SDValue addTokenForArgument(SDValue Chain, Index: lib/Target/AMDGPU/AMDGPUISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1003,8 +1003,8 @@ SDValue AMDGPUTargetLowering::LowerReturn( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // FIXME: Fails for r600 tests //assert(!isVarArg && Outs.empty() && OutVals.empty() && Index: lib/Target/AMDGPU/R600ISelLowering.h =================================================================== --- lib/Target/AMDGPU/R600ISelLowering.h +++ lib/Target/AMDGPU/R600ISelLowering.h @@ -38,7 +38,7 @@ SelectionDAG &DAG) const override; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; EVT getSetCCResultType(const DataLayout &DL, LLVMContext &, Index: lib/Target/AMDGPU/R600ISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/R600ISelLowering.cpp +++ lib/Target/AMDGPU/R600ISelLowering.cpp @@ -1544,7 +1544,7 @@ /// separate calling conventions for kernel and non-kernel functions. SDValue R600TargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { SmallVector ArgLocs; CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), ArgLocs, Index: lib/Target/AMDGPU/SIISelLowering.h =================================================================== --- lib/Target/AMDGPU/SIISelLowering.h +++ lib/Target/AMDGPU/SIISelLowering.h @@ -203,7 +203,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -213,8 +213,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; void passSpecialInputs( Index: lib/Target/AMDGPU/SIISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/SIISelLowering.cpp +++ lib/Target/AMDGPU/SIISelLowering.cpp @@ -1679,7 +1679,7 @@ SDValue SITargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { const SIRegisterInfo *TRI = getSubtarget()->getRegisterInfo(); @@ -1950,8 +1950,8 @@ SDValue SITargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); SIMachineFunctionInfo *Info = MF.getInfo(); Index: lib/Target/ARC/ARCISelLowering.h =================================================================== --- lib/Target/ARC/ARCISelLowering.h +++ lib/Target/ARC/ARCISelLowering.h @@ -96,7 +96,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -104,8 +104,8 @@ SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &dl, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, Index: lib/Target/ARC/ARCISelLowering.cpp =================================================================== --- lib/Target/ARC/ARCISelLowering.cpp +++ lib/Target/ARC/ARCISelLowering.cpp @@ -431,7 +431,7 @@ /// ARC formal arguments implementation SDValue ARCTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { default: @@ -605,8 +605,8 @@ SDValue ARCTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { auto *AFI = DAG.getMachineFunction().getInfo(); MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); Index: lib/Target/ARM/ARMISelLowering.h =================================================================== --- lib/Target/ARM/ARMISelLowering.h +++ lib/Target/ARM/ARMISelLowering.h @@ -707,7 +707,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -746,8 +746,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override; Index: lib/Target/ARM/ARMISelLowering.cpp =================================================================== --- lib/Target/ARM/ARMISelLowering.cpp +++ lib/Target/ARM/ARMISelLowering.cpp @@ -2437,8 +2437,8 @@ SDValue ARMTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of the return value to a location. SmallVector RVLocs; @@ -3577,7 +3577,7 @@ SDValue ARMTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); Index: lib/Target/AVR/AVRISelLowering.h =================================================================== --- lib/Target/AVR/AVRISelLowering.h +++ lib/Target/AVR/AVRISelLowering.h @@ -148,12 +148,12 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &dl, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, Index: lib/Target/AVR/AVRISelLowering.cpp =================================================================== --- lib/Target/AVR/AVRISelLowering.cpp +++ lib/Target/AVR/AVRISelLowering.cpp @@ -1028,7 +1028,7 @@ SDValue AVRTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -1350,8 +1350,8 @@ SDValue AVRTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of the return value to locations. SmallVector RVLocs; Index: lib/Target/BPF/BPFISelLowering.h =================================================================== --- lib/Target/BPF/BPFISelLowering.h +++ lib/Target/BPF/BPFISelLowering.h @@ -81,13 +81,13 @@ // Lower incoming arguments, copy physregs into vregs SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, Index: lib/Target/BPF/BPFISelLowering.cpp =================================================================== --- lib/Target/BPF/BPFISelLowering.cpp +++ lib/Target/BPF/BPFISelLowering.cpp @@ -173,7 +173,7 @@ SDValue BPFTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { default: @@ -370,8 +370,8 @@ SDValue BPFTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { unsigned Opc = BPFISD::RET_FLAG; Index: lib/Target/Hexagon/HexagonISelLowering.h =================================================================== --- lib/Target/Hexagon/HexagonISelLowering.h +++ lib/Target/Hexagon/HexagonISelLowering.h @@ -144,7 +144,7 @@ SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const; @@ -183,8 +183,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool mayBeEmittedAsTailCall(const CallInst *CI) const override; Index: lib/Target/Hexagon/HexagonISelLowering.cpp =================================================================== --- lib/Target/Hexagon/HexagonISelLowering.cpp +++ lib/Target/Hexagon/HexagonISelLowering.cpp @@ -572,8 +572,8 @@ SDValue HexagonTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of the return value to locations. SmallVector RVLocs; @@ -1096,7 +1096,7 @@ SDValue HexagonTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); Index: lib/Target/Lanai/LanaiISelLowering.h =================================================================== --- lib/Target/Lanai/LanaiISelLowering.h +++ lib/Target/Lanai/LanaiISelLowering.h @@ -123,7 +123,7 @@ SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const; @@ -138,13 +138,13 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; const LanaiRegisterInfo *TRI; Index: lib/Target/Lanai/LanaiISelLowering.cpp =================================================================== --- lib/Target/Lanai/LanaiISelLowering.cpp +++ lib/Target/Lanai/LanaiISelLowering.cpp @@ -398,7 +398,7 @@ SDValue LanaiTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { case CallingConv::C: @@ -439,7 +439,7 @@ // generate load operations for arguments places on the stack. SDValue LanaiTargetLowering::LowerCCCArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -536,8 +536,8 @@ SDValue LanaiTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of the return value to a location SmallVector RVLocs; Index: lib/Target/MSP430/MSP430ISelLowering.h =================================================================== --- lib/Target/MSP430/MSP430ISelLowering.h +++ lib/Target/MSP430/MSP430ISelLowering.h @@ -131,7 +131,7 @@ SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, CallingConv::ID CallConv, bool isVarArg, bool isTailCall, - const SmallVectorImpl &Outs, + SmallVectorImpl &Outs, const SmallVectorImpl &OutVals, const SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, @@ -139,7 +139,7 @@ SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; @@ -151,7 +151,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue @@ -165,8 +165,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, Index: lib/Target/MSP430/MSP430ISelLowering.cpp =================================================================== --- lib/Target/MSP430/MSP430ISelLowering.cpp +++ lib/Target/MSP430/MSP430ISelLowering.cpp @@ -414,12 +414,12 @@ } static void AnalyzeVarArgs(CCState &State, - const SmallVectorImpl &Outs) { + SmallVectorImpl &Outs) { State.AnalyzeCallOperands(Outs, CC_MSP430_AssignStack); } static void AnalyzeVarArgs(CCState &State, - const SmallVectorImpl &Ins) { + SmallVectorImpl &Ins) { State.AnalyzeFormalArguments(Ins, CC_MSP430_AssignStack); } @@ -430,7 +430,7 @@ template static void AnalyzeArguments(CCState &State, SmallVectorImpl &ArgLocs, - const SmallVectorImpl &Args) { + SmallVectorImpl &Args) { static const MCPhysReg CRegList[] = { MSP430::R12, MSP430::R13, MSP430::R14, MSP430::R15 }; @@ -541,7 +541,7 @@ SDValue MSP430TargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { @@ -592,7 +592,7 @@ // FIXME: struct return stuff SDValue MSP430TargetLowering::LowerCCCArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -709,8 +709,8 @@ SDValue MSP430TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); @@ -778,7 +778,7 @@ /// (physical regs)/(stack frame), CALLSEQ_START and CALLSEQ_END are emitted. SDValue MSP430TargetLowering::LowerCCCCallTo( SDValue Chain, SDValue Callee, CallingConv::ID CallConv, bool isVarArg, - bool isTailCall, const SmallVectorImpl &Outs, + bool isTailCall, SmallVectorImpl &Outs, const SmallVectorImpl &OutVals, const SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { Index: lib/Target/Mips/MipsCCState.h =================================================================== --- lib/Target/Mips/MipsCCState.h +++ lib/Target/Mips/MipsCCState.h @@ -108,7 +108,7 @@ SmallVectorImpl &Flags, CCAssignFn Fn) = delete; - void AnalyzeFormalArguments(const SmallVectorImpl &Ins, + void AnalyzeFormalArguments(SmallVectorImpl &Ins, CCAssignFn Fn) { PreAnalyzeFormalArgumentsForF128(Ins); CCState::AnalyzeFormalArguments(Ins, Fn); Index: lib/Target/Mips/MipsISelLowering.h =================================================================== --- lib/Target/Mips/MipsISelLowering.h +++ lib/Target/Mips/MipsISelLowering.h @@ -590,7 +590,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -607,8 +607,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; SDValue LowerInterruptReturn(SmallVectorImpl &RetOps, Index: lib/Target/Mips/MipsISelLowering.cpp =================================================================== --- lib/Target/Mips/MipsISelLowering.cpp +++ lib/Target/Mips/MipsISelLowering.cpp @@ -3343,7 +3343,7 @@ /// and generate load operations for arguments places on the stack. SDValue MipsTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -3529,8 +3529,8 @@ SDValue MipsTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of // the return value to a location Index: lib/Target/NVPTX/NVPTXISelLowering.h =================================================================== --- lib/Target/NVPTX/NVPTXISelLowering.h +++ lib/Target/NVPTX/NVPTXISelLowering.h @@ -482,7 +482,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -495,8 +495,8 @@ ImmutableCallSite CS) const; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &dl, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, Index: lib/Target/NVPTX/NVPTXISelLowering.cpp =================================================================== --- lib/Target/NVPTX/NVPTXISelLowering.cpp +++ lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -2323,7 +2323,7 @@ SDValue NVPTXTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); const DataLayout &DL = DAG.getDataLayout(); @@ -2521,8 +2521,8 @@ SDValue NVPTXTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); Type *RetTy = MF.getFunction().getReturnType(); Index: lib/Target/Nios2/Nios2ISelLowering.h =================================================================== --- lib/Target/Nios2/Nios2ISelLowering.h +++ lib/Target/Nios2/Nios2ISelLowering.h @@ -49,13 +49,13 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &dl, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; }; } // end namespace llvm Index: lib/Target/Nios2/Nios2ISelLowering.cpp =================================================================== --- lib/Target/Nios2/Nios2ISelLowering.cpp +++ lib/Target/Nios2/Nios2ISelLowering.cpp @@ -29,8 +29,8 @@ SDValue Nios2TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of // the return value to a location @@ -85,7 +85,7 @@ // and generate load operations for arguments places on the stack. SDValue Nios2TargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); Index: lib/Target/PowerPC/PPCISelLowering.h =================================================================== --- lib/Target/PowerPC/PPCISelLowering.h +++ lib/Target/PowerPC/PPCISelLowering.h @@ -985,7 +985,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -998,8 +998,8 @@ LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; SDValue extendArgForPPC64(ISD::ArgFlagsTy Flags, EVT ObjectVT, @@ -1008,15 +1008,15 @@ SDValue LowerFormalArguments_Darwin( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; SDValue LowerFormalArguments_64SVR4( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; SDValue LowerFormalArguments_32SVR4( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; SDValue createMemcpyOutsideCallSeq(SDValue Arg, SDValue PtrOff, Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -3218,7 +3218,7 @@ SDValue PPCTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { if (Subtarget.isSVR4ABI()) { if (Subtarget.isPPC64()) @@ -3235,7 +3235,7 @@ SDValue PPCTargetLowering::LowerFormalArguments_32SVR4( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { // 32-bit SVR4 ABI Stack Frame Layout: @@ -3483,7 +3483,7 @@ SDValue PPCTargetLowering::LowerFormalArguments_64SVR4( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { // TODO: add description of PPC stack frame format, or at least some docs. // @@ -3895,7 +3895,7 @@ SDValue PPCTargetLowering::LowerFormalArguments_Darwin( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { // TODO: add description of PPC stack frame format, or at least some docs. // @@ -6426,8 +6426,8 @@ SDValue PPCTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { SmallVector RVLocs; CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), RVLocs, Index: lib/Target/RISCV/RISCVISelLowering.h =================================================================== --- lib/Target/RISCV/RISCVISelLowering.h +++ lib/Target/RISCV/RISCVISelLowering.h @@ -61,7 +61,7 @@ // Lower incoming arguments, copy physregs into vregs SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, @@ -69,8 +69,8 @@ const SmallVectorImpl &Outs, LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl &InVals) const override; Index: lib/Target/RISCV/RISCVISelLowering.cpp =================================================================== --- lib/Target/RISCV/RISCVISelLowering.cpp +++ lib/Target/RISCV/RISCVISelLowering.cpp @@ -672,7 +672,7 @@ // Transform physical registers into virtual registers. SDValue RISCVTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { @@ -997,8 +997,8 @@ SDValue RISCVTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // Stores the assignment of the return value to a location. SmallVector RVLocs; Index: lib/Target/Sparc/SparcCallingConv.td =================================================================== --- lib/Target/Sparc/SparcCallingConv.td +++ lib/Target/Sparc/SparcCallingConv.td @@ -21,12 +21,12 @@ // i32 f32 arguments get passed in integer registers if there is space. CCIfType<[i32, f32], CCAssignToReg<[I0, I1, I2, I3, I4, I5]>>, // f64 arguments are split and passed through registers or through stack. - CCIfType<[f64], CCCustom<"CC_Sparc_Assign_Split_64">>, + CCIfType<[f64], CCAssignToRegWithType>, // As are v2i32 arguments (this would be the default behavior for // v2i32 if it wasn't allocated to the IntPair register-class) - CCIfType<[v2i32], CCCustom<"CC_Sparc_Assign_Split_64">>, - + CCIfType<[v2i32], CCAssignToRegWithType>, + CCIfType<[f64, v2i32], CCAssignToStack<8, 8>>, // Alternatively, they are assigned to the stack in 4-byte aligned units. CCAssignToStack<4, 4> ]>; @@ -35,7 +35,7 @@ CCIfType<[i32], CCAssignToReg<[I0, I1, I2, I3, I4, I5]>>, CCIfType<[f32], CCAssignToReg<[F0, F1, F2, F3]>>, CCIfType<[f64], CCAssignToReg<[D0, D1]>>, - CCIfType<[v2i32], CCCustom<"CC_Sparc_Assign_Ret_Split_64">> + CCIfType<[v2i32], CCAssignToRegWithType> ]>; Index: lib/Target/Sparc/SparcISelLowering.h =================================================================== --- lib/Target/Sparc/SparcISelLowering.h +++ lib/Target/Sparc/SparcISelLowering.h @@ -127,19 +127,24 @@ EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override; + /// Break down vectors to the correct number of gpr sized integers. + unsigned getVectorTypeBreakdownForCallingConv( + LLVMContext &Context, EVT VT, EVT &IntermediateVT, + unsigned &NumIntermediates, MVT &RegisterVT) const override; + SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerFormalArguments_32(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; SDValue LowerFormalArguments_64(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; @@ -152,18 +157,18 @@ SmallVectorImpl &InVals) const; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; SDValue LowerReturn_32(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const; SDValue LowerReturn_64(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const; SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; Index: lib/Target/Sparc/SparcISelLowering.cpp =================================================================== --- lib/Target/Sparc/SparcISelLowering.cpp +++ lib/Target/Sparc/SparcISelLowering.cpp @@ -51,57 +51,6 @@ return true; } -static bool CC_Sparc_Assign_Split_64(unsigned &ValNo, MVT &ValVT, - MVT &LocVT, CCValAssign::LocInfo &LocInfo, - ISD::ArgFlagsTy &ArgFlags, CCState &State) -{ - static const MCPhysReg RegList[] = { - SP::I0, SP::I1, SP::I2, SP::I3, SP::I4, SP::I5 - }; - // Try to get first reg. - if (unsigned Reg = State.AllocateReg(RegList)) { - State.addLoc(CCValAssign::getCustomReg(ValNo, ValVT, Reg, LocVT, LocInfo)); - } else { - // Assign whole thing in stack. - State.addLoc(CCValAssign::getCustomMem(ValNo, ValVT, - State.AllocateStack(8,4), - LocVT, LocInfo)); - return true; - } - - // Try to get second reg. - if (unsigned Reg = State.AllocateReg(RegList)) - State.addLoc(CCValAssign::getCustomReg(ValNo, ValVT, Reg, LocVT, LocInfo)); - else - State.addLoc(CCValAssign::getCustomMem(ValNo, ValVT, - State.AllocateStack(4,4), - LocVT, LocInfo)); - return true; -} - -static bool CC_Sparc_Assign_Ret_Split_64(unsigned &ValNo, MVT &ValVT, - MVT &LocVT, CCValAssign::LocInfo &LocInfo, - ISD::ArgFlagsTy &ArgFlags, CCState &State) -{ - static const MCPhysReg RegList[] = { - SP::I0, SP::I1, SP::I2, SP::I3, SP::I4, SP::I5 - }; - - // Try to get first reg. - if (unsigned Reg = State.AllocateReg(RegList)) - State.addLoc(CCValAssign::getCustomReg(ValNo, ValVT, Reg, LocVT, LocInfo)); - else - return false; - - // Try to get second reg. - if (unsigned Reg = State.AllocateReg(RegList)) - State.addLoc(CCValAssign::getCustomReg(ValNo, ValVT, Reg, LocVT, LocInfo)); - else - return false; - - return true; -} - // Allocate a full-sized argument for the 64-bit ABI. static bool CC_Sparc64_Full(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, @@ -196,8 +145,8 @@ SDValue SparcTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { if (Subtarget->is64Bit()) return LowerReturn_64(Chain, CallConv, IsVarArg, Outs, OutVals, DL, DAG); @@ -207,8 +156,8 @@ SDValue SparcTargetLowering::LowerReturn_32(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); @@ -220,7 +169,7 @@ *DAG.getContext()); // Analyze return values. - CCInfo.AnalyzeReturn(Outs, RetCC_Sparc32); + CCInfo.AnalyzeReturn(DAG, Outs, OutVals, RetCC_Sparc32); SDValue Flag; SmallVector RetOps(1, Chain); @@ -236,26 +185,7 @@ SDValue Arg = OutVals[realRVLocIdx]; - if (VA.needsCustom()) { - assert(VA.getLocVT() == MVT::v2i32); - // Legalize ret v2i32 -> ret 2 x i32 (Basically: do what would - // happen by default if this wasn't a legal type) - - SDValue Part0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, - Arg, - DAG.getConstant(0, DL, getVectorIdxTy(DAG.getDataLayout()))); - SDValue Part1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, MVT::i32, - Arg, - DAG.getConstant(1, DL, getVectorIdxTy(DAG.getDataLayout()))); - - Chain = DAG.getCopyToReg(Chain, DL, VA.getLocReg(), Part0, Flag); - Flag = Chain.getValue(1); - RetOps.push_back(DAG.getRegister(VA.getLocReg(), VA.getLocVT())); - VA = RVLocs[++i]; // skip ahead to next loc - Chain = DAG.getCopyToReg(Chain, DL, VA.getLocReg(), Part1, - Flag); - } else - Chain = DAG.getCopyToReg(Chain, DL, VA.getLocReg(), Arg, Flag); + Chain = DAG.getCopyToReg(Chain, DL, VA.getLocReg(), Arg, Flag); // Guarantee that all emitted copies are stuck together with flags. Flag = Chain.getValue(1); @@ -292,8 +222,8 @@ SDValue SparcTargetLowering::LowerReturn_64(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { // CCValAssign - represent the assignment of the return value to locations. SmallVector RVLocs; @@ -368,7 +298,7 @@ SDValue SparcTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { if (Subtarget->is64Bit()) return LowerFormalArguments_64(Chain, CallConv, IsVarArg, Ins, @@ -382,7 +312,7 @@ /// pass FP values in FP registers for fastcc functions. SDValue SparcTargetLowering::LowerFormalArguments_32( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineRegisterInfo &RegInfo = MF.getRegInfo(); @@ -395,7 +325,6 @@ CCInfo.AnalyzeFormalArguments(Ins, CC_Sparc32); const unsigned StackOffset = 92; - bool IsLittleEndian = DAG.getDataLayout().isLittleEndian(); unsigned InIdx = 0; for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i, ++InIdx) { @@ -414,37 +343,6 @@ } if (VA.isRegLoc()) { - if (VA.needsCustom()) { - assert(VA.getLocVT() == MVT::f64 || VA.getLocVT() == MVT::v2i32); - - unsigned VRegHi = RegInfo.createVirtualRegister(&SP::IntRegsRegClass); - MF.getRegInfo().addLiveIn(VA.getLocReg(), VRegHi); - SDValue HiVal = DAG.getCopyFromReg(Chain, dl, VRegHi, MVT::i32); - - assert(i+1 < e); - CCValAssign &NextVA = ArgLocs[++i]; - - SDValue LoVal; - if (NextVA.isMemLoc()) { - int FrameIdx = MF.getFrameInfo(). - CreateFixedObject(4, StackOffset+NextVA.getLocMemOffset(),true); - SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); - LoVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, MachinePointerInfo()); - } else { - unsigned loReg = MF.addLiveIn(NextVA.getLocReg(), - &SP::IntRegsRegClass); - LoVal = DAG.getCopyFromReg(Chain, dl, loReg, MVT::i32); - } - - if (IsLittleEndian) - std::swap(LoVal, HiVal); - - SDValue WholeValue = - DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64, LoVal, HiVal); - WholeValue = DAG.getNode(ISD::BITCAST, dl, VA.getLocVT(), WholeValue); - InVals.push_back(WholeValue); - continue; - } unsigned VReg = RegInfo.createVirtualRegister(&SP::IntRegsRegClass); MF.getRegInfo().addLiveIn(VA.getLocReg(), VReg); SDValue Arg = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32); @@ -464,50 +362,14 @@ unsigned Offset = VA.getLocMemOffset()+StackOffset; auto PtrVT = getPointerTy(DAG.getDataLayout()); - if (VA.needsCustom()) { - assert(VA.getValVT() == MVT::f64 || VA.getValVT() == MVT::v2i32); - // If it is double-word aligned, just load. - if (Offset % 8 == 0) { - int FI = MF.getFrameInfo().CreateFixedObject(8, - Offset, - true); - SDValue FIPtr = DAG.getFrameIndex(FI, PtrVT); - SDValue Load = - DAG.getLoad(VA.getValVT(), dl, Chain, FIPtr, MachinePointerInfo()); - InVals.push_back(Load); - continue; - } - - int FI = MF.getFrameInfo().CreateFixedObject(4, - Offset, - true); - SDValue FIPtr = DAG.getFrameIndex(FI, PtrVT); - SDValue HiVal = - DAG.getLoad(MVT::i32, dl, Chain, FIPtr, MachinePointerInfo()); - int FI2 = MF.getFrameInfo().CreateFixedObject(4, - Offset+4, - true); - SDValue FIPtr2 = DAG.getFrameIndex(FI2, PtrVT); - - SDValue LoVal = - DAG.getLoad(MVT::i32, dl, Chain, FIPtr2, MachinePointerInfo()); - - if (IsLittleEndian) - std::swap(LoVal, HiVal); - - SDValue WholeValue = - DAG.getNode(ISD::BUILD_PAIR, dl, MVT::i64, LoVal, HiVal); - WholeValue = DAG.getNode(ISD::BITCAST, dl, VA.getValVT(), WholeValue); - InVals.push_back(WholeValue); - continue; - } - - int FI = MF.getFrameInfo().CreateFixedObject(4, + unsigned Size = VA.getValVT().getSizeInBits(); + int FI = MF.getFrameInfo().CreateFixedObject(Size, Offset, true); SDValue FIPtr = DAG.getFrameIndex(FI, PtrVT); SDValue Load ; - if (VA.getValVT() == MVT::i32 || VA.getValVT() == MVT::f32) { + if (VA.getValVT() == MVT::i32 || VA.getValVT() == MVT::f32 || + VA.getValVT() == MVT::f64 || VA.getValVT() == MVT::v2i32) { Load = DAG.getLoad(VA.getValVT(), dl, Chain, FIPtr, MachinePointerInfo()); } else if (VA.getValVT() == MVT::f128) { report_fatal_error("SPARCv8 does not handle f128 in calls; " @@ -577,7 +439,7 @@ // Lower formal arguments for the 64 bit ABI. SDValue SparcTargetLowering::LowerFormalArguments_64( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); @@ -734,7 +596,7 @@ SmallVector ArgLocs; CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), ArgLocs, *DAG.getContext()); - CCInfo.AnalyzeCallOperands(Outs, CC_Sparc32); + CCInfo.AnalyzeCallOperands(DAG, Outs, OutVals, CC_Sparc32); // Get the size of the outgoing arguments stack space requirement. unsigned ArgsSize = CCInfo.getNextStackOffset(); @@ -827,72 +689,6 @@ continue; } - if (VA.needsCustom()) { - assert(VA.getLocVT() == MVT::f64 || VA.getLocVT() == MVT::v2i32); - - if (VA.isMemLoc()) { - unsigned Offset = VA.getLocMemOffset() + StackOffset; - // if it is double-word aligned, just store. - if (Offset % 8 == 0) { - SDValue StackPtr = DAG.getRegister(SP::O6, MVT::i32); - SDValue PtrOff = DAG.getIntPtrConstant(Offset, dl); - PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, PtrOff); - MemOpChains.push_back( - DAG.getStore(Chain, dl, Arg, PtrOff, MachinePointerInfo())); - continue; - } - } - - if (VA.getLocVT() == MVT::f64) { - // Move from the float value from float registers into the - // integer registers. - - // TODO: The f64 -> v2i32 conversion is super-inefficient for - // constants: it sticks them in the constant pool, then loads - // to a fp register, then stores to temp memory, then loads to - // integer registers. - Arg = DAG.getNode(ISD::BITCAST, dl, MVT::v2i32, Arg); - } - - SDValue Part0 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i32, - Arg, - DAG.getConstant(0, dl, getVectorIdxTy(DAG.getDataLayout()))); - SDValue Part1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i32, - Arg, - DAG.getConstant(1, dl, getVectorIdxTy(DAG.getDataLayout()))); - - if (VA.isRegLoc()) { - RegsToPass.push_back(std::make_pair(VA.getLocReg(), Part0)); - assert(i+1 != e); - CCValAssign &NextVA = ArgLocs[++i]; - if (NextVA.isRegLoc()) { - RegsToPass.push_back(std::make_pair(NextVA.getLocReg(), Part1)); - } else { - // Store the second part in stack. - unsigned Offset = NextVA.getLocMemOffset() + StackOffset; - SDValue StackPtr = DAG.getRegister(SP::O6, MVT::i32); - SDValue PtrOff = DAG.getIntPtrConstant(Offset, dl); - PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, PtrOff); - MemOpChains.push_back( - DAG.getStore(Chain, dl, Part1, PtrOff, MachinePointerInfo())); - } - } else { - unsigned Offset = VA.getLocMemOffset() + StackOffset; - // Store the first part. - SDValue StackPtr = DAG.getRegister(SP::O6, MVT::i32); - SDValue PtrOff = DAG.getIntPtrConstant(Offset, dl); - PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, PtrOff); - MemOpChains.push_back( - DAG.getStore(Chain, dl, Part0, PtrOff, MachinePointerInfo())); - // Store the second part. - PtrOff = DAG.getIntPtrConstant(Offset + 4, dl); - PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, PtrOff); - MemOpChains.push_back( - DAG.getStore(Chain, dl, Part1, PtrOff, MachinePointerInfo())); - } - continue; - } - // Arguments that can be passed on register must be kept at // RegsToPass vector if (VA.isRegLoc()) { @@ -983,29 +779,12 @@ // Copy all of the result registers out of their specified physreg. for (unsigned i = 0; i != RVLocs.size(); ++i) { - if (RVLocs[i].getLocVT() == MVT::v2i32) { - SDValue Vec = DAG.getNode(ISD::UNDEF, dl, MVT::v2i32); - SDValue Lo = DAG.getCopyFromReg( - Chain, dl, toCallerWindow(RVLocs[i++].getLocReg()), MVT::i32, InFlag); - Chain = Lo.getValue(1); - InFlag = Lo.getValue(2); - Vec = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, MVT::v2i32, Vec, Lo, - DAG.getConstant(0, dl, MVT::i32)); - SDValue Hi = DAG.getCopyFromReg( - Chain, dl, toCallerWindow(RVLocs[i].getLocReg()), MVT::i32, InFlag); - Chain = Hi.getValue(1); - InFlag = Hi.getValue(2); - Vec = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, MVT::v2i32, Vec, Hi, - DAG.getConstant(1, dl, MVT::i32)); - InVals.push_back(Vec); - } else { - Chain = + Chain = DAG.getCopyFromReg(Chain, dl, toCallerWindow(RVLocs[i].getLocReg()), - RVLocs[i].getValVT(), InFlag) + RVLocs[i].getLocVT(), InFlag) .getValue(1); - InFlag = Chain.getValue(2); - InVals.push_back(Chain.getValue(0)); - } + InFlag = Chain.getValue(2); + InVals.push_back(Chain.getValue(0)); } return Chain; @@ -1389,6 +1168,22 @@ return Chain; } +unsigned SparcTargetLowering::getVectorTypeBreakdownForCallingConv( + LLVMContext &Context, EVT VT, EVT &IntermediateVT, + unsigned &NumIntermediates, MVT &RegisterVT) const { + // For the vector type, we need to specify how to break down v2i32 type + // as described by CCAssignToRegWithType in SparcCallingConv.td to make + // sure getCopyFromParts could work correctly. + if (!Subtarget->is64Bit() && (VT == MVT::v2i32)) { + RegisterVT = MVT::i32; + IntermediateVT = VT.getVectorElementType(); + NumIntermediates = 2; + return 2; + } + return getVectorTypeBreakdown(Context, VT, IntermediateVT, NumIntermediates, + RegisterVT); +} + //===----------------------------------------------------------------------===// // TargetLowering Implementation //===----------------------------------------------------------------------===// Index: lib/Target/SystemZ/SystemZCallingConv.h =================================================================== --- lib/Target/SystemZ/SystemZCallingConv.h +++ lib/Target/SystemZ/SystemZCallingConv.h @@ -42,7 +42,7 @@ SmallVectorImpl &locs, LLVMContext &C) : CCState(CC, isVarArg, MF, locs, C) {} - void AnalyzeFormalArguments(const SmallVectorImpl &Ins, + void AnalyzeFormalArguments(SmallVectorImpl &Ins, CCAssignFn Fn) { // Formal arguments are always fixed. ArgIsFixed.clear(); Index: lib/Target/SystemZ/SystemZISelLowering.h =================================================================== --- lib/Target/SystemZ/SystemZISelLowering.h +++ lib/Target/SystemZ/SystemZISelLowering.h @@ -474,7 +474,7 @@ bool mayBeEmittedAsTailCall(const CallInst *CI) const override; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerCall(CallLoweringInfo &CLI, @@ -485,8 +485,8 @@ const SmallVectorImpl &Outs, LLVMContext &Context) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, const SDLoc &DL, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override; SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; Index: lib/Target/SystemZ/SystemZISelLowering.cpp =================================================================== --- lib/Target/SystemZ/SystemZISelLowering.cpp +++ lib/Target/SystemZ/SystemZISelLowering.cpp @@ -1049,7 +1049,7 @@ SDValue SystemZTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -1414,8 +1414,8 @@ SDValue SystemZTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &DL, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); Index: lib/Target/WebAssembly/WebAssemblyISelLowering.h =================================================================== --- lib/Target/WebAssembly/WebAssemblyISelLowering.h +++ lib/Target/WebAssembly/WebAssemblyISelLowering.h @@ -76,7 +76,7 @@ SelectionDAG &DAG) const override; SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; Index: lib/Target/WebAssembly/WebAssemblyISelLowering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -647,7 +647,7 @@ SDValue WebAssemblyTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, - const SmallVectorImpl &Ins, const SDLoc &DL, + SmallVectorImpl &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl &InVals) const { if (!CallingConvSupported(CallConv)) fail(DL, DAG, "WebAssembly doesn't support non-C calling conventions"); Index: lib/Target/X86/X86ISelLowering.h =================================================================== --- lib/Target/X86/X86ISelLowering.h +++ lib/Target/X86/X86ISelLowering.h @@ -1213,15 +1213,15 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool supportSplitCSR(MachineFunction *MF) const override { Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -2182,8 +2182,8 @@ SDValue X86TargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); X86MachineFunctionInfo *FuncInfo = MF.getInfo(); @@ -2902,7 +2902,7 @@ SDValue X86TargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); X86MachineFunctionInfo *FuncInfo = MF.getInfo(); Index: lib/Target/XCore/XCoreISelLowering.h =================================================================== --- lib/Target/XCore/XCoreISelLowering.h +++ lib/Target/XCore/XCoreISelLowering.h @@ -147,7 +147,7 @@ // Lower Operand helpers SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const; SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, @@ -208,7 +208,7 @@ SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const override; @@ -217,8 +217,8 @@ SmallVectorImpl &InVals) const override; SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const override; bool Index: lib/Target/XCore/XCoreISelLowering.cpp =================================================================== --- lib/Target/XCore/XCoreISelLowering.cpp +++ lib/Target/XCore/XCoreISelLowering.cpp @@ -1238,7 +1238,7 @@ /// XCore formal arguments implementation SDValue XCoreTargetLowering::LowerFormalArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { switch (CallConv) { @@ -1257,7 +1257,7 @@ /// TODO: sret SDValue XCoreTargetLowering::LowerCCCArguments( SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Ins, const SDLoc &dl, + SmallVectorImpl &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl &InVals) const { MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo &MFI = MF.getFrameInfo(); @@ -1434,8 +1434,8 @@ SDValue XCoreTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, - const SmallVectorImpl &Outs, - const SmallVectorImpl &OutVals, + SmallVectorImpl &Outs, + SmallVectorImpl &OutVals, const SDLoc &dl, SelectionDAG &DAG) const { XCoreFunctionInfo *XFI = Index: test/CodeGen/SPARC/32abi.ll =================================================================== --- test/CodeGen/SPARC/32abi.ll +++ test/CodeGen/SPARC/32abi.ll @@ -67,7 +67,7 @@ ; HARD-NEXT: ! kill ; HARD-NEXT: std %i0, [%fp+-8] ; HARD-NEXT: st %i2, [%fp+-28] -; HARD-NEXT: ld [%fp+104], %f0 +; HARD-NEXT: ld [%fp+100], %f0 ; HARD-NEXT: ldd [%fp+96], %f2 ; HARD-NEXT: ld [%fp+-28], %f1 ; HARD-NEXT: ldd [%fp+-8], %f4 @@ -152,9 +152,9 @@ ; HARD: save %sp, -112, %sp ; HARD: mov %i2, %o1 ; HARD-NEXT: mov %i1, %o0 -; HARD-NEXT: st %i0, [%sp+104] -; HARD-NEXT: std %o0, [%sp+96] +; HARD-NEXT: st %i0, [%sp+100] ; HARD-NEXT: st %o1, [%sp+92] +; HARD-NEXT: std %o0, [%sp+96] ; HARD-NEXT: mov %i0, %o2 ; HARD-NEXT: mov %o0, %o3 ; HARD-NEXT: mov %o1, %o4 Index: utils/TableGen/CallingConvEmitter.cpp =================================================================== --- utils/TableGen/CallingConvEmitter.cpp +++ utils/TableGen/CallingConvEmitter.cpp @@ -130,6 +130,33 @@ << "Reg, LocVT, LocInfo));\n"; O << IndentStr << " return false;\n"; O << IndentStr << "}\n"; + } else if (Action->isSubClassOf("CCAssignToRegWithType")) { + ListInit *RegList = Action->getValueAsListInit("RegList"); + Record *DestTy = Action->getValueAsDef("DestTy"); + MVT::SimpleValueType DestVT = getValueType(DestTy); + O << IndentStr << "LocVT = " << getEnumName(DestVT) << ";\n"; + if (RegList->size() == 1) { + O << IndentStr << "if (unsigned Reg = State.AllocateReg("; + O << getQualifiedName(RegList->getElementAsRecord(0)) << ")) {\n"; + } else { + O << IndentStr << "static const MCPhysReg RegList" << ++Counter + << "[] = {\n"; + O << IndentStr << " "; + for (unsigned i = 0, e = RegList->size(); i != e; ++i) { + if (i != 0) O << ", "; + O << getQualifiedName(RegList->getElementAsRecord(i)); + } + O << "\n" << IndentStr << "};\n"; + O << IndentStr << "if (unsigned Reg = State.AllocateReg(RegList" + << Counter << ")) {\n"; + } + O << IndentStr << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, " + << "Reg, LocVT, LocInfo));\n"; + O << IndentStr << " State.setCCSplitType(" << getEnumName(DestVT) + << ");\n"; + O << IndentStr << " State.setCCSplit();\n"; + O << IndentStr << " return false;\n"; + O << IndentStr << "}\n"; } else if (Action->isSubClassOf("CCAssignToRegWithShadow")) { ListInit *RegList = Action->getValueAsListInit("RegList"); ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList");