39 return CC_RISCV_GHC(ValNo, ValVT, LocVT, LocInfo, ArgFlags, OrigTy, State);
46 return CC_RISCV_Impl(ValNo, ValVT, LocVT, LocInfo, ArgFlags, OrigTy, State,
54 return CC_RISCV_Impl(ValNo, ValVT, LocVT, LocInfo, ArgFlags, OrigTy, State,
84 RISCV::F13_H, RISCV::F14_H, RISCV::F15_H,
85 RISCV::F16_H, RISCV::F17_H};
87 RISCV::F13_F, RISCV::F14_F, RISCV::F15_F,
88 RISCV::F16_F, RISCV::F17_F};
90 RISCV::F13_D, RISCV::F14_D, RISCV::F15_D,
91 RISCV::F16_D, RISCV::F17_D};
93 RISCV::F13_Q, RISCV::F14_Q, RISCV::F15_Q,
94 RISCV::F16_Q, RISCV::F17_Q};
98 RISCV::V8, RISCV::V9, RISCV::V10, RISCV::V11, RISCV::V12, RISCV::V13,
99 RISCV::V14, RISCV::V15, RISCV::V16, RISCV::V17, RISCV::V18, RISCV::V19,
100 RISCV::V20, RISCV::V21, RISCV::V22, RISCV::V23};
102 RISCV::V14M2, RISCV::V16M2, RISCV::V18M2,
103 RISCV::V20M2, RISCV::V22M2};
108 RISCV::V8_V9, RISCV::V9_V10, RISCV::V10_V11, RISCV::V11_V12,
109 RISCV::V12_V13, RISCV::V13_V14, RISCV::V14_V15, RISCV::V15_V16,
110 RISCV::V16_V17, RISCV::V17_V18, RISCV::V18_V19, RISCV::V19_V20,
111 RISCV::V20_V21, RISCV::V21_V22, RISCV::V22_V23};
113 RISCV::V8_V9_V10, RISCV::V9_V10_V11, RISCV::V10_V11_V12,
114 RISCV::V11_V12_V13, RISCV::V12_V13_V14, RISCV::V13_V14_V15,
115 RISCV::V14_V15_V16, RISCV::V15_V16_V17, RISCV::V16_V17_V18,
116 RISCV::V17_V18_V19, RISCV::V18_V19_V20, RISCV::V19_V20_V21,
117 RISCV::V20_V21_V22, RISCV::V21_V22_V23};
119 RISCV::V8_V9_V10_V11, RISCV::V9_V10_V11_V12, RISCV::V10_V11_V12_V13,
120 RISCV::V11_V12_V13_V14, RISCV::V12_V13_V14_V15, RISCV::V13_V14_V15_V16,
121 RISCV::V14_V15_V16_V17, RISCV::V15_V16_V17_V18, RISCV::V16_V17_V18_V19,
122 RISCV::V17_V18_V19_V20, RISCV::V18_V19_V20_V21, RISCV::V19_V20_V21_V22,
123 RISCV::V20_V21_V22_V23};
125 RISCV::V8_V9_V10_V11_V12, RISCV::V9_V10_V11_V12_V13,
126 RISCV::V10_V11_V12_V13_V14, RISCV::V11_V12_V13_V14_V15,
127 RISCV::V12_V13_V14_V15_V16, RISCV::V13_V14_V15_V16_V17,
128 RISCV::V14_V15_V16_V17_V18, RISCV::V15_V16_V17_V18_V19,
129 RISCV::V16_V17_V18_V19_V20, RISCV::V17_V18_V19_V20_V21,
130 RISCV::V18_V19_V20_V21_V22, RISCV::V19_V20_V21_V22_V23};
132 RISCV::V8_V9_V10_V11_V12_V13, RISCV::V9_V10_V11_V12_V13_V14,
133 RISCV::V10_V11_V12_V13_V14_V15, RISCV::V11_V12_V13_V14_V15_V16,
134 RISCV::V12_V13_V14_V15_V16_V17, RISCV::V13_V14_V15_V16_V17_V18,
135 RISCV::V14_V15_V16_V17_V18_V19, RISCV::V15_V16_V17_V18_V19_V20,
136 RISCV::V16_V17_V18_V19_V20_V21, RISCV::V17_V18_V19_V20_V21_V22,
137 RISCV::V18_V19_V20_V21_V22_V23};
139 RISCV::V8_V9_V10_V11_V12_V13_V14, RISCV::V9_V10_V11_V12_V13_V14_V15,
140 RISCV::V10_V11_V12_V13_V14_V15_V16, RISCV::V11_V12_V13_V14_V15_V16_V17,
141 RISCV::V12_V13_V14_V15_V16_V17_V18, RISCV::V13_V14_V15_V16_V17_V18_V19,
142 RISCV::V14_V15_V16_V17_V18_V19_V20, RISCV::V15_V16_V17_V18_V19_V20_V21,
143 RISCV::V16_V17_V18_V19_V20_V21_V22, RISCV::V17_V18_V19_V20_V21_V22_V23};
145 RISCV::V9_V10_V11_V12_V13_V14_V15_V16,
146 RISCV::V10_V11_V12_V13_V14_V15_V16_V17,
147 RISCV::V11_V12_V13_V14_V15_V16_V17_V18,
148 RISCV::V12_V13_V14_V15_V16_V17_V18_V19,
149 RISCV::V13_V14_V15_V16_V17_V18_V19_V20,
150 RISCV::V14_V15_V16_V17_V18_V19_V20_V21,
151 RISCV::V15_V16_V17_V18_V19_V20_V21_V22,
152 RISCV::V16_V17_V18_V19_V20_V21_V22_V23};
154 RISCV::V12M2_V14M2, RISCV::V14M2_V16M2,
155 RISCV::V16M2_V18M2, RISCV::V18M2_V20M2,
158 RISCV::V8M2_V10M2_V12M2, RISCV::V10M2_V12M2_V14M2,
159 RISCV::V12M2_V14M2_V16M2, RISCV::V14M2_V16M2_V18M2,
160 RISCV::V16M2_V18M2_V20M2, RISCV::V18M2_V20M2_V22M2};
162 RISCV::V8M2_V10M2_V12M2_V14M2, RISCV::V10M2_V12M2_V14M2_V16M2,
163 RISCV::V12M2_V14M2_V16M2_V18M2, RISCV::V14M2_V16M2_V18M2_V20M2,
164 RISCV::V16M2_V18M2_V20M2_V22M2};
173 static const MCPhysReg ArgIGPRs[] = {RISCV::X10, RISCV::X11, RISCV::X12,
174 RISCV::X13, RISCV::X14, RISCV::X15,
175 RISCV::X16, RISCV::X17};
177 static const MCPhysReg ArgEGPRs[] = {RISCV::X10, RISCV::X11, RISCV::X12,
178 RISCV::X13, RISCV::X14, RISCV::X15};
199 if (STI.hasStdExtQ())
202 if (STI.hasStdExtD())
211 static const MCPhysReg ArgIGPRs[] = {RISCV::X10_H, RISCV::X11_H, RISCV::X12_H,
212 RISCV::X13_H, RISCV::X14_H, RISCV::X15_H,
213 RISCV::X16_H, RISCV::X17_H};
215 static const MCPhysReg ArgEGPRs[] = {RISCV::X10_H, RISCV::X11_H,
216 RISCV::X12_H, RISCV::X13_H,
217 RISCV::X14_H, RISCV::X15_H};
228 static const MCPhysReg ArgIGPRs[] = {RISCV::X10_W, RISCV::X11_W, RISCV::X12_W,
229 RISCV::X13_W, RISCV::X14_W, RISCV::X15_W,
230 RISCV::X16_W, RISCV::X17_W};
232 static const MCPhysReg ArgEGPRs[] = {RISCV::X10_W, RISCV::X11_W,
233 RISCV::X12_W, RISCV::X13_W,
234 RISCV::X14_W, RISCV::X15_W};
247 RISCV::X10, RISCV::X11, RISCV::X12, RISCV::X13, RISCV::X14, RISCV::X15,
248 RISCV::X16, RISCV::X17, RISCV::X28, RISCV::X29, RISCV::X30, RISCV::X31};
251 static const MCPhysReg FastCCEGPRs[] = {RISCV::X10, RISCV::X11, RISCV::X12,
252 RISCV::X13, RISCV::X14, RISCV::X15};
265 RISCV::X10_H, RISCV::X11_H, RISCV::X12_H, RISCV::X13_H,
266 RISCV::X14_H, RISCV::X15_H, RISCV::X16_H, RISCV::X17_H,
267 RISCV::X28_H, RISCV::X29_H, RISCV::X30_H, RISCV::X31_H};
270 static const MCPhysReg FastCCEGPRs[] = {RISCV::X10_H, RISCV::X11_H,
271 RISCV::X12_H, RISCV::X13_H,
272 RISCV::X14_H, RISCV::X15_H};
285 RISCV::X10_W, RISCV::X11_W, RISCV::X12_W, RISCV::X13_W,
286 RISCV::X14_W, RISCV::X15_W, RISCV::X16_W, RISCV::X17_W,
287 RISCV::X28_W, RISCV::X29_W, RISCV::X30_W, RISCV::X31_W};
290 static const MCPhysReg FastCCEGPRs[] = {RISCV::X10_W, RISCV::X11_W,
291 RISCV::X12_W, RISCV::X13_W,
292 RISCV::X14_W, RISCV::X15_W};
307 unsigned XLen = Subtarget.
getXLen();
308 unsigned XLenInBytes = XLen / 8;
322 Align StackAlign(XLenInBytes);
323 if (!
EABI || XLen != 32)
327 State.AllocateStack(XLenInBytes, StackAlign),
330 ValNo2, ValVT2, State.AllocateStack(XLenInBytes,
Align(XLenInBytes)),
342 ValNo2, ValVT2, State.AllocateStack(XLenInBytes,
Align(XLenInBytes)),
352 if (RC == &RISCV::VRRegClass) {
359 return State.AllocateReg(
ArgVRs);
361 if (RC == &RISCV::VRM2RegClass)
363 if (RC == &RISCV::VRM4RegClass)
365 if (RC == &RISCV::VRM8RegClass)
367 if (RC == &RISCV::VRN2M1RegClass)
369 if (RC == &RISCV::VRN3M1RegClass)
371 if (RC == &RISCV::VRN4M1RegClass)
373 if (RC == &RISCV::VRN5M1RegClass)
375 if (RC == &RISCV::VRN6M1RegClass)
377 if (RC == &RISCV::VRN7M1RegClass)
379 if (RC == &RISCV::VRN8M1RegClass)
381 if (RC == &RISCV::VRN2M2RegClass)
383 if (RC == &RISCV::VRN3M2RegClass)
385 if (RC == &RISCV::VRN4M2RegClass)
387 if (RC == &RISCV::VRN2M4RegClass)
399 assert(ValVT == LocVT &&
"Expected ValVT and LocVT to match");
405 unsigned XLen = Subtarget.
getXLen();
416 const auto StaticChainReg = HasCFBranch ? RISCV::X28 : RISCV::X7;
422 "Nested functions with control flow protection are not "
423 "usable with ILP32E or LP64E ABI.");
442 bool AllowFPRForF16_F32 =
false;
444 bool AllowFPRForF64 =
false;
457 AllowFPRForF64 = !ArgFlags.
isVarArg();
461 AllowFPRForF16_F32 = !ArgFlags.
isVarArg();
465 if ((LocVT == MVT::f16 || LocVT == MVT::bf16) && AllowFPRForF16_F32) {
472 if (LocVT == MVT::f32 && AllowFPRForF16_F32) {
479 if (LocVT == MVT::f64 && AllowFPRForF64) {
486 if (LocVT == MVT::f16 && Subtarget.hasStdExtZhinxmin()) {
493 if (LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) {
503 if (LocVT == MVT::f64 && XLen == 64 && Subtarget.hasStdExtZdinx()) {
511 if (LocVT == MVT::f16 || LocVT == MVT::bf16 ||
512 (LocVT == MVT::f32 && XLen == 64)) {
522 if ((XLen == 32 && LocVT == MVT::f32) || (XLen == 64 && LocVT == MVT::f64)) {
541 unsigned TwoXLenInBytes = (2 * XLen) / 8;
543 DL.getTypeAllocSize(OrigTy) == TwoXLenInBytes &&
545 unsigned RegIdx = State.getFirstUnallocated(
ArgGPRs);
547 if (RegIdx != std::size(
ArgGPRs) && RegIdx % 2 == 1)
553 State.getPendingArgFlags();
556 "PendingLocs and PendingArgFlags out of sync");
564 "Can't lower f64 or P extension vector if it is split");
595 assert(PendingLocs.
size() == 1 &&
"Unexpected PendingLocs.size()");
601 PendingArgFlags.
clear();
622 unsigned StoreSizeBytes = XLen / 8;
634 LocVT = TLI.getContainerForFixedLengthVector(LocVT);
663 Reg ? 0 : State.AllocateStack(StoreSizeBytes, StackAlign);
667 if (!PendingLocs.
empty()) {
669 assert(PendingLocs.
size() > 1 &&
"Unexpected PendingLocs.size()");
671 for (
auto &It : PendingLocs) {
681 PendingArgFlags.
clear();
687 (TLI.getSubtarget().hasVInstructions() &&
689 "Expected an XLenVT or vector types at this stage");
711 if ((LocVT == MVT::f16 && Subtarget.hasStdExtZfhmin()) ||
712 (LocVT == MVT::bf16 && Subtarget.hasStdExtZfbfmin())) {
714 RISCV::F10_H, RISCV::F11_H, RISCV::F12_H, RISCV::F13_H, RISCV::F14_H,
715 RISCV::F15_H, RISCV::F16_H, RISCV::F17_H, RISCV::F0_H, RISCV::F1_H,
716 RISCV::F2_H, RISCV::F3_H, RISCV::F4_H, RISCV::F5_H, RISCV::F6_H,
717 RISCV::F7_H, RISCV::F28_H, RISCV::F29_H, RISCV::F30_H, RISCV::F31_H};
724 if (LocVT == MVT::f32 && Subtarget.hasStdExtF()) {
726 RISCV::F10_F, RISCV::F11_F, RISCV::F12_F, RISCV::F13_F, RISCV::F14_F,
727 RISCV::F15_F, RISCV::F16_F, RISCV::F17_F, RISCV::F0_F, RISCV::F1_F,
728 RISCV::F2_F, RISCV::F3_F, RISCV::F4_F, RISCV::F5_F, RISCV::F6_F,
729 RISCV::F7_F, RISCV::F28_F, RISCV::F29_F, RISCV::F30_F, RISCV::F31_F};
736 if (LocVT == MVT::f64 && Subtarget.hasStdExtD()) {
738 RISCV::F10_D, RISCV::F11_D, RISCV::F12_D, RISCV::F13_D, RISCV::F14_D,
739 RISCV::F15_D, RISCV::F16_D, RISCV::F17_D, RISCV::F0_D, RISCV::F1_D,
740 RISCV::F2_D, RISCV::F3_D, RISCV::F4_D, RISCV::F5_D, RISCV::F6_D,
741 RISCV::F7_D, RISCV::F28_D, RISCV::F29_D, RISCV::F30_D, RISCV::F31_D};
751 if ((LocVT == MVT::f16 && Subtarget.hasStdExtZhinxmin())) {
759 if (LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) {
767 if (LocVT == MVT::f64 && Subtarget.
is64Bit() && Subtarget.hasStdExtZdinx()) {
787 LocVT = TLI.getContainerForFixedLengthVector(LocVT);
805 if (LocVT == XLenVT) {
812 if (LocVT == XLenVT || LocVT == MVT::f16 || LocVT == MVT::bf16 ||
828 "Attribute 'nest' is not supported in GHC calling convention");
832 RISCV::X9, RISCV::X18, RISCV::X19, RISCV::X20, RISCV::X21, RISCV::X22,
833 RISCV::X23, RISCV::X24, RISCV::X25, RISCV::X26, RISCV::X27};
835 if (LocVT == MVT::i32 || LocVT == MVT::i64) {
847 if (LocVT == MVT::f32 && Subtarget.hasStdExtF()) {
850 static const MCPhysReg FPR32List[] = {RISCV::F8_F, RISCV::F9_F,
851 RISCV::F18_F, RISCV::F19_F,
852 RISCV::F20_F, RISCV::F21_F};
859 if (LocVT == MVT::f64 && Subtarget.hasStdExtD()) {
862 static const MCPhysReg FPR64List[] = {RISCV::F22_D, RISCV::F23_D,
863 RISCV::F24_D, RISCV::F25_D,
864 RISCV::F26_D, RISCV::F27_D};
871 if (LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) {
873 RISCV::X9_W, RISCV::X18_W, RISCV::X19_W, RISCV::X20_W,
874 RISCV::X21_W, RISCV::X22_W, RISCV::X23_W, RISCV::X24_W,
875 RISCV::X25_W, RISCV::X26_W, RISCV::X27_W};
882 if (LocVT == MVT::f64 && Subtarget.hasStdExtZdinx() && Subtarget.
is64Bit()) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Module.h This file contains the declarations for the Module class.
const MCPhysReg ArgFPR32s[]
const MCPhysReg ArgFPR64s[]
const MCPhysReg ArgGPRs[]
static const MCPhysReg ArgVRN2M2s[]
static CCAssignFn CC_RISCV_FastCC
Used for assigning arguments with CallingConvention::Fast.
static const MCPhysReg ArgVRM2s[]
static CCAssignFn CC_RISCV_GHC
Used for assigning arguments with CallingConvention::GHC.
static const MCPhysReg ArgVRN3M2s[]
static const MCPhysReg ArgVRN4M1s[]
static const MCPhysReg ArgVRN6M1s[]
static bool CC_RISCV_Impl(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State, bool IsRet)
static ArrayRef< MCPhysReg > getFastCCArgGPRF32s(const RISCVABI::ABI ABI)
static const MCPhysReg ArgVRN4M2s[]
static const MCPhysReg ArgFPR128s[]
static const MCPhysReg ArgVRN3M1s[]
static const MCPhysReg ArgVRN7M1s[]
static bool CC_RISCVAssign2XLen(CCState &State, CCValAssign VA1, ISD::ArgFlagsTy ArgFlags1, unsigned ValNo2, MVT ValVT2, MVT LocVT2, ISD::ArgFlagsTy ArgFlags2, const RISCVSubtarget &Subtarget)
static MCRegister allocateRVVReg(MVT LocVT, unsigned ValNo, CCState &State, const RISCVTargetLowering &TLI)
static const MCPhysReg ArgVRN5M1s[]
static const MCPhysReg ArgVRN2M4s[]
static ArrayRef< MCPhysReg > getFastCCArgGPRF16s(const RISCVABI::ABI ABI)
static ArrayRef< MCPhysReg > getArgGPR32s(const RISCVABI::ABI ABI)
static const MCPhysReg ArgVRN2M1s[]
static const MCPhysReg ArgVRN8M1s[]
static ArrayRef< MCPhysReg > getArgGPR16s(const RISCVABI::ABI ABI)
static ArrayRef< MCPhysReg > getFastCCArgGPRs(const RISCVABI::ABI ABI)
static const MCPhysReg ArgVRM8s[]
static const MCPhysReg ArgVRM4s[]
static const MCPhysReg ArgFPR16s[]
Represent a constant reference to an array (0 or more elements consecutively in memory),...
CCState - This class holds information needed while lowering arguments and return values.
CCValAssign - Represent assignment of one arg/retval to a location.
static CCValAssign getPending(unsigned ValNo, MVT ValVT, MVT LocVT, LocInfo HTP, unsigned ExtraInfo=0)
static CCValAssign getReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
unsigned getValNo() const
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
A parsed version of the target data layout string in and methods for querying it.
Wrapper class representing physical registers. Should be passed by value.
bool isRISCVVectorTuple() const
Return true if this is a RISCV vector tuple type where the runtime length is machine dependent.
uint64_t getScalarSizeInBits() const
bool isVector() const
Return true if this is a vector value type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
bool isFixedLengthVector() const
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
MVT getVectorElementType() const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
RISCVABI::ABI getTargetABI() const
bool isPExtPackedDoubleType(MVT VT) const
bool isPExtPackedType(MVT VT) const
const RISCVTargetLowering * getTargetLowering() const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
StackOffset holds a fixed and a scalable offset in bytes.
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
The instances of the Type class are immutable: once they are created, they are never changed.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ Fast
Attempts to make calls as fast as possible (e.g.
ArrayRef< MCPhysReg > getArgFPRs(const RISCVSubtarget &STI)
ArrayRef< MCPhysReg > getArgGPRs(const RISCVSubtarget &STI)
This is an optimization pass for GlobalISel generic memory operations.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
CCAssignFn RetCC_RISCV
This is used for assigning return values to locations when making calls.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
CCAssignFn CC_RISCV
This is used for assigining arguments to locations when making calls.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Align getNonZeroOrigAlign() const
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.