17 #define _USE_MATH_DEFINES 89 #define DEBUG_TYPE "si-lower" 91 STATISTIC(NumTailCalls,
"Number of tail calls");
94 "amdgpu-vgpr-index-mode",
95 cl::desc(
"Use GPR indexing mode instead of movrel for vector indexing"),
99 "amdgpu-frame-index-zero-bits",
100 cl::desc(
"High bits of frame index assumed to be zero"),
105 unsigned NumSGPRs = AMDGPU::SGPR_32RegClass.getNumRegs();
108 return AMDGPU::SGPR0 +
Reg;
349 if (!Subtarget->
hasBFI()) {
684 EVT DestVT,
EVT SrcVT)
const {
743 EVT VT,
EVT &IntermediateVT,
744 unsigned &NumIntermediates,
MVT &RegisterVT)
const {
751 IntermediateVT = RegisterVT;
752 NumIntermediates = NumElts;
753 return NumIntermediates;
758 IntermediateVT = RegisterVT;
759 NumIntermediates = 2 * NumElts;
760 return NumIntermediates;
768 IntermediateVT = RegisterVT;
769 NumIntermediates = NumElts / 2;
770 return NumIntermediates;
775 Context, CC, VT, IntermediateVT, NumIntermediates, RegisterVT);
781 unsigned IntrID)
const {
791 if (RsrcIntr->IsImage) {
826 case Intrinsic::amdgcn_atomic_inc:
827 case Intrinsic::amdgcn_atomic_dec:
828 case Intrinsic::amdgcn_ds_fadd:
829 case Intrinsic::amdgcn_ds_fmin:
830 case Intrinsic::amdgcn_ds_fmax: {
838 if (!Vol || !Vol->
isZero())
851 Type *&AccessTy)
const {
853 case Intrinsic::amdgcn_atomic_inc:
854 case Intrinsic::amdgcn_atomic_dec:
855 case Intrinsic::amdgcn_ds_fadd:
856 case Intrinsic::amdgcn_ds_fmin:
857 case Intrinsic::amdgcn_ds_fmax: {
868 bool SITargetLowering::isLegalFlatAddressingMode(
const AddrMode &AM)
const {
882 bool SITargetLowering::isLegalGlobalAddressingMode(
const AddrMode &AM)
const {
896 return isLegalFlatAddressingMode(AM);
899 return isLegalMUBUFAddressingMode(AM);
902 bool SITargetLowering::isLegalMUBUFAddressingMode(
const AddrMode &AM)
const {
945 return isLegalGlobalAddressingMode(AM);
953 return isLegalMUBUFAddressingMode(AM);
960 return isLegalGlobalAddressingMode(AM);
987 return isLegalMUBUFAddressingMode(AM);
1011 return isLegalFlatAddressingMode(AM);
1033 bool *IsFast)
const {
1051 bool AlignedBy4 = (Align % 4 == 0);
1053 *IsFast = AlignedBy4;
1073 (Align % 4 == 0) :
true;
1093 unsigned SrcAlign,
bool IsMemset,
1102 if (Size >= 16 && DstAlign >= 4)
1105 if (Size >= 8 && DstAlign >= 4)
1120 unsigned DestAS)
const {
1126 const MemSDNode *MemNode = cast<MemSDNode>(
N);
1128 const Instruction *
I = dyn_cast_or_null<Instruction>(Ptr);
1133 unsigned DestAS)
const {
1143 const MemSDNode *MemNode = cast<MemSDNode>(
N);
1199 std::tie(InputPtrReg, RC)
1211 const SDLoc &SL)
const {
1228 Val = getFPExtOrFPTrunc(DAG, Val, SL, VT);
1237 SDValue SITargetLowering::lowerKernargMemParameter(
1240 uint64_t Offset,
unsigned Align,
bool Signed,
1251 int64_t AlignDownOffset =
alignDown(Offset, 4);
1252 int64_t OffsetDiff = Offset - AlignDownOffset;
1258 SDValue Ptr = lowerKernArgParameterPtr(DAG, SL, Chain, AlignDownOffset);
1268 ArgVal = convertArgType(DAG, VT, MemVT, SL, ArgVal, Signed, Arg);
1274 SDValue Ptr = lowerKernArgParameterPtr(DAG, SL, Chain, Offset);
1279 SDValue Val = convertArgType(DAG, VT, MemVT, SL, Load, Signed, Arg);
1326 ExtType, SL, VA.
getLocVT(), Chain, FIN,
1349 for (
unsigned I = 0,
E = Ins.
size(), PSInputNum = 0;
I !=
E; ++
I) {
1352 assert(!Arg->
VT.
isVector() &&
"vector type argument should have been split");
1366 "unexpected vector split in ps argument type");
1397 unsigned Reg = AMDGPU::VGPR0;
1398 MF.
addLiveIn(Reg, &AMDGPU::VGPR_32RegClass);
1405 unsigned Reg = AMDGPU::VGPR1;
1406 MF.
addLiveIn(Reg, &AMDGPU::VGPR_32RegClass);
1413 unsigned Reg = AMDGPU::VGPR2;
1414 MF.
addLiveIn(Reg, &AMDGPU::VGPR_32RegClass);
1427 if (RegIdx == ArgVGPRs.
size()) {
1434 unsigned Reg = ArgVGPRs[RegIdx];
1436 assert(Reg != AMDGPU::NoRegister);
1439 MF.
addLiveIn(Reg, &AMDGPU::VGPR_32RegClass);
1445 unsigned NumArgRegs) {
1448 if (RegIdx == ArgSGPRs.
size())
1451 unsigned Reg = ArgSGPRs[RegIdx];
1453 assert(Reg != AMDGPU::NoRegister);
1524 MF.
addLiveIn(ImplicitBufferPtrReg, &AMDGPU::SGPR_64RegClass);
1531 MF.
addLiveIn(PrivateSegmentBufferReg, &AMDGPU::SGPR_128RegClass);
1537 MF.
addLiveIn(DispatchPtrReg, &AMDGPU::SGPR_64RegClass);
1543 MF.
addLiveIn(QueuePtrReg, &AMDGPU::SGPR_64RegClass);
1549 MF.
addLiveIn(InputPtrReg, &AMDGPU::SGPR_64RegClass);
1555 MF.
addLiveIn(DispatchIDReg, &AMDGPU::SGPR_64RegClass);
1561 MF.
addLiveIn(FlatScratchInitReg, &AMDGPU::SGPR_64RegClass);
1577 MF.
addLiveIn(Reg, &AMDGPU::SReg_32_XM0RegClass);
1583 MF.
addLiveIn(Reg, &AMDGPU::SReg_32_XM0RegClass);
1589 MF.
addLiveIn(Reg, &AMDGPU::SReg_32_XM0RegClass);
1595 MF.
addLiveIn(Reg, &AMDGPU::SReg_32_XM0RegClass);
1601 unsigned PrivateSegmentWaveByteOffsetReg;
1604 PrivateSegmentWaveByteOffsetReg =
1609 if (PrivateSegmentWaveByteOffsetReg == AMDGPU::NoRegister) {
1616 MF.
addLiveIn(PrivateSegmentWaveByteOffsetReg, &AMDGPU::SGPR_32RegClass);
1617 CCInfo.
AllocateReg(PrivateSegmentWaveByteOffsetReg);
1632 if (HasStackObjects)
1638 HasStackObjects =
true;
1642 bool RequiresStackAccess = HasStackObjects || MFI.
hasCalls();
1646 if (RequiresStackAccess) {
1664 unsigned ReservedOffsetReg
1673 unsigned ReservedBufferReg
1675 unsigned ReservedOffsetReg
1694 if (HasStackObjects && !MFI.
hasCalls()) {
1699 unsigned ReservedOffsetReg
1729 if (AMDGPU::SReg_64RegClass.
contains(*
I))
1730 RC = &AMDGPU::SGPR_64RegClass;
1731 else if (AMDGPU::SReg_32RegClass.
contains(*
I))
1732 RC = &AMDGPU::SGPR_32RegClass;
1743 for (
auto *Exit : Exits)
1745 TII->
get(TargetOpcode::COPY), *
I)
1764 Fn,
"unsupported non-compute shaders with HSA", DL.
getDebugLoc());
1771 if (ST.debuggerEmitPrologue())
1772 createDebuggerPrologueStackObjects(MF);
1787 CCInfo.AllocateStack(4, 4);
1810 CCInfo.AllocateReg(AMDGPU::VGPR0);
1811 CCInfo.AllocateReg(AMDGPU::VGPR1);
1825 if ((PsInputBits & 0x7F) == 0 ||
1826 ((PsInputBits & 0xF) == 0 &&
1827 (PsInputBits >> 11 & 1)))
1839 }
else if (IsKernel) {
1854 CCInfo.AnalyzeFormalArguments(Splits, AssignFn);
1864 const unsigned KernelArgBaseAlign = 16;
1866 for (
unsigned i = 0, e = Ins.
size(), ArgIdx = 0; i != e; ++i) {
1876 if (IsEntryFunc && VA.
isMemLoc()) {
1881 unsigned Align =
MinAlign(KernelArgBaseAlign, Offset);
1883 SDValue Arg = lowerKernargMemParameter(
1884 DAG, VT, MemVT, DL, Chain, Offset, Align, Ins[i].Flags.isSExt(), &Ins[i]);
1900 }
else if (!IsEntryFunc && VA.
isMemLoc()) {
1901 SDValue Val = lowerStackParameter(DAG, VA, DL, Chain, Arg);
1961 for (
unsigned j = 1; j != NumElements; ++j) {
1962 Reg = ArgLocs[ArgIdx++].getLocReg();
1995 auto &ArgUsageInfo =
1999 unsigned StackArgSize = CCInfo.getNextStackOffset();
2002 return Chains.
empty() ? Chain :
2020 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
2047 for (
unsigned i = 0, e = Outs.
size(); i != e; ++i) {
2060 for (
unsigned j = 0; j != NumElements; ++j) {
2099 Chain = DAG.
getCopyToReg(Chain, DL, PhysReturnAddrReg, ReturnAddrReg, Flag);
2106 for (
unsigned i = 0, realRVLocIdx = 0;
2108 ++i, ++realRVLocIdx) {
2113 SDValue Arg = SplitVals[realRVLocIdx];
2147 if (AMDGPU::SReg_64RegClass.
contains(*I))
2149 else if (AMDGPU::SReg_32RegClass.
contains(*I))
2182 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
2246 auto &ArgUsageInfo =
2249 = ArgUsageInfo.lookupFuncArgInfo(*CalleeFunc);
2270 for (
auto InputID : InputRegs) {
2274 std::tie(OutgoingArg, ArgRC) = CalleeArgInfo.getPreloadedValue(InputID);
2280 std::tie(IncomingArg, IncomingArgRC)
2282 assert(IncomingArgRC == ArgRC);
2293 assert(InputID == AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR);
2294 InputReg = getImplicitArgPtr(DAG, DL);
2298 RegsToPass.emplace_back(OutgoingArg->
getRegister(), InputReg);
2338 if (!CallerPreserved)
2341 bool CCMatch = CallerCC == CalleeCC;
2354 if (Arg.hasByValAttr())
2369 if (!TRI->regmaskSubsetEqual(CallerPreserved, CalleePreserved))
2378 CCState CCInfo(CalleeCC, IsVarArg, MF, ArgLocs, Ctx);
2402 return (Attr.getValueAsString() !=
"true");
2418 bool IsSibCall =
false;
2419 bool IsThisReturn =
false;
2424 "unsupported call to variadic function ");
2429 "unsupported indirect call to function ");
2434 "unsupported required tail call to function ");
2441 "unsupported call from graphics shader of function ");
2445 const unsigned CalleeUsableStackOffset = 4;
2449 Callee, CallConv, IsVarArg, Outs, OutVals, Ins, DAG);
2452 "site marked musttail");
2459 if (!TailCallOpt && IsTailCall)
2474 GA->getTargetFlags());
2485 CCInfo.AnalyzeCallOperands(Outs, AssignFn);
2488 unsigned NumBytes = CCInfo.getNextStackOffset();
2512 unsigned OffsetReg = Info->getScratchWaveOffsetReg();
2517 RegsToPass.
emplace_back(AMDGPU::SGPR0_SGPR1_SGPR2_SGPR3, ScratchRSrcReg);
2522 RegsToPass.
emplace_back(AMDGPU::SGPR4, ScratchWaveOffsetReg);
2524 if (!Info->isEntryFunction()) {
2528 Info->getFrameOffsetReg(),
MVT::i32);
2540 for (
unsigned i = 0, realArgIdx = 0, e = ArgLocs.size(); i != e;
2541 ++i, ++realArgIdx) {
2543 SDValue Arg = OutVals[realArgIdx];
2577 int32_t Offset = LocMemOffset;
2583 unsigned OpSize = Flags.
isByVal() ?
2586 Offset = Offset + FPDiff;
2606 if (Outs[i].Flags.isByVal()) {
2610 Chain, DL, DstAddr, Arg, SizeNode, Outs[i].Flags.getByValAlign(),
2627 if (!MemOpChains.
empty())
2633 for (
auto &RegToPass : RegsToPass) {
2635 RegToPass.second, InFlag);
2651 Chain = DAG.
getCopyToReg(Chain, DL, PhysReturnAddrReg, ReturnAddrReg, InFlag);
2659 if (IsTailCall && !IsSibCall) {
2667 std::vector<SDValue> Ops;
2668 Ops.push_back(Chain);
2669 Ops.push_back(Callee);
2677 Ops.push_back(PhysReturnAddrReg);
2682 for (
auto &RegToPass : RegsToPass) {
2684 RegToPass.second.getValueType()));
2691 assert(Mask &&
"Missing call preserved mask for calling convention");
2695 Ops.push_back(InFlag);
2711 if (CallerSavedFP) {
2713 Chain = DAG.
getCopyToReg(Chain, DL, FPReg, CallerSavedFP, InFlag);
2717 uint64_t CalleePopBytes = NumBytes;
2726 return LowerCallResult(Chain, InFlag, CallConv, IsVarArg, Ins, DL, DAG,
2727 InVals, IsThisReturn,
2728 IsThisReturn ? OutVals[0] :
SDValue());
2734 .Case(
"m0", AMDGPU::M0)
2735 .
Case(
"exec", AMDGPU::EXEC)
2736 .
Case(
"exec_lo", AMDGPU::EXEC_LO)
2737 .
Case(
"exec_hi", AMDGPU::EXEC_HI)
2738 .
Case(
"flat_scratch", AMDGPU::FLAT_SCR)
2739 .
Case(
"flat_scratch_lo", AMDGPU::FLAT_SCR_LO)
2740 .
Case(
"flat_scratch_hi", AMDGPU::FLAT_SCR_HI)
2743 if (Reg == AMDGPU::NoRegister) {
2752 +
StringRef(RegName) +
"\" for subtarget."));
2757 case AMDGPU::EXEC_LO:
2758 case AMDGPU::EXEC_HI:
2759 case AMDGPU::FLAT_SCR_LO:
2760 case AMDGPU::FLAT_SCR_HI:
2765 case AMDGPU::FLAT_SCR:
2786 if (SplitPoint == BB->
end()) {
2821 unsigned InitSaveExecReg,
2824 bool IsIndirectSrc) {
2832 BuildMI(LoopBB, I, DL, TII->get(TargetOpcode::PHI), PhiReg)
2838 BuildMI(LoopBB, I, DL, TII->get(TargetOpcode::PHI), PhiExec)
2839 .addReg(InitSaveExecReg)
2845 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::V_READFIRSTLANE_B32), CurrentIdxReg)
2849 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::V_CMP_EQ_U32_e64), CondReg)
2850 .addReg(CurrentIdxReg)
2854 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_AND_SAVEEXEC_B64), NewExec)
2859 if (UseGPRIdxMode) {
2862 IdxReg = CurrentIdxReg;
2865 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_ADD_I32), IdxReg)
2869 unsigned IdxMode = IsIndirectSrc ?
2872 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_SET_GPR_IDX_ON))
2879 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_MOV_B32), AMDGPU::M0)
2882 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_ADD_I32), AMDGPU::M0)
2890 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_XOR_B64), AMDGPU::EXEC)
2891 .addReg(AMDGPU::EXEC)
2898 BuildMI(LoopBB, I, DL, TII->get(AMDGPU::S_CBRANCH_EXECNZ))
2912 unsigned InitResultReg,
2916 bool IsIndirectSrc) {
2926 BuildMI(MBB, I, DL, TII->get(TargetOpcode::IMPLICIT_DEF), TmpExec);
2929 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_MOV_B64), SaveExec)
2930 .addReg(AMDGPU::EXEC);
2939 MF->
insert(MBBI, LoopBB);
2940 MF->
insert(MBBI, RemainderBB);
2954 InitResultReg, DstReg, PhiReg, TmpExec,
2955 Offset, UseGPRIdxMode, IsIndirectSrc);
2958 BuildMI(*RemainderBB, First, DL, TII->get(AMDGPU::S_MOV_B64), AMDGPU::EXEC)
2965 static std::pair<unsigned, int>
2970 int NumElts = TRI.getRegSizeInBits(*SuperRC) / 32;
2974 if (Offset >= NumElts || Offset < 0)
2975 return std::make_pair(AMDGPU::sub0, Offset);
2977 return std::make_pair(AMDGPU::sub0 + Offset, 0);
2986 bool IsIndirectSrc) {
2999 if (UseGPRIdxMode) {
3000 unsigned IdxMode = IsIndirectSrc ?
3004 BuildMI(*MBB, I, DL, TII->get(AMDGPU::S_SET_GPR_IDX_ON))
3011 BuildMI(*MBB, I, DL, TII->get(AMDGPU::S_ADD_I32), Tmp)
3015 BuildMI(*MBB, I, DL, TII->get(AMDGPU::S_SET_GPR_IDX_ON))
3026 BuildMI(*MBB, I, DL, TII->get(AMDGPU::S_MOV_B32), AMDGPU::M0)
3029 BuildMI(*MBB, I, DL, TII->get(AMDGPU::S_ADD_I32), AMDGPU::M0)
3053 std::tie(SubReg, Offset)
3062 if (UseGPRIdxMode) {
3066 BuildMI(MBB, I, DL, TII->get(AMDGPU::V_MOV_B32_e32), Dst)
3070 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_SET_GPR_IDX_OFF));
3072 BuildMI(MBB, I, DL, TII->get(AMDGPU::V_MOVRELS_B32_e32), Dst)
3088 BuildMI(MBB, I, DL, TII->get(TargetOpcode::IMPLICIT_DEF), InitReg);
3091 Offset, UseGPRIdxMode,
true);
3094 if (UseGPRIdxMode) {
3095 BuildMI(*LoopBB, InsPt, DL, TII->get(AMDGPU::V_MOV_B32_e32), Dst)
3099 BuildMI(*LoopBB, InsPt, DL, TII->get(AMDGPU::S_SET_GPR_IDX_OFF));
3101 BuildMI(*LoopBB, InsPt, DL, TII->get(AMDGPU::V_MOVRELS_B32_e32), Dst)
3113 switch (TRI.getRegSizeInBits(*VecRC)) {
3115 return AMDGPU::V_MOVRELD_B32_V1;
3117 return AMDGPU::V_MOVRELD_B32_V2;
3119 return AMDGPU::V_MOVRELD_B32_V4;
3121 return AMDGPU::V_MOVRELD_B32_V8;
3123 return AMDGPU::V_MOVRELD_B32_V16;
3153 if (Idx->
getReg() == AMDGPU::NoRegister) {
3159 BuildMI(MBB, I, DL, TII->get(TargetOpcode::INSERT_SUBREG), Dst)
3172 if (UseGPRIdxMode) {
3173 BuildMI(MBB, I, DL, TII->get(AMDGPU::V_MOV_B32_indirect))
3180 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_SET_GPR_IDX_OFF));
3184 BuildMI(MBB, I, DL, MovRelDesc)
3188 .addImm(SubReg - AMDGPU::sub0);
3203 Offset, UseGPRIdxMode,
false);
3206 if (UseGPRIdxMode) {
3207 BuildMI(*LoopBB, InsPt, DL, TII->get(AMDGPU::V_MOV_B32_indirect))
3213 BuildMI(*LoopBB, InsPt, DL, TII->get(AMDGPU::S_SET_GPR_IDX_OFF));
3217 BuildMI(*LoopBB, InsPt, DL, MovRelDesc)
3221 .
addImm(SubReg - AMDGPU::sub0);
3247 case AMDGPU::S_ADD_U64_PSEUDO:
3248 case AMDGPU::S_SUB_U64_PSEUDO: {
3260 Src0, &AMDGPU::SReg_64RegClass, AMDGPU::sub0,
3261 &AMDGPU::SReg_32_XM0RegClass);
3263 Src0, &AMDGPU::SReg_64RegClass, AMDGPU::sub1,
3264 &AMDGPU::SReg_32_XM0RegClass);
3267 Src1, &AMDGPU::SReg_64RegClass, AMDGPU::sub0,
3268 &AMDGPU::SReg_32_XM0RegClass);
3270 Src1, &AMDGPU::SReg_64RegClass, AMDGPU::sub1,
3271 &AMDGPU::SReg_32_XM0RegClass);
3273 bool IsAdd = (MI.
getOpcode() == AMDGPU::S_ADD_U64_PSEUDO);
3275 unsigned LoOpc = IsAdd ? AMDGPU::S_ADD_U32 : AMDGPU::S_SUB_U32;
3276 unsigned HiOpc = IsAdd ? AMDGPU::S_ADDC_U32 : AMDGPU::S_SUBB_U32;
3277 BuildMI(*BB, MI, DL, TII->get(LoOpc), DestSub0)
3280 BuildMI(*BB, MI, DL, TII->get(HiOpc), DestSub1)
3283 BuildMI(*BB, MI, DL, TII->get(TargetOpcode::REG_SEQUENCE), Dest.
getReg())
3291 case AMDGPU::SI_INIT_M0: {
3293 TII->get(AMDGPU::S_MOV_B32), AMDGPU::M0)
3298 case AMDGPU::SI_INIT_EXEC:
3306 case AMDGPU::SI_INIT_EXEC_FROM_INPUT: {
3322 if (
I->getOpcode() != TargetOpcode::COPY ||
3323 I->getOperand(0).getReg() != InputReg)
3327 FirstMI = &*++BB->
begin();
3329 I->removeFromParent();
3339 BuildMI(*BB, FirstMI,
DebugLoc(), TII->get(AMDGPU::S_BFE_U32), CountReg)
3356 case AMDGPU::GET_GROUPSTATICSIZE: {
3358 BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_MOV_B32))
3364 case AMDGPU::SI_INDIRECT_SRC_V1:
3365 case AMDGPU::SI_INDIRECT_SRC_V2:
3366 case AMDGPU::SI_INDIRECT_SRC_V4:
3367 case AMDGPU::SI_INDIRECT_SRC_V8:
3368 case AMDGPU::SI_INDIRECT_SRC_V16:
3370 case AMDGPU::SI_INDIRECT_DST_V1:
3371 case AMDGPU::SI_INDIRECT_DST_V2:
3372 case AMDGPU::SI_INDIRECT_DST_V4:
3373 case AMDGPU::SI_INDIRECT_DST_V8:
3374 case AMDGPU::SI_INDIRECT_DST_V16:
3376 case AMDGPU::SI_KILL_F32_COND_IMM_PSEUDO:
3377 case AMDGPU::SI_KILL_I1_PSEUDO:
3379 case AMDGPU::V_CNDMASK_B64_PSEUDO: {
3392 BuildMI(*BB, MI, DL, TII->get(AMDGPU::COPY), SrcCondCopy)
3394 BuildMI(*BB, MI, DL, TII->get(AMDGPU::V_CNDMASK_B32_e64), DstLo)
3395 .addReg(Src0, 0, AMDGPU::sub0)
3396 .
addReg(Src1, 0, AMDGPU::sub0)
3398 BuildMI(*BB, MI, DL, TII->get(AMDGPU::V_CNDMASK_B32_e64), DstHi)
3399 .addReg(Src0, 0, AMDGPU::sub1)
3400 .
addReg(Src1, 0, AMDGPU::sub1)
3403 BuildMI(*BB, MI, DL, TII->get(AMDGPU::REG_SEQUENCE), Dst)
3411 case AMDGPU::SI_BR_UNDEF: {
3420 case AMDGPU::ADJCALLSTACKUP:
3421 case AMDGPU::ADJCALLSTACKDOWN: {
3433 case AMDGPU::SI_CALL_ISEL:
3434 case AMDGPU::SI_TCRETURN_ISEL: {
3447 if (MI.
getOpcode() == AMDGPU::SI_CALL_ISEL) {
3448 MIB =
BuildMI(*BB, MI, DL, TII->get(AMDGPU::SI_CALL), ReturnAddrReg)
3450 .addGlobalAddress(G);
3452 MIB =
BuildMI(*BB, MI, DL, TII->get(AMDGPU::SI_TCRETURN))
3454 .addGlobalAddress(G);
3597 "Load should return a value and a chain");
3603 return LowerTrig(Op, DAG);
3605 case ISD::FDIV:
return LowerFDIV(Op, DAG);
3611 return LowerGlobalAddress(MFI, Op, DAG);
3618 return lowerINSERT_VECTOR_ELT(Op, DAG);
3620 return lowerEXTRACT_VECTOR_ELT(Op, DAG);
3622 return lowerBUILD_VECTOR(Op, DAG);
3624 return lowerFP_ROUND(Op, DAG);
3626 return lowerTRAP(Op, DAG);
3628 return lowerDEBUGTRAP(Op, DAG);
3678 SDValue SITargetLowering::adjustLoadValueType(
unsigned Opcode,
3681 bool IsIntrinsic)
const {
3697 EVT EquivLoadVT = LoadVT;
3698 if (Unpacked && LoadVT.
isVector()) {
3735 unsigned IID = cast<ConstantSDNode>(N->
getOperand(0))->getZExtValue();
3737 case Intrinsic::amdgcn_cvt_pkrtz: {
3746 case Intrinsic::amdgcn_cvt_pknorm_i16:
3747 case Intrinsic::amdgcn_cvt_pknorm_u16:
3748 case Intrinsic::amdgcn_cvt_pk_i16:
3749 case Intrinsic::amdgcn_cvt_pk_u16: {
3755 if (IID == Intrinsic::amdgcn_cvt_pknorm_i16)
3757 else if (IID == Intrinsic::amdgcn_cvt_pknorm_u16)
3759 else if (IID == Intrinsic::amdgcn_cvt_pk_i16)
3787 EVT SelectVT = NewVT;
3797 if (NewVT != SelectVT)
3840 if (
I.getUse().get() != Value)
3843 if (
I->getOpcode() == Opcode)
3849 unsigned SITargetLowering::isCFIntrinsic(
const SDNode *
Intr)
const {
3851 switch (cast<ConstantSDNode>(Intr->
getOperand(1))->getZExtValue()) {
3852 case Intrinsic::amdgcn_if:
3854 case Intrinsic::amdgcn_else:
3856 case Intrinsic::amdgcn_loop:
3858 case Intrinsic::amdgcn_end_cf:
3870 void SITargetLowering::createDebuggerPrologueStackObjects(
3886 for (
unsigned i = 0; i < 3; ++i) {
3896 bool SITargetLowering::shouldEmitFixup(
const GlobalValue *GV)
const {
3903 bool SITargetLowering::shouldEmitGOTReloc(
const GlobalValue *GV)
const {
3907 !shouldEmitFixup(GV) &&
3911 bool SITargetLowering::shouldEmitPCReloc(
const GlobalValue *GV)
const {
3912 return !shouldEmitFixup(GV) && !shouldEmitGOTReloc(GV);
3944 unsigned CFNode = isCFIntrinsic(Intr);
3994 for (
unsigned i = 1, e = Intr->
getNumValues() - 1; i != e; ++i) {
4027 "Do not know how to custom lower FP_ROUND for non-f16 type");
4030 EVT SrcVT = Src.getValueType();
4052 assert(UserSGPR != AMDGPU::NoRegister);
4054 DAG, &AMDGPU::SReg_64RegClass, UserSGPR,
MVT::i64);
4075 "debugtrap handler not supported",
4090 SDValue SITargetLowering::getSegmentAperture(
unsigned AS,
const SDLoc &DL,
4115 assert(UserSGPR != AMDGPU::NoRegister);
4118 DAG, &AMDGPU::SReg_64RegClass, UserSGPR,
MVT::i64);
4162 NonNull, Ptr, SegmentNullPtr);
4215 if (NumElts == 4 && EltSize == 16 && KIdx) {
4226 unsigned Idx = KIdx->getZExtValue();
4227 bool InsertLo = Idx < 2;
4229 InsertLo ? LoVec : HiVec,
4242 if (isa<ConstantSDNode>(Idx))
4268 DAG.
getNOT(SL, BFM, IntVT), BCVec);
4292 if (
SDValue Combined = performExtractVectorEltCombine(Op.
getNode(), DCI))
4367 const SDLoc &DL,
unsigned Offset,
EVT PtrVT,
4403 GAFlags : GAFlags + 1);
4418 !GV->getType()->getElementType()->isFunctionTy())
4424 if (shouldEmitFixup(GV))
4426 else if (shouldEmitPCReloc(GV))
4464 unsigned Offset)
const {
4476 "non-hsa intrinsic with hsa target",
4485 "intrinsic not supported on subtarget",
4497 if (Elts.
size() == 1) {
4500 }
else if (Elts.
size() == 2) {
4503 }
else if (Elts.
size() <= 4) {
4506 }
else if (Elts.
size() <= 8) {
4516 for (
unsigned i = 0; i < Elts.
size(); ++i) {
4522 for (
unsigned i = Elts.
size(); i < NumElts; ++i)
4533 if (!CachePolicyConst)
4536 uint64_t
Value = CachePolicyConst->getZExtValue();
4537 SDLoc DL(CachePolicy);
4540 Value &= ~(uint64_t)0x1;
4544 Value &= ~(uint64_t)0x2;
4551 const AMDGPU::ImageDimIntrinsicInfo *Intr,
4555 const AMDGPU::MIMGBaseOpcodeInfo *BaseOpcode =
4558 const AMDGPU::MIMGLZMappingInfo *LZMappingInfo =
4560 unsigned IntrOpcode = Intr->BaseOpcode;
4569 if (BaseOpcode->Atomic) {
4573 if (BaseOpcode->AtomicX2) {
4581 DMask = Is64Bit ? 0xf : 0x3;
4582 NumVDataDwords = Is64Bit ? 4 : 2;
4585 DMask = Is64Bit ? 0x3 : 0x1;
4586 NumVDataDwords = Is64Bit ? 2 : 1;
4592 if (BaseOpcode->Store) {
4598 !BaseOpcode->HasD16)
4602 VData = handleD16VData(VData, DAG);
4611 !BaseOpcode->HasD16)
4619 NumVDataDwords = (ResultTypes[0].getSizeInBits() + 31) / 32;
4620 DMaskIdx = isa<MemSDNode>(
Op) ? 2 : 1;
4627 AddrIdx = DMaskIdx + 1;
4628 DMask = DMaskConst->getZExtValue();
4629 if (!DMask && !BaseOpcode->Store) {
4633 if (isa<MemSDNode>(Op))
4639 unsigned NumVAddrs = BaseOpcode->NumExtraArgs +
4640 (BaseOpcode->Gradients ? DimInfo->NumGradients : 0) +
4641 (BaseOpcode->Coordinates ? DimInfo->NumCoords : 0) +
4642 (BaseOpcode->LodOrClampOrMip ? 1 : 0);
4644 for (
unsigned i = 0; i < NumVAddrs; ++i)
4648 if (LZMappingInfo) {
4649 if (
auto ConstantLod =
4650 dyn_cast<ConstantFPSDNode>(VAddrs[NumVAddrs-1].getNode())) {
4651 if (ConstantLod->isZero() || ConstantLod->isNegative()) {
4652 IntrOpcode = LZMappingInfo->LZ;
4664 if (!BaseOpcode->Sampler) {
4666 CtrlIdx = AddrIdx + NumVAddrs + 1;
4673 Unorm = UnormConst->getZExtValue() ? True : False;
4674 CtrlIdx = AddrIdx + NumVAddrs + 3;
4679 if (!TexFailConst || TexFailConst->getZExtValue() != 0)
4684 if (BaseOpcode->Atomic) {
4694 if (BaseOpcode->Store || BaseOpcode->Atomic)
4698 if (BaseOpcode->Sampler)
4707 Ops.
push_back(DimInfo->DA ? True : False);
4708 if (BaseOpcode->HasD16)
4710 if (isa<MemSDNode>(Op))
4718 NumVDataDwords, NumVAddrDwords);
4721 NumVDataDwords, NumVAddrDwords);
4725 if (
auto MemOp = dyn_cast<MemSDNode>(Op)) {
4727 *MemRefs = MemOp->getMemOperand();
4731 if (BaseOpcode->AtomicX2) {
4735 }
else if (IsD16 && !BaseOpcode->Store) {
4752 unsigned IntrinsicID = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
4756 switch (IntrinsicID) {
4757 case Intrinsic::amdgcn_implicit_buffer_ptr: {
4760 return getPreloadedValue(DAG, *MFI, VT,
4763 case Intrinsic::amdgcn_dispatch_ptr:
4764 case Intrinsic::amdgcn_queue_ptr: {
4767 MF.
getFunction(),
"unsupported hsa intrinsic without hsa target",
4773 auto RegID = IntrinsicID == Intrinsic::amdgcn_dispatch_ptr ?
4775 return getPreloadedValue(DAG, *MFI, VT, RegID);
4777 case Intrinsic::amdgcn_implicitarg_ptr: {
4779 return getImplicitArgPtr(DAG, DL);
4780 return getPreloadedValue(DAG, *MFI, VT,
4783 case Intrinsic::amdgcn_kernarg_segment_ptr: {
4784 return getPreloadedValue(DAG, *MFI, VT,
4787 case Intrinsic::amdgcn_dispatch_id: {
4790 case Intrinsic::amdgcn_rcp:
4792 case Intrinsic::amdgcn_rsq:
4794 case Intrinsic::amdgcn_rsq_legacy:
4799 case Intrinsic::amdgcn_rcp_legacy:
4803 case Intrinsic::amdgcn_rsq_clamp: {
4817 case Intrinsic::r600_read_ngroups_x:
4821 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4823 case Intrinsic::r600_read_ngroups_y:
4827 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4829 case Intrinsic::r600_read_ngroups_z:
4833 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4835 case Intrinsic::r600_read_global_size_x:
4839 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4841 case Intrinsic::r600_read_global_size_y:
4845 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4847 case Intrinsic::r600_read_global_size_z:
4851 return lowerKernargMemParameter(DAG, VT, VT, DL, DAG.
getEntryNode(),
4853 case Intrinsic::r600_read_local_size_x:
4857 return lowerImplicitZextParam(DAG, Op,
MVT::i16,
4859 case Intrinsic::r600_read_local_size_y:
4863 return lowerImplicitZextParam(DAG, Op,
MVT::i16,
4865 case Intrinsic::r600_read_local_size_z:
4869 return lowerImplicitZextParam(DAG, Op,
MVT::i16,
4871 case Intrinsic::amdgcn_workgroup_id_x:
4872 case Intrinsic::r600_read_tgid_x:
4873 return getPreloadedValue(DAG, *MFI, VT,
4875 case Intrinsic::amdgcn_workgroup_id_y:
4876 case Intrinsic::r600_read_tgid_y:
4877 return getPreloadedValue(DAG, *MFI, VT,
4879 case Intrinsic::amdgcn_workgroup_id_z:
4880 case Intrinsic::r600_read_tgid_z:
4881 return getPreloadedValue(DAG, *MFI, VT,
4883 case Intrinsic::amdgcn_workitem_id_x: {
4884 case Intrinsic::r600_read_tidig_x:
4887 MFI->getArgInfo().WorkItemIDX);
4889 case Intrinsic::amdgcn_workitem_id_y:
4890 case Intrinsic::r600_read_tidig_y:
4893 MFI->getArgInfo().WorkItemIDY);
4894 case Intrinsic::amdgcn_workitem_id_z:
4895 case Intrinsic::r600_read_tidig_z:
4898 MFI->getArgInfo().WorkItemIDZ);
4899 case AMDGPUIntrinsic::SI_load_const: {
4909 VT.getStoreSize(), 4);
4913 case Intrinsic::amdgcn_fdiv_fast:
4914 return lowerFDIV_FAST(Op, DAG);
4915 case Intrinsic::amdgcn_interp_mov: {
4921 case Intrinsic::amdgcn_interp_p1: {
4927 case Intrinsic::amdgcn_interp_p2: {
4934 case Intrinsic::amdgcn_sin:
4937 case Intrinsic::amdgcn_cos:
4940 case Intrinsic::amdgcn_log_clamp: {
4945 MF.
getFunction(),
"intrinsic not supported on subtarget",
4950 case Intrinsic::amdgcn_ldexp:
4954 case Intrinsic::amdgcn_fract:
4957 case Intrinsic::amdgcn_class:
4960 case Intrinsic::amdgcn_div_fmas:
4965 case Intrinsic::amdgcn_div_fixup:
4969 case Intrinsic::amdgcn_trig_preop:
4972 case Intrinsic::amdgcn_div_scale: {
4991 Denominator, Numerator);
4993 case Intrinsic::amdgcn_icmp: {
4999 if (CondCode < ICmpInst::Predicate::FIRST_ICMP_PREDICATE ||
5000 CondCode > ICmpInst::Predicate::LAST_ICMP_PREDICATE)
5008 case Intrinsic::amdgcn_fcmp: {
5014 if (CondCode < FCmpInst::Predicate::FIRST_FCMP_PREDICATE ||
5015 CondCode > FCmpInst::Predicate::LAST_FCMP_PREDICATE)
5023 case Intrinsic::amdgcn_fmed3:
5026 case Intrinsic::amdgcn_fdot2:
5030 case Intrinsic::amdgcn_fmul_legacy:
5033 case Intrinsic::amdgcn_sffbh:
5035 case Intrinsic::amdgcn_sbfe:
5038 case Intrinsic::amdgcn_ubfe:
5041 case Intrinsic::amdgcn_cvt_pkrtz:
5042 case Intrinsic::amdgcn_cvt_pknorm_i16:
5043 case Intrinsic::amdgcn_cvt_pknorm_u16:
5044 case Intrinsic::amdgcn_cvt_pk_i16:
5045 case Intrinsic::amdgcn_cvt_pk_u16: {
5050 if (IntrinsicID == Intrinsic::amdgcn_cvt_pkrtz)
5052 else if (IntrinsicID == Intrinsic::amdgcn_cvt_pknorm_i16)
5054 else if (IntrinsicID == Intrinsic::amdgcn_cvt_pknorm_u16)
5056 else if (IntrinsicID == Intrinsic::amdgcn_cvt_pk_i16)
5065 case Intrinsic::amdgcn_wqm: {
5070 case Intrinsic::amdgcn_wwm: {
5075 case Intrinsic::amdgcn_fmad_ftz:
5079 if (
const AMDGPU::ImageDimIntrinsicInfo *ImageDimIntr =
5081 return lowerImage(Op, ImageDimIntr, DAG);
5089 unsigned IntrID = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
5093 case Intrinsic::amdgcn_atomic_inc:
5094 case Intrinsic::amdgcn_atomic_dec:
5095 case Intrinsic::amdgcn_ds_fadd:
5096 case Intrinsic::amdgcn_ds_fmin:
5097 case Intrinsic::amdgcn_ds_fmax: {
5101 case Intrinsic::amdgcn_atomic_inc:
5104 case Intrinsic::amdgcn_atomic_dec:
5107 case Intrinsic::amdgcn_ds_fadd:
5110 case Intrinsic::amdgcn_ds_fmin:
5113 case Intrinsic::amdgcn_ds_fmax:
5128 case Intrinsic::amdgcn_buffer_load:
5129 case Intrinsic::amdgcn_buffer_load_format: {
5139 unsigned Opc = (IntrID == Intrinsic::amdgcn_buffer_load) ?
5143 auto *M = cast<MemSDNode>(
Op);
5152 case Intrinsic::amdgcn_tbuffer_load: {
5177 case Intrinsic::amdgcn_buffer_atomic_swap:
5178 case Intrinsic::amdgcn_buffer_atomic_add:
5179 case Intrinsic::amdgcn_buffer_atomic_sub:
5180 case Intrinsic::amdgcn_buffer_atomic_smin:
5181 case Intrinsic::amdgcn_buffer_atomic_umin:
5182 case Intrinsic::amdgcn_buffer_atomic_smax:
5183 case Intrinsic::amdgcn_buffer_atomic_umax:
5184 case Intrinsic::amdgcn_buffer_atomic_and:
5185 case Intrinsic::amdgcn_buffer_atomic_or:
5186 case Intrinsic::amdgcn_buffer_atomic_xor: {
5197 auto *M = cast<MemSDNode>(
Op);
5198 unsigned Opcode = 0;
5201 case Intrinsic::amdgcn_buffer_atomic_swap:
5204 case Intrinsic::amdgcn_buffer_atomic_add:
5207 case Intrinsic::amdgcn_buffer_atomic_sub:
5210 case Intrinsic::amdgcn_buffer_atomic_smin:
5213 case Intrinsic::amdgcn_buffer_atomic_umin:
5216 case Intrinsic::amdgcn_buffer_atomic_smax:
5219 case Intrinsic::amdgcn_buffer_atomic_umax:
5222 case Intrinsic::amdgcn_buffer_atomic_and:
5225 case Intrinsic::amdgcn_buffer_atomic_or:
5228 case Intrinsic::amdgcn_buffer_atomic_xor:
5239 case Intrinsic::amdgcn_buffer_atomic_cmpswap: {
5250 auto *M = cast<MemSDNode>(
Op);
5257 if (
const AMDGPU::ImageDimIntrinsicInfo *ImageDimIntr =
5259 return lowerImage(Op, ImageDimIntr, DAG);
5295 unsigned IntrinsicID = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
5298 switch (IntrinsicID) {
5299 case Intrinsic::amdgcn_exp: {
5317 unsigned Opc = Done->isNullValue() ?
5321 case Intrinsic::amdgcn_exp_compr: {
5346 case Intrinsic::amdgcn_s_sendmsg:
5347 case Intrinsic::amdgcn_s_sendmsghalt: {
5348 unsigned NodeOp = (IntrinsicID == Intrinsic::amdgcn_s_sendmsg) ?
5355 case Intrinsic::amdgcn_init_exec: {
5359 case Intrinsic::amdgcn_init_exec_from_input: {
5363 case AMDGPUIntrinsic::AMDGPU_kill: {
5366 if (!K->isNegative())
5376 case Intrinsic::amdgcn_s_barrier: {
5386 case AMDGPUIntrinsic::SI_tbuffer_store: {
5396 "Legacy intrinsic doesn't support both offset and index - use new version");
5398 SDValue VIndex = IdxEn->isOne() ? VAddr : Zero;
5421 "Value of tfe other than zero is unsupported");
5427 VT.getStoreSize(), 4);
5432 case Intrinsic::amdgcn_tbuffer_store: {
5436 VData = handleD16VData(VData, DAG);
5457 case Intrinsic::amdgcn_buffer_store:
5458 case Intrinsic::amdgcn_buffer_store_format: {
5462 VData = handleD16VData(VData, DAG);
5472 unsigned Opc = IntrinsicID == Intrinsic::amdgcn_buffer_store ?
5480 if (
const AMDGPU::ImageDimIntrinsicInfo *ImageDimIntr =
5482 return lowerImage(Op, ImageDimIntr, DAG);
5509 SDValue SITargetLowering::widenLoad(
LoadSDNode *Ld, DAGCombinerInfo &DCI)
const {
5525 if ((MemVT.
isSimple() && !DCI.isAfterLegalizeDAG()) ||
5532 "unexpected vector extload");
5548 "unexpected fp extload");
5566 DCI.AddToWorklist(Cvt.
getNode());
5571 DCI.AddToWorklist(Cvt.
getNode());
5599 BasePtr, RealMemVT, MMO);
5613 "Custom lowering for non-i32 vectors hasn't been implemented.");
5660 if (NumElements > 4)
5673 if (NumElements > 2)
5678 if (NumElements > 4)
5690 if (NumElements > 2)
5739 if (CLHS->isExactlyValue(1.0)) {
5759 if (CLHS->isExactlyValue(-1.0)) {
5780 return DAG.
getNode(Opcode, SL, VT, A, B);
5801 return DAG.
getNode(Opcode, SL, VT, A, B, C);
5819 if (
SDValue FastLowered = lowerFastUnsafeFDIV(Op, DAG))
5873 if (
SDValue FastLowered = lowerFastUnsafeFDIV(Op, DAG))
5907 EnableDenormValue, BitField);
5918 ApproxRcp, One, NegDivScale0);
5927 NumeratorScaled, Mul);
5932 NumeratorScaled, Fma3);
5935 const SDValue DisableDenormValue =
5944 DisableDenorm, DAG.
getRoot());
5950 Fma4, Fma1, Fma3, Scale);
5957 return lowerFastUnsafeFDIV(Op, DAG);
5985 NegDivScale0, Mul, DivScale1);
6017 Fma4, Fma3, Mul, Scale);
6026 return LowerFDIV32(Op, DAG);
6029 return LowerFDIV64(Op, DAG);
6032 return LowerFDIV16(Op, DAG);
6065 unsigned NumElements = VT.getVectorNumElements();
6068 if (NumElements > 4)
6076 if (NumElements > 2)
6080 if (NumElements > 4)
6089 VT.getStoreSize() == 16)
6092 if (NumElements > 2)
6141 SDValue Ops[] = { ChainIn, Addr, NewOld };
6152 DAGCombinerInfo &DCI)
const {
6168 if (DCI.isAfterLegalizeDAG() && SrcVT ==
MVT::i32) {
6171 DCI.AddToWorklist(Cvt.
getNode());
6196 DAGCombinerInfo &DCI)
const {
6241 DAGCombinerInfo &DCI)
const {
6262 return (Opc ==
ISD::AND && (Val == 0 || Val == 0xffffffff)) ||
6263 (Opc ==
ISD::OR && (Val == 0xffffffff || Val == 0)) ||
6272 SDValue SITargetLowering::splitBinaryBitConstantOp(
6273 DAGCombinerInfo &DCI,
6316 if (!(C & 0x000000ff)) ZeroByteMask |= 0x000000ff;
6317 if (!(C & 0x0000ff00)) ZeroByteMask |= 0x0000ff00;
6318 if (!(C & 0x00ff0000)) ZeroByteMask |= 0x00ff0000;
6319 if (!(C & 0xff000000)) ZeroByteMask |= 0xff000000;
6320 uint32_t NonZeroByteMask = ~ZeroByteMask;
6321 if ((NonZeroByteMask & C) != NonZeroByteMask)
6350 return (0x03020100 & ConstMask) | (0x0c0c0c0c & ~ConstMask);
6356 return (0x03020100 & ~ConstMask) | ConstMask;
6364 return uint32_t((0x030201000c0c0c0cull << C) >> 32);
6370 return uint32_t(0x0c0c0c0c03020100ull >> C);
6377 DAGCombinerInfo &DCI)
const {
6378 if (DCI.isBeforeLegalize())
6390 = splitBinaryBitConstantOp(DCI,
SDLoc(N),
ISD::AND, LHS, CRHS))
6403 if (
auto *CShift = dyn_cast<ConstantSDNode>(LHS->
getOperand(1))) {
6404 unsigned Shift = CShift->getZExtValue();
6406 unsigned Offset = NB + Shift;
6407 if ((Offset & (Bits - 1)) == 0) {
6494 if (LHSMask != ~0u && RHSMask != ~0u) {
6497 if (LHSMask > RHSMask) {
6504 uint32_t LHSUsedLanes = ~(LHSMask & 0x0c0c0c0c) & 0x0c0c0c0c;
6505 uint32_t RHSUsedLanes = ~(RHSMask & 0x0c0c0c0c) & 0x0c0c0c0c;
6508 if (!(LHSUsedLanes & RHSUsedLanes) &&
6511 !(LHSUsedLanes == 0x0c0c0000 && RHSUsedLanes == 0x00000c0c)) {
6518 for (
unsigned I = 0;
I < 32;
I += 8) {
6520 if ((LHSMask & ByteSel) == 0x0c || (RHSMask & ByteSel) == 0x0c)
6521 Mask &= (0x0c <<
I) & 0xffffffff;
6526 uint32_t Sel = Mask | (LHSUsedLanes & 0x04040404);
6540 DAGCombinerInfo &DCI)
const {
6560 static const uint32_t MaxMask = 0x3ff;
6572 if (isa<ConstantSDNode>(RHS) && LHS.
hasOneUse() &&
6591 if (LHSMask != ~0u && RHSMask != ~0u) {
6594 if (LHSMask > RHSMask) {
6601 uint32_t LHSUsedLanes = ~(LHSMask & 0x0c0c0c0c) & 0x0c0c0c0c;
6602 uint32_t RHSUsedLanes = ~(RHSMask & 0x0c0c0c0c) & 0x0c0c0c0c;
6605 if (!(LHSUsedLanes & RHSUsedLanes) &&
6608 !(LHSUsedLanes == 0x0c0c0000 && RHSUsedLanes == 0x00000c0c)) {
6610 LHSMask &= ~RHSUsedLanes;
6611 RHSMask &= ~LHSUsedLanes;
6613 LHSMask |= LHSUsedLanes & 0x04040404;
6646 DCI.AddToWorklist(LowOr.
getNode());
6647 DCI.AddToWorklist(HiBits.
getNode());
6658 = splitBinaryBitConstantOp(DCI,
SDLoc(N),
ISD::OR, LHS, CRHS))
6666 DAGCombinerInfo &DCI)
const {
6677 = splitBinaryBitConstantOp(DCI,
SDLoc(N),
ISD::XOR, LHS, CRHS))
6741 SDValue SITargetLowering::performZeroExtendCombine(
SDNode *N,
6742 DAGCombinerInfo &DCI)
const {
6768 DAGCombinerInfo &DCI)
const {
6773 if (
const ConstantSDNode *CMask = dyn_cast<ConstantSDNode>(Mask)) {
6774 if (CMask->isNullValue())
6785 DAGCombinerInfo &DCI)
const {
6867 auto F = cast<ConstantFPSDNode>(
Op)->getValueAPF();
6868 return !
F.isDenormal() && !(
F.isNaN() &&
F.isSignaling());
6875 SDValue SITargetLowering::performFCanonicalizeCombine(
6877 DAGCombinerInfo &DCI)
const {
6894 if (((VT ==
MVT::f32 &&
ST->hasFP32Denormals()) ||
6895 (VT ==
MVT::f64 &&
ST->hasFP64Denormals()) ||
6896 (VT ==
MVT::f16 &&
ST->hasFP16Denormals())) &&
6963 SDValue SITargetLowering::performIntMed3ImmCombine(
6985 return DAG.
getNode(Med3Opc, SL, VT,
7058 DAGCombinerInfo &DCI)
const {
7101 if (
SDValue Med3 = performIntMed3ImmCombine(DAG,
SDLoc(N), Op0, Op1,
true))
7106 if (
SDValue Med3 = performIntMed3ImmCombine(DAG,
SDLoc(N), Op0, Op1,
false))
7118 if (
SDValue Res = performFPMed3ImmCombine(DAG,
SDLoc(N), Op0, Op1))
7129 return (CA->isExactlyValue(0.0) && CB->isExactlyValue(1.0)) ||
7130 (CA->isExactlyValue(1.0) && CB->isExactlyValue(0.0));
7139 DAGCombinerInfo &DCI)
const {
7163 if (isa<ConstantFPSDNode>(Src0) && !isa<ConstantFPSDNode>(Src1))
7166 if (isa<ConstantFPSDNode>(Src1) && !isa<ConstantFPSDNode>(Src2))
7169 if (isa<ConstantFPSDNode>(Src0) && !isa<ConstantFPSDNode>(Src1))
7180 DAGCombinerInfo &DCI)
const {
7188 SDValue SITargetLowering::performExtractVectorEltCombine(
7189 SDNode *N, DAGCombinerInfo &DCI)
const {
7211 if (Vec.
hasOneUse() && DCI.isBeforeLegalize()) {
7229 return DAG.
getNode(Opc, SL, EltVT,
7237 if (!DCI.isBeforeLegalize())
7247 if (EltSize <= 16 &&
7250 VecSize % 32 == 0 &&
7254 unsigned BitIndex = Idx->getZExtValue() * EltSize;
7255 unsigned EltIdx = BitIndex / 32;
7256 unsigned LeftoverBitIdx = BitIndex % 32;
7260 DCI.AddToWorklist(Cast.
getNode());
7264 DCI.AddToWorklist(Elt.
getNode());
7267 DCI.AddToWorklist(Srl.
getNode());
7270 DCI.AddToWorklist(Trunc.
getNode());
7281 (isa<ConstantSDNode>(
Lo) || Lo.
isUndef())) {
7290 SDValue SITargetLowering::performBuildVectorCombine(
7291 SDNode *N, DAGCombinerInfo &DCI)
const {
7319 unsigned SITargetLowering::getFusedOpcode(
const SelectionDAG &DAG,
7321 const SDNode *N1)
const {
7352 DAGCombinerInfo &DCI)
const {
7376 return getMad64_32(DAG, SL, VT, MulLHS, MulRHS, AddRHS,
false);
7383 return getMad64_32(DAG, SL, VT, MulLHS, MulRHS, AddRHS,
true);
7389 if (VT !=
MVT::i32 || !DCI.isAfterLegalizeDAG())
7411 return DAG.
getNode(Opc, SL, VTList, Args);
7416 if (!
C ||
C->getZExtValue() != 0)
break;
7425 DAGCombinerInfo &DCI)
const {
7443 if (!
C ||
C->getZExtValue() != 0)
7451 SDValue SITargetLowering::performAddCarrySubCarryCombine(
SDNode *N,
7452 DAGCombinerInfo &DCI)
const {
7458 if (!
C ||
C->getZExtValue() != 0)
7477 DAGCombinerInfo &DCI)
const {
7495 unsigned FusedOp = getFusedOpcode(DAG, N, LHS.
getNode());
7498 return DAG.
getNode(FusedOp, SL, VT, A, Two, RHS);
7507 unsigned FusedOp = getFusedOpcode(DAG, N, RHS.
getNode());
7510 return DAG.
getNode(FusedOp, SL, VT, A, Two, LHS);
7519 DAGCombinerInfo &DCI)
const {
7537 SDValue A = LHS.getOperand(0);
7539 unsigned FusedOp = getFusedOpcode(DAG, N, LHS.getNode());
7544 return DAG.
getNode(FusedOp, SL, VT, A, Two, NegRHS);
7554 unsigned FusedOp = getFusedOpcode(DAG, N, RHS.
getNode());
7557 return DAG.
getNode(FusedOp, SL, VT, A, NegTwo, LHS);
7566 DAGCombinerInfo &DCI)
const {
7625 if (Vec1 == Vec2 || Vec3 == Vec4)
7631 if ((Vec1 == Vec3 && Vec2 == Vec4) ||
7632 (Vec1 == Vec4 && Vec2 == Vec3)) {
7641 DAGCombinerInfo &DCI)
const {
7726 SDValue SITargetLowering::performCvtF32UByteNCombine(
SDNode *N,
7727 DAGCombinerInfo &DCI)
const {
7744 dyn_cast<ConstantSDNode>(Srl.
getOperand(1))) {
7748 unsigned SrcOffset =
C->getZExtValue() + 8 *
Offset;
7749 if (SrcOffset < 32 && SrcOffset % 8 == 0) {
7760 !DCI.isBeforeLegalizeOps());
7762 if (TLI.ShrinkDemandedConstant(Src, Demanded, TLO) ||
7763 TLI.SimplifyDemandedBits(Src, Demanded, Known, TLO)) {
7764 DCI.CommitTargetLoweringOpt(TLO);
7771 DAGCombinerInfo &DCI)
const {
7799 return performAddCombine(N, DCI);
7801 return performSubCombine(N, DCI);
7804 return performAddCarrySubCarryCombine(N, DCI);
7806 return performFAddCombine(N, DCI);
7808 return performFSubCombine(N, DCI);
7810 return performSetCCCombine(N, DCI);
7821 return performMinMaxCombine(N, DCI);
7825 return performFMACombine(N, DCI);
7827 if (
SDValue Widended = widenLoad(cast<LoadSDNode>(N), DCI))
7854 return performMemSDNodeCombine(cast<MemSDNode>(N), DCI);
7856 return performAndCombine(N, DCI);
7858 return performOrCombine(N, DCI);
7860 return performXorCombine(N, DCI);
7862 return performZeroExtendCombine(N, DCI);
7864 return performClassCombine(N, DCI);
7866 return performFCanonicalizeCombine(N, DCI);
7868 return performRcpCombine(N, DCI);
7883 return performUCharToFloatCombine(N, DCI);
7888 return performCvtF32UByteNCombine(N, DCI);
7890 return performFMed3Combine(N, DCI);
7892 return performCvtPkRTZCombine(N, DCI);
7894 return performClampCombine(N, DCI);
7914 return performExtractVectorEltCombine(N, DCI);
7916 return performBuildVectorCombine(N, DCI);
7925 case AMDGPU::sub0:
return 0;
7926 case AMDGPU::sub1:
return 1;
7927 case AMDGPU::sub2:
return 2;
7928 case AMDGPU::sub3:
return 3;
7946 unsigned NewDmask = 0;
7949 if (OldDmask == 0) {
7959 if (
I.getUse().getResNo() != 0)
7963 if (!
I->isMachineOpcode() ||
7964 I->getMachineOpcode() != TargetOpcode::EXTRACT_SUBREG)
7975 for (
unsigned i = 0, Dmask = OldDmask; i <= Lane; i++) {
7977 Dmask &= ~(1 << Comp);
7985 NewDmask |= 1 << Comp;
7989 if (NewDmask == OldDmask)
7995 assert(NewOpcode != -1 &&
7997 "failed to find equivalent MIMG op");
8007 MVT ResultVT = BitsSet == 1 ?
8032 for (
unsigned i = 0, Idx = AMDGPU::sub0; i < 4; ++i) {
8042 case AMDGPU::sub0: Idx = AMDGPU::sub1;
break;
8043 case AMDGPU::sub1: Idx = AMDGPU::sub2;
break;
8044 case AMDGPU::sub2: Idx = AMDGPU::sub3;
break;
8056 return isa<FrameIndexSDNode>(
Op);
8070 if (SrcVal.getValueType() ==
MVT::i1 &&
8113 if (TII->
isMIMG(Opcode) && !TII->get(Opcode).mayStore() &&
8115 return adjustWritemask(Node, DAG);
8118 if (Opcode == AMDGPU::INSERT_SUBREG ||
8119 Opcode == AMDGPU::REG_SEQUENCE) {
8125 case AMDGPU::V_DIV_SCALE_F32:
8126 case AMDGPU::V_DIV_SCALE_F64: {
8136 (Src0 == Src1 || Src0 == Src2))
8150 if (Src0.isMachineOpcode() &&
8151 Src0.getMachineOpcode() == AMDGPU::IMPLICIT_DEF) {
8196 if (NoRetAtomicOp != -1) {
8198 MI.
setDesc(TII->get(NoRetAtomicOp));
8216 MI.
setDesc(TII->get(NoRetAtomicOp));
8224 TII->get(AMDGPU::IMPLICIT_DEF),
Def);
8273 uint64_t RsrcDword2And3)
const {
8283 RsrcDword2And3 & UINT64_C(0xFFFFFFFF));
8305 std::pair<unsigned, const TargetRegisterClass *>
8310 if (Constraint.
size() == 1) {
8311 switch (Constraint[0]) {
8318 return std::make_pair(0U,
nullptr);
8321 RC = &AMDGPU::SReg_32_XM0RegClass;
8324 RC = &AMDGPU::SGPR_64RegClass;
8327 RC = &AMDGPU::SReg_128RegClass;
8330 RC = &AMDGPU::SReg_256RegClass;
8333 RC = &AMDGPU::SReg_512RegClass;
8340 return std::make_pair(0U,
nullptr);
8343 RC = &AMDGPU::VGPR_32RegClass;
8346 RC = &AMDGPU::VReg_64RegClass;
8349 RC = &AMDGPU::VReg_96RegClass;
8352 RC = &AMDGPU::VReg_128RegClass;
8355 RC = &AMDGPU::VReg_256RegClass;
8358 RC = &AMDGPU::VReg_512RegClass;
8367 return std::make_pair(0U, RC);
8370 if (Constraint.
size() > 1) {
8371 if (Constraint[1] ==
'v') {
8372 RC = &AMDGPU::VGPR_32RegClass;
8373 }
else if (Constraint[1] ==
's') {
8374 RC = &AMDGPU::SGPR_32RegClass;
8380 if (!Failed && Idx < RC->getNumRegs())
8389 if (Constraint.
size() == 1) {
8390 switch (Constraint[0]) {
8419 MFI.hasVarSizedObjects() ||
8444 const APInt &DemandedElts,
8446 unsigned Depth)
const {
8481 if (TRI.isPhysicalRegister(Reg))
8482 return TRI.
isVGPR(MRI, Reg);
8484 if (MRI.isLiveIn(Reg)) {
8487 if (TRI.
isVGPR(MRI, Reg))
8512 cast<ConstantSDNode>(N->
getOperand(0))->getZExtValue());
8515 cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue());
bool hasBCNT(unsigned Size) const
bool enableIEEEBit(const MachineFunction &MF) const
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
unsigned addImplicitBufferPtr(const SIRegisterInfo &TRI)
unsigned getFrameOffsetReg() const
static void allocateSpecialEntryInputVGPRs(CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
unsigned getScratchWaveOffsetReg() const
void setWorkItemIDX(ArgDescriptor Arg)
bool hasDispatchPtr() const
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
constexpr bool isUInt< 32 >(uint64_t x)
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set, or Regs.size() if they are all allocated.
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array...
static MVT getIntegerVT(unsigned BitWidth)
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
void push_back(const T &Elt)
ArgDescriptor DispatchPtr
const MachineInstrBuilder & add(const MachineOperand &MO) const
BUILTIN_OP_END - This must be the last enum value in this list.
static void r3(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
A parsed version of the target data layout string in and methods for querying it. ...
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EVT getValueType() const
Return the ValueType of the referenced return value.
Interface definition for SIRegisterInfo.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
void setFuncArgInfo(const Function &F, const AMDGPUFunctionArgInfo &ArgInfo)
static void r2(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const SDValue & getOffset() const
bool hasPrivateSegmentBuffer() const
unsigned reservedPrivateSegmentBufferReg(const MachineFunction &MF) const
Return the end register initially reserved for the scratch buffer in case spilling is needed...
CombineLevel getDAGCombineLevel()
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
const GlobalValue * getGlobal() const
bool hasApertureRegs() const
bool isFMAFasterThanFMulAndFAdd(EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents an incoming formal argument to a Function.
unsigned getAddrSpace() const
Diagnostic information for unsupported feature in backend.
SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC, unsigned Reg, EVT VT, const SDLoc &SL, bool RawReg=false) const
Helper function that adds Reg to the LiveIn list of the DAG's MachineFunction.
AMDGPU specific subclass of TargetSubtarget.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
bool isPSInputAllocated(unsigned Index) const
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd)...
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
static ConstantFPSDNode * getSplatConstantFP(SDValue Op)
bool hasPrivateSegmentWaveByteOffset() const
C - The default llvm calling convention, compatible with C.
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
Compute iterated dominance frontiers using a linear time algorithm.
bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &, MachineFunction &MF, unsigned IntrinsicID) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
void analyzeFormalArgumentsCompute(CCState &State, const SmallVectorImpl< ISD::InputArg > &Ins) const
The SelectionDAGBuilder will automatically promote function arguments with illegal types...
value_iterator value_end() const
Type * getParamType(unsigned i) const
Parameter type accessors.
bool isCompareAndSwap() const
Returns true if this SDNode represents cmpxchg atomic operation, false otherwise. ...
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool supportSplitCSR(MachineFunction *MF) const override
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineSDNodes's memory reference descriptor list.
uint64_t getDefaultRsrcDataFormat() const
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
iterator begin() const
begin/end - Return all of the registers in this class.
static bool isBoolSGPR(SDValue V)
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
unsigned getStackPtrOffsetReg() const
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
static void allocateSystemSGPRs(CCState &CCInfo, MachineFunction &MF, SIMachineFunctionInfo &Info, CallingConv::ID CallConv, bool IsShader)
void passSpecialInputs(CallLoweringInfo &CLI, const SIMachineFunctionInfo &Info, SmallVectorImpl< std::pair< unsigned, SDValue >> &RegsToPass, SmallVectorImpl< SDValue > &MemOpChains, SDValue Chain, SDValue StackPtr) const
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain targets require unusual breakdowns of certain types.
SDValue copyToM0(SelectionDAG &DAG, SDValue Chain, const SDLoc &DL, SDValue V) const
bool isVector() const
Return true if this is a vector value type.
bool hasStackObjects() const
Return true if there are any stack objects in this function.
bool isAllocated(unsigned Reg) const
isAllocated - Return true if the specified register (or an alias) is allocated.
const SDValue & getBasePtr() const
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
unsigned getRegister(unsigned i) const
Return the specified register in the class.
bool isNegative() const
Return true if the value is negative.
bool hasFlatGlobalInsts() const
bool canMergeStoresTo(unsigned AS, EVT MemVT, const SelectionDAG &DAG) const override
Returns if it's reasonable to merge stores to MemVT size.
SDValue loadInputValue(SelectionDAG &DAG, const TargetRegisterClass *RC, EVT VT, const SDLoc &SL, const ArgDescriptor &Arg) const
bool supportsMinMaxDenormModes() const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
void setIsUndef(bool Val=true)
bool hasFmaMixInsts() const
MachineMemOperand::Flags flags
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
const SDValue & getValue() const
unsigned addKernargSegmentPtr(const SIRegisterInfo &TRI)
bool hasImplicitBufferPtr() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
SDVTList getVTList() const
This class represents a function call, abstracting a target machine's calling convention.
unsigned addWorkGroupIDY()
unsigned getSubReg() const
void setHasFloatingPointExceptions(bool FPExceptions=true)
Tells the code generator that this target supports floating point exceptions and cares about preservi...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
const GCNSubtarget * getSubtarget() const
float BitsToFloat(uint32_t Bits)
This function takes a 32-bit integer and returns the bit equivalent float.
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
unsigned getVectorNumElements() const
const SDValue & getChain() const
Function Alias Analysis Results
LLVMContext & getContext() const
All values hold a context through their type.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const SIInstrInfo * getInstrInfo() const override
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
Returns an APFloat semantics tag appropriate for the given type.
static bool bitOpWithConstantIsReducible(unsigned Opc, uint32_t Val)
unsigned getAlignment() const
unsigned getPSInputAddr() const
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
Return the ValueType of the result of SETCC operations.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfo(unsigned Dim)
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
bool hasWorkItemIDZ() const
SDNode * legalizeTargetIndependentNode(SDNode *Node, SelectionDAG &DAG) const
Legalize target independent instructions (e.g.
bool isAmdCodeObjectV2(const Function &F) const
static SDValue getFPTernOp(SelectionDAG &DAG, unsigned Opcode, const SDLoc &SL, EVT VT, SDValue A, SDValue B, SDValue C, SDValue GlueChain)
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
static bool isCanonicalized(SelectionDAG &DAG, SDValue Op, const GCNSubtarget *ST, unsigned MaxDepth=5)
void markPSInputEnabled(unsigned Index)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select's if you just have operands and don't want to check...
const fltSemantics & getSemantics() const
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
virtual bool isTypeDesirableForOp(unsigned, EVT VT) const
Return true if the target has native support for the specified value type and it is 'desirable' to us...
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
const SDNodeFlags getFlags() const
MachineFunction & getMachineFunction() const
SDNode * getNode() const
get the SDNode which holds the desired result
ConstantFPSDNode * isConstOrConstSplatFP(SDValue N)
Returns the SDNode if it is a constant splat BuildVector or constant float.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
iv Induction Variable Users
Address space for local memory.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
void reserve(size_type N)
LLVM_READONLY int getAtomicNoRetOp(uint16_t Opcode)
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
CLAMP value between 0.0 and 1.0.
static MachineBasicBlock * emitIndirectDst(MachineInstr &MI, MachineBasicBlock &MBB, const GCNSubtarget &ST)
bool isInlineConstant(const APInt &Imm) const
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
bool hasFastFMAF32() const
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
bool hasDispatchID() const
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
const DebugLoc & getDebugLoc() const
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
const SIRegisterInfo & getRegisterInfo() const
static void allocateSpecialInputSGPRs(CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
return AArch64::GPR64RegClass contains(Reg)
bool isAllOnesValue() const
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
bool hasWorkItemIDX() const
bool hasVOP3PInsts() const
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
unsigned getAddressSpace() const
Return the address space for the associated pointer.
bool hasFP64Denormals() const
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
bool hasFlatScratchInit() const
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
Calling convention used for Mesa/AMDPAL pixel shaders.
MachineSDNode * wrapAddr64Rsrc(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr) const
static SDValue emitRemovedIntrinsicError(SelectionDAG &DAG, const SDLoc &DL, EVT VT)
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
void setPrivateSegmentWaveByteOffset(unsigned Reg)
#define FP_DENORM_FLUSH_NONE
static unsigned numBitsUnsigned(SDValue Op, SelectionDAG &DAG)
void setDebuggerWorkGroupIDStackObjectIndex(unsigned Dim, int ObjectIdx)
Sets stack object index for Dim's work group ID to ObjectIdx.
uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the largest uint64_t less than or equal to Value and is Skew mod Align.
bool hasOneUse() const
Return true if there is exactly one use of this node.
void setScratchRSrcReg(unsigned Reg)
bool isBeforeLegalize() const
static unsigned findFirstFreeSGPR(CCState &CCInfo)
Address space for constant memory (VTX2)
A description of a memory reference used in the backend.
bool useVGPRIndexMode(bool UserEnable) const
unsigned getBytesInStackArgArea() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Shift and rotation operations.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
static bool isGather4(const MachineInstr &MI)
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
void setHasNonSpillStackObjects(bool StackObject=true)
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
unsigned addDispatchID(const SIRegisterInfo &TRI)
bool isEntryFunction() const
static bool isMIMG(const MachineInstr &MI)
void setDebuggerWorkItemIDStackObjectIndex(unsigned Dim, int ObjectIdx)
Sets stack object index for Dim's work item ID to ObjectIdx.
void setIfReturnsVoid(bool Value)
bool enableDX10Clamp() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static void allocateHSAUserSGPRs(CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
The returned value is undefined.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
bool isMemOpUniform(const SDNode *N) const
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
static unsigned SubIdx2Lane(unsigned Idx)
Helper function for adjustWritemask.
CopyToReg - This node has three operands: a chain, a register number to set to this value...
MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
static bool mayTailCallThisCC(CallingConv::ID CC)
Return true if we might ever do TCO for calls with this calling convention.
op_iterator op_end() const
uint64_t getConstantOperandVal(unsigned i) const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
static ArgDescriptor allocateSGPR64Input(CCState &CCInfo)
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) For double-word atomic operations: ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) These correspond to the atomicrmw instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
bool isTrapHandlerEnabled() const
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
unsigned reservedStackPtrOffsetReg(const MachineFunction &MF) const
This is an SDNode representing atomic operations.
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels)
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
LocInfo getLocInfo() const
bool isSGPRClass(const TargetRegisterClass *RC) const
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SmallVector< ISD::InputArg, 32 > Ins
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
unsigned getSizeInBits() const
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
static void reservePrivateMemoryRegs(const TargetMachine &TM, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
unsigned getScalarSizeInBits() const
static void allocateSpecialInputVGPRs(CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
Class to represent function types.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
int64_t getSExtValue() const
Get sign extended value.
SDValue SplitVectorLoad(SDValue Op, SelectionDAG &DAG) const
Split a vector load into 2 loads of half the vector.
Type * getType() const
All values are typed, get the type of this value.
MachineFunction & getMachineFunction() const
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
void setStackPtrOffsetReg(unsigned Reg)
void limitOccupancy(const MachineFunction &MF)
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
bool useFlatForGlobal() const
SDValue getRegisterMask(const uint32_t *RegMask)
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT) const
Return the preferred vector type legalization action.
const TargetMachine & getTarget() const
Simple integer binary arithmetic operators.
SITargetLowering(const TargetMachine &tm, const GCNSubtarget &STI)
SmallVector< ISD::OutputArg, 32 > Outs
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool enableAggressiveFMAFusion(EVT VT) const override
Return true if target always beneficiates from combining into FMA for a given value type...
const ImageDimIntrinsicInfo * getImageDimIntrinsicInfo(unsigned Intr)
static unsigned minMaxOpcToMin3Max3Opc(unsigned Opc)
uint32_t getImplicitParameterOffset(const MachineFunction &MF, const ImplicitParameter Param) const
Helper function that returns the byte offset of the given type of implicit parameter.
ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
std::pair< SDValue, SDValue > split64BitValue(SDValue Op, SelectionDAG &DAG) const
Return 64-bit value Op as two 32-bit integers.
static bool parseCachePolicy(SDValue CachePolicy, SelectionDAG &DAG, SDValue *GLC, SDValue *SLC)
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
op_iterator op_begin() const
static SDValue getLoadExtOrTrunc(SelectionDAG &DAG, ISD::LoadExtType ExtType, SDValue Op, const SDLoc &SL, EVT VT)
std::pair< SDValue, SDValue > expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Expands an unaligned load to 2 half-size loads for an integer, and possibly more for vectors...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
bool getAddrModeArguments(IntrinsicInst *, SmallVectorImpl< Value *> &, Type *&) const override
CodeGenPrepare sinks address calculations into the same BB as Load/Store instructions reading the add...
void insertCopiesSplitCSR(MachineBasicBlock *Entry, const SmallVectorImpl< MachineBasicBlock *> &Exits) const override
Insert explicit copies in entry and exit blocks.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool parametersInCSRMatch(const MachineRegisterInfo &MRI, const uint32_t *CallerPreservedMask, const SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< SDValue > &OutVals) const
Check whether parameters to a call that are passed in callee saved registers are the same as from the...
static bool convertBuildVectorCastElt(SelectionDAG &DAG, SDValue &Lo, SDValue &Hi)
unsigned getUndefRegState(bool B)
void markPSInputAllocated(unsigned Index)
bool hasWorkGroupIDX() const
amdgpu Simplify well known AMD library false Value * Callee
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
mmo_iterator memoperands_end() const
static SDValue emitNonHSAIntrinsicError(SelectionDAG &DAG, const SDLoc &DL, EVT VT)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
unsigned getSrcAddressSpace() const
MVT getVectorElementType() const
Class to represent pointers.
unsigned getByValSize() const
UNDEF - An undefined node.
This class is used to represent ISD::STORE nodes.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
uint32_t FloatToBits(float Float)
This function takes a float and returns the bit equivalent 32-bit integer.
SDValue splitBinaryVectorOp(SDValue Op, SelectionDAG &DAG) const
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
bool hasAllowReciprocal() const
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
const Value * getValue() const
Return the base address of the memory access.
Value * getOperand(unsigned i_nocapture) const
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
static bool isFlatGlobalAddrSpace(unsigned AS, AMDGPUAS AMDGPUASI)
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool hasUnalignedBufferAccess() const
bool hasAllowContract() const
The memory access is volatile.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool hasFP32Denormals() const
const SDValue & getBasePtr() const
static bool fp16SrcZerosHighBits(unsigned Opc)
A switch()-like statement whose cases are string literals.
initializer< Ty > init(const Ty &Val)
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
Control flow instructions. These all have token chains.
bool isMemOpHasNoClobberedMemOperand(const SDNode *N) const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
MachineBasicBlock * splitKillBlock(MachineInstr &MI, MachineBasicBlock *BB) const
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
unsigned addWorkGroupInfo()
unsigned reservedPrivateSegmentWaveByteOffsetReg(const MachineFunction &MF) const
Return the end register initially reserved for the scratch wave offset in case spilling is needed...
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
Simple binary floating point operators.
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
bool hasAnyUseOfValue(unsigned Value) const
Return true if there are any use of the indicated value.
bool isMachineOpcode() const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
size_t size() const
size - Get the array size.
SDNode * PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override
Fold the instructions after selecting them.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getReturnAddressReg(const MachineFunction &MF) const
const RsrcIntrinsic * lookupRsrcIntrinsic(unsigned Intr)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
const SDValue & getOperand(unsigned Num) const
bool hasFPExceptions() const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
bool hasBitPreservingFPLogic(EVT VT) const override
Return true if it is safe to transform an integer-domain bitwise operation into the equivalent floati...
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(PreloadedValue Value) const
const GlobalValue * getGlobal() const
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
bool has16BitInsts() const
EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, MachineFunction &MF) const override
Returns the target specific optimal type for load and store operations as a result of memset...
bool isSDNodeSourceOfDivergence(const SDNode *N, FunctionLoweringInfo *FLI, DivergenceAnalysis *DA) const override
bool isEntryFunctionCC(CallingConv::ID CC)
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
static bool isUniformMMO(const MachineMemOperand *MMO)
bool isEligibleForTailCallOptimization(SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SmallVectorImpl< ISD::InputArg > &Ins, SelectionDAG &DAG) const
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
Split the node's operand with EXTRACT_SUBVECTOR and return the low/high part.
virtual SDValue LowerGlobalAddress(AMDGPUMachineFunction *MFI, SDValue Op, SelectionDAG &DAG) const
virtual void computeKnownBitsForFrameIndex(const SDValue FIOp, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
Determine which of the bits of FrameIndex FIOp are known to be 0.
const AMDGPUBufferPseudoSourceValue * getBufferPSV(const SIInstrInfo &TII, const Value *BufferRsrc)
SI DAG Lowering interface definition.
unsigned getDestAddressSpace() const
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
bool mayBeEmittedAsTailCall(const CallInst *) const override
Return true if the target may be able emit the call instruction as a tail call.
static ArgDescriptor createRegister(unsigned Reg)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This class provides iterator support for SDUse operands that use a specific SDNode.
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
unsigned getMachineOpcode() const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
unsigned addQueuePtr(const SIRegisterInfo &TRI)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
static unsigned getMOVRELDPseudo(const SIRegisterInfo &TRI, const TargetRegisterClass *VecRC)
TRAP - Trapping instruction.
bool hasWorkItemIDY() const
const APInt & getAPIntValue() const
Generation getGeneration() const
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline...
const Triple & getTargetTriple() const
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static bool resultsCompatible(CallingConv::ID CalleeCC, CallingConv::ID CallerCC, MachineFunction &MF, LLVMContext &C, const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn CalleeFn, CCAssignFn CallerFn)
Returns true if the results of the two calling conventions are compatible.
DEBUGTRAP - Trap intended to get the attention of a debugger.
static SDValue getMad64_32(SelectionDAG &DAG, const SDLoc &SL, EVT VT, SDValue N0, SDValue N1, SDValue N2, bool Signed)
#define FP_DENORM_FLUSH_IN_FLUSH_OUT
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
self_iterator getIterator()
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
bool hasWorkGroupIDY() const
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
static std::pair< unsigned, int > computeIndirectRegAndOffset(const SIRegisterInfo &TRI, const TargetRegisterClass *SuperRC, unsigned VecReg, int Offset)
AMDGPUFunctionArgInfo & getArgInfo()
The AMDGPU TargetMachine interface definition for hw codgen targets.
void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
If Opc/OrigVT is specified as being promoted, the promotion code defaults to trying a larger integer/...
static void r1(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
Bit counting operators with an undefined result for zero inputs.
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
static MachineBasicBlock * emitIndirectSrc(MachineInstr &MI, MachineBasicBlock &MBB, const GCNSubtarget &ST)
const Pass * getPass() const
unsigned REGION_ADDRESS
Address space for region memory.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void setScratchWaveOffsetReg(unsigned Reg)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This structure contains all information that is necessary for lowering calls.
bool hasUnalignedScratchAccess() const
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
const TargetMachine & getTargetMachine() const
This class contains a discriminated union of information about pointers in memory operands...
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getNumOperands() const
Return the number of values used by this operation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
TrapHandlerAbi getTrapHandlerAbi() const
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
constexpr char NumSGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSGPRs.
bool hasImplicitArgPtr() const
bool isKnownNeverNaN(SDValue Op) const
Test whether the given SDValue is known to never be NaN.
SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value...
unsigned addDispatchPtr(const SIRegisterInfo &TRI)
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
Triple - Helper class for working with autoconf configuration names.
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding, unsigned VDataDwords, unsigned VAddrDwords)
static CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg)
Selects the correct CCAssignFn for a given CallingConvention value.
bool hasUnpackedD16VMem() const
unsigned getAddressSpace() const
unsigned getQueuePtrUserSGPR() const
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
The memory access writes data.
void setHasExtractBitsInsn(bool hasExtractInsn=true)
Tells the code generator that the target has BitExtract instructions.
bool getScalarizeGlobalBehavior() const
unsigned getStackOffset() const
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
uint64_t getNullPointerValue(unsigned AddrSpace) const
Get the integer value of a null pointer in the given address space.
static bool setM0ToIndexFromSGPR(const SIInstrInfo *TII, MachineRegisterInfo &MRI, MachineInstr &MI, int Offset, bool UseGPRIdxMode, bool IsIndirectSrc)
bool hasFlatAddressSpace() const
unsigned getWavefrontSize() const
static SDValue buildPCRelGlobalAddress(SelectionDAG &DAG, const GlobalValue *GV, const SDLoc &DL, unsigned Offset, EVT PtrVT, unsigned GAFlags=SIInstrInfo::MO_NONE)
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
SDValue addTokenForArgument(SDValue Chain, SelectionDAG &DAG, MachineFrameInfo &MFI, int ClobberedFI) const
static ArgDescriptor allocateSGPR32InputImpl(CCState &CCInfo, const TargetRegisterClass *RC, unsigned NumArgRegs)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override
EVT is not used in-tree, but is used by out-of-tree target.
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
MachineSDNode * buildRSRC(SelectionDAG &DAG, const SDLoc &DL, SDValue Ptr, uint32_t RsrcDword1, uint64_t RsrcDword2And3) const
Return a resource descriptor with the 'Add TID' bit enabled The TID (Thread ID) is multiplied by the ...
const TargetLowering & getTargetLoweringInfo() const
bool enableHugePrivateBuffer() const
Iterator for intrusive lists based on ilist_node.
Address space for 32-bit constant memory.
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
CCState - This class holds information needed while lowering arguments and return values...
void setNoUnsignedWrap(bool b)
unsigned countPopulation(T Value)
Count the number of set bits in a value.
SDValue scalarizeVectorLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Turn load of vector type into a load of the individual elements.
static ArgDescriptor allocateSGPR32Input(CCState &CCInfo)
static uint32_t getPermuteMask(SelectionDAG &DAG, SDValue V)
bool isFPExtFoldable(unsigned Opcode, EVT DestVT, EVT SrcVT) const override
Return true if an fpext operation input to an Opcode operation is free (for instance, because half-precision floating-point numbers are implicitly extended to float-precision) for an FMA instruction.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
This is the shared class of boolean and integer constants.
bool hasKernargSegmentPtr() const
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(EVT VT) const override
Return the preferred vector type legalization action.
Returns platform specific canonical encoding of a floating point number.
static bool isKnownNeverSNan(SelectionDAG &DAG, SDValue Op)
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
testing::Matcher< const detail::ErrorHolder & > Failed()
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
unsigned getLDSSize() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasFloatingPointExceptions() const
Return true if target supports floating point exceptions.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue lowerUnhandledCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals, StringRef Reason) const
bool hasMadMixInsts() const
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
ADDRSPACECAST - This operator converts between pointers of different address spaces.
MachineOperand class - Representation of each machine instruction operand.
value_iterator value_begin() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
const DebugLoc & getDebugLoc() const
CCValAssign - Represent assignment of one arg/retval to a location.
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
BRCOND - Conditional branch.
An SDNode that represents everything that will be needed to construct a MachineInstr.
bool hasMin3Max3_16() const
Byte Swap and Counting operators.
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
static SDValue getFPBinOp(SelectionDAG &DAG, unsigned Opcode, const SDLoc &SL, EVT VT, SDValue A, SDValue B, SDValue GlueChain)
This is an abstract virtual class for memory operations.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
AMDGPUAS getAMDGPUAS() const
LLVM_READNONE bool isKernel(CallingConv::ID CC)
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static uint32_t getConstantPermuteMask(uint32_t C)
static MachineBasicBlock::iterator loadM0FromVGPR(const SIInstrInfo *TII, MachineBasicBlock &MBB, MachineInstr &MI, unsigned InitResultReg, unsigned PhiReg, int Offset, bool UseGPRIdxMode, bool IsIndirectSrc)
void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0)
Append the extracted elements from Start to Count out of the vector Op in Args.
Represents one node in the SelectionDAG.
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
static SDNode * findUser(SDValue Value, unsigned Opcode)
Helper function for LowerBRCOND.
void setWorkItemIDZ(ArgDescriptor Arg)
static bool allUsesHaveSourceMods(const SDNode *N, unsigned CostThreshold=4)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getVectorNumElements() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
unsigned getPrivateSegmentWaveByteOffsetSystemSGPR() const
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT...
EVT getMemoryVT() const
Return the type of the in-memory value.
Target - Wrapper for Target specific information.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
bool isShader(CallingConv::ID cc)
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
Interface for the AMDGPU Implementation of the Intrinsic Info class.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
void finalizeLowering(MachineFunction &MF) const override
Execute target specific actions to finalize target lowering.
static SDValue getBuildDwordsVector(SelectionDAG &DAG, SDLoc DL, ArrayRef< SDValue > Elts)
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
static use_iterator use_end()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Calling convention for AMDGPU code object kernels.
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
AddrMode
ARM Addressing Modes.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
ANY_EXTEND - Used for integer types. The high bits are undefined.
static unsigned numBitsSigned(SDValue Op, SelectionDAG &DAG)
bool isDivergent(const Value *V) const
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
iterator insert(iterator I, T &&Elt)
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors...
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
Address space for global memory (RAT0, VTX0).
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, unsigned Align, bool *IsFast) const override
Determine if the target supports unaligned memory accesses.
void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const override
Assign the register class depending on the number of bits set in the writemask.
static bool isVOP3(const MachineInstr &MI)
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
unsigned addPrivateSegmentBuffer(const SIRegisterInfo &TRI)
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
amdgpu Simplify well known AMD library false Value Value * Arg
const MachineBasicBlock * getParent() const
unsigned addFlatScratchInit(const SIRegisterInfo &TRI)
static CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
std::pair< const ArgDescriptor *, const TargetRegisterClass * > getPreloadedValue(AMDGPUFunctionArgInfo::PreloadedValue Value) const
unsigned getPSInputEnable() const
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isCheapAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast from SrcAS to DestAS is "cheap", such that e.g.
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
mmo_iterator memoperands_begin() const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
These are IR-level optimization flags that may be propagated to SDNodes.
static SDValue buildSMovImm32(SelectionDAG &DAG, const SDLoc &DL, uint64_t Val)
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array...
unsigned PartOffset
Offset in bytes of current output value relative to the beginning of original argument.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
SmallVector< SDValue, 32 > OutVals
Interface definition for SIInstrInfo.
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
unsigned getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
bool isVector() const
Return true if this is a vector value type.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
static cl::opt< unsigned > AssumeFrameIndexHighZeroBits("amdgpu-frame-index-zero-bits", cl::desc("High bits of frame index assumed to be zero"), cl::init(5), cl::ReallyHidden)
void emplace_back(ArgTypes &&... Args)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getLocMemOffset() const
LLVM_NODISCARD bool empty() const
static MachineBasicBlock::iterator emitLoadM0FromVGPRLoop(const SIInstrInfo *TII, MachineRegisterInfo &MRI, MachineBasicBlock &OrigBB, MachineBasicBlock &LoopBB, const DebugLoc &DL, const MachineOperand &IdxReg, unsigned InitReg, unsigned ResultReg, unsigned PhiReg, unsigned InitSaveExecReg, int Offset, bool UseGPRIdxMode, bool IsIndirectSrc)
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
static bool isClampZeroToOne(SDValue A, SDValue B)
PointerUnion< const Value *, const PseudoSourceValue * > ptrVal
SDValue splitBinaryBitConstantOpImpl(DAGCombinerInfo &DCI, const SDLoc &SL, unsigned Opc, SDValue LHS, uint32_t ValLo, uint32_t ValHi) const
Split the 64-bit value LHS into two 32-bit components, and perform the binary operation Opc to it wit...
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned FLAT_ADDRESS
Address space for flat memory.
static cl::opt< bool > EnableVGPRIndexMode("amdgpu-vgpr-index-mode", cl::desc("Use GPR indexing mode instead of movrel for vector indexing"), cl::init(false))
bool isShuffleMaskLegal(ArrayRef< int >, EVT) const override
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations, those with specific masks.
static ArgDescriptor createStack(unsigned Reg)
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Flags getFlags() const
Return the raw flags of the source value,.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
The memory access always returns the same value (or traps).
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
bool hasFlatInstOffsets() const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool shouldEmitConstantsToTextSection(const Triple &TT)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
SDValue splitUnaryVectorOp(SDValue Op, SelectionDAG &DAG) const
const Value * getValueFromVirtualReg(unsigned Vreg)
This method is called from TargetLowerinInfo::isSDNodeSourceOfDivergence to get the Value correspondi...
unsigned addWorkGroupIDZ()
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static void r0(uint32_t &A, uint32_t &B, uint32_t &C, uint32_t &D, uint32_t &E, int I, uint32_t *Buf)
unsigned getOpcode() const
FSINCOS - Compute both fsin and fcos as a single operation.
SDValue getValue(unsigned R) const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
bool isInfinity() const
Return true if the value is an infinity.
constexpr bool isUInt< 16 >(uint64_t x)
void setSimpleHint(unsigned VReg, unsigned PrefReg)
Specify the preferred (target independent) register allocation hint for the specified virtual registe...
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getCondCode(ISD::CondCode Cond)
static bool isFrameIndexOp(SDValue Op)
bool hasWorkGroupInfo() const
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
const MachinePointerInfo & getPointerInfo() const
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
unsigned addPrivateSegmentWaveByteOffset()
unsigned getRegister() const
SDValue storeStackInputValue(SelectionDAG &DAG, const SDLoc &SL, SDValue Chain, SDValue StackPtr, SDValue ArgVal, int64_t Offset) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, unsigned Alignment=1, bool *Fast=nullptr) const
Return true if the target supports a memory access of this type for the given address space and align...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
static bool canGuaranteeTCO(CallingConv::ID CC)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
static ArgDescriptor allocateVGPR32Input(CCState &CCInfo)
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
FMA - Perform a * b + c with no intermediate rounding step.
const AMDGPUImagePseudoSourceValue * getImagePSV(const SIInstrInfo &TII, const Value *ImgRsrc)
SDValue getRegister(unsigned Reg, EVT VT)
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
virtual void finalizeLowering(MachineFunction &MF) const
Execute target specific actions to finalize target lowering.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
EVT changeTypeToInteger()
Return the type converted to an equivalently sized integer or vector with integer element type...
bool hasNoUnsignedWrap() const
SDValue getValueType(EVT)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static SDValue adjustLoadValueTypeImpl(SDValue Result, EVT LoadVT, const SDLoc &DL, SelectionDAG &DAG, bool Unpacked)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
void computeKnownBitsForFrameIndex(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits of FrameIndex FIOp are known to be 0.
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone...
static EVT getEquivalentMemType(LLVMContext &Context, EVT VT)
Primary interface to the complete machine description for the target machine.
bool hasWorkGroupIDZ() const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const APFloat & getValueAPF() const
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
StringRef - Represent a constant reference to a string, i.e.
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations...
SetCC operator - This evaluates to a true value iff the condition is true.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
APInt bitcastToAPInt() const
void setWorkItemIDY(ArgDescriptor Arg)
SDValue SplitVectorStore(SDValue Op, SelectionDAG &DAG) const
Split a vector store into 2 stores of half the vector.
unsigned getNumOperands() const
bool isTypeDesirableForOp(unsigned Op, EVT VT) const override
Return true if the target has native support for the specified value type and it is 'desirable' to us...
const SDValue & getOperand(unsigned i) const
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
unsigned getLocReg() const
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
uint64_t getZExtValue() const
TRUNCATE - Completely drop the high bits.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static void Split(std::vector< std::string > &V, StringRef S)
Splits a string of comma separated items in to a vector of strings.
SDValue LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals, bool isThisReturn, SDValue ThisVal) const
void setBytesInStackArgArea(unsigned Bytes)
std::pair< unsigned, unsigned > getFlatWorkGroupSizes(const Function &F) const
unsigned AllocateReg(unsigned Reg)
AllocateReg - Attempt to allocate one register.
unsigned addWorkGroupIDX()
unsigned getLiveInVirtReg(unsigned PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in physical ...
const MachineOperand & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
unsigned getMaxPrivateElementSize() const
static void processShaderInputArgs(SmallVectorImpl< ISD::InputArg > &Splits, CallingConv::ID CallConv, ArrayRef< ISD::InputArg > Ins, BitVector &Skipped, FunctionType *FType, SIMachineFunctionInfo *Info)
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
unsigned AllocateStack(unsigned Size, unsigned Align)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
static IntegerType * getInt8Ty(LLVMContext &C)
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
const SDValue & getBasePtr() const
LLVMContext * getContext() const
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const override
Return true if it is beneficial to convert a load of a constant to just the constant itself...
PointerType * getType() const
Global values are always pointers.
void initializeSplitCSR(MachineBasicBlock *Entry) const override
Perform necessary initialization to handle a subset of CSRs explicitly via copies.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned PRIVATE_ADDRESS
Address space for private memory.
Carry-using nodes for multiple precision addition and subtraction.
iterator_range< arg_iterator > args()
bool empty() const
empty - Check if the array is empty.
cmpResult compare(const APFloat &RHS) const
A wrapper class for inspecting calls to intrinsic functions.
mmo_iterator memoperands_end() const
const BasicBlock * getParent() const
unsigned getRegisterByName(const char *RegName, EVT VT, SelectionDAG &DAG) const override
Return the register ID of the name passed in.
bool hasCalls() const
Return true if the current function has any function calls.
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
const fltSemantics & getFltSemantics() const
bool hasFP16Denormals() const
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
This class is used to represent ISD::LOAD nodes.
const SIRegisterInfo * getRegisterInfo() const override